Practical Reasoning in DatalogMTL

Dingmin Wang, Przemysław A. Wałęga, Pan Hu, Bernardo Cuenca Grau · DOI

TL;DR

This paper introduces MeTeoR, the first practical reasoning system for DatalogMTL that is sound, complete, and guaranteed to terminate. By cleverly combining a highly optimized "seminaïve" materialization procedure with an automata-based fallback, the authors enable efficient reasoning over temporal datasets containing tens of millions of facts.

What Problem Does This Paper Address?

Datalog is a staple of logic programming, used to derive new information from existing facts using rules. DatalogMTL extends this by adding Metric Temporal Logic (MTL) operators, allowing rules to reason about when things happen (e.g., "If a patient had a fever sometime in the last 2 days and has been coughing continuously for 15 days, then...").

While powerful, reasoning in DatalogMTL is notoriously difficult—it is ExpSpace-complete. The core challenge is "recursion through time." Standard forward-chaining (materialization) can fall into infinite loops, while theoretical alternatives like LTL reduction or Büchi automata suffer from exponential state-space explosions that make them impractical for real-world data. This paper bridges the gap between theoretical complexity and practical performance.

Methods

The authors propose a hybrid algorithm implemented in a system called MeTeoR. Its architecture relies on three main pillars:

  1. Optimized Seminaïve Materialization: Standard materialization often re-derives the same facts repeatedly. The authors developed a "seminaïve" version for DatalogMTL that ensures each rule instance is considered at most once (the non-repetition property).
  2. Rule Discarding: A novel optimization that identifies when a rule has "exhausted" its potential. For example, in forward-propagating programs, once the system has processed all facts up to a certain time point, it can safely discard rules that only look at the past, significantly reducing redundant computation.
  3. The Hybrid Strategy: The system first runs a terminating version of materialization. If a result isn't found, it launches two parallel threads: one continues materialization (which is fast but might not terminate) and the other uses an automata-based procedure (which is slow but guaranteed to terminate). This "best of both worlds" approach ensures the system is always correct and eventually finishes.

The semantics of the temporal operators used in these methods are summarized in the table below:

Semantics of ground metric atoms

Datasets

The authors evaluated MeTeoR using three distinct benchmarks:

  • Temporal LUBM: An extension of the Lehigh University Benchmark, featuring 29 recursive rules and datasets of varying sizes.
  • Weather Benchmark: Real-world US meteorological data containing 397 million temporal facts, used to test non-recursive reasoning.
  • iTemporal: A synthetic benchmark generator used to create complex recursive programs and datasets to test the limits of the system.

Key Insights and Ideas

  • Discretization is Key: To handle the dense rational timeline, the system partitions time into regular intervals (punctual points and open segments) where the truth of atoms remains uniform.
  • Automata > LTL: While DatalogMTL can be reduced to Linear Temporal Logic (LTL), the authors found that a direct automata-based approach is roughly an order of magnitude faster than using state-of-the-art LTL solvers like BLACK.
  • Materialization Does the Heavy Lifting: In 99.7% of tested cases, the materialization component was able to answer the query on its own, with the expensive automata component only needed in rare, "exceptional" cases. This justifies the design of delegating the bulk of the work to the scalable materialization engine.

Key Results

  • Scalability: MeTeoR successfully processed datasets with up to 10 million temporal facts, a significant feat for a logic with such high theoretical complexity.
  • Efficiency: The seminaïve strategy consistently outperformed naïve materialization in both time and memory usage.
  • Superiority over Baselines: MeTeoR outperformed existing query-rewriting approaches on non-recursive programs and proved much more practical than LTL-reduction methods.

Limitations and Future Work

While MeTeoR is a major step forward, the authors note some areas for improvement:

  • Automata Bottleneck: The automata-based component, while necessary for completeness, still struggles to scale beyond a few thousand facts if materialization fails to reach a fixpoint.
  • Negation: The current system focuses on positive DatalogMTL. The authors suggest extending the seminaïve procedure to handle stratified negation-as-failure.
  • Periodic Models: They are exploring "blocking conditions" that could detect periodic patterns in temporal models, potentially allowing the materialization component to terminate even more often.

Summary updated

BibTeX
@article{wang2025practical,
  author = {Dingmin Wang and Przemysław A. Wałęga and Pan Hu and Bernardo Cuenca Grau},
  title = {{Practical Reasoning in DatalogMTL}},
  journal = {Theory Pract. Log. Program.},
  year = {2025},
  doi = {10.1017/s1471068424000164},
}
Figure