Datalog 2026-10-31
A function-free rule language based on definite first-order Horn clauses, normally with safety conditions on rule variables. Positive Datalog has a least Herbrand model obtained by forward chaining.
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.
A Herbrand interpretation is a stable model when it is the least Herbrand model of its stable model reduct . To form the reduct, ground the rules, delete each rule with a premise for which , and remove the remaining occurrences of
not and their atoms.For , the rules concerning in the reduct aretogether with . No rule has a divisibility atom in its head, so forward chaining produces no divisibility facts and no leap fact. Ground rules for the other constants cannot fire because their year premises are absent. ThusTherefore .
For , the rule using is deleted. The common-year rule is retained without its negative premise, since is absent. Crucially, the reduct does not convert atoms already in into facts. Its least Herbrand model is again . The two divisibility atoms in have no support. Hence
Inspecting these two interpretations alone is not sufficient for skeptical entailment. That requires every stable model to contain . Here we can finish the argument: every reduct has no rule deriving divisibility atoms, so every stable model has empty divisibility relation. Its leap relation must then be empty as well. The common-year rule consequently derives , and the only year fact is . Thus is the unique stable model, andThis final uniqueness argument, rather than the examination of just two candidate interpretations, establishes the required universal claim.