Datalog is a declarative logic programming language that syntactically is a subset of Prolog. It is often used as a query language for deductive databases. In recent years, Datalog has found new application in data integration, information extraction, networking, program analysis, security, and cloud computing.
Its origins date back to the beginning of logic programming, but it became prominent as a separate area around 1977 when Hervé Gallaire and Jack Minker organized a workshop on logic and databases.David Maier is credited with coining the term Datalog.
Unlike in Prolog, statements of a Datalog program can be stated in any order. Furthermore, Datalog queries on finite sets are guaranteed to terminate, so Datalog does not have Prolog's cut operator. This makes Datalog a fully declarative language.
In contrast to Prolog, Datalog
Query evaluation with Datalog is based on first-order logic, and is thus sound and complete. However, Datalog is not Turing complete, and is thus used as a domain-specific language that can take advantage of efficient algorithms developed for query resolution. Indeed, various methods have been proposed to efficiently perform queries, e.g., the Magic Sets algorithm, tabled logic programming or SLG resolution.
Some widely used database systems include ideas and algorithms developed for Datalog. For example, the SQL:1999 standard includes recursive queries, and the Magic Sets algorithm (initially developed for the faster evaluation of Datalog queries) is implemented in IBM's DB2. Moreover, Datalog engines are behind specialised database systems such as Intellidimension's database for the semantic web.
Several extensions have been made to Datalog, e.g., to support aggregate functions, to allow object-oriented programming, or to allow disjunctions as heads of clauses. These extensions have significant impacts on the definition of Datalog's semantics and on the implementation of a corresponding Datalog interpreter.
These two lines define two facts, i.e. things that always hold:
parent(bill, mary). parent(mary, john).
This is what they mean: bill is a parent of mary and mary is a parent of john. The names are written in lowercase because uppercase letters stand for variables.
These two lines define rules, which define how new facts can be inferred from known facts.
ancestor(X, Y) :- parent(X, Y). ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).
This line is a query:
?- ancestor(bill, X).
It asks the following: Who are all the X that bill is an ancestor of? It would return mary and john when posed against a Datalog system containing the facts and rules described above.
More about rules: a rule has a :- symbol in the middle: the part to the left of this symbol is the head of the rule, the part to the right is the body. A rule reads like this: <head> is known to be true if it is known that <body> is true. Uppercase letters in rules stand for variables: in the example, we don't know who X or Y are, but some X is the ancestor of some Y if that X is the parent of that Y. The ordering of the clauses is irrelevant in Datalog, in contrast to Prolog which depends on the ordering of clauses for computing the result of the query call.
Datalog distinguishes between Extensional predicate symbols (defined by facts) and intensional predicate symbols (defined by rules). In the example above
ancestor is an intensional predicate symbol, and
parent is extensional. Predicates may also be defined by facts and rules and therefore neither be purely extensional nor intensional, but any Datalog program can be rewritten into an equivalent program without such predicate symbols with duplicate roles.
Here is a short list of systems that are either based on Datalog or provide a Datalog interpreter:
|Written in||Name||Try it online||External Database||Description||Licence|
|In Java||IRIS||IRIS extends Datalog with function symbols, built-in predicates, locally stratified or un-stratified logic programs (using the well-founded semantics), unsafe rules and XML schema data types||GNU LGPL v2.1|
|Jena||a Semantic Web framework which includes a Datalog implementation as part of its general purpose rule engine, which provides OWL and RDFS support.||Apache v2|
|SociaLite||SociaLite is a datalog variant for large-scale graph analysis developed in Stanford||Apache v2|
|Graal||Graal is a Java toolkit dedicated to querying knowledge bases within the framework of existential rules, aka Datalog+/-.||CeCILL v2.1|
|Flix||Yes||A functional and logic programming language inspired by Datalog extended with user-defined lattices and monotone filter/transfer functions.||Apache v2|
|In C||XSB||A logic programming and deductive database system for Unix and MS Windows with tabling giving Datalog-like termination and efficiency, including incremental evaluation||GNU LGPL|
|In C++||Coral||A deductive database system written in C++ with semi-naïve datalog evaluation. Developed 1988-1997.||custom licence, free for non-commercial use|
|DLV||A Datalog extension that supports disjunctive head clauses.||custom licence, free for academic and non-commercial educational use, as well as for use by non-profit organisations|
|Inter4QL||an open-source command-line interpreter of Datalog-like 4QL query language implemented in C++ for Windows, Mac OS X and Linux. Negation is allowed in heads and bodies of rules as well as in recursion||GNU GPL v3|
|RDFox||RDF triple store with Datalog reasoning. Implements the FBF algorithm for incremental evaluation.||custom licence, free for non-commercial use|
|Souffle||an open-source Datalog-to-C++ compiler converting Datalog into high-performance, parallel C++ code, specifically designed for complex Datalog queries over large data sets as e.g. encountered in the context of static program analysis||UPL v1.0|
|In Python||pyDatalog||11 dialects of SQL||adds logic programming to Python's toolbox. It can run logic queries on databases or Python objects, and use logic clauses to define the behavior of Python classes.||GNU LGPL|
|In Ruby||bloom / bud||A Ruby DSL for programming with data-centric constructs, based on the Dedalus extension of Datalog which adds a temporal dimension to the logic.||BSD 3-Clause|
|In Lua||Datalog||Yes||a lightweight deductive database system.||GNU LGPL|
|In Prolog||DES||an open-source implementation to be used for teaching Datalog in courses||GNU LGPL|
|In Clojure||Cascalog||Hadoop||a Clojure library for querying data stored on Hadoop clusters||Apache|
|Clojure Datalog||a contributed library implementing aspects of Datalog||Eclipse Public License 1.0|
|Datascript||in-memory||Immutable database and Datalog query engine that runs in the browser||Eclipse Public License 1.0|
|In Racket||Datalog for Racket||GNU LGPL|
|Datafun||Generalized Datalog on Semilattices||GNU LGPL|
|In Tcl||tclbdd||Implementation based on binary decision diagrams. Built to support development of an optimizing compiler for Tcl.||BSD|
|In Haskell||Dyna||Dyna is a declarative programming language for statistical AI programming. The language is based on Datalog, supports both forward and backward chaining, and incremental evaluation.||GNU AGPL v3|
|In other or unknown languages||bddbddb||an implementation of Datalog done at Stanford University. It is mainly used to query Java bytecode including points-to analysis on large Java programs||GNU LGPL|
|ConceptBase||a deductive and object-oriented database system based on a Datalog query evaluator : Prolog for triggered procedures and rewrites, axiomatized Datalog called « Telos » for (meta)modeling. It is mainly used for conceptual modeling and metamodeling||BSD (FreeBSD-style license) Prolog, Java, C++.|
Manage research, learning and skills at defaultlogic.com. Create an account using LinkedIn to manage and organize your omni-channel knowledge. defaultlogic.com is like a shopping cart for information -- helping you to save, discuss and share.