@@ -3916,8 +3916,8 @@ <h4>DISTINCT</h4>
3916
3916
<h4>REDUCED</h4>
3917
3917
<p>While the <code>DISTINCT</code> modifier ensures that duplicate solutions are
3918
3918
eliminated from the solution set, <code>REDUCED</code> simply permits them to be
3919
- eliminated. The cardinality of any set of variable bindings in a <code>REDUCED</code>
3920
- solution set is at least one and not more than the cardinality of the solution set with
3919
+ eliminated. The multiplicity of any solution in a <code>REDUCED</code>
3920
+ solution set is at least one and not more than the multiplicity of the solution within the solution set with
3921
3921
no <code>DISTINCT</code> or <code>REDUCED</code> modifier. For example, using the data
3922
3922
above, the query</p>
3923
3923
<div class="queryGroup">
@@ -9005,7 +9005,7 @@ <h4>Converting Solution Modifiers</h4>
9005
9005
<li>Limit</li>
9006
9006
</ul>
9007
9007
<p>Step: ToList</p>
9008
- <p>ToList turns a multiset into a sequence with the same elements and cardinality . There is
9008
+ <p>ToList turns a multiset into a sequence with the same elements and multiplicities . There is
9009
9009
no implied ordering to the sequence; duplicates need not be adjacent.</p>
9010
9010
<blockquote>
9011
9011
<p>Let M := ToList(Pattern)</p>
@@ -9067,15 +9067,15 @@ <h3>Basic Graph Patterns</h3>
9067
9067
<a href="https://en.wikipedia.org/w/index.php?title=Multiset">multiset</a>,
9068
9068
also known as a <i>bag</i>. A multiset is an
9069
9069
unordered collection of elements in which each element may appear more than once. It is
9070
- described by a set of elements and a cardinality function giving the number of occurrences of
9071
- each element from the set in the multiset.</p>
9072
- <p>Write μ for solution mappings.</p>
9073
- <p>Write μ<sub>0</sub> for the mapping such that dom( μ<sub>0</sub>) is the empty set.</p>
9074
- <p>Write Ω<sub>0</sub> for the multiset consisting of exactly the empty mapping
9075
- μ<sub>0, </sub> with cardinality 1. This is the join identity.</p>
9076
- <p>Write μ(x ) for the solution mapping variable x to RDF term t : { (x, t ) }</p>
9077
- <p>Write Ω(x ) for the multiset consisting of exactly μ(?x ->t ), that is, { { (x, t) } }
9078
- with cardinality 1.</p>
9070
+ described by a set of elements and a function giving the multiplicity of each of these
9071
+ elements (i.e., the number of times the element is contained in the multiset) .</p>
9072
+ <p>Write <var>μ</var> for solution mappings.</p>
9073
+ <p>Write <var> μ<sub>0</sub></var> for the mapping such that <var> dom</var>(<var> μ<sub>0</sub></var >) is the empty set.</p>
9074
+ <p>Write <var> Ω<sub>0</sub></var > for the multiset consisting of exactly the empty mapping
9075
+ <var> μ<sub>0</sub></var>, with multiplicity 1. This is the join identity.</p>
9076
+ <p>Write <var>μ</var>(<var>x</var> ) for the solution mapping variable <var>x</var> to RDF term <var>t</var> : { (<var>x</var>, <var>t</var> ) }. </p>
9077
+ <p>Write <var>Ω</var>(<var>x</var> ) for the multiset consisting of exactly <var>μ</var>(<var>?x</var> -><var>t</var> ), that is, <code> { { (x, t) } }</code>
9078
+ with multiplicity 1.</p>
9079
9079
<div class="defn">
9080
9080
<p><b>Definition: <span id="defn_algCompatibleMapping">Compatible Mappings</span></b></p>
9081
9081
<p>Two solution mappings μ<sub>1</sub> and μ<sub>2</sub> are compatible if, for every
@@ -9087,8 +9087,15 @@ <h3>Basic Graph Patterns</h3>
9087
9087
<p>If μ<sub>1</sub> and μ<sub>2</sub> are compatible then μ<sub>1</sub> ∪ μ<sub>2</sub> is
9088
9088
also a mapping. Write merge(μ<sub>1</sub>, μ<sub>2</sub>) for μ<sub>1</sub> ∪
9089
9089
μ<sub>2</sub></p>
9090
- <p>Write card[Ω](μ) for the cardinality of solution mapping μ in a multiset of mappings
9091
- Ω.</p>
9090
+ <div class="defn">
9091
+ <p><b>Definition: <span id="defn_Multiplicity">Multiplicity</span></b></p>
9092
+ <p>Given a multiset <var>Ω</var> of solution mappings and a solution
9093
+ mapping <var>μ</var>, we write <var>multiplicity</var>(<var>μ</var> | <var>Ω</var>)
9094
+ to denote the number of times <var>μ</var> appears in <var>Ω</var>.</p>
9095
+ <p>Similarly, given a solution sequence <var>Ψ</var> and a solution
9096
+ mapping <var>μ</var>, we write <var>multiplicity</var>(<var>μ</var> | <var>Ψ</var>)
9097
+ to denote the number of times <var>μ</var> appears in <var>Ψ</var>.</p>
9098
+ </div>
9092
9099
<section id="BGPsparql">
9093
9100
<h4>SPARQL Basic Graph Pattern Matching</h4>
9094
9101
<p>A basic graph pattern is matched against the active graph for that part of the query.
@@ -9111,8 +9118,9 @@ <h4>SPARQL Basic Graph Pattern Matching</h4>
9111
9118
<p>μ is a <b>solution</b> for BGP from G when there is a pattern instance mapping P such
9112
9119
that P(BGP) is a subgraph of G and μ is the restriction of P to the query variables in
9113
9120
BGP.</p>
9114
- <p>card[Ω](μ) = card[Ω](number of distinct RDF instance mappings, σ, such that P = μ(σ)
9115
- is a pattern instance mapping and P(BGP) is a subgraph of G).</p>
9121
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Ω ) =
9122
+ number of distinct RDF instance mappings, σ, such that P = μ(σ)
9123
+ is a pattern instance mapping and P(BGP) is a subgraph of G.</p>
9116
9124
</div>
9117
9125
<p>If a basic graph pattern is the empty set, then the solution is Ω<sub>0</sub>.</p>
9118
9126
</section>
@@ -9380,7 +9388,8 @@ <h3>SPARQL Algebra</h3>
9380
9388
<p>Let Ω be a multiset of solution mappings and expr be an expression. We define:</p>
9381
9389
<p>Filter(expr, Ω) = { μ | μ in Ω and expr(μ) is an expression that has an
9382
9390
effective boolean value of true }</p>
9383
- <p>card[Filter(expr, Ω)](μ) = card[Ω](μ)</p>
9391
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Filter(expr, Ω) )
9392
+ = <a href="#defn_Multiplicity">multiplicity</a>( μ | Ω )</p>
9384
9393
<blockquote>
9385
9394
Note that evaluating an <code>exists(pattern)</code> expression uses the dataset and
9386
9395
active graph, D(G). See the <a href="#defn_evalFilter">evaluation of filter</a>.
@@ -9392,24 +9401,25 @@ <h3>SPARQL Algebra</h3>
9392
9401
<p>Join(Ω<sub>1</sub>, Ω<sub>2</sub>) = { merge(μ<sub>1</sub>, μ<sub>2</sub>) |
9393
9402
μ<sub>1</sub> in Ω<sub>1</sub> and μ<sub>2</sub> in Ω<sub>2</sub>, and μ<sub>1</sub> and
9394
9403
μ<sub>2</sub> are compatible }</p>
9395
- <p>card[ Join(Ω<sub>1</sub>, Ω<sub>2</sub>)](μ ) =<br>
9404
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Join(Ω<sub>1</sub>, Ω<sub>2</sub>) ) =<br>
9396
9405
for each merge(μ<sub>1</sub>, μ<sub>2</sub>), μ<sub>1</sub> in
9397
9406
Ω<sub>1</sub> and μ<sub>2</sub> in Ω<sub>2</sub> such that μ = merge(μ<sub>1</sub>,
9398
9407
μ<sub>2</sub>),<br>
9399
9408
sum over (μ<sub>1</sub>, μ<sub>2</sub>),
9400
- card[Ω< sub>1</sub>](μ <sub>1</sub>)*card[Ω< sub>2</sub>](μ <sub>2</sub>)</p>
9409
+ <a href="#defn_Multiplicity">multiplicity</a>( μ< sub>1</sub> | Ω <sub>1</sub> ) * <a href="#defn_Multiplicity">multiplicity</a>( μ< sub>2</sub> | Ω <sub>2</sub> )</p>
9401
9410
</div>
9402
9411
<p>It is possible that a solution mapping μ in a Join can arise in different solution
9403
- mappings, μ<sub>1</sub> and μ<sub>2</sub> in the multisets being joined. The cardinality
9404
- of μ is the sum of the cardinalities from all possibilities.</p>
9412
+ mappings, μ<sub>1</sub> and μ<sub>2</sub> in the multisets being joined. The multiplicity
9413
+ of μ is the sum of the multiplicities from all possibilities.</p>
9405
9414
<div class="defn">
9406
9415
<p><b>Definition: <span id="defn_algDiff">Diff</span></b></p>
9407
9416
<p>Let Ω<sub>1</sub> and Ω<sub>2</sub> be multisets of solution mappings and expr be an
9408
9417
expression. We define:</p>
9409
9418
<p>Diff(Ω<sub>1</sub>, Ω<sub>2</sub>, expr) = { μ | μ in Ω<sub>1</sub> such that ∀ μ′ in
9410
9419
Ω<sub>2</sub>, either μ and μ′ are not compatible or μ and μ' are compatible and
9411
9420
expr(merge(μ, μ')) does not have an effective boolean value of true }</p>
9412
- <p>card[Diff(Ω<sub>1</sub>, Ω<sub>2</sub>, expr)](μ) = card[Ω<sub>1</sub>](μ)</p>
9421
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Diff(Ω<sub>1</sub>, Ω<sub>2</sub>, expr) ) =
9422
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Ω<sub>1</sub> )</p>
9413
9423
</div>
9414
9424
<p>The evaluation of expr(merge(μ, μ')) does not have an effective boolean
9415
9425
value of true if it evaluates to false or if it raises an error.</p>
@@ -9420,26 +9430,29 @@ <h3>SPARQL Algebra</h3>
9420
9430
expression. We define:</p>
9421
9431
<p>LeftJoin(Ω<sub>1</sub>, Ω<sub>2</sub>, expr) = Filter(expr, Join(Ω<sub>1</sub>,
9422
9432
Ω<sub>2</sub>)) ∪ Diff(Ω<sub>1</sub>, Ω<sub>2</sub>, expr)</p>
9423
- <p>card[LeftJoin(Ω<sub>1</sub>, Ω<sub>2</sub>, expr)](μ) = card[Filter(expr,
9424
- Join(Ω<sub>1</sub>, Ω<sub>2</sub>))](μ) + card[Diff(Ω<sub>1</sub>, Ω<sub>2</sub>,
9425
- expr)](μ)</p>
9433
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | LeftJoin(Ω<sub>1</sub>, Ω<sub>2</sub>, expr) ) =
9434
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Filter(expr,Join(Ω<sub>1</sub>, Ω<sub>2</sub>)) ) +
9435
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Diff(Ω<sub>1</sub>, Ω<sub>2</sub>,
9436
+ expr) )</p>
9426
9437
</div>
9427
9438
9428
9439
<div class="defn">
9429
9440
<p><b>Definition: <span id="defn_algUnion">Union</span></b></p>
9430
9441
<p>Let Ω<sub>1</sub> and Ω<sub>2</sub> be multisets of solution mappings. We define:</p>
9431
9442
<p>Union(Ω<sub>1</sub>, Ω<sub>2</sub>) = { μ | μ in Ω<sub>1</sub> or μ in Ω<sub>2</sub>
9432
9443
}</p>
9433
- <p>card[Union(Ω<sub>1</sub>, Ω<sub>2</sub>)](μ) = card[Ω<sub>1</sub>](μ) +
9434
- card[Ω<sub>2</sub>](μ)</p>
9444
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Union(Ω<sub>1</sub>, Ω<sub>2</sub>) ) =
9445
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Ω<sub>1</sub> ) +
9446
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Ω<sub>2</sub> )</p>
9435
9447
</div>
9436
9448
<div class="defn">
9437
9449
<p><b>Definition: <span id="defn_algMinus">Minus</span></b></p>
9438
9450
<p>Let Ω<sub>1</sub> and Ω<sub>2</sub> be multisets of solution mappings. We define:</p>
9439
9451
<p>Minus(Ω<sub>1</sub>, Ω<sub>2</sub>) = { μ | μ in Ω<sub>1</sub> . ∀ μ' in
9440
9452
Ω<sub>2</sub>, either μ and μ' are not compatible or dom(μ) and dom(μ') are disjoint
9441
9453
}</p>
9442
- <p>card[Minus(Ω<sub>1</sub>, Ω<sub>2</sub>)](μ) = card[Ω<sub>1</sub>](μ)</p>
9454
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Minus(Ω<sub>1</sub>, Ω<sub>2</sub>) ) =
9455
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Ω<sub>1</sub> )</p>
9443
9456
</div>
9444
9457
<p>The additional restriction on dom(μ) and dom(μ') is added because otherwise if there is
9445
9458
a solution mapping in Ω<sub>2</sub> that has no variables in common with the solution
@@ -9457,45 +9470,55 @@ <h3>SPARQL Algebra</h3>
9457
9470
<p>Extend(Ω, var, expr) = { Extend(μ, var, expr) | μ in Ω }</p>
9458
9471
</div>
9459
9472
<p>Write [ x | C ] for a sequence of elements where C is a condition on x.</p>
9460
- <p>Write card[L](x) to be the cardinality of x in L.</p>
9461
9473
<div class="defn">
9462
9474
<p><b>Definition: <span id="defn_algToList">ToList</span></b></p>
9463
9475
<p>Let Ω be a multiset of solution mappings. We define:</p>
9464
- <p>ToList(Ω) = a sequence of mappings μ in Ω in any order, with card[Ω](μ) occurrences of
9476
+ <p>ToList(Ω) = a sequence of mappings μ in Ω in any order, with
9477
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Ω ) occurrences of
9465
9478
μ</p>
9466
- <p>card[ToList(Ω)](μ) = card[Ω](μ)</p>
9479
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | ToList(Ω) ) =
9480
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Ω )</p>
9467
9481
</div>
9468
9482
<div class="defn">
9469
9483
<p><b>Definition: <span id="defn_algOrdered">OrderBy</span></b></p>
9470
9484
<p>Let Ψ be a sequence of solution mappings. We define:</p>
9471
9485
<div id="defn_algOrderBy">
9472
9486
OrderBy
9473
9487
</div>(Ψ, condition) = [ μ | μ in Ψ and the sequence satisfies the ordering condition]
9474
- <p>card[OrderBy(Ψ, condition)](μ) = card[Ψ](μ)</p>
9488
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | OrderBy(Ψ, condition) ) =
9489
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Ψ )</p>
9475
9490
</div>
9476
9491
<div class="defn">
9477
9492
<p><b>Definition: <span id="defn_algProjection">Project</span></b></p>
9478
9493
<p>Let Ψ be a sequence of solution mappings and PV a set of variables.</p>
9479
9494
<p>For mapping μ, write Proj(μ, PV) to be the restriction of μ to variables in PV.</p>
9480
9495
<p>Project(Ψ, PV) = [ Proj(μ, PV) | μ in Ψ ]</p>
9481
- <p>card[Project(Ψ, PV)](μ) = sum(card[Ψ](ν) | ν in Ψ such that ν = Proj(μ, PV))</p>
9496
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Project(Ψ, PV) ) =
9497
+ sum( <a href="#defn_Multiplicity">multiplicity</a>( ν | Ψ ) | ν in Ψ such that ν = Proj(μ, PV))</p>
9482
9498
<p>The order of Project(Ψ, PV) must preserve any ordering given by OrderBy.</p>
9483
9499
</div>
9484
9500
<div class="defn">
9485
9501
<p><b>Definition: <span id="defn_algDistinct">Distinct</span></b></p>
9486
9502
<p>Let Ψ be a sequence of solution mappings. We define:</p>
9487
9503
<p>Distinct(Ψ) = [ μ | μ in Ψ ]</p>
9488
- <p>card[Distinct(Ψ)](μ) = 1</p>
9504
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Distinct(Ψ) ) = 1
9505
+ for every μ ∈ Distinct(Ψ)</p>
9506
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Distinct(Ψ) ) = 0
9507
+ for every μ ∉ Distinct(Ψ)</p>
9489
9508
<p>The order of Distinct(Ψ) must preserve any ordering given by OrderBy.</p>
9490
9509
</div>
9491
9510
<div class="defn">
9492
9511
<p><b>Definition: <span id="defn_algReduced">Reduced</span></b></p>
9493
9512
<p>Let Ψ be a sequence of solution mappings. We define:</p>
9494
9513
<p>Reduced(Ψ) = [ μ | μ in Ψ ]</p>
9495
- <p>card[Reduced(Ψ)](μ) is between 1 and card[Ψ](μ)</p>
9514
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Reduced(Ψ) ) is
9515
+ between 1 and <a href="#defn_Multiplicity">multiplicity</a>( μ | Ψ )
9516
+ for every μ ∈ Reduced(Ψ)</p>
9517
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | Reduced(Ψ) ) = 0
9518
+ for every μ ∉ Reduced(Ψ)</p>
9496
9519
<p>The order of Reduced(Ψ) must preserve any ordering given by OrderBy.</p>
9497
9520
</div>
9498
- <p>The Reduced solution sequence modifier does not guarantee a defined cardinality .</p>
9521
+ <p>The Reduced solution sequence modifier does not guarantee a defined multiplicity .</p>
9499
9522
<div class="defn">
9500
9523
<p><b>Definition: <span id="defn_algSlice">Slice</span></b></p>
9501
9524
<p>Let Ψ be a sequence of solution mappings. We define:</p>
@@ -9507,15 +9530,16 @@ <h3>SPARQL Algebra</h3>
9507
9530
<p><b>Definition: <span id="defn_algToMultiSet">ToMultiSet</span></b></p>
9508
9531
<p>Let Ψ be a solution sequence. We define:</p>
9509
9532
<p>ToMultiSet(Ψ) = { μ | μ in Ψ }</p>
9510
- <p>card[ToMultiSet(Ψ)](μ) = card[Ψ](μ)</p>
9533
+ <p><a href="#defn_Multiplicity">multiplicity</a>( μ | ToMultiSet(Ψ) ) =
9534
+ <a href="#defn_Multiplicity">multiplicity</a>( μ | Ψ )</p>
9511
9535
</div>
9512
9536
<p>ListEval is a function which is used to evaluate a list of expressions against a
9513
9537
solution and return a list of the resulting values.</p>
9514
9538
<div class="defn">
9515
9539
<div id="defn_algToMultiset">
9516
9540
<b>Definition: ToMultiset</b>
9517
9541
</div>
9518
- <p>ToMultiset turns a sequence into a multiset with the same elements and cardinality as
9542
+ <p>ToMultiset turns a sequence into a multiset with the same elements and multiplicities as
9519
9543
the sequence. The order of the sequence has no effect on the resulting multiset, and
9520
9544
duplicates are preserved.</p>
9521
9545
</div>
@@ -9935,8 +9959,8 @@ <h3>Evaluation Semantics</h3>
9935
9959
the result is R
9936
9960
</pre>
9937
9961
</div>
9938
- <p>The evaluation of graph uses the SPARQL algebra union operator. The cardinality of a
9939
- solution mapping is the sum of the cardinalities of that solution mapping in each join
9962
+ <p>The evaluation of graph uses the SPARQL algebra union operator. The multiplicity of a
9963
+ solution mapping is the sum of the multiplicities of that solution mapping in each join
9940
9964
operation.</p>
9941
9965
<div class="defn">
9942
9966
<div id="defn_evalGroup">
0 commit comments