A Context-Based Semantics
for SPARQL Property Paths
over the Web
Olaf Hartig and Giuseppe Pirrò
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 2
Puzzle
Give me the URL of every Web document that
mentions its own URL somewhere in its text.
A Context-Based Semantics
for SPARQL Property Paths
over the Web
Olaf Hartig and Giuseppe Pirrò
Disclaimer:
This work is not about reasoning.
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 4
Property Path Pattern (PP Pattern)
(α, path, β)
variable, IRI, literal (or
bnode), respectively
property path expression
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 5
Property Path Expression
(α, path, β)
variable, IRI, literal (or
bnode), respectively
path := p | (IRI)
^path | (inverse)
path / path | (concatenation)
(path | path) | (alternative)
(path)* (recursive concatenation)
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 6
path := p | (IRI)
^path | (inverse)
path / path | (concatenation)
(path | path) | (alternative)
(path)* (recursive concatenation)
Example
( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x )
( ex:bob , foaf:knows , ex:alice )
( ex:alice , foaf:made , a:doc1 )
( e:objA , foaf:maker , ex:alice )
Data:
μ1 = { ?x → a:doc1 }
μ2 = { ?x → e:objA }
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 7
Example
( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x )
( ex:bob , foaf:knows , ex:alice )
( ex:alice , foaf:made , a:doc1 )
( e:objA , foaf:maker , ex:alice )
G =
⟦P⟧G = { μ1, μ2 }
P =
μ1 = { ?x → a:doc1 }
μ2 = { ?x → e:objA }
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 8
Example
( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x )
( ex:bob , foaf:knows , ex:alice )
( ex:alice , foaf:made , a:doc1 )
( e:objA , foaf:maker , ex:alice )
P =
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 9
Example
( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x )
P =
( ex:alice , foaf:made , a:doc1 )
( ex:bob , foaf:knows , ex:alice )
( e:objA , foaf:maker , ex:alice )
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 10
Example
( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x )
P =
⟦P⟧W = ??
What is the expected result of executing P
as a query over the Web of Linked Data?
Can this expected result be computed in practice?
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 11
Contributions
● Formal definition of a context-based query
semantics to use PP patterns (and SPARQL
patterns constructed thereof) as queries over
Linked Data in a well-defined manner.
● Web-safeness property of such queries (i.e.,
the fundamental feasibility of executing such a
query in practice over the WWW)
● Decidable syntactic property to identify
queries that are Web safe
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 12
⟦(u1, p, ?x)⟧W =
Context-Based Query Semantics
…
(u1, p, u2)
(u1, p, u3)
...
{ μ1, μ2 }
μ1 = { ?x → u2 }
μ2 = { ?x → u3 }
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 13
⟦(u1, p / q , ?x)⟧W =
Context-Based Query Semantics
…
(u1, p, u2)
(u1, p, u3)
...
{ μ1, μ2 }
μ1 = { ?x → b }
μ2 = { ?x → a }
…
(u3, q, a)
...
…
(u2, q, b)
...
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 14
Context-Based Query Semantics
= { μ={ ?x → u } | for every URI u s.t.
(u, p, a) in ctxt(u) }
⟦(?x, p, a)⟧W
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 15
Main Result
Theorem: A PP-based SPARQL pattern P is
Web-safe if cbvars( P | Ø ) = vars(P),
...where cbvars( P | X ) denotes the set of
conditionally bounded variables of P for a
given set X of variables (see paper).
● Open problem:
– Note that the condition is sufficient only.
– Is there an alternative condition that is sufficient
and also necessary (and decidable)?
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 16
Summary
● Formal definition of a context-based query
semantics to use PP patterns (and SPARQL
patterns constructed thereof) as queries over
Linked Data in a well-defined manner.
● Web-safeness property of such queries (i.e.,
the fundamental feasibility of executing such a
query in practice over the WWW)
● Decidable syntactic property to identify
queries that are Web safe
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 17
Backup Slides
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 18
Web-Safeness
A PP-based SPARQL pattern P is Web-safe if
there exists an algorithm that, for any Web of
Linked Data W = (D, adoc), computes ⟦P⟧W
without assuming an a-priori availability of
information about the sets D and dom(adoc).
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 19
Conditionally Bounded Variables
● cbvars( P | X ) denotes the set of conditionally
bounded variables of P for a given set X of variables
● Defined recursively for all types of patterns
– If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1)
and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then
cbvars( P | X ) = vars(P).
– If P is (u, p, β), then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø.
– etc.
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 20
Conditionally Bounded Variables
● cbvars( P | X ) denotes the set of conditionally
bounded variables of P for a given set X of variables
● Defined recursively for all types of patterns
– If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1)
and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then
cbvars( P | X ) = vars(P).
– If P is (u, p, β), then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø.
– etc.
Pex = ( (u1, p, ?x) AND (?x, q, ?y) )
cbvars( Pex | Ø ) = ?
Example
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 21
Conditionally Bounded Variables
● cbvars( P | X ) denotes the set of conditionally
bounded variables of P for a given set X of variables
● Defined recursively for all types of patterns
– If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1)
and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then
cbvars( P | X ) = vars(P).
– If P is (u, p, β), then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø.
– etc.
Pex = ( (u1, p, ?x) AND (?x, q, ?y) )
cbvars( P1 | Ø ) = {?x} cbvars( P2 | Ø ) = Ø
Example
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 22
Conditionally Bounded Variables
● cbvars( P | X ) denotes the set of conditionally
bounded variables of P for a given set X of variables
● Defined recursively for all types of patterns
– If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1)
and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then
cbvars( P | X ) = vars(P).
– If P is (u, p, β), then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø.
– etc.
Pex = ( (u1, p, ?x) AND (?x, q, ?y) )
cbvars( P1 | Ø ) = {?x} cbvars( P2 | sbvars(P1) )
Example
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 23
Conditionally Bounded Variables
● cbvars( P | X ) denotes the set of conditionally
bounded variables of P for a given set X of variables
● Defined recursively for all types of patterns
– If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1)
and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then
cbvars( P | X ) = vars(P).
– If P is (u, p, β), then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø.
– etc.
Pex = ( (u1, p, ?x) AND (?x, q, ?y) )
cbvars( P1 | Ø ) = {?x} cbvars( P2 | {?x} ) = {?x,?y}
Example
A Context-Based Semantics for SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 24
Conditionally Bounded Variables
● cbvars( P | X ) denotes the set of conditionally
bounded variables of P for a given set X of variables
● Defined recursively for all types of patterns
– If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1)
and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then
cbvars( P | X ) = vars(P).
– If P is (u, p, β), then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P).
– If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø.
– etc.
Pex = ( (u1, p, ?x) AND (?x, q, ?y) )
cbvars( Pex | Ø ) = vars(Pex) = {?x,?y}
Example

A Context-Based Semantics for SPARQL Property Paths over the Web

  • 1.
    A Context-Based Semantics forSPARQL Property Paths over the Web Olaf Hartig and Giuseppe Pirrò
  • 2.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 2 Puzzle Give me the URL of every Web document that mentions its own URL somewhere in its text.
  • 3.
    A Context-Based Semantics forSPARQL Property Paths over the Web Olaf Hartig and Giuseppe Pirrò Disclaimer: This work is not about reasoning.
  • 4.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 4 Property Path Pattern (PP Pattern) (α, path, β) variable, IRI, literal (or bnode), respectively property path expression
  • 5.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 5 Property Path Expression (α, path, β) variable, IRI, literal (or bnode), respectively path := p | (IRI) ^path | (inverse) path / path | (concatenation) (path | path) | (alternative) (path)* (recursive concatenation)
  • 6.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 6 path := p | (IRI) ^path | (inverse) path / path | (concatenation) (path | path) | (alternative) (path)* (recursive concatenation) Example ( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x ) ( ex:bob , foaf:knows , ex:alice ) ( ex:alice , foaf:made , a:doc1 ) ( e:objA , foaf:maker , ex:alice ) Data: μ1 = { ?x → a:doc1 } μ2 = { ?x → e:objA }
  • 7.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 7 Example ( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x ) ( ex:bob , foaf:knows , ex:alice ) ( ex:alice , foaf:made , a:doc1 ) ( e:objA , foaf:maker , ex:alice ) G = ⟦P⟧G = { μ1, μ2 } P = μ1 = { ?x → a:doc1 } μ2 = { ?x → e:objA }
  • 8.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 8 Example ( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x ) ( ex:bob , foaf:knows , ex:alice ) ( ex:alice , foaf:made , a:doc1 ) ( e:objA , foaf:maker , ex:alice ) P =
  • 9.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 9 Example ( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x ) P = ( ex:alice , foaf:made , a:doc1 ) ( ex:bob , foaf:knows , ex:alice ) ( e:objA , foaf:maker , ex:alice )
  • 10.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 10 Example ( ex:bob , foaf:knows / (foaf:made | ^foaf:maker) , ?x ) P = ⟦P⟧W = ?? What is the expected result of executing P as a query over the Web of Linked Data? Can this expected result be computed in practice?
  • 11.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 11 Contributions ● Formal definition of a context-based query semantics to use PP patterns (and SPARQL patterns constructed thereof) as queries over Linked Data in a well-defined manner. ● Web-safeness property of such queries (i.e., the fundamental feasibility of executing such a query in practice over the WWW) ● Decidable syntactic property to identify queries that are Web safe
  • 12.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 12 ⟦(u1, p, ?x)⟧W = Context-Based Query Semantics … (u1, p, u2) (u1, p, u3) ... { μ1, μ2 } μ1 = { ?x → u2 } μ2 = { ?x → u3 }
  • 13.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 13 ⟦(u1, p / q , ?x)⟧W = Context-Based Query Semantics … (u1, p, u2) (u1, p, u3) ... { μ1, μ2 } μ1 = { ?x → b } μ2 = { ?x → a } … (u3, q, a) ... … (u2, q, b) ...
  • 14.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 14 Context-Based Query Semantics = { μ={ ?x → u } | for every URI u s.t. (u, p, a) in ctxt(u) } ⟦(?x, p, a)⟧W
  • 15.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 15 Main Result Theorem: A PP-based SPARQL pattern P is Web-safe if cbvars( P | Ø ) = vars(P), ...where cbvars( P | X ) denotes the set of conditionally bounded variables of P for a given set X of variables (see paper). ● Open problem: – Note that the condition is sufficient only. – Is there an alternative condition that is sufficient and also necessary (and decidable)?
  • 16.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 16 Summary ● Formal definition of a context-based query semantics to use PP patterns (and SPARQL patterns constructed thereof) as queries over Linked Data in a well-defined manner. ● Web-safeness property of such queries (i.e., the fundamental feasibility of executing such a query in practice over the WWW) ● Decidable syntactic property to identify queries that are Web safe
  • 17.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 17 Backup Slides
  • 18.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 18 Web-Safeness A PP-based SPARQL pattern P is Web-safe if there exists an algorithm that, for any Web of Linked Data W = (D, adoc), computes ⟦P⟧W without assuming an a-priori availability of information about the sets D and dom(adoc).
  • 19.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 19 Conditionally Bounded Variables ● cbvars( P | X ) denotes the set of conditionally bounded variables of P for a given set X of variables ● Defined recursively for all types of patterns – If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1) and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then cbvars( P | X ) = vars(P). – If P is (u, p, β), then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø. – etc.
  • 20.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 20 Conditionally Bounded Variables ● cbvars( P | X ) denotes the set of conditionally bounded variables of P for a given set X of variables ● Defined recursively for all types of patterns – If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1) and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then cbvars( P | X ) = vars(P). – If P is (u, p, β), then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø. – etc. Pex = ( (u1, p, ?x) AND (?x, q, ?y) ) cbvars( Pex | Ø ) = ? Example
  • 21.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 21 Conditionally Bounded Variables ● cbvars( P | X ) denotes the set of conditionally bounded variables of P for a given set X of variables ● Defined recursively for all types of patterns – If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1) and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then cbvars( P | X ) = vars(P). – If P is (u, p, β), then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø. – etc. Pex = ( (u1, p, ?x) AND (?x, q, ?y) ) cbvars( P1 | Ø ) = {?x} cbvars( P2 | Ø ) = Ø Example
  • 22.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 22 Conditionally Bounded Variables ● cbvars( P | X ) denotes the set of conditionally bounded variables of P for a given set X of variables ● Defined recursively for all types of patterns – If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1) and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then cbvars( P | X ) = vars(P). – If P is (u, p, β), then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø. – etc. Pex = ( (u1, p, ?x) AND (?x, q, ?y) ) cbvars( P1 | Ø ) = {?x} cbvars( P2 | sbvars(P1) ) Example
  • 23.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 23 Conditionally Bounded Variables ● cbvars( P | X ) denotes the set of conditionally bounded variables of P for a given set X of variables ● Defined recursively for all types of patterns – If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1) and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then cbvars( P | X ) = vars(P). – If P is (u, p, β), then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø. – etc. Pex = ( (u1, p, ?x) AND (?x, q, ?y) ) cbvars( P1 | Ø ) = {?x} cbvars( P2 | {?x} ) = {?x,?y} Example
  • 24.
    A Context-Based Semanticsfor SPARQL Property Paths over the Web - Olaf Hartig and Giuseppe Pirrò 24 Conditionally Bounded Variables ● cbvars( P | X ) denotes the set of conditionally bounded variables of P for a given set X of variables ● Defined recursively for all types of patterns – If P is ( P1 AND P2 ) s.t. cbvars( P1 | X ) = vars(P1) and cbvars( P2 | X U sbvars(P1) ) = vars(P2), then cbvars( P | X ) = vars(P). – If P is (u, p, β), then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x in X, then cbvars( P | X ) = vars(P). – If P is (?x, p, β) s.t. ?x not in X, then cbvars( P | X ) = Ø. – etc. Pex = ( (u1, p, ?x) AND (?x, q, ?y) ) cbvars( Pex | Ø ) = vars(Pex) = {?x,?y} Example