<!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>On the Data Complexity of Ontology-Mediated Queries with MTL Operators over Timed Words</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>S. Kikot</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>V. Ryzhikov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>P. A. Wa“ƒga</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>M. Zakharyaschev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Birkbeck, University of London</institution>
          ,
          <country country="UK">U.K</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Oxford</institution>
          ,
          <country country="UK">U.K</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>University of Warsaw</institution>
          ,
          <country country="PL">Poland</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>We report on our initial results regarding the data complexity of answering atomic queries mediated by ontologies given in a Horn fragment of the metric temporal logic MTL. We adopt the pointwise semantics for MTL over dense time. The complexity classes involved are AC0, NC1, L, NL, and P. Our general concern is detecting events in a complex asynchronous system based on qualitative sensor measurements. More precisely, the system in question has a number of sensors that from time to time and asynchronously send their readings to a database. We may think of such readings as pairs of the form (A; t), where A is a concept name and t a timestamp given as a non-negative nite binary fraction such as 101.011. As a formalism to dene events we use propositional Horn clauses with operators of the metric temporal logic MTL [14,2]. For example, according to Siemens, a gas turbine has a normal stop if the rotor speed coasts down from 1500 to 200, which was preceded by another coast down from 6600 to 1500 some time in the previous 9 minutes, at most 2 minutes before which the main ame was o, while the active power was o earlier within another 2 minutes. The event 'normal stop' can be encoded by the following hornMTL rule, where (n;m]' is assumed to hold true at a timestamp t if ' holds at some previous timestamp t0 with n &lt; t t0 m: CoastDown1500to200 ^ (0;9m] CoastDown6600to1500 ^ (the concepts on the right-hand side can be dened by similar rules). The use of hornMTL and datalogMTL ontologies (with both diamond and box operators in rule bodies and only box operators in rule heads) for querying temporal log data was advocated in [9], which also demonstrated experimentally feasibility and eciency of ontology-based data access (OBDA) with nonrecursive datalogMTL queries. An extension of the OBDA platform Ontop to support such queries was suggested in [8]. For a recent survey of temporal OBDA we refer the reader to [5]; surveys of early developments in temporal deductive databases</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        NormalStop
are given in [
        <xref ref-type="bibr" rid="ref10 ref7">7,10</xref>
        ]. Note also that the satisability problem for the description
logic ALC extended with MTL operators over (N; ) was considered in [
        <xref ref-type="bibr" rid="ref12 ref6">12,6</xref>
        ].
      </p>
      <p>
        In this paper, we start investigating the data complexity of answering
ontology-mediated queries (OMQs) with MTL operators. As the problem turns out
to be quite involved, we restrict ourselves to atomic queries and ontologies in
the fragment hornMTL of hornMTL where only past diamond operators are
allowed in rule bodies and no temporal operators can be used in rule heads. We
distinguish between arbitrary, linear and core (or binary) rules and consider, in
particular, the following types of the range % in %: hr; 1), h0; ri, and [r; r] where
h is one of [ or (, while i is one of ] or ). The underlying timeline is (R; ) as
we cannot assume that sensor readings come at regular time intervals. There
are two standard semantics for MTL over (R; ): continuous and pointwise ;
see, e.g., [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ] and references therein. Here, we only consider the latter, under
which both model checking and satisability for full MTL are decidable but not
primitive recursive [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ] (over (Z; ), these problems are ExpSpace-complete).
As pointed out in [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ], under the pointwise semantics, one thinks of atomic
propositions in MTL as referring to events (corresponding to state changes)
rather than to states themselves.
      </p>
      <sec id="sec-1-1">
        <title>The complexity results we obtain in this paper are collected in the table</title>
        <p>below, where ‘range-uniform’ means that all the % operators before intensional
concept names in a given hornMTL program have the same range %:
rules n ranges</p>
      </sec>
      <sec id="sec-1-2">
        <title>Horn</title>
        <p>linear
core
any hr; 1)
= P
= NL in AC0</p>
        <p>NL
h0; ri</p>
        <p>L</p>
        <p>NC1
in AC0(range-uniform)
[r; r]</p>
        <p>L
NC1
L
2</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>The Horn Fragment of MTL</title>
      <sec id="sec-2-1">
        <title>We denote the set of nite binary fractionsaka dyadic rational numbersby</title>
        <p>Q2; the set of non-negative dyadic rationals is denoted by Q2 0. As well-known,</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Q2 is dense in R and, by Cantor’s theorem, (Q2; &lt;) is isomorphic to (Q; &lt;).</title>
    </sec>
    <sec id="sec-4">
      <title>By an interval, , we mean any nonempty subset of the real numbers R of</title>
      <p>the form [t1; t2], [t1; t2), (t1; t2] or (t1; t2), where t1; t2 2 Q2 [ f 1; 1g and
t1 t2, excluding t1 = t2 2 f 1; 1g. We identify (t; 1] with (t; 1), [ 1; t]
with ( 1; t], etc. A range, %, is an interval with non-negative endpoints.</p>
      <sec id="sec-4-1">
        <title>The metric temporal logic MTL [14,2] is a propositional modal logic with box</title>
        <p>operators indexed by ranges, say (0;60], which is interpreted over (R; &lt;) as ‘at
every time instant within the previous minute’, its future counterpart (0;60], and
their dual diamond operators (0;60] and (0;60]. In this paper, we only consider
a fragment of MTL that is called hornMTL .</p>
      </sec>
      <sec id="sec-4-2">
        <title>A hornMTL program, , is a nite set of rules of the form</title>
        <p>where k</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>1 and the Bi are dened by the grammar</title>
      <p>A</p>
      <p>B1 ^</p>
      <p>^ Bk;
B ::= A
j &gt; j
%B;
(1)
with A being a concept name or ?. As usual, A is called the head of the rule, and
B1 ^ : : : ^ Bk its body. A hornMTL program is linear if, in each of its rules,
at most one of the concepts in the body occurs as a head in . A hornMTL
program is core if all of its rules are of the form A B or ? B1 ^ B2. A
hornMTL (ontology-mediated) query takes the form ( ; A(x)).</p>
      <sec id="sec-5-1">
        <title>As mentioned in Section 1, we may think of a data instance as a nite set</title>
        <p>D = f(A1; t1); : : : ; (An; tn)g, where the Ai are concept names from some xed
alphabet and the ti are (not necessarily ordered) timestamps from Q2 0. When
proving some complexity results, we assume that D is given as the FO-structure
D = ( ; &lt;; ; bitin ; bitfr ; A1; : : : ; Ap);
(2)
in which</p>
        <p>= f0; : : : ; `g N, where ` is the maximum of the number of distinct
timestamps in D and the number of bits in the longest binary fraction in D
(excluding the binary point), and &lt; is the usual order on ;</p>
        <p>is a set of timestamps ; for every n 2 , we set n = b` b0:c0 c`
such that bitin (i; n; bi) and bitfr (i; n; ci) hold, for i = 0; : : : ; `;
thus, bitin and bitfr are ternary relations on such that, for any n 2 and
i 2 , there is a unique bi 2 f0; 1g and a unique ci 2 f0; 1g with bitin (i; n; bi)
and bitfr (i; n; ci);</p>
        <p>Ai , for i = 1; : : : ; p; intuitively, Ai(n) holds i Ai(n) 2 D.</p>
        <p>For any d 2 Q2 0, one can readily dene FO-formulas:
dist&lt;d(x; y) that holds in D i x; y 2 and 0
dist&gt;d(x; y) that holds in D i x; y 2 and x
their modications dist d(x; y) and dist d(x; y).
x y &lt; d;
y &gt; d;
It will be convenient to assume that these predicates are also given by D for the
relevant d. In Theorem 5, we also make the following assumption:
(ord)
= f0; : : : ; kg, for some k
`, and n &lt; m
k implies n &lt; m.</p>
      </sec>
      <sec id="sec-5-2">
        <title>There are two semantics for MTL known as pointwise and continuous [16].</title>
      </sec>
      <sec id="sec-5-3">
        <title>Pointwise semantics. A pointwise interpretation is a structure of the form</title>
        <p>I = (T; A1I ; A2I ; : : : );
where T 6= ; is a nite subset of Q2 0 (timestamps) and AI
i
if B = A, BI = T if B = &gt;, BI = ; if B = ?, and
T. We set BI = AI
( %B)I = ft 2 T j 9t0 2 BI (t
t0 2 %)g:
I is a model of a data instance D if t 2 AI for any (A; t) 2 D; I is a model of a
hornMTL program if, for any rule (1) in and any t 2 T, we have t 2 AI
whenever t 2 BiI for 1 i k. We say that D and are consistent if there
is a model of D and . We also say that a timestamp t from D is a certain
answer to a query ( ; A(x)) over D if t 2 AI , for every model I of D and .
The query answering problem for ( ; A(x)) is to decide, given a data instance</p>
        <sec id="sec-5-3-1">
          <title>D and a timestamp t in it, whether t is a certain answer to ( ; A(x)) over D.</title>
        </sec>
      </sec>
      <sec id="sec-5-4">
        <title>Continuous semantics. The only dierence from the pointwise case is that</title>
        <p>a continuous interpretation is dened over the reals: I = (R; A1I ; A2I ; : : : ) with
AiI R and ( %B)I = ft 2 R j 9t0 2 BI (t t0 2 %)g. To illustrate, suppose that
= fA (0;1] (0;1]Bg and D = f(B; 0); (C; 2)g. Then ( ; A) has no answers
over D under the former semantics (because 1 is not a timestamp in D), but 2
is an answer under the latter one.</p>
      </sec>
      <sec id="sec-5-5">
        <title>In this paper, we only consider the pointwise semantics and leave the continuous one for future work. Normal form. A program is in normal form if its rules have one of the forms:</title>
        <p>P0
P0
%01 P10 ^
%1 P1 ^
^ %0` P m0;
^ %k Pk ^ %01 P10 ^
^ %0` P m0;
(3)
(4)
where the Pi0 are from the data alphabet , the Pi do not belong to (and so
cannot occur in data instances), and 0 2= %i for any i (although there may be,
say %0i = [0; 0]). Every hornMTL program can be transformed to a program in
normal form with the same answers. We illustrate this claim by an example.
Example 1. Let = fP10 [0;d]P00 ^ Q00; P00 (0;e)P10 ^ [0;f]Q01g, where the</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Pi0 are in . By introducing fresh concept names P0, P1, we convert to</title>
      <p>P1
[0;d]P0 ^ Q00; P0
(0;e)P1 ^ [0;f]Q01; P0
P00; P1</p>
      <p>P 0:
1</p>
      <sec id="sec-6-1">
        <title>To get rid of [0; d], we further transform the program to</title>
        <p>P1</p>
        <p>P0 ^Q00; P1
(0;d]P0 ^Q00; P0
(0;e)P1 ^ [0;f]Q01; P0</p>
        <p>P00; P1</p>
        <p>P 0:
1
Now, P0 in the rst rule is not in the scope of % (Q00 can be regarded as a
shorthand for [0;0]Q00). So we transform the rule using obvious derivations to
obtain the following program in normal form:</p>
        <p>P1</p>
        <p>P00 ^ Q00; P1
(0;e)P1 ^ [0;f]Q01 ^ Q00; P1</p>
        <p>(0;d]P0 ^ Q00;
P0
(0;e)P1 ^ [0;f]Q01; P0</p>
        <p>P00; P1</p>
        <p>P 0:
1</p>
      </sec>
      <sec id="sec-6-2">
        <title>A hornMTL query ( ; A(x)) is in normal form if is in normal form and</title>
        <p>A 2= . Clearly, every query can be converted to a one in normal form and having
the same answers.
3</p>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>The Data Complexity of Answering hornMTL</title>
    </sec>
    <sec id="sec-8">
      <title>Queries</title>
      <p>It is not hard to see that consistency checking and answering hornMTL queries
can be reduced to consistency checking and answering monadic datalog queries
over D. For example, the rule A
datalog rule</p>
      <p>(r;s]B can be replaced with the monadic
A(x)</p>
      <p>
        B(y) ^ dist&gt;r(x; y) ^ dist s(x; y);
where dist&gt;r and dist s are extensional predicates given by the data instance. It
follows that consistency checking and answering hornMTL queries can be done
in polynomial time for data complexity; for linear hornMTL queries, this can
be done in NL. The next theorem establishes a matching lower bound, which is
in sharp contrast to hornLTL queries that are in NC 1 for data complexity [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
Theorem 1. (i) Consistency checking and answering hornMTL queries is
Pcomplete for data complexity.
      </p>
      <p>(ii) Consistency checking and answering linear hornMTL queries is
NLcomplete for data complexity.</p>
      <p>Proof. We only show the lower bound in (ii); the construction in (i) is similar.</p>
      <sec id="sec-8-1">
        <title>The proof is by reduction of the reachability problem in acyclic digraphs. Let</title>
        <p>G = (V; E) be such a digraph with a set V = fv0; : : : ; vn 1g of vertices and a set
E V V of edges such that whenever (vi; vj ) 2 E then i &lt; j (we can always
represent G in this way due to its acyclicity). Suppose that the task is to check
whether vt 2 V is reachable from vs 2 V in G.</p>
        <p>We construct a data instance DG with concepts V , Er, El, I, O, which
encodes G on a linear order. Namely, DG contains the following pairs (i; j; k 2 N):
(V; 2k + 2in ), for 0 k &lt; n and 1 i
(Er; 2i + i2+n1 ), for (vi; vj ) 2 E;
(El; 2i + j2+n1 ), for (vi; vj ) 2 E;
(I; 2k + i2+n1 ), for 0 k &lt; n and vs = vi;
(O; 2k + i2+n1 ), for 0 k &lt; n and vt = vi.
n;</p>
      </sec>
      <sec id="sec-8-2">
        <title>An example of a graph and the corresponding data instance are shown below:</title>
        <p>vs = v0</p>
        <p>G:
by</p>
        <p>:
DG :</p>
        <p>R R
I O
Er El</p>
        <p>V V V V
0 116126136146 1
V :
v0v1v2v3</p>
        <p>R R
I O</p>
        <p>Er El
V V V V</p>
        <p>be a linear hornMTL program with the following rules:
R</p>
        <p>I; R</p>
        <p>El ^ [0;1](Er ^ R); R</p>
        <p>V ^ [2;2]R; P</p>
        <p>R ^ O; ?</p>
        <p>P:
Note that all numbers occurring in DG and belong to Q2. For the atoms
implied by , see the previous picture. One can show that and DG are consistent
i vt is not reachable from vs.
4
hornMTL</p>
      </sec>
    </sec>
    <sec id="sec-9">
      <title>Queries with</title>
      <p>hr;1)
In this section, we show that if all temporal operators in a hornMTL program
are of the form hr;1), then answering ( ; A(x)) can be done in AC0; in other
words, ( ; A(x)) is FO-rewritable. To this end, we require the canonical models
for hornMTL programs, which can be dened as follows.</p>
      <p>Suppose we are given a hornMTL program and a data instance D. Dene
a set C ;D of pairs of the form (B; t) that contains all answers to queries with
over D. We start by setting C = D and denote by cl(C) the result of applying
exhaustively and non-recursively the following rules to C:
(horn) if A B1 ^ : : : ^ Bk is in and (Bi; t) 2 C, for i = 1; : : : ; k, then we
add (A; t) to C;
( %) if %B occurs in , (B; t0) 2 C, and t t0 2 %, for a timestamp t in D, then
we add ( %B; t) to C.</p>
      <sec id="sec-9-1">
        <title>It should be clear that there is some N &lt; ! (polynomially depending on</title>
        <p>D) such that clN (C) = clN+1(C). We then set C ;D = clN (D).
and</p>
        <sec id="sec-9-1-1">
          <title>Theorem 2. A timestamp t from D is a certain answer to ( ; A(x)) over D i</title>
          <p>(A; t) 2 C ;D.</p>
        </sec>
      </sec>
      <sec id="sec-9-2">
        <title>As known from [3], if we use LTL diamonds in place of the MTL ones in</title>
        <p>hornMTL programs, then all such queries are FO-rewritable and in AC0 for
data complexity. In fact, almost the same argument shows the following:
Theorem 3. Consistency checking and answering hornMTL queries with
temporal operators of the form hr;1) are in AC0 for data complexity.
Proof. Let ( ; A(x)) be a hornMTL query with temporal operators of the form
hr;1). It is easy to see that constructing Cp ;D needs at most j j2 applications
of the cl operator to D (because each rule ( hr;1)) needs to be applied at most
once). Thus, we can construct an FO-rewriting of ( ; A(x)) using iteratively the
standard FO-translation of, say, [r;1)B into 9t0 (dist r(t; t0) ^ B(t0)).</p>
      </sec>
      <sec id="sec-9-3">
        <title>Example 2. An FO-rewriting for the query ( ; A(x)) with the program</title>
        <p>prising two rules A [2;1)C, C [1;1)A looks as follows:
com9y A(x) _ C(y) ^ dist 2(x; y) _
A(y) ^ dist 3(x; y) :</p>
        <sec id="sec-9-3-1">
          <title>When the ranges % in % are dierent from hr; 1), the technique above does</title>
          <p>not work any more and the complexity landscape changes signicantly.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-10">
      <title>Metric Automata for Linear hornMTL</title>
      <p>
        Our technical tool for studying the data complexity of linear hornMTL queries
is automata with metric constraints that are dened for programs in normal
form. These automata can be viewed as a primitive version of standard timed
automata for MTL [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] as we only have one clock c, the clock reset c := 0 happens
at every transition, and the clock constraints are of the simple form c 2 %.
      </p>
      <p>A (nondeterministic) metric automaton is a quadruple A = (S; S0; ; ),
where S 6= ; is a set of states, a tape alphabet, a transition relation , and S0
is a nonempty set of pairs of the form (q; e), where e 2 , q 2 S. The transition
relation is a set of instructions of the form q !%e q0 with q; q0 2 S, e 2 and a
range %. The automaton A takes as input timed words = (e0; t0); : : : ; (en; tn),
where the ti are timestamps with ti 1 &lt; ti. A run over is a sequence q0; : : : ; qm
such that (q0; e0) 2 S0, qi 1 %!iei qi is in and ti ti 1 2 %i, for 0 &lt; i n.</p>
      <p>Let be a linear hornMTL program in normal form. We denote the
conjunctions %01 P10 ^ : : : ^ %0` P m0 (with data concept names Pi0) that occur in
by ", possibly with subscripts. Thus, since is linear, rules (4) in are of the
form P " ^ %Q. Let E = f"1; : : : ; "qg be the set of all such " occurring in
. We dene a metric automaton A for as follows. The set S of its states
comprises the head concept names in , and = 2E . The transition relation
comprises Q !%E P such that P " ^ %Q is in and " 2 E. Finally, S0 is
the set of all pairs (P; ") such that a rule P " of the form (3) is in .
E1 = f [0;1]P00g, E2 = fP10; [0;1]P00g, and S0 = f(P0; [0;1]P00)g.</p>
      <p>Example 3. For = fP0
the metric automaton A</p>
      <p>[0;1]P00; P1 (1;2)P0 ^ P10; P0
is depicted below, where P00; P10 2
(1;3)P1g,
, E0 = fP10g,
P0</p>
      <p>P1
E2 (1; 2)
E0 (1; 2)</p>
      <sec id="sec-10-1">
        <title>We represent any data instance D as a timed word D. For ti occurring</title>
        <p>in D, let E(ti) be the maximal set of " from that hold at ti in D, and
let D = (E(t1); t1); : : : ; (E(tn); tn) . The corresponding FO-structure from</p>
        <sec id="sec-10-1-1">
          <title>Section 2 can take the form</title>
          <p>D = ( ; &lt;; ; bitin ; bitfr ; E1; : : : ; Ek);
(5)
where fE1; : : : ; Ekg = 2E . It is not hard to see that there is an FO-translation
of (2) to (5).
Theorem 4. For any linear hornMTL query ( ; A(x)), a timestamp ti is a
tcheertalaisnt atinms wesetramovpertiaadnadtaa irnusntaonfceA D oivtehrereD0etxhisatt aensdusbwwoitrhd A. D0 of D with</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-11">
      <title>Example 5. Let ( ; P1(x)) be the query with from Example 3. Then, for from Example 4, we have the run P0; P1; P0; P1 on</title>
      <p>D
3
(E1; 1); (E0; 2 ); (;; 4); (E2; 5);
and so 5 is a certain answer to the query over D from Example 4.</p>
      <sec id="sec-11-1">
        <title>One could dene metric automata as classical timed automata; however,</title>
        <p>Theorem 4 does not use them in the standard way as it requires runs on subwords.
Whether and how such runs can be captured by timed automata remains to
be claried. We now use the obtained automaton characterisation of certain
answers to linear queries to give better complexity bounds for two classes of linear
programs with restricted temporal ranges than the NL bound of Theorem 1 (ii).
6
hornMTL</p>
      </sec>
    </sec>
    <sec id="sec-12">
      <title>Queries with</title>
      <p>h0;ri
We say that a hornMTL program in normal form is range-uniform if every
(intensional) concept name P 2= occurs in in the scope of %, for some xed
range %. By a coreMTL program we mean a core hornMTL program in normal
form. Rules (4) in such a program take the form P %Q.
6.1</p>
      <sec id="sec-12-1">
        <title>Range-uniform coreMTL queries with</title>
        <p>
          h0;ri
Let be a range-uniform coreMTL program and A = (S; S0; ; ) the
corresponding metric automaton. For each (q0; e0) in S0, we dene a classical nite
automaton AqA0;e0 = (S; ; fq0g; ; fAg), where S; , and are as in A (note
tnhaal tsatalltetrsa,nrseistpioenctsivtaelkye. tThheufos,rmAqqA0h;0e;0r!iis; aq0)u,naanrdy q(0i.ae.n,dovAerarseinugnleiqtoune ianliptihaalbaentd)
automaton. It is known that each such automaton has an equivalent automaton
in normal form [
          <xref ref-type="bibr" rid="ref11 ref17">11,17</xref>
          ], where cycles can be only disjoint. More precisely, there
is a number of arithmetic progressions ai + biN = fai + bi m j m 2 Ng such that
a word ;n is accepted by AqA0;e0 i n 2 Si ai + biN. This characterisation allows
us to obtain the following:
Theorem 5. Consistency checking and answering range-uniform coreMTL
queries with temporal operators of the form h0;ri are in AC0 for data complexity
provided that the input data instances satisfy (ord).
        </p>
      </sec>
    </sec>
    <sec id="sec-13">
      <title>Example 6. To illustrate the theorem, consider the query ( ; S1(x)) with</title>
      <p>= fS0</p>
      <p>B; S1
(0;d)S0; S2
(0;d)S1; S3
(0;d)S2; S1
(0;d)S3g:
The automaton AS0;B (which is in normal form) is shown in the picture below on
the right. Using it, we construct the following FO-rewriting '(x) of ( ; S1(x)):
'(x) = 9x0 B(x0) ^ 8y (x0 &lt; y
x) ! 9y0 dist&lt;d(y; y0) ^
('1(x0; x) _ '2(x0; x) _ '3(x0; x)) ;
where
'1(x0; x) = (x x0) 2 1 + 3N;
'2(x0; x) = (x x0) 2 2 + 3N ^ 9x1 ((x0 &lt; x1 x) ^ '+1(x1; x0));
'3(x0; x) = (x x0) 2 3 + 3N ^ '1+1+1(x0; x) _ '1+2(x0; x);
'1+2(x0; x) = 9x1 ((x0 &lt; x1 x) ^ '+2(x1; x0));
'1+1+1(x0; x) = 9x1; x2 ((x0 &lt; x1 &lt; x2 x) ^ '+1(x1; x0) ^ '+1(x2; x0) ^
((x2 x1) &gt; 1));
'+k(z; x0) = dist&lt;d(z; z k k 1) x0), for k = 1; 2.</p>
      <p>1) ^ ((z
Intuitively, to derive S1 at x, we need a point x0 with B(x0) in the data and a
sequence of points y between x0 and x without gaps of length d. An example
of such a data instance is given below.</p>
      <p>S0</p>
      <p>S1</p>
      <p>S3
S2 S3 S1</p>
      <p>S1
S2</p>
      <p>S2
S3</p>
      <p>S0</p>
      <p>
        S1
Note how we maintain the ‘stack of states’ with the elements at its bottom
alternating in a cycle between S1; S2, and S3. Note also that the states go in
decreasing order when we scan the stack from bottom to top. So we use the
formulas 'k(x0; x) to express that S1 is inferred at x on level k of the stack.
The formula '+k(z; x0) says that the height of the stack increases by k because
of a cluster of k + 2 points within the segment of size &lt; d ending with z. The
formulas '1+2(x0; x) and '1+1+1(x0; x) express two ways of increasing the height
of the stack from 1 to 3. It is to be emphasised that properties of x and x0
such as (x x0) 2 1 + 3N can be expressed by FO-formulas using the predicate
PLUS(num1; num2; sum) or BIT(num; bit), which gives a binary representation
of every object num in the domain of an FO-structure [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ], whereas FO with &lt;
only is not enough. For example, (x x0) 2 1 + 3N is expressed by the formula
'1(x0; x) = 9z; z0; z00; y (x = y + 1) ^ PLUS(z; z; z0) ^
PLUS(z0; z; z00) ^ PLUS(x0; z00; y) :
Also, '(x) above is a correct rewriting only if evaluated over D satisfying (ord).
S3
S2
      </p>
      <sec id="sec-13-1">
        <title>We next turn to hornMTL programs</title>
        <p>h0;ri
with ranges % of the form h0; ri.</p>
        <p>Theorem 6. Consistency checking and answering hornMTL queries with
temporal operators of the form h0;ri are in L for data complexity.</p>
        <p>Example 7. We illustrate the log-space algorithm used in the proof of Theorem 6
by means of a program with the following rules:</p>
        <p>P2
(0;2]P2 ^ (0;1]P1;</p>
        <p>P1
(0;3]P2;</p>
        <p>P2</p>
        <p>P 0:
2
For this , we can scan an input word D with the help of three pointers , 1
and 2. Intuitively, will point to the last processed timestamp and 1 ( 2)
to the last timestamp where P1 (respectively, P2) holds. Consider the word D
shown in the picture below. Before the algorithm starts, we assume that , 1,
and 2 do not point anywhere. First, we set to the rst point t0 (with the
timestamp 0) and read P20. Because P2 holds there by the last rule in , we set
2 to t0. Next, we move to t1 where we read Q0 (not present in ). Here, we
check whether t0 pointed to by 2 and t1 pointed to by are such that t1 t0 3
(which can be done in L using any subtraction algorithm). Since it is the case,
we set 1 to t1 to reect the meaning of the second rule in , and we do not
need to update 2. Next, we move to t2. We check that the dierence between
the timestamps pointed to by and 1 does not exceed 3 to verify whether the
second rule in applies. Similarly, we check that the dierence between and</p>
      </sec>
    </sec>
    <sec id="sec-14">
      <title>1 does not exceed 1 and the dierence between and 2 does not exceed 2 to</title>
      <p>verify whether the rst rule in applies. As a result, we set both 1 and 2 to
t2. A complete run of our algorithm on D is shown below.</p>
      <p>D :
run:
derived:
0
P 0
2
2
P2
1
Q0</p>
      <p>1
P1
2
Q0
1; 2
P1; P2
To decide whether, say, t5 is a certain answer to ( ; P1(x)), we only need to
check whether we move 2 to t5 when we move there.</p>
      <sec id="sec-14-1">
        <title>Note that the algorithm above works correctly only if the ranges are of the</title>
        <p>form h0; ri. Intuitively, resetting i to every time a rule with Pi in the head
applies does not provide correct answers for other forms of ranges.</p>
        <p>
          The exact complexity for the queries in Theorem 6 remains open. At the
moment, we only have the following result, which is proved by reduction of
hornLTL queries with rules of the form Q P P ^ P 0, where P is the ‘previous
moment of time’ operator, that were shown to be NC 1-complete in [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ]. In this
reduction, we use the axioms Q (0;1]P ^P 0 to encode the axioms above. Then
every hornLTL data instance of the form P00(0); P10(1); : : : ; Pk0 (k) is translated to
a hornMTL data instance by means of an FO-reduction using the standard
predicate BIT (num; bit).
        </p>
        <p>Theorem 7. Consistency checking and answering hornMTL queries with
temporal operators of the form h0;ri are NC1-hard for data complexity.
7
hornMTL
Theorem 8. Consistency checking and answering hornMTL queries with
temporal operators of the form [r;r] are in L for data complexity.</p>
      </sec>
      <sec id="sec-14-2">
        <title>We illustrate the idea of the proof by a concrete example.</title>
      </sec>
      <sec id="sec-14-3">
        <title>Example 8. Suppose</title>
        <p>= fP1
[1;1]P1; A</p>
        <p>P1 ^ [1:5;1:5]P2g and
D = f(P1; 1); (P1; 1:25); (P1; 1:5); (P2; 2); (P1; 2:375); (P2; 2:5);
(P2; 3); (P1; 3:5); (P2; 3:625); (P2; 4)g:
Let num( ) be the set of numbers in . To check whether 4 is a certain answer
to ( ; A(x)), we compute d = gcd(num( )) = 0:5 and k = max(num( )) = 3.
d
Observe rst that the algorithm can ignore those facts in D with a timestamp t
for which 4 t is not divisible by d, that is, we can omit (P1; 1:25), (P1; 2:375),
and (P2; 3:625) as they have no inuence on the facts derived at 4. Next, notice
that to derive a fact at some t, it suces to check what facts hold at the instants
t; t d; : : : ; t kd. Hence, for each concept name in , it suces to use k + 1 = 4
pointers storing the last 4 timestamps where this concept holds. The consecutive
steps of our algorithm are shown below, where symbols in boxes represent facts
derived by the rules in :</p>
        <p>D :
step 1:
step 2:
step 3:
step 4:
step 5:
step 6:
step 7:</p>
        <p>Z
P1 PZ1 P1
The algorithm uses k + 1-many log-space pointers for each concept name in
, where k only depends on , and a single pointer indicating the currently
processed timestamp. As a result, the algorithm is in L for data complexity.</p>
      </sec>
      <sec id="sec-14-4">
        <title>We note that the best known lower bound for this language is NC 1, which</title>
        <p>can be shown using a reduction similar to that in the proof of Theorem 7. The
algorithm illustrated above cannot be used to show an NC 1 upper bound because
it must ignore some facts in D.</p>
      </sec>
      <sec id="sec-14-5">
        <title>Acknowledgements</title>
        <p>This work was supported by the NCN grant 2016/23/N/HS1/02168 and the</p>
      </sec>
      <sec id="sec-14-6">
        <title>Foundation for Polish Science (FNP).</title>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Alur</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dill</surname>
            ,
            <given-names>D.L.</given-names>
          </string-name>
          :
          <article-title>A theory of timed automata</article-title>
          .
          <source>Theoretical Computer Science</source>
          <volume>126</volume>
          (
          <issue>2</issue>
          ),
          <fpage>183</fpage>
          <lpage>235</lpage>
          (
          <year>1994</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Alur</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Henzinger</surname>
            ,
            <given-names>T.A.</given-names>
          </string-name>
          :
          <article-title>Real-time logics: Complexity and expressiveness</article-title>
          .
          <source>Inf. Comput</source>
          .
          <volume>104</volume>
          (
          <issue>1</issue>
          ),
          <volume>3577</volume>
          (
          <year>1993</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Artale</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kontchakov</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wolter</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zakharyaschev</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Temporal description logic for ontology-based data access</article-title>
          .
          <source>In: Proc. of the 23rd Int. Joint Conf. on Articial Intelligence</source>
          ,
          <string-name>
            <surname>IJCAI</surname>
          </string-name>
          <year>2013</year>
          .
          <article-title>IJCAI/AAAI (</article-title>
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Artale</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kontchakov</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kovtunova</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ryzhikov</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wolter</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zakharyaschev</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>First-order rewritability of temporal ontology-mediated queries</article-title>
          .
          <source>In: Proc. of the 24th Int. Joint Conf. on Articial Intelligence</source>
          ,
          <string-name>
            <surname>IJCAI</surname>
          </string-name>
          <year>2015</year>
          . pp.
          <fpage>27062712</fpage>
          . IJCAI/AAAI (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Artale</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kontchakov</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kovtunova</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ryzhikov</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wolter</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zakharyaschev</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Ontology-mediated query answering over temporal data: A survey (invited talk)</article-title>
          .
          <source>In: TIME. LIPIcs</source>
          , vol.
          <volume>90</volume>
          , pp.
          <volume>1</volume>
          :
          <issue>11</issue>
          :
          <fpage>37</fpage>
          .
          <string-name>
            <surname>Schloss Dagstuhl - LeibnizZentrum fuer Informatik</surname>
          </string-name>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Baader</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Borgwardt</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Koopmann</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ozaki</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Thost</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          :
          <article-title>Metric temporal description logics with interval-rigid names</article-title>
          .
          <source>In: Frontiers of Combining Systems - 11th International Symposium, FroCoS</source>
          <year>2017</year>
          , Braslia, Brazil,
          <source>September 27-29</source>
          ,
          <year>2017</year>
          , Proceedings. pp.
          <volume>6076</volume>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Baudinet</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chomicki</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wolper</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Temporal deductive databases</article-title>
          .
          <source>In: Temporal Databases</source>
          , pp.
          <volume>294320</volume>
          (
          <year>1993</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Brandt</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kalayci</surname>
            ,
            <given-names>E.G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ryzhikov</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xiao</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zakharyaschev</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>A framework for temporal ontology-based data access: A proposal</article-title>
          .
          <source>In: New Trends in Databases and Information Systems - ADBIS 2017 Short Papers and Workshops</source>
          , AMSD, BigNovelTI,
          <string-name>
            <surname>DAS</surname>
          </string-name>
          , SW4CH, DC, Nicosia, Cyprus,
          <source>September 24-27</source>
          ,
          <year>2017</year>
          , Proceedings.
          <source>Communications in Computer and Information Science</source>
          , vol.
          <volume>767</volume>
          , pp.
          <fpage>161173</fpage>
          . Springer (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Brandt</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kalayc</surname>
            ,
            <given-names>E.G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ryzhikov</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xiao</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zakharyaschev</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Querying log data with metric temporal logic</article-title>
          .
          <source>Journal of Articial Intelligence Research</source>
          <volume>62</volume>
          ,
          <issue>829877</issue>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Chomicki</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Toman</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>Temporal logic in information systems</article-title>
          .
          <source>In: Logics for Databases and Information Systems</source>
          . pp.
          <fpage>3170</fpage>
          .
          <string-name>
            <surname>Kluwer</surname>
          </string-name>
          (
          <year>1998</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Chrobak</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Finite automata and unary languages</article-title>
          .
          <source>Theor. Comp. Sci</source>
          .
          <volume>47</volume>
          (
          <issue>2</issue>
          ),
          <fpage>149</fpage>
          <lpage>158</lpage>
          (
          <year>1986</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>GutiØrrez-Basulto</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jung</surname>
            ,
            <given-names>J.C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ozaki</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>On metric temporal description logics</article-title>
          .
          <source>In: ECAI 2016 - 22nd European Conference on Articial Intelligence</source>
          ,
          <volume>29</volume>
          <fpage>August</fpage>
          -2
          <source>September</source>
          <year>2016</year>
          ,
          <string-name>
            <given-names>The</given-names>
            <surname>Hague</surname>
          </string-name>
          ,
          <source>The Netherlands - Including Prestigious Applications of Articial Intelligence (PAIS</source>
          <year>2016</year>
          ). pp.
          <volume>837845</volume>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Immerman</surname>
          </string-name>
          , N.: Descriptive Complexity. Springer (
          <year>1999</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Koymans</surname>
          </string-name>
          , R.:
          <article-title>Specifying real-time properties with metric temporal logic</article-title>
          .
          <source>RealTime Systems</source>
          <volume>2</volume>
          (
          <issue>4</issue>
          ),
          <volume>255299</volume>
          (
          <year>1990</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Ouaknine</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Worrell</surname>
          </string-name>
          , J.:
          <article-title>On the decidability and complexity of metric temporal logic over nite words</article-title>
          .
          <source>Logical Methods in Computer Science</source>
          <volume>3</volume>
          (
          <issue>1</issue>
          ) (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Ouaknine</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Worrell</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>Some recent results in metric temporal logic</article-title>
          .
          <source>In: Formal Modeling and Analysis of Timed Systems</source>
          , 6th International Conference, FORMATS 2008,
          <string-name>
            <surname>Saint</surname>
            <given-names>Malo</given-names>
          </string-name>
          , France,
          <source>September 15-17</source>
          ,
          <year>2008</year>
          . Proceedings. pp.
          <volume>113</volume>
          (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <surname>To</surname>
            ,
            <given-names>A.W.</given-names>
          </string-name>
          :
          <article-title>Unary nite automata vs. arithmetic progressions</article-title>
          .
          <source>Inf. Process. Lett</source>
          .
          <volume>109</volume>
          (
          <issue>17</issue>
          ),
          <volume>10101014</volume>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>