Information Technology Reference
In-Depth Information
clause of the program P, the corresponding resolvent will be put into stack. While
in the case that no clause could be unified, a backtracking operator will be
triggered with the result that an element was poped from the stack; in this case,
the resulted stack should be inspected for unification.
Example 2.1 Consider the following program:
p(X, Z) :- q(X,Y), p(Y,Z).
p(X,X).
q(a, b).
Let “?-p(X ,b)” be the goal. Then the evolvement of the goal stack is as
follows.
Table 2.2. Prolog goal stack
?-p(X ,b).
G is put into stack
?-p(X ,b).
?- q(X,Y), p(Y,b).
A resolvent is put into stack
?- q(X,Y), p(Y,b).
?- p(b, b).
A resolvent is put into stack
?-p(X ,b).
?-p(X ,b).
?- q(X,Y), p(Y,b).
?- p(b, b). ?-q(b,W),
p(W,b)
A resolvent is put into stack
?- q(X,Y), p(Y,b).
?- p(b, b). ￿
?-p(X ,b).
An element is poped, then
the resolvent ￿ is put into
stack
?-p(X ,b).
The pop operation is
triggered for three times
￿
the resolvent ￿ is put into
stack
￿ is poped
2. Completeness of SLD resolution proces is destroyed by the depth-first search
strategy.
This problem can be partially solved according to change the order of sub-goals
and the order of clauses of the program. For example, consider the following
program:
(1) p(f(X)):- p(X).
Search WWH ::




Custom Search