/* * airplane example from text */ /* * can(Op, L) means that the conditions listed in L * must be part of the current state in order to apply the * operator Op. */ can(load(C,P,A),[at(C,A),at(P,A)]) :- cargo(C),plane(P),airport(A). can(unload(C,P,A),[in(C,P),at(P,A)]) :- cargo(C),plane(P),airport(A). can(fly(P,From,To),[at(P,From)]) :- plane(P),airport(From),airport(To). /* * del(Op, L) is true if L is a list of conditions which * are removed from the current state by the operator Op. */ del(load(C,P,A), [at(C,A)]). del(unload(C,P,A), [in(C,P)]). del(fly(P,From,To), [at(P,From)]). /* * add(Op, L) is true if L is a list of conditions which * are added to the current state by the operator Op. */ add(load(C,P,A), [in(C,P)]). add(unload(C,P,A), [at(C,A)]). add(fly(P,From,To), [at(P,To)]). /* * List facts which can't occur at the same time in * a state description */ impossible(at(X,A),Goals) :- member(at(X,B),Goals),A \== B ; %%denotes logical OR member(in(X,_),Goals). impossible(in(C,_),Goals) :- member(at(C,_),Goals). /* * Define a specific problem instance */ cargo(c1). cargo(c2). plane(p1). plane(p2). airport(sfo). airport(jfk). init1([at(c1,sfo),at(c2,jfk),at(p1,sfo),at(p2,jfk)]). goal1([at(c1,jfk),at(c2,sfo)]).