diff --git a/spec/index.html b/spec/index.html index ed5ad663..de3f892f 100644 --- a/spec/index.html +++ b/spec/index.html @@ -9686,46 +9686,54 @@
This section defines the evaluation of property path - patterns. A property path pattern is a subject endpoint (an RDF term or a variable), a - property path express and an object endpoint. The - translation of property path expressions converts some - forms to other SPARQL expressions, such as converting property paths of length one to triple - patterns, which in turn are combined into basic graph patterns. This leaves property path - operators ZeroOrOnePath, ZeroOrMorePath, OneOrMorePath and NegatedPropertySets and also path + patterns. A property path pattern consists of a subject endpoint (an RDF term or a variable), a + property path expression, and an object endpoint.
+The translation of property path expressions
+ converts every property path expression
+ into an algebraic property path expression.
+ For example, the property path expression (:p/:q)*
+ is a ZeroOrMorePath expression involving a sequence property path,
+ and is translated into the algebraic property path expression
+ ZeroOrMorePath( seq(link(:p), link(:q)) ).
Thereafter, the translation of property path patterns + converts some of these algebraic property path expressions + to other SPARQL graph patterns, such as converting property paths of length one to triple + patterns, which in turn are combined into basic graph patterns. + This leaves algebraic property path expressions with the operators + ZeroOrOnePath, + ZeroOrMorePath, + OneOrMorePath, + and NegatedPropertySets, + as well as algebraic property path expressions contained within these operators.
-All remaining property path expressions are present in the algebra in the form
- Path(X, path, Y) for endpoints X and Y. For example: syntax(:p/:q)*
- is a ZeroOrMorePath expression involving a sequence property path becoming the algebra
- expession ZeroOrMorePath(seq(link(:p), link(:q))).
The property path patterns with these remaining algebraic property path expressions + are present in the algebraic syntax in the form + Path(|X|, |ppe|, |X|) for endpoints |X| and |Y|.
Write
-eval(Path(X, PP, Y))-
for the evaluation of the property path patterns. This produces a multiset of solution - mappings μ, each solution mapping having a binding for variables used (each of X and Y can +
To denote the evaluation of the property path pattern, for every + algebraic query expression + of the form + Path(|X|, |ppe|, |Y|), we write the following:
+ppeval(X, ppe, Y)+
This produces a multiset of solution + mappings, each solution mapping having a binding for variables used (each of |X| and |Y| can be a variable). Some operators only produce a set of solution mappings.
-Write
-
-Var(x1, x2, ..., xn) = { xi | i in 1...n and xi is a variable
-}
-
- for the variables in x1, x2, ..., xn.
Write
x:term |
- when x is an RDF term |
+ Write | +When |x| is |
|---|---|---|---|
x:var |
- when x is a variable |
+ |x|:term |
+ an RDF term |
x:path |
- when x is a path expression |
+ |x|:var |
+ a variable |
Definition: Evaluation of Predicate Property Path
-Let Path(X, link(iri), Y) be an predicate inverse property path pattern, using some IRI - iri.
--eval(Path(X, link(iri), Y)) = evaluation of basic graph pattern {X iri Y} +Let |iri| be an IRI.
++ppeval(X, link(iri), Y) = evaluation of basic graph pattern {X iri Y}
If both X and Y are variables, this is the same as:
-
-eval(Path(X:var, link(iri), Y:var)) = { (X, xn) (Y, yn) | xn and yn are RDF terms and triple (xn iri yn) is in the active graph }
- If X is a variable and Y an RDF term:
-
-eval(Path(X:var, link(iri), Y:term)) = { (X, xn) | xn is an RDF term and triple (xn iri Y) is in the active graph
-}
-
- If X is an RDF term and Y is a variable:
-
-eval(Path(X:term, link(iri), Y:var)) = { (Y, yn) | yn is an RDF term and triple (X iri yn) is in the active graph
-}
-
- If both X and Y are RDF terms:
-
-eval(Path(X:term, link(iri), Y:term))
- = { μ0 } if triple (X iri Y) is in the active graph
+ If both |X| and |Y| are variables, this is the same as:
+
+ppeval(X:var, link(iri), Y:var) =
+ { (X, xn:term) (Y, yn:term) | triple (xn, iri, yn) is in the active graph }
+ If |X| is a variable and |Y| an RDF term:
+
+ppeval(X:var, link(iri), Y:term) =
+ { (X, xn:term) | triple (xn, iri, Y) is in the active graph }
+ If |X| is an RDF term and |Y| is a variable:
+
+ppeval(X:term, link(iri), Y:var) =
+ { (Y, yn:term) | triple (X, iri, yn) is in the active graph }
+ If both |X| and |Y| are RDF terms:
+
+ppeval(X:term, link(iri), Y:term)
+ = { μ0 } if triple (X, iri, Y) is in the active graph
= { { } } = Ω0
-eval(Path(X:term, link(iri), Y:term)) = { } if triple (X iri Y) is not in the active graph
+ppeval(X:term, link(iri), Y:term) =
+ { } if triple (X, iri, Y) is not in the active graph
Informally, evaluating a Predicate Property Path is the same as executing a subquery
- SELECT * { X P Y } at that point in the query evaluation.
+ SELECT * { |X| |iri| |Y| } at that point in the query evaluation.
Definition: Evaluation of Inverse Property Path
- Let P be a property path expression, then:
- eval(Path(X, inv(P), Y)) = eval(Path(Y, P, X))
+ Let |ppe| be an algebraic property path expression, then:
+ ppeval(X, inv(ppe), Y) = ppeval(Y, ppe, X)
Definition: Evaluation of Sequence Property Path
- Let P and Q be property path expressions. Let V be a fresh variable.
- A = Join( eval(Path(X, P, V)), eval(Path(V, Q, Y)) )
- eval(Path(X, seq(P,Q), Y)) = Project(A, Var(X,Y))
+ Let ppe1 and ppe2 be algebraic property path expressions. Let |V| be a fresh variable.
+ A = Join( ppeval(X, ppe1, V), ppeval(V, ppe2, Y) )
+ ppeval(X, seq(ppe1, ppe2), Y) = Project(A, PV)
+ where |PV| = { |v| ∈ {|X|,|Y|} | |v| is a variable}.
+
Informally, this is the same as:
- SELECT * { X P _:a . _:a Q Y }
- using the fact that a blank node _:a acts like a variable (under simple
+
SELECT * { X P1 _:a . _:a P2 Y }
+ where P1 is a
+ property path expression
+ that can be translated into the
+ algebraic property path expression ppe1,
+ and P2 can be translated into ppe2.
+ This observation is based on the fact that a blank node _:a acts like a variable (under simple
entailment) except it does not appear in the results from SELECT *.
Definition: Evaluation of Alternative Property Path
- Let P and Q be property path expressions.
-
-eval(Path(X, alt(P,Q), Y)) =
- Union(eval(Path(X, P, Y)), eval(Path(X, Q, Y)))
+ Let ppe1 and ppe2 be algebraic property path expressions.
+
+ppeval(X, alt(ppe1, ppe2), Y) =
+ Union( ppeval(X, ppe1, Y), ppeval(X, ppe2, Y) )
Informally, this is the same as:
- SELECT * { { X P Y } UNION { X Q Y } }
+ SELECT * { { X P1 Y } UNION { X P2 Y } }
+ where P1 is a
+ property path expression
+ that can be translated into the
+ algebraic property path expression ppe1,
+ and P2 can be translated into ppe2.
Definition: Node set of a graph
- The node set of a graph G, nodes(G), is:
- nodes(G) = { n | n is an RDF term that is used as a subject or object of a triple of
- G}
+ The node set of a graph |G|, nodes(|G|), is:
+ nodes(|G|) = { |n| | |n| is an RDF term that is used as a subject or object of an asserted triple of
+ |G|}
Definition: Evaluation of ZeroOrOnePath
-
-eval(Path(X:term, ZeroOrOnePath(P), Y:var)) =
- { (Y, yn) | yn = X or {(Y, yn)} in eval(Path(X,P,Y)) }
+ Let |ppe| be an algebraic property path expression.
+ Let G be the active graph.
+
+ppeval(X:term, ZeroOrOnePath(ppe), Y:var) =
+ { (Y, yn) | yn = X or {(Y, yn)} in ppeval(X, ppe, Y) }
-
-eval(Path(X:var, ZeroOrOnePath(P), Y:term)) =
- { (X, xn) | xn = Y or {(X, xn)} in eval(Path(X,P,Y)) }
+
+ppeval(X:var, ZeroOrOnePath(ppe), Y:term) =
+ { (X, xn) | xn = Y or {(X, xn)} in ppeval(X, ppe, Y) }
-
-eval(Path(X:term, ZeroOrOnePath(P), Y:term)) =
- { {} } if X = Y or eval(Path(X,P,Y)) is not empty
- { } othewise
-
-eval(Path(X:var, ZeroOrOnePath(P), Y:var)) =
- { (X, xn) (Y, yn) | either (yn in nodes(G) and xn = yn) or {(X,xn), (Y,yn)} in eval(Path(X,P,Y)) }
+
+ppeval(X:term, ZeroOrOnePath(ppe), Y:term) =
+ { {} } if X = Y or ppeval(X,ppe,X) is not empty
+ { } otherwise
+
+ppeval(X:var, ZeroOrOnePath(ppe), Y:var) =
+ { (X, xn) (Y, yn) |
+ either (yn in nodes(G) and xn = yn)
+ or {(X, xn), (Y, yn)} in ppeval(X, ppe, Y) }
- We define an auxillary function, ALP, used in the definitions of ZeroOrMorePath and
- OneOrMorePath. Note that the algorithm given here serves to specify the feature. An
- implementation is free to implement evaluation by any method that produces the same results
- for the query overall. The ZeroOrMorePath and OneOrMorePath forms return matches based on
+
We define an auxiliary function, ALP, used in the definitions of ZeroOrMorePath and
+ OneOrMorePath. Note that the algorithm given here serves to specify the feature. An
+ implementor is free to implement evaluation by any method that produces the same results
+ for the query overall. The ZeroOrMorePath and OneOrMorePath forms return matches based on
distinct nodes connected by the path.
The matching algorithm is based on following all paths, and detecting when a graph node
(subject or object), has been already visited on the path.
Informally, this algorithm attempts to extend the multiset of results by one application
- of path at each step, noting which nodes it has visited for this particular path. If
+ of the given algebraic property path expression |ppe| at each step, noting which nodes it has visited for this particular path. If
a node has been visited for the path under consideration, it is not a candidate for another
step.
Definition: Function ALP
-
-Let eval(x:term, path) be the evaluation of 'path', starting at RDF term x,
+
+Let ppe be an algebraic property path expression.
+Let eval(x:term, ppe) be the evaluation of ppe,
+ starting at RDF term x,
and returning a multiset of RDF terms reached
- by repeated matches of path.
-
- ALP(x:term, path) =
- Let V = empty set
- ALP(x:term, path, V)
- return is V
-
- # V is the set of nodes visited
-
- ALP(x:term, path, V:set of RDF terms) =
- if ( x in V ) return
- add x to V
- X = eval(x,path)
- For n:term in X
- ALP(n, path, V)
+ starting at RDF term x, and returning a multiset
+ of RDF terms reached by repeated matches of ppe.
+
+ ALP(x:term, ppe) =
+ Let V = empty set
+ ALP(x:term, ppe, V)
+ return is V
+
+ # V is the set of nodes visited
+
+ ALP(x:term, ppe, V:set of RDF terms) =
+ if ( x in V ) return
+ add x to V
+ X = eval(x, ppe)
+ For n:term in X
+ ALP(n, ppe, V)
End
- Definition: Evaluation of
-
- ZeroOrMorePath
-
-
-eval(Path(X:term, ZeroOrMorePath(path), vy:var)) =
- { { (vy, n) } | n in ALP(X, path) }
-
-eval(Path(vx:var, ZeroOrMorePath(path), vy:var)) =
- { { (vx, t), (vy, n) } | t in nodes(G), (vy, n) in eval(Path(t, ZeroOrMorePath(path), vy)) }
-
-eval(Path(vx:var, ZeroOrMorePath(path), y:term)) =
- eval(Path(y:term, ZeroOrMorePath(inv(path)), vx:var))
-
-eval(Path(x:term, ZeroOrMorePath(path), y:term)) =
- { { } } if { (vy:var,y) } in eval(Path(x, ZeroOrMorePath(path) vy)
+ Definition: Evaluation of ZeroOrMorePath
+ Let ppe be an algebraic property path expression.
+ Let G be the active graph.
+
+ppeval(X:term, ZeroOrMorePath(ppe), vy:var) =
+ { { (vy, n) } | n in ALP(X, ppe) }
+
+ppeval(vx:var, ZeroOrMorePath(ppe), vy:var) =
+ { { (vx, t), (vy, n) } |
+ t in nodes(G), (vy, n) in ppeval(t, ZeroOrMorePath(ppe), vy) }
+
+ppeval(vx:var, ZeroOrMorePath(ppe), y:term) =
+ ppeval(y:term, ZeroOrMorePath(inv(ppe)), vx:var)
+
+ppeval(x:term, ZeroOrMorePath(ppe), y:term) =
+ { { } } if { (vy:var,y) } in ppeval(x, ZeroOrMorePath(ppe), vy)
{ } otherwise
- Definition: Evaluation of
-
- OneOrMorePath
-
- eval(Path(X, OneOrMorePath(path), Y))
-
-# For OneOrMorePath, we take one step of the path then start
+ Definition: Evaluation of OneOrMorePath
+ Let ppe be an algebraic property path expression.
+ Let G be the active graph.
+
+# For OneOrMorePath, we take one step of the path then start
# recording nodes for results.
-eval(Path(x:term, OneOrMorePath(path), vy:var)) =
- Let X = eval(x, path)
- Let V = the empty multiset
- For n in X
- ALP(n, path, V)
+ppeval(x:term, OneOrMorePath(ppe), vy:var) =
+ Let X = eval(x, ppe)
+ Let V = the empty multiset
+ For n in X
+ ALP(n, ppe, V)
End
- result is V
+ result is V
-eval(Path(vx:var, OneOrMorePath(path), vy:var)) =
- { { (vx, t), (vy, n) } | t in nodes(G), (vy, n) in eval(Path(t, OneOrMorePath(path), vy)) }
+ppeval(vx:var, OneOrMorePath(ppe), vy:var) =
+ { { (vx, t), (vy, n) } |
+ t in nodes(G), (vy, n) in ppeval(t, OneOrMorePath(ppe), vy) }
-eval(Path(vx:var, OneOrMorePath(path), y:term)) =
- eval(Path(y:term, OneOrMorePath(inv(path)), vx))
+ppeval(vx:var, OneOrMorePath(ppe), y:term) =
+ ppeval(y:term, OneOrMorePath(inv(ppe)), vx)
-eval(Path(x:term, OneOrMorePath(path), y:term)) =
- { { } } if { (vy:var, y) } in eval(Path(x, OneOrMorePath(path), vy))
+ppeval(x:term, OneOrMorePath(ppe), y:term) =
+ { { } } if { (vy:var, y) } in ppeval(x, OneOrMorePath(ppe), vy)
{ } otherwise
+V is not a multiset of solution mappings but a set of RDF terms.
Definition: Evaluation of NegatedPropertySet
-
-Write μ' as the extension of a solution mapping:
-μ'(μ,x) = μ(x) if x is a variable
-μ'(μ,t) = t if t is a RDF term
+
+Write μ' as the extension of a solution mapping:
+μ'(μ, x) = μ(x) if x is a variable
+μ'(μ, t) = t if t is an RDF term
-
-Let x and y be variables or RDF terms, and S a set of IRIs:
+
+Let x and y be variables or RDF terms, S a set of IRIs,
+and G the active graph.
- eval(Path(x, NPS(S), y)) = { μ | ∃ triple(μ'(μ,x), p, μ'(μ,y)) in G, such that the IRI of p ∉ S }
+ ppeval(x, NPS(S), y) =
+ { μ | ∃ triple(μ'(μ, x), p, μ'(μ, y)) in G, such that the IRI of p ∉ S }