Information Technology Reference
In-Depth Information
Figure 4.1.
A blocks world
B3
B4
B1
B5
B2
B6
B7
simply correct means that it is grammatically correct, logically correct (criteria 1 and
2), and in a form suitable for back-chaining (criterion 3).
4.2 A blocks world
Imagine that we would like to draw appropriate conclusions about a scene like the
one depicted in figure 4.1 involving toy blocks on a table. The goal is to describe this
scene and get Prolog to determine that
block B3 is above block B5;
block B1 is to the left of block B7;
block B4 is to the right of block B2.
A Prolog program that does this is presented in figure 4.2. (In that figure, the small
line numbers on the right are for reference only. They are not part of Prolog.) The
program uses five predicates, whose intended meaning is described in the comments.
With respect to the scene in figure 4.1, the program handles the on and just_left
predicates appropriately, with the six atomic clauses. Similarly, the single clause for
the right predicate is correct assuming that the ones for the left predicate are cor-
rect. (The program says that right is the inverse of left , just as parent was the
inverse of child .)
 
Search WWH ::




Custom Search