<!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>Rewriting Ontological Queries into Small Nonrecursive Datalog Programs?</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Georg Gottlob</string-name>
          <email>gottlob@cs.ox.ac.uk</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Thomas Schwentick</string-name>
          <email>thomas.schwentick@udo.edu</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science, University of Oxford</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Fakulta ̈t fu ̈r Informatik, TU Dortmund</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>We consider the setting of ontological database access, where an Abox is given in form of a relational database D and where a Boolean conjunctive query q has to be evaluated against D modulo a T -box formulated in DLLite or Linear Datalog . It is well-known that ( ; q) can be rewritten into an equivalent nonrecursive Datalog program P that can be directly evaluated over D. However, for Linear Datalog or for DL-Lite versions that allow for role inclusion, the rewriting methods described so far result in a nonrecursive Datalog program P of size exponential in the joint size of and q. This gives rise to the interesting question of whether such a rewriting necessarily needs to be of exponential size. In this paper we show that it is actually possible to translate ( ; q) into a polynomially sized equivalent nonrecursive Datalog program P .</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        ? Future improvements and extended versions of this paper will be published in arXive-CORR
at http://arxiv.org/abs/1106.3767
setting where ontological constraints are formulated in terms of tuple-generating
dependencies (tgds), and we make heavy use of the well-known chase procedure [
        <xref ref-type="bibr" rid="ref14 ref17">17, 14</xref>
        ].
For definitions, see Section 2. The result after chasing a tgd set over a database D is
denoted by chase(D; ).
      </p>
      <p>Consider a set of tgds and a database D over a joint signature R. Let q be a
Boolean conjunctive query (BCQ) issued against (D; ). We would like to transform q
into a nonrecursive Datalog query P such that (D; ) j= q iff D j= P . We assume here
that P has a special propositional goal goal, and D j= P means that goal is derivable
from P when evaluated over D. Let us define an important property of classes of tgds.
Definition 1. Polynomial witness property (PWP). The PWP holds for a class C of
tgds if there exists a polynomial such that, for every finite set C of tgds and each
BCQ q, the following holds: for each database D, whenever (D; ) j= q, then there is
a sequence of at most (j j; jqj) chase steps whose atoms already entail q.</p>
      <p>Our main technical result, which is more formally stated in Section 3, is as follows.
Theorem 1. Let be a set of tgds from a class C enjoying the PWP. Then each BCQ
q can be rewritten in polynomial time into a nonrecursive Datalog program P of size
polynomial in the joint size of q and , such that for every database D, (D; ) j= q if
and only if D j= P . Moreover, the arity of P is max(a + 2; 9), where a is the maximum
arity of any predicate symbol occurring in , in case a sufficiently large linear order
can be accessed in the database, or otherwise by O(max(a + 2; 9) log m), where m
is the joint size of q and .</p>
      <p>
        Other Results. From this result, and from already established facts, a good number
of further rewritabliity results for other formalisms can be derived. In particular, we can
show that conjunctive queries based on other classes of tgds or description logics can
be efficiently translated into nonrecursive Datalog. Among these formalisms are: linear
tgds, originally defined in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and equivalent to inclusion dependencies, various major
versions of the well-known description logic DL-Lite [
        <xref ref-type="bibr" rid="ref20 ref9">9, 20</xref>
        ], and sticky tgds [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] as well
as sticky-join tgds [
        <xref ref-type="bibr" rid="ref6 ref7">6, 7</xref>
        ]. For space reasons, we will just give an overview and very short
explanations of how each of these rewritability results follows from our main theorem.
      </p>
      <p>Structure of the Paper. The rest of the paper is structured as follows. In Section 2
we state a few preliminaries and simplifying assumptions. In Section 3, we explain the
idea of the proof of the main result. Section 4, contains the other results following from
the main result. A brief overview of related work concludes the paper in Section 5.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Preliminaries and Assumptions</title>
      <p>
        We assume the reader to be familiar with the terminology of relational databases and
the concepts of conjunctive query (CQ) and Boolean conjunctive query (BCQ). For
simplicity, we restrict our attention to Boolean conjunctive queries q. However, our
results can easily be reformulated for queries with output, see the extended version of
this paper [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ]).
      </p>
      <p>
        Given a relational schema R, a tuple-generating dependency (tgd) is a first-order
formula of the form 8X8Y (X; Y ) ! 9Z (X; Z), where (X; Y ) and (X; Z)
are conjunctions of atoms over R, called the body and the head of , denoted body ( )
and head ( ), respectively. We usually omit the universal quantifiers in tgds. Such is
satisfied in a database D for R iff, whenever there exists a homomorphism h that maps
the atoms of (X; Y ) to atoms of D, there exists an extension h0 of h that maps the
atoms of (X; Z) to atoms of D. All sets of tgds are finite here. We assume in the rest
of the paper that every tgd has exactly one atom and at most one existentially quantified
variable in its head. A set of tgds is in normal form if the head of each tgd consists
of a single atom. It was shown in [4, Lemma 10] that every set of TGDs can be
transformed into a set 0 in normal form of size at most quadratic in j j, such that
and 0 are equivalent with respect to query answering. The normal form transformation
shown in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] can be achieved in logarithmic space. It is, moreover, easy to see that this
very simple transformation preserves the polynomial witness property.
      </p>
      <p>For a database D for R, and a set of tgds on R, the set of models of D and ,
denoted mods(D; ), is the set of all (possibly infinite) databases B such that (i) D B
and (ii) every 2 is satisfied in B. The set of answers for a CQ q to D and , denoted
ans(q; D; ), is the set of all tuples a such that a 2 q(B) for all B 2 mods(D; ). The
answer for a BCQ q to D and is yes iff the empty tuple is in ans(q; D; ), also
denoted as D [ j= q.</p>
      <p>
        Note that, in general, query answering under tgds is undecidable [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], even when the
schema and tgds are fixed [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Query answering is, however, decidable for interesting
classes of tgds, among which are those considered in the present paper.
      </p>
      <p>
        The chase procedure [
        <xref ref-type="bibr" rid="ref14 ref17">17, 14</xref>
        ] uses the following oblivious chase rule.
      </p>
      <p>TGD CHASE RULE. Consider a database D for a relational schema R, and a tgd
on R of the form (X; Y ) ! 9Z (X; Z). Then, is applicable to D if there
exists a homomorphism h that maps the atoms of (X; Y ) to atoms of D. Let be
applicable to D, and h1 be a homomorphism that extends h as follows: for each Xi 2
X, h1(Xi) = h(Xi); for each Zj 2 Z, h1(Zj ) = zj , where zj is a fresh null value
(i.e., a Skolem constant) different from all nulls already introduced. The application of
on D adds to D the atom h1( (X; Z)) if not already in D (which is possible when
Z is empty).</p>
      <p>The chase algorithm for a database D and a set of tgds consists of an exhaustive
application of the tgd chase rule in a breadth-first (level-saturating) fashion, which leads
as result to a (possibly infinite) chase for D and . Each atom from the database D is
assigned a derivation level. Atoms in D have derivation level 0. If an atom has not
already derivation level i but can be obtained by a single application of a tgd via the
chase rule from atoms having derivation level i, then its derivation level is i + 1. The
set of all atoms of derivation level k is denoted by chasek(D; ). The chase of D
relative to , denoted chase(D; ), is then the limit of chasek(D; ) for k ! 1.</p>
      <p>
        The (possibly infinite) chase relative to tgds is a universal model, i.e., there exists
a homomorphism from chase(D; ) onto every B 2 mods(D; ) [
        <xref ref-type="bibr" rid="ref11 ref4">11, 4</xref>
        ]. This result
implies that BCQs q over D and can be evaluated on the chase for D and , i.e.,
D [ j= q is equivalent to chase(D; ) j= q.
      </p>
      <p>A chase sequence of length n based on D and is a sequence of n atoms such that
each atom is either from D or can be derived via a single application of some rule in
from previous atoms in the sequence. If S is such a chase sequence and q a conjunctive
query, we write S j= q if there is a homomorphism from q to the set of atoms of S.</p>
      <p>We assume that every database has two constants, 0 and 1, that are available via
the unary predicates Zero and One, respectively. Moreover, each database has a binary
predicate Neq such that Neq(a; b) is true precisely if a and b are distinct values.</p>
      <p>We finally define N -numerical databases. Let D be a database whose domain does
not contain any natural numbers. We define DN as the extension of D by adding the
natural numbers 0; 1; : : : ; N to its domain, a unary relation Num that contains exactly
the numbers 1; : : : ; N , binary order relations Succ and &lt; on 0; 1; : : : ; N , expressing
the natural successor and “&lt;” orders on N , respectively. 3 We refer to DN as the
N -numerical extension of D, and, a so extended database as N -numerical database.
We denote the total domain of a numerical database DN by domN (D) and the
nonnumerical domain (still) by dom(D). Standard databases can always be considered to
be N -numerical, for some large N by the standard type integer, with the &lt; predicate
(and even arithmetic operations). A number maxint corresponding to N can be defined.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Main Result</title>
      <sec id="sec-3-1">
        <title>Our main result is more formally stated as follows:</title>
        <p>Theorem 1. Let C be a class of tgds in normal form, enjoying the polynomial
witness property and let be the polynomial bounding the number of chase steps (with
(n1; n2) max(n1; n2), for all naturals n1; n2). For each set C of tgds and
each Boolean CQ q, one can compute in polynomial time a nonrecursive Datalog
program P of polynomial size in j j and jqj, such that, for every database D it holds
D; j= q if and only if D j= P . Furthermore:
(a) For N -numerical databases D, where N (j j; jqj), the arity of P is max(a +
2; 9), where a is the maximum arity of any predicate symbol occurring in ;
(b) otherwise (for non-numerical databases), the arity of P is O(max(a + 2; 9)
log (j j; jqj)), where a is as above.</p>
        <p>
          We note that N is polynomially bounded in j j and jqj by the polynomial that
only depends on C. The rest of this section explains the basic ideas of the proof of this
result. A more detailed proof is given in [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ].
        </p>
        <p>High-level idea of the proof. We first describe the high level idea of the
construction of the Datalog program P . It checks whether there is a chase sequence
S = t1; : : : ; tN with respect to D and and a homomorphism h from q to (the set
of atoms of) S. To this end, P consists of one large rule rgoal of polynomial size in N
and some shorter rules that define auxiliary relations and will be explained below.</p>
        <p>The aim of rgoal is to guess the chase sequence S and the homomorphism q at the
same time. We recall that N does not depend on the size of D but only on j j and
jqj and thus rgoal can well be as long as the chase sequence and q together. One of the
advantages of this approach is that we only have to deal with those null values that
are actually relevant for answering the query. Thus, at most N null values need to be
represented.
3 Of course, if dom(D) already contains some natural numbers we can add a fresh copy of
f0; 1; : : : ; N g instead.</p>
        <p>One might try to obtain rgoal by just taking one atom Ai for each tuple ti of S and
one atom for each atom of q and somehow test that they are consistent. However, it is
not clear how consistency could possibly be checked in a purely conjunctive fashion.4
There are two ways in which disjunctive reasoning is needed. First, it is not a priori
clear on which previous tuples, tuple ti will depend. Second, it is not a priori clear to
which tuples of S the atoms of q can be mapped.</p>
        <p>To overcome these challenges we use the following basic ideas.
(1) We represent the tuples of S (and the required tuples of D) in a symbolic fashion,
utilizing the numerical domain.
(2) We let P compute auxiliary predicates that allow us to express disjunctive
relationships between the tuples in S.</p>
        <p>Example 1. We illustrate the proof idea with a very simple running example, shown in
Figure 1.</p>
        <p>(a)
:
1: R1(X; Y ) ! 9Z R4(X; Y; Z)
2: R2(Y; Z) ! 9X R4(X; Y; Z)
3: R3(X; Z) ! 9Y R4(X; Y; Z)
4: R4(X1; Y1; Z1); R4(X2; Y2; Z2) ! R5(X1; Z2)
(b) q : R5(X; Y ); R3(Y; X)
(c) D :</p>
        <p>R1
a b
c d</p>
        <p>R2
e g</p>
        <p>R3
g a
g h</p>
        <p>A possible chase sequence in this example is shown in Figure 2(a). The mapping X 7! a
and Y 7! g, maps R5(X; Y ) to t5 and R3(Y; X) to t6, thus satisfying q.
(a)
– t1: R1(a; b)
– t2: R4(a; b; ?2)
– t3: R2(e; g)
– t4: R4(?4; e; g)
– t5: R5(a; g)
– t6: R3(g; a)
(b)
– t1: R1(a; b; a)
– t2: R4(a; b; ?2)
– t3: R2(e; g; e)
– t4: R4(?4; e; g)
– t5: R5(a; g; a)
– t6: R3(g; a; g)
i ri fi xi1 xi2 xi3 si ci1 ci2
1 1 0 a b a 0 0 0
2 4 1 a b 2 1 1 1
(c) 3 2 0 e g e 0 0 0
4 4 1 4 e g 2 3 3
5 5 1 a g a 4 2 4
6 3 0 g a g 0 0 0</p>
        <p>Notation and conventions. Let C be a class of tgds enjoying the PWP, let be a set
of tgds from C, and let q be a BCQ. Let R1; : : : Rm be the predicate symbols occurring
in or in q. We denote the number of tgds in by `.
4 Furthermore, of course, there are no relations to which the atoms Ai could possible be
matched.</p>
        <p>Let N := (j j; jqj) where is as in Definition 1, thus N is polynomial in j j and
jqj. By definition of N , if (D; ) j= q, then q can be witnessed by a chase sequence
of length N . Our assumption that (n1; n2) max(n1; n2), for every n1; n2,
guarantees that N is larger than (i) the number of predicate symbols occurring in , (ii)
the cardinality jqj of the query, and (iii) the number of rules in .</p>
        <p>For the sake of a simpler presentation, we assume that all relations in have the
same arity a and all rules use the same number k of tuples in their body. The latter
can be easily achieved by repeating tuples, the former by filling up shorter tuples by
repeating the first tuple entry. Furthermore, we only consider chase sequences of length
N . Shorter sequences can be extended by adding tuples from D.</p>
        <p>Example 2. Example 1 thus translates as illustrated in Figure 3. The (extended) chase
sequence is shown in Figure 2 (b). The query q is now satisfied by the mapping X 7! a,
Y 7! g, U 7! g, V 7! a, thus mapping R5(X; Y; X) to t5 and R3(Y; X; Y ) to t6.
(a)
:
1: R1(X; Y; X); R1(X; Y; X) ! 9Z R4(X; Y; Z) (b) q : R5(X; Y; U ); R3(Y; X; V )
2: R2(Y; Z; Y ); R2(Y; Z; Y ) ! 9X R4(X; Y; Z) (c) D :
3: R3(X; Z; X); R3(X; Z; X) ! 9Y R4(X; Y; Z) R1 R2 R3
4: R4(X1; Y1; Z1); R4(X2; Y2; Z2) ! a b a e g e g a g</p>
        <p>R5(X1; Z2; X1) c d c g h g</p>
        <p>Proof idea (continued). On an abstract level, the atoms that make up the final rule
rgoal of P can be divided into three groups serving three different purposes. That is, rgoal
can be considered as a conjunction rtuples ^ rchase ^ rquery. Each group is “supported”
by a sub-program of P that defines relations that are used in rgoal, and we refer to these
three subprograms as Ptuples, Pchase and Pquery, respectively.</p>
        <p>– The purpose of rtuples is basically to lay the ground for the other two. It consists of</p>
        <p>N atoms that allow to guess the symbolic encoding of a sequence S = t1; : : : ; tN .
– The atoms of rchase are designed to verify that S is an actual chase sequence with
respect to D.
– Finally, rquery checks that there is a homomorphism from q to S.</p>
        <p>Ptuples and rtuples. The symbolic representation of the tuples ti of the chase
sequence S uses numerical values to encode null values, predicate symbols Ri (by i),
tgds j 2 (by j) and the number of a tuple ti in the sequence (that is: i).</p>
        <p>In particular, the symbolic encoding uses the following numerical parameters.5
– ri to indicate the relation Rri to which the tuple belongs;
– fi to indicate whether ti is from D (fi = 0 ) or yielded by the chase ( fi = 1);</p>
      </sec>
      <sec id="sec-3-2">
        <title>5 We use the names of the parameters as variable names in rgoal as well.</title>
        <p>– Furthermore, xi1; : : : ; xia represent the attribute values of ti as follows. If the
jth attribute of ti is a value from dom(D) then xij is intended to be that value,
otherwise it is a null represented by a numeric value.</p>
        <p>Since each rule of has at most one existential quantifier in its head, at each chase step,
at most one new null value can be introduced. Thus, we can unambiguously represent
the null value (possibly) introduced in the j-th step of the chase by the number j.</p>
        <p>The remaining parameters si and ci1; : : : ; cik are used to encode information about
the tgd and the tuples (atoms) in S that are used to generate the current tuple. More
precisely, si is intended to be the number of the applied tgd si and ci1; : : : ; cik are
the tuple numbers of the k tuples that are used to yield ti. In the example, e.g., t5 is
obtained by applying 4 to t2 and t4. The encoding of our running example can be
found in Figure 2 (c).</p>
        <p>We use a new relational symbol T of arity a + k + 4 not present in the schema of
D for the representation of the tuples from S. Thus, rtuples is just:
T (1; r1; f1; x11; : : : ; x1a; s1; c11; : : : ; c1k); : : :;</p>
        <p>T (N; rN ; fN ; xN1; : : : ; xNa; sN ; cN1; : : : ; cNk).</p>
        <p>The sub-program Ptuples is intended to “fill” T with suitable tuples. Basically, T
contains all encodings of tuples in D (with fi = 0) and all syntactically meaningful
tuples corresponding to possible chase steps (with fi = 1).</p>
        <p>Pchase and rchase. The following kinds of conditions have to be checked to ensure
that the tuples “guessed” by rtuples constitute a chase sequence.
(1) For every i, the relation Rri of a tuple ti has to match the head of its rule si .</p>
        <p>– In the example, e.g., r4 has to be 4 as the head of 2 is an R4-atom.
(2) Likewise, for each i and j the relation number of tuple tcij has to be the relation
number of the j-th atom of si .</p>
        <p>– In the example, e.g., r2 must be 4, as c5;1 = 2 and the first atom of s5 = 4 is
an R4-atom.
(3) If the head of si contains an existentially quantified variable, the new null value is
represented by the numerical value i.</p>
        <p>– This is illustrated by t4 in the example: the first position of the head of rule 2
has an existentially quantified variable and thus x4;1 = 4.
(4) If a variable occurs at two different positions in si then the corresponding positions
in the tuples used to produce ti carry the same value.
(5) If a variable in the body of si also occurs in the head of si then the values of the
corresponding positions in the body tuple and in ti are equal.</p>
        <p>– Z2 occurs in position 3 of the second atom of the body of 4 and in position 2
of its head. Therefore, x4;3 and x5;2 have to coincide (where the 4 is determined
by c5;2.</p>
        <p>It turns out that all these tests can be done by rchase, given some relations that
are precomputed by Pchase. More precisely, we let Pchase specify a 4-ary predicate
IfThen(X1; X2; U1; U2) that is intended to contain all tuples fulfilling the condition:
if X1 = X2 then U1 = U2. Similar predicates are defined for conditions with two and
three conjuncts in the IF-part. Their definition by Datalog rules is straightforward.</p>
        <p>Pquery and rquery. Finally, we explain how it can be checked that there is a
homomorphism from q to S. We explain the issue through the little example query
R3(x; y) ^ R4(y; z). To evaluate this query, rquery makes use of two additional
variables q1 and q2, one for each atom of q. The intention is that these variables bind to the
numbers of the tuples that the atoms are mapped to. We have to make sure two kinds
of conditions. First, the tuples need to have the right relation symbol and second, they
have to obey value equalities induced by the variables of q that occur more than once.</p>
        <p>The first kind of conditions is checked by adding atoms IfThen(q1; i; ri; 3) and
IfThen(q2; i; ri; 4) to rquery, for every i N . The second condition is checked
similarly. As we do not need any further auxiliary predicates, Pquery is empty.</p>
        <p>This completes the description of P . Note that P is nonrecursive, and has
polynomial size in the size of q and . Furthermore, the arity of P is as required. This proves
part (a) of Theorem 1.</p>
        <p>In order to prove part (b), we must get rid of the numeric domain (except for 0
and 1). This is actually very easy. We just replace each numeric value by a logarithmic
number of bits (coded by our 0 and 1 domain elements), and extend the predicate arities
accordingly. As a matter of fact, this requires an increase of arity by a factor of log N =
O(log jqj). This concludes our explanation of the proof ideas underlying Theorem 1.</p>
        <p>
          Remark 1. Note that the evaluation complexity of the Datalog program obtained
for case (b) is not significantly higher than the evaluation complexity of the program P
constructed for case (a). For example, in the most relevant case of bounded arities, both
programs can be evaluated in NPTIME combined complexity over a database D. In
fact, it is well-known that the combined complexity of a Datalog program of bounded
arity is in NPTIME (see [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]). But it is easy to see that if we expand the signature of
such a program (and of the underlying database) by a logarithmic number of
Booleanvalued argument positions (attributes), nothing changes, because the possible values for
such vectorized arguments are still of polynomial size. It is just a matter of coding. In a
similar way, the data complexity in both cases (a) and (b) is the same (PTIME).
        </p>
        <p>Remark 2. It is easy to generalize this result to the setting where q is actually a
union of conjunctive queries (UCQ).
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Further Results Derived From the Main Theorem</title>
      <p>We wish to mention some interesting consequences of Theorem 1 that follow easily
from the above result after combining it with various other known results.
4.1</p>
      <sec id="sec-4-1">
        <title>Linear TGDs</title>
        <p>
          A linear tgd [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ] is one that has a single atom in its rule body. The class of linear tgds
is a fundamental one in the Datalog family. This class contains the class of inclusion
dependencies. It was already shown in [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ] for inclusion dependencies that classes of
linear tgds of bounded (predicate) arities enjoy the PWP. That proof carries over to
linear tgds.
        </p>
        <p>
          By Theorem 1, we then conclude:
Theorem 2. Conjunctive queries under linear tgds of bounded arity are polynomially
rewritable as nonrecursive Datalog programs in the same fashion as for Theorem 1. So
are sets of inclusion dependencies of bounded arity.
A pioneering and highly significant contribution towards tractable ontological reasoning
was the introduction of the DL-Lite family of description logics (DLs) by Calvanese et
al. [
          <xref ref-type="bibr" rid="ref20 ref9">9, 20</xref>
          ]. DL-Lite was further studied and developed in [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ].
        </p>
        <p>
          A DL-lite theory (or TBox) = ( ; +) consists of a set of negative constraints
such as key and disjointness constraints, and of a set + of positive constraints
that resemble tgds. As shown in [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ], the negative constraints can be compiled into a
polymomially sized first-order formula (actually a union of conjunctive queries) of the
same arity as such that for each database and BCQ q, (D; ) j= q iff D 6j=
and (D; +) j= q. In (the full version of) [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ] it was shown that for the main DL-Lite
variants defined in [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ], each + can be immediately translated into an equivalent set of
linear tgds of arity 2. By virtue of this, and the above we obtain the following theorem.
Theorem 3. Let q be a CQ and let = ( ; +) be a DL-Lite theory expressed
in one of the following DL-Lite variants: DL-LiteF;u, DL-LiteR;u, DL-Lite+A;u,
DLRLiteF;u, DLR-LiteR;u, or DLR-Lite+A;u. Then + can be rewritten into a nonrecursive
Datalog program P such that for each database D, (D; +) j= q iff D j= P . Regarding
the arities of P , the same bounds as in Theorem 1 hold.
4.3
        </p>
      </sec>
      <sec id="sec-4-2">
        <title>Sticky and Sticky Join TGDs</title>
        <p>
          Sticky tgds [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ] and sticky-join tgds [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ] are special classes of tgds that generalize linear
tgds but allow for a limited form of join (including as special case the cartesian product).
They allow one to express natural ontological relationships not expressible in DLs such
as OWL. For space reasons, we do not define these classes here, and refer the reader
to [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. By results of [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ], which will also be discussed in detail in a future extended
version [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ] of the present paper, both classes enjoy the Polynomial Witness Property.
By Theorem 1, we thus obtain the following result:
Theorem 4. Conjunctive queries under sticky tgds and sticky-join tgds over a fixed
signature R are rewritable into polynomially sized nonrecursive Datalog programs of
arity bounded as in Theorem 1.
5
        </p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Related Work on Query Rewriting</title>
      <p>
        Several techniques for query-rewriting have been developed. An early algorithm,
introduced in [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] and implemented in the QuOnto system6, reformulates the given query
into a union of CQs (UCQs) by means of a backward-chaining resolution procedure.
      </p>
      <sec id="sec-5-1">
        <title>6 http://www.dis.uniroma1.it/ quonto/</title>
        <p>
          The size of the computed rewriting increases exponentially w.r.t. the number of atoms
in the given query. This is mainly due to the fact that unifications are derived in a
“blind” way from every unifiable pair of atoms, even if the generated rule is
superfluous. An alternative resolution-based rewriting technique was proposed by Pere´z-Urbina
et al. [
          <xref ref-type="bibr" rid="ref19">19</xref>
          ], implemented in the Requiem system7, that produces a UCQs as a rewriting
which is, in general, smaller (but still exponential in the number of atoms of the query)
than the one computed by QuOnto. This is achieved by avoiding the useless
unifications, and thus the redundant rules obtained due to these unifications. This algorithm
works also for more expressive non-first-order rewritable DLs. In this case, the
computed rewriting is a (recursive) Datalog query. Following a more general approach, Cal`ı
et al. [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] proposed a backward-chaining rewriting algorithm for the first-order rewritable
Datalog languages mentioned above. However, this algorithm is inspired by the
original QuOnto algorithm, and inherits all its drawbacks. In [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ], a rewriting technique
for linear Datalog into unions of conjunctive queries is proposed. This algorithm is an
improved version of the one already presented in [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ]. However, the size of the rewriting
is still exponential in the number of query atoms.
        </p>
        <p>
          Of more interest to the present work are rewritings into nonrecursive Datalog.
In [
          <xref ref-type="bibr" rid="ref15 ref16">15, 16</xref>
          ] a polynomial-size rewriting into nonrecursive Datalog is given for the
description logics DL-LitehForn and DL-Litehorn. For DL-LitehNorn, a DL with counting, a
polynomial rewriting involving aggregate functions is proposed. It is, moreover, shown
in (the full version of) [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ] that for the description logic DL-LiteF a polynomial-size
pure first-order query rewriting is possible. Note that neither of these logics allows for
role inclusion, while our approach covers description logics with role inclusion axioms.
Other results in [
          <xref ref-type="bibr" rid="ref15 ref16">15, 16</xref>
          ] are about combined rewritings where both the query and the
database D have to be rewritten. A recent very interesting paper discussing polynomial
size rewritings is [
          <xref ref-type="bibr" rid="ref22">22</xref>
          ]. Among other results, [
          <xref ref-type="bibr" rid="ref22">22</xref>
          ] provides complexity-theoretic
arguments indicating that without the use of special constants (e.g, 0 and 1, or the numerical
domain), a polynomial rewriting such as ours may not be possible. Rosati et al. [
          <xref ref-type="bibr" rid="ref21">21</xref>
          ]
recently proposed a very sophisticated rewriting technique into nonrecursive Datalog,
implemented in the Presto system. This algorithm produces a non-recursive Datalog
program as a rewriting, instead of a UCQs. This allows the “hiding” of the exponential
blow-up inside the rules instead of generating explicitly the disjunctive normal form.
The size of the final rewriting is, however, exponential in the number of non-eliminable
existential join variables of the given query; such variables are a subset of the join
variables of the query, and are typically less than the number of atoms in the query. Thus,
the size of the rewriting is exponential in the query size in the worst case. Relevant
further optimizations of this method are given in [
          <xref ref-type="bibr" rid="ref18">18</xref>
          ].
        </p>
        <p>Acknowledgment G. Gottlob’s Work was funded by the EPSRC Grant EP/H051511/1
ExODA: Integrating Description Logics and Database Technologies for Expressive
Ontology-Based Data Access. We thank the anonymous referees, as well as Roman
Kontchakov, Carsten Lutz, and Michael Zakharyaschev for useful comments on an
earlier version of this paper.</p>
      </sec>
      <sec id="sec-5-2">
        <title>7 http://www.comlab.ox.ac.uk/projects/requiem/home.html</title>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>Alessandro</given-names>
            <surname>Artale</surname>
          </string-name>
          , Diego Calvanese, Roman Kontchakov, and
          <string-name>
            <given-names>Michael</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          ,
          <article-title>The dl-lite family and relations</article-title>
          ,
          <source>J. Artif. Intell. Res. (JAIR) 36</source>
          (
          <year>2009</year>
          ),
          <fpage>1</fpage>
          -
          <lpage>69</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>Catriel</given-names>
            <surname>Beeri</surname>
          </string-name>
          and
          <string-name>
            <surname>Moshe Y. Vardi</surname>
          </string-name>
          ,
          <article-title>The implication problem for data dependencies</article-title>
          ,
          <source>Proc. of ICALP</source>
          ,
          <year>1981</year>
          , pp.
          <fpage>73</fpage>
          -
          <lpage>85</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>A.</given-names>
            <surname>Cal</surname>
          </string-name>
          <article-title>`ı, G. Gottlob, and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <article-title>Query rewriting under non-guarded rules</article-title>
          ,
          <source>Proc. AMW</source>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>Andrea</given-names>
            <surname>Cal</surname>
          </string-name>
          <article-title>`ı, Georg Gottlob, and Michael Kifer, Taming the infinite chase: Query answering under expressive relational constraints</article-title>
          ,
          <source>Proc. of KR</source>
          ,
          <year>2008</year>
          , pp.
          <fpage>70</fpage>
          -
          <lpage>80</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5. Andrea Cal`ı, Georg Gottlob, and
          <string-name>
            <given-names>Thomas</given-names>
            <surname>Lukasiewicz</surname>
          </string-name>
          ,
          <article-title>A general datalog-based framework for tractable query answering over ontologies</article-title>
          ,
          <source>Proc. of PODS</source>
          ,
          <year>2009</year>
          , pp.
          <fpage>77</fpage>
          -
          <lpage>86</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>Andrea</given-names>
            <surname>Cal</surname>
          </string-name>
          <article-title>`ı, Georg Gottlob, and Andreas Pieris, Advanced processing for ontological queries</article-title>
          ,
          <source>PVLDB</source>
          <volume>3</volume>
          (
          <year>2010</year>
          ), no.
          <issue>1</issue>
          ,
          <fpage>554</fpage>
          -
          <lpage>565</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. ,
          <article-title>Query answering under non-guarded rules in datalog+/-</article-title>
          ,
          <source>Proc. of RR</source>
          ,
          <year>2010</year>
          , pp.
          <fpage>175</fpage>
          -
          <lpage>190</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8. ,
          <article-title>Towards more expressive ontology languages: The query answering problem</article-title>
          ,
          <source>Tech. report</source>
          , University of Oxford, Department of Computer Science,
          <year>2011</year>
          ,
          <article-title>Submitted for publication - available from the authors</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. Diego Calvanese, Giuseppe De Giacomo, Domenico Lembo, Maurizio Lenzerini, and Riccardo Rosati,
          <article-title>Tractable reasoning and efficient query answering in description logics: The DL-lite family</article-title>
          ,
          <source>J. Autom. Reasoning</source>
          <volume>39</volume>
          (
          <year>2007</year>
          ), no.
          <issue>3</issue>
          ,
          <fpage>385</fpage>
          -
          <lpage>429</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Evgeny</surname>
            <given-names>Dantsin</given-names>
          </string-name>
          , Thomas Eiter, Gottlob Georg, and
          <article-title>Andrei Voronkov, Complexity and expressive power of logic programming</article-title>
          ,
          <source>ACM Comput. Surv</source>
          .
          <volume>33</volume>
          (
          <year>2001</year>
          ), no.
          <issue>3</issue>
          ,
          <fpage>374</fpage>
          -
          <lpage>425</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Alin</surname>
            <given-names>Deutsch</given-names>
          </string-name>
          , Alan Nash, and
          <string-name>
            <surname>Jeff</surname>
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Remmel</surname>
          </string-name>
          ,
          <article-title>The chase revisisted</article-title>
          ,
          <source>Proc. of PODS</source>
          ,
          <year>2008</year>
          , pp.
          <fpage>149</fpage>
          -
          <lpage>158</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Georg</surname>
            <given-names>Gottlob</given-names>
          </string-name>
          , Giorgio Orsi, and Andreas Pieris,
          <article-title>Ontological queries: Rewriting and optimization</article-title>
          ,
          <source>Proc. of ICDE</source>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13. Georg Gottlob and Thomas Schwentick,
          <article-title>Rewriting ontological queries into small nonrecursive datalog programs</article-title>
          ,
          <source>arXiv Computing Research Repository (CoRR) arXiv:1106.3767</source>
          (
          <year>2011</year>
          ), extended version, available at http://arxiv.org/abs/1106.3767.
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14. David S. Johnson and Anthony C.
          <article-title>Klug, Testing containment of conjunctive queries under functional and inclusion dependencies</article-title>
          ,
          <source>J. Comput. Syst. Sci</source>
          .
          <volume>28</volume>
          (
          <year>1984</year>
          ), no.
          <issue>1</issue>
          ,
          <fpage>167</fpage>
          -
          <lpage>189</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Roman</surname>
            <given-names>Kontchakov</given-names>
          </string-name>
          , Carsten Lutz, David Toman,
          <string-name>
            <given-names>Frank</given-names>
            <surname>Wolter</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Michael</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          ,
          <article-title>The combined approach to query answering in dl-lite, KR (Fangzhen Lin, Ulrike Sattler</article-title>
          , and Miroslaw Truszczynski, eds.), AAAI Press,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16. ,
          <article-title>The combined approach to ontology-based data access</article-title>
          ,
          <source>IJCAI</source>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17. David Maier,
          <string-name>
            <given-names>Alberto O.</given-names>
            <surname>Mendelzon</surname>
          </string-name>
          , and Yehoshua Sagiv,
          <article-title>Testing implications of data dependencies</article-title>
          .,
          <source>ACM Trans. Database Syst</source>
          .
          <volume>4</volume>
          (
          <issue>1979</issue>
          ), no.
          <issue>4</issue>
          ,
          <fpage>455</fpage>
          -
          <lpage>469</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <article-title>Giorgio Orsi and Andreas Pieris, Optimizing query answering under ontological constraints</article-title>
          ,
          <source>PVLDB</source>
          ,
          <year>2011</year>
          , to appear.
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19. H.
          <article-title>Pe´rez-</article-title>
          <string-name>
            <surname>Urbina</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Motik</surname>
            ,
            <given-names>and I. Horrocks</given-names>
          </string-name>
          ,
          <article-title>Tractable query answering and rewriting under description logic constraints</article-title>
          ,
          <source>Journal of Applied Logic</source>
          <volume>8</volume>
          (
          <year>2009</year>
          ), no.
          <issue>2</issue>
          ,
          <fpage>151</fpage>
          -
          <lpage>232</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          20.
          <string-name>
            <surname>Antonella</surname>
            <given-names>Poggi</given-names>
          </string-name>
          , Domenico Lembo, Diego Calvanese, Giuseppe De Giacomo, Maurizio Lenzerini, and Riccardo Rosati,
          <article-title>Linking data to ontologies</article-title>
          ,
          <source>J. Data Semantics</source>
          <volume>10</volume>
          (
          <year>2008</year>
          ),
          <fpage>133</fpage>
          -
          <lpage>173</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          21.
          <string-name>
            <given-names>R.</given-names>
            <surname>Rosati</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Almatelli</surname>
          </string-name>
          ,
          <article-title>Improving query answering over DL-Lite ontologies</article-title>
          ,
          <source>Proc. KR</source>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          22. R.Kontchakov S. Kikot, Carsten Lutz, and
          <string-name>
            <given-names>M.</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          ,
          <article-title>On (In)Tractability of OBDA with OWL2QL</article-title>
          ,
          <source>Proc. DL</source>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>