-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimple_example.lgt
84 lines (70 loc) · 1.78 KB
/
simple_example.lgt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
In this example we have a door and a light to work with.
Example queries:
```
?- sitcalc::holds(door_position(Pos) and power(light, Power), s0).
Pos = closed,
Power = off ;
false.
?- sitcalc::poss(A, s0).
A = turn_on(light) ;
A = open_door ;
false.
?- open_door::do(s0, S1).
S1 = do(open_door, s0).
?- turn_on(light)::do($(S1), S2).
S2 = do(turn_on(light), do(open_door, s0)),
S1 = do(open_door, s0).
?- sitcalc::prior($(S2), S).
S = do(open_door, s0),
S2 = do(turn_on(light), do(open_door, s0)) ;
S = s0,
S2 = do(turn_on(light), do(open_door, s0)) ;
false.
?- sitcalc::holds(F, $(S2)), F::holds($(S1)).
F = door_position(open),
S2 = do(turn_on(light), do(open_door, s0)),
S1 = do(open_door, s0) ;
false.
```
*/
:- object(power(_Dev_, _V_), imports(fluent)).
holds(s0) :-
_Dev_ = light, _V_ = off.
holds(do(A, _)) :-
A = turn_on(_Dev_), _V_ = on.
holds(do(A, _)) :-
A = turn_off(_Dev_), _V_ = off.
holds(do(A, S)) :-
A \= turn_on(_Dev_),
A \= turn_off(_Dev_),
holds(S).
:- end_object.
:- object(door_position(_Pos_), imports(fluent)).
holds(s0) :-
_Pos_ = closed.
holds(do(A, _)) :-
A = close_door, _Pos_ = closed.
holds(do(A, _)) :-
A = open_door, _Pos_ = open.
holds(do(A, S)) :-
A \= close_door,
A \= open_door,
holds(S).
:- end_object.
:- object(turn_on(_Dev_), imports(action)).
poss(S) :-
power(_Dev_, off)::holds(S).
:- end_object.
:- object(turn_off(_Dev_), imports(action)).
poss(S) :-
power(_Dev_, on)::holds(S).
:- end_object.
:- object(open_door, imports(action)).
poss(S) :-
door_position(closed)::holds(S).
:- end_object.
:- object(close_door, imports(action)).
poss(S) :-
door_position(open)::holds(S).
:- end_object.