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

Combining Rewriting and Incremental Materialisation Maintenance for Datalog Programs with Equality

Boris Motik, Yavor Nenov, Robert Piro, Ian Horrocks

Abstract: Materialisation precomputes all consequences of a set of facts and a datalog program so that queries can be evaluated directly. Rewriting optimises materialisation for datalog programs with equality by replacing all equal constants with a single representative; and incremental maintenance algorithms can efficiently update a materialisation for small changes in the input facts. Both techniques are critical to practical applicability of datalog systems; however, we are unaware of an approach that combines rewriting and incremental maintenance. In this paper we present the first such combination, and we show empirically that it can speed up updates by several orders of magnitude compared to using either rewriting or incremental maintenance in isolation.

Introduction

Materialisation is a core technique in Datalog systems, precomputing all logical consequences of a set of facts and rules to enable rapid query evaluation. However, real-world applications often involve equality ($\approx$), which can lead to a combinatorial explosion of redundant facts. Rewriting optimizations address this by merging equal constants into single representatives. Simultaneously, dynamic datasets require incremental maintenance to update materialisations without full re-computation. Until now, these two critical techniques—rewriting and incremental maintenance—have not been successfully combined due to the complexity of "un-merging" constants when equalities are deleted.

The $B/F^\approx$ Algorithm

The authors introduce $B/F^\approx$, the first algorithm to integrate rewriting with incremental maintenance. It extends the "Backward/Forward" (B/F) update strategy to handle the volatile nature of equality.

Key components of the algorithm include:

  • Canonical Representatives: Instead of storing every variation of an equal object, the system picks one "representative" and rewrites all facts to use it, collapsing large cliques of redundant data.
  • Doubtful Fact Tracking: When a fact is deleted, the algorithm marks affected facts as "doubtful."
  • Hybrid Chaining: It uses backward chaining to see if a doubtful fact can be proven another way. If not, it uses forward chaining to find and prune all downstream consequences of that deletion.
  • Equality Restoration: If a deletion breaks an equality, the algorithm identifies which facts need to be "restored" to their original, distinct forms.

Empirical Evaluation

The researchers evaluated $B/F^\approx$ across several benchmarks, including Claros, DBpedia, UniProt, and UOBM. The performance was compared against both standard axiomatic approaches (denoted with superscript $A$) and rewriting-based re-materialisation (denoted with superscript $\approx$).

Performance results for the Claros-LE dataset, showing significant speedups for small updates compared to re-materialisation.

As shown in the Claros-LE results (Figure 1), for an update of 100 facts ($|E^-|$), $B/F^\approx$ completes in 0.6 seconds, whereas re-materialisation from scratch (Remat$^\approx$) takes 45.1 seconds. The algorithm remains effective for larger updates, only approaching the cost of full re-calculation when a significant portion of the database changes.

Performance results for the UOBM-100-UE dataset, highlighting the advantage of $B/F^\approx$ over standard axiomatic incremental maintenance ($B/F^A$).

The most dramatic improvements were observed in complex ontologies like UOBM-100-UE. In this test (Figure 6), for an update of 100 facts, the standard incremental algorithm ($B/F^A$) took 5703 seconds, while $B/F^\approx$ required only 16.1 seconds—a speedup of over two orders of magnitude. This demonstrates that combining rewriting with incremental maintenance is far more effective than using either technique in isolation.

Conclusion and Future Work

$B/F^\approx$ represents a significant advancement in Datalog reasoning, offering orders-of-magnitude speedups for updates in the presence of equality. While highly effective, the authors note that certain rules still impose high computational costs during updates. Future work will focus on specialized optimizations for these rules and improving index lookup efficiency for massive datasets like OpenCyc.

Summary updated

BibTeX
@inproceedings{motik2015combining,
  author = {Boris Motik and Yavor Nenov and Robert Piro and Ian Horrocks},
  title = {{Combining Rewriting and Incremental Materialisation Maintenance for Datalog Programs with Equality}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2015},
  url = {https://openreview.net/forum?id=BkbUBXM_-r},
}
Figure