I 1 ⊆B J 2, BJ2 = BI2? andBJ20 = B2I?∪BJ2?. Moreover, for every concept inclusionB1 v ¬B2 ∈ B, where B1,B2 are basic concepts, we have thatBI1 ⊆(¬B2)J0given thatBI1 ⊆(¬B2)J, (¬B2)J =(¬B2)I? and (¬B2)J0 =(¬B2)I?∪(¬B2)J? (sinceBJ20 =B2I? ∪BJ2? and∆I?∩∆J? =∅). Finally, for role inclusionsR1 vR2andR1 v ¬R2inB, whereR1,R2
are basic roles, we conclude thatRI1 ⊆RJ20andRI1 ⊆(¬R2)J0as in the previous two cases. From the results in the previous paragraph, we conclude thatJ0 ∈ S
atM(Mod(Ks)) (sinceJ0 ∈ SatM(I) and I ∈Mod(Ks)). On the other hand, we have thatJ06|=T, by definition ofJ0and given thatJ?6|=T. Thus, we have thatJ06|=K
tand, thus,J0<Mod(Kt). Therefore, we conclude that SatM(Mod(Ks)),Mod(Kt), which contradicts
the fact thatKtis a universal solution forKsunderM. This concludes the proof of the proposition.
B. Proofs in Section 6 B.1. Proof of Lemma 6.2
Proof. In this proof we assume thatKs=hS,Asiand we denote byKsbthe KBhS ∪ B,Asi.
(⇒) LetAtbe a universal solution forKsunderM. Thenuni(At) isΓ-homomorphically equivalent touni(Ksb):
sinceAtis a solution, there existsI, a model ofKs, such that (I,uni(At))|=B. ThenI ∪uni(At) is a model ofKsb,
therefore there is a homomorphismhfromuni(Ksb) toI ∪uni(At). AsΣandΓare disjoint signatures it follows thath
is aΓ-homomorphism fromuni(Ksb) touni(At). On the other hand, asAtis a universal solution,J, the interpretation
ofΓobtained fromuni(Ksb) is a model ofAtwith a substitutionh0. Thish0is exactly a homomorphism fromuni(At) touni(Ksb). Thus, we showed(hom).
For the sake of contradiction, assume that(safe)does not hold, i.e.,Ksis notΓ-safe with respect toM, and e.g.,
(cs)does not hold, i.e., there is a disjointness axiom inSof the formBv ¬C, such that (B,C) is not safe. Then both
BandCare not safe inuni(Ksb): for someb∈Buni(Ksb)andc∈Cuni(Ksb), tuni(Ksb)
Γ (b),∅ or b∈Na, and t
uni(Ksb)
Γ (c),∅ or c∈Na.
Lethbe aΓ-homomorphism fromuni(Ksb) touni(At) (it exists by(hom)), andh(b)=tandh(c)=s. Then it follows
that
tuniΓ (At)(t),∅ or b∈Na, and tuniΓ (At)(s),∅ or c∈Na.
Take a modelJofAtwith a substitutionhJ such that∆J ={d}(hence,tJ =sJ). Such a model exists becauseAt
does not assert any negative information and the UNA doesnothold. First, assume that bothbandcare constants (i.e.,bJ =cJ). Then, obviously there exists no modelIofΣsuch thatI |=Ksand (I,J)|=B: in every suchI,bI
must be equal tocIwhich contradictsBv ¬C, andbI∈BIandcI∈CI. Now, assume that at leastbis not a constant andtail(b)=w[R]for some roleRoverΣ(hence,b ∈(∃R−)uni(Ksb) andS |=∃R− vB). LetB0∈t
uni(Ksb)
Γ (b), then by
construction of the canonical model,S ∪ B |=∃R−vB0, by homomorphism,B0(t)∈ At, and by construction ofJ,
B0J ={d}. AsA
(∃R−)I⊆B0J. It immediately follows thatd∈(∃R−)I, henced ∈BI. By a similar argument, it can be shown thatd
must be inCI, which contradicts thatIis a model ofBv ¬C. Contradiction withAtbeing a universal solution. Similar to(cs)we can derive a contradiction if assume that(rs)does not hold.
Now, assume(re)does not hold, i.e.,Bv ¬B0 ∈ BandBuni(Ksb)
,∅. Note thatAtis an extended ABox, i.e., it
contains only assertions of the formA(u),P(u,v) foru,v∈Na∪Nl. Take a modelJofAtsuch thatB0J = ∆J. Such Jexists asAtcontains only positive facts. SinceAtis a universal solution, there exist a modelIofKs such that
(I,J)|=B. Then,BI
,∅, and it is easy to see that (I,J)6|=Bv ¬B0because∆J\B0J =∅andBI*∆J\B0J. Similar to(ce)we can derive a contradiction if assume that(re)does not hold.
In every case we derive a contradiction, henceKsisΓ-safe with respect toM.
(⇐) Assume(hom)and(safe)hold. We show thatAtis a universal solution forKsunderM.
First,At is a solution forKsunderM. LetJ be a model ofAt, andh1 a homomorphism fromuni(At) to J.
Furthermore, lethbe aΓ-homomorphism fromuni(Ksb) touni(At). Thenh2(x)=h1(h(x)) is aΓ-homomorphism from uni(Ksb) toJ. LetIbe the interpretation ofΣdefined as the image ofh2applied touni(Ks), i.e.,I=h2(uni(Ks)).
Next, define a new functionh0:∆uni(Ks)→∆∪∆I, where∆is an infinite set of domain elements disjoint from∆I, as follows:
– h0(x)=h2(x) iftuni(Ksb)
Γ (x),∅orx∈Na. – h0(x)=d
x, a fresh domain element from∆, otherwise.
We show that interpretationI0defined as the image ofh0applied touni(K
sb), is a model ofKsand (I0,J)|=M. It
is straightforward to verify thatI0is a model of the positive inclusions inSand (I0,J) satisfy the positive inclusions fromB. In what follows we prove thatI0is a model of the disjointness axioms inS.
LetS |= B v ¬Cfor basic concepts B,C. By contradiction, assumeI0 6|= B v ¬C, i.e., for some d ∈ ∆I0,
d ∈ BI0 ∩CI0. We defined I0 as the image of h0 on uni(Ks), hence there must exist b,c ∈ ∆uni(Ks) such that
b∈ Buni(Ks),c∈Cuni(Ks), andh0(b)=h0(c)=d. Then, sinceK
sisΓ-safe with respect toM, it follows that (B,C) is
safe and it cannot be the case that
tuni(Ksb)
Γ (b),∅ or b∈Na, and t
uni(Ksb)
Γ (c),∅ or c∈Na. Assumebis a null andtuni(Ksb)
Γ (b)=∅. Then by definition ofh0,h0(b)=db ∈∆(henced =db). In either casecis a constant, ortuniΓ (Ksb)(c),∅, ortuniΓ (Ksb)(c)=∅, we obtain contradiction withh0(b)=db =h0(c) (recall,∆and∆Iare disjoint). Contradiction rises from the assumptionI 6|=Bv ¬C.
Next, assumeS |=Rv ¬Qfor rolesR,Q, andI06|=Rv ¬Q, i.e., for somed1,d2 ∈∆I0, (d1,d2)∈RI0∩QI0. We definedI0as the image ofh0onuni(Ks), hence there must existb1,b2,c1,c2 ∈∆uni(Ks) such that (b1,b2) ∈Runi(Ks),
(c1,c2) ∈ Quni(Ks), andh0(b
i)= h0(ci) =difori = 1,2. Then, sinceKsisΓ-safe with respect toM, it follows that
(R,Q) is safe and it cannot be the case that 1)RandQare not safe, i.e.,
tuni(Ksb)
Γ (bi),∅ or bi∈Na, and t
uni(Ksb)
Γ (ci),∅ or ci∈Na,
or 2)tuniΓ (Ksb)(b2),∅andtΓuni(Ksb)(c2),∅ifb1=c1. Consider the following possible cases:
– b1is a null andtuni(Ksb)
Γ (b1)=∅. Then by definition ofh0,h0(b1)=db1 ∈∆(andd1=db1).
– c1is a null andtuni(Ksb)
Γ (c1) =∅, thenh0(c1) =dc1 =d1, hencec1 =b1and (b1,b2)∈ Runi(Ks), (b1,c2)∈
Quni(Ks). Assumeb2is a null andtuni(Ksb)
Γ (b2)=∅. Thenh0(b2)=db2 ∈∆and in either casec2is a constant, ortuniΓ (Ksb)(c2),∅, ortΓuni(Ksb)(c2)=∅, we obtain contradiction withh0(b2)=db2 =h
0(c2).
– otherwise we obtain contradiction withh0(b1)=db1=h0(c1).
The casesb2orciare nulls with the emptyΓ-type are covered by swappingRandQor by taking their inverses. Finally, assumeBv ¬B0∈ Band (I0,J)6|=Bv ¬B0, i.e., for somed∈BI0
,d<∆J\CJ. Then there must exist b∈Buni(Ks)such thath0(b)=d. Contradiction with(ce). Similarly, we derive a contradiction with(re)if assume that
Therefore, indeed,Iis a model ofKsand (I,J)|=B. This concludes the proofAtis a solution forKsunderM. Second,Atis a universal solution. LetIbe a model ofKsandJan interpretation ofΓsuch that (I,J) |=M. Then, sinceuni(Ksb) is the canonical model ofKsb, there exists a homomorphismhfromuni(Ksb) toI ∪ J(I ∪ J is a model ofKsb). In turn, there is a homomorphismh1 from uni(At) to uni(Ksb), thereforeh0 = h◦h1 is a
homomorphism fromuni(At) toI ∪ J, and aΓ-homomorphism fromuni(At) toJ. Hence,Jis a model ofAt: takeh0as the substitution for the labeled nulls. By definition of universal solution,A
tis a universal solution forKs
underM.
B.2. Proof of Lemma 6.8
Proof. The proof is inspired by one in [30], but makes use of a reduction from the Circuit Value problem, known to be PTime-complete [63, Theorem 8.1], instead of a reduction from the Horn Satisfiability problem. Given a monotone Boolean circuitCconsisting of a finite set of assignments to Boolean variablesP1, . . . ,Pnof the formPi=0,Pi=1,
Pi=Pj∧Pk,j,k<i, orPi=Pj∨Pk,j,k<i, where eachPiappears on the left-hand side of exactly one assignment, check whether the valuePnis 1 inC.
We fix signaturesΣ ={P,L,R}andΓ ={L0,R0}. Leta1, . . . ,a
n∈Na, and consider
As={P(an)} ∪ {L(ai,ai),R(ai,ai)|Pi=1 inC} ∪ {L(ai,aj),R(ai,ak)|Pi=Pj∧PkinC}
∪ {L(ai,aj),R(ai,aj),L(ai,ak),R(ai,ak)|Pi=Pj∨PkinC}
S={Pv ∃L, Pv ∃R, ∃L−vP, ∃R−vP}, B={LvL0, RvR0}
At={L0(ai,aj)|L(ai,aj)∈ As} ∪ {R0(ai,aj)|R(ai,aj)∈ As}
Note thatΣ,Γ,S, andBdo not depend onC, hence the reduction provides a lower bound for data complexity. We show that the value ofPn inCis 1 if and only ifAtis a universal solution forKs =hS,AsiunderM =(Σ,Γ,B).
Denote byKsb the KBhS ∪ B,Asi. Clearly, uni(At) ⊆ uni(Ksb) (independently of the value of Pn inC). So, it suffices to show that the value ofPninCis 1 if and only ifuni(Ksb) isΓ-homomorphically embeddable intouni(At).
(⇒) SupposePn evaluates to 1 inC. Observe that the projection ofuni(Ksb) overΓcontains an infinite binary
tree whose root isan, and in which each left edge is labeled withL0and each right edge is labeled withR0. We define aΓ-homomorphismh fromuni(Ksb)an touni(At) by induction on the length ofσ ∈ ∆uni(Ksb)
an
. Note that, sinceΓ contains only role names, the local homomorphism condition is trivially satisfied.
For the base case, we seth(an) =an. For the inductive step, assume the value ofPiis 1 and we already defined
h(σ) = ai for σ ∈ ∆uni(Ksb) an
. Consider the following three cases. First, if Pi = Pj∧Pk inC, then Atcontains
assertionsL0(a
i,aj) andR0(ai,ak), moreover,PjandPkboth evaluate to 1: we seth(σw[L])=ajandh(σw[R])=ak. Second, ifPi=Pj∨PkinC, thenAtcontains assertionsL0(ai,aj),R0(ai,aj) andL0(ai,ak),R0(ai,ak), and at least one ofPjandPkevaluates to 1, assume it isPj: we seth(σw[L])= ajandh(σw[R])=aj. Finally, ifPi =1 inC, then
Atcontains assertionsL0(ai,ai) andR0(ai,ai): we seth(σw[L])=aiandh(σw[R])=ai. Hence, by construction,his a Γ-homomorphism.
(⇐) SupposeAtis a universal solution forKsunderM. Thenuni(S ∪ B,As) isΓ-homomorphically embeddable inuni(At). We prove that the value ofPnis 1 inC.
Leth be aΓ-homomorphism fromuni(Ksb) touni(At). Sinceuni(Ksb)an is an infinite tree, and the only role
cycles thatAtcontains are loops of the formL0(a
i,ai) andR0(ai,ai), there exists a boundmsuch that for eachσ =
anw[S1]· · ·w[Sm]∈∆
uni(Ksb)an
withSj∈ {L,R}, it holdsh(σ)=aifor someisuch thatPi=1 inC.
Assume 1≤`≤mand for eachσ=anw[S1]· · ·w[S`] withSj∈ {L,R}and each 1≤i≤n, the value ofPiis 1 in
Cwheneverh(σ)=ai. We verify by induction on`that for eachδ=anw[S1]· · ·w[S`−1]and each 1 ≤i≤n, the value ofPi is 1 inCwheneverh(δ)= ai. Assume thath(δw[L])= aj,h(δw[R]) =akand the values ofPjandPk are 1 in
C, moreoverh(δ) =ai. Ifi= j=k, then obviously the value ofPiis 1 inC. Otherwisei, jandi ,k. If j =k,
then given thathis aΓ-homomorphism,Atcontains assertionsL0(ai,aj) andR0(ai,aj) (hence,Ascontains assertions
L(ai,aj) andR(ai,aj)). By construction ofAs, it follows that there is an assignmentPi =Pj∨Pj0inCfor some j0. AsPjis 1, we obtain that alsoPievaluates to 1. If j ,k, thenAtcontains assertionsL0(ai,aj) andR0(ai,ak), so by construction ofAsthere is an assignmentPi=Pj∧PkorPi =Pj∨PkinC. Again it follows thatPievaluates to 1 inC. By induction,Pnevaluates to 1 inC.
B.3. Proof of Lemma 6.12
Proof. The proof is by reduction from 3-colorability of undirected graphs known to be NP-hard. Consider an undirected graphG=(V,E), which we view as a symmetric directed graph, and fix signatures Σ = {E(·,·)} and Γ ={E0(·,·)}. Further, letr,g,b∈N a,V⊆Nland As = {E(r,g),E(g,r),E(r,b),E(b,r),E(g,b),E(b,g)}, S = {}, B = {EvE0}, At = {E0(r,g),E0(g,r),E0(r,b),E0(b,r),E0(g,b),E0(b,g)} ∪ {E0(x,y)|(x,y)∈E}.
Note that the nodes inGbecome labeled nulls inAt. We show thatGis 3-colorable if and only ifAtis a universal
solution forKs=hS,AsiunderM=(Σ,Γ,B).
(⇒) SupposeGis 3-colorable. Then it follows that there exists a functionhthat assigns to each vertex fromVone of the colors{r,g,b}such that if (x,y)∈E, thenh(x),h(y). Hencehis a homomorphism fromGto the undirected
graph {r,g,b},{(r,g),(g,b),(b,r)}.
We prove thatAtis a universal solution forKsunderMby employing Lemma 6.2. Obviously,KsisΓ-safe with respect toM. Thus, it remains to verify thatuni(At) isΓ-homomorphically equivalent touni(S ∪ B,As). First, it is easy to see thatuni(S ∪ B,As) isΓ-homomorphically embeddable intouni(At). Second,his also a homomorphism
fromuni(At) touni(S ∪ B,As). ThusAtis indeed a universal solution forKsunderM.
(⇐) Suppose nowAtis a universal solution forKs under M. Then by Lemma 6.2 it follows that uni(At) is
Γ-homomorphically equivalent touni(S ∪ B,As). Lethbe a homomorphism fromuni(At) touni(S ∪ B,As). Notice
that∆uni(S∪B,As) =ind(A
s), hencehassigns to each labeled nullx∈∆uni(At)some constanta∈ind(As), and it is easy
to see thathis an assignment for the vertices inVthat is a 3-coloring ofG.
B.4. Proof of Lemma 6.15
Proof. The proof is by reduction from the validity problem for Quantified Boolean Formulas (QBF), known to be PSpace-complete. Consider a QBF
ϕ=Q1X1· · ·QnXn m ^
j=1 Cj
whereQi∈ {∀,∃}andCj, 1≤ j≤m, are clauses over the variablesXi, 1≤i≤n.
LetΣ ={A, Q0,Qi,Qki,Rj, P0,Pi,Pki,R0j,Rij| j∈ {1, . . . ,m}, i∈ {1, . . . ,n}, k∈ {0,1}}whereAis a concept name and the rest are role names. LetSbe the following TBox overΣfor j∈ {1, . . . ,m},i∈ {1, . . . ,n}andk∈ {0,1}:
Av ∃Q− 0 ∃Q − i−1v ∃Q k i, ifQi=∀ Qki vQi ∃Q−n v ∃Rj ∃R−j v ∃Rj ∃Q−i−1v ∃Qi, ifQi=∃ (B.1) Av ∃P−0 ∃P−i−1v ∃Pki Pki vPi ∃(P0i)−v ∃Rij, if¬Xi∈Cj ∃(Rij)−v ∃Rij−1 ∃(P1 i) −v ∃Ri j, ifXi∈Cj (B.2) andAs={A(a)}.
Further, letΓ = {Xi0,Xi1,T,Sj}whereXi0,X1i are concept names andT,Sjare role names,M=(Σ,Γ,B), andB the following set of inclusions:
QivT ∃(Qki)−vXki RjvSj RijvSj PivT ∃(Pki) −vXk i PivS−j R 0 jvS − j
Then,|=ϕif and only ifuni(S ∪ B,As) isΓ-homomorphically embeddable into a finite subset of itself, i.e., if and only
if a universal solution forKs=hS,AsiunderMexists. We show this following the line of the proof of Theorem 11
(⇒) Suppose|=ϕ. We show that the canonical modeluni(S ∪ B,As) isΓ-homomorphically embeddable into a finite subset of itself. More precisely, let us denote withSinf the subset ofSconsisting of the first 6 axioms (B.1), and
Sfinthe subset ofSconsisting of the last 6 axioms (B.2). Thenuni(S ∪ B,A
s)=uni(Sinf∪ B,As)∪uni(Sfin∪ B,As).
In the following we useUinf to denoteuni(Sinf ∪ B,A
s), andUfin to denoteuni(Sfin ∪ B,As), and show how to
construct aΓ-homomorphismh:Uinf → Ufin.
We begin by settingh(a)=a. Then we definehin such a way that, for each pathπinUinf of lengthi+1≤n,h(π) is a path of the formaw[Pk1
1]
· · ·w[Pki i]
inUfin and it defines an assignmentαh(π) to the variablesX1, . . . ,Xiby taking
αh(π)(Xi0) = >ifki0 = 1 andαh(π)(Xi0) = ⊥if ki0 = 0, for all 1 ≤ i0 ≤ i. Such assignmentsαh(π) will satisfy the following:
the QBF obtained fromϕby removingQ1X1. . .QiXifrom its prefix is true underαh(π). (α)
For the paths of length 1 theΓ-homomorphismh has been defined and (α) trivially holds. Suppose that we have definedhfor all paths inUinf of lengthi+1≤n. We extendhto all paths of lengthi+2 inUinf such that (α) holds. Letπbe a path of lengthi+1. Observe thath(π) has two successors inUfin:h(π)·w[P0
i+1]andh(π)·w[P1i+1]. Now, – ifQi=∀thenπhas two successors inUinf:π·w[Q0
i+1]andπ·w[Qi1+1]. Thus, we seth(π·w[Qki+1])=h(π)·w[Pki+1], fork=0,1. Clearly, (α) holds.
– ifQi =∃thenπhas one successor inUinf: π·w[Qi+1]. Sinceϕis valid, by (α) the QBF obtained fromϕby
removingQ1X1. . .QiXiis true under eitherαh(π)∪{Xi7→ >}orαh(π)∪{Xi7→ ⊥}. We seth(π·w[Qi+1])=h(π)·w[Pki+1]
wherek=1 in the former case, andk=0 in the latter case. Either way, (α) holds. Let nowπbe a path of lengthn+1 inUinf. By construction, we have thath(π)=a·w[Pk1
1]
· · ·w[Pkn
n]. Next, on the one
hand, inUinf the pathπhasminfinite extensions of the formπ·w[Rj]·w[Rj]· · ·, for 1≤ j≤m. On the other hand, by
(α),αh(π) |=Cjfor each clauseCj, i.e., there is some 1≤i≤nsuch thatki=1 ifXi ∈Cj, orki =0 if¬Xi ∈Cj. For
l≥1, denote byπlthe pathπ·w[Rj]·. . .·w[Rj]wherew[Rj]is repeatedltimes. We now set h(πl)=a·w[Pk1 1] ·. . .·w[Pkn−l n−l] , for 1≤l≤n−i, h(πl)=a·w[Pk1 1] ·. . .·w[Pki i] ·w[Ri j] ·. . .·w[Rn−l+1 j ], forn −i<l≤n+1, h(πl)=a·w[Pk1 1] ·. . .·w[Pki i] ·w[Ri j] ·w[Ri−1 j ] ·. . .·w[Ri? j ], forn+1<landi ?=(n−l+1) mod 2.
It is immediate to verify thathis aΓ-homomorphism fromUinf toUfin. Since K1 isΓ-safe with respect toM, by Lemma 6.4 we obtain that a universal solution forK1underMexists.
(⇐) Lethbe aΓ-homomorphism fromUinf toUfin. We show that|=ϕ.
Letπ= a·w1· · ·wn be a path of lengthn+1 inUinf. Then its homomorphic imageh(π) must be of the form
a·w[Pk1 1]
· · ·w[Pkn
n]. This implies a variable assignmentαπ:απ(Xi)=>ifki=1 andαπ(Xi)=⊥ifki=0, for 1≤i≤n.