Let be a definite clause program with rules , where , and let be a conjunctive query over .
- Set
progressto . - Set
currentGoalto . - While the
currentGoalis not empty andprogressis :- Let be a proposition in the current goal.
- If it exists, choose in a rule with the head .
- Let be a rule in with the head .
- In the current goal, replace for :
- Else, set
progressto .
- If
currentGoalis empty andprogressis then the output is true, otherwise the output is false.
There are two points of non-determinism:
- (3.1) When we choose a proposition in the current goal. The choice here does not matter but we must be consistent, i.e. always leftmost or rightmost.
- (3.2) When we choose a matching rule, this choice does matter. See example 2 for an explanation.