|
|
|
|
|
by YeGoblynQueenne
2651 days ago
|
|
My understanding is that Datalog terminates because it does not allow functions as arguments to predicates. No functions means it's not possible to create infinite terms: P(f(x)).
p(f(f(x)).
p(f(f(f(x)))).
... etc
In fact I understand that termination is guaranteed even if a datalog program is executed by a Prolog interpreter. Or in other words, it's a result of the language semantics, not its implementation.(but I might be wrong about this- corrections welcome). |
|
p(X) :- p(X). does usually not terminate in a top-down (Prolog) system but does in a bottom-up (Datalog) system. Datalog doesn't even allow terms as predicate arguments so of course you can't construct them of infinite size. But also this isn't allowed (where it is in Prolog)
p(X) :- p(Y), X is Y + 1.
Given a fact p(0) you get p(X) true for any integer X or generate all positive integers. This doesn't terminate for some binding patterns.