• Keine Ergebnisse gefunden

Complex Patterns and Compatibility

4.2 The Dual Simulation Semantics of Sparql

4.2.2 Complex Patterns and Compatibility

Replacing homomorphisms by dual simulations yields a tractable alternative to the Sparql semantics for basic graph patterns. Here, we study the interactions between dual simula-tions and the join operators (AND and OPT) to see whether the success for BGPs can be expanded to more complex Sparql queries. Therefore, we canonically extend the notion of compatibility to dual simulations and study the consequences for the resulting semantics ofSAO. Unfortunately, as we will demonstrate in a few examples, this new semantics does not fulll the requirement of correctness, whose formal denition will also be given in the course of this section. Dual simulations, exhibiting unbounded cycles, harmfully interact with optional clauses.

Compatibility of dual simulation candidates S1, S2 ⊆ V × U is conservatively dened as follows: S1 S2 i for all v ∈ dom(S1) ∩dom(S2), vS1 = vS2. This notion of compatibility allows us to directly dene the dual simulation semantics of conjunctions as well as optional patterns.

A dual simulationS ∈JQK

DSDB is called a dual simulation match forQ in DB. N

Subsequently, we give characteristic examples for the interactions of dual simulations and SAO-queries. If not stated otherwise, they all refer to the graph database DB4.1 from Figure 4.1.

Example 4.30 The query

Q1 = (p,cite,p)AND(p,author,r)

is the unfolded version of the basic graph pattern G discussed in Example 4.23. While Sparql's only match is µ(p7→P1,r7→John), our dual simulation semantics additionally yields the dual simulationS from Example 4.23. The base dual simulations to the left and the right triple pattern are

S1 ={(p,P1),(p,P2),(p,P4)} and S2 =S1∪ {(r,John),(r,Kristin)}.

S1 S2 because dom(S1)∩dom(S2) ={p}and pS1={P1,P2,P4}=pS2.

Such extensions of cycles may easily lead to more informative results than possibly returned under Sparql's original semantics. Let us therefore consider the query

Q2 = (p,cite,s)OPT(s,cite,s)

being structurally quite similar to Q1. Only this time, we use OPT instead of AND. The Sparql semantics exhibits one match for the conjunctive part4 inDB4.1, namelyµ1 (p7→

P1,s7→P1). Note that there are four more matches to be found inJQK

SDB4.1, only matching the left-hand side of Q2. Under the dual simulation semantics,

S3 ={(p,P3),(s,P2),(s,P4)}

is a dual simulation between(p,cite,s) and DB4.1. Furthermore, S4 ={(s,P2),(s,P4)}

is a dual simulation match for(s,cite,s)inDB4.1. S3andS4 are compatible, meaning that S3∪S4 is a dual simulation match for Q2. Hence, although P3 does not occur as a match for the conjunctive part ofQ2under Sparql's semantics, it does so in the dual simulation

interpretation.

This example is not yet harmful to the correctness of the resulting semantics. However, it already shows that not all Sparql matches are preserved by the dual simulation semantics since there is a query Q (e. g., Q2 from Example 4.30) and a graph database DB (e. g., DB4.1) for which JQK

S

DB * JQK

DS

DB. Therefore, the degree of correctness still achievable must be weaker. As with monotonicity, we bypass the strong requirement enforced by ⊆ through subsumption (v), i. e., every match µ∈JQK

S

DB must be included in some match S ∈ JQK

DS

DB. Although correctness of a semantics J·K_ for Sparql queries clearly is a relative notion to some other semantics for Sparql, we pursue it only w. r. t. Sparql's well-accepted semantics J·KS_.

Denition 4.31 (Correctness of (L,J·K_))

Let L ⊆ S. A semantics J·K_ is correct for L i for all queries Q ∈ L and all graph databases, JQK

SDB vJQKDB. A query language(L,J·K_)is correct iJ·K_is correct forL.N

4Since the evaluation ofQ1OPTQ2 includes all matches to the conjunctionQ1ANDQ2, these matches belong to the conjunctive part ofQ1OPTQ2.

As an application of the notion and as a consequence of Lemma 4.24, we obtain the following result about BGPs and their dual simulation interpretation.

Theorem 4.32 (SA,J·K

The subsequent example provides a counterexample disproving correctness of the dual sim-ulation semantics forSAO. The reason is that, due to unbounded cycles, dual simulations may match expanded cycles in optional clauses where Sparql does not nd a respective match.

Example 4.33 ConsiderDB4.3 (a)(Figure 4.3 (a)), which extendsDB4.1by node P0. Node P0, like P1, participates in a citedBy-relationship with P3 and exhibits a cite-self-loop.

ReconsiderQpref from Examples 4.4 and 4.8, i. e., (p,author,r)

being the result of the conjunction of M and O2. There is no match for O1 compatible to µ1 (p 7→ P3,r 7→ Robert) under the original semantics of Sparql. Under dual simu-lations, however,µ1 (easily interpreted as a dual simulation between M and DB4.3 (a) by Theorem 4.32) may be compatibly extended by a match forO1, namely

S2={(p,P3),(s,P2),(s,P4)}.

It holds thatµ1 S2 sincepµ1={µ1(p)}={P3}=pS2. Thus,µ1∪S2 ∈JQprefK

DS DB4.3 (a), letting incompatibility of µ1 to all matches of O1 disappear. Only circumstantially, the dual simulation semantics preservesµby the dual simulation matchS ∈JQprefK

DSDB with S={(r,Robert),(p,P3),(r,John),(p,P1)} ∪ {(p,P1),(s,P1),(p,P3),(s,P2),(s,P4)}. The counterexample Sparql match

µ0 (p7→P3,r7→Robert,s7→P0)

once more stems from a conjunction ofM andO2. This time, however,µ0does not reappear

in any dual simulation match forQpref.

Proposition 4.34 For some Q ∈ SAO and graph database DB, JQK

Proof: By queryQpref and graph database DB4.3 (a), we already have witnesses for the claim. In order to reduce this proof's complexity, we simplify the counterexample.

Consider

P1 cite P0

cite

author John

P2 author

P3 citedBy citedBy

cite

P4 cite

cite cite

Kristin author

Robert

author

(a)

1 a 3

2

b0 c

4 b

5 b

c c

(b)

Figure 4.3: (a) Another Adaptation of the Network in Figure 4.1 (b) A Simplied Version of Figure 4.3 (a)

as the counterexample query andDB4.3 (b)depicted in Figure 4.3 (b). JMK

DS_ )cannot be shown correct as not all matches due to the original semantics of Sparql are preserved for every Sparql query.

Before going on to the rescue of J·K

DS_ , at least for a fragment of SAO, we provide two more technical results about the semantics. They are going to be useful in subsequent proofs. The rst one is concerned with pairwise compatible dual simulation candidates.

For every three dual simulation candidates, that are pairwise compatible, the union of every two of them is compatible with the third.

Proposition 4.35 LetSi ⊆ V × U (i= 1,2,3) be dual simulation candidates. If Si Sj

As a rst application of Proposition 4.35, we subsequently prove thatANDis commutative and associative for the dual simulation semantics. Since matches are no longer partial func-tions, the proof requires a slightly dierent argument than necessary for Proposition 4.10.

Proposition 4.36 Let DB be a graph database and Qi ∈ S (i = 1,2,3). It holds that The other direction follows the same line of arguments, only backwards.

(II) Let S ∈ J(Q1 ANDQ2)ANDQ3K The same arguments apply for showing that S1 S3. Then (ii) follows from

Proposition 4.35. q. e. d.