The files in this directory are organized according to the
following conventions:

1. file.pddl - an action domain description in PDDL. They
   came from the PDDL planning domain library distributed
   along with the first version of the PDDL standard by
   McDermott and others.
2. file.pl - our reformulation of file.pddl in Prolog.
   They are in the style of acton domain descriptions
   given in the paper. The special Prolog notations are
   described below.
3. file-out.sht - the STRIPS-like output of our CCP procedure
   on file.pl
4. file-out.lng - the complete set of fully instantiated
   successor state axioms returned by our program on file.pl
5. The logical operators used in file.pl are: - (negation),
   & (and), \/ (or), <-> (equivalence), -> (implication),
   all(x, p, W) (W holds for all x in p),
   some(x, p, W) (W holds for some x in p).

To help you understand file.pl, we give a detailed explanation of
blocks1.pl below. Comments in Prolog are enclosed in /* ... */.
Comments that I made here are after %.

*************** blocks1.pl **************

/* The blocks world with four actions: pickup(X), putdown(X), stack(X,Y),
and unstack(X,Y). Of special interest is the preconditions of pickup(X) -
normally this action is intended for the robot to pickup a block that is
on the table and clear, so ontable(X) is a precondition. However, if one
delete this precondition, meaning we allow the robot to pick up X from
anywhere as long as it is clear, then the underlying causal rules will make
this action context-dependent. For instance, if X is on Y initially, then
Y will be clear afterward. 

The standard version is given here. The one that drops ontable(X) as
a precondition is given in blocks2.pl
*/

% Directives telling Prolog to ignore certain style checks.
:- style_check(-singleton).
:- style_check(-discontiguous).

% Domain(block, {1,2,3}) in the paper. Names started with a capital
% letter are Prolog variables. Read ":-" as "if".
block(X) :- member(X, [1,2,3]).

% Fluent definitions 
fluent(on(X,Y)) :- block(X), block(Y).
fluent(clear(X)) :- block(X).
fluent(ontable(X)) :- block(X).
fluent(holding(X)) :- block(X).
fluent(handempty).


/* clear and handempty are defined fluents */

defined(clear(X), -some(x,block(x),on(x,X)) & -holding(X)) :- fluent(clear(X)).
defined(handempty, -some(x, block(x),holding(x))).

% Domain rules. Conditions like "fluent(on(X,Y))" are needed so
% that Prolog can properly instantiate variables "X" and "Y".
% "\==" is "not equal to" in Prolog.
causes(on(X,Y), -on(Z,Y)) :- fluent(on(X,Y)), fluent(on(Z,Y)), X\==Z.
causes(on(X,Y), -on(X,Z)) :- fluent(on(X,Y)), fluent(on(X,Z)), Y\==Z.
causes(on(X,Y), -ontable(X)) :- fluent(on(X,Y)).
causes(on(X,Y), -holding(X)) :- fluent(on(X,Y)).
causes(on(X,Y), -holding(Y)) :- fluent(on(X,Y)).
causes(ontable(X), -on(X,Y)) :-  fluent(on(X,Y)).
causes(ontable(X), -holding(X)) :-  fluent(ontable(X)).
causes(holding(X), -ontable(X)) :-   fluent(ontable(X)).
causes(holding(X), -on(X,Y)) :-   fluent(on(X,Y)).
causes(holding(X), -on(Y,X)) :-   fluent(on(X,Y)).
causes(holding(X), -holding(Y)) :-   fluent(on(X,Y)), X\==Y.

action(stack(X,Y)) :- block(X), block(Y), X\==Y. 
poss(stack(X,Y),holding(X)).
poss(stack(X,Y),clear(Y)).
effect(stack(X,Y),true,on(X,Y)).

action(unstack(X,Y)) :- block(X), block(Y), X\==Y. 
poss(unstack(X,Y),on(X,Y)).
poss(unstack(X,Y),clear(X)).
poss(unstack(X,Y),handempty).
effect(unstack(X,Y),true,holding(X)).

action(putdown(X)) :- block(X).
poss(putdown(X),holding(X)).
effect(putdown(X),true,ontable(X)).

action(pickup(X)) :- block(X).
poss(pickup(X), clear(X)).
poss(pickup(X), handempty).
poss(pickup(X), ontable(X)).  /* delete this to get blocks2.pl */
effect(pickup(X), true, holding(X)).

*************** END OF blocks1.pl ***************

Comments to flin@cs.ust.hk
http://www.cs.ust.hk/~flin
