Sei sulla pagina 1di 7

Answering Counting Aggregate Queries over Ontologies of DL-Lite Family

(Proofs)
ID number: 318
Copyright c 2013, Association for the Advancement of Articial
Intelligence (www.aaai.org). All rights reserved.
Proof (Lem.5, full version). For completeness we show the full reduction hinted in the body of the paper.
Let A, B and E, P be atomic concepts and roles. Let T = A _ P, P

_ B and q(Count()) = y
1
. . . y
4
B(y
1
)
E(y
2
, y
3
) P(y
2
, y
4
) P(y
3
, y
4
).
Consider the complement of the NP-complete 3-colouring problem with an undirected graph ((1, c) as input and positive
output iff the graph has no 3-colouring.
Let D = 1 r, g, b, a. Let / contain E(u, v) and E(v, u) for each (u, v) c, A(v) for each v 1, B(c) for each
c r, g, b, and E(a, a), P(a, r).
Note that, from the construction of q, we have that the count is at least 3 in every interpretation of the knowledge base /. In
other words, every interpretation J for / is such that J [= q(t

, 3). This is because of the assertions in /.


We now show that 4Cert(q, t

, /) iff ((1, c) has no 3-colouring.


(): Assume that ( has no 3-coloring, and assume for the sake of contradiction that 4 / Cert(q, t

, /). This means that


there exists an interpretation J for / such that J [= q(t

, 3) (we know from our observation above that the count cannot be any
number less than 3).
Since conjunctive queries are monotone, it is safe to assume the following: For every element v 1, there is a single pair of
form (v, e) in P
I
, for some element e D
I
.
Let us now dene the following coloring : 1 red, green, blue for the nodes of (: For each node v 1, we have that
(v) = red iff J [= P(v, r);
(v) = green iff J [= P(v, g) and
(v) = blue iff J [= P(v, b);
All that is left to do is to show that is indeed a proper 3-coloring, which results in a contradiction.
First, we show that assigns a color to each node in _. For the sake of contradiction, assume the contrary. Then there must
be a node v such that P
I
does not contain any of (v, r), (v, g), (v, b). Since we know that A(v) must hold in J, and since
A _ P, it follows that there is an element e distinct from r, g and b and such that P(v, e) holds in J. But then B(e) holds
since P

_ B. We can then construct a fourth evaluation h from the core of q to D


I
: h(y
1
) = e, h(y
2
) = h(y
3
) = a and
h(y
4
) = r. This contradicts the fact that J [= q(t

, 3).
Next we show that is indeed a correct coloring. Assume for the sake of contradiction that this is not the case. Then there
is an edge (u, v) c such that (u) = (v). Let us assume without loss of generality that colors both nodes u and v as red.
From the denition of , this means that the pairs (u, r) and (v, r) belong to P
I
. We can then construct a fourth evaluation h
from the core of q to D
I
: h(y
1
) = r, h(y
2
) = u, h(y
3
) = v and h(y
4
) = r. This contradicts the fact that J [= q(t

, 3).
We obtain that is a 3-coloring, which is a contradiction.
(): Assume that 4Cert(q, t

, /), and assume for the sake of contradiction that there is a 3-coloring for (.
We now show how to construct an interpretation J for / such that J [= q(t

, 3), which results in a contradiction.


Our interpretation J is as follows.
B
I
= r, b, c, A
I
= v [ v 1;
E
I
= (a, a) (u, v) [ (u, v) c or (v, u) c, and
P
I
= (v, r) [ v 1 and (v) = red (v, g) [ v 1 and (v) = green (v, b) [ v 1 and (v) = blue.
Clearly J is a valid interpretation for /. We know that there are 3 evaluations from the core of q to D
I
, resulting of mapping
y
1
to alternatively r, b or g, and y
2
, y
3
to a and y
4
to r. From the denition of B
I
and E
I
, any other evaluation must send y
2
and y
3
to some (u, v) such that (u, v) or (v, u) is an edge in (. But then this means that there is an element e r, b, g such
that both (u, e) and v, e) are in P
I
, and, therefore, that (u) = (v). This contradicts our initial assumption.
Proof using a connected query.
For readability, we have opted to use a non-connected query in our reduction. However, one can easily modify this reduction
so that the corresponding query is actually connected. One just extends the Knowledge base into /

= (/

, T

) so that it
now uses an extra concept G, add to T the assertions that say that every element that belongs to the interpretation of a role
A, B, E, P must also be in G, and use instead query q

(Count()) = y
1
. . . y
4
z
1
. . . z
4
B(y
1
) E(y
2
, y
3
) P(y
2
, y
4
)
P(y
3
, y
4
) G(y
1
, z
1
) G(y
2
, z
2
) G(y
3
, z
3
) G(y
4
, z
4
).
Clearly, q

is connected. The proof that 4 Cert(q

, t

, /

) iff ((1, c) has no 3-colouring goes along the same lines as the
proof shown above.
Proof (Lem.14, full version).
In this proof we will show that the problem DL-Lite
core
Cntd-ACQ ANSWERING is
p
2
-hard. This hardness is established by
a reduction from 3-SAT, which is the problem of verifying, given a Boolean formula in 3-CNF with variables partitioned
into tuples x and z, whether it is true that for every truth assignment of the variables x, there exists a truth assignment of the
variables z so that is satised with the overall assignment. This problem is well known to be
p
2
-complete.
Let be such a formula of the form xz

1k

k
, where each
k
(1 k ) is a clause containing exactly three
literals. We denote the variables of each
k
from x z by y
1
k
, y
2
k
and y
3
k
. Let also x = x
1
, . . . , x
n
and z = z
1
, . . . , z
m
. Based
on , we show how to construct in polynomial time a DL-Lite
core
knowledge base / = T , / and a boolean Cntd-ACQ q
such that 3 m(q, t

, /) (where t

is the empty tuple), if and only if for every truth assignment of the variables in x, there
exists a truth assignment of the variables in z so that is satised with the overall assignment.
Let us begin by dening the query. Consider roles R, V , S
1
, S
2
, S
3
and concepts C
1
k
, C
2
k
, C
3
k
for each 1 k . The
Cntd-ACQ is
q(Cntd(u)) :- x
1
x
n
z
1
z
m
c
1
c

v
x1
v
xn
v
z1
v
zm
s ,
where
= V (s, u)

1k

R(s, c
k
) S
1
(c
k
, v
y
1
k
) S
2
(c
k
, v
y
2
k
) S
3
(c
k
, v
y
3
k
) C
1
k
(y
1
k
) C
2
k
(y
2
k
) C
3
k
(y
3
k
)

V (x
1
, v
x1
) V (x
n
, v
xn
) V (z
1
, v
z1
) V (z
m
, v
zm
).
Next we dene the knowledge base / and start with the ABox /.
1. The active domain contains constants x
1
, . . . , x
n
, z
1
, . . . , z
m
, c
1
, . . . , c

, v
x1
, . . . , v
xn
, v
z1
, . . . , v
zm
, and s. The ABox /
contains assertions which are copies of all atoms of the formula , except V (s, u), in the way that every existential variable
a (except u) of q is frozen into the constant a.
2. The active domain contains constants 0 and 1. The ABox / contains the assertions V ( s, 0) and V ( s, 1).
3. The active domain contains constants x
1
, . . . , x
n
. For each 1 i n and 1 k the ABox / contains the assertion
R( x
i
, c
k
). For each 1 i n it also contains the assertion X
i
( x
i
), where X
i
is a new concept assigned to x
i
.
4. The active domain contains constants z
1
, . . . , z
m
. For each 1 j m the ABox / contains the assertions V ( z
j
, 0) and
V ( z
j
, 1).
5. For every 1 k the ABox / contains the assertions C
1
k
( y
1
k
), C
2
k
( y
2
k
) and C
3
k
( y
3
k
) where y
1
k
, y
2
k
and y
3
k
are the constants
among x
1
, . . . , x
n
, z
1
, . . . , z
m
such that y
1
k
, y
2
k
and y
3
k
are the variables of the clause
k
in the formula .
6. For each 1 k and 1 p 7 the active domain contains a constant c
p
k
. For each 1 k , let
1
, . . . ,
7
be
an enumeration of all satisfying assignments of the clause
k
, that uses variables y
1
k
, y
2
k
, y
3
k
. For each such assignment
p
,
1 p 7, the ABox / contains assertions S
1
( c
p
k
,
p
(y
1
k
)), S
2
( c
p
k
,
p
(y
2
k
)) and S
3
( c
p
k
,
p
(y
3
k
)). Here we abuse notation and
assume that
p
(y
i
k
), 1 i 3, evaluates to either the constant 0 or the constant 1.
7. The active domain contains constants d
1
and d
2
. The ABox /contains assertions V (d
1
, d
2
) and R(d
1
, c
p
k
) for each 1 k
and 1 p 7.
Finally, the TBox T contains the assertion X
i
_ V for each 1 i n.
Next we show that 3 Cert(q, t

, /), where t

is the empty tuple, holds if and only if for every truth assignment of the
variables x, there exists a truth assignment of the variables z so that is satised with the overall assignment.
(=): Let 3 Cert(q, t

, /), but assume for the sake of contradiction that there is a truth assignment
x
for the variables in
x such that is not satisable under any assignment for the variables in z.
Construct the following interpretation J for /:
1. The interpretation of all roles and concepts except for V corresponds precisely to /. That is, for each role R different from
V , we have that (a, b) R
I
if and only if R(a, b) is an assertion in /, and likewise for all concepts C.
2. For each 1 i n, the pair ( x
i
,
x
( x
i
)) belongs to V
I
. Note that here we abuse terminology once again, the value of each

x
( x
i
) is either the constant 1 or the constant 0 in the active domain.
It is clear that J is a model of /. From the assumption that 3 m(q, t, /) and the construction of J, it must be the case
that q(d
2
) holds in J (recall, that q is the core of the Cntd-ACQ q). From this fact it is possible to derive a contradiction as
follows. Let d be a constant in J such that q(d), q(0) and q(1) hold in J (we know from the construction of / that q(0) and
q(1) must already hold in all models of /). But again from the interpretation of V in J we know that d can only be the constant
d
2
, since the remainder of the pairs in V have either 0 or 1 in the second position. It follows that there must be a mapping
from the variables of to elements in J such that (1) the mapping sends the variable u to constant d
2
, and (2) q((u)) hold in
J. We can, however, determine more properties of from the construction of J and /. In fact, it follows that each variable x
i
,
1 i n, is indeed mapped by to the constant x
i
in J, and that v
xi
is mapped to the corresponding valuation of x
i
according
to
x
. It follows from the construction of that the following assignment
z
of the variables z in is such that
x
,
z
satisfy
:
z
assigns the value 1 to z
j
iff the variable v
zj
in is mapped to 1, according to .
(=): Assume that for every truth assignment of the variables x, there exists a truth assignment of the variables z so that each

k
is satised with the overall assignment, yet assume for the sake of contradiction that there is a model J of / such that only
q(1) and q(0) hold in J (those hold by the construction of /).
From the construction of /, it is not difcult to see that, for each pair ( x
i
, a) in V
I
it must be the case that a is either 1 or 0
(otherwise it violates the assumption previously mentioned, since this would give an extra witness for the variable u). Construct
the following valuation
x
for the variables in x. For each 1 i n,
x
(x
i
) = 1, if the pair ( x
i
, 1) is in V
I
, and
x
(x
i
) = 0
otherwise.
From the original assumption, there must be an assignment
z
of the variables in z such that
x
,
z
satisfy . We now show
that q(d
2
) must hold in J. To that extent, construct the following mapping from the variables in q to constants in J: maps
every variable x
1
, . . . , x
n
and z
1
, . . . , z
m
to the corresponding constants x
1
, . . . , x
n
and z
1
, . . . , z
m
in J, and maps each v
xi
(and v
zj
) to 1 if and only if
x
(and
z
) assigns the value 1 to x
i
(and z
j
). Moreover, for each clause
k
, it maps each variable
c
k
to the corresponding constant c
p
k
such that the p-th satisfying assignment for
k
is the one witnessed by
x
and
z
. It is then
clear that q(d
2
) hold in J, which violates our original assumption.
Proof (Lem.11).
The coNExpTime-hardness is established by a reduction from the satisability problem for the Bernays-Sch onnkel class
of boolean FO formulas, which is known to be NExpTime-complete (see, e.g., (B orger, Gr adel, and Gurevich 2001)), to the
complement of the counting problem. Formally, the Bernays-Sch onnkel class of boolean FO formulas is dened as the class
of all FO formulas of the form xy (x, y), where is quantier-free and does not contain function symbols and equalities.
Let xy (x, y) be such a formula in the Bernays-Sch onnkel class. Let also x = x
1
, . . . , x
n
and y = y
1
, . . . , y
m
. For
the sake of readability, we assume that mentions a single relation symbol P, of arity r. Later we explain how to modify the
proof to work with any arbitrary relational vocabulary. Finally, w.l.g. we assume that is not atomic and let
1
, . . . ,
p
be an
enumeration of all the sub-formulas of such that
1
, . . . ,
q
are all atomic sub-formulas of and
p
= .
Next we will show how to construct in polynomial time a DL-Lite
R
KB / = T , / and a boolean Count-ACQ q such that
2 Cert(q, t

, /) (where t

is the empty tuple) iff xy (x, y) is satisable, i.e. has a model. Along the proof we will use
the following property of this formula: either it is unsatisable, or it has a model with at most n elements (see, e.g. (B orger,
Gr adel, and Gurevich 2001)).
We start with the construction of the boolean Count-ACQ
q(Count()) :- s A
1
(s
1
) A
n
(s
n
) S(s
1
) TV
p
F
(s
2
, s
3
) C(s
3
)
p

=1

,
where s is the tuple of all variables in the query q, including the ones appearing below, and
- for each , 1 q, i.e. all such that the sub-formula

P(z
h1
, . . . , z
hr
) is atomic, we have that

R
0
(u

1
) R(u

1
, v

1,1
)

1
TV
R
(v

1,r
, v

1
) C(v

1
)
F
0
(u

1
) F(u

1
, w

1,1
)

1
TV

(w

1,m
, w

1
) U(w

1
)
R
0
(u

2
) R(u

2
, v

2,1
)

2
TV
R
(v

2,r
, v

2
) U(v

2
)
F
0
(u

2
) F(u

2
, w

2,1
)

2
TV

(w

2,m
, w

2
) C(w

2
),
where

j
, 1 j 2, contains
the atom R(v

j,k
, v

j,k+1
) for each k, 1 k r 1,
the atom V (v

j,k
, t

j,k
) for each k, 1 k r,
the atom A
i
(t

j,k
) for each k, 1 k r, where i, 1 i n, is the number such that z
h
k
(i.e. the kth variable of

) is
x
i
, and
the atom V (w

j,i
, t

j,k
) for each k, 1 k r, where i, 1 i n, is the number such that z
h
k
is y
i
,
and

j
, 1 j 2, contains the atom F(w

j,k
, w

j,k+1
) for each k, 1 k m1.
- for each , q < p, such that

=
1

2
, we have that

TV

F
(u

1
, v

1
) TV
1
F
(u

1
, w

1
) TV
2
F
(u

1
, t

1
) U(v

1
) C(w

1
) C(t

1
)
TV

F
(u

2
, v

2
) TV
1
F
(u

2
, w

2
) C(v

2
) U(w

2
) TV

F
(u

3
, v

3
) TV
2
F
(u

3
, t

3
) C(v

3
) U(t

3
);
- for each , q < p, such that

=
1
, we have that

TV

F
(u

1
, v

1
) TV
2
F
(u

1
, w

1
) U(v

1
) U(w

1
) TV

F
(u

2
, v

2
) TV
1
F
(u

2
, w

2
) C(v

2
) C(w

2
).
Next we dene the KB / = T , / and start with the ABox /.
1. The active domain contains the constants a
1
, . . . , a
n
(corresponding to the elements of the model of ). The ABox / for
every i, 1 i n, contains the assertion A
i
(a
i
).
2. The active domain contains the constants 0 and 1 (corresponding to the truth values false and true). The ABox / contains
the assertions S(0), S(1), C(0) and U(1).
3. The active domain contains the constant c (which initiates the computation of ). The ABox / contains the assertions
START
R
(c) and START
F
(c).
4. The active domain contains the constants b, e
1
, . . . , e
n
, d
1
, . . . , d
m
, f, g
q+1
, . . . g
p
. These constants, along with the following
assertions, force every model of / to have one homomorphism from (the existential closure of)

. The ABox / contains


the assertions:
- R
0
(b), R(b, e
1
) and R(e
k
, e
k+1
) for each i, 1 k r 1;
- V (e
k
, a
i
) for each k and i, 1 k r, 1 i n;
- V (e
k
, f) for each k, 1 k r;
- TV
R
(e
r
, 0) and TV
R
(e
r
, 1);
- F
0
(b), F(b, d
1
) and F(d
k
, d
k+1
) for each i, 1 k m1;
- V (d
k
, f) for each k, 1 k m;
- TV

F
(d
m
, 0) and TV

F
(d
m
, 1) for each , 1 q;
- TV

F
(g

, 0), TV
1
F
(g

, 0), TV
2
F
(g

, 0), TV

F
(g

, 1), TV
1
F
(g

, 1) and TV
2
F
(g

, 1) for each , q < p, such that

1

2
;
- TV

F
(g

, 0), TV
1
F
(g

, 0), TV

F
(g

, 1) and TV
1
F
(g

, 1) for each , q < p, such that

=
1
.
Finally, the TBox T consists of the following three parts.
1. The rst part essentially assigns elements to the existential variables x:
- for each i, 1 i n, the TBox T contains the assertions V
i

_ A
i
and V
i
_ V .
2. The second part essentially assigns a truth value to every fact P(a
i1
, . . . , a
ir
):
- for each i, 1 i n, the TBox T contains the assertions START
R
_ R
0
and START
R
_ R
i
1
;
- for each i, j and k, 1 i n, 1 j n, 1 k r 1, the TBox T contains the assertion R
i
k

_ R
j
k+1
;
- for each i and k, 1 i n, 1 k r, the TBox T contains the assertions R
i
k

_ V
i
and R
i
k
_ R;
- for each i, 1 i n, the TBox T contains the assertion R
i
r

_ TV
R
;
- the TBox T contains the assertion TV

R
_ S.
3. The third part essentially assigns a truth value to every sub-formula

of for every element assignment of variables y:


- for each i, 1 i n, the TBox T contains the assertions START
F
_ F
0
and START
F
_ F
i
1
;
- for each i, j and k, 1 i n, 1 j n, 1 k m1, the TBox T contains the assertion F
i
k

_ F
j
k+1
;
- for each i and k, 1 i n, 1 k m, the TBox T contains the assertions F
i
k

_ V
i
and F
i
k
_ F;
- for each i and , 1 i n, 1 p, the TBox T contains the assertion F
i
m

_ TV

F
;
- for each , 1 p, the TBox T contains the assertion TV

F

_ S.
Having the construction of the KB / completed next we will show the correctness of the reduction. We start with the
following claim.
Claim 1. Let J be a model for the KB / above. Then there are exactly two homomorphisms from the body of the Count-CQ q
to J that map all the existential variables s of q to the constants in the active domain of /.
Proof. Both homomorphisms can be constructed as follows: map the variable s
1
of q to either 0 or 1 (we know this is valid
since / contains assertions S(1) and S(0)). In the same fashion, map each variable s
i
, 1 i n, in q to the constant a
i
, for
each i, 1 i n (this is again valid since /contains all the assertions A
i
(a
i
)). For the rest of the variables of q one can check
that all of them can be mapped to constants b, d, e, f, g (with indexes) that appear already in assertions of /. That no other
homomorphism can be constructed in this fashion can be checked by a straightforward inspection of the construction.
It follows from the above claim that the body of the query q has at least two homomorphisms to each model of /, and thus
that 2 m(q, t

, /) (recall that t

is the empty tuple). This property is crucial for this proof.


We now show that 2 Cert(q, t

, /) iff xy (x, y) is satisable.


(=) Assume that 2 Cert(q, t

, /). Then there is a model J for / such that there are exactly two homomorphisms from q
to J (we know that there are at least two of them). Without loss of generality we assume that J is minimal, in the sense that
all the tuples in the interpretation of concepts and roles in J witness a certain TBox or ABox assertions. If not, one can always
remove this extra tuples, ending up with a model with no greater number of homomorphisms, since removing them can never
create extra homomorphisms from the body of q to J.
We can deduce several properties of the model J.
- The interpretation of S in J contains only elements 0 and 1, and therefore these are the only constants in the second compo-
nent of the pairs in the interpretation over each TV
R
and TV

F
, 1 p over J. Otherwise, one can construct additional
homomorphisms by mapping the variable s
1
in the atom S(s
1
) of the body of q to one of the other elements.
- By similar reasons, the interpretation of each A
i
, 1 i n, contains exclusively the constant a
i
, and therefore the second
component of each pair in the interpretation of V
i
over J does the same.
Let now / be a model over the vocabulary of consisting of the elements a
1
, . . . , a
n
, and assume that the in-
terpretation P
M
of the only relation P over / is as follows: each r-tuple (a
i1
, . . . , a
ir
) of elements in a
1
, . . . , a
n

belongs to P
M
if and only if there are elements a
i1
, . . . , a
ir
in J so that the following assertions holds in J:
R
i1
1
(c, a
i1
), R
i2
2
( a
i1
, a
i2
), . . . , R
ir
r
( a
ir1
, a
ir
), V ( a
i1
, a
i1
), . . . , V ( a
ir
, a
ir
), TV
R
( a
ir
, 1).
We now show that all possible assignments for variables y
1
, . . . , y
m
in to variables from a
1
, . . . , a
n
satisfy , in the
case when each x
i
is assigned the element a
i
, for 1 i n. In order to do that, we show the following claim by induction.
Claim 2. A sub-formula

of is satised by the assignment : xy a


1
, . . . , a
n
such that (x
i
) = a
i
, 1 i n, and
(y
k
) = a
(k)
, 1 k m, where is a mapping from1, . . . , m to 1, . . . , n, if and only if there are elements a
k1
, . . . , a
km
in J so that the following assertions are in J:
F
(1)
1
(c, a
k1
), F
(2)
2
( a
k1
, a
k2
), . . . , F
(m)
m
( a
km1
, a
km
), V ( a
k1
, a
(1)
), . . . , V ( a
km
, a
(m)
), TV

F
( a
km
, 1).
Proof.
Basis. The base case is when 1 q, i.e.

is an atomic formula of form P(z


h1
, . . . , z
hr
), where each z
h
k
is
one of x
1
, . . . , x
n
, y
1
, . . . , y
m
. Assume for the sake of contradiction that there are constants a
k1
, . . . , a
km
in the domain
of J so that J does contain the required assetions, yet

is not satised with assignment (the other direction is sym-


metrical). If

is not true for the assignment , then the r-tuple (z


h1
, . . . , z
hr
) is not in the interpretation of P over
/. By the construction of / and the properties deduced from J, it must be the case that the following facts are in J:
R
i1
1
(c, a
i1
), R
i2
2
( a
i1
, a
i2
), . . . , R
ir
r
( a
ir1
, a
ir
), V ( a
i1
, a
i1
), . . . , V ( a
ir
, a
ir
), TV
R
( a
ir
, 0) for some elements a
i1
, . . . , a
ir
in J
and such that for each h
k
, 1 k r, we have that (z
h
k
) = a
h
k
. From this one can easily check that there is a homomorphism
from the subquery

to the aforementioned atoms, which results in extra homomorphisms from the body of q to J.
Inductive step. For the inductive case, assume that

=
1

2
, q < p (the case when

=
1
is analogous).
Moreover, assume for the sake of contradiction that there are constants a
k1
, . . . , a
km
in J so that the J does contain the facts
in the statement of the claim, yet

is not satised with the assignment (the other direction is symmetrical). If

is not
satised, then neither
1
nor
2
are satised. By the induction hypothesis and the construction of /, there are constants
a
k1
1
, . . . , a
km
1
and a
k1
2
, . . . , a
km
2
such that the facts
F
(1)
1
(c, a
k1
1
), F
(2)
2
( a
k1
1
, a
k2
1
), . . . , F
(m)
m
( a
km1
1
, a
km
1
), V ( a
k1
1
, a
(1)
), . . . , V ( a
km
1
, a
(m)
), TV

F
( a
km
1
, 0),
and
F
(1)
1
(c, a
k1
2
), F
(2)
2
( a
k1
2
, a
k2
2
), . . . , F
(m)
m
( a
km1
2
, a
km
2
), V ( a
k1
2
, a
(1)
), . . . , V ( a
km
2
, a
(m)
), TV

F
( a
km
2
, 0)
belong to J. In other words, these facts cause an extra witness for the subquery

in q.
Having established Claim 2, we note that the body of the query q contains atoms TV
p
F
(s
2
, s
3
) C(s
3
). Thus, if the sub-
formula
p
which is itself by the convention, does not hold for some assignment , it means that J contains the fact TV
p
F
( a, 0)
for some constant a, and then at least one extra homomorphism can be constructed from the body of q to J. Thus, it must be
the case that
p
is satised by all possible assignments of y
1
, . . . , y
m
to a
1
, . . . , a
n
. It follows that xy (x, y) is satisable.
(=) Assume that xy (x, y) is satisable. Then, as we have mentioned, there is a model / with at most n elements,
that satises this formula. Assume without loss of generality that this model has exactly n elements, say a
1
, . . . , a
n
, and the
satisfying assignment for assigns each x
i
, 1 i n, to a
i
. We now construct an instance J, which is a model of the KB /,
such that there are only two homomorphisms from q to J. Dene the model as follows:
The interpretation of each A
i
, 1 i n, and S in J is as required by the ABox /: each A
i
contains a
j
and S contains 1
and 0.
The interpretation of each role R
i
k
, 1 i n, 1 k r, and R is as in the /, plus extra pairs as in a canonical instance of
/. It is convenient to note that a canonical instance contains a tree of Rs of height r and width n. Each of the leaves of this
tree has to be the rst component of an extra atom TV
R
. We add the following to J. Consider each path from c to some leaf
a
ir
in J, of the form R
0
(c), R
i1
1
(c, a
i1
), R
i2
2
( a
i1
, a
i2
), . . . , R
ir
r
( a
ir1
, a
ir
), such that a
i1
, . . . , a
ir
are different constants and
V
i1
( a
i1
, a
i1
), . . . , V
ir
( a
ir
, a
ir
) are new assertions in J. Then the interpretation of TV
R
in J contains the pair ( a
ir
, 1) if the
interpretation of the relation P in the model M contains the tuple (a
i1
, . . . , a
ir
), and ( a
ir
, 0) otherwise.
The interpretation of each role F
i
k
, 1 i n, 1 k m, and F is as in the /, plus extra pairs as in a canonical instance of
/. Again, it is convenient to note that a canonical instance contains a tree of Fs of height m and width n. Each of the leaves
of this tree has to be the rst component of extra atoms TV

F
for all 1 p. We add the following to J. Consider each
path from c to some leaf a
im
in J, of form F
0
(c), F
i1
1
(c, a
i1
), F
i2
2
( a
i1
, a
i2
), . . . , F
im
m
( a
im1
, a
im
), such that a
i1
, . . . , a
im
are
different constants and V
i1
( a
i1
, a
i1
), . . . , V
im
( a
im
, a
ir
) are new assertions in J. Then the interpretation of each TV

F
in J
contains the pair ( a
im
, 1) if the sub-formula

of holds in the model /for the evaluation of y


1
, . . . , y
m
to (a
i1
, . . . , a
im
),
and ( a
im
, 0) otherwise.
It is now a cumbersome, but straightforward task to show that there are only two homomorphisms from q to J. The proof
of course makes use of the fact that any other homomorphisms must map at least one variable of q to a constant that does not
appear in the active domain of /.
The only thing left to complete the proof is to explain how to extend the construction above in the case when the vocabulary
of contains several relations P
1
, . . . , P
N
. Essentially, one needs a tree like construct as above for each such relation. The KB
can then be adapted in the expected way. Note that if the arities of these relations are not the same then the lengths of these
trees need to be adapted accordingly.
References
B orger, E.; Gr adel, E.; and Gurevich, Y. 2001. The Classical Decision Problem. Springer, Berlin.