<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Reasoning Techniques in DatalogMTL</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Przemysław Andrzej Wałęga</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Michał Zawidzki</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Bernardo Cuenca Grau</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science, University of Oxford</institution>
          ,
          <addr-line>7 Parks Rd, Oxford, OX1 3QG</addr-line>
          ,
          <country country="UK">United Kingdom</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Department of Logic, University of Łódź</institution>
          ,
          <addr-line>Lindleya 3/5, 91-131 Łódź</addr-line>
          ,
          <country country="PL">Poland</country>
        </aff>
      </contrib-group>
      <fpage>127</fpage>
      <lpage>138</lpage>
      <abstract>
        <p>DatalogMTL is a recently introduced extension of Datalog with operators from metric temporal logic (MTL). It allows for performing complex temporal reasoning tasks over the rational timeline, which makes it suitable for many practical applications. Although the main reasoning tasks in DatalogMTL are decidable, they have high computational complexity, and so, developing practically eficient reasoning techniques is challenging. Consequently, a number of approaches have been recently established; some of them have already been implemented and tested experimentally, but no comparison of these techniques has been provided yet. To fill this gap, we present an overview of reasoning techniques in DatalogMTL, sketch relations between them, and discuss their properties. Moreover, we present our ongoing research in this area and possible future directions thereof.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;DatalogMTL</kwd>
        <kwd>temporal Datalog</kwd>
        <kwd>reasoning techniques</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        DatalogMTL [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] is a recently introduced extension of Datalog with operators from metric
temporal logic (MTL) [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] interpreted over the rational timeline; for example an atom x[0,60](, )
states that (, ) did hold at some time point in the past at least 0 and at most 60 seconds
ago, whereas ⊟[0,60](, ) states that (, ) did hold continuously in the above-mentioned
interval. Such operators allow us to express complex temporal properties, like a turbine’s active
power trip, which is defined in Siemens remote diagnostic centre as an event when ‘the active
power was above 1.5MW for a period of at least 10 seconds, maximum 3 seconds after which
there was a period of at least one minute where the active power was below 0.15MW’ [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
Indeed, we can express this concept with the rule
      </p>
      <p>Active() ←</p>
      <p>
        Turbine () ∧ ⊟[0,60)Below 0.15() ∧ x[60,63] ⊟[
        <xref ref-type="bibr" rid="ref10">0,10</xref>
        ] Above1.5().
      </p>
      <p>
        Due to its high expressive power, DatalogMTL has found a number of potential applications,
including stream reasoning [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], temporal ontology-based data access [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], and verification of
banking agreements [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Consistency checking and fact entailment in DatalogMTL, however,
are of high computational complexity (ExpSpace for combined [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], and PSpace for data
complexity [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]), which makes the development of scalable implementations challenging. Despite
these dificulties, there is currently growing interest in the development of practical reasoning
algorithms for DatalogMTL, and new systems are becoming available.
      </p>
      <p>In this paper, we provide a comprehensive overview of the diferent reasoning techniques
available for DatalogMTL and discuss future research directions. In particular, we observe that
reasoning techniques for DatalogMTL can be divided into two main groups:
1. Approaches based on materialisation (a.k.a. forward chaining), which derive and store in
memory all facts that are entailed by a program and dataset. This is obtained by means of
successive rounds of rule applications until a fixpoint is reached; the resulting set of facts
is called the materialisation. In these approaches, fact entailment and query answering
are performed directly over the materialisation. The main obstacle, however, is that the
materialisation process in DatalogMTL is not guaranteed to terminate.
2. Approaches based on discretisation of the rational timeline, that is, on partitioning the
dense timeline into a discrete sequence of intervals, within which all the time points
satisfy the same relational atoms. Since this sequence of intervals is discrete, it allows
us for exploiting techniques used for reasoning in temporal logics interpreted over the
discrete timeline (e.g., linear temporal logic LTL). The problem of such approaches is that
their implementations are usually ineficient in practice.</p>
      <p>In the remainder of this paper, we will discuss in detail these approaches. We start by
recapitulating the syntax, semantics, and main reasoning tasks for DatalogMTL in Section 2. In
Section 3, we describe materialisation-based reasoning techniques, which exploit the fixpoint
characterisation of the DatalogMTL semantics; in particular, we discuss the naïve approach to
materialisation which does not guarantee termination, introduce finitely materialisable programs
for which materialisation always terminates, and discuss algorithms based on sliding windows
which are particularly useful in the stream reasoning setting. Next, in Section 4, we describe
reasoning based on the discretisation of time; we show how the timeline can be discretised and
how discretisation can be used to devise a translation to LTL or to provide Büchi automata and
arithmetic progressions capturing the meaning of a DatalogMTL program. Finally, we present
our ongoing research and outline its possible future directions in Section 5.</p>
    </sec>
    <sec id="sec-2">
      <title>2. DatalogMTL</title>
      <p>
        In this section, we introduce DatalogMTL; we will focus on the standard setting given by
‘continuous semantics’ and interpretations over the rational timeline. It is, however, worth
mentioning that DatalogMTL was also studied under an alternative ‘pointwise’ semantics [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]
and interpreted over the integer timeline [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <sec id="sec-2-1">
        <title>2.1. Syntax</title>
        <p>Syntactically, DatalogMTL is an extension of Datalog with the MTL operators x, |, ⊟, ⊞, ,
and  , which are indexed with rational intervals  containing only non-negative numbers.
We distinguish two types of atoms. Relational atoms are standard Datalog atoms of the form
 (s), with an arbitrary arity predicate  and a tuple s of terms (variables or constants). Metric
atoms extend relational atoms by allowing MTL operators, and are generated by the following
grammar:</p>
        <p>::= ⊤ | ⊥ |  (s) | x | | | ⊟ | ⊞ |   |  .</p>
        <p>Then, DatalogMTL rules are of the form
 ′ ←
1 ∧ · · · ∧
,
for  ≥ 1,
where each body atom  is a metric atom, and the head atom  ′ is a metric atom not mentioning
any of the ‘non-deterministic’ operators x, |, , and  . As usual, a program Π is a finite set
of safe rules, but the definition of safety in DatalogMTL is slightly more elaborated than in
Datalog. In particular, we do not only require that each variable in a rule’s head occurs in this
rule’s body, but also that this occurrence in the body is not in a left operand of  or  . This
additional requirement discards, for example, a rule of the form () ← ()[0,0]⊤, which is
equivalent to () ← ⊤ (see the semantics of DatalogMTL operators from the next subsection),
and so, should not be treated as safe.</p>
        <p>A DatalogMTL dataset  is a finite set of facts of the form  @, where  is a ground (i.e.,
with no variables) relational atom and  is an interval in which  holds true.</p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. Semantics</title>
        <p>A DatalogMTL interpretation I can be seen as a set containing one standard Herbrand
interpretation for each rational time point. More precisely, I specifies, for each ground relational
atom  and each time point  ∈ Q, whether  holds at , in which case we write I,  |=  .
Satisfaction of relational atoms determines satisfaction of (more complex) metric atoms, as
presented below.</p>
        <p>I,  |= ⊤
I,  |= ⊥
I,  |= x
I,  |= |
I,  |= ⊟
I,  |= ⊞
I,  |= 12
I,  |= 12
if
if
if
if
if
if
for each ,
for no ,
I, ′ |=  for some ′ with  − ′ ∈ ,
I, ′ |=  for some ′ with ′ −  ∈ ,
I, ′ |=  for all ′ with  − ′ ∈ ,
I, ′ |=  for all ′ with ′ −  ∈ ,
I, ′ |= 2 for some ′ with  − ′ ∈  and
I, ′′ |= 1 for all ′′ ∈ (′, ),
I, ′ |= 2 for some ′ with ′ −  ∈  and
I, ′′ |= 1 for all ′′ ∈ (, ′).</p>
        <p>A fact  @ is satisfied if  is satisfied at all time points  ∈ , whereas a rule  is satisfied
if, for each of its ground instances ′ and for each time point , if all the body atoms of ′ are
satisfied at , then so is the head of ′. As usual, a model of a dataset  or of a program Π is an
interpretation which satisfies all facts in  or all rules in Π , respectively. Program Π and dataset
 are consistent if they have a model (note that if none of the rules mentions ⊥ in the head,
then an inconsistency cannot occur—in the absence of negation in the language of DatalogMTL,
⊥ is the only means for expressing a contradiction), and they entail a fact  @ if each model
of both Π and  is a model of  @.</p>
      </sec>
      <sec id="sec-2-3">
        <title>2.3. Complexity of Reasoning</title>
        <p>
          The main reasoning tasks considered in DatalogMTL are fact entailment and consistency checking.
These problems polynomially reduce to the complements of each other [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ], so we identify
them with reasoning in DatalogMTL. As usual, we distinguish between combined and data
complexity, where in the latter case the input consists of a dataset only, while programs are
considered fixed. Reasoning in DatalogMTL is decidable but of high complexity; in particular, it
is ExpSpace-complete for combined complexity [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ] and PSpace-complete for data complexity [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ].
A number of lower-complexity fragments of DatalogMTL have been introduced, for example
ifnitely-materialisable programs with ExpTime-complete combined complexity of reasoning [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ],
linear and core fragments with NL- and TC0-complete data complexity [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ], and the
nonrecursive fragment with AC0 data complexity [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. DatalogMTL has also been extended with
non-monotonic negation, which does not increase the complexity for stratifiable programs
[
          <xref ref-type="bibr" rid="ref11">11</xref>
          ], but leads to undecidability if a program is not stratifiable, unless it is interpreted over
the integer timeline [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. In contrast, in negation-free DatalogMTL reasoning over the integer
timeline is as hard as over the rational timeline [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ].
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Approaches Based on Materialisation</title>
      <p>We observe that there is a group of reasoning techniques for DatalogMTL whose main
component is the materialisation process. This process mimics the fixpoint characterisation of
DatalogMTL semantics, as we describe in the first part of this section.</p>
      <sec id="sec-3-1">
        <title>3.1. Fixpoint Characterisation and Basic Materialisation</title>
        <p>The fixpoint characterisation is based on the observation that each pair of a consistent program
Π and a dataset  admits a unique least model, which we refer to as their canonical interpretation
CΠ,. As in Datalog, we can construct this interpretation by applying rules of Π to  in a
forward-chaining manner until a fixpoint is reached. However, unlike in Datalog, the fixpoint
in DatalogMTL may only be reachable after infinitely many materialisation steps; for example,
given a fact  @0, the rule ⊞1 ←  propagates  to all positive integers, which requires 
materialisation steps.</p>
        <p>Formally, we define the immediate consequence operator Π for a program Π as the operator
mapping each interpretation I to the least interpretation containing I and satisfying the
following property for each ground instance  of a rule in Π : whenever I satisfies each body
// initialise new
Procedure 1: Materialisation-based reasoning</p>
        <p>Input: A program Π and a dataset</p>
        <p>Output: A dataset
1 new := ;
2 repeat
3
4
5 until old = new;
6 return new;
old := new; // copy new before applying rules
new := the least dataset representation of Π(Inew );
atom of  at a time point , then Π(I) satisfies the head of  at . Subsequent applications of Π
to the (least) model I of  define the following sequence of interpretations, for all ordinals  :
Π0 (I) = I,
 Π (I) = Π (︀  Π− 1(I)︀) ,
 Π (I) = ⋃︁  Π(I),
&lt;
for  a successor ordinal,
for  a limit ordinal.</p>
        <p>
          If Π and  are consistent, then the canonical interpretation is obtained after at most 1 (i.e.,
the first uncountable ordinal) applications of the immediate consequence operator; that is,
CΠ, =  Π1 (I) [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ].
        </p>
        <p>The fixpoint characterisation suggests a naïve materialisation-based reasoning approach
presented in Procedure 1; given a program Π and a dataset , the procedure applies the
immediate consequence operator Π until no new facts can be derived, that is, a fixpoint is
reached.</p>
        <p>
          We have recently implemented this approach in the metric temporal reasoner MeTeoR, and
provided an eficient way of computing Π(Inew ), which allowed us to handle datasets with
hundreds of millions of facts [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ]. The naïve materialisation procedure was also implemented
by rewriting a program into a set of standard SQL queries (with views) [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ], which was exploited
in the Ontop ontology-based data access reasoning system to answer temporal queries [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ].
        </p>
        <p>
          The advantage of rewriting DatalogMTL programs into SQL is that constructed queries can
be evaluated with standard systems such as PostgreSQL or Apache Spark. The downside of
this approach, however, is that relying on SQL systems limits the possibility of controlling and
optimising computations which are specific to DatalogMTL materialisation. Such materialisation
requires, for example, computing numerous temporal joins, and the experimental evaluation [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ]
shows that a handcrafted implementation in MeTeoR of such computations (obtained by first
sorting the sets of intervals involved in a join and then linearly scanning these sets to compute
the relevant intersections) significantly outperforms the approach based on SQL rewritings (the
latter is not optimised for intersecting time intervals).
        </p>
        <p>Clearly, materialisation is a sound reasoning technique, but the procedure is not always
terminating, as reaching the fixpoint may require an infinite number of materialisation steps.
However, if a fixpoint is reached, then a representation of the full canonical interpretation can
be kept in memory, which can be used for an eficient verification of entailment of any fact.
6 until old = new;
7 return true;
Algorithm 2: Checking finite materialisability for a single dataset</p>
        <p>Input: A bounded program Π and a bounded dataset 
Output: A Boolean value
old := new;
new := the least dataset representation of Π(Inew );
if there is  @ ∈ new with  ̸⊆ Π, then Return false;</p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. Finite Materialisability</title>
        <p>Recent experiments suggest that, when materialisation terminates, it is a very scalable technique
for DatalogMTL which is well suited for reasoning with large temporal datasets. Therefore, a
natural question arises—for which reasoning instances does naïve materialisation terminate?</p>
        <p>This question has recently been studied by introducing the notion of finitely materialisable
programs. In particular, we can consider a data-dependent and a data-independent variant of
this notion as follows. We say that a program Π is finitely materialisable for a dataset  if,
when applied to , the immediate consequence operator Π reaches a fixpoint in finitely many
steps. The data-independent notion considers finite materialisability of Π for all datasets.</p>
        <p>
          The problem of checking whether a program is finitely materialisable, as well as the complexity
of reasoning in finitely materialisable programs have recently been studied for programs and
datasets in which all intervals are bounded (i.e., do not mention infinities as endpoints) [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]. In
this setting, it has been shown how to compute, for a program Π which is finitely materialisable
for a dataset , an interval Π, in which are located all the facts entailed by Π and . Thus,
checking finite materialisability boils down to performing materialisation until a fixpoint is
reached or some fact is entailed outside Π,, as depicted in Algorithm 2 (c.f. Procedure 1).
        </p>
        <p>
          On the other hand, checking if a program Π is finitely materialisable for all datasets reduces
to checking if Π is finitely materialisable for a specific critical dataset Π consisting of facts
 (s)@[0, depth(Π)] , for all predicates  occurring in Π , all tuples s of constants in Π (and one
additional fresh constant), and depth(Π) a suficiently large number depending on the intervals
occurring in Π [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]. It turns out that checking data-dependent finite materialisability is
PSpacecomplete for data and ExpSpace-complete for combined complexity, whereas checking
dataindependent finite materialisability is ExpTime-complete. Furthermore, suficient conditions
for finite materialisability have been established, which allow for a limited form of temporal
recursion and can be checked eficiently. In particular, MTL-acyclicity of a program requires that
a generalisation of the program’s dependency graph, where edges are labelled with intervals
occurring in the rules, does not contain cycles of certain types, and can be checked in NL [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ].
        </p>
        <p>Testing finite materialisability is a useful static analysis task, which can be performed ofline.
If the program is finitely materialisable, then a scalable materialisation-based algorithm with
termination guarantees can be used. Reasoning with finitely materialisable programs is also
suficiently easier from the theoretical point of view, as it is ExpTime-complete for combined
complexity, in contrast to ExpSpace-completeness for full DatalogMTL.</p>
      </sec>
      <sec id="sec-3-3">
        <title>3.3. Sliding Windows</title>
        <p>
          Another reasoning approach in DatalogMTL consists in materialising all the facts within a
bounded fragment of the timeline—called a window—and then sliding the window by some
distance towards the future. The algorithm ‘forgets’ all the facts outside the current window
and repeats the process, by materialising all the facts in the current window, and then, sliding it
further towards the future. The main advantage of this approach is that it keeps in memory only
facts describing a fixed fragment of the timeline. Hence, the approach is particularly useful in
the stream reasoning setting, where reasoning is performed based on a continuously increasing
and potentially infinite stream of input facts, in contrast to a static dataset considered in the
standard setting [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ].
        </p>
        <p>
          Like the other materialisation-based techniques for reasoning in DatalogMTL, using sliding
windows constitutes a sound approach. Notice, however that, in general, materialisation based
only on the information kept within a bounded window may lead to the incompleteness of
reasoning. Nevertheless, completeness can be retained for forward-propagating programs, where
rules can propagate information only towards the future, and which are a natural choice in the
stream reasoning setting [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ]. Moreover, it is worth noting that even though a sliding window
is of a bounded length, it can contain an unbounded number of facts since DatalogMTL is
interpreted over the rational timeline. One way to bound the memory usage is to disallow
punctual intervals (i.e., containing a single time point) in a program which, in turn, allows for
keeping in memory a succinct bounded-size representation of facts in a window [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ].
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Approaches Based on Discretisation of Time</title>
      <sec id="sec-4-1">
        <title>4.1. Time Discretisation</title>
        <p>
          Although the timeline in DatalogMTL is dense, it can be divided into regularly distributed
intervals which are uniform in the sense that all time points belonging to the same interval
satisfy exactly the same relational atoms. This observation was first exploited to partition the
rational timeline, for a program Π and dataset , into punctual intervals [ · ,  · ] and open
intervals (( − 1) · ,  · ), for each  ∈ Z, where  is the greatest common divisor (gcd) of the
numbers occurring as interval endpoints in Π and  [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. Later, an alternative partitioning of
the timeline was proposed [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ], where punctual intervals of the form [ · ,  · ] are replaced with
punctual intervals [ +  · ′,  +  · ′], for all rational numbers  in ,  ∈ Z, and ′ the gcd of
numbers occurring in Π ; in turn, open intervals of the form (( − 1) · ,  · ) were replaced
with open intervals located between the new punctual intervals. Below we present exemplary
partitionings of the timeline into intervals stemming from both discretisation methods, for
the case where the only rational numbers occurring in  are 12 and 23 and the gcd of Π is 1
(therefore,  = 16 and ′ = 1).
0 61 13 12 23 56 1 116 113 112 123 156 2 216 231 221 223 256 3
0
The main advantage of the second partitioning is that gcd is computed independently of ,
which was used in devising reasoning techniques with a better computational behaviour for
data complexity [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ].
        </p>
      </sec>
      <sec id="sec-4-2">
        <title>4.2. Translation to LTL</title>
        <p>
          Discretisartion of time was exploited by Brandt et al. [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ] to reduce reasoning in DatalogMTL to
reasoning in linear temporal logic (LTL). The reduction consists in transforming a program Π
and a dataset  into an LTL formula  Π, such that Π and  are consistent if and only if  Π,
is LTL-satisfiable (over the integer timeline).
        </p>
        <p>In its basic variant, LTL is a propositional modal logic interpreted over the ordered set of
natural numbers, whose language involves boolean connectives and temporal operators ○ 
for at the previous time point , □  for always in the past, ○  for at the next time point, and □ 
for always in the future. An LTL formula  is satisfiable if there exists an LTL model in which 
is satisfied at 0.</p>
        <p>Since, in contrast to DatalogMTL, the language of LTL is propositional, the first step in
the translation is to ground Π with all constants occurring in Π or . Then, every relational
atom  (c) occurring in the grounding of Π with constants from Π and  is translated into a
propositional symbol  c. Moreover, since LTL does not allow for metric operators, the
binaryencoded MTL operators occurring in Π need to be rewritten to basic LTL operators. Note that
both the grounding of the initial program Π and then expanding the binary-encoded numbers
involved in an MTL operator into sequences of LTL operators lead to an exponential blow-up.
For example, assume that Π mentions an atom ⊟[0,60)(). Moreover, let Π and  mention
100 constants 1, . . . , 100 and assume that after a discretisation of the timeline the interval
[0, 60) contains 600 intervals. Then ⊟[0,60)() is translated to an LTL-formula containing 100
conjuncts (one conjunct for each  ∈ {1, . . . , 100}), each of the form
() ∧ ○  () ∧ ○  ○  () ∧ · · · ∧ ○
⏟
 · · · ○
599⏞
 ().</p>
        <p>
          Consequently,  Π, is exponentially large. Since satisfiability checking in LTL is
PSpacecomplete, this approach provides an ExpSpace reasoning procedure for DatalogMTL, which is
worst-case optimal. Although it allows for using optimised of-the-shelf reasoning systems for
LTL, it turns out that due to the exponential grounding of a program and the encoding of MTL
operators, the approach is ineficient in practice [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ]. Indeed, a recent implementation of the
translation-based approach has been outperformed by the MeTeoR system by a considerable
margin in a series of performed tests.
        </p>
      </sec>
      <sec id="sec-4-3">
        <title>4.3. Automata-Based Techniques</title>
        <p>
          Another method of reasoning in DatalogMTL was obtained by directly applying to DatalogMTL
techniques known for LTL, instead of translating the former to the latter. In particular, one of
the main approaches to checking satisfiability of an LTL-formula  consists in constructing a
generalised non-deterministic Büchi automaton whose states are sets of formulas relevant for  ,
alphabet consists of sets of propositions, whereas transition relation and accepting conditions
ensure that words accepted by the automaton are exactly models of  [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ].
        </p>
        <p>
          To adapt this technique to the needs of DatalogMTL, the automaton was modified as
follows [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. Each state of the automaton now represents formulas (ground metric atoms) which
hold not in a single time point but in all time points belonging to a fragment of the timeline called
a window (c.f. the sliding windows technique from Section 3.3). Note that since the timeline can
be discretised in DatalogMTL, each window can be finitely represented as a sequence consisting
of sets of metric atoms which hold in the consecutive intervals from the window. Additionally,
for such a sequence, to be a state of the automaton, it is required that the involved metric atoms
are locally consistent, for example if ⊞[0,∞)—stating that  holds always in the future—holds
in some interval , then ⊞[0,∞) needs to hold also in all the intervals in the window which
are to the right of . The rest of the automaton is defined similarly to the way we do it in LTL,
namely the alphabet consists of sets of ground relational atoms, whereas the transition relation
and accepting conditions are analogous to those in the automaton for LTL.
        </p>
        <p>
          It was shown that consistency checking in DatalogMTL reduces to checking non-emptiness
of (pairs of) the above-described automata, and that the latter is feasible in PSpace [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. Indeed,
it was shown that states of the automata are polynomially large in the size of the dataset. In
particular, windows can be chosen so that, after the timeline discretisation, the number of
intervals in each window is polynomially large in the size of the dataset—to obtain this property
it is crucial to use the second of the time discretisation methods from Section 4.1. Moreover, the
number of ground metric atoms that can hold in each of these intervals is also polynomially
bounded. Hence, each state is polynomially large and non-emptiness of the automata can be
checked with the standard on-the-fly approach [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ] in PSpace.
        </p>
        <p>
          This approach provides a worst-case optimal reasoning approach for full DatalogMTL, which
was implemented as part of the MeTeoR system [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ] and used for reasoning in cases where
materialisation does not terminate. With suitable optimisations, automata construction is
feasible in practice for inputs of moderate size and performs better than the translation to LTL,
but its application to large-scale datasets remains problematic. The automata technique was also
exploited to establish reasoning procedures in extensions of DatalogMTL with non-monotonic
negation; both in the case of stratifiable [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ] and general programs [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ].
        </p>
      </sec>
      <sec id="sec-4-4">
        <title>4.4. Arithmetic Progressions</title>
        <p>Discretisation of time proved also useful in establishing low-complexity fragments of
DatalogMTL. In particular, it allowed for constructing specific reasoning techniques for
fragments in which x is the only MTL operator occurring in a program, and moreover, each rule
is core, that is, has at most one body atom (DatalogMTLx) or each rule is linear in the sense
that it can mention at most one intensional (IDB) body atom (DatalogMTLx).</p>
        <p>
          The discussed reasoning technique for DatalogMTLx is based on two main observations.
First, since there are no conjunctions in rule bodies nor box operators (which simulate
conjunctions), all derivations in DatalogMTLx can be seen as sequences of facts, where each
fact is derived only based on the previous fact in the sequence. Secondly, although the second
type of the timeline discretisation from Section 4.1 yields intervals of diferent length, there
are polynomially many types of intervals (c.f. the figure from Section 4.1 with four types of
intervals). These observations allow us to represent all derivations as paths in a temporal
dependency graph [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. To illustrate, consider the following graph:
        </p>
        <p>•
1
0
3
4
•
0
•
1
8
8</p>
        <p>•
0</p>
        <p>
          •
1
8
8
The graph shows that, for example,  holding at some interval  of type 1 (vertex 1 ) allows us
to derive  in the interval of type 0 (vertex 0) which is located 3 intervals (the weight of the
edge from 1 to 0) to the right from . Lengths of paths (i.e., derivations) connecting any pair
of vertices in such a graph can be succinctly represented with a set of arithmetic progressions
after transforming the initial graph into the Chrobak normal form for automata [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ]. This
makes it possible to check entailment in TC0 for data complexity [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ] .
        </p>
        <p>This reasoning technique can be extended to DatalogMTLx. The structure of DatalogMTLx
programs allows for decomposing the timeline into (polynomially many) sections in which
reasoning can be performed with the technique established for DatalogMTLx. The existence
of these sections, however, leads to an increase of the data complexity from TC0 to NL.</p>
        <p>Although fact entaiment in both DatalogMTLx and DatalogMTLx is tractable in data
complexity, and the discussed algorithms are optimal, to the best of our knowledge they have
not yet been implemented.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Ongoing and Future Research Directions</title>
      <p>
        A promising direction of future work, thrusting from the ongoing research on reasoning
techniques for DatalogMTL, stems from the observation that the canonical model of a program
Π and a dataset  has a periodic structure (which corresponds to ultimately periodic LTL models).
In particular, by the translation to LTL and reasoning techniques that rely on Büchi automata,
it follows that there exists a left period 1 and a right period 2 such that for all (suficiently
small) time points , the same relational atoms hold in CΠ, at  and  − 1, whereas for all
(suficiently large) , the same relational atoms hold in CΠ, at  and  + 2. If we knew 1 and
2 in advance, we could use them to significantly speed up the materialisation process, and
potentially guarantee its termination for of all programs. The main problem, however, is that
although an (impractically large) upper bound on the length of the periods can be determined
[
        <xref ref-type="bibr" rid="ref18">18</xref>
        ], so far no eficient algorithm for computing values of these periods has been proposed. Some
preliminary results in this direction have recently been established by Bellomarini et al. [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ],
but computing periods in advance seems to be a computationally challenging task. Instead, we
are currently working on an approach that computes periods from a partial materialisation; in
particular, we aim to construct an algorithm that performs a bounded number of materialisation
steps until the obtained materialisation satisfies specific properties that allow us to read periods
from this partial materialisation.
      </p>
      <p>Another interesting direction focuses on optimising materialisation, e.g., by developing
semi naïve and parallel rule evaluation strategies and incremental materialisation maintenance
techniques.</p>
    </sec>
    <sec id="sec-6">
      <title>Acknowledgements</title>
      <p>This work has been supported by the EPSRC projects OASIS (EP/S032347/1), AnaLOG
(EP/P025943/1), and UK FIRES (EP/S019111/1), the SIRIUS Centre for Scalable Data Access,
and Samsung Research UK. For the purpose of Open Access, the authors have applied a CC BY
public copyright licence to any Author Accepted Manuscript (AAM) version arising from this
submission.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>S.</given-names>
            <surname>Brandt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. G.</given-names>
            <surname>Kalaycı</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Ryzhikov</surname>
          </string-name>
          , G. Xiao,
          <string-name>
            <given-names>M.</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          ,
          <article-title>Querying log data with metric temporal logic</article-title>
          ,
          <source>J. Artif. Intell. Res</source>
          .
          <volume>62</volume>
          (
          <year>2018</year>
          )
          <fpage>829</fpage>
          -
          <lpage>877</lpage>
          . doi:
          <volume>10</volume>
          .1613/jair.1.11229.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>R.</given-names>
            <surname>Koymans</surname>
          </string-name>
          ,
          <article-title>Specifying real-time properties with metric temporal logic, Real-Time Syst</article-title>
          .
          <volume>2</volume>
          (
          <year>1990</year>
          )
          <fpage>255</fpage>
          -
          <lpage>299</lpage>
          . doi:
          <volume>10</volume>
          .1007/BF01995674.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kaminski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. Cuenca</given-names>
            <surname>Grau</surname>
          </string-name>
          ,
          <article-title>Reasoning over streaming data in metric temporal Datalog</article-title>
          ,
          <source>in: Proc. of AAAI</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>3092</fpage>
          -
          <lpage>3099</lpage>
          . doi:
          <volume>10</volume>
          .1609/aaai.v33i01.
          <fpage>33013092</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>S.</given-names>
            <surname>Brandt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. G.</given-names>
            <surname>Kalayci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Kontchakov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Ryzhikov</surname>
          </string-name>
          , G. Xiao,
          <string-name>
            <given-names>M.</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          ,
          <article-title>Ontologybased data access with a Horn fragment of metric temporal logic</article-title>
          ,
          <source>in: Proc. of AAAI</source>
          ,
          <year>2017</year>
          , pp.
          <fpage>1070</fpage>
          -
          <lpage>1076</lpage>
          . doi:
          <volume>10</volume>
          .1609/aaai.v31i1.
          <fpage>10696</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>M.</given-names>
            <surname>Nissl</surname>
          </string-name>
          , E. Sallinger,
          <article-title>Modelling smart contracts with DatalogMTL</article-title>
          , in: M.
          <string-name>
            <surname>Ramanath</surname>
          </string-name>
          , T. Palpanas (Eds.),
          <source>Proc. of EDBT/ICDT</source>
          ,
          <year>2022</year>
          . URL: http://ceur-ws.
          <source>org/</source>
          Vol-
          <volume>3135</volume>
          /EcoFinKG_ 2022_paper4.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. Cuenca</given-names>
            <surname>Grau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kaminski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. V.</given-names>
            <surname>Kostylev</surname>
          </string-name>
          ,
          <article-title>DatalogMTL: Computational complexity and expressive power</article-title>
          ,
          <source>in: Proc. of IJCAI</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>1886</fpage>
          -
          <lpage>1892</lpage>
          . doi:
          <volume>10</volume>
          .24963/ ijcai.
          <year>2019</year>
          /261.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>V.</given-names>
            <surname>Ryzhikov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          ,
          <article-title>Data complexity and rewritability of ontology-mediated queries in metric temporal logic under the event-based semantics</article-title>
          ,
          <source>in: Proc. of IJCAI</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>1851</fpage>
          -
          <lpage>1857</lpage>
          . doi:
          <volume>10</volume>
          .24963/ijcai.
          <year>2019</year>
          /256.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. Cuenca</given-names>
            <surname>Grau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kaminski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. V.</given-names>
            <surname>Kostylev</surname>
          </string-name>
          ,
          <article-title>DatalogMTL over the integer timeline</article-title>
          ,
          <source>in: Proc. of KR</source>
          ,
          <year>2020</year>
          , pp.
          <fpage>768</fpage>
          -
          <lpage>777</lpage>
          . doi:
          <volume>10</volume>
          .24963/kr.2020/79.
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Zawidzki</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. Cuenca</given-names>
            <surname>Grau</surname>
          </string-name>
          ,
          <article-title>Finitely materialisable Datalog programs with metric temporal operators</article-title>
          ,
          <source>in: Proc. of KR</source>
          ,
          <year>2021</year>
          , pp.
          <fpage>619</fpage>
          -
          <lpage>628</lpage>
          . doi:
          <volume>10</volume>
          .24963/kr.2021/ 59.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. Cuenca</given-names>
            <surname>Grau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kaminski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. V.</given-names>
            <surname>Kostylev</surname>
          </string-name>
          ,
          <article-title>Tractable fragments of Datalog with metric temporal operators</article-title>
          ,
          <source>in: Proc. of IJCAI</source>
          ,
          <year>2020</year>
          , pp.
          <fpage>1919</fpage>
          -
          <lpage>1925</lpage>
          . doi:
          <volume>10</volume>
          .24963/ ijcai.
          <year>2020</year>
          /266.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>D. J. Tena</given-names>
            <surname>Cucala</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. Cuenca</given-names>
            <surname>Grau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. V.</given-names>
            <surname>Kostylev</surname>
          </string-name>
          ,
          <article-title>Stratified negation in Datalog with metric temporal operators</article-title>
          ,
          <source>in: Proc. of AAAI</source>
          ,
          <year>2021</year>
          , pp.
          <fpage>6488</fpage>
          -
          <lpage>6495</lpage>
          . URL: https://ojs.aaai.org/index.php/AAAI/article/view/16804/16611.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. J. Tena</given-names>
            <surname>Cucala</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. V.</given-names>
            <surname>Kostylev</surname>
          </string-name>
          ,
          <string-name>
            <surname>B. Cuenca Grau</surname>
          </string-name>
          ,
          <article-title>DatalogMTL with negation under stable models semantics</article-title>
          ,
          <source>in: Proc. of KR</source>
          ,
          <year>2021</year>
          , pp.
          <fpage>609</fpage>
          -
          <lpage>618</lpage>
          . doi:
          <volume>10</volume>
          .24963/kr. 2021/58.
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>D.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Hu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Wałęga</surname>
          </string-name>
          ,
          <string-name>
            <surname>B. Cuenca Grau</surname>
          </string-name>
          ,
          <article-title>MeTeoR: Practical reasoning in Datalog with metric temporal operators</article-title>
          ,
          <source>in: Proc. of AAAI</source>
          ,
          <year>2022</year>
          , pp.
          <fpage>5906</fpage>
          -
          <lpage>5913</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>E. G.</given-names>
            <surname>Kalayci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Brandt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Calvanese</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Ryzhikov</surname>
          </string-name>
          , G. Xiao,
          <string-name>
            <given-names>M.</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          ,
          <article-title>Ontology-based access to temporal data with Ontop: A framework proposal</article-title>
          ,
          <source>Int. J. Appl. Math</source>
          .
          <volume>29</volume>
          (
          <year>2019</year>
          )
          <fpage>17</fpage>
          -
          <lpage>30</lpage>
          . doi:
          <volume>10</volume>
          .2478/amcs-2019-0002.
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>J.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <article-title>Translation of DatalogMTL Into PLTL</article-title>
          ,
          <string-name>
            <surname>Technical</surname>
            <given-names>Report</given-names>
          </string-name>
          , Department of Computer Science, University of Oxford,
          <year>2022</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>C.</given-names>
            <surname>Baier</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.-P.</given-names>
            <surname>Katoen</surname>
          </string-name>
          , Principles of model checking, MIT Press,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>M.</given-names>
            <surname>Chrobak</surname>
          </string-name>
          ,
          <article-title>Finite automata and unary languages</article-title>
          ,
          <source>Theor. Comput. Sci</source>
          .
          <volume>47</volume>
          (
          <year>1986</year>
          )
          <fpage>149</fpage>
          -
          <lpage>158</lpage>
          . doi:
          <volume>10</volume>
          .1016/
          <fpage>0304</fpage>
          -
          <lpage>3975</lpage>
          (
          <issue>86</issue>
          )
          <fpage>90142</fpage>
          -
          <lpage>8</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>A.</given-names>
            <surname>Artale</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Kontchakov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Kovtunova</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Ryzhikov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Wolter</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          ,
          <article-title>Firstorder rewritability of ontology-mediated queries in linear temporal logic, Artif</article-title>
          . Intell.
          <volume>299</volume>
          (
          <year>2021</year>
          )
          <article-title>103536</article-title>
          . doi:
          <volume>10</volume>
          .1016/j.artint.
          <year>2021</year>
          .
          <volume>103536</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <given-names>L.</given-names>
            <surname>Bellomarini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Nissl</surname>
          </string-name>
          , E. Sallinger,
          <article-title>Query evaluation in DatalogMTL - taming infinite query results</article-title>
          ,
          <source>CoRR abs/2109</source>
          .10691 (
          <year>2021</year>
          ). arXiv:
          <volume>2109</volume>
          .
          <fpage>10691</fpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>