The algorithm is . Its recursive calls return only Booleans. They do not return and propagate the first-order substitutions obtained while satisfying earlier rule premises.
Take distinct constants , factsand the single Datalog ruleAsk for . The head matches the goal without binding . In line 15, the recursive call for succeeds by first-order unification with , but returns only
true. The next recursive call still receives with unbound, and succeeds by first-order unification with . Neither subgoal is the visited head , so the visited test does not stop these calls. Both recursive results are true, and the algorithm returns true for .However, the least Herbrand model is just . No single constant makes both and true, so the rule cannot derive . The two individually successful premises need one consistent first-order substitution. A correct backward chaining procedure must thread answer first-order substitutions through the remaining premises and backtrack when they cannot be extended; forward chaining on ground Datalog instances is another way to avoid this error.