Datalog that's as easy as A B C.

AbcDatalog is an open-source, Java-based implementation of the logic programming language Datalog. It provides ready-to-use implementations of common Datalog evaluation algorithms, including efficient multi-threaded versions of bottom-up and magic set transformation techniques. Additionally, it is designed to be easily extensible with new evaluation engines and new language features. We hope that it proves to be useful for both research and pedagogy.

The entire source code is available as a ZIP file. We have also provided a stand-alone executable JAR that launches a graphical Datalog editor and interpreter. The source code and the graphical user interface both depend on Java 8.

Version 0.1, released March 2016:

AbcDatalog is distributed under a BSD License.

Datalog Syntax and Grammar

Both the graphical Datalog editor/interpreter and the parser included in the source code recognize the following grammar for Datalog:

c ∈ Const
X ∈ Var
p ∈ PredSym
t ∈ Term ::= c | X
A ∈ Atom ::= p | p(t1, ..., tn)          (n ≥ 1)
C ∈ Clause ::= A. | A0 :- A1, ..., Am.    (m ≥ 1)

All identifiers must consist of a combination of alphanumeric characters and underscores. Constants and predicate symbols must start with a lowercase letter, digit, or underscore. Variables must start with an uppercase letter. Following Datalog convention, we enforce the requirement that every variable in the head of a clause must also appear in the body of the clause.

An AbcDatalog program consists of a set of clauses. Bodiless clauses are treated as EDB facts. Clauses with bodies are treated as rules for deriving IDB relations. A query is phrased as an atom followed by a question mark.

Comments begin with the character % and extend to the end of the line.

Using the source code

The source code is documented with Javadocs, which are also available here. We refer you in particular to the interfaces datalog.engine.DatalogEngine and datalog.executor.DatalogExecutor, which provide the main ways of interfacing with the Datalog evaluation algorithms we have implemented. The classes datalog.engine.DatalogEngineTest and datalog.executor.ExecutorExample also provide examples of how to use these interfaces.

Please see the README for information on compiling the source code.

Using the GUI

Start the GUI from the command line with java -jar abcdatalog-gui.jar. Use the menu to open an existing Datalog source file, or create one from scratch in the editor. Clicking the Load button loads the program currently in the editor into the Datalog interpreter. Perform a query on the loaded program by entering the query in the query text area and clicking the Run button. Any matching facts are displayed in the space below. Remember that a query has to have the form of an atom followed by a question mark.

For instance, say we type the following program into the Datalog editor:

hello(X) :- name(X).

If we then load the program and pose the query hello(X)?, we get:


The primary contributors to AbcDatalog are:

Email with questions, comments, and bug reports.

AbcDatalog has been developed as part of the Privacy Tools for Sharing Research Data project at Harvard University and is supported by the National Science Foundation under Grant Nos. 1237235 and 1054172.