From 2ba4ae3b0993824cb615d5c83ce897567a669479 Mon Sep 17 00:00:00 2001 From: Olaf Hartig Date: Fri, 9 May 2025 15:13:27 +0200 Subject: [PATCH 1/3] linked function names and markup for variables in formulas in Sec.18.5 and 18.5.1, but not yet in 18.5.2 --- spec/index.html | 375 ++++++++++++++++++++++++------------------------ 1 file changed, 190 insertions(+), 185 deletions(-) diff --git a/spec/index.html b/spec/index.html index 70bf09c..c760399 100644 --- a/spec/index.html +++ b/spec/index.html @@ -8374,10 +8374,10 @@

Solution Sequence Modifiers

A solution sequence modifier is one of:

-

GroupConcat(S, scalarvals) = +

GroupConcat(S, scalarvals) = GCList(L, sep),

where L = Flatten(S) and GCList(L, sep) @@ -10257,25 +10262,25 @@

GroupConcat
L, and L2..n is L without its first element.

-

For example, GroupConcat([("a"), ("b"), ("c")], {"separator" → "."}) +

For example, GroupConcat([("a"), ("b"), ("c")], {"separator" → "."}) = GCList( ("a", "b", "c"), "." ) = "a.b.c".

Sample
-

Sample is a set function which returns an arbitrary value from the sequence passed +

Sample is a set function which returns an arbitrary value from the sequence passed to it.

Definition: Sample

-
RDFTerm Sample(sequence S)
+
RDFTerm Sample(sequence S)

If Card(S) = 0, then - Sample(S) = error.

+ Sample(S) = error.

If Card(S) > 0, then - Sample(S) = v, where v + Sample(S) = v, where v in Flatten(S).

-

For example, given Sample([("a"), ("b"), ("c")]), "a", "b", and "c" are all valid return - values. Note that the Sample function is not required to be deterministic for a given input. The +

For example, given Sample([("a"), ("b"), ("c")]), "a", "b", and "c" are all valid return + values. Note that the Sample function is not required to be deterministic for a given input. The only restriction is that the output value must be present in the input sequence.

From a8c3c947b2edb239524c2ebb30248db35270218d Mon Sep 17 00:00:00 2001 From: Olaf Hartig Date: Fri, 9 May 2025 18:47:19 +0200 Subject: [PATCH 2/3] uses linked function names and markup for variables in formulas in Sec.18.5.2 --- spec/index.html | 188 ++++++++++++++++++++++++------------------------ 1 file changed, 93 insertions(+), 95 deletions(-) diff --git a/spec/index.html b/spec/index.html index c760399..fe0cab5 100644 --- a/spec/index.html +++ b/spec/index.html @@ -10074,13 +10074,13 @@
Set Functions
functions are in fact sequences. The name is retained due to the commonality with SQL Set Functions, which operate over multisets.

The set functions defined in this document are - Count, - Sum, - Min, - Max, - Avg, - GroupConcat, and - Sample + Count, + Sum, + Min, + Max, + Avg, + GroupConcat, and + Sample — corresponding to the aggregates COUNT, SUM, MIN, MAX, AVG, GROUP_CONCAT, and SAMPLE. Definitions may be found in the @@ -10120,27 +10120,27 @@

Set Functions
Count
-

Count is a SPARQL set function which counts the number of times a given expression +

Count is a SPARQL set function which counts the number of times a given expression has a bound, non-error value within the aggregate group.

Definition: Count

-
xsd:integer Count(sequence S)
-

Count(S) = Card(L'),

+
xsd:integer Count(sequence S)
+

Count(S) = Card(L'),

where L' is the list L = Flatten(S) with all error elements removed.

Sum
-

Sum is a SPARQL set function that returns the numeric value obtained by summing +

Sum is a SPARQL set function that returns the numeric value obtained by summing the values within the aggregate group. Type promotion happens as per the op:numeric-add function, applied transitively, (see definition below) so the value of SUM(?x), in an aggregate group where ?x has values 1 (integer), 2.0e0 (float), and 3.0 (decimal) will be 6.0 (float).

Definition: Sum

-
numeric Sum(sequence S)
-

Sum(S) = SumList(L),

+
numeric Sum(sequence S)
+

Sum(S) = SumList(L),

where L = Flatten(S) and SumList(L) is defined recursively as follows.

    @@ -10156,37 +10156,37 @@
    Sum
    L, and L2..n is L without its first element.

-

In this way, Sum( [(1), (2), (3)] ) = SumList( (1, 2, 3) ) = +

In this way, Sum( [(1), (2), (3)] ) = SumList( (1, 2, 3) ) = op:numeric-add(1, op:numeric-add(2, op:numeric-add(3, 0))).

Avg
-
The Avg set function calculates the +
The Avg set function calculates the average value for an expression over a group. It is defined in terms of Sum and Count.

Definition: Avg

-
numeric Avg(sequence S)
+
numeric Avg(sequence S)

If Count(S) = 0, - then Avg(S) = "0"^^xsd:integer.

+ then Avg(S) = "0"^^xsd:integer.

If Count(S) > 0, - then Avg(S) = - Sum(S) / - Count(S).

+ then Avg(S) = + Sum(S) / + Count(S).

-

For example, Avg([(1), (2), (3)]) = +

For example, Avg([(1), (2), (3)]) = Sum([(1), (2), (3)])/Count([(1), (2), (3)]) = 6/3 = 2.

Min
-

Min is a SPARQL set function that returns the minimum value from a group +

Min is a SPARQL set function that returns the minimum value from a group respectively.

It makes use of the SPARQL ORDER BY ordering definition, to allow ordering over arbitrarily typed expressions.

Definition: Min

-
term Min(sequence S)
-

Min(S) = MinList(L),

+
term Min(sequence S)
+

Min(S) = MinList(L),

where L is the list of values obtained by Flatten(S) and then ordered as per the ORDER BY ASC clause, @@ -10203,14 +10203,14 @@

Min
Max
-

Max is a SPARQL set function that returns the maximum value from a group +

Max is a SPARQL set function that returns the maximum value from a group respectively.

It makes use of the SPARQL ORDER BY ordering definition, to allow ordering over arbitrarily typed expressions.

Definition: Max

-
term Max(sequence S)
-

Max(S) = MaxList(L),

+
term Max(sequence S)
+

Max(S) = MaxList(L),

where L is the list of values obtained by Flatten(S) and then ordered as per the ORDER BY DESC clause, @@ -10227,13 +10227,13 @@

Max
GroupConcat
-

GroupConcat is a set function which performs a string concatenation across the +

GroupConcat is a set function which performs a string concatenation across the values of an expression with a group. The order of the strings is not specified. The separator character used in the concatenation may be given with the scalar argument SEPARATOR.

Definition: GroupConcat

-
literal GroupConcat(sequence S, function scalarvals)
+
literal GroupConcat(sequence S, function scalarvals)

If the scalarvals argument is absent from GROUP_CONCAT, then scalarvals is taken to be the empty function.

Let sep be a string that is defined as follows.

@@ -10243,7 +10243,7 @@
GroupConcat
  • If scalarvals is undefined for the argument "separator", then sep is the "space" character (i.e., unicode codepoint U+0020).
  • -

    GroupConcat(S, scalarvals) = +

    GroupConcat(S, scalarvals) = GCList(L, sep),

    where L = Flatten(S) and GCList(L, sep) @@ -10262,169 +10262,167 @@

    GroupConcat
    L, and L2..n is L without its first element.

    -

    For example, GroupConcat([("a"), ("b"), ("c")], {"separator" → "."}) +

    For example, GroupConcat([("a"), ("b"), ("c")], {"separator" → "."}) = GCList( ("a", "b", "c"), "." ) = "a.b.c".

    Sample
    -

    Sample is a set function which returns an arbitrary value from the sequence passed +

    Sample is a set function which returns an arbitrary value from the sequence passed to it.

    Definition: Sample

    -
    RDFTerm Sample(sequence S)
    +
    RDFTerm Sample(sequence S)

    If Card(S) = 0, then - Sample(S) = error.

    + Sample(S) = error.

    If Card(S) > 0, then - Sample(S) = v, where v + Sample(S) = v, where v in Flatten(S).

    -

    For example, given Sample([("a"), ("b"), ("c")]), "a", "b", and "c" are all valid return - values. Note that the Sample function is not required to be deterministic for a given input. The +

    For example, given Sample([("a"), ("b"), ("c")]), "a", "b", and "c" are all valid return + values. Note that the Sample function is not required to be deterministic for a given input. The only restriction is that the output value must be present in the input sequence.

    Evaluation Semantics

    -

    We define eval(D(G), algebra expression) as the evaluation of an algebra expression with - respect to a dataset D having active graph G. The active graph is initially the default - graph.

    -
    -D : a dataset
    -D(G) : D a dataset with active graph G (the one patterns match against)
    -D[i] : The graph with IRI i in dataset D
    -P, P1, P2 : graph patterns
    -L : a solution sequence
    -F : an expression
    -          
    +

    We define eval(|D|(|G|), |A|) as the evaluation of an algebra expression |A| with + respect to a dataset |D| having active graph |G|. The active graph is initially the default + graph of |D|. Further symbols and notation used in the following definitions are:

    +
      +
    • |D|[|i|] : Denotes the graph with IRI |i| in dataset |D|
    • +
    • |P|, P1, P2 : graph patterns
    • +
    • |L| : a solution sequence
    • +
    • |F| : an expression
    • +

    Definition: Evaluation of a Basic Graph Pattern

    -
    eval(D(G), BGP) = multiset of solution mappings
    +

    eval( |D|(|G|), |BGP| ) = multiset of solution mappings

    See section Basic Graph Patterns

    Definition: Evaluation of a Property Path Pattern

    -
    eval(D(G), Path(X, path, Y)) = multiset of solution mappings
    -

    See section Property Path Expresions

    +

    eval( |D|(|G|), Path(|X|, |path|, |Y|) ) = multiset of solution mappings

    +

    See section Property Path Expressions

    Definition: Evaluation of Filter

    -
    eval(D(G), Filter(F, P)) = Filter(F, eval(D(G),P), D(G))
    +

    eval( |D|(|G|), Filter(|F|, |P|) ) = Filter( |F|, eval(|D|(|G|), |P|), |D|(|G|) )

    'substitute' is a filter function in support of the evaluation of EXISTS and NOT EXISTS forms which were translated to exists.

    Definition: Substitute

    -

    Let μ be a solution mapping.

    +

    Let μ be a solution mapping.

    -

    substitute(pattern, μ) = the pattern formed by replacing every occurrence of - a variable v in pattern by μ(v) for each v in dom(μ)

    +

    substitute(|pattern|, μ) = the pattern formed by replacing every occurrence of + a variable |v| in |pattern| by μ(|v|) for each |v| in dom(μ)

    Definition: Evaluation of Exists

    -

    Let μ be the current solution mapping for a filter and P a graph pattern:

    +

    Let μ be the current solution mapping for a filter and |P| a graph pattern:

    - The value exists(P), given D(G) is true if and only if eval(D(G), substitute(P, μ)) is + The value exists(|P|), given |D|(|G|) is true if and only if eval( |D|(|G|), substitute(|P|, μ)) is a non-empty sequence.

    Definition: Evaluation of Join

    -
    eval(D(G), Join(P1, P2)) = Join(eval(D(G), P1), eval(D(G), P2))
    +

    eval( |D|(|G|), Join(P1, P2) ) = Join( eval(|D|(|G|), P1), eval(|D|(|G|), P2) )

    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| ) +

    Definition: Evaluation of Union

    -
    eval(D(G), Union(P1,P2)) = Union(eval(D(G), P1), eval(D(G), P2))
    +

    eval( |D|(|G|), Union(P1, P2) ) = Union( eval(|D|(|G|), P1), eval(|D|(|G|), P2) )

    Definition: Evaluation of Graph

    -if IRI is a graph name in D
    -    eval(D(G), Graph(IRI,P)) = eval(D(D[IRI]), P)
    +if IRI is a graph name in D
    +    eval( D(G), Graph(IRI,P) ) = eval( D(D[IRI]), P )
                 
    -              if IRI is not a graph name in D
    -                  eval(D(G), Graph(IRI,P)) = the empty multiset
    +              if IRI is not a graph name in D
    +                  eval( D(G), Graph(IRI,P) ) = the empty multiset
                 
    -eval(D(G), Graph(var,P)) =
    -    Let R be the empty multiset
    -    foreach IRI i in D
    -        R := Union(R, Join( eval(D(D[i]), P) , Ω(?var->i) ) )
    -    the result is R
    +eval( D(G), Graph(var,P) ) =
    +    Let R be the empty multiset
    +    foreach IRI i in D
    +        R := Union(R, Join( eval(D(D[i]), P) , Ω(var->i) ) )
    +    the result is R
                 
    -

    The evaluation of graph uses the SPARQL algebra union operator. The multiplicity of a - solution mapping is the sum of the multiplicities of that solution mapping in each join +

    The evaluation of graph uses the Union operator. The multiplicity of a + solution mapping is the sum of the multiplicities of that solution mapping in each Join operation.

    Definition: Evaluation of Group
    -

    eval(D(G), Group(exprlist, P)) = Group(exprlist, eval(D(G), P))

    +

    eval( |D|(|G|), Group(|exprlist|, |P|) ) = Group( |exprlist|, eval(|D|(|G|), |P|) )

    Definition: Evaluation of Aggregation
    -

    eval(D(G), Aggregation(exprlist, func, scalarvals, Grp)) = Aggregation(exprlist, func, - scalarvals, eval(D(G), Grp))

    +

    eval( |D|(|G|), Aggregation(|exprlist|, |func|, |scalarvals|, |Grp|) ) = Aggregation( |exprlist|, |func|, + |scalarvals|, eval(|D|(|G|), |Grp|) )

    Definition: Evaluation of AggregateJoin
    -

    eval(D(G), AggregateJoin(A1, ..., An)) = - AggregateJoin(eval(D(G), A1), ..., eval(D(G), An))

    +

    eval( |D|(|G|), AggregateJoin(A1, ..., An) ) = + AggregateJoin( eval(|D|(|G|), A1), ..., eval(|D|(|G|), An) )

    -

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

    +

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

    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| ) +

    Definition: Evaluation of ToList

    -
    eval(D(G), ToList(P)) = ToList(eval(D(G), P))
    +

    eval( |D|(|G|), ToList(|P|) ) = ToList( eval(|D|(|G|), |P|) )

    Definition: Evaluation of Distinct

    -
    eval(D(G), Distinct(L)) = Distinct(eval(D(G), L))
    -            
    +

    eval( |D|(|G|), Distinct(|L|) ) = Distinct( eval(|D|(|G|), |L|) ) +

    Definition: Evaluation of Reduced

    -
    eval(D(G), Reduced(L)) = Reduced(eval(D(G), L))
    -            
    +

    eval( |D|(|G|), Reduced(|L|) ) = Reduced( eval(|D|(|G|), |L|) ) +

    Definition: Evaluation of Project

    -
    eval(D(G), Project(L, vars)) = Project(eval(D(G), L), vars)
    -            
    +

    eval( |D|(|G|), Project(|L|, |vars|) ) = Project( eval(|D|(|G|), |L|), |vars| ) +

    Definition: Evaluation of OrderBy

    -
    eval(D(G), OrderBy(L, condition)) = OrderBy(eval(D(G), L), condition)
    -            
    +

    eval( |D|(|G|), OrderBy(|L|, |condition|) ) = OrderBy( eval(|D|(|G|), |L|), |condition| ) +

    Definition: Evaluation of ToMultiSet

    -
    eval(D(G), ToMultiSet(L)) = ToMultiSet(eval(D(G), L))
    +

    eval( |D|(|G|), ToMultiSet(|L|) ) = ToMultiSet( eval(|D|(|G|), |L|) )

    Definition: Evaluation of Slice

    -
    -eval(D(G), Slice(L, start, length)) = Slice(eval(D(G), L), start, length)
    -            
    +

    +eval( |D|(|G|), Slice(|L|, |start|, |length|) ) = Slice( eval(|D|(|G|), |L|), |start|, |length| ) +

    From 38052ef109ffd3c9e7ec7d9fe32bb9f4da67e90a Mon Sep 17 00:00:00 2001 From: Olaf Hartig Date: Tue, 13 May 2025 09:23:41 +0200 Subject: [PATCH 3/3] restores obsolete id anchors --- spec/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/index.html b/spec/index.html index fe0cab5..2369ddd 100644 --- a/spec/index.html +++ b/spec/index.html @@ -9835,7 +9835,7 @@

    SPARQL Algebra

    every other solution mapping so P MINUS {} would otherwise be empty for any pattern P.

    -

    Definition: Extend

    +

    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(μ) }

    @@ -9854,14 +9854,14 @@

    SPARQL Algebra

    multiplicity( μ | Ω )

    -

    Definition: OrderBy

    +

    Definition: OrderBy

    Let Ψ be a sequence of solution mappings. We define:

    OrderBy(Ψ, condition) = [ μ | μ in Ψ and the sequence satisfies the ordering condition]

    multiplicity( μ | OrderBy(Ψ, condition) ) = multiplicity( μ | Ψ )

    -

    Definition: Project

    +

    Definition: Project

    Let Ψ be a sequence of solution mappings and PV a set of variables.

    For mapping μ, write Proj(μ, PV) to be the restriction of μ to variables in PV.

    Project(Ψ, PV) = [ Proj(μ, PV) | μ in Ψ ]