4
8block(1).
9block(2).
10block(3).
11block(4).
12block(5).
13block(6).
14
16on(1,2,0).
17on(2, 'table', 0).
18on(3,4,0).
19on(4, 'table', 0).
20on(5,6,0).
21on(6, 'table', 0).
22
23% Goal Situation
24
25% TEST
26:- not on(3,2,3).
27:- not on(2,1,3).
28:- not on(1,'table',3).
29:- not on(6,5,3).
30:- not on(5,4,3).
31:- not on(4,'table',3).
32
34
36time(0).
37time(1).
38time(2).
39time(3).
40location(B) :- block(B).
41location('table').
42
43% GENERATE
44
45% { move(B,L,T) : block(B) , location(L) } 2 :-
46% time(T),
47% T<3.
48move(B,L,T) :-
49 block(B) ,
50 location(L),
51 time(T),
52 T < 3, not neg_move(B,L,T).
53neg_move(B,L,T) :-
54 block(B),
55 location(L),
56 time(T),
57 T < 3, not move(B,L,T).
58
60
62on(B,L,T1) :-
63 block(B),
64 location(L),
65 time(T),
66 move(B,L,T),
67 T1 is T + 1,
68 T < 3.
69
70% inertia
71on(B,L,T1) :-
72 location(L),
73 block(B),
74 time(T),
75 on(B,L,T),
76 T1 is T + 1,
77 not neg_on(B,L,T1),
78 T < 3.
79
81neg_on(B,L1,T) :-
82 block(B),
83 location(L),
84 location(L1),
85 time(T),
86 on(B,L,T),
87 L \= L1.
88
90
92:- block(B), location(L), time(T), on(B,L,T), neg_on(B,L,T). 93
95:- block(B), time(T), on(B1,B,T), block(B1), on(B2,B,T), block(B2), B1 \= B2. 96
98:- location(L), time(T), T < 3, move(B,L,T), on(B1,B,T), block(B), block(B1). 99
101:- block(B), block(B1), location(L), time(T), T < 3, move(B,B1,T), move(B1,L,T). 102
103?- move(A,B,L).