Is there documentation the explains the relation of SWI Prolog to SLD resolution?
The literature generally claims that Prolog uses SLD resolution, e.g., “Logic for Computer Science”, by Jean Gallier, Chapter 9, pp. 410-447. But it does not seem that this is how SRI Prolog works. There is another algorithm called “pattern search” discussed in the textbook “Artificial Intelligwence: Structure and Strategies for Problem Solving, 6th Edition”, by George F. Luger, pp. 198-199, which is claimed to be the Prolog algorithm. As a simple example, suppose you are given the knowledge base
- Q AND R → P
- Q
- R
and it is desired to show that the goal P is true. Pattern search proceeds by matching this goal with the conclusion of Item 1, leading to the subgoal
Q AND R
Recursively applying pattern search to the Q leads to the unification of this with fact 2, yielding “true”. Then the algorithm proceeds to apply pattern search to the subgoal R, unifies this with Item 3, yielding “true”, and then “true” is passed back along the recursive chain and applied to P.
If I encode this as a Prolog program:
p :- q, r.
q.
r.
and run this with the trace function in SWI Prolog I get:
[trace] ?- p.
Call: (12) p ? creep
Call: (13) q ? creep
Exit: (13) q ? creep
Call: (13) r ? creep
Exit: (13) r ? creep
Exit: (12) p ? creep
true.
This indicates that SWI-Prolog actually is using the pattern search algorithm.
However, if your are to perform the same exercise using Resolution, you would first need to transform the foregoing program into a set of Horn clauses:
NOT Q OR NOT R OR P, Q, R
add to this set the negation of the goal, NOT P, and then apply resolution as follows. Clash the goal NOT P with the occurrence of P in the foregoing set, yielding the resolvent set
NOT Q OR NOT R, Q, R.
Next clash the NOT Q with Q, yielding the resolvent set
NOT R, R.
Finally clash these two propositions, yielding the empty clause. By the Resolution principle, this establishes that P is a logical consequence of the given three propostions.
But, as shown in the foregoing, this does not seem to be how SWI Prolog actually works. Based on this example, however, it does seem that pattern search and resolution are equivalent when applied to Horn clauses. Only it is not obvious that this is generally correct. Has anyone ever written out a proof of this?