Query Answering for Existential Rules via Efficient Datalog Rewriting

Zhe Wang, Peng Xiao, Kewen Wang, Zhiqiang Zhuang, Hai WanIJCAI 2020

Abstract

Query answering over existential rules is a fundamental challenge in knowledge representation and the Semantic Web. Traditional approaches often suffer from either excessive data generation (the chase) or exponential query blow-up (First-Order rewriting). This paper introduces Drewer, a system that leverages a novel Datalog rewriting technique to produce compact, efficient programs. By utilizing rule-splitting and a shared "rewriting forest" data structure, Drewer achieves significant performance gains. Evaluation across diverse benchmarks shows that Drewer handles complex ontologies and long queries where existing state-of-the-art systems fail.

Introduction

Existential rules, or Datalog±, provide a powerful framework for reasoning about implicit entities in data. However, querying under these rules is computationally demanding. The two primary strategies—materialization (the chase) and query rewriting—each have significant drawbacks. The chase can be slow and generate massive amounts of unnecessary data, while First-Order (FO) rewriting often results in Union of Conjunctive Queries (UCQ) that are too large for standard database management systems (DBMS) to process.

Datalog rewriting offers a middle ground by transforming logic into recursive programs, but previous methods lacked the efficiency required for practical applications. This work addresses these limitations by proposing a practical Datalog rewriting approach that ensures both compactness and high performance.

Methodology

The Drewer system is built upon three core technical innovations:

  1. Rule Unfolding and Splitting: To prevent monolithic query generation, Drewer "unfolds" rules and strategically partitions them into smaller components. It introduces separating predicates—intermediate markers that facilitate the reuse of logic across different query branches.
  2. The Rewriting Forest ($F_\Sigma$): A specialized data structure, the rewriting forest, allows for the sharing of logical structures between different rules. This ensures that redundant computations are avoided and the resulting Datalog program remains compact.
  3. The "fus-shy" Logic Class: The authors identify a broad class of ontologies, termed fus-shy (combining Finite Unification Sets and Shy rules), for which their rewriting method is guaranteed to terminate. This class encompasses many real-world scenarios that were previously problematic for rewriting systems.

Experimental Evaluation

Drewer was evaluated against a comprehensive suite of benchmarks, including standard ontologies (LUBM, OpenGALEN2, OBOprotein), large-scale datasets (Reactome, Uniprot), and specialized tests like the RS benchmark for long queries.

Performance comparison of Drewer against chase-based and UCQ-based systems across various ontologies.

As shown in Figure 1, Drewer demonstrates robust performance across a wide range of ontologies. Notably, on the Uniprot dataset, chase-based systems like VLog timed out (TO), whereas Drewer successfully completed both the total processing and query answering (QA) phases efficiently.

Results and Discussion

The experimental results highlight Drewer's superiority in handling "un-handlable" cases. For instance, on the OBOprotein dataset (query q5), Drewer completed the rewriting in approximately 516ms, while all other tested systems reached a timeout.

Comparison of rewriting size and time for Datalog (Drewer, Rapid) and UCQ (Graal, Iqaros) approaches.

Figure 2 illustrates the compactness of Drewer's rewritings compared to UCQ-based systems like Graal and Iqaros. On the RS benchmark, designed to trigger query blow-up, Drewer's Datalog programs remained manageable in size and execution time, while competing systems either timed out or produced significantly larger rewritings.

Key Insights

  • Compactness is King: The use of intermediate Datalog predicates allows for a polynomial representation of what would otherwise be an exponentially large FO query. This makes the resulting query much more efficient for standard database engines.
  • Versatility: By targeting the "fus-shy" fragment, Drewer provides a versatile solution for a wide array of practical logic fragments, including linear, sticky, and shy rules.
  • Rewriting vs. Chase: Rewriting proves particularly advantageous when queries depend on a small subset of data or when the data complexity makes full materialization infeasible, as seen in the Uniprot results.

Conclusion

Drewer represents a significant advancement in query answering for existential rules. By focusing on efficient Datalog rewriting, it overcomes the scalability issues of traditional methods. Future work will explore even broader classes of rewritable rules and further optimizations for distributed database environments.

Summary updated

BibTeX
@inproceedings{wang2020query,
  author = {Zhe Wang and Peng Xiao and Kewen Wang and Zhiqiang Zhuang and Hai Wan},
  title = {{Query Answering for Existential Rules via Efficient Datalog Rewriting}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2020},
  doi = {10.24963/ijcai.2020/268},
}
Figure