DatalogZ

DatalogZ (stylized as ) is an extension of Datalog with integer arithmetic and comparisons. The decision problem of whether or not a given ground atom (fact) is entailed by a DatalogZ program is RE-complete (hence, undecidable), which can be shown by a reduction to diophantine equations.

Syntax
The syntax of DatalogZ extends that of Datalog with numeric terms, which are integer constants, integer variables, or terms built up from these with addition, subtraction, and multiplication. Furthermore, DatalogZ allows, which are atoms of the form  or   for numeric terms  ,.

Semantics
The semantics of DatalogZ are based on the model-theoretic (Herbrand) semantics of Datalog.

Limit DatalogZ
The undecidability of entailment of DatalogZ motivates the definition of limit DatalogZ. Limit DatalogZ restricts predicates to a single numeric position, which is marked maximal or minimal. The semantics are based on the model-theoretic (Herbrand) semantics of Datalog. The semantics require that Herbrand interpretations be to qualify as models, in the following sense: Given a ground atom $$a=r(c_1, \ldots, c_n)$$ of a limit predicate $$r$$ where the last position is a max (resp. min) position, if $$a$$ is in a Herbrand interpretation $$I$$, then the ground atoms $$r(c_1,\ldots,k)$$ for $$k > c_n$$ (resp. $$k < c_n$$) must also be in $$I$$ for $$I$$ to be limit-closed.

Example
Given a constant, a binary relation   that represents the edges of a graph, and a binary relation   with the last position of   minimal, the following limit DatalogZ program computes the relation  , which represents the length of the shortest path from   to any other node in the graph: