logoalt Hacker News

vilterpyesterday at 5:48 PM1 replyview on HN

> [Datalog] is a subset of Prolog that lacks recursion

Datalog does allow for recursion — a common example is graph reachability:

reachable(a, b) :- edge(a, b). reachable(a, c) :- edge(a, b), reachable(b, c).

(Evan mentioned implementing kCFA, which would require recursion like this...)

'Base datalog' guarantees termination by requiring all input relations to be finite. Notably this means that it doesn't have numerical operations like addition or multiplication, since `plus(a, b)` or `times(a, b)` would be infinite relations.

More practical Datalog engines like Souffle (https://souffle-lang.github.io/) have numerical operations but don't guarantee termination.

Recursive queries are not needed by most applications, but maybe Acadia could allow them (compiling to recursive CTEs) by proving that recursion only goes through finite relations.


Replies

cryptonectoryesterday at 7:58 PM

If you can do Peano numbers...

Guaranteed termination isn't really if you give me enough rope to implement the Ackermann function.