Algorithm Search⌘K

Problemresearch

Ontology-mediated query answering

Also called ontology-based data access, OBDA.

Answer a conjunctive query over data under an ontology, returning the tuples that are answers in every model.

Ontology-mediated query answering asks for the answers of a database query over data that is read through an ontology. The data is an ABox, a set of facts about individuals. The ontology is a TBox that adds background knowledge, for example that every professor teaches something. The query is usually a conjunctive query. Because of the open world assumption, facts that are missing from the data are unknown, not false, so the answers are the certain answers: the tuples that are answers in every model of the TBox and the ABox. The cost depends on the ontology language. In DL-Lite the query can be rewritten into a first-order query over the data alone, so it runs in a database; in EL answering stays polynomial in the data; in ALC it is already coNP-hard in the data.

In plain words

You have a table of facts and a list of rules about what the words mean. Someone asks a question, such as "which people teach a course?". Some people are not listed as teaching anything, but the rules say that every professor teaches some course, so each professor must be in the answer. The answer should contain exactly the people for whom the facts and the rules together force a yes, no matter how the gaps in the facts are filled in. Finding these people is the task. With simple rules the question can be changed into a larger question that the plain table answers. With rich rules you may have to consider many ways to fill the gaps.

Definition

An ontology-mediated query is a pair Q=(T,q)Q = (\mathcal T, q) of a TBox T\mathcal T in a description logic L\mathcal L and a conjunctive query (CQ)

q(x⃗)=∃y⃗. α1∧⋯∧αk,q(\vec x) = \exists \vec y.\, \alpha_1 \wedge \cdots \wedge \alpha_k,

where each atom αi\alpha_i is A(t)A(t) or r(t,t′)r(t, t') for a concept name AA, a role name rr and terms among the answer variables x⃗\vec x and the bound variables y⃗\vec y. A union of conjunctive queries (UCQ) is a finite disjunction of CQs with the same answer variables. An interpretation II satisfies q(a⃗)q(\vec a) if some map hh from the variables to ΔI\Delta^I, with h(x⃗)=a⃗Ih(\vec x) = \vec a^I, sends each atom to a true fact of II. The bound variables may go to any element, also to elements that are not named in the data.

Input. A TBox T\mathcal T, a CQ q(x⃗)q(\vec x), an ABox A\mathcal A (see TBoxes and ABoxes), and a tuple a⃗\vec a of individuals of A\mathcal A of the length of x⃗\vec x.

Question. Is a⃗\vec a a certain answer, that is, does every model of (T,A)(\mathcal T, \mathcal A) satisfy q(a⃗)q(\vec a)?

The set of certain answers is written cert(q,T,A)\mathrm{cert}(q, \mathcal T, \mathcal A). If (T,A)(\mathcal T, \mathcal A) has no model, every tuple is a certain answer, so algorithms first test consistency. A CQ with no answer variables is Boolean.

Complexity is measured in two ways. In data complexity the TBox and the query are fixed, and only A\mathcal A and a⃗\vec a are the input. This is the measure that matters when the data is large and the ontology and query are small. In combined complexity all parts are the input.

Variants

  • Instance queries. The query is one atom A(x)A(x). This is instance checking, a classical reasoning task of description logics.
  • Unions of conjunctive queries. The query is a UCQ. Rewriting algorithms produce UCQs even from a single CQ.
  • The ontology language. The problem is studied for DL-Lite, EL and its Horn extensions, ALC and expressive logics such as SHIQ, and for rule languages such as existential rules.
  • Ontology-based data access. The data stays in relational sources, and mappings, which are queries over the sources, define the ABox. A query is answered by rewriting it with the TBox and then unfolding it with the mappings into a query over the sources.
  • Rewritability questions. Given (T,q)(\mathcal T, q), decide whether an equivalent first-order query or an equivalent Datalog program exists, and compute it.

Examples

  • Anonymous elements. Let T={Professor⊑∃teaches}\mathcal T = \{\mathit{Professor} \sqsubseteq \exists \mathit{teaches}\} and A={Professor(ann)}\mathcal A = \{\mathit{Professor}(\mathit{ann})\}. For q(x)=∃y. teaches(x,y)q(x) = \exists y.\, \mathit{teaches}(x, y), ann\mathit{ann} is a certain answer: every model has some teaches\mathit{teaches}-successor of ann\mathit{ann}. For q′(x,y)=teaches(x,y)q'(x, y) = \mathit{teaches}(x, y) there is no certain answer, because the successor need not be a named individual.
  • Rewriting. Add ∃teaches−⊑Course\exists \mathit{teaches}^- \sqsubseteq \mathit{Course} to T\mathcal T, and let A={Professor(ann), teaches(bob,c1)}\mathcal A = \{\mathit{Professor}(\mathit{ann}),\ \mathit{teaches}(\mathit{bob}, c_1)\}. For q(x)=∃y. teaches(x,y)∧Course(y)q(x) = \exists y.\, \mathit{teaches}(x, y) \wedge \mathit{Course}(y), the certain answers are ann\mathit{ann} and bob\mathit{bob}, though the data has no Course\mathit{Course} fact. PerfectRef finds them with a UCQ that includes ∃y. teaches(x,y)\exists y.\, \mathit{teaches}(x, y) and Professor(x)\mathit{Professor}(x).
  • Reasoning by cases. Let T={A⊑B⊔C, B⊑D, C⊑D}\mathcal T = \{A \sqsubseteq B \sqcup C,\ B \sqsubseteq D,\ C \sqsubseteq D\} and A={A(a)}\mathcal A = \{A(a)\}. Then aa is a certain answer of D(x)D(x), but not of B(x)B(x) nor of C(x)C(x). No single model of (T,A)(\mathcal T, \mathcal A) gives exactly the certain answers to all queries, which is why disjunction makes the problem hard.

Known algorithms

  • Query rewriting. For DL-Lite, compute from (T,q)(\mathcal T, q) a UCQ qTq_{\mathcal T} with cert(q,T,A)=qT(A)\mathrm{cert}(q, \mathcal T, \mathcal A) = q_{\mathcal T}(\mathcal A) for every consistent A\mathcal A, and run it as SQL. PerfectRef does this for DL-LiteR_R. The UCQ can be exponential in qq. For Tn={Bi⊑Ai:i≤n}\mathcal T_n = \{B_i \sqsubseteq A_i : i \le n\} and q=A1(x)∧⋯∧An(x)q = A_1(x) \wedge \cdots \wedge A_n(x), every UCQ rewriting needs all 2n2^n choices of AiA_i or BiB_i.
  • Datalog rewriting. For Horn logics such as EL, rewrite into a Datalog program and evaluate it with semi-naive evaluation. For instance queries in EL, the completion rules of EL classification, applied to the individuals of the ABox, are such a program.
  • Materialization and the chase. For Horn logics the certain answers are the answers over one canonical model, built by the chase of the ABox with the TBox. The canonical model can be infinite, for example with A⊑∃r.AA \sqsubseteq \exists r.A. The combined approach builds a finite part of it that may give some wrong answers, and removes them by a filter or by a rewriting of the query.
  • Expressive logics. For ALC and beyond, algorithms reduce the problem to inconsistency tests of the knowledge base extended with the negation of the query, by tableaux, resolution or automata.
AlgorithmTimeSpacePropertiesCode
PerfectRef query rewriting(t n)^O(n) worst(t n)^O(n) extradata independentdeterministicexactsaturation1 language

Bounds

ontology language query data complexity combined complexity
none (plain database) CQ in AC0 NP-complete
DL-LiteR_R UCQ in AC0 NP-complete
EL instance query P-complete P-complete
ALC instance query coNP-complete EXPTIME-complete
ALC CQ coNP-hard EXPTIME-complete (Lutz 2008)
ALCI CQ coNP-hard 2EXPTIME-complete (Lutz 2008)

The DL-Lite row is from Calvanese et al. (2007). The coNP upper bound for instance queries in ALC is a case of the result of Hustadt, Motik and Sattler (2005) for SHIQ. The EXPTIME lower bounds for ALC come from the general TBox theorem, and the textbook of Baader, Horrocks, Lutz and Sattler (2017) gives the matching upper bound for instance queries; Lutz (2008) gives the one for CQs. For the lower bound, CC is satisfiable with respect to T\mathcal T if and only if (T∪{A⊑C},{A(a)})(\mathcal T \cup \{A \sqsubseteq C\}, \{A(a)\}) is consistent for a new name AA, which holds if and only if aa is not a certain answer of N(x)N(x) for a new name NN. Two lower bounds have short proofs.

EL is P-hard in data complexity. Fix TH={∃first.True⊓∃second.True⊑Fired, ∃rule.Fired⊑True}\mathcal T_H = \{\exists \mathit{first}.\mathit{True} \sqcap \exists \mathit{second}.\mathit{True} \sqsubseteq \mathit{Fired},\ \exists \mathit{rule}.\mathit{Fired} \sqsubseteq \mathit{True}\}. For a set of propositional Horn clauses with at most two body atoms, let the ABox have True(p)\mathit{True}(p) for each fact pp, and for each clause c=(p←s∧t)c = (p \leftarrow s \wedge t) the facts rule(p,c)\mathit{rule}(p, c), first(c,s)\mathit{first}(c, s) and second(c,t)\mathit{second}(c, t), with s=ts = t for clauses with one body atom. If pp is derivable, then True(p)\mathit{True}(p) follows, by induction on the derivation. In the other direction, the interpretation with the individuals as domain, the ABox edges, True\mathit{True} the derivable variables and Fired\mathit{Fired} the clauses whose body atoms are derivable is a model of TH\mathcal T_H and the ABox. So pp is a certain answer of True(x)\mathit{True}(x) if and only if pp is derivable. Derivability in Horn logic is P-complete (Horn satisfiability), and the ABox is built in logarithmic space. The upper bound holds because an ABox can be written with nominals, {a}⊑A\{a\} \sqsubseteq A and {a}⊑∃r.{b}\{a\} \sqsubseteq \exists r.\{b\}, and subsumption in EL with nominals is polynomial (Baader, Brandt and Lutz 2005).

ALC is coNP-hard in data complexity. Fix T3={⊤⊑R⊔G⊔B, ∃s.D⊑F}∪{X⊓∃e.X⊑D:X∈{R,G,B}}\mathcal T_3 = \{\top \sqsubseteq R \sqcup G \sqcup B,\ \exists s.D \sqsubseteq F\} \cup \{X \sqcap \exists e.X \sqsubseteq D : X \in \{R, G, B\}\} and the instance query F(x)F(x). For a graph, let the ABox have e(u,v)e(u, v) for each edge and s(o,v)s(o, v) for each vertex vv, with a new individual oo. If the graph has a proper 3-coloring, the interpretation with the individuals as domain, each vertex in its color, oo in RR, and DD and FF empty is a model, so oo is not a certain answer. If it has none, in any model choose one color among RR, GG and BB for each vertex. Some edge (u,v)(u, v) gets the same color XX at both ends, so u∈X⊓∃e.X⊆Du \in X \sqcap \exists e.X \subseteq D, and then o∈∃s.D⊆Fo \in \exists s.D \subseteq F. So oo is a certain answer of F(x)F(x) if and only if the graph is not 3-colorable, which is coNP-complete.

Reductions

  • To consistency. For an instance query, a∈cert(A,T,A)a \in \mathrm{cert}(A, \mathcal T, \mathcal A) if and only if (T,A∪{¬A(a)})(\mathcal T, \mathcal A \cup \{\neg A(a)\}) is inconsistent. In ALC the assertion ¬A(a)\neg A(a) is allowed; in logics without negation use a new name Aˉ\bar A with A⊓Aˉ⊑⊥A \sqcap \bar A \sqsubseteq \bot.
  • From database query evaluation. With the empty TBox the certain answers are the answers over A\mathcal A as a database, so CQ evaluation, which is NP-complete in combined complexity by the Chandra-Merlin theorem, is a special case.
  • To query containment. A rewriting qTq_{\mathcal T} can be made smaller by deleting each CQ that is contained in another one, which is a query containment test.
  • To constraint satisfaction. Bienvenu, ten Cate, Lutz and Wolter (2014) related ontology-mediated queries with ALC TBoxes and UCQs to disjunctive Datalog and to constraint satisfaction problems, which transfers dichotomy results to data complexity.

Applications

  • Data access. Users ask queries in the words of a domain ontology, and the system rewrites them into SQL over existing databases through mappings. DL-Lite was designed for this setting.
  • Data integration. An ontology gives one view of several sources. Incomplete sources are read under the open world assumption, which is what certain answers express.
  • Large ontologies with data. In medicine and life sciences, EL ontologies classify records, and Datalog engines answer instance queries over them.

References

  1. Diego Calvanese, Giuseppe De Giacomo, Domenico Lembo, Maurizio Lenzerini and Riccardo Rosati, Tractable reasoning and efficient query answering in description logics, the DL-Lite family, Journal of Automated Reasoning 39(3), 2007, pages 385 to 429 (certain answers of conjunctive queries, FO-rewritability, the AC0 data complexity and the NP combined complexity for DL-Lite; general locator)
  2. Franz Baader, Sebastian Brandt and Carsten Lutz, Pushing the EL envelope, Proceedings of the 19th International Joint Conference on Artificial Intelligence (IJCAI), 2005, pages 364 to 369 (polynomial reasoning in EL with nominals, which covers instance checking over ABoxes)
  3. Ullrich Hustadt, Boris Motik and Ulrike Sattler, Data complexity of reasoning in very expressive description logics, Proceedings of the 19th International Joint Conference on Artificial Intelligence (IJCAI), 2005, the coNP data complexity of reasoning in SHIQ (general locator)
  4. Carsten Lutz, The complexity of conjunctive query answering in expressive description logics, Proceedings of the 4th International Joint Conference on Automated Reasoning (IJCAR), LNAI 5195, Springer, 2008, the 2EXPTIME combined complexity of conjunctive query answering in ALCI, and the EXPTIME upper bound for conjunctive queries over ALC (general locator)
  5. Meghyn Bienvenu, Balder ten Cate, Carsten Lutz and Frank Wolter, Ontology-based data access: a study through disjunctive Datalog, CSP, and MMSNP, ACM Transactions on Database Systems 39(4), 2014, ontology-mediated queries as pairs of an ontology and a query, and their relation to disjunctive Datalog and constraint satisfaction (general locator)
  6. Franz Baader, Ian Horrocks, Carsten Lutz and Ulrike Sattler, An Introduction to Description Logic, Cambridge University Press, 2017, the chapter on query answering (general locator)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml