Stream Reasoning in Temporal Datalog

Alessandro Ronca, Mark Kaminski, Bernardo Cuenca Grau, Boris Motik, Ian Horrocks

Abstract

Stream reasoning extends traditional stream processing by applying complex logical rules to real-time data. However, two fundamental challenges hinder its practical application: determining when a system can output a final answer without waiting for future data (latency) and identifying when data can be safely purged from memory (storage). This paper establishes a formal theoretical foundation for these problems within the framework of Temporal Datalog. We identify the computational complexity of determining definitive answers and safe forgetting, demonstrating that while the general recursive case is often undecidable, nonrecursive queries—highly relevant to industrial applications—are computationally tractable.

1. Introduction

In modern data engineering, the ability to analyze high-velocity streams—such as financial tickers, network traffic, or industrial sensor data—is critical. While standard stream processing excels at simple filtering and aggregation, "stream reasoning" introduces sophisticated logic. For instance, monitoring a wind turbine might require a rule like: "If a high-temperature event occurs at time $t$ and persists at $t+1$, trigger a maintenance alert."

This logical depth introduces two operational bottlenecks:

  1. The Latency Problem: Because rules can reference future time points, a system may not know if a current output is "final" or if subsequent data will invalidate it.
  2. The Memory Problem: Because rules can reference the past, the system must maintain a history of facts. In an infinite stream, keeping all history is impossible.

This research addresses these bottlenecks by asking: Can we mathematically determine the minimum wait time for a definitive answer and the minimum history required for memory?

2. Temporal Datalog and Problem Formulation

The authors utilize Temporal Datalog, a logic-based language that extends standard Datalog with a successor function ($t+1$). This allows rules to reference specific, discrete points in time. Within this framework, four key decision problems are formalized:

Online Problems (Data-Dependent)

  • Definitive Time Point (DTP): Given the current history, is the answer for a specific time $\tau$ final, or could future data change it?
  • Forgetting: Can a specific fact be safely deleted from memory without affecting any future answers?

Offline Problems (Data-Independent)

  • Delay: What is the maximum "lag" $d$ required to guarantee definitive answers for any possible input stream?
  • Window Size: What is the maximum "sliding window" $s$ of history required to ensure no relevant data is ever lost?

3. Key Insights: The Critical Update and Program Radius

A major contribution of this work is the "Critical Update" shortcut. To determine if an answer is definitive, a system theoretically needs to consider all possible future data. The authors prove that this is unnecessary; one only needs to check a single "critical update"—a worst-case scenario of future facts. If the answer remains stable under this scenario, it is definitive.

Furthermore, the authors introduce the concept of a "program radius." This metric measures how far forward or backward a set of rules can propagate information. This radius serves as the mathematical foundation for calculating the necessary window size and delay for a given set of rules.

4. The Complexity Landscape

The research reveals a sharp divide in computational difficulty based on whether the rules are recursive (where rules can refer back to themselves).

Problem General (Recursive) Case Nonrecursive Case
DTP (Definitive Answer) PSPACE-complete P (Tractable)
Forgetting (Memory) Undecidable P (Tractable)
Delay / Window Size Undecidable co-NEXP-complete

The most striking finding is that for general recursive rules, the problem of "forgetting" is undecidable. There is no algorithm that can always determine if a fact is safe to delete. However, for nonrecursive rules—which encompass a vast majority of practical monitoring and alerting tasks—the online problems (DTP and Forgetting) fall into the complexity class P. This indicates that efficient, real-time engines can be built to manage latency and memory on the fly.

5. Limitations and Future Directions

While providing a robust foundation, the study notes several constraints:

  • Connectedness: The tractability results assume "connected" queries, where variables are linked in specific patterns.
  • Encoding: The complexity assumes timestamps are in unary encoding; binary encoding might shift these results.
  • Negation: The current study focuses on negation-free Datalog. Incorporating "NOT" logic (e.g., "if event A happens and event B does not") remains a challenge for future work.

6. Conclusion

This paper bridges the gap between formal logic and stream processing. By proving that nonrecursive stream reasoning is computationally manageable, it paves the way for a new generation of intelligent monitoring systems that know exactly when to speak and when to forget.

Summary updated

BibTeX
@inproceedings{ronca2018stream,
  author = {Alessandro Ronca and Mark Kaminski and Bernardo Cuenca Grau and Boris Motik and Ian Horrocks},
  title = {{Stream Reasoning in Temporal Datalog}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2018},
  doi = {10.1609/aaai.v32i1.11537},
}
Figure