Introduction
In Knowledge Representation and Reasoning, existential rules (also known as Datalog±) provide a powerful framework for describing ontologies. These rules allow for the inference of missing information—for instance, concluding that "every person has a parent who is also a person." However, querying data under these rules is computationally intensive and, in the general case, undecidable.
A prevalent strategy to manage this complexity is query rewriting. This process transforms a conjunctive query and an ontology into a new query that can be executed by a standard Database Management System (DBMS). Historically, most systems have focused on First-Order (FO) logic rewritings, typically resulting in a Union of Conjunctive Queries (UCQ). The primary drawback of FO rewriting is the "size explosion" phenomenon, where the resulting query becomes too massive for a DBMS to process efficiently. While Datalog rewritings (which allow recursion) offer a more compact alternative, bridging the gap between theoretical Datalog rewriting and a high-performance, practical implementation has remained a significant challenge.
Methodology: The Drewer System
This paper introduces Drewer, a prototype system that implements a novel Datalog rewriting algorithm based on the concept of unfolding. The authors propose several key innovations to ensure the resulting programs remain compact and executable:
The Separation Technique
To avoid the exponential growth characteristic of FO methods, Drewer employs a separation technique. Instead of generating a single, monolithic rule for a complex query, the algorithm decomposes long rules into smaller "chunks." By introducing fresh intermediate predicates, the system breaks down the logical dependencies, preventing redundant atom repetition.
Graph-Based Structure Sharing
The algorithm utilizes a Rewriting Graph to manage the transformation process. This graph-based representation allows the system to identify identical sub-structures within different parts of a rewriting. By reusing intermediate predicates across the graph, Drewer achieves significant compression. If a new node in the graph is found to be subsumed by an existing one, it is eliminated early, further streamlining the output.
New Rule Classes
The authors identify and define a new class of ontologies termed separable rule sets. This class generalizes existing "shy" rule sets. The paper provides theoretical proof that the Drewer algorithm is guaranteed to terminate and produce correct results for separable, sticky, and acyclic rule sets.
Experimental Evaluation
The researchers evaluated Drewer using a suite of well-known benchmark ontologies and query sets:
- Size and Time Benchmarks: Adolena (A), OpenGALEN2 (G), and StockExchange (S) were used to measure the efficiency of the rewriting process itself.
- End-to-End Performance: LUBM and Reactome were used for query answering tests. Reactome provided a particularly rigorous testbed with over 100 complex queries.
Drewer was compared against state-of-the-art systems including Graal, Iqaros, and the hybrid system Pagoda.
Key Results and Insights
The evaluation demonstrated that Datalog's ability to handle recursion and intermediate predicates provides a superior "divide and conquer" approach to query rewriting.
- Compactness: For the complex OpenGALEN2 ontology, traditional UCQ rewritings produced programs with up to 624 atoms. In contrast, Drewer generated rewritings with as few as 37 to 80 atoms.
- Query Efficiency: In end-to-end testing on the LUBM dataset, Drewer significantly outperformed Graal. For example, on query $q_2$, Graal required approximately 13.8 seconds to complete, whereas Drewer finished in just 0.46 seconds.
- Preprocessing: While Drewer requires an initial phase to construct the Datalog program, this preprocessing time was generally lower than the materialization times required by hybrid systems like Pagoda.
Conclusion and Future Work
Drewer successfully transitions Datalog rewriting from a theoretical concept into a practical tool capable of outperforming established FO-based systems. By leveraging intermediate predicates and graph-based sharing, it produces compact, efficient rewritings for complex existential rules.
However, limitations remain. Because the general problem of existential rule querying is undecidable, the algorithm is only guaranteed to terminate on specific classes (separable, sticky, and acyclic). Future research will focus on identifying broader classes of rules that can be handled by this approach and further optimizing the generated Datalog code for specific DBMS engines.
Summary updated