SLIDE 1 Semantics is an indispensable aspect
SLIDE 2 Semantics is an indispensable aspect
SELECT Name, Salary FROM Employees WHERE Salary >= 500000
SLIDE 3 Semantics is an indispensable aspect
SELECT Name, Salary FROM Employees WHERE Salary >= 500000 πName,Salary
- σSalary≥500000(Employees)
SLIDE 4
RDF data model for the Semantic Web SPARQL query language for RDF (W3C initiatives)
SLIDE 5 RDF data model for the Semantic Web SPARQL query language for RDF (W3C initiatives)
RDF Graph:
:name Federico Meza 35-446928 Ricardo Baeza URI 2 :email rbaeza@utalca.cl URI 1 fmeza@utalca.cl :name :email :phone :knows
SLIDE 6 RDF data model for the Semantic Web SPARQL query language for RDF (W3C initiatives)
RDF Graph:
:name Federico Meza 35-446928 Ricardo Baeza URI 2 :email rbaeza@utalca.cl URI 1 fmeza@utalca.cl :name :email :phone :knows
SPARQL Query:
SELECT ?N WHERE { ?X :name ?N . }
SLIDE 7 RDF data model for the Semantic Web SPARQL query language for RDF (W3C initiatives)
RDF Graph:
:name Federico Meza 35-446928 Ricardo Baeza URI 2 :email rbaeza@utalca.cl URI 1 fmeza@utalca.cl :name :email :phone :knows
SPARQL Query:
SELECT ?N ?E WHERE { ?X :name ?N . ?X :email ?E . }
SLIDE 8 RDF data model for the Semantic Web SPARQL query language for RDF (W3C initiatives)
RDF Graph:
:name Federico Meza 35-446928 Ricardo Baeza URI 2 :email rbaeza@utalca.cl URI 1 fmeza@utalca.cl :name :email :phone :knows
SPARQL Query:
SELECT ?N ?E WHERE { ?X :name ?N . ?X :email ?E . ?X :knows ?Y . ?Y :name "Ricardo Baeza" }
SLIDE 9
But things can become more complex...
Interesting features of pattern matching on graphs
SELECT ?X1 ?X2 ... WHERE { P1 . P2 }
SLIDE 10
But things can become more complex...
Interesting features of pattern matching on graphs
◮ Grouping
SELECT ?X1 ?X2 ... WHERE { { P1 . P2 } { P3 . P4 } }
SLIDE 11
But things can become more complex...
Interesting features of pattern matching on graphs
◮ Grouping ◮ Optional parts
SELECT ?X1 ?X2 ... WHERE { { P1 . P2 OPTIONAL { P5 } } { P3 . P4 OPTIONAL { P7 } } }
SLIDE 12
But things can become more complex...
Interesting features of pattern matching on graphs
◮ Grouping ◮ Optional parts ◮ Nesting
SELECT ?X1 ?X2 ... WHERE { { P1 . P2 OPTIONAL { P5 } } { P3 . P4 OPTIONAL { P7 OPTIONAL { P8 } } } }
SLIDE 13
But things can become more complex...
Interesting features of pattern matching on graphs
◮ Grouping ◮ Optional parts ◮ Nesting ◮ Union of patterns
SELECT ?X1 ?X2 ... WHERE { { P1 . P2 OPTIONAL { P5 } } { P3 . P4 OPTIONAL { P7 OPTIONAL { P8 } } } } UNION { P9 }
SLIDE 14
But things can become more complex...
Interesting features of pattern matching on graphs
◮ Grouping ◮ Optional parts ◮ Nesting ◮ Union of patterns ◮ Filtering
SELECT ?X1 ?X2 ... WHERE { { P1 . P2 OPTIONAL { P5 } } { P3 . P4 OPTIONAL { P7 OPTIONAL { P8 } } } } UNION { P9 FILTER ( R ) }
SLIDE 15
But things can become more complex...
Interesting features of pattern matching on graphs
◮ Grouping ◮ Optional parts ◮ Nesting ◮ Union of patterns ◮ Filtering ◮ ...
SELECT ?X1 ?X2 ... WHERE { { P1 . P2 OPTIONAL { P5 } } { P3 . P4 OPTIONAL { P7 OPTIONAL { P8 } } } } UNION { P9 FILTER ( R ) }
SLIDE 16
But things can become more complex...
Interesting features of pattern matching on graphs
◮ Grouping ◮ Optional parts ◮ Nesting ◮ Union of patterns ◮ Filtering ◮ ...
SELECT ?X1 ?X2 ... WHERE { { P1 . P2 OPTIONAL { P5 } } { P3 . P4 OPTIONAL { P7 OPTIONAL { P8 } } } } UNION { P9 FILTER ( R ) }
What is the meaning of a general SPARQL query?
SLIDE 17
The SPARQL W3C specification had no formal semantics!
◮ Specification primarily based on use cases and examples ◮ Semantics given in natural language
SLIDE 18
The SPARQL W3C specification had no formal semantics!
◮ Specification primarily based on use cases and examples ◮ Semantics given in natural language ◮ 6 Working Drafts from Feb-2004 to Feb-2006 ◮ Candidate Recommendation in Apr-2006
but still no formal semantics!
SLIDE 19
The SPARQL W3C specification had no formal semantics!
◮ Specification primarily based on use cases and examples ◮ Semantics given in natural language ◮ 6 Working Drafts from Feb-2004 to Feb-2006 ◮ Candidate Recommendation in Apr-2006
but still no formal semantics! A formal approach is beneficial to:
◮ Clarify corner cases ◮ Help in the implementation process ◮ Provide sound database foundations
SLIDE 20
Semantics and Complexity of SPARQL
Jorge P´ erez
PhD Student Computer Science Department, PUC – Chile Work presented at the International Semantic Web Conference 2006
SLIDE 21
W3C SPARQL specification is currently based on our work
W3C document:
◮ Oct-2006 back to working draft ◮ Finally, a recommendation in Jan-2008
incorporating our fomalization
SLIDE 22
W3C SPARQL specification is currently based on our work
W3C document:
◮ Oct-2006 back to working draft ◮ Finally, a recommendation in Jan-2008
incorporating our fomalization In our work:
◮ A formal compositional semantics (for graph patterns) ◮ Complexity bounds ◮ Normalization and optimization procedures
SLIDE 23
Outline
Motivation Our contributions Syntax and semantics of SPARQL graph patterns Syntax Semantics Complexity results Well–designed graph patterns Complexity Normalization and optimization
SLIDE 24
Outline
Motivation Our contributions Syntax and semantics of SPARQL graph patterns Syntax Semantics Complexity results Well–designed graph patterns Complexity Normalization and optimization
SLIDE 25 A standard algebraic syntax
◮ Triple patterns: just triples + variables (V )
?X :name "john" (?X, name, john)
◮ Graph patterns: full parenthesized algebra
{ P1 P2 } ( P1 AND P2 ) { P1 OPTIONAL { P2 }} ( P1 OPT P2 ) { P1 } UNION { P2 } ( P1 UNION P2 ) { P1 FILTER ( R ) } ( P1 FILTER R )
algebraic syntax
SLIDE 26
A standard algebraic syntax (cont.)
◮ Explicit precedence/association
Example
{ t1 t2 OPTIONAL { t3 } OPTIONAL { t4 } t5 }
( ( ( ( t1 AND t2 ) OPT t3 ) OPT t4 ) AND t5 )
SLIDE 27
Mappings: building block for the semantics
Definition
A mapping is a partial function from variables to RDF terms. µ : Variables → RDF Terms
SLIDE 28
Mappings: building block for the semantics
Definition
A mapping is a partial function from variables to RDF terms. µ : Variables → RDF Terms The evaluation of a pattern results in a set of mappings.
SLIDE 29
The semantics of triple patterns
Given an RDF graph G and a triple pattern t
Definition
The evaluation of t over G is the set of mappings µ that:
SLIDE 30
The semantics of triple patterns
Given an RDF graph G and a triple pattern t
Definition
The evaluation of t over G is the set of mappings µ that:
◮ make t to match the graph: µ(t) ∈ G
SLIDE 31
The semantics of triple patterns
Given an RDF graph G and a triple pattern t
Definition
The evaluation of t over G is the set of mappings µ that:
◮ make t to match the graph: µ(t) ∈ G ◮ have as domain the variables in t: dom(µ) = var(t)
SLIDE 32
The semantics of triple patterns
Given an RDF graph G and a triple pattern t
Definition
The evaluation of t over G is the set of mappings µ that:
◮ make t to match the graph: µ(t) ∈ G ◮ have as domain the variables in t: dom(µ) = var(t)
Example
graph triple evaluation (R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) (?X, name, ?Y ) ?X ?Y µ1: R1 john µ2: R2 paul
SLIDE 33
The semantics of triple patterns
Given an RDF graph G and a triple pattern t
Definition
The evaluation of t over G is the set of mappings µ that:
◮ make t to match the graph: µ(t) ∈ G ◮ have as domain the variables in t: dom(µ) = var(t)
Example
graph triple evaluation (R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) (?X, name, ?Y ) ?X ?Y µ1: R1 john µ2: R2 paul
SLIDE 34
The semantics of triple patterns
Given an RDF graph G and a triple pattern t
Definition
The evaluation of t over G is the set of mappings µ that:
◮ make t to match the graph: µ(t) ∈ G ◮ have as domain the variables in t: dom(µ) = var(t)
Example
graph triple evaluation (R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) (?X, name, ?Y ) ?X ?Y µ1: R1 john µ2: R2 paul
SLIDE 35
Compatible mappings: mappings that can be merged.
Definition
Mappings are compatibles if they agree in their common variables.
Example
?X ?Y ?Z ?V µ1 : R1 john µ2 : R1 J@edu.ex µ3 : P@edu.ex R2
SLIDE 36
Compatible mappings: mappings that can be merged.
Definition
Mappings are compatibles if they agree in their common variables.
Example
?X ?Y ?Z ?V µ1 : R1 john µ2 : R1 J@edu.ex µ3 : P@edu.ex R2
SLIDE 37
Compatible mappings: mappings that can be merged.
Definition
Mappings are compatibles if they agree in their common variables.
Example
?X ?Y ?Z ?V µ1 : R1 john µ2 : R1 J@edu.ex µ3 : P@edu.ex R2 µ1 ∪ µ2 : R1 john J@edu.ex
SLIDE 38
Compatible mappings: mappings that can be merged.
Definition
Mappings are compatibles if they agree in their common variables.
Example
?X ?Y ?Z ?V µ1 : R1 john µ2 : R1 J@edu.ex µ3 : P@edu.ex R2 µ1 ∪ µ2 : R1 john J@edu.ex
SLIDE 39
Compatible mappings: mappings that can be merged.
Definition
Mappings are compatibles if they agree in their common variables.
Example
?X ?Y ?Z ?V µ1 : R1 john µ2 : R1 J@edu.ex µ3 : P@edu.ex R2 µ1 ∪ µ2 : R1 john J@edu.ex µ1 ∪ µ3 : R1 john P@edu.ex R2
SLIDE 40
Compatible mappings: mappings that can be merged.
Definition
Mappings are compatibles if they agree in their common variables.
Example
?X ?Y ?Z ?V µ1 : R1 john µ2 : R1 J@edu.ex µ3 : P@edu.ex R2 µ1 ∪ µ2 : R1 john J@edu.ex µ1 ∪ µ3 : R1 john P@edu.ex R2
◮ µ2 and µ3 are not compatible
SLIDE 41
Sets of mappings and operations
Let M1 and M2 be sets of mappings:
Definition
SLIDE 42
Sets of mappings and operations
Let M1 and M2 be sets of mappings:
Definition
Join: extends mappings in M1 with compatible mappings in M2
SLIDE 43
Sets of mappings and operations
Let M1 and M2 be sets of mappings:
Definition
Join: extends mappings in M1 with compatible mappings in M2
◮ M1 ⋊
⋉ M2 = {µ1 ∪ µ2 | µ1 ∈ M1, µ2 ∈ M2, and µ1, µ2 are compatible}
SLIDE 44
Sets of mappings and operations
Let M1 and M2 be sets of mappings:
Definition
Join: extends mappings in M1 with compatible mappings in M2
◮ M1 ⋊
⋉ M2 = {µ1 ∪ µ2 | µ1 ∈ M1, µ2 ∈ M2, and µ1, µ2 are compatible} Difference: selects mappings in M1 that cannot be extended with mappings in M2
SLIDE 45
Sets of mappings and operations
Let M1 and M2 be sets of mappings:
Definition
Join: extends mappings in M1 with compatible mappings in M2
◮ M1 ⋊
⋉ M2 = {µ1 ∪ µ2 | µ1 ∈ M1, µ2 ∈ M2, and µ1, µ2 are compatible} Difference: selects mappings in M1 that cannot be extended with mappings in M2
◮ M1 M2 = {µ1 ∈ M1 | there is no mapping µ2 ∈ M2
compatible with µ1}
SLIDE 46
Sets of mappings and operations
Let M1 and M2 be sets of mappings:
Definition
SLIDE 47
Sets of mappings and operations
Let M1 and M2 be sets of mappings:
Definition
Union: includes mappings in M1 plus mappings in M2 (set union)
◮ M1 ∪ M2 = {µ | µ ∈ M1 or µ ∈ M2}
SLIDE 48
Sets of mappings and operations
Let M1 and M2 be sets of mappings:
Definition
Union: includes mappings in M1 plus mappings in M2 (set union)
◮ M1 ∪ M2 = {µ | µ ∈ M1 or µ ∈ M2}
Left Outer Join: considers mappings in M1 extending them with compatible mappings in M2 whenever it is possible
◮ M1
M2 = (M1 ⋊ ⋉ M2) ∪ (M1 M2)
SLIDE 49
Semantics in terms of operations between evaluations
Let M1 and M2 be the evaluation of P1 and P2.
Definition
The evaluation of: (P1 AND P2) → (P1 UNION P2) → (P1 OPT P2) →
SLIDE 50
Semantics in terms of operations between evaluations
Let M1 and M2 be the evaluation of P1 and P2.
Definition
The evaluation of: (P1 AND P2) → M1 ⋊ ⋉ M2 (P1 UNION P2) → (P1 OPT P2) →
SLIDE 51
Semantics in terms of operations between evaluations
Let M1 and M2 be the evaluation of P1 and P2.
Definition
The evaluation of: (P1 AND P2) → M1 ⋊ ⋉ M2 (P1 UNION P2) → M1 ∪ M2 (P1 OPT P2) →
SLIDE 52
Semantics in terms of operations between evaluations
Let M1 and M2 be the evaluation of P1 and P2.
Definition
The evaluation of: (P1 AND P2) → M1 ⋊ ⋉ M2 (P1 UNION P2) → M1 ∪ M2 (P1 OPT P2) → M1 M2
SLIDE 53
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) )
SLIDE 54
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) )
SLIDE 55
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) ) ?X ?Y R1 john R2 paul
SLIDE 56
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) ) ?X ?Y R1 john R2 paul
SLIDE 57
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) ) ?X ?Y R1 john R2 paul ?X ?E R1 J@ed.ex
SLIDE 58
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) ) ?X ?Y R1 john R2 paul ?X ?E R1 J@ed.ex
SLIDE 59
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) ) ?X ?Y R1 john R2 paul ?X ?Y ?E R1 john J@ed.ex R2 paul ?X ?E R1 J@ed.ex
SLIDE 60
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) ) ?X ?Y R1 john R2 paul ?X ?Y ?E R1 john J@ed.ex R2 paul ?X ?E R1 J@ed.ex
◮ from the Join
SLIDE 61
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) ) ?X ?Y R1 john R2 paul ?X ?Y ?E R1 john J@ed.ex R2 paul ?X ?E R1 J@ed.ex
◮ from the Join ◮ from the Difference
SLIDE 62
Simple example
Example
(R1, name, john) (R1, email, J@ed.ex) (R2, name, paul) ( (?X, name, ?Y ) OPT (?X, email, ?E) ) ?X ?Y R1 john R2 paul ?X ?Y ?E R1 john J@ed.ex R2 paul ?X ?E R1 J@ed.ex
◮ from the Join ◮ from the Difference ◮ from the Union
SLIDE 63
Boolean filter expressions (value constraints)
In filter expressions we consider
◮ equality (=) among variables and RDF terms ◮ unary predicate bound ◮ boolean combinations (∧, ∨, ¬)
SLIDE 64
Satisfaction of value constraints
A mapping satisfies
◮ ?X = c if it gives the value c to variable ?X ◮ ?X =?Y if it gives the same value to ?X and ?Y ◮ bound(?X) if it is defined for ?X
SLIDE 65
Satisfaction of value constraints
A mapping satisfies
◮ ?X = c if it gives the value c to variable ?X ◮ ?X =?Y if it gives the same value to ?X and ?Y ◮ bound(?X) if it is defined for ?X
Definition
The evaluation of (P FILTER R):
◮ mappings in the evaluation of P that satisfy R.
SLIDE 66
It was not that difficult to define a formal semantics for SPARQL
SLIDE 67
It was not that difficult to define a formal semantics for SPARQL
Key aspects:
◮ use partial mappings for individual solutions ◮ adapt classical operators to deal with partial mappings
SLIDE 68
Outline
Motivation Our contributions Syntax and semantics of SPARQL graph patterns Syntax Semantics Complexity results Well–designed graph patterns Complexity Normalization and optimization
SLIDE 69
The evaluation decision problem
INPUT:
A mapping, a graph pattern, and an RDF graph.
OUTPUT:
Is the mapping in the evaluation of the pattern over the graph?
SLIDE 70
Evaluation of simple patterns is polynomial.
Theorem
For patterns using only AND and FILTER operators, the evaluation problem is polynomial: O(size of the pattern × size of the graph).
SLIDE 71
Evaluation of simple patterns is polynomial.
Theorem
For patterns using only AND and FILTER operators, the evaluation problem is polynomial: O(size of the pattern × size of the graph).
Proof idea
◮ Check that the mapping makes every triple to match. ◮ Then check that the mapping satisfies the FILTERs.
SLIDE 72
Evaluation including UNION is NP-complete.
Theorem
For patterns using AND, FILTER and UNION operators, the evaluation problem is NP-complete.
SLIDE 73
Evaluation including UNION is NP-complete.
Theorem
For patterns using AND, FILTER and UNION operators, the evaluation problem is NP-complete.
Proof idea
◮ Reduction from propositional SAT ◮ The pattern codifies a propositional formula.
SLIDE 74
Evaluation including UNION is NP-complete.
Theorem
For patterns using AND, FILTER and UNION operators, the evaluation problem is NP-complete.
Proof idea
◮ Reduction from propositional SAT ◮ The pattern codifies a propositional formula. ◮ Using ¬ bound to codify negation.
SLIDE 75
A simple normal from
Theorem (UNION Normal Form)
Every graph pattern is equivalent to one of the form P1 UNION P2 UNION · · · UNION Pn with Pi UNION–free.
SLIDE 76
A simple normal from
Theorem (UNION Normal Form)
Every graph pattern is equivalent to one of the form P1 UNION P2 UNION · · · UNION Pn with Pi UNION–free.
Theorem
The evaluation problem for AND-FILTER-UNION patterns in UNION normal form, is polynomial.
SLIDE 77
Evaluation in general is PSPACE-complete.
Theorem
For general patterns that include OPT operator, the evaluation problem is PSPACE-complete.
SLIDE 78
Evaluation in general is PSPACE-complete.
Theorem
For general patterns that include OPT operator, the evaluation problem is PSPACE-complete.
◮ still PSPACE-complete for AND-FILTER-OPT patterns
SLIDE 79
Evaluation in general is PSPACE-complete.
Theorem
For general patterns that include OPT operator, the evaluation problem is PSPACE-complete.
◮ still PSPACE-complete for AND-FILTER-OPT patterns
Proof idea
◮ Reduction from propositional quantified SAT ◮ The pattern codifies a quantified formula
∀x1∃x2∀x3 · · · ϕ.
SLIDE 80
Evaluation in general is PSPACE-complete.
Theorem
For general patterns that include OPT operator, the evaluation problem is PSPACE-complete.
◮ still PSPACE-complete for AND-FILTER-OPT patterns
Proof idea
◮ Reduction from propositional quantified SAT ◮ The pattern codifies a quantified formula
∀x1∃x2∀x3 · · · ϕ.
◮ Using nested OPTs to codify quantifier alternations.
SLIDE 81
Outline
Motivation Our contributions Syntax and semantics of SPARQL graph patterns Syntax Semantics Complexity results Well–designed graph patterns Complexity Normalization and optimization
SLIDE 82
Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · )
if a variable occurs
SLIDE 83
Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑
if a variable occurs inside B
SLIDE 84
Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ↑ ↑
if a variable occurs inside B and anywhere outside the OPT,
SLIDE 85
Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑
if a variable occurs inside B and anywhere outside the OPT, then the variable must also occur inside A.
SLIDE 86 Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑
if a variable occurs inside B and anywhere outside the OPT, then the variable must also occur inside A.
Example
(?Y , name, paul) OPT (?X, email, ?Z)
(?X, name, john)
SLIDE 87 Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑
if a variable occurs inside B and anywhere outside the OPT, then the variable must also occur inside A.
Example
(?Y , name, paul) OPT (?X, email, ?Z)
(?X, name, john)
SLIDE 88 Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑
if a variable occurs inside B and anywhere outside the OPT, then the variable must also occur inside A.
Example
(?Y , name, paul) OPT (?X, email, ?Z)
(?X, name, john)
↑
SLIDE 89 Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑
if a variable occurs inside B and anywhere outside the OPT, then the variable must also occur inside A.
Example
(?Y , name, paul) OPT (?X, email, ?Z)
(?X, name, john)
↑
SLIDE 90 Well–designed patterns
Definition
An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern
( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑
if a variable occurs inside B and anywhere outside the OPT, then the variable must also occur inside A.
Example
(?Y , name, paul) OPT (?X, email, ?Z)
(?X, name, john)
↑
◮ Well-designed patterns initially proposed to show equivalence
with a procedural semantics (by W3C)
SLIDE 91
Evaluation of well-designed patterns is in coNP-complete
Theorem
For AND-FILTER-OPT well–designed graph patterns the evaluation problem is coNP-complete
SLIDE 92
Evaluation of well-designed patterns is in coNP-complete
Theorem
For AND-FILTER-OPT well–designed graph patterns the evaluation problem is coNP-complete
Corollary
For patterns of the form P1 UNION P2 UNION · · · UNION Pk where every Pi is a UNION-free well-designed pattern, the evaluation problem is coNP-complete
SLIDE 93
Classical optimization is not directly applicable.
◮ Classical optimization assumes null–rejection.
SLIDE 94 Classical optimization is not directly applicable.
◮ Classical optimization assumes null–rejection.
◮ null–rejection: the join/outer–join condition must fail in the
presence of null.
SLIDE 95 Classical optimization is not directly applicable.
◮ Classical optimization assumes null–rejection.
◮ null–rejection: the join/outer–join condition must fail in the
presence of null.
◮ SPARQL operations are never null–rejecting
◮ by definition of compatible mappings.
SLIDE 96 Classical optimization is not directly applicable.
◮ Classical optimization assumes null–rejection.
◮ null–rejection: the join/outer–join condition must fail in the
presence of null.
◮ SPARQL operations are never null–rejecting
◮ by definition of compatible mappings.
◮ Can we use classical optimization in the context of SPARQL?
SLIDE 97 Classical optimization is not directly applicable.
◮ Classical optimization assumes null–rejection.
◮ null–rejection: the join/outer–join condition must fail in the
presence of null.
◮ SPARQL operations are never null–rejecting
◮ by definition of compatible mappings.
◮ Can we use classical optimization in the context of SPARQL?
◮ Well-designed patterns are suitable for reordering, and then for
classical optimization.
SLIDE 98
Well–designed graph patterns and optimization
Consider the following rules:
((P1 OPT P2) FILTER R) − → ((P1 FILTER R) OPT P2) (1) (P1 AND (P2 OPT P3)) − → ((P1 AND P2) OPT P3) (2) ((P1 OPT P2) AND P3) − → ((P1 AND P3) OPT P2) (3)
SLIDE 99
Well–designed graph patterns and optimization
Consider the following rules:
((P1 OPT P2) FILTER R) − → ((P1 FILTER R) OPT P2) (1) (P1 AND (P2 OPT P3)) − → ((P1 AND P2) OPT P3) (2) ((P1 OPT P2) AND P3) − → ((P1 AND P3) OPT P2) (3)
Proposition
If P is a well-designed pattern and Q is obtained from P by applying either (1) or (2) or (3), then Q is a well-designed pattern equivalent to P.
SLIDE 100
Well–designed graph patterns and optimization
Definition
A graph pattern P is in OPT normal form if there exist AND-FILTER patterns Q1, . . ., Qk such that: P is constructed from Q1, . . ., Qk by using only the OPT operator.
SLIDE 101
Well–designed graph patterns and optimization
Definition
A graph pattern P is in OPT normal form if there exist AND-FILTER patterns Q1, . . ., Qk such that: P is constructed from Q1, . . ., Qk by using only the OPT operator.
Theorem
Every well-designed pattern is equivalent to a pattern in OPT normal form.
SLIDE 102
Summary
◮ A formal compositional semantics for SPARQL ◮ Complexity bounds ◮ Normalization and initial optimizations procedures
SLIDE 103
Summary
◮ A formal compositional semantics for SPARQL ◮ Complexity bounds ◮ Normalization and initial optimizations procedures
Impact:
◮ Official semantics for SPARQL by W3C based on our work ◮ Base of the theoretical studies around SPARQL ◮ Journal version published in ACM TODS 2009
SLIDE 104
Semantics and Complexity of SPARQL
Jorge P´ erez
PhD Student Computer Science Department, PUC – Chile Work presented at the International Semantic Web Conference 2006