Datalog that's as easy as ABC.

AbcDatalog is an open-source implementation of the logic programming language Datalog written in Java. It provides ready-to-use implementations of common Datalog evaluation algorithms, as well as some experimental multi-threaded evaluation engines. It supports language features beyond core Datalog such as explicit (dis-)unification of terms and stratified negation. Additionally, AbcDatalog 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.2, released January 2017:

AbcDatalog is distributed under a BSD License.

Datalog Syntax and Grammar

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

a ∈ Const
X ∈ Var
p ∈ PredicateSym
t ∈ Term ::= a | X
A ∈ Atom ::= p | p(t, ..., t)
φ ∈ Premise ::= A | not A | t = t | t != t
C ∈ Clause ::= A. | A :- φ, ..., φ.

All identifiers must consist of a combination of alphanumeric characters and underscores. Constants and predicate symbols must start with a lowercase letter or a digit. Variables must start with an uppercase letter or an underscore. The variable _ represents an anonymous variable; each instance of _ in a clause is treated as a fresh variable. We enforce the requirement that every variable in a clause must be bound. A variable X is bound if at least one of the following conditions holds:

An AbcDatalog program consists of a set of clauses. Bodiless clauses are treated as initial facts. Clauses with bodies are treated as rules for deriving IDB relations. A query is phrased as an atom followed by a question mark. Not every evaluation engine provided by AbcDatalog supports every language feature in the above grammar.

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.