1% A SIMPLE STRIPS PLANNER USING STRIPS NOTATION
    2
    3%achieve_all(Gs,S0,S1,U0,U1) is true if every element of list Gs can be 
    4%   achieved  going from state S0 to state S1.
    5% U0 is the bound on the number of actions going into achieve_all 
    6%   and U1 is the limit coming out
    7
    8achieve_all([],World,World,U,U).
    9achieve_all(Gs,W0,W2,U0,U2) <-
   10   remove(G1,Gs,Gr) &
   11   achieve(G1,W0,W1,U0,U1) &
   12   achieve_all(Gr,W1,W2,U1,U2).
   13
   14% achieve(G,S0,S1) is true if goal G can be achieved going from S0 to S1
   15
   16achieve(G,W,W,U,U) <-              % goals already true
   17   true_in(G,W).
   18achieve(G,W0,W1,U0,U1) <-          % derived relations
   19   clause(G, Body) &
   20   achieve_all(Body,W0,W1,U0,U1).
   21achieve(A \= B,W,W,U,U) <-         % inequality constraints
   22   A \= B.
   23achieve(G,W0,do(Act,W1),U0,U2) <-  % primitive relations
   24   U0>0 &
   25   U1 is U0-1 &
   26   achieves(Act,G) &
   27   preconditions(Act,PreAct) &
   28   achieve_all(PreAct,W0,W1,U1,U2).
   29
   30% remove(Elt,List,RemainingElts).
   31remove(X,[X|Y],Y).
   32
   33% true_in(Goal,State) is true if Goal is true in State.
   34true_in(G,init) <-
   35   holds(G,init).
   36true_in(G,do(A,_)) <-
   37   achieves(A,G).
   38true_in(G,do(A,S)) <-
   39   true_in(G,S) &
   40   ~ deletes(A,G).
   41
   42% TRY THE FOLLOWING QUERIES with delrob_strips.pl:
   43% ask achieve(carrying(rob,k1),init,S,10,_).
   44% ask achieve(at(k1,lab2),init,S,6,N).
   45% ask achieve_all([carrying(rob,parcel),sitting_at(rob,lab2)],init,S,10,N).
   46% ask achieve_all([sitting_at(rob,lab2),carrying(rob,parcel)],init,S,10,N).
   47%    is the plan returned correct?