Live data from Hacker News

Introduction to Datalog

x775.net

11–20 of 40 posts

Re: Introduction to Datalog

#11
post #10

Thanks for sharing. There is one very significant conceptual error early on, however, and it is captured first in this statement: "The :- means if and only if, or iff". `:-` means if - or more precisely represents material conditional - where the consequent is on the left and the antecedent is on the right. iff is logical biconditional.

Hi Stephen. You are absolutely right, thank you for the feedback! I have edited accordingly.

Re: Introduction to Datalog

#12

> The :- means if and only if, or iff. Is it really the case? Human("Socrates"). Animal("Turtle"). Mortal(x) :- Human(x). Mortal(x) :- Animal(x). Suppose :- means iff. Turtle is Mortal (lines 2+4, implication to the left). Because Turtle is Mortal, it must be a Human (line 3, implication to the right). Is it really valid according to Datalog semantics?

Hi! Thank you for highlighting this.

No, you and sdbrady who commented above are correct; the :- only means "if". I have edited accordingly and apologise for the misunderstanding!

Re: Introduction to Datalog

#14
post #6

Earlier quoted context omitted.

Transitive closure is the first thing nearly every introduction to datalog (or Prolog, for that matter) will show you. All you had to do was click the link and scroll down: Edge("a", "b"). Edge("b", "c"). Path(x, y) :- Edge(x, y). Path(x, z) :- Path(x, y), Edge(y, z). Symmetric closure, assuming I'm understanding correctly, is also trivial: SymmetricEdge(Left, Right) :- Edge(Left, Right). SymmetricEdge(Left, Right) :…

I was wondering about termination. With finite ground facts that appears not to be an issue. Complexity is another matter.

Termination is achieved in brian_cloutier's example (https://news.ycombinator.com/item?id=19423320) by the use of different clauses (e.g., `Path` vs. `Edge`), so that all recursion is productive.

Re: Introduction to Datalog

#15

Can anyone recommend any implementation of Datalog (+ negation) that is not datomic? I haven't tried datascript, which appears to support negation. Maybe I will try that if/when I revisit this interest someday.

Check out Datahike aswell, if you are interested in a durable datalog database.

https://github.com/replikativ/datahike

Re: Introduction to Datalog

#16

Can anyone recommend any implementation of Datalog (+ negation) that is not datomic? I haven't tried datascript, which appears to support negation. Maybe I will try that if/when I revisit this interest someday.

Hi Joel.

You can give http://www.dlvsystem.com/dlv/ a shot!

Alternatively, if you prefer open-source solutions, check https://abcdatalog.seas.harvard.edu/.

Due to a number of complications on my machine, I used DLV.

Re: Introduction to Datalog

#17
post #16

Can anyone recommend any implementation of Datalog (+ negation) that is not datomic? I haven't tried datascript, which appears to support negation. Maybe I will try that if/when I revisit this interest someday.

Hi Joel. You can give http://www.dlvsystem.com/dlv/ a shot! Alternatively, if you prefer open-source solutions, check https://abcdatalog.seas.harvard.edu/ . Due to a number of complications on my machine, I used DLV.

Ah, I usually automatically pass on closed source solutions (hence my dislike for datomic).

TY for the link to abcdatalog though!

Re: Introduction to Datalog

#18
post #15

Can anyone recommend any implementation of Datalog (+ negation) that is not datomic? I haven't tried datascript, which appears to support negation. Maybe I will try that if/when I revisit this interest someday.

Check out Datahike aswell, if you are interested in a durable datalog database. https://github.com/replikativ/datahike

Cool, ty! Seems similar to DataScript.

Re: Introduction to Datalog

#19
Great post! Still working through it, but there is a slight error in the nested diagram at the start. Relational algebra has set difference, which is akin to negation-as-failure, but it lacks recursion. So the positive Datalog and RA circles should overlap without either containing the other. See http://www.lifl.fr/%7Ekuttler/elfe/biblio/datalog-overview-g...

Re: Introduction to Datalog

#20
post #11
post #10

Thanks for sharing. There is one very significant conceptual error early on, however, and it is captured first in this statement: "The :- means if and only if, or iff". `:-` means if - or more precisely represents material conditional - where the consequent is on the left and the antecedent is on the right. iff is logical biconditional.

Hi Stephen. You are absolutely right, thank you for the feedback! I have edited accordingly.

I always remind myself that it's not an if-and-only-if with this argument: since there could always be another rule that is satisfied to make that fact true, it can't be iff.
Post reply on HN