@@ -10645,7 +10645,7 @@ <h3>Evaluation Semantics</h3>
10645
10645
<section>
10646
10646
<h3>Values Insertion and `EXISTS`</h3>
10647
10647
<div class="ednote">
10648
- <p>The following subsections contain draft of material for a revised
10648
+ <p>The following subsections contain draft material for a revised
10649
10649
"`exists`" operation.
10650
10650
</p>
10651
10651
<p>
@@ -10660,7 +10660,10 @@ <h4>Syntax Restriction</h4>
10660
10660
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
10661
10661
clause, and variables introduced by `AS` in `GROUP BY`.
10662
10662
</blockquote>
10663
- <p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10663
+ <p>
10664
+ Extend the "in-scope" rules to include the possible
10665
+ variables that are in-scope for the current row:
10666
+ </p>
10664
10667
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
10665
10668
<tbody>
10666
10669
<tr>
@@ -10674,10 +10677,15 @@ <h4>Syntax Restriction</h4>
10674
10677
</tr>
10675
10678
</tbody>
10676
10679
</table>
10677
- <p class="note">
10678
- This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10679
- do not conflict with values assigned to variables within the pattern.
10680
- </p>
10680
+ <div class="note">
10681
+ <p>
10682
+ This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10683
+ do not conflict with values assigned to variables within the pattern.
10684
+ </p>
10685
+ <p>
10686
+ This operation is performed as part of query parsing.
10687
+ </p>
10688
+ </div>
10681
10689
</section>
10682
10690
<section>
10683
10691
<h4>Remapping</h4>
@@ -10692,7 +10700,7 @@ <h4>Remapping</h4>
10692
10700
the project expresssion.
10693
10701
</p>
10694
10702
<div class="defn">
10695
- <b>Definition: <span id="defn_projmap" name="defn_projmap" >Projection Expression Variable Remapping</span></b>
10703
+ <b>Definition: <span id="defn_projmap">Projection Expression Variable Remapping</span></b>
10696
10704
<p>
10697
10705
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10698
10706
a partial mapping `F` from
@@ -10702,7 +10710,7 @@ <h4>Remapping</h4>
10702
10710
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10703
10711
F(v) = v if v is not in PV</pre>
10704
10712
<p>
10705
- Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10713
+ Define the Projection Expression Variable Remapping `ProjectMap(P, PV)`
10706
10714
</p>
10707
10715
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10708
10716
where A1 is the result of applying F
@@ -10716,7 +10724,7 @@ <h4>Remapping</h4>
10716
10724
</div>
10717
10725
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10718
10726
<div class="defn">
10719
- <b>Definition: <span id="defn_varrename" name="defn_varrename" >Variable Remapping</span></b>
10727
+ <b>Definition: <span id="defn_varrename">Variable Remapping</span></b>
10720
10728
<p>
10721
10729
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
10722
10730
of algebra expression `X`:
@@ -10730,49 +10738,98 @@ <h4>Remapping</h4>
10730
10738
Replacements may happen several times, depending on recursive order
10731
10739
but each time a replacement is made, the variable not used anywhere else.
10732
10740
</p>
10733
-
10734
- <p class="note">
10735
- A variable inside a project expression that is not in the variables projected
10736
- is not affected by the values insertion operation because it is renamed apart.
10737
- </p>
10741
+
10742
+ <div class="note">
10743
+ <p>
10744
+ A variable inside a project expression that is not in the variables projected
10745
+ is not affected by the values insertion operation because it is renamed apart.
10746
+ </p>
10747
+ <p>
10748
+ This operation is as part of the <a href="#sparqlQuery">translation to the SPARQL
10749
+ algebra</a>.
10750
+ </p>
10751
+ </div>
10738
10752
</section>
10739
10753
<section>
10740
10754
<h4>Values Insertion</h4>
10755
+ <p>
10756
+ Alternative 1: rewrite the algebra during
10757
+ <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10758
+ to include a function that evaluates to the current row.
10759
+ </p>
10760
+
10741
10761
<div class="defn">
10742
10762
<div>
10743
- <b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion" >Values Insertion </span></b>
10763
+ <b>Definition: <span id="defn_correlate" >Values In Scope </span></b>
10744
10764
<p>
10745
- Define the Values Insertion function `ValuesInsert(X, μ)`
10765
+ Define the function `BindingInScope()`.
10766
+ Evaluation of `BindingInScope()` results in a table of one row,
10767
+ being the current binding of the enclosing filter.
10746
10768
</p>
10747
- <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10769
+ </div>
10770
+ </div>
10748
10771
10772
+ <div class="defn">
10773
+ <div>
10774
+ <b>Definition: Access to the current binding</b>
10775
+ <p>
10776
+ During <a href="#sparqlQuery">translation to the SPARQL algebra</a>
10777
+ </p>
10778
+ <pre>
10749
10779
Replace each occurence of `Y` in X where `Y` is one of
10750
10780
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10751
10781
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10752
10782
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10753
10783
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10754
- with `join(Y, Table(μ))`.</pre>
10755
-
10784
+ with `join(Y, BindingInScope())`.</pre>
10785
+ </div>
10786
+ <div class="note">
10787
+ c.f. section <a href="#sparqlTranslateGraphPatterns">Translate Graph Patterns</a>
10788
+ where an empty basic graph pattern start any
10789
+ <a href="#rGroupGraphPattern">GroupGraphPattern</a>.
10790
+ It happens before the <a href="#sparqlSimplification">simplification step</a>.
10756
10791
</div>
10757
- <p>@@ rename as ???correllate</p>
10758
10792
</div>
10759
10793
10760
10794
<div class="example">
10761
10795
<p>
10762
10796
Examples
10763
10797
</p>
10764
10798
</div>
10799
+
10800
+ <p>
10801
+ Alternative 2: rewrite the algebra during execution. This corresponds to the
10802
+ <a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">original SEP-0007 proposal</a>.
10803
+ </p>
10804
+ <div class="defn">
10805
+ <div>
10806
+ <b>Definition: <span id="defn_valuesinsertion">Values Insertion</span></b>
10807
+ <p>
10808
+ Define the Values Insertion function `ValuesInsert(X, μ)`
10809
+ </p>
10810
+ <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10811
+
10812
+ Replace each occurence of `Y` in X where `Y` is one of
10813
+ <a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10814
+ <a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10815
+ <a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10816
+ <a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10817
+ with `join(Y, Table(μ))`.</pre>
10818
+
10819
+ </div>
10820
+ </div>
10765
10821
</section>
10822
+
10766
10823
<section>
10767
10824
<h4>Evaluation of EXISTS</h4>
10768
10825
<div class="defn">
10769
- <b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists" >Evaluation of Exists</span></b>
10826
+ <b>Definition: <span id="x-defn_evalExists">Evaluation of Exists</span></b>
10770
10827
<p>
10771
10828
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10772
10829
define the Evaluation of Exists `exists(X)`
10773
10830
</p>
10774
10831
<pre>exists(X) = true
10775
- if eval( D(G), ValuesInsert (PrjMap(X), μ) )
10832
+ if eval( D(G), ValuesInScope (PrjMap(X)) , μ)
10776
10833
is a non-empty solution sequence.
10777
10834
exists(X) = false otherwise</pre>
10778
10835
</div>
0 commit comments