logoalt Hacker News

ModernMechtoday at 12:53 PM2 repliesview on HN

Importantly, Datalog is not Turing-complete though.


Replies

AlotOfReadingtoday at 2:39 PM

You can get Turing completeness by wrapping your datalog query in a while loop, so that's not particularly restrictive.

show 1 reply
gobdovantoday at 1:31 PM

Exactly :) It is terminating due to the LFP semantics I was pointing out, it's more akin to SQL than to Prolog. The article doesn't even show the usage of the Prolog cut (`!`).

And yet Prolog can express all examples in the article. For these kinds of problems, giving up TC is mostly a feature. And if you need more expressiveness, there's a lot of practical Datalog-ish systems that can recover Turing completeness (Flix, Formulog, parts of Souffle), while still being saner than SWI Prolog and co. for this type of work, as you generally don't have to care about atom order or search order in the same way. They act so much more predictably.