{"slug":"datalog","article":{"kind":"article","title":"Datalog","category":"Knowledge graphs","summary":"Datalog is a declarative language for deriving facts from relations and rules. Recursive rules make it useful for questions such as which topics or dependencies can be reached through a series of links.","sources":["source:49f7367b511bed3a"],"related":["article:ontology","article:taxonomy"],"id":"article:datalog","from":"2026-11-25","revision":"039b44cb5d0240645cc85eefdc755719be098ac8cc5a099349c34d1f3bf74561","recordedAt":"2026-11-25T09:44:03.282Z"},"sections":[{"kind":"section","article":"article:datalog","title":"Facts and rules","text":"A fact supplies a known tuple, such as a direct link from one topic to another. A rule supplies a conclusion whenever all conditions in its body hold. A query asks which tuples follow. A typical implementation of positive Datalog repeatedly applies rules until they produce no new tuples.","order":0,"sources":["source:49f7367b511bed3a","source:e923178fa7732372"],"id":"section:datalog-facts-and-rules","from":"2026-11-25","revision":"039b44cb5d0240645cc85eefdc755719be098ac8cc5a099349c34d1f3bf74561","recordedAt":"2026-11-25T09:44:03.282Z"},{"kind":"section","article":"article:datalog","title":"Why recursion terminates in the basic language","text":"In function-free, range-restricted positive Datalog over a finite set of constants, every variable in a rule’s conclusion is bound by a positive body relation. Only finitely many distinct tuples can be derived. Implementations can add arithmetic or operations that generate new values, so check the dialect before relying on this termination guarantee.","order":1,"sources":["source:49f7367b511bed3a","source:e923178fa7732372"],"id":"section:datalog-why-recursion-terminates-in-the-basic-language","from":"2026-11-25","revision":"039b44cb5d0240645cc85eefdc755719be098ac8cc5a099349c34d1f3bf74561","recordedAt":"2026-11-25T09:44:03.282Z"},{"kind":"section","article":"article:datalog","title":"Use it in a wiki","text":"Store directly asserted links and their sources. Derive ancestor links in a separate relation so that a page can distinguish a direct citation from the result of a rule. If editors remove a link, recompute the affected conclusions or use an engine that maintains them. A second derivation might still support the same conclusion.","order":2,"sources":["source:49f7367b511bed3a","source:b59273fdb31591bf","source:e923178fa7732372"],"id":"section:datalog-use-it-in-a-wiki","from":"2026-11-25","revision":"039b44cb5d0240645cc85eefdc755719be098ac8cc5a099349c34d1f3bf74561","recordedAt":"2026-11-25T09:44:03.282Z"}],"events":[{"kind":"event","title":"Ceri, Gottlob and Tanca describe Datalog’s syntax, semantics and query evaluation","date":"1989-03","sources":["source:49f7367b511bed3a"],"articles":["article:datalog"],"id":"event:d21b7f66d2b6b0eb","from":"1989-03-31","revision":"0d3976156c61e1f92c1ece10e46254b9ffe18a2412b90d58ee3b74ca18d988f3","recordedAt":"2026-11-25T09:44:03.207Z"},{"kind":"event","title":"W3C publishes a second edition of the Datalog-related RIF Core dialect","date":"2013-02-05","sources":["source:b9ff06e31a81e041"],"articles":["article:datalog"],"id":"event:c74bd6a559affc3d","from":"2013-02-05","revision":"0d3976156c61e1f92c1ece10e46254b9ffe18a2412b90d58ee3b74ca18d988f3","recordedAt":"2026-11-25T09:44:03.207Z"},{"kind":"event","title":"The Soufflé team describes compiling Datalog rules into program analyzers","date":"2016-07-13","sources":["source:b59273fdb31591bf"],"articles":["article:datalog"],"id":"event:4cb388a34b4da980","from":"2016-07-13","revision":"0d3976156c61e1f92c1ece10e46254b9ffe18a2412b90d58ee3b74ca18d988f3","recordedAt":"2026-11-25T09:44:03.207Z"}],"examples":[{"kind":"example","article":"article:datalog","title":"Beginner","text":"Record that Retrieval is broader than Hybrid search and that AI methods is broader than Retrieval. Asking for all ancestors of Hybrid search should return both topics.","order":0,"sources":["source:49f7367b511bed3a","source:e923178fa7732372"],"id":"example:datalog-1","from":"2026-11-25","revision":"039b44cb5d0240645cc85eefdc755719be098ac8cc5a099349c34d1f3bf74561","recordedAt":"2026-11-25T09:44:03.282Z"},{"kind":"example","article":"article:datalog","title":"Intermediate","text":"With broader(child,parent), use ancestor(X,Y) :- broader(X,Y). Then add ancestor(X,Z) :- broader(X,Y), ancestor(Y,Z). The second rule extends a known path by one edge.","order":1,"sources":["source:49f7367b511bed3a","source:e923178fa7732372"],"id":"example:datalog-2","from":"2026-11-25","revision":"039b44cb5d0240645cc85eefdc755719be098ac8cc5a099349c34d1f3bf74561","recordedAt":"2026-11-25T09:44:03.282Z"},{"kind":"example","article":"article:datalog","title":"Advanced","text":"Feed the rules a diamond-shaped hierarchy with two paths to the same ancestor. Expect one ancestor tuple under set semantics. Remove one path and confirm the ancestor is still reachable through the other.","order":2,"sources":["source:49f7367b511bed3a","source:b59273fdb31591bf","source:e923178fa7732372"],"id":"example:datalog-3","from":"2026-11-25","revision":"039b44cb5d0240645cc85eefdc755719be098ac8cc5a099349c34d1f3bf74561","recordedAt":"2026-11-25T09:44:03.282Z"}],"links":[],"sources":[{"kind":"source","title":"Ceri, Gottlob and Tanca · What You Always Wanted to Know About Datalog","url":"https://www.dcc.fc.up.pt/~ines/aulas/1617/PL/datalog-paper.pdf","id":"source:49f7367b511bed3a","from":"1989-03-31","revision":"0d3976156c61e1f92c1ece10e46254b9ffe18a2412b90d58ee3b74ca18d988f3","recordedAt":"2026-11-25T09:44:03.207Z"},{"kind":"source","title":"Soufflé project · Datalog tutorial","url":"https://souffle-lang.github.io/tutorial","id":"source:e923178fa7732372","from":"2026-11-25","revision":"0d3976156c61e1f92c1ece10e46254b9ffe18a2412b90d58ee3b74ca18d988f3","recordedAt":"2026-11-25T09:44:03.207Z"},{"kind":"source","title":"Soufflé project · On Synthesis of Program Analyzers","url":"https://souffle-lang.github.io/cav-paper","id":"source:b59273fdb31591bf","from":"2016-07-13","revision":"0d3976156c61e1f92c1ece10e46254b9ffe18a2412b90d58ee3b74ca18d988f3","recordedAt":"2026-11-25T09:44:03.207Z"},{"kind":"source","title":"W3C · RIF Core Dialect, second edition","url":"https://www.w3.org/TR/2013/REC-rif-core-20130205/","id":"source:b9ff06e31a81e041","from":"2013-02-05","revision":"0d3976156c61e1f92c1ece10e46254b9ffe18a2412b90d58ee3b74ca18d988f3","recordedAt":"2026-11-25T09:44:03.207Z"}],"related":[{"slug":"ontology","title":"Ontology"},{"slug":"taxonomy","title":"Taxonomy"}],"backlinks":[{"slug":"taxonomy","title":"Taxonomy"},{"slug":"ontology","title":"Ontology"}],"history":[{"id":"0d3976156c61e1f92c1ece10e46254b9ffe18a2412b90d58ee3b74ca18d988f3","recordedAt":"2026-11-25T09:44:03.207Z","message":"Index the sourced subject histories"},{"id":"039b44cb5d0240645cc85eefdc755719be098ac8cc5a099349c34d1f3bf74561","recordedAt":"2026-11-25T09:44:03.282Z","message":"Publish current guides, examples and practice links"}]}
