% File 'bw': blocks world representation by Ilkka Niemela % modifed by Yuliya Babovich % % Command line per avere tutti i possibili piani: % lparse < filename | smodels 0 % Attenzione! Cambiando situazione iniziale puo' essere necessario aumentare time = numero max passi time(0..5). % goal predicate which holds when the goal conditions have be reached goal :- time(T), goal(T). :- not goal. % goal(T) holds for all subsequent situations % This is used for blocking all operators after the goal has been reached goal(T2) :- nextstate(T2,T1), goal(T1). goal(T) :- time(T), on(b,table,T), on(c,b,T), on(a,c,T). % Stop applying operators when the goal has been reached % operator preconditions {moveop(X,Y,T)}:- time(T), block(X), object(Y), X != Y, not covered(X,T), not covered(Y,T), not goal(T). % operator effects on(X,Y,T2) :- block(X), object(Y), nextstate(T2,T1), moveop(X,Y,T1). covered(X,T) :- block(Z), block(X), time(T), on(Z,X,T). % frame axioms on(X,Y,T2) :- nextstate(T2,T1), block(X), object(Y), on(X,Y,T1), not moving(X,T1). moving(X,T) :- time(T), block(X), object(Y), moveop(X,Y,T). % An object cannot be moved on top of an object that is moved :-block(X), object(Y), block(Z), time(T), moveop(X,Y,T), moveop(Z,X,T). % An object can be moved by one move operation at a time :-2{moveop(X,Y,T):block(X)}, object(Y),time(T). % Two objects cannot be moved on top of the same object by % one move operation at a time :-2{moveop(X,Y,T):block(Y)}, block(X),time(T). % pruning rules % do not move blocks from table to table :- block(X), time(T), moveop(X,table,T), on(X,table,T). % do not move a block on top of something and then on the table :- nextstate(T2,T1), block(X), object(Y), moveop(X,Y,T1), moveop(X,table,T2). nextstate(Y,X) :- time(X), time(Y), Y = X + 1. object(table). object(X) :- block(X). % stato iniziale block(a). block(b). block(c). on(a,table,0). on(b,a,0). on(c,b,0). % predicati che non si vogliono vedere nei modelli stabili hide on(X,Y,T). hide block(X). hide object(O). hide nextstate(X,Y). hide goal(T). hide time(T). hide covered(X,T). hide moving(A,T). hide goal.