<!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>A Datalog-Based Language for Querying RDF Graphs?</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Marcelo Arenas</string-name>
          <email>marenas@ing.puc.cl</email>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Georg Gottlob</string-name>
          <email>georg.gottlob@cs.ox.ac.uk</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andreas Pieris</string-name>
          <email>pieris@dbai.tuwien.ac.at</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science, University of Oxford</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Institute of Information Systems, Vienna University of Technology</institution>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Pontificia Universidad Cato ́lica de Chile</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>RDF is the W3C recommendation data model to represent information about World Wide Web resources, while SPARQL is the standard language for querying RDF data, since its standardization in 2008. One of the distinctive features of Semantic Web data is the existence of vocabularies with predefined semantics: the RDF Schema (RDFS) and the Web Ontology Language (OWL), which can be used to derive logical conclusions from RDF graphs; hence, an RDF query language equipped with reasoning capabilities to deal with these vocabularies is desirable. In addition, navigational capabilities are vital for data models with an explicit graph structure such as RDF [1, 3, 9, 15], while recursive definitions are a key feature for graph query languages [5, 14]. Having an RDF query language available that combines the above key functionalities is of paramount importance for the development of the Semantic Web. This has been recognized by the W3C, which led to the release of SPARQL 1.1 in 2013 [10, 12], that is, an extended version of the 2008 language with reasoning capabilities to deal with RDFS and OWL vocabularies, and a mechanism to express navigation patterns through regular expressions. However, there are still useful queries that cannot be expressed in SPARQL 1.1, due to the lack of general recursion [14]. To the best of our knowledge, the only language that supports the above features, focussing on the profile OWL 2 QL of OWL 2, while its query evaluation problem is tractable in data complexity, is the recently introduced rule-based language TriQ-Lite, the lite version of the highly expressive triple query (TriQ) language [2]. This language is based on Datalog9;:s;?, that is, Datalog extended with existential quantification in rule-heads, stratified negation, and negative constraints with the falsum (?) in ruleheads. Unfortunately, TriQ-Lite suffers from a serious drawback, which may revoke its advantage as an expressive RDF query language, namely it is not a plain language. A query language is called plain if it allows the user to write a query as a single program in a simple non-composite syntax. An example of a plain query language is Datalog, where the user simply needs to define a single Datalog program that captures the intended query. The property of plainness provides conceptual simplicity, which is considered to be a key condition for a query language to be useful in practice. Although TriQ-Lite is based on an extension of Datalog, the way its syntax and semantics are defined significantly deviates from the standard way of defining Datalog-like languages, and thus does not inherit the plainness of Datalog. In fact, TriQ-Lite is a composite language, where the user is forced to split the query in several modules 1; : : : ; n so that each i can be expressed by the fragment of Datalog9;:s;? that is underlying TriQ-Lite, while each pair ( i; i+1) is bridged via a set Qi of conjunctive queries.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        ? This short paper is based on the recent works [
        <xref ref-type="bibr" rid="ref11 ref2">2, 11</xref>
        ].
      </p>
      <p>From the above discussion, we conclude that an RDF query language that fulfills
certain desiderata, which in turn guarantee its applicability in real Semantic Web
applications, is currently missing. These desiderata are the following:
1. Plainness: simple syntax and semantics, with the aim of simplifying the definition
of queries;
2. Reasoning Capabilities: express every SPARQL query under the entailment regime
for OWL 2 QL;
3. Recursive Definitions: general form of recursion must be supported, and ideally</p>
      <p>Datalog must be incorporated;
4. Efficiency: query evaluation must be data tractable, and feasible by the use of
standard database technology.</p>
      <p>
        At this point, we would like to expose an additional (conceptual) shortcoming of
SPARQL 1.1, which must be taken into account during the designing of an RDF query
language. Under the OWL 2 direct semantics entailment regime, the evaluation of a
basic graph pattern over an RDF graph adopts the so-called active domain semantics,
i.e., it uses the notion of entailment in OWL 2 QL, but allowing variables and blank
nodes to take only values from the RDF graph. As discussed in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], this forces the
user to encode part of the reasoning in the actual query, which undoubtedly leads to
unnatural and complex queries. This is illustrated in the following example:
Example 1. Consider the OWL 2 QL ontology O which states that Tom is a person and
each person has a father, and let G be the RDF graph that represents O. Assume that we
want to retrieve the elements of G that have a father. One may be tempted to claim that
this query can be expressed via the graph pattern P = (?X; father; B), where B is a
blank node. However, the answer to P over G is empty since there are no elements a; b
in G such that the triple (a; father; b) is implied by the ontology. To obtain the expected
answer, we have to consider the graph pattern (?X; rdf:type; 9father), which means that
we are forced to implicitly encode the fact that the triple (Tom; rdf:type; 9father) is
inferred by the ontology.
      </p>
      <p>Notably, TriQ-Lite provides the definition of the more natural entailment regime
without the active domain restriction. This is certainly an additional desideratum:
5. Reasoning-Query Decoupling: the entailment regime without the active domain
restriction must be definable in order to decouple the reasoning from the query.</p>
      <p>
        In this work, we focus on TriQ-Lite, which is a language in evolution, and we
investigate how it can be transformed into a plain language without sacrificing any of
the other desiderata. The outcome of our study is TriQ-Lite 1:0, the new version of
TriQ-Lite, which is based on Datalog9;:sg;?; we use the superscript :sg (instead of :s)
since, for our purposes, it suffices to focus on negation that, apart from being stratified,
is also grounded, i.e., it can be used with predicates that can only store constants. The
proposed formalism is part of Datalog , that is, a family of logical KR languages [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
Although several interesting Datalog languages can be found in the literature (see,
e.g., [
        <xref ref-type="bibr" rid="ref13 ref16 ref4 ref6 ref8">4, 6, 8, 13, 16</xref>
        ]), none of them fulfills all desiderata. Even though Datalog
languages inherit the plainness of Datalog, either they are not expressive enough for
satisfying desiderata 2, 3 and 5, or very expressive and thus intractable. Hence, our key
      </p>
      <p>Desideratum How it is Achieved
Plainness Standard Datalog-like language
Reasoning capabilities 9-quantification and ? in rule-heads
Recursive definitions Incorporate full Datalog:s
Efficiency Reduction to UCQ evaluation
Reasoning-Query Expressive joins in rule-bodies, and
decoupling 9-quantification in rule-heads
challenge was to define a Datalog language that achieves the right balance between
expressivity and complexity.</p>
      <p>Contribution. We propose a new syntactic paradigm, which is underlying TriQ-Lite 1:0,
called wardedness, that can be informally described as follows: all the dangerous
bodyvariables, i.e., variables that may be bound by the program to non-constant values, and
at the same time are propagated to the rule-head, occur in exactly one body-atom, called
ward, that can interact with the rest of the rule-body only via harmless join variables,
i.e., variables that are bound by the program to database constants. For example, the
program , where the dangerous variables are the variables marked by tilde,
triple(X~ ; U; Y~ ); inv (U; V ) ! triple(Y~ ; V; X~ )</p>
      <p>type(X~ ; Y ); rest (Y; U ) ! 9Z triple(X~ ; U; Z)
triple(X~ ; U; Y ); rest (Z; U ) ! type(X~ ; Z)
is warded; for each rule, all the tilde variables occur in a single body-atom a, while all
the other variables of a are harmless.</p>
      <p>
        Our technical results can be summarized as follows (for details see [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]):
- We introduce TriQ-Lite 1:0, which is based on warded Datalog9;:sg;?, and show
that it fulfills all desiderata; the technical reasons are given in Table 1.
- We show that for the reasoning-query decoupling, apart from expressive joins among
body-variables that are bound to non-constant values (this exposes one of the main
limitations of the language underlying TriQ-Lite), it is vital to allow for
existentially quantified variables in rule-heads.
- We provide a formal justification for the necessity of introducing a new
Datalogbased formalism. We establish, via a model-theoretic argument, that existing tractable
formalisms are not able to encode the OWL 2 direct semantics entailment regime,
and at the same time ensure the reasoning-query decoupling.
- Finally, we substantiate the design choices made in the definition of our formalism.
      </p>
      <p>In fact, we show that very mild extensions lead to EXPTIME-hardness.</p>
      <p>Let us say that warded Datalog9;:sg;?, the formalism underlying TriQ-Lite 1:0, is
well-suited as a general-purpose KR language, since it extends Datalog with features
that allow us to express OWL 2 QL and OWL 2 RL ontologies.</p>
      <p>Acknowledgements. Arenas is funded by the Millenium Nucleus Center for Semantic
Web Research under grant NC120004. Gottlob is supported by the EPSRC Programme
Grant EP/M025268/ “VADA: Value Added Data Systems – Principles and
Architecture”. Pieris is supported by the Austrian Science Fund (FWF), projects P25207-N23
and Y698, and Vienna Science and Technology Fund (WWTF), project ICT12-015.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Alkhateeb</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Baget</surname>
            ,
            <given-names>J.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Euzenat</surname>
          </string-name>
          , J.:
          <article-title>Extending SPARQL with regular expression patterns (for querying RDF)</article-title>
          .
          <source>J. Web Sem</source>
          .
          <volume>7</volume>
          (
          <issue>2</issue>
          ),
          <fpage>57</fpage>
          -
          <lpage>73</lpage>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Arenas</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gottlob</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pieris</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Expressive languages for querying the semantic web</article-title>
          .
          <source>In: PODS</source>
          . pp.
          <fpage>14</fpage>
          -
          <lpage>26</lpage>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Arenas</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gutierrez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          , Pe´rez, J.:
          <article-title>Foundations of RDF databases</article-title>
          .
          <source>In: RW</source>
          . pp.
          <fpage>158</fpage>
          -
          <lpage>204</lpage>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Baget</surname>
            ,
            <given-names>J.F.</given-names>
          </string-name>
          , Lecle`re,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Mugnier</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.L.</given-names>
            ,
            <surname>Salvat</surname>
          </string-name>
          , E.:
          <article-title>On rules with existential variables: Walking the decidability line</article-title>
          .
          <source>Artif. Intell</source>
          .
          <volume>175</volume>
          (
          <issue>9-10</issue>
          ),
          <fpage>1620</fpage>
          -
          <lpage>1654</lpage>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5. Barcelo´,
          <string-name>
            <surname>P.</surname>
          </string-name>
          :
          <article-title>Querying graph databases</article-title>
          .
          <source>In: PODS</source>
          . pp.
          <fpage>175</fpage>
          -
          <lpage>188</lpage>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. Cal`ı,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Gottlob</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            ,
            <surname>Kifer</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          :
          <article-title>Taming the infinite chase: Query answering under expressive relational constraints</article-title>
          .
          <source>J. Artif. Intell. Res</source>
          .
          <volume>48</volume>
          ,
          <fpage>115</fpage>
          -
          <lpage>174</lpage>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. Cal`ı,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Gottlob</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            ,
            <surname>Lukasiewicz</surname>
          </string-name>
          ,
          <string-name>
            <surname>T.</surname>
          </string-name>
          :
          <article-title>A general Datalog-based framework for tractable query answering over ontologies</article-title>
          .
          <source>J. Web Sem</source>
          .
          <volume>14</volume>
          ,
          <fpage>57</fpage>
          -
          <lpage>83</lpage>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8. Cal`ı,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Gottlob</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            ,
            <surname>Pieris</surname>
          </string-name>
          ,
          <string-name>
            <surname>A.</surname>
          </string-name>
          :
          <article-title>Towards more expressive ontology languages: The query answering problem</article-title>
          .
          <source>Artif. Intell</source>
          .
          <volume>193</volume>
          ,
          <fpage>87</fpage>
          -
          <lpage>128</lpage>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Fionda</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gutierrez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          , Pirro`, G.:
          <article-title>Semantic navigation on the web of data: specification of routes, web fragments and actions</article-title>
          .
          <source>In: WWW</source>
          . pp.
          <fpage>281</fpage>
          -
          <lpage>290</lpage>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Glimm</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ogbuji</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>SPARQL 1.1 entailment regimes (</article-title>
          <year>2013</year>
          ),
          <source>w3C Recommendation 21 March</source>
          <year>2013</year>
          , http://www.w3.org/TR/sparql11-entailment/
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Gottlob</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pieris</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Beyond SPARQL under OWL 2 QL entailment regime: Rules to the rescue</article-title>
          .
          <source>In: IJCAI</source>
          . pp.
          <fpage>2999</fpage>
          -
          <lpage>3007</lpage>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Harris</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Seaborne</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>SPARQL 1.1 query language (</article-title>
          <year>2013</year>
          ),
          <source>w3C Recommendation 21 March</source>
          <year>2013</year>
          , http://www.w3.org/TR/sparql11-query/
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Leone</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Manna</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Terracina</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Veltri</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Efficiently computable Datalog9 programs</article-title>
          .
          <source>In: KR</source>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Libkin</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Reutter</surname>
            ,
            <given-names>J.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vrgoc</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>Trial for RDF: adapting graph query languages for RDF data</article-title>
          .
          <source>In: PODS</source>
          . pp.
          <fpage>201</fpage>
          -
          <lpage>212</lpage>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15. Pe´rez, J.,
          <string-name>
            <surname>Arenas</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gutierrez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>nSPARQL: a navigational language for RDF</article-title>
          .
          <source>J. Web Sem</source>
          .
          <volume>8</volume>
          (
          <issue>4</issue>
          ),
          <fpage>255</fpage>
          -
          <lpage>270</lpage>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Thomazo</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Baget</surname>
            ,
            <given-names>J.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mugnier</surname>
            ,
            <given-names>M.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rudolph</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>A generic querying algorithm for greedy sets of existential rules</article-title>
          .
          <source>In: KR</source>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>