<!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>Towards Reconciling Certain Answers and SPARQL: Bag Semantics to the Rescue??</article-title>
      </title-group>
      <abstract>
        <p>Despite the intention of RDF, the data model for the Semantic Web, to support reasoning about RDF data (as witnessed e.g. by three di erent semantics for RDF { simple/RDF/RDFS entailment { or accompanying standards like OWL), SPARQL, the standardized query language for RDF, lacks some support of including such reasoning into query answering, as was noted e.g. in [6, 1]. One major cause of this is that SPARQL only makes partially use of certain answers, which are the semantics commonly applied in reasoning scenarios. While not fully supporting certain answers might be a reasonable decision when looking at the costs of evaluating and (for a user) understanding a query, it negatively a ects the power of SPARQL. As a result, in recent years suggestions have been made how to cover di erent aspects of reasoning about RDF data (e.g. blank nodes under RDF simple entailment [6]; OWL reasoning [1]) in SPARQL by adopting a certain answer semantics. However, as observed in [1], just applying the usual de nition of certain answers to SPARQL can, in certain cases, be unnecessarily restrictive. To better illustrate these situations, let us rst recall the de nition of certain answers. Given an RDF graph G (possibly extended by some additional information), most reasoning formalisms de ne the semantics of G in terms of an (in nite) set models(G) of RDF graphs implied by G. Query answering in such a setting is then commonly de ned in terms of the certain answer semantic: for a query Q, the certain answers certain(Q; G) (w.r.t. some reasoning formalism) are certain(Q; G) = TG02models(G) Q(G0), where Q(G0) denotes the result of evaluating Q over the RDF graph G0. While this de nition can be immediately applied to SPARQL queries, problems arise e.g. when looking at the OPTIONAL operator, or more precisely at the weakly monotone classes of SPARQL queries, like the well-designed queries [10]. Example 1. Consider the SPARQL query Q SELECT ?auth; ?award WHERE f?auth writes ?bg OPTIONAL f?b receives ?awardg and an RDF graph G = f(a; writes; b)g. Assuming that models(G) contains all supersets of G (like e.g. under the RDF simple semantics), certain(Q; G) = ;.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        Given that (a; writes; b) 2 G0 for every G0 2 models(G), this is an
unintuitive result. However, the mapping = f(?auth; a)g is no certain answer
because it is not part of Q(G0) for every G0 2 models(G). For example, take
G0 = G [ f(b; receives; p)g. Then Q(G0) = ff(?auth; a); (?award; p)gg.
What makes this situation unintuitive is that while 2= Q(G0), an extension
of is contained in Q(G0). In fact, weakly monotone queries are exactly those
queries Q where for all pairs of RDF graphs G G0 the result Q(G0) contains a
not necessarily proper extension of every mapping in Q(G) [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
      </p>
      <p>
        To account for this, based on the notion of subsumption (a mapping 0
subsumes a mapping if 0 extends ), an alternative certain answer semantics was
proposed in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. One challenge in devising such a semantics is to avoid introducing
unjusti ed subsumed mappings to the certain answers.
      </p>
      <p>
        Example 2. Consider the query Q from Example 1 and let the RDF graph G1 be
the RDF graph G0 from Example 1. Assuming models(G1) to contain all
supersets of G1, one would expect certain(Q; G1) = ff(?auth; a); (?award; p)gg, while
there is no justi cation for f(?auth; a)g 2 certain(Q; G1). However, for G2 =
G1 [ f(a; writes; c)g, intuitively certain(Q; G2) = ff(?auth; a); (?award; p)g;
f(?auth; a)gg. This is because, unlike for G1, over each graph in models(G2) at
least two di erent mappings contribute a solution, namely f(?auth; a); (?b; b);
(?award; p)g and f(?auth; a); (?b; c)g. However, due to projection, these two
mappings may lead to the same solution: for G3 = G2 [f(c; receives; p)g we get
(under set semantics) Q(G1) = Q(G3). Under bag semantics, Q(G1) and Q(G3)
still contain the same mapping, but it occurs once in Q(G1) and twice in Q(G3).
As a result, these two cases cannot be distinguished under set semantics, which
prevents a de nition of certain answers that acknowledges the di erences
between these cases. In [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] this was resolved by excluding all subsumed mappings
from the certain answers. E.g., in the above example, f(?auth; a); (?award; p)g
would be the only certain answer for both, G1 and G2. While being a sensible
de nition, it is nevertheless a little ad hoc.
      </p>
      <p>
        Given recent advances in SPARQL query answering and reasoning under bag
semantics (cf. [
        <xref ref-type="bibr" rid="ref2 ref4 ref5 ref6 ref9">6, 9, 2, 4, 5</xref>
        ]), in this ongoing work we are revisiting the de nition of
a certain answer semantics for SPARQL under bag semantics, with the nal goal
to devise a certain answer semantics that (more) adequately describes the certain
information returned by weakly monotone queries. This submission does not
present new results, but suggests a possible certain answer semantics, (hopefully)
showcasing that revisiting certain answer semantics for SPARQL is worthwhile.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Subsumption between Bags</title>
      <p>A possible way of de ning a certain answer semantics that faithfully includes
subsumed mappings is to introduce a \subsumption-aware" variant of bag-intersection.</p>
      <p>Towards this goal, we x some notation. A mapping is a set of pairs (?xi; vi),
each pair denoting (?xi) = vi. A bag M of mappings is a collection of mappings
that may contain each mapping more than once. We write card M ( ) to denote
the number of times a mapping occurs in bag M (if clear, M may be dropped;
if we do not specify card M ( ), we assume 1 by default). In this submission, we
will assume RDF graphs to be sets, while we assume query results to be bags of
mappings, a setting sometimes referred to as set-bag semantics in the literature.</p>
      <p>
        Having settled this, we rst have to extend the notion of subsumption to
bags. For sets L, R of mappings, subsumption L v R holds when for every
mapping 2 L there exists a mapping 0 2 R such that 0. Similar to
homomorphisms (cf. [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]), there are several possibilities for extending
subsumption to bags L; R of mappings: one could just apply the de nition for sets, or one
could demand that for every mapping 2 L there exists 0 2 R such that 0
and card L( ) card R( 0). While it would be interesting to study the e ects of
these de nitions, for our purpose they are too weak. For example, they cannot
resolve the situation described in Example 2: under both de ntions, Q(G1) and
Q(G2) would subsume each other. Thus a subsumption based de nition of
certain answers could not distinguish Q(G1) from Q(G2), despite our intention that
certain(Q; G2) = Q(G2), but not Q(G1).
      </p>
      <p>
        We thus use a stricter de nition for subsumption between bags, and say that a
bag L is subsumed by a bag R, written L vb R, if there exists a mapping h : L !
R such that v h( ) for all 2 L and card R( 0) P 2L : h( )= 0 card L( ) for
all 0 2 R (this corresponds to the additive homomorphisms in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]).
      </p>
      <p>Next, we say that a bag M of mappings is vb maximal w.r.t. a property if
M satis es and there is no M 0 satisfying such that M v M 0 but M 0 6v M .</p>
      <p>It is an interesting observation at this point that sets M1 6= M2 of mappings
may satisfy M1 v M2 and M2 v M1 (just consider the mappings in Example 2),
while (for bags or sets) B1 vb B2 and B2 vb B1 implies B1 = B2.</p>
      <p>The notion of vb-maximal bags now allows us to de ne L \v R, a version of
bag-intersection that retrieves maximal information from both, L and R: for two
bags L, R of mappings, let L \v R be a vb-maximal bag M such that M vb L
and M vb R. Unfortunately, the result of this operator is not necessarily unique.
Example 3. Let L = ff(x; 1); (y; 1); (u; 1)g; f(v; 1)gg and R = ff(x; 1); (y; 1); (v; 1)g;
f(u; 1)gg be two bags of mappings. Then M1 = ff(x; 1); (y; 1)gg and M2 =
ff(u; 1)g; f(v; 1)gg are both vb-maximal w.r.t. being subsumed by L and R.
However, we will discuss next that in many cases \v, or a slight adaption of it,
is nevertheless well-suited to de ne meaningful certain answers.
3</p>
      <p>Certain Answers via \v
Besides not returning a unique bag, another property of \v needs to be taken
care of before it can be used to de ne certain answers, as illustrated next.
Example 4. Consider a SPARQL query Q
SELECT ?a; ?w; ?r WHERE f?a isa authorg OPTIONAL f?a writes ?w:?a reads ?rg
and an RDF graph G = f(a; isa; author); (a; reads; b)g. Assume that also the
knowledge \every author writes some book" (expressed e.g. in OWL) is given and
that every RDF graph G0 2 models(G) satis es this condition. Then Tvfq(G0) j
G0 2 models(G)g = ff(?a; a); (?r; b)gg.</p>
      <p>
        However, this result does not respect the requirement expressed in the query that
a result should contain either a value for both, ?w and ?r, or neither of them. As
a result, instead of de ning certain answers just as Tvfq(G0) j G0 2 models(G)g,
following [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], we also restrict the possible domains for the certain answers. For
a set V of sets of variables, we therefore extend L \v R to L \v
V R as being the
vb-maximal bag M such that M vb L, M vb R, and dom( ) 2 V for all 2 M .
      </p>
      <p>Finally, for a query Q, let the admissible solution domains adsoldom (Q) be
the set of possible domains of mappings in Q(G) (for any G). Due to space
restrictions we stick to this vague de nition; but, for example, for conjunctive queries
Q, adsoldom(Q) contains as single element the set of all output variables of Q,
for query Q from Example 2 we get adsoldom(Q) = ff?authg; f?auth; ?awardgg,
and for Q from Example 4, adsoldom(Q) = ff?ag; f?a; ?w; ?rgg.</p>
      <p>De nition 1. Let G be an RDF graph, Q a query, and models (G0) the set of
graphs entailed by G. Then the certain answers of Q are de ned as
certain(Q; G) = Tadsoldom(Q)fQ(G0) j G0 2 models(G)g:</p>
      <p>v</p>
      <p>While, for arbitrary inputs L; R; V, the result of L \Vv R is not necessarily
unique, in most of the settings in which we compute certain answers, L, R, and
V are not arbitrary inputs but adhere to some structure that we can exploit.</p>
      <p>For example, when applied to conjunctive queries, \v
V reduces to conventional
(set- or bag) intersection, and as a result for these queries we get the \classical"
de nition of certain answers as a special case of De nition 1.</p>
      <p>Similarly, in the special case of models(G) containing a minimal element G
(i.e. G G0 for all G0 2 models(G)), for weakly monotone SPARQL queries the
certain answers are uniquely de ned. In fact, applied to the settings in
Examples 1 and 2 it produces exactly the intuitive bags of certain answers.</p>
      <p>More generally, also for the sets models(G) that exhibit a canonical model
(i.e. that contain some G0 2 models(G) such that for every Gi 2 models(G) there
exists some homomorphism hi : G0 ! Gi) we strongly conjecture that for weakly
monotone queries, and especially for well-designed SPARQL queries, De nition 1
gives a unique bag of certain answers.</p>
      <p>
        There are, of course, a lot of open question for future and ongoing work.
These include the relationship to certain answer semantics from the literature
(e.g., while \typical" certain answers for CQs are a special case of De nition 1,
this seems not to be the case for the de nition in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]), an investigation of classes
that provide a unique bag of certain answers, and of course the costs/complexity
of query evaluation under this semantics for speci c reasoning formalisms (e.g.
OWL). Another line of research is to establish a connection with the work in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
Finally, also considering alterations of this de nition could be of interest.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Ahmetaj</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Fischl</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pichler</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Simkus</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Skritek</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Towards reconciling SPARQL and certain answers</article-title>
          .
          <source>In: Proc. WWW</source>
          <year>2015</year>
          . pp.
          <volume>23</volume>
          {
          <fpage>33</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Angles</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gutierrez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>The multiset semantics of SPARQL patterns</article-title>
          .
          <source>In: Proc. ISWC</source>
          <year>2016</year>
          .
          <article-title>LNCS</article-title>
          , vol.
          <volume>9981</volume>
          , pp.
          <volume>20</volume>
          {
          <fpage>36</fpage>
          . Springer (
          <year>2016</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>Perez</surname>
          </string-name>
          , J.:
          <article-title>Querying semantic web data with SPARQL</article-title>
          .
          <source>In: Proc. PODS</source>
          <year>2011</year>
          . pp.
          <volume>305</volume>
          {
          <fpage>316</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Console</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Guagliardo</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Libkin</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          :
          <article-title>Approximations and re nements of certain answers via many-valued logics</article-title>
          .
          <source>In: Principles of Knowledge Representation and Reasoning: Proceedings of the Fifteenth International Conference, KR</source>
          <year>2016</year>
          ,
          <string-name>
            <surname>Cape</surname>
            <given-names>Town</given-names>
          </string-name>
          , South Africa,
          <source>April 25-29</source>
          ,
          <year>2016</year>
          . pp.
          <volume>349</volume>
          {
          <fpage>358</fpage>
          . AAAI Press (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Console</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Guagliardo</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Libkin</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          :
          <article-title>On querying incomplete information in databases under bag semantics</article-title>
          .
          <source>In: Proc. IJCAI</source>
          <year>2017</year>
          . pp.
          <volume>993</volume>
          {
          <fpage>999</fpage>
          . ijcai.
          <source>org</source>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Hernandez</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gutierrez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hogan</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Certain answers for SPARQL with blank nodes</article-title>
          .
          <source>In: Proc. ISWC</source>
          <year>2018</year>
          .
          <article-title>LNCS</article-title>
          , vol.
          <volume>11136</volume>
          , pp.
          <volume>337</volume>
          {
          <fpage>353</fpage>
          . Springer (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Hernich</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kolaitis</surname>
            ,
            <given-names>P.G.</given-names>
          </string-name>
          :
          <article-title>Foundations of information integration under bag semantics</article-title>
          .
          <source>In: Proc. LICS</source>
          <year>2017</year>
          . pp.
          <volume>1</volume>
          {
          <fpage>12</fpage>
          . IEEE Computer Society (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Libkin</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          :
          <article-title>Certain answers as objects and knowledge</article-title>
          . vol.
          <volume>232</volume>
          , pp.
          <volume>1</volume>
          {
          <issue>19</issue>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Nikolaou</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kostylev</surname>
            ,
            <given-names>E.V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Konstantinidis</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kaminski</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grau</surname>
            ,
            <given-names>B.C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Horrocks</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>The bag semantics of ontology-based data access</article-title>
          .
          <source>In: Proc. IJCAI</source>
          <year>2017</year>
          . pp.
          <volume>1224</volume>
          {
          <fpage>1230</fpage>
          . ijcai.
          <source>org</source>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Perez</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <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>Semantics and complexity of SPARQL</article-title>
          .
          <source>ACM Trans. Database Syst</source>
          .
          <volume>34</volume>
          (
          <issue>3</issue>
          ),
          <volume>16</volume>
          :1{
          <fpage>16</fpage>
          :
          <fpage>45</fpage>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>