Information Technology Reference
In-Depth Information
Call: (6) estbf([[a],[b],[u,p,b],[p,a]], [u,c])
Call: (7) estbf([[a],[b],[u,p,b],[p,a]], [c,p,b])
Fail: (7) estbf([[a],[b],[u,p,b],[p,a]], [c,p,b])
Fail: (6) estbf([[a],[b],[u,p,b],[p,a]], [u,c])
The procedure estbf detects the failure before even getting to the atom p .
So estbf is a thinking procedure that does not work like Prolog. There is no con-
tradiction in saying this. Prolog uses a depth-first procedure, and its atomic queries
(like member and append and even estbf ) will always be handled in this way. The
estbf procedure is breadth-first, however, and its atomic queries (like u and c )are
handled in that way. So Prolog is reasoning in a depth-first way about a thinking procedure
that reasons in a breadth-first way . This way of handling thinking procedures that are
different from the back-chaining of Prolog is at the root of everything else discussed
in this chapter.
Note that the breadth-first variant of back-chaining avoids some of the difficulties
encountered with a depth-first procedure:
?- est([[a],[p,p]], [p,b]).
% Gets stuck in a loop.
ERROR: Out of global stack
?- estbf([[a],[p,p]], [p,b]).
% Does not get stuck.
No
Although
the estbf predicate
terminates
here
without
getting
stuck,
it
is
not
guaranteed to always terminate:
?- estbf([[a],[p,p],[p,a]], [p]).
ERROR: Out of global stack
It is possible to revise back-chaining to ensure termination. But it is easier to move to
a very different sort of procedure that is guaranteed to terminate.
11.1.2 A forward-chaining thinking procedure
Let us now turn to a more substantial change in how to deal with a knowledge
base. Instead of working backward from a query the way that Prolog does, one can
work forward from the knowledge base. This is what was termed forward-chaining in
section 2.5.
The idea with forward-chaining is to start by focusing on the clauses whose bodies
are empty, that is, the atomic sentences of the knowledge base. Call an atom that is
the head of such a clause solved (meaning “known to be true”). To establish a query
by forward-chaining, proceed as follows:
 
Search WWH ::




Custom Search