Table of Contents
Fetching ...

Rule Rewriting Revisited: A Fresh Look at Static Filtering for Datalog and ASP

Philipp Hanisch, Markus Krötzsch

TL;DR

This work revisits static filtering, a data-independent optimization for Datalog, and extends it to modern rule engines and ASP. It formalizes a general filtering framework with expressive filter predicates, analyzes the inherent worst-case complexity (including double exponential growth in general and single exponential growth under bounded-arity restrictions), and proposes tractable approximations (CASF) based on conjunctive filters and approximate entailment. The authors also adapt static filtering to nonmonotonic negation, proving that admissible rewritings preserve output semantics via a bijection between stable models of the original and rewritten programs. Empirically, the approach demonstrates meaningful performance gains on real-world data, and the framework is positioned to synergize with other optimizations and to support modular and terminating reasoning in arithmetic-rich rule languages.

Abstract

Static filtering is a data-independent optimisation method for Datalog, which generalises algebraic query rewriting techniques from relational databases. In spite of its early discovery by Kifer and Lozinskii in 1986, the method has been overlooked in recent research and system development, and special cases are being rediscovered independently. We therefore recall the original approach, using updated terminology and more general filter predicates that capture features of modern systems, and we show how to extend its applicability to answer set programming (ASP). The outcome is strictly more general but also more complex than the classical approach: double exponential in general and single exponential even for predicates of bounded arity. As a solution, we propose tractable approximations of the algorithm that can still yield much improved logic programs in typical cases, e.g., it can improve the performance of rule systems over real-world data in the order of magnitude.

Rule Rewriting Revisited: A Fresh Look at Static Filtering for Datalog and ASP

TL;DR

This work revisits static filtering, a data-independent optimization for Datalog, and extends it to modern rule engines and ASP. It formalizes a general filtering framework with expressive filter predicates, analyzes the inherent worst-case complexity (including double exponential growth in general and single exponential growth under bounded-arity restrictions), and proposes tractable approximations (CASF) based on conjunctive filters and approximate entailment. The authors also adapt static filtering to nonmonotonic negation, proving that admissible rewritings preserve output semantics via a bijection between stable models of the original and rewritten programs. Empirically, the approach demonstrates meaningful performance gains on real-world data, and the framework is positioned to synergize with other optimizations and to support modular and terminating reasoning in arithmetic-rich rule languages.

Abstract

Static filtering is a data-independent optimisation method for Datalog, which generalises algebraic query rewriting techniques from relational databases. In spite of its early discovery by Kifer and Lozinskii in 1986, the method has been overlooked in recent research and system development, and special cases are being rediscovered independently. We therefore recall the original approach, using updated terminology and more general filter predicates that capture features of modern systems, and we show how to extend its applicability to answer set programming (ASP). The outcome is strictly more general but also more complex than the classical approach: double exponential in general and single exponential even for predicates of bounded arity. As a solution, we propose tractable approximations of the algorithm that can still yield much improved logic programs in typical cases, e.g., it can improve the performance of rule systems over real-world data in the order of magnitude.
Paper Structure (12 sections, 27 theorems, 12 equations, 3 figures, 2 tables, 2 algorithms)

This paper contains 12 sections, 27 theorems, 12 equations, 3 figures, 2 tables, 2 algorithms.

Key Result

Theorem 5

If $P'$ is an admissible rewriting of $P$, and $p(\bm{c})$ is a fact with $p\in\mathbf{P}_{\text{\sf{out}}}$, then $P,\mathcal{D} \models p(\bm{c})$ iff $P',\mathcal{D} \models p(\bm{c})$.

Figures (3)

  • Figure 1: Template programs for transitive closure over some EDB predicate $p \in \mathbf{P}$; some filter predicate $x \mathrel{\overset{\cdot}{=}} a \in \mathbf{F}$ with constant $\mathtt{a}\xspace$ is applied to compute the output predicate $\textit{out} \in \mathbf{P}_{\text{\sf{out}}}$; original program (left) and rewritten program by tractable static filtering (right)
  • Figure 2: Table of used Wikidata properties used in the evaluation, i.e., the programs in Figure \ref{['fig_eval_templates']} are instantiated with properties $p$ and entities $\mathtt{a}\xspace$; #Facts is the number of facts for property $p$
  • Figure 3: Runtimes (median of five runs) for transitive closure programs for different properties and rule systems; solid bars show runtime for original programs; hatched bars show runtime for rewritten programs; runtime of static filtering (black, solid lines); timeout (red, dotted lines) at 5min

Theorems & Definitions (37)

  • Example 1
  • Example 2
  • Example 3
  • Definition 4
  • Theorem 5
  • Example 6
  • Theorem 7
  • Example 8
  • Example 9
  • Lemma 9
  • ...and 27 more