<!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>Answering Expressive Conjunctive Queries over RDFS Knowledge Bases (Extended Abstract)</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Gianluca Cima</string-name>
          <email>cima@diag.uniroma1.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Marco Console</string-name>
          <email>console@diag.uniroma1.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Roberto Maria Delfino</string-name>
          <email>delfino@diag.uniroma1.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Maurizio Lenzerini</string-name>
          <email>lenzerini@diag.uniroma1.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Antonella Poggi</string-name>
          <email>poggi@diag.uniroma1.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Sapienza University of Rome</institution>
          ,
          <addr-line>via Ariosto 25, Rome</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2025</year>
      </pub-date>
      <abstract>
        <p>Answering conjunctive queries (CQs) equipped with basic forms of negation is a challenging task, which happens to be undecidable even for lightweight Description Logic (DL) ontologies. Interestingly, the DL counterpart of RDFS seems to be partially unafected by those negative results, even when equipped with disjointness axioms. This paper summarises our recent work on this subject, where we present a refined complexity analysis of answering CQs with inequality atoms and safe negation posed over such ontologies. We introduce a unified Π2 algorithm for the general case; we prove that two inequality atoms already lead to Π2-hardness, and we show similar results for the case of safe negation: answering CQs with one negated atom is in NP, but two negated atoms are enough to reach Π2-hardness. These results close key gaps in the literature and refine the complexity analysis of the query containment problem.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Query Answering</kwd>
        <kwd>DL Ontologies</kwd>
        <kwd>Negative conditions</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        in [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] for UCQs with inequality atoms only, providing a Π 2 upper bound in combined complexity and
a coNP upper bound in data complexity, where data complexity [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] concerns the case where only the
ABox is regarded as the input of the problem. We also provide a matching lower bound for the problem
of answering conjunctive queries with at most two inequality atoms, for which a matching lower bound
in data complexity was already known. We also show that our result afects the query containment
problem, previously proven Π 2-complete [
        <xref ref-type="bibr" rid="ref12 ref13">12, 13</xref>
        ], and studied under various syntactic and semantic
restrictions in [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. To our knowledge, only [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] examined the impact of bounding the number of
inequalities in the queries. That work showed NP-completeness when the containing query has at most
one inequality atom, matching the complexity of CQs [15]. Here, we complete the analysis by proving
that the problem remains Π 2-hard even when the containing and contained queries have one and two
inequality atoms, respectively. We also provide lower bounds for CQs with safe negations, showing
that they presents a behavior similar to that of CQs with inequality atoms, i.e., allowing for two safe
negations is enough to obtain Π 2-hardness. Finally, we present results for the case where the UNA
holds. We denote by CQ¬,̸= the language of conjunctive queries containing both safe negations and
inequality atoms, where a safe negation is a negated atom whose variables occur in at least one positive
atom, and an inequality atom is an atom of the form  ̸= ′, with  and ′ being either distinguished
variables, existential variables, or constants. We denote the language of conjunctive queries with at
most  negated atoms and no inequality atoms by CQ¬, , while the language of conjunctive queries
with at most  inequality atoms and no negated atoms is denoted by CQ̸= . We denote by UCQ the
language of unions of CQ, where  is a combination of the symbols denoting the presence of either
negations or inequality atoms.
      </p>
      <p>Definition 1. We denote by ans(ℒ, ) the problem of deciding, given  = ⟨ , ⟩ in the language ℒ, a
query  ∈  of arity , and an -tuple ¯ of constants occurring in , whether ¯ is an answer to  in every
model of .</p>
      <p>A local interpretation ℐ = ⟨∆ ℐ , · ℐ ⟩ w.r.t.  and  has its domain ∆ ℐ restricted to constants in the
ABox and in the query, and interpretations of concepts and roles not appearing in  and in  are empty.
It can be shown that ¯ ∈/ (, ), where (, ) is the set of certain answers to  w.r.t. , i.e.,
the set of answers satisfying  in every model of , if and only if there exists a local interpretation ℐ
w.r.t.  and  such that ℐ is a model of  and (1ℐ , ..., ℐ) ∈/ (ℐ). This suggests a nondeterministic
algorithm for deciding ¯ ∈/ (, ): guess a local interpretation ℐ and check if it is a model of  and
if ¯ ∈/ (, ). The size of ℐ is linear in the size of the input. Checking whether ℐ is a model of  is
feasible in AC0 in the size of ℐ, while checking whether ¯ ∈/ (ℐ) is feasible in NP. Thus, the overall
verification can be performed in NP.</p>
      <p>This approach leads to the following result.</p>
      <p>Theorem 1. The problem ans(DL-LiteR¬DFS, UCQ¬,̸=) is in Π 2 in combined complexity and in coNP in
data complexity.</p>
      <p>
        This provides an upper bound. Matching lower bounds regarding data complexity were known for
the case of two negated atoms [16] and two inequalities [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. In the following, we show that matching
lower bounds also hold for combined complexity for CQ¬,2 and CQ̸=2 .
      </p>
      <p>Theorem 2. The problem ans(DL-LiteRDFS, UCQ¬,2 ) is Π 2-hard in combined complexity and coNP-hard
in data complexity.</p>
      <p>This hardness result is obtained via a LogSpace reduction from ∀∃-CNF [17]. The reduction maps a
∀∃3CNF formula  to a DL-LiteR¬DFS ontology  and a Boolean UCQ¬  such that  |=  if and only
if  is true. The initial construction uses predicates of arity greater than two. However, the encoding
can be transformed into an equivalent one that uses only unary and binary predicates, thus complying
with the syntactic restrictions of DL-LiteR¬DFS. A similar result holds for the query language CQ¬,2 over
DL-LiteR¬DFS.</p>
      <p>Theorem 3. The problem ans(DL-LiteR¬DFS, CQ¬,2 ) is Π 2-hard in combined complexity and coNP-hard in
data complexity.</p>
      <p>The coNP-hardness comes from [16], while the Π 2-hardness is shown by an adaptation of the
reduction from ∀∃3CNF used for Theorem 2, involving a fixed TBox with disjointness assertions and
a slightly modified query and ABox construction. In contrast to the case of two negated atoms, the
complexity drops significantly when only one safe negation atom is allowed per disjunct. In particular,
ans(DL-LiteR¬DFS, UCQ¬,1 ) can be polynomially reduced to checking entailment of a ground atom for
a Datalog program  [18] that can be obtained by means of a transformation from an ontology , a
UCQ¬,1  and a tuple ¯, and is such that ¯ ∈ (, ) if and only if  entails a specific propositional
atom. Combining this property with the known Datalog complexity for predicates with bounded
arity [19, 20] results yield the following result.</p>
      <p>Theorem 4. The problem ans(DL-LiteR¬DFS, UCQ¬,1 ) is NP-complete in combined complexity and
Pcomplete in data complexity. The hardnesses already hold for ans(DL-LiteR¬DFS, CQ¬,1 ).</p>
      <p>Note that NP-hardness follows from the NP-hardness of evaluating CQs over relational databases [21],
while P-hardness in data complexity comes from [16].</p>
      <p>Regarding the case of queries containing inequalities, previous work thoroughly analysed the case of
UCQ̸=s over DL-LiteR¬DFS ontologies, but only conjectured the Π 2-hardness of ans(DL-LiteR¬DFS, UCQ̸=2 ).
The next result confirms the conjecture.</p>
      <p>Theorem 5. The problem ans(DL-LiteR¬DFS, CQ̸=2 ) is Π 2-hard in combined complexity.</p>
      <p>This is proved via a LogSpace reduction from ∀∃3CNF, similar to the safe negation cases. The
reduction constructs a DL-LiteR¬DFS ontology  and a Boolean CQ̸=2  from a ∀∃3CNF formula  such
that  |=  if and only if the formula  is true. The ontology simulates propositional assignments,
and the query structure checks for satisfiability.</p>
      <p>Interestingly, our results on hardness for the case of CQ̸=2 s have implications for the query
containment problem cont(, ′), which asks if () ⊆ ′() for all databases , with  ∈ , and ′ ∈ ′
for some query languages  and ′. Through Theorem 5 and a reduction from ontology-mediated
query answering to query containment for ontologies without role disjointness assertions, we provide
a tight complexity characterization based on the number of inequality atoms present in the queries.
Proposition 1. Let  = ⟨ , ⟩ be a DL-LiteR¬DFS ontology without role disjointness assertions. It is possible
to construct in polynomial time a Boolean CQ̸=  such that, for any Boolean CQ̸= :  |=  if and only
if  ⊑ .</p>
      <p>By combining the reduction used for Theorem 5 and Proposition 1, we obtained the following:
Theorem 6. The problem cont(CQ̸=1 , CQ̸=2 ) is Π 2-complete.</p>
      <p>
        This is a significant finding, as cont(CQ̸= , CQ̸= ) is NP-complete if  = 0 or  ≤ 1 [
        <xref ref-type="bibr" rid="ref10">15, 10</xref>
        ].
      </p>
      <p>Finally, we analysed the problem of query answering under the UNA. In this case, the decision problem
of interest is denoted by ansU(ℒ, ). The same Π 2 combined complexity and coNP data complexity
upper bounds as Theorem 1 hold for ansU(DL-LiteR¬DFS, UCQ¬,̸=) by using U-local interpretations, i.e.,
local interpretations under the UNA.</p>
      <p>Theorem 7. ansU(DL-LiteR¬DFS, UCQ¬,̸=) is in Π 2 in combined complexity and in coNP in data complexity.</p>
      <p>For UCQ¬ queries, DL-LiteR¬DFS is insensitive to the UNA, since it is a sub-logic of DL-Liteℛ, which is
insensitive to the UNA for CQ answering [22]. This allows us to derive that ans(, ) = ansU(, ),
where  is a DL-LiteR¬DFS, and  ∈ UCQ¬ . However, answering  ̸=s over DL-LiteR¬DFS is significantly
easier under the UNA, becoming tractable in data complexity.</p>
      <p>Theorem 8. ansU(DL-LiteR¬DFS, UCQ̸=) is NP-complete in combined complexity and in AC0 in data
complexity.</p>
      <p>We provided a thorough analysis of the complexity of answering queries with safe negation and
inequalities over DL-LiteR¬DFS ontologies, confirming its potential as a theoretical foundation for AI
systems based on KGs. We completed the picture of the complexity of answering CQs with fixed numbers
of inequality atoms by showing that, for CQ̸=2 , it is Π 2-hard, verifying a long-standing conjecture. We
showed that CQs with safe negation exhibit a similar complexity jump from one to two negated atoms.
These results provide tight complexity bounds and contribute to the understanding of query containment,
showing that cont(CQ̸=1 , CQ̸=2 ) is Π 2-complete. The decidability of ans(DL-Lite, CQ̸=) remains
an open problem. Our results suggest that answering UCQ¬,̸=s over DL-LiteR¬DFS can potentially be
implemented using systems designed for Π 2-complete problems, such as ASP solvers [23].</p>
    </sec>
    <sec id="sec-2">
      <title>Acknowledgments</title>
      <p>This work has been supported by MUR under the PNRR project FAIR (PE0000013).
This work has been carried out while Roberto Maria Delfino was enrolled in the Italian
National Doctorate on Artificial Intelligence run by Sapienza University of Rome.</p>
    </sec>
    <sec id="sec-3">
      <title>Declaration on Generative AI</title>
      <p>During the preparation of this work, the author(s) used OpenAI ChatGPT-4 in order to: Grammar and
spelling check; Paraphrase and reword. After using these tool(s)/service(s), the author(s) reviewed and
edited the content as needed and take(s) full responsibility for the publication’s content.
[15] A. K. Chandra, P. M. Merlin, Optimal implementation of conjunctive queries in relational data
bases, 1977, pp. 77–90.
[16] V. Gutiérrez-Basulto, Y. A. Ibáñez-García, R. Kontchakov, E. V. Kostylev, Queries with negation
and inequalities over lightweight ontologies 35 (2015) 184–202.
[17] L. J. Stockmeyer, The polynomial-time hierarchy, Theor. Comput. Sci. 3 (1976) 1–22.
[18] S. Ceri, G. Gottlob, L. Tanca, What you always wanted to know about datalog (and never dared to
ask) 1 (1989) 146–166.
[19] E. Dantsin, T. Eiter, G. Gottlob, A. Voronkov, Complexity and expressive power of logic
programming 33 (2001) 374–425.
[20] G. Gottlob, T. Schwentick, Rewriting ontological queries into small nonrecursive Datalog programs,
2011.
[21] S. Abiteboul, R. Hull, V. Vianu, Foundations of Databases, 1995.
[22] A. Artale, D. Calvanese, R. Kontchakov, M. Zakharyaschev, The DL-Lite Family and Relations,
Technical Report BBKCS-09-03, School of Computer Science and Information Systems, Birbeck
College, London, 2009. Available at http://www.dcs.bbk.ac.uk/research/techreps/2009/bbkcs-09-03.
pdf.
[23] V. Lifschitz, Answer Set Programming, Springer, 2019.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>A.</given-names>
            <surname>Khan</surname>
          </string-name>
          ,
          <source>Knowledge graphs querying 52</source>
          (
          <year>2023</year>
          )
          <fpage>18</fpage>
          -
          <lpage>29</lpage>
          . URL: https://doi.org/10.1145/3615952. 3615956. doi:
          <volume>10</volume>
          .1145/3615952.3615956.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>L.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Ding</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Wu</surname>
          </string-name>
          ,
          <article-title>Give us the facts: Enhancing large language models with knowledge graphs for fact-aware language modeling</article-title>
          ,
          <source>IEEE Transactions on Knowledge and Data Engineering</source>
          <volume>36</volume>
          (
          <year>2024</year>
          )
          <fpage>3091</fpage>
          -
          <lpage>3110</lpage>
          . doi:
          <volume>10</volume>
          .1109/TKDE.
          <year>2024</year>
          .
          <volume>3360454</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>S.</given-names>
            <surname>Pan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Luo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Wu</surname>
          </string-name>
          ,
          <article-title>Unifying large language models and knowledge graphs: A roadmap</article-title>
          ,
          <source>IEEE Transactions on Knowledge and Data Engineering</source>
          <volume>36</volume>
          (
          <year>2024</year>
          )
          <fpage>3580</fpage>
          -
          <lpage>3599</lpage>
          . doi:
          <volume>10</volume>
          .1109/TKDE.
          <year>2024</year>
          .
          <volume>3352100</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>F.</given-names>
            <surname>Baader</surname>
          </string-name>
          , I. Horrocks,
          <string-name>
            <given-names>C.</given-names>
            <surname>Lutz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Sattler</surname>
          </string-name>
          , An Introduction to Description Logic,
          <year>2017</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>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Rosati</surname>
          </string-name>
          ,
          <article-title>Tractable reasoning and eficient query answering in description logics: The DL-Lite family 39 (</article-title>
          <year>2007</year>
          )
          <fpage>385</fpage>
          -
          <lpage>429</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>M.</given-names>
            <surname>Bienvenu</surname>
          </string-name>
          ,
          <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>
          , volume
          <volume>9203</volume>
          ,
          <year>2015</year>
          , pp.
          <fpage>218</fpage>
          -
          <lpage>307</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>B.</given-names>
            <surname>Cuenca Grau</surname>
          </string-name>
          ,
          <article-title>A possible simplification of the semantic web architecture</article-title>
          ,
          <year>2004</year>
          , pp.
          <fpage>704</fpage>
          -
          <lpage>713</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>R.</given-names>
            <surname>Rosati</surname>
          </string-name>
          ,
          <article-title>The limits of querying ontologies</article-title>
          , volume
          <volume>4353</volume>
          ,
          <year>2007</year>
          , pp.
          <fpage>164</fpage>
          -
          <lpage>178</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>G.</given-names>
            <surname>Cima</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Poggi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Lenzerini</surname>
          </string-name>
          ,
          <article-title>The notion of abstraction in ontology-based data management 323 (</article-title>
          <year>2023</year>
          )
          <fpage>103976</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>G.</given-names>
            <surname>Cima</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Lenzerini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Poggi</surname>
          </string-name>
          ,
          <article-title>Answering conjunctive queries with inequalities in DL-Lite</article-title>
          ,
          <year>2020</year>
          , pp.
          <fpage>2782</fpage>
          -
          <lpage>2789</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>M. Y.</given-names>
            <surname>Vardi</surname>
          </string-name>
          ,
          <article-title>The complexity of relational query languages (extended abstract</article-title>
          ),
          <year>1982</year>
          , pp.
          <fpage>137</fpage>
          -
          <lpage>146</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>A. C.</given-names>
            <surname>Klug</surname>
          </string-name>
          ,
          <article-title>On conjunctive queries containing inequalities</article-title>
          ,
          <source>J. ACM</source>
          <volume>35</volume>
          (
          <year>1988</year>
          )
          <fpage>146</fpage>
          -
          <lpage>160</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <surname>R. van der Meyden</surname>
          </string-name>
          ,
          <article-title>The complexity of querying indefinite data about linearly ordered domains</article-title>
          ,
          <source>J. Comput. Syst. Sci</source>
          .
          <volume>54</volume>
          (
          <year>1997</year>
          )
          <fpage>113</fpage>
          -
          <lpage>135</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>P. G.</given-names>
            <surname>Kolaitis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. L.</given-names>
            <surname>Martin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. N.</given-names>
            <surname>Thakur</surname>
          </string-name>
          ,
          <article-title>On the complexity of the containment problem for conjunctive queries with built-in predicates</article-title>
          ,
          <year>1998</year>
          , pp.
          <fpage>197</fpage>
          -
          <lpage>204</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>