Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/HarvardPL/AbcDatalog/llms.txt

Use this file to discover all available pages before exploring further.

AbcDatalog is an open-source Java implementation of Datalog, a declarative logic programming language used for knowledge representation and rule-based inference. It provides multiple ready-to-use evaluation engines, an interactive GUI, and a clean Java API — making it ideal for research, education, and embedding in production applications.

Installation

Add AbcDatalog to your Maven or Gradle project, or download the pre-built JAR.

Quickstart

Write your first Datalog program and run queries in under 5 minutes.

Language Guide

Learn Datalog syntax: facts, rules, variables, negation, and unification.

Evaluation Engines

Choose between bottom-up, concurrent, and top-down evaluation strategies.

What is Datalog?

Datalog is a subset of Prolog used for deductive databases and knowledge reasoning. You define a set of facts (known truths) and rules (logical derivations), then query what can be inferred. AbcDatalog handles the evaluation for you.
Example: Graph transitive closure
% Facts: direct edges in a graph
edge(a, b).
edge(b, c).
edge(c, d).

% Rule: transitive closure
tc(X, Y) :- edge(X, Y).
tc(X, Y) :- tc(X, Z), tc(Z, Y).

% Query: what is reachable from a?
tc(a, X)?

Key features

Multiple engines

Semi-naive bottom-up, concurrent bottom-up, and top-down QSQ engines — pick the right one for your workload.

Async evaluation

Stream new EDB facts into a running evaluation and receive derived facts via callbacks.

Why-provenance

Trace exactly which rules and facts were used to derive any result.

Extensible API

Plug in custom evaluation engines and extend the language with new features.

Getting started

1

Add AbcDatalog to your project

Add the Maven Central dependency to your pom.xml:
pom.xml
<dependency>
    <groupId>io.github.harvardpl</groupId>
    <artifactId>AbcDatalog</artifactId>
    <version>0.8.0</version>
</dependency>
2

Parse a Datalog program

Use DatalogParser to parse Datalog text into an AST:
DatalogTokenizer t = new DatalogTokenizer(new FileReader("program.dtlg"));
Set<Clause> program = DatalogParser.parseProgram(t);
3

Initialize an engine and query

Choose an engine, initialize it, and run queries:
DatalogEngine engine = SemiNaiveEngine.newEngine();
engine.init(program);
Set<PositiveAtom> results = engine.query(DatalogParser.parseQuery(t));

See the full quickstart

Step-by-step guide from installation to running your first queries.

Build docs developers (and LLMs) love