% Blocks' world adopted from Ilkka Niemelä's representation % (c) Tomi Janhunen % % usage: lparse -ck= bw.lp | smodels 0 %%% Points of time %%% time(0..k). hide time(T). %%% Initial situation %%% on(a,b,0). on(b,c,0). on(c,f,0). on(d,f,0). clear(a,0). clear(d,0). hide clear(X,T). hide on(X,Y,T). %%% Final situation (after at most k actions) %%% :- not on(b,a,k). %%% Domain/auxiliary predicates %%% block(a). block(b). block(c). block(d). object(X) :- block(X). % The floor which cannot be moved, is never clear, and holds several blocks object(f). % Define objects that can hold blocks can_hold(f,T) :- time(T). can_hold(Z,T) :- clear(Z,T), block(Z), time(T). % Triples of objects that are potentially subject to move operations diff(X,Y,Z) :- X!=Z, X!=Y, Y!=Z, block(X), object(Y;Z). hide block(X). hide object(X). hide can_hold(Z,T). hide diff(X,Y,Z). %%% Operator MOVE(X,Y,Z,T) %%% move(X,Y,Z,T) :- clear(X,T), on(X,Y,T), can_hold(Z,T), not denied_move(X,Y,Z,T), diff(X,Y,Z), time(T), T