diff --git a/spec/index.html b/spec/index.html index 3eabcac0..bfb76631 100644 --- a/spec/index.html +++ b/spec/index.html @@ -4694,6 +4694,15 @@

Operand Data Types

Expression Evaluation

+

+ A SPARQL expression is evaluated + with respect to a solution mapping + and in the context of an RDF dataset + with an active graph. + The result of such an evaluation is either + an RDF term or + an [=error=]. +

SPARQL provides a subset of the functions and operators defined by XPath and XQuery Functions and Operators. @@ -10048,16 +10057,18 @@

SPARQL Algebra

|D| be a dataset, and |G| be the active graph. We define:

-

Filter(expr, Ω, |D|, |G|) = { μ in Ω | expr(μ) is an expression that has an - [=effective boolean value=] of true }

-
- It is not clear what expr(μ) is, and it is not apparent in the formula that the expression |expr| is meant to be evaluated not only with respect to μ but also with respect to |D| with active graph |G|.
+

Filter(expr, Ω, |D|, |G|) = + { μ in Ω | + |expr|(μ, |D|, |G|) is an RDF term |t| + such that EBV(|t|) is `"true"^^xsd:boolean` }

multiplicity( μ | Filter(expr, Ω, |D|, |G|) ) = multiplicity( μ | Ω )

-
- Note that evaluating an exists(pattern) expression uses the dataset |D| and - active graph |G|. See the evaluation of filter. -
+

+ where, for every solution mapping μ, + |expr|(μ, |D|, |G|) is the result of + evaluating expression |expr| + with respect to μ, in the context of dataset |D| with active graph |G|. +

Definition: Join

@@ -10077,29 +10088,46 @@

SPARQL Algebra

of μ is the sum of the multiplicities from all possibilities.

Definition: Diff

-

Let Ω1 and Ω2 be multisets of solution mappings and expr be an - expression. We define:

-

Diff(Ω1, Ω2, expr) = { μ | μ in Ω1 such that ∀ μ' in - Ω2, either μ and μ' are not compatible or μ and μ' are compatible and - expr(merge(μ, μ')) does not have an [=effective boolean value=] of true }

-
- It is not clear what expr(μ) is, and it is not apparent in the formula that the expression |expr| is meant to be evaluated not only with respect to μ but also with respect to |D| with active graph |G|.
-

multiplicity( μ | Diff(Ω1, Ω2, expr) ) = +

Let Ω1 and Ω2 be multisets of solution mappings, + expr be an expression, + |D| be a dataset, + and |G| be the active graph. + We define:

+

Diff(Ω1, Ω2, expr, |D|, |G|) + = { μ in Ω1 | for every μ' in Ω2, + any of the following conditions holds:

+
    +
  • μ and μ' are not compatible,
  • +
  • μ and μ' are compatible + and |expr|(merge(μ, μ'), |D|, |G|) is an [=error=], or
  • +
  • μ and μ' are compatible + and |expr|(merge(μ, μ'), |D|, |G|) is an RDF term |t| + for which EBV(|t|) is not `"true"^^xsd:boolean`.
  • +
+

}

+

multiplicity( μ | Diff(Ω1, Ω2, expr, |D|, |G|) ) = multiplicity( μ | Ω1 )

+

+ where, for every solution mapping μ, + |expr|(μ, |D|, |G|) is the result of + evaluating expression |expr| + with respect to μ, in the context of dataset |D| with active graph |G|. +

-

The evaluation of expr(merge(μ, μ')) does not have an - [=effective boolean value=] of true if it evaluates to false or if it raises an error.

Diff is used internally for the definition of LeftJoin.

Definition: LeftJoin

-

Let Ω1 and Ω2 be multisets of solution mappings and expr be an - expression. We define:

-

LeftJoin(Ω1, Ω2, expr) = Filter(expr, Join(Ω1, - Ω2)) ∪ Diff(Ω1, Ω2, expr)

-

multiplicity( μ | LeftJoin(Ω1, Ω2, expr) ) = - multiplicity( μ | Filter(expr, Join(Ω1, Ω2)) ) + +

Let Ω1 and Ω2 be multisets of solution mappings, + expr be an expression, + |D| be a dataset, + and |G| be the active graph. + We define:

+

LeftJoin(Ω1, Ω2, expr, |D|, |G|) = Filter(expr, Join(Ω1, + Ω2), |D|, |G|) ∪ Diff(Ω1, Ω2, expr, |D|, |G|)

+

multiplicity( μ | LeftJoin(Ω1, Ω2, expr, |D|, |G|) ) = + multiplicity( μ | Filter(expr, Join(Ω1, Ω2), |D|, |G|) ) + multiplicity( μ | Diff(Ω1, Ω2, - expr) )

+ expr, |D|, |G|) )

@@ -10128,14 +10156,28 @@

SPARQL Algebra

pattern P.

Definition: Extend

-

Let μ be a solution mapping, Ω a multiset of solution mappings, var a variable - and expr be an expression, then we define:

-

Extend(μ, var, expr) = μ ∪ { (var, value) | var not in dom(μ) and value = expr(μ) }

-
- It is not clear what expr(μ) is, and it is not apparent in the formula that the expression |expr| is meant to be evaluated not only with respect to μ but also with respect to |D| with active graph |G|.
-

Extend(μ, var, expr) = μ if var not in dom(μ) and expr(μ) is an error

-

Extend is undefined if var in dom(μ).

-

Extend(Ω, var, expr) = { Extend(μ, var, expr) | μ in Ω }

+

Let μ be a solution mapping, Ω a multiset of solution mappings, + var be a variable, + expr be an expression, + |D| be a dataset, + and |G| be the active graph. + We define:

+

Extend(Ω, var, expr, |D|, |G|) = { |Extend|(μ, var, expr, |D|, |G|) | μ in Ω },

+

where, for every solution mapping μ,

+

|Extend|(μ, var, expr, |D|, |G|) = μ ∪ { (var, |expr|(μ, |D|, |G|)) } + if var not in dom(μ) and + |expr|(μ, |D|, |G|) is an RDF term,

+

|Extend|(μ, var, expr, |D|, |G|) = μ + if var not in dom(μ) and + |expr|(μ, |D|, |G|) is an [=error=],

+

|Extend|(μ, var, expr, |D|, |G|) is undefined + if var in dom(μ), and

+

|expr|(μ, |D|, |G|) is the result of + evaluating expression |expr| + with respect to μ, in the context of dataset |D| with active graph |G|. +

+
+ We need to define multiplicity( μ | Extend(Ω, var, expr, |D|, |G|) )

Write [ x | C ] for a sequence of elements where C is a condition on x.

@@ -10631,7 +10673,7 @@

Evaluation Semantics

Definition: Evaluation of LeftJoin

-eval( |D|(|G|), LeftJoin(P1, P2, |F|) ) = LeftJoin( eval(|D|(|G|), P1), eval(|D|(|G|), P2), |F| ) +eval( |D|(|G|), LeftJoin(P1, P2, |F|) ) = LeftJoin( eval(|D|(|G|), P1), eval(|D|(|G|), P2), |F|, |D|, |G| )

@@ -10702,9 +10744,9 @@

Evaluation Semantics

Note that if eval(|D|(|G|), Ai) is an error, it is ignored.

-

Definition: Evaluation of Extend

+

Definition: Evaluation of Extend

-eval( |D|(|G|), Extend(|P|, |var|, |expr|) ) = Extend( eval(|D|(|G|), |P|), |var|, |expr| ) +eval( |D|(|G|), Extend(|P|, |var|, |expr|) ) = Extend( eval(|D|(|G|), |P|), |var|, |expr|, |D|, |G| )

@@ -12652,6 +12694,9 @@

Changes between SPARQL 1.1 Query Language and SPARQL 1.2 Query Language

from eval to reachableTerms.
  • Add section about SPARQL expression evaluation errors.
  • Rename section "Filter evaluation" as .
  • +
  • Improve definitions of all algebra operators that involve expressions + (Filter, Diff, + LeftJoin, and Extend).