NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Modular Materialisation of Datalog Programs.

Pan Hu, Boris Motik, Ian Horrocks · DOI

Abstract

This paper introduces a modular framework for Datalog reasoning that allows specialized, high-performance algorithms for specific rules (such as transitivity) to be seamlessly integrated with general-purpose reasoning. By moving away from a "one-size-fits-all" approach, the authors achieve speedups of up to three orders of magnitude for both initial data computation and incremental updates.

Introduction

Datalog is a powerful language used to express recursive relationships, such as finding all reachable nodes in a graph (transitive closure). In many systems, reasoning is performed via materialisation: precomputing and storing all possible conclusions from a set of rules and facts.

The industry standard for this is the seminaïve algorithm. While robust, it is often inefficient for specific types of rules. For example, computing a transitive and symmetric relation over $n$ vertices using the seminaïve approach takes $O(n^3)$ steps, whereas a custom graph-based algorithm could do it in $O(n^2)$. The challenge lies in integrating these specialized algorithms into general-purpose programs without compromising mathematical soundness, especially during incremental updates.

Methods

The authors propose a Modular Framework that partitions a Datalog program into disjoint subsets called modules.

  1. The Plugin System: Each module can be handled by a specialized "plugin" function. If no specialized algorithm exists for a module, it defaults to the standard seminaïve evaluation.
  2. Formal Requirements: To ensure system-wide consistency, the authors define four core functions that a module must implement: Add (initial consequences), Diff (consequences affected by external changes), Del (handling overdeletion), and Red (re-derivation of facts).
  3. Specialized Modules: The paper provides optimized algorithms for two common patterns:
  4. Transitive Closure (TC): Uses a "linearization" strategy to reduce rule applications.
  5. Symmetric-Transitive Closure (STC): Uses a connected-components graph algorithm, which is significantly faster than iterative logic rules.

Datasets

The researchers evaluated their framework using a mix of real-world and synthetic benchmarks:

  • Claros-LE: Archaeological artifacts dataset.
  • LUBM-LE: Synthetic benchmark modeling university organizations.
  • DBpedia-SKOS: Wikipedia category data with long transitive chains.
  • DAG-R: Synthetic benchmark testing transitivity over a Directed Acyclic Graph.

Key Insights and Ideas

  • Internal vs. External Facts: For transitivity, the framework distinguishes between facts provided as input ("external") and those derived by the rule itself ("internal"). By only joining external facts with internal ones, they simulate linear recursion, avoiding the $O(n^3)$ explosion.
  • Graph Theory as Logic: For symmetric-transitive rules, the authors treat the logic as finding connected components in an undirected graph, swapping expensive logical joins for efficient graph traversal.
  • Incremental Maintenance: The modular approach excels during deletions. Standard algorithms often "overdelete" facts and struggle to re-derive them; the modular approach uses internal data structures to make this process more surgical.

Key Results

The modular approach (Mat-Mod) was compared against the standard seminaïve approach (Mat) and the state-of-the-art incremental algorithm (DRedᶜ).

Initial Materialisation

As shown in Table 1, the modular approach achieved significant speedups. On the DAG-R dataset, the modular approach was over 100x faster (29.6 seconds vs. 3238 seconds). On DBpedia-SKOS, it was roughly 35x faster.

Table 1: Benchmark statistics and initial materialisation times (in seconds).

Incremental Maintenance

The performance gap was most dramatic during small deletions. On the Claros-LE dataset, deleting 1,000 facts took 0.93 seconds with the modular approach compared to 1035 seconds with the standard approach—a 1000x speedup. Even on "Large Deletions" (removing 25% of the dataset), the framework maintained its advantage, proving that modular overhead is negligible compared to algorithmic gains.

Table 2: Incremental maintenance times (in seconds) for deletions and insertions.

Limitations and Future Work

Currently, the paper focuses on Transitive and Symmetric-Transitive rules. Other patterns, like "Same-As" chains, could also benefit from custom modules. Additionally, while the modular approach improves deletion, integrating more recent algorithms like B/Fᶜ could further reduce overdeletion inefficiencies. Finally, automating the partitioning of arbitrary Datalog programs into modules remains an open engineering challenge.

Summary updated

BibTeX
@inproceedings{hu2019modular,
  author = {Pan Hu and Boris Motik and Ian Horrocks},
  title = {{Modular Materialisation of Datalog Programs.}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.1609/aaai.v33i01.33012859},
}
Figure