<!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>
      <journal-title-group>
        <journal-title>DL</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Towards Practicable Algorithms for Rewriting Graph Queries beyond DL-Lite (Extended Abstract)</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Bianca Löhnert</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nikolaus Augsten</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Cem Okulmus</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Magdalena Ortiz</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Paris-Lodron University of Salzburg</institution>
          ,
          <country country="AT">Austria</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>TU Wien</institution>
          ,
          <country country="AT">Austria</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Umeå University</institution>
          ,
          <country country="SE">Sweden</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2024</year>
      </pub-date>
      <volume>37</volume>
      <fpage>18</fpage>
      <lpage>21</lpage>
      <abstract>
        <p>Despite the many advantages that ontology-based data access (OBDA) has brought to a range of application domains, state-of-the-art OBDA systems still do not support popular graph database management systems such as Neo4j. Algorithms for query rewriting focus on languages like conjunctive queries and their unions, which are fragments of first-order logic and were developed for relational data. Such query languages are poorly suited for querying graph data. Moreover, they also limit the expressiveness of the ontology languages that admit rewritings, restricting them to those where the data complexity of reasoning is not higher than it is in first-order logic. In this paper, we propose a technique for rewriting a family of navigational queries for a suitably restricted fragment of ℰℒℋℐ that extends DL-Lite and that is NL-complete in data complexity. We implemented a proof-of-concept prototype that rewrites into Cypher queries, and tested it on a real-world cognitive neuroscience use case with promising results.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>standard for extending C2RPQs, are NL complete in data complexity (under the so-called walk
semantics). This means that we are not bound to DL-Lite and can attempt query rewriting for
richer ontology languages, provided that they have NL data complexity.</p>
      <p>
        Contributions This extended abstract summarizes the following results, described in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
• We prove the existence of C2RPQs that cannot be rewritten into a union of C2RPQs (UC2RPQs)
which captures all consequences from the ontology, even it the ontology is restricted to one
axiom ∃ ⊑ ∃ for role names , . Motivated by this negative result, we define Navigational
Conjunctive Queries (NCQs), a subset of C2RPQs (similar to [
        <xref ref-type="bibr" rid="ref5">5, 6</xref>
        ]) which admits such rewritings.
• We propose such a rewriting for OMQs that pair NCQs with ontologies in a language that
, tailored to extend DL-Lite with some features of ℰ ℒℋℐ while keeping the
we call ℰ ℒℋℐ⊥
data complexity of standard reasoning in NL. We first show how to construct a graph structure
whose paths witness all the relevant entailments of the input ontology, and then use this graph
to rewrite atomic queries into C2RPQs. Then we combine this with the ideas behind the Clipper
 ontologies into UC2RPQs.
rewriting [7] to obtain a rewriting of NCQ mediated by ℰ ℒℋℐ⊥
• We present a proof-of-concept prototype of our technique and use it to evaluate queries over
data from a real-world use case in the domain of cognitive neuroscience.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Query Rewriting Algorithm for Navigational Queries</title>
      <p>TBoxes, that have axioms of the form (NF1)  ⊑ ,
For our algorithm we consider ℰ ℒℋℐ⊥
(NF2) ∃. ⊑ , (NF3)  ⊑ ∃., (NF4)  ⊑ , (NF5) ∃− .⊤ ⊑ , or (NF6)  ⊑ ∃− .⊤.</p>
      <p>
        In Navigational Conjunctive Queries (NCQs), atoms take the form (︀ 1 ∪ · · · ∪ )︀ () or
︀(  1 ∪ · · · ∪  )︀ (, ) or (︀  1 ∪ · · · ∪  )︀ * (, ), with  a concept name and each   a restricted
regular path expression   :=  | − | * | (− )* . As a first step towards our query rewriting
 TBoxes.
algorithm, we introduce the so-called concept dependency graph for ℰ ℒℋℐ⊥
Concept Dependency Graph As the name suggests the concept dependency graph (CDG)
depicts the dependencies of concepts of a given TBox. The nodes of the CDG represent concepts
and for axioms in form of (NF1), e.g.,  ⊑  we add an edge pointing from  to  with the
empty label . In case of an existential restriction on the left-hand side as in (NF2) or (NF5)
we additionally label this edge with the role name. In order to make the construction of the
CDG complete for TBox reasoning we extend it with additional edges and witnessing nodes
for axioms with existential quantifiers on the right-hand side, i.e., (NF3) and (NF6). Having
all these edges in place it is possible to check for TBox entailments. More precisely, it holds
that  |= ∃1 . . . ∃. ⊑  if and only if there is a path from  to  with a sequence of edge
labels 1, . . . ,  (possibly interleaved with -labeled edges) such that  ⊑*  for 1 ≤  ≤ .
Note that, in particular, this means that  |=  ⊑  if there is a path from  to  with  labels
only. We illustrate these properties of the CDG in the example below. For a formal definition of
concept dependency graphs see [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>Example 1. For the TBox  = {2 ⊑ 1, ∃.1 ⊑ 1, ∃3.1 ⊑ 3, 3 ⊑ 2, ∃1.2 ⊑ 1,
∃2− .⊤ ⊑ 3,  ⊑ 2, ∃2.3 ⊑ 2, 1 ⊑ ∃2.3} the CDG  is as in Figure 1. The presence
of paths in the CDG corresponds to concept inclusions that hold in  . We illustrate this on
an ABox  = {1(1, 2), 2(2, 3), 3(3, 4), 1(4, 5), 2(5)}. Since there is the path
3
2
3
1
start
3
2
12 1 1 2</p>
      <p>r

1
3
2</p>
      <p>⊤

⊤
3
2−
2 1 1</p>
      <p>1
2
3
3 ∃2
 ∃2.</p>
      <p>3
 2

 3
2−</p>
      <p>⊤
112233112 in the CDG of  it follows for 1 that  ,  |= 1(1). However, as
we mentioned before, we can use the CDG to check for TBox entailments, i.e, from the path
112233112 we can infer that  |= ∃1∃2∃3∃1.2 ⊑ 1. The construction of the
 entailment from  with a concept name on
CDG is complete, in the sense that for every ℰ ℒℋℐ⊥
the right-hand side there exists a corresponding path in the CDG of  .</p>
      <p>Extracting regular path expressions. Given a CDG  and a concept  in  , we construct
an NFA A () that accepts the propagating paths in  which start at node  and end in

another concept while passing over only roles or , as illustrated in Example 2. We then use an
of-the-shelf technique to transform this NFA into a regular expression, and finally we eliminate
all occurrences of  from this regular expression.</p>
      <p>Example 2. For the CDG from Example 1, we can see its 1-path-generating NFA in Figure 2.</p>
      <p>paths ending in 1 paths ending in 2 paths ending in 3
The extracted RPE is: (︀ (⏞(1 ∪ (123))* 1) ∪ ⏞(1+(231+)* 2) ∪ (⏞1+2(31+2)* 3) ︀) .</p>
      <p>
        ⏟ ⏟ ⏟
Rewriting Atomic Queries Into Regular Path Expressions We replace each  in a given
input of the form (︀ 1 ∪ · · · ∪ )︀ () with the regular expression described above. Then we
replace each role  in the regular path expression with a union over all roles  such that  ⊑* .
Rewriting NCQs into UC2RPQs Given a NCQ (⃗) and an ℰ ℒℋℐ⊥ TBox  , we
exhaustively apply the so-called clipping function, inspired by [7]. It relies on a well-known property
of ℰ ℒℋℐ: for each  and  there is a universal, forest-shaped model ℐ that can be used for
answering all C2RPQs. Intuitively, we consider each possible set  of variables that may be
mapped to the same ‘anonymous’ object  of maximal depth in a tree structure of ℐ. We know
that each such  is introduced to satisfy an existential axiom  ⊑ ∃., that is, it has a parent
 that satisfies , and  is created as an -child of  that is . Exploiting this, we can ‘remove’
from the query the parts that are guaranteed to be locally satisfied using ’s -child . This idea
has been applied to variants of (U)CQs [7], where each application must only remove the query
atoms that are locally satisfied. But in navigational queries we must consider also how path
expressions can be partially satisfied, and modify the expressions in the atoms accordingly. E.g.,
given () = (* ∪ * )(, ), () and  = { ⊑ ∃.}, a possible application of clipping
returns ′() = * (, ), (). Note that * ∪ * is replaced by * , reflecting the fact that an *
path to an  can always be extended to an * path to a  in the models of  , but this does not
apply to the * paths. We show in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] that for every query mapping there is an application of
clipping that results in a rewritten query whose mappings have a strictly lower depth (as at
least one variable is now mapped to  instead of its child ), but remain unchanged otherwise.
      </p>
      <p>By clipping exhaustively, iterating over all sets  of variables in  and all axioms in  of the
form  ⊑ ∃. and  ⊑ ∃− .⊤, and taking each result as a disjunct in a union of NCQs, we
obtain a query that has the same answers as the original NCQ, but whose variables are mapped
to ABox individuals only. We can then apply the rewriting of atomic queries into regular path
expressions described above, and obtain a sound and complete rewriting of NCQs mediated by
 ontologies into UC2RPQs .
ℰ ℒℋℐ⊥</p>
    </sec>
    <sec id="sec-3">
      <title>3. Implementation and Experiments</title>
      <p>TBox (in OWL
We implemented a proof-of-concept prototype [8] that, given an ℰ ℒℋℐ⊥
syntax), rewrites NCQs into UC2RPQs and translates them into Cypher. We execute the
experiments on a machine running Ubuntu 22.04.4 with an Intel Core i7-6700HQ CPU clocked
at 2.60 GHz and 8 GB RAM; with Neo4j 5.18.1 running on it. As TBox (OWL ontology) we use
the Cognitive Task Ontology (COGITO) [9], which includes about 9000 axioms describing 4700
concepts used for annotating experimental data [10]. For example, the axiom ReadingTask ⊑
(∃has.Read ⊓ ∃has.Language-item) defines a reading task by referring to the Hierarchical Event
Descriptors (HEDs) Read and Language-item [11]. COGITO includes axioms that are not in
 since they use conjunction on the left side (e.g., the converse of the ReadingTask axiom
ℰ ℒℋℐ⊥
above). Hence, to make our experimental evaluation more faithful to COGITO, we consider
two ontologies: (1) in 1 we drop the axioms with conjunction on the left-hand side, and (2)
in 2 we replace these conjunctions by disjunctions. We are currently working on inferring
the exact answers over COGITO from these over- and under-approximations. We chose a
real-world dataset from the domain of cognitive neuroscience [12], stored in a Neo4j database
and consisting of 15 512 nodes and 78 113 relationships. For our experiments, we manually
created 8 queries, structurally similar to those in [12], and applied our rewriting technique. The
rewritten queries were evaluated using Cypher.1 We report our results in Table 1.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>We presented an algorithm for rewriting NCQs into UC2RPQs over a lightweight ontology that
extends DL-Lite with some of the expressive features of ℰ ℒℋ while keeping the data complexity
of reasoning in NL. One of our goals is to make progress towards a practicable algorithm, and
our prototype implementation, which rewrites the queries into Cypher, suggests that we may
be on track. It shows promising results on a real-world dataset from cognitive neuroscience.</p>
    </sec>
    <sec id="sec-5">
      <title>Acknowledgements</title>
      <p>This work was partially supported by the Federal State of Salzburg under grant number
20102F2101143-FPR (Digital Neuroscience Initiative) and the Austrian Federal Ministry of Education,
Science and Research (BMBWF) under grant number 2920 (Austrian NeuroCloud). This work
was also partially supported by the Wallenberg AI, Autonomous Systems and Software Program
(WASP) funded by the Knut and Alice Wallenberg Foundation.
1The selected queries happen to be insensitive to the trail semantics (implemented in Cypher) vs. the walk semantics.
[6] N. Dragovic, Querying Property Graphs with Ontologies, Master’s thesis, TU Wien, 2022.
[7] T. Eiter, M. Ortiz, M. Simkus, T. Tran, G. Xiao, Query rewriting for Horn-SHIQ plus rules,
in: J. Hofmann, B. Selman (Eds.), Proceedings of the Twenty-Sixth AAAI Conference on
Artificial Intelligence, July 22-26, 2012, Toronto, Ontario, Canada, AAAI Press, 2012, pp.
726–733. URL: http://www.aaai.org/ocs/index.php/AAAI/AAAI12/paper/view/4931.
[8] N. Dragovic, B. Löhnert, Ontology-mediated querying for property graphs, 2022. URL:
https://gitlab.com/ccns/neurocog/neurodataops/anc/software/owl2cypher, accessed:
202405-24.
[9] B. Löhnert, B. Engler, F. Hutzler, Cognitive task ontology (COGITO), 2024. URL: https:
//gitlab.com/ccns/neurocog/neurodataops/anc/classification/cogito/, accessed: 2024-05-24.
[10] R. A. Poldrack, A. Kittur, D. J. Kalar, E. Miller, C. Seppa, Y. Gil, D. S. Parker, F. W. Sabb, R. M.</p>
      <p>Bilder, The cognitive atlas: Toward a knowledge foundation for cognitive neuroscience,
Frontiers Neuroinformatics 5 (2011) 17. doi:10.3389/fninf.2011.00017.
[11] K. Robbins, D. Truong, S. Appelhof, A. Delorme, S. Makeig, Capturing the nature of
events and event context using hierarchical event descriptors (hed), NeuroImage 245 (2021)
118766.
[12] A. Ravenschlag, M. Denissen, B. Löhnert, M. Pawlik, N. A. Himmelstoß, F. Hutzler, Efective
queries for mega-analysis in cognitive neuroscience, in: G. Fletcher, V. Kantere (Eds.),
Proceedings of the Workshops of the EDBT/ICDT 2023 Joint Conference, Ioannina, Greece,
March, 28, 2023, volume 3379 of CEUR Workshop Proceedings, CEUR-WS.org, 2023. URL:
https://ceur-ws.org/Vol-3379/CoMoNoS_2023_id252_Mateusz_Pawlik.pdf.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>G.</given-names>
            <surname>Xiao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Ding</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Cogrel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Calvanese</surname>
          </string-name>
          ,
          <article-title>Virtual knowledge graphs: An overview of systems and use cases</article-title>
          ,
          <source>Data Intell</source>
          .
          <volume>1</volume>
          (
          <year>2019</year>
          )
          <fpage>201</fpage>
          -
          <lpage>223</lpage>
          . URL: https://doi.org/10.1162/dint_a_ 00011. doi:
          <volume>10</volume>
          .1162/DINT\_A\_
          <volume>00011</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>D.</given-names>
            <surname>Calvanese</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. D.</given-names>
            <surname>Giacomo</surname>
          </string-name>
          ,
          <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</article-title>
          ,
          <source>Journal of Automated Reasoning</source>
          <volume>39</volume>
          (
          <year>2007</year>
          )
          <fpage>385</fpage>
          -
          <lpage>429</lpage>
          . doi:
          <volume>10</volume>
          .1007/s10817-007-9078-x.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>N.</given-names>
            <surname>Francis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gheerbrant</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Guagliardo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Libkin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Marsault</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Martens</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Murlak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Peterfreund</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Rogova</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Vrgoc</surname>
          </string-name>
          ,
          <article-title>A researcher's digest of GQL (invited talk)</article-title>
          , in: F.
          <string-name>
            <surname>Geerts</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          Vandevoort (Eds.),
          <source>26th International Conference on Database Theory, ICDT 2023, March 28-31</source>
          ,
          <year>2023</year>
          , Ioannina, Greece, volume
          <volume>255</volume>
          of LIPIcs, Schloss Dagstuhl - LeibnizZentrum
          <source>für Informatik</source>
          ,
          <year>2023</year>
          , pp.
          <volume>1</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>1</lpage>
          :
          <fpage>22</fpage>
          . doi:
          <volume>10</volume>
          .4230/LIPIcs.ICDT.
          <year>2023</year>
          .
          <volume>1</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>B.</given-names>
            <surname>Löhnert</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Augsten</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Okulmus</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ortiz</surname>
          </string-name>
          ,
          <article-title>Towards practicable algorithms for rewriting graph queries beyond dl-lite -</article-title>
          full version,
          <year>2024</year>
          . URL: https://arxiv.org/abs/2405.18181, accessed:
          <fpage>2024</fpage>
          -06-04.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>N.</given-names>
            <surname>Dragovic</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Okulmus</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ortiz</surname>
          </string-name>
          ,
          <article-title>Rewriting ontology-mediated navigational queries into cypher</article-title>
          , in: O.
          <string-name>
            <surname>Kutz</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Lutz</surname>
            ,
            <given-names>A</given-names>
          </string-name>
          . Ozaki (Eds.),
          <source>Proceedings of the 36th International Workshop on Description Logics (DL</source>
          <year>2023</year>
          )
          <article-title>co-located with the 20th</article-title>
          <source>International Conference on Principles of Knowledge Representation and Reasoning and the 21st International Workshop on Non-Monotonic Reasoning (KR 2023 and NMR</source>
          <year>2023</year>
          ).,
          <string-name>
            <surname>Rhodes</surname>
          </string-name>
          , Greece, September 2-
          <issue>4</issue>
          ,
          <year>2023</year>
          , volume
          <volume>3515</volume>
          <source>of CEUR Workshop Proceedings, CEUR-WS.org</source>
          ,
          <year>2023</year>
          . URL: https://ceur-ws.
          <source>org/</source>
          Vol-
          <volume>3515</volume>
          /paper-9.pdf.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>