Information Technology Reference
In-Depth Information
Initial and successor state clauses
The easiest way to characterize a fluent in a program is to do it in two steps:
1.
State what holds in the initial situation, [] . This is writing what are called the
initial state clauses for the fluent.
2.
State what holds in a noninitial situation, [A|S] . This is writing what are
called the successor state clauses for the fluent. Typically, there are cases involved
depending on the action A and according to whether
a. A makes the fluent true;
b. A makes the fluent false;
c. A leaves the fluent unchanged, as it was in situation S .
Here are the three clauses that characterize the location of the box in any situation:
location(box,loc3,[]).
location(box,L,[push(L)|_]).
location(box,L,[A|S]) :- \+ A=push(_), location(box,L,S).
The first clause is the initial state clause stating that the box is initially located at
loc3 . (The remaining clauses are the successor state clauses.)
The second clause states that if the most recent action in a situation is pushing the
box to L , then the location of the box is L , no matter what the previous actions in
the situation are. Note that it is not the job of the successor state axiom to ensure
that the push is legal .
The third clause states that if the location of the box in a situation S is L , then the
location of the box in situation [A|S] (in other words, after doing action A ) is also
L , provided A is not a push action. Note that this provides a recursive definition
of location: to calculate the location of the box in situation [A|S] , one may need
to calculate the location of the box in situation S .
It is not hard to see that these three clauses will allow all the previous location
sentences to succeed as queries.
This pattern can be applied to other fluents in the monkey and bananas world. For
example, one would want a fluent on_box to indicate whether or not the monkey is
on the box. Climbing on the box makes it true; climbing off the box makes it false; all
the other actions leave this fluent unchanged. In other words,
on_box([climb_on|_]).
on_box([A|S]) :- \+ A=climb_off, on_box(S).
 
Search WWH ::




Custom Search