<!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>Polynomial Disjunctive Datalog Rewritings of Instance Queries in Expressive Description Logics</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Shqiponja Ahmetaj</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Magdalena Ortiz</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mantas Simkus</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute of Information Systems</institution>
          ,
          <addr-line>TU Vienna</addr-line>
          ,
          <country country="AT">Austria</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Rewriting ontology mediated queries (OMQs) into traditional query languages like FO-queries and Datalog is central for understanding their relative expressiveness, and plays a crucial role in the ongoing e orts to develop OMQ answering tools by reusing existing database technologies. However, the vast majority of works focus on Horn ontologies, and for OMQs where the ontologies are written in extensions of ALC, only a couple of exponential rewritings into disjunctive Datalog are known. In this paper we propose a translation of instance queries mediated by ontologies in the expressive DL ALCHI, into polynomial-sized disjunctive Datalog programs. The translation is based on a simple game-like algorithm, and can be extended to accommodate nominals. We can also rewrite OMQs with closed-predicates into Datalog programs with (limited) negation. Closed predicates are useful for combining complete and incomplete information, but make OMQs non-monotonic and thus not rewritable into positive disjunctive Datalog.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        In ontology-mediated queries (OMQs), a database query is enriched with an
ontology, providing knowledge to obtain more complete answers from incomplete
data. OMQs are receiving much attention in the database and knowledge
representation research communities, particularly when the ontological knowledge is
expressed in Description Logics (DLs) or in rule-based formalisms like existential
rules and Datalog , see e.g., [
        <xref ref-type="bibr" rid="ref13 ref3 ref4">4, 3, 13</xref>
        ] and their references. One of the most
central questions in OMQ research is rewritability : given an OMQ Q, speci ed
by a query and an ontology, obtain a query Q0|in some standard database
language, like rst-order (FO) queries or (fragments of) Datalog|such that,
for any dataset A, the certain answers to Q and Q0 coincide. Such a Q0 is called
a rewriting of Q. Its existence and size are crucial for understanding the relative
expressiveness of di erent families of OMQs in terms of more traditional query
languages. Rewritings are also very relevant in practice, since they allow to reuse
existing database technologies to support OMQ answering.
      </p>
      <p>
        Research into OMQs that can be rewritten into rst-order (FO) queries has
produced the successful DL-Lite family [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] of DLs. The succinctness of rewritings
for OMQs consisting of the so-called (unions of ) conjunctive queries (UCQs)
paired with ontologies in DL-Lite, or in related families of existential rules, has
been extensively studied. It has been shown that polynomially sized non-recursive
Datalog queries can be constructed for a few well known ontology languages,
formulated as DLs or existential rules [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]; but for many other cases, the lack of
succinctness of such rewritings has also been established [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], and some authors
have considered rewritings that, unlike the ones we consider here, are not
dataindependent [
        <xref ref-type="bibr" rid="ref12 ref18">18, 12</xref>
        ]. For DLs beyond DL-Lite, which are often not FO-rewritable,
rewritings of UCQs into Datalog queries have been proposed, and lie at the
core of implemented systems, e.g., [
        <xref ref-type="bibr" rid="ref9">24, 9, 25</xref>
        ]. The pioneering work in [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ] showed
that instance queries in an expressive extension of ALC can be rewritten into
a program in disjunctive Datalog, using a constant number of variables per
rule, but exponentially many rules. The rst translation from CQs in expressive
DLs (SH, SHQ) to disjunctive Datalog programs was introduced in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], but
the program may contain double exponentially many predicates. For ALC and
UCQs, the existence of exponential rewritings in disjunctive Datalog was shown
recently [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. For restricted fragments of SHI and classes of CQs translations to
Datalog were investigated in [
        <xref ref-type="bibr" rid="ref16 ref17">16, 17</xref>
        ]. A polynomial time Datalog translation
of instance queries has been proposed in [23], but for a so-called Horn-DL that
lacks disjunction. To our knowledge, this was until now the only polynomial
rewriting for a DL that is not FO-rewritable.
      </p>
      <p>
        The main contribution of this paper is a polynomial time translation of
instance queries mediated by ALCHI TBoxes into disjunctive Datalog. The
translation is based on a simple game-theoretic characterization, and implements
a so-called type-elimination procedure using a polynomially sized Datalog
program. To our knowledge, this is the rst polynomial time translation of an
expressive (non-Horn) DL into disjunctive Datalog. The translation we present
here can be extended to richer OMQs, and in particular, to nominals and closed
predicates. In fact, we report here a simpli ed version of the translation in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ],
which is a polynomial translation of instance queries mediated by ALCHOI
TBoxes with closed predicates into disjunctive Datalog queries with negation.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Preliminaries</title>
      <sec id="sec-2-1">
        <title>We give some basic notions of DLs and Datalog.</title>
        <p>The DL ALCHI We assume countably in nite, mutually disjoint sets NR of
role names, NC of concept names, and NI of individual names. A role r is either a
role name p, or an expression p , called the inverse of p. We let r = p if r = p .
Concepts are de ned inductively: (i) &gt;, ? and all A 2 NC are concepts; (ii) if
C1; C2 are concepts, then C1 u C2, C1 t C2 and :C1 are concepts; (iii) if r is a
role, and C is a concept, then 9r:C, 8r:C are concepts. A concept inclusion is
an expression of form C1 v C2, where C1; C2 are concepts. A role inclusion is
an expression of form r1 v r2, where r1; r2 are roles. A TBox T is a nite set of
(concept and role) inclusions. An ABox A is a nite set of assertions of the forms
A(a) and p(a; b), where fa; bg NI, A 2 NC, and p 2 NR. A knowledge base (KB)
is a tuple K = (T ; A), where T is a TBox and A is an ABox.</p>
        <p>
          An interpretation is a pair I = h I ; I i, where I is a non-empty set (called
the domain), AI I for each A 2 NC, rI I I for each r 2 NR, and
aI 2 I for each a 2 NI. The function I is extended to the remaining concepts
and roles in the standard way [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. An interpretation I satis es an inclusion
q1 v q2, if q1I q2I , in symbols I j= q1 v q2; and it satis es an assertion q(a) if
(a)I 2 qI , in symbols, I j= q(a). For a TBox or ABox, we write I j= if
I j= for all 2 . For a KB K = (T ; A), we write I j= K if the following
hold: (i) a 2 I and aI = a for each a 2 NI occurring in K,1 (ii) I j= T , and
(iii) I j= A. For an assertion , we write K j= if I j= for all I with I j= K.
Instance Queries An (ontology mediated) instance query is a tuple Q = (T ; q),
where T is a TBox, and q 2 NC [ NR. Let a 2 NI in case q 2 NC, and a 2 N2
I
otherwise. Then a is a certain answer to Q over an ABox A if (T ; A) j= q(a). To
ease presentation, we assume that every concept and role of A also occurs in T .
Normal Form Our results apply to arbitrary TBoxes, but to simplify
presentation, we consider TBoxes in normal form where inclusions take one of the
following forms:
(N1) A1 u
(N2) A v 9r:A0
u An v An+1 t
t Ak
(N3) A v 8r:A0
(N4) r v s
with r; s roles, fA1; : : : ; Akg NC, and fA; A0g NC. We also assume that T is
closed under role inclusions as follows: (a) p v p 2 T , for each p 2 NR occurring
in T , (b) if r v s 2 T , then r v s 2 T , and (c) if r1 v r2 2 T and r2 v r3 2 T ,
then r1 v r3 2 T . For a TBox, ABox, or KB, we denote by NI( ), NR( ),
NC( ) the set of individuals, role and concept names that occur in , resp.
Disjunctive Datalog We assume countably in nite sets NP and NV of predicate
symbols (each with an associated arity) and variables, respectively. We further
assume that NC [ NR NP with each A 2 NC being unary, and each r 2 NR being
binary. An atom is an expression of the form R(t1; : : : ; tn), where ft1; : : : ; tng
NI [ NV, and R is an n-ary relation symbol. A rule is an expression of the
form h1 _ : : : _ hn b1; : : : ; bk, where H = fh1; : : : ; hng and B = fb1; : : : ; bkg
are sets of atoms, called the head and the body of , respectively. Each variable
that occurs in H must also occur in B. Rules of the form h (known as facts)
are simply identi ed with the atom h, thus ABox assertions are valid facts
in our syntax. For a role name p, we may use p (t1; t2) to denote the atom
p(t2; t1). A program is any nite set P of rules. We use ground(P ) to denote the
grounding of P , i.e. the variable-free program that is obtained from P by applying
on its rules all the possible substitutions of variables by individuals of P . An
(Herbrand) interpretation (or, database) I is any nite set of variable-free (or,
ground ) atoms. An interpretation I is a model of a program P if fb1; : : : ; bkg I
implies I \ fh1; : : : ; hng 6= ; for all rules h1 _ : : : _ hn b1; : : : ; bk in ground(P ).
A ( Datalog) query is a pair (P; q), where P is a program, and q is a predicate
1 This is called the standard name assumption (SNA), which we apply to the individuals
occurring in K.
symbol from P . A tuple a of constants is a certain answer to (P; q) over a
database I if q(a) 2 J for all models J of P [ I.
3
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Characterization of Counter Models</title>
      <p>Assume a KB K = (T ; A) and an assertion . Towards deciding K 6j=
polynomially sized program, we decompose the problem into two steps:
using a
(1) Guess a core interpretation Ic for K, whose domain is NI(A). Core
interpretations x how the individuals of K participate in concepts and roles, ensuring
the satisfaction of A, and the non-entailment of .
(2) Check that Ic can be extended to satisfy all axioms in T .</p>
      <p>De ning Datalog rules that do (1) is not hard, but (2) is more challenging, and
will rely on a game-theoretic characterization we describe below. But rst we
need to de ne core interpretations.</p>
      <p>De nition 1. A core interpretation for a KB K = (T ; A) is any interpretation
Ic such that
(c1) Ic = NI(A) and aIc = a for all a 2 NI(A),
(c2) Ic j= A,
(c3) Ic j= A v 8r:A0 for all A v 8r:A0 2 T ,
(c4) Ic j= r v s for all r v s 2 T ,
(c5) qIc = ; for each q 62 NC(T ) [ NR(T ).</p>
      <p>An interpretation J is called an extension of Ic, if Ic is the result of restricting
J to NI(A).</p>
      <p>A core and its extensions coincide on the assertions they entail, and deciding
non-entailment of an instance query q amounts to deciding whether there is a
core that does not entail q, and that can be extended into a model. But verifying
whether a core can be extended into a full model is hard: it corresponds to testing
consistency (of Ic viewed as an ABox) with respect to T , an ExpTime-hard
problem already for fragments of ALCHI. In order to obtain a polynomial set
of rules that solves this ExpTime-hard problem, we characterize it as a game,
revealing a simple algorithm that admits an elegant implementation in Datalog.
De nition 2. A type (over a TBox T ) is a subset of NC(T ) [ f&gt;g such that
? 62 and &gt; 2 . We say that satis es an inclusion = A1 u u An v An+1 t
t Ak of type (N1), if fA1; : : : ; Ang implies fAn+1; : : : ; Akg \ 6= ;;
otherwise violates . For an element e 2 I in an interpretation I, we let
type(e; I) = fB 2 NC j e 2 BI g. A type is realized in I if there is some e 2 I
s.t. type(e; I) = .</p>
      <p>We now describe a game to decide whether a given core Ic can be extended
into a model of a KB K. The game is played by Bob (the builder), who wants
to extend Ic into a model, and Sam (the spoiler), who wants to spoil all Bob's
attempts. Sam starts by picking an individual a, and they look at its type
type(a; Ic). If it doesn't satisfy the inclusions of type (N1) Sam wins. Otherwise,
in each turn Sam chooses an inclusion of the form A v 9rA0 which would need to
be satis ed by (an element with) the current type, forcing Bob to pick a type for
the corresponding r-successor that satis es A0. The game continues for as long
as Bob can respond to the challenges of Sam.</p>
      <p>The game on I starts by Sam choosing an individual a 2 I , and =
type(a; I) is set to be the current type. Then:
( ) If does not satisfy all inclusions of type (N1) in T , then Sam is declared
the winner. Otherwise, Sam chooses an inclusion A v 9r:A0 2 T with A 2 ;
if there is no such inclusion, Bob is declared the winner. Otherwise, Bob
chooses a new type 0 such that:
(C1) A0 2 0, and
(C2) for all inclusions A1 v 8s:A2 2 T :
if r v s 2 T and A1 2 then A2 2 0,
if r v s 2 T and A1 2 0 then A2 2 .</p>
      <p>0 is set to be the current type, and the game continues with a new round,
i.e. we go back to .</p>
      <p>A run of the game on I is a (possibly in nite) sequence
where a is the individual picked initially by Sam, and each i and i are the
inclusion picked by Sam and the type picked by Bob in round i, respectively. A
strategy for Bob is a partial function str that maps pairs of a type and an
inclusion A v 9r:A0 with A 2 to a type 0 that satis es (C1) and (C2); intuitively,
it gives a move for Bob in response to moves of Sam. A run a 1 1 2 2 : : : with
type(a; I) = 0 follows a strategy str if i = str( i 1; i) for every i 1.</p>
      <p>For a nite run w, we let tail(w) = type(a; I) if w = a, and tail(w) = ` if
w = a : : : ` ` with ` 1. The strategy str is called non-losing on I if for every
nite run w that follows str, tail(w) satis es all inclusions of type (N1) in T ,
and str(tail(w); A v 9r:A0) is de ned for every A v 9r:A0 2 T with A 2 tail(w).
Theorem 1. Assume a KB K and an assertion . Then K 6j=
core interpretation Ic for K such that:
(1) Ic 6j= , and
(2) there is a non-losing strategy for Bob on Ic.
i there is a
Proof. (Sketch.) We focus on showing that there is a non-losing strategy str for
Bob on Ic i there exists an extension J of Ic s.t. J j= K. The claim follows
from this, and the easy claim that extensions preserve non-entailment of .</p>
      <p>For the \)" direction, from an arbitrary non-losing str for Ic, we build J as
follows. We denote by frn(Ic; str) the set of all nite runs a 1 1 : : : i i, i 0
that follow str. The domain of J is:</p>
      <p>J = frn(Ic; str)
and for each a 2 NI, each A 2 NC, and each p 2 NR we let:
aJ = aIc</p>
      <p>AJ = fw j A 2 tail(w)g
pJ = pIc [ f(w; w i i) j ri v p 2 T g [</p>
      <p>f(w i i; w) j ri v p 2 T g
where i = A v 9ri:A0 2 T and fw; w i ig J .</p>
      <p>It is not hard to see that J is an extension of Ic. We show that J is a model
of K. First, J j= A by de nition of Ic and the fact that J is an extension of
Ic. It is left to prove that J satis es all inclusions in T . Note that for each
w 2 J , type(w; J ) = tail(w). That J satis es all inclusions of type (N1) holds
by de nition of non-losing str and the fact that tail(w) satis es all such inclusions.
For the inclusions = A v 9r:A0 of type (N2), we see that for each w 2 J ,
if w 2 AJ , then A 2 tail(w) and w is a run that follows str. Hence, since str is
a non-losing strategy str(tail(w); ) is de ned, that is there exists a 0 over T
such that str(tail(w); ) = 0 and A0 2 0. Thus w 0 is a run that follows str,
i.e. w 0 2 frn(Ic; str), so w 0 is in A0J and (w; w 0) 2 rJ if r is a role name,
and (w 0; w) 2 rJ otherwise. For the inclusions A1 v 8r:A2 of type (N3), we
distinguish the case of (a; a0) 2 rIc for a pair a; a0 of individuals in Ic , for which
a 2 A1J implies a0 2 A2J holds by de nition of Ic, and the case of an arbitrary
pair of objects (w; w0) 2 rIc where w0 is a child of w (that is, w0 is of the form
w i i), or vice-versa, for which w0 2 AJ whenever w 2 A1J is ensured by the
2
condition (C2) in the de nition of the game, the fact that str is a non-losing
strategy, and the construction of J . Finally, the inclusions of type (N4) are also
guaranteed by the de nition of the core Ic for pairs of individual names, and by
the condition (C2) in the de nition of the game for arbitrary pairs of an object
and its child.</p>
      <p>For \(", assume an arbitrary model J of K that is an extension of Ic. We can
extract from it a non-losing strategy for Bob as follows. First, let T be a the set of
all the types realized in J , and observe that each type in T satis es all inclusions
of type (N1) and that for all a 2 NI(A), type(a; J ) 2 T . Then it su ces to set,
for each 2 T and each A v 9r:A0 2 T with A 2 , str( ; A v 9r:A0) = 0 for an
arbitrarily chosen 0 2 T that satis es (C1) and (C2), which exists because J is a
model, hence it satis es all existential and universal inclusions in T , and all types
realized in J are contained in T . This str is a non-losing strategy for Bob. tu</p>
      <p>To decide whether Bob has a non-losing strategy on a given core we use the
type elimination procedure Mark in Algorithm 1, which marks (or, eliminates )
all types from which Sam has a winning strategy. It takes as input the TBox T ,
and an interpretation I which intuitively is the core being checked. The algorithm
starts by building the set N of all possible types over T , and then it eliminates
bad choices (from which Bob would loose) by marking them. In step (MN1), the
algorithm marks in N all types that violate some inclusion of type (N1) in T ;
Sam wins already in the rst round on these types. Then, in the loop, (M9)
exhaustively marks types that allow Sam to pick an inclusion A v 9r:A0 for</p>
      <sec id="sec-3-1">
        <title>Algorithm 1: Mark</title>
        <p>input : TBox T , interpretation I
output : Set of (possibly marked) types
N</p>
        <p>f j is a type over T g
(MN1) Mark each</p>
        <p>2 N that violates some inclusion of the form (N1) in T
repeat
(M9) Mark each 2 N such that A v 9r:A0 2 T , A 2 , and for each 0 2 N ,
at least one the following holds:
(C0)</p>
        <p>0 is marked,
(C10) A0 2= 0, or
(C20) there exists A1 v 8s:A2 2 T with
{ r v s 2 T and A1 2
{ r v s 2 T and A1 2 0 and A2 2=</p>
        <p>and A2 2= 0, or
until no new type is marked
return N
which Bob cannot reply with any 0. At the end the marked types, are those
from which Bob can lose, so we get:
Theorem 2. Let Ic be a core interpretation. Then Bob has a non-losing strategy
on Ic i none of the types realized in Ic is marked by Mark(T ; Ic).
Proof. (Sketch.) For the \)" direction, we can show (by induction in the number
of iterations of Mark(T ; Ic)) that if a type is marked, then it cannot occur in a
non-losing str for Bob. For the \(" direction, a non-losing str for Ic is obtained
by taking all unmarked 2 N , and for each of them, and each A v 9r:A0 2 T
with A 2 , setting str( ; A v 9r:A0) = 0 for an arbitrary unmarked 0 that
satis es (C1) and (C2).
tu
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Translation into Datalog</title>
      <p>Assume an instance query (T ; q). We build next a polynomially sized program
P such that the queries (T ; q) and (P; q) have the same certain answers for all
ABoxes over the signature of T . Roughly, the program P has 3 major components:
(a) rules to non-deterministically generate a core interpretation Ic for the KB
(T ; A), where A is an input ABox; (b) rules that implement the type elimination
algorithm presented in the previous section; (c) rules that glue (a) and (b) together,
ensuring that all types that occur in Ic are not marked by the marking procedure.
We remark that the construction of P is independent from any particular ABox.
(I) Collecting the individuals We rst add rules to collect in the unary
predicate ind all the individuals that occur in the input ABox. For each A 2 NC(T ),
r 2 NR(T ), we have:
ind(x)</p>
      <p>A(x)
r(x; y)
ind(y)
r(x; y)
(II) Generating core interpretations For each A 2 NC(T ) (resp., r 2
NR(T )) we will use a fresh concept name A (resp., role name r). We add the
following rules to P :</p>
      <p>A(x) _ A(x)
r(x; y) _ r(x; y)
ind(x)
A(x); A(x)
ind(x); ind(y)
r(x; y); r(x; y)</p>
      <p>A 2 NC(T )
A 2 NC(T )
r 2 NR(T )
r 2 NR(T )
To ensure (c3) in De nition 1, for each A v 8r:A0 2 T we add the rule
A0(y) A(x); r(x; y). Then, to ensure (c4), for each role inclusion r v s 2 T
we add the rule s(x; y) r(x; y).</p>
      <p>Intuitively, the stable models of the above rules generate the di erent core
interpretations Ic of the KB K = (T ; A) for any given A.</p>
      <p>
        We next implement the algorithm Mark from Section 3. To obtain a
polynomially sized program, we need to use non-ground rules whose number of
variables depends on the number of di erent concept names in T . Assume an
arbitrary enumeration A1; : : : ; Ak of NC(T ). Assume also a pair 0; 1 of special
individuals. Intuitively, we will use a k-ary relation Type = f0; 1gk to store the
set of all types over T . Naturally, a k-tuple (a1; : : : ; ak) 2 Type encodes the type
= fAi j ai = 1; 1 i kg [ f&gt;g. We are most interested in computing a
k-ary relation Marked f0; 1gk that contains precisely the types marked by the
Mark algorithm. We next de ne the rules to compute Type and Marked, and
other relevant relations.
(III) A linear order over types The rst ingredient is a linear order over
all possible types. To this end, for every 1 i k, we inductively de ne i-ary
relations rsti and lasti, and a 2i-ary relation nexti, which will provide the rst,
the last and the successor elements from a linear order on f0; 1gi. In particular,
given u; v 2 f0; 1gi, the fact nexti(u; v) will be true if v follows u in the ordering
of f0; 1gi. The rules to populate nexti are quite standard (see, e.g., Theorem 4.5
in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]). For the case i = 1, we simply add the following facts:
rst1(0)
last1(1)
next1(0; 1)
Then, for all 1
i
k
      </p>
      <p>1 we add the following rules:
nexti+1(0; x; 0; y)
nexti+1(1; x; 1; y)
nexti+1(0; x; 1; y)
rsti+1(0; x)
lasti+1(1; x)
nexti(x; y)
nexti(x; y)
lasti(x); rsti(y)</p>
      <p>rsti(x)
lasti(x)
We can now collect in the k-ary relation Type all types over T (thus computing
the set N of the Mark algorithm):</p>
      <p>Type(x)
rstk(x)
(IV) Implementing Step (MN1) First, we add the auxiliary facts F(0) and
T(1) to P . For a k-tuple of variables x, we let B 2 x denote the atom T (xj),
where j is the index of B in the enumeration of NC(T ). Similarly, we let B 62 x
denote the atom F (xj), where j is the index of B in the enumeration. Then the
step (MN1), which marks types violating inclusions of type (N1), is implemented
using the following rule for every inclusion A1 u u An v A01 t t A0m of T :
Marked(x)</p>
      <p>Type(x); A1 2 x; : : : ; An 2 x; A01 62 x; : : : ; A0m 62 x
(V) Implementing Step (M9) The following rules are added for each
inclusion = A v 9r:A0 2 T . Recall that we need to mark a type if A 2 , and for
each type 0 at least one of (C0), (C10) or (C20) holds. We rst use an auxiliary
(2k + 1) relation MarkedOne to collect all such types 0.</p>
      <p>Assume a fresh individual a . For collecting each 0 that satis es (C0), we
add:</p>
      <p>MarkedOne(x; a ; y)</p>
      <p>Type(x); Marked(y)</p>
      <sec id="sec-4-1">
        <title>For the condition (C10), we add the rule:</title>
        <p>MarkedOne(x; a ; y)</p>
        <p>Type(x); Type(y); A0 62 y</p>
        <p>The rules for (C20) are as follows. For all inclusions A1 v 8r:A2 2 T with
r v s 2 T , we add the rule</p>
        <p>MarkedOne(x; a ; y)</p>
        <p>Type(x); Type(y); A1 2 x; A2 62 y
For all A1 v 8r:A2 2 T with r v s 2 T , we also add</p>
        <p>MarkedOne(x; a ; y)</p>
        <p>Type(x); Type(y); A1 2 y; A2 62 x</p>
        <p>We infer Marked(t) in case MarkedOne(t; a ; v) is true for all types (bit
vectors) v. To this end, we need another (2k + 1)-ary relation MarkedUntil. We
add:</p>
        <p>MarkedUntil(x; a ; z)
MarkedUntil(x; a ; u)</p>
        <p>MarkedOne(x; a ; z); rstk(z)
MarkedUntil(x; a ; z); nextk(z; u);</p>
        <p>MarkedOne(x; a ; u)</p>
        <p>Intuitively, with the above rules we traverse all types checking the conditions
(C0), (C10), (C20) described in (M9). If we manage to reach the last type, we
know the condition is satis ed. We add the following rule:</p>
        <p>Marked(x)</p>
        <p>MarkedUntil(x; a ; z); A 2 x; lastk(z)
(VI) Forbidding marked types in the core We need to forbid each
individual in the generated core interpretation from having a type from Marked. For
all 0 i k, we take a fresh (i + 1)-ary relation symbol Proji. We rst add:
Projk(x; y)</p>
        <p>ind(x); Marked(y)
We will now project away bits from the Proji relations by looking at the actual
types of individuals. For all 1 i k we have the following rules:
Proji 1(x; y)
Proji 1(x; y)</p>
        <p>Proji(x; y; 1); Ai(x)</p>
        <p>Proji(x; y; 0); Ai(x)
Intuitively, Proji 1(a; b1; : : : ; bi 1) says the partial type given by the bit values
b1; : : : ; bi 1 can be extended to a marked type by choosing additional concepts
according to the actual type of the individual a. Thus the fact Proj0(a) represent
the situation where a has a marked type. Such situations are ruled out by adding
the constraint:</p>
        <p>Proj0(x)</p>
        <p>This concludes the translation of the instance query (T ; q), where T is an
ALCHI TBox, into the disjunctive Datalog program P . This construction,
together with Theorems 1 and 2, yields the main result of this paper.
Theorem 3. For an instance query (T ; q), we can build in polynomial time a
Datalog query (P; q) such that the certain answers to (T ; q) and (P; q) coincide
for any given ABox A over the signature of T .</p>
        <p>
          The above encoding employs disjunctive programs. Entailment of ground
atoms in such programs is coNExpTime-complete [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], which does not match the
ExpTime-completeness of satis ability of ALCHI KBs. However, we employ
disjunction in a limited way, and thus our programs fall into a class of programs
that can be evaluated in (deterministic) exponential time. In particular, the
above program P can be partitioned into two programs P1; P2 as follows: P1
consists of all rules in (I) and (II), and P2 consists of the remaining rules. Observe
that P1 is a disjunctive program with at most two variables in each rule, while
P2 is is disjunction-free. Note also that P2 does not de ne any relations used
in P1, i.e. none of the relation symbols of P1 occurs in the head of a rule in P2.
Assume a set F of facts over the signature of P1. Due to the above properties,
the successful runs of the following non-deterministic procedure generate the set
of all minimal models of P [ F :
(S1) Compute a minimal model I1 of P1 [ F . If I1 does not exist due to a
constraint violation, then return failure.
(S2) Compute the least model I2 of P2 [ I1. Again, if I2 does not exist due to a
constraint violation, then return failure. Otherwise, output I2.
        </p>
        <p>Since P1 has at most two-variables in every rule, each minimal model I1 of
P1 [ F is of polynomial size in the size of P1 [ F , and the set of all such models
can be traversed in polynomial space. For a given I1, performing the step (S2)
is feasible in (deterministic) exponential time, because P2 is disjunction-free
and of polynomial size in the size of the original instance query. It follows that
computing the certain answers to (P; q) for any given ABox A over the signature
of T requires single exponential time.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Discussion</title>
      <p>
        We have presented our results for ALCHI, but they also apply to SHI, its
extension with transitivity axioms; it is well known that instance queries mediated
by SHI TBoxes can be rewritten in polynomial time to instance queries mediated
by ALCHI TBoxes (see, e.g., [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ]). Moreover, we have presented the translation
for instance queries, but the results can be easily generalized, e.g., to DL-safe
rules of [22], or the quanti er-free conjunctive queries like in [21]. These queries
are syntactically restricted to ensure that the relevant variable assignments only
map into individuals of the input ABox. We note that generalizing our translation
to arbitrary conjunctive queries while remaining polynomial is not possible under
common assumptions in complexity theory. Indeed, cautious inference from a
disjunctive program is in coNExpTime, but entailment of (Boolean) conjunctive
queries is 2ExpTime-hard already for the DL ALCI [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ].
      </p>
      <p>
        As mentioned in the introduction, both the game theoretic characterization
and the Datalog translation can be extended to ontologies in ALCHOI, the
extension of ALCHI with nominals. This is possible even in the presence of
the so-called closed predicates, which are useful for combining complete and
incomplete knowledge, by explicitly specifying predicates assumed complete, thus
given a closed-world semantics [
        <xref ref-type="bibr" rid="ref10 ref20">10, 20</xref>
        ]. For example, take the following TBox T :
BScStud v Student Student v 9attends:Course
      </p>
      <p>BScStud v 8attends::GradCourse
and the ABox A:</p>
      <p>Course(c1), Course(c2), GradCourse(c2), BScStud(a)
Then (a; c1) is not a certain answer to (T ; q) with q = attends(x; y). But if c1 and
c2 are known to be the only courses, then (a; c1) should be a certain answer. This
can be achieved by declaring Course a closed predicate: (a; c1) is indeed a certain
answer to the OMQ with closed predicates (T ; ; q), where = fCourseg.</p>
      <p>
        Interestingly, OMQs with closed predicates are non-monotonic. Indeed, (a; c1)
is a certain answer to (T ; ; q) over A, but it is not a certain answer over
the extended set of facts A0 = A [ fCourse(c3)g. For this reason, these queries
cannot be rewritten into monotonic variants of Datalog, like positive Datalog
with disjunction as considered here. However, one can devise a polynomial time
translation into disjunctive Datalog with negation as failure, for OMQs of the
form (T ; ; q) where T is an ALCHOI TBox, is a set of closed predicates, and
q is an instance query. The translation uses the same ideas presented here, but
handling closed predicates (both in the game-theoretic characterization, and in the
Datalog translation) implies reasoning about the types that are already realized
in the core; in Datalog, this requires negation. Details can be found in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
      <sec id="sec-5-1">
        <title>Acknowledgements</title>
        <p>This work was supported by the Austrian Science Fund (FWF): projects
P25207N23, T515 and W1255-N23.
21. C. Lutz, I. Seylan, and F. Wolter. Ontology-mediated queries with closed predicates.</p>
        <p>In Proc. of IJCAI 2015. IJCAI/AAAI, 2015.
22. B. Motik, U. Sattler, and R. Studer. Query answering for OWL-DL with rules. J.</p>
        <p>Web Sem., 3(1):41{60, 2005.
23. M. Ortiz, S. Rudolph, and M. Simkus. Worst-case optimal reasoning for the</p>
        <p>Horn-DL fragments of OWL 1 and 2. In Proc. of KR 2010. AAAI Press, 2010.
24. H. Perez-Urbina, B. Motik, and I. Horrocks. Tractable query answering and
rewriting under description logic constraints. J. Applied Logic, 8(2):186{209, 2010.
25. D. Trivela, G. Stoilos, A. Chortaras, and G. B. Stamou. Optimising resolution-based
rewriting algorithms for OWL ontologies. J. Web Sem., 33:30{49, 2015.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>S.</given-names>
            <surname>Ahmetaj</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ortiz</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Simkus</surname>
          </string-name>
          .
          <article-title>Polynomial datalog rewritings for expressive description logics with closed predicates</article-title>
          .
          <source>In Proc. of IJCAI'16</source>
          ,
          <year>2016</year>
          . To appear.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>F.</given-names>
            <surname>Baader</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Calvanese</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>McGuinness</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Nardi</surname>
          </string-name>
          , and P. Patel-Schneider, editors.
          <source>The Description Logic Handbook: Theory</source>
          , Implementation, and
          <string-name>
            <surname>Applications</surname>
          </string-name>
          . Cambridge University Press, second edition,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>M.</given-names>
            <surname>Bienvenu</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Ortiz</surname>
          </string-name>
          .
          <article-title>Ontology-mediated query answering with data-tractable description logics</article-title>
          .
          <source>In Proc. of RW</source>
          <year>2015</year>
          , pages
          <fpage>218</fpage>
          {
          <fpage>307</fpage>
          . Springer,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>M.</given-names>
            <surname>Bienvenu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            ten
            <surname>Cate</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Lutz</surname>
          </string-name>
          , and
          <string-name>
            <given-names>F.</given-names>
            <surname>Wolter</surname>
          </string-name>
          .
          <article-title>Ontology-based data access: A study through disjunctive Datalog, CSP, and MMSNP</article-title>
          .
          <source>ACM Trans. Database Syst</source>
          .,
          <volume>39</volume>
          (
          <issue>4</issue>
          ):
          <volume>33</volume>
          :1{
          <fpage>33</fpage>
          :
          <fpage>44</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>D.</given-names>
            <surname>Calvanese</surname>
          </string-name>
          , G. De Giacomo,
          <string-name>
            <given-names>D.</given-names>
            <surname>Lembo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Lenzerini</surname>
          </string-name>
          , and
          <string-name>
            <given-names>R.</given-names>
            <surname>Rosati</surname>
          </string-name>
          .
          <article-title>Tractable reasoning and e cient query answering in description logics: The DL-Lite family</article-title>
          .
          <source>J. Autom. Reasoning</source>
          ,
          <volume>39</volume>
          (
          <issue>3</issue>
          ):
          <volume>385</volume>
          {
          <fpage>429</fpage>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>E.</given-names>
            <surname>Dantsin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          ,
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Gottlob, and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Voronkov</surname>
          </string-name>
          .
          <article-title>Complexity and expressive power of logic programming</article-title>
          .
          <source>ACM Comput. Surv.</source>
          ,
          <volume>33</volume>
          (
          <issue>3</issue>
          ):
          <volume>374</volume>
          {
          <fpage>425</fpage>
          ,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          , G. Gottlob, and
          <string-name>
            <given-names>H.</given-names>
            <surname>Mannila</surname>
          </string-name>
          .
          <article-title>Disjunctive datalog</article-title>
          .
          <source>ACM Trans. Database Syst</source>
          .,
          <volume>22</volume>
          (
          <issue>3</issue>
          ):
          <volume>364</volume>
          {
          <fpage>418</fpage>
          ,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ortiz</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Simkus</surname>
          </string-name>
          .
          <article-title>Conjunctive query answering in the description logic SH using knots</article-title>
          .
          <source>J. Comput. Syst. Sci.</source>
          ,
          <volume>78</volume>
          (
          <issue>1</issue>
          ):
          <volume>47</volume>
          {
          <fpage>85</fpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ortiz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Simkus</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Tran</surname>
          </string-name>
          , and
          <string-name>
            <given-names>G.</given-names>
            <surname>Xiao</surname>
          </string-name>
          .
          <article-title>Query rewriting for Horn-SHIQ plus rules</article-title>
          .
          <source>In Proc. of AAAI</source>
          <year>2012</year>
          . AAAI Press,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10. E. Franconi,
          <string-name>
            <given-names>Y. A.</given-names>
            <surname>Iban</surname>
          </string-name>
          <article-title>~ez-Garc a, and I. Seylan. Query answering with DBoxes is hard</article-title>
          .
          <source>Electr. Notes Theor. Comput. Sci.</source>
          ,
          <volume>278</volume>
          :
          <fpage>71</fpage>
          {
          <fpage>84</fpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11. G. Gottlob,
          <string-name>
            <given-names>S.</given-names>
            <surname>Kikot</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Kontchakov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V. V.</given-names>
            <surname>Podolskii</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Schwentick</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          .
          <article-title>The price of query rewriting in ontology-based data access</article-title>
          .
          <source>Artif</source>
          . Intell.,
          <volume>213</volume>
          :
          <fpage>42</fpage>
          {
          <fpage>59</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12. G. Gottlob,
          <string-name>
            <given-names>M.</given-names>
            <surname>Manna</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          .
          <article-title>Polynomial combined rewritings for existential rules</article-title>
          .
          <source>In Proc. of KR</source>
          <year>2014</year>
          . AAAI Press,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13. G. Gottlob,
          <string-name>
            <given-names>M.</given-names>
            <surname>Manna</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          .
          <article-title>Polynomial rewritings for linear existential rules</article-title>
          .
          <source>In Proc. of IJCAI</source>
          <year>2015</year>
          . AAAI Press,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14. G. Gottlob and
          <string-name>
            <given-names>T.</given-names>
            <surname>Schwentick</surname>
          </string-name>
          .
          <article-title>Rewriting ontological queries into small nonrecursive datalog programs</article-title>
          .
          <source>In Proc. of KR</source>
          <year>2012</year>
          . AAAI Press,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15. U. Hustadt,
          <string-name>
            <given-names>B.</given-names>
            <surname>Motik</surname>
          </string-name>
          , and
          <string-name>
            <given-names>U.</given-names>
            <surname>Sattler</surname>
          </string-name>
          .
          <article-title>Reasoning in description logics by a reduction to disjunctive datalog</article-title>
          .
          <source>J. Autom. Reasoning</source>
          ,
          <volume>39</volume>
          (
          <issue>3</issue>
          ):
          <volume>351</volume>
          {
          <fpage>384</fpage>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>M. Kaminski</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          <string-name>
            <surname>Nenov</surname>
            , and
            <given-names>B. C.</given-names>
          </string-name>
          <string-name>
            <surname>Grau</surname>
          </string-name>
          .
          <article-title>Computing datalog rewritings for disjunctive datalog programs and description logic ontologies</article-title>
          .
          <source>In Proc. of RR</source>
          <year>2014</year>
          , pages
          <fpage>76</fpage>
          {
          <fpage>91</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <surname>M. Kaminski</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          <string-name>
            <surname>Nenov</surname>
            , and
            <given-names>B. C.</given-names>
          </string-name>
          <string-name>
            <surname>Grau</surname>
          </string-name>
          .
          <article-title>Datalog rewritability of disjunctive datalog programs and its applications to ontology reasoning</article-title>
          .
          <source>In Proc. of AAAI</source>
          <year>2014</year>
          , pages
          <fpage>1077</fpage>
          {
          <fpage>1083</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <given-names>R.</given-names>
            <surname>Kontchakov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Lutz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Toman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Wolter</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Zakharyaschev</surname>
          </string-name>
          .
          <article-title>The combined approach to ontology-based data access</article-title>
          .
          <source>In Proc. of IJCAI 2011. IJCAI/AAAI</source>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <given-names>C.</given-names>
            <surname>Lutz</surname>
          </string-name>
          .
          <article-title>Inverse roles make conjunctive queries hard</article-title>
          .
          <source>In Proc. of DL</source>
          <year>2007</year>
          .
          <article-title>CEURWS</article-title>
          .org,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          20.
          <string-name>
            <surname>C. Lutz</surname>
            ,
            <given-names>I. Seylan</given-names>
          </string-name>
          , and
          <string-name>
            <given-names>F.</given-names>
            <surname>Wolter</surname>
          </string-name>
          .
          <article-title>Ontology-based data access with closed predicates is inherently intractable(sometimes)</article-title>
          .
          <source>In Proc. of IJCAI 2013. IJCAI/AAAI</source>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>