% defining location, type

location(home).
location(school).
location(station).

station(station).
station(school).

company(paymeter).
company(payflat).

% actions 

action(bus(L1,L2)):- 
	station(L1), station(L2), neq(L1, L2).
action(train(L1,L2)):- 
	station(L1), station(L2), neq(L1, L2).
action(taxi(L1,L2)):- 
	location(L1), location(L2), neq(L1, L2).
action(walk(L1,L2)):- 
	location(L1), location(L2), neq(L1, L2).
action(callTaxi(L,C)):- 
	location(L), company(C).

% fluents

fluent(at(L)):- location(L).
fluent(taxiAvl(L)):- location(L).
fluent(hasMoney).

% executable condition

executable(bus(L1,L2), [at(L1), hasMoney]):- 
	action(bus(L1,L2)).
executable(train(L1,L2), [at(L1), hasMoney]):- 
	action(train(L1,L2)).
executable(walk(L1,L2), [at(L1)]):- 
	action(walk(L1,L2)).
executable(taxi(L1,L2), [at(L1), hasMoney, taxiAvl(L1)]):- 
	action(taxi(L1,L2)).
executable(callTaxi(L,C), [at(L), hasMoney]):- 
	action(callTaxi(L,C)).

% effects 

causes(bus(L1,L2), at(L2), []):- 
	action(bus(L1,L2)).

causes(train(L1,L2), at(L2), []):- 
	action(train(L1,L2)).

causes(taxi(L1,L2), at(L2), []):- 
	action(taxi(L1,L2)).

causes(walk(L1,L2), at(L2), []):-
        action(walk(L1,L2)).

causes(taxi(L1,L2), neg(hasMoney), []):- 
	action(taxi(L1,L2)).

causes(callTaxi(L,C), taxiAvl(L), []):-
	action(callTaxi(L,C)).

% static causal laws

caused(neg(at(L1)),[at(L2)]):-
	location(L1), location(L2), neq(L1, L2).

% initial conditions

initially(at(home)).
initially(hasMoney).
initially(neg(taxiAvl(L))):- location(L).



% goal 

finally(at(school)).







