@@ -10640,7 +10640,148 @@ <h3>Evaluation Semantics</h3>
10640
10640
<a href="#defn_eval" class="evalFct">eval</a>( |D|(|G|), <a href="#defn_absSlice" class="absOp">Slice</a>(|L|, |start|, |length|) ) = <a href="#defn_algSlice" class="algFct">Slice</a>( <a href="#defn_eval" class="evalFct">eval</a>(|D|(|G|), |L|), |start|, |length| )
10641
10641
</p>
10642
10642
</div>
10643
+
10644
+ <!-- ValuesInsertion -->
10645
+ <section>
10646
+ <h3>Values Insertion and `EXISTS`</h3>
10647
+ <div class="ednote">
10648
+ <p>The following subsections contain draft of material for a revised
10649
+ "`exists`" operation.
10650
+ </p>
10651
+ <p>
10652
+ Background: <a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">SPARQL CG SEP-0007</a>
10653
+ </p>
10654
+ </div>
10655
+ <section>
10656
+ <h4>Syntax Restriction</h4>
10657
+ <p><i>Additional [[[#sparqlGrammar]]] note:</i></p>
10658
+ <blockquote>
10659
+ Any variable that is assigned to in the graph pattern of `EXISTS`/`NOT EXISTS` must not be in-scope.
10660
+ This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
10661
+ clause, and variables introduced by `AS` in `GROUP BY`.
10662
+ </blockquote>
10663
+ <p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10664
+ <table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
10665
+ <tbody>
10666
+ <tr>
10667
+ <th>Syntax Form</th>
10668
+ <th>In-scope variables</th>
10669
+ </tr>
10670
+ <tr>
10671
+ <td>`EXISTS` and `NOT EXISTS` filters </td>
10672
+ <td><code>v</code> is in-scope if it is in-scope for the pattern to which the `FILTER` is applied.
10673
+ </td>
10674
+ </tr>
10675
+ </tbody>
10676
+ </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>
10681
+ </section>
10682
+ <section>
10683
+ <h4>Remapping</h4>
10684
+ <p>
10685
+ Remapping ensures that a variable name used inside a project expression,
10686
+ but which is not part of the results of the evaluation of the project expression,
10687
+ does not coincide with a variable mentioned anywhere else in the
10688
+ algebra expression of a query.
10689
+ </p>
10690
+ <p>
10691
+ Renaming these variables does not change the results of evaluating
10692
+ the project expresssion.
10693
+ </p>
10694
+ <div class="defn">
10695
+ <b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10696
+ <p>
10697
+ For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10698
+ a partial mapping `F` from
10699
+ `<a href="#sparqlQueryVariables">V</a>`,
10700
+ the set of all variables, to `V` where:
10701
+ </p>
10702
+ <pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10703
+ F(v) = v if v is not in PV</pre>
10704
+ <p>
10705
+ Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10706
+ </p>
10707
+ <pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10708
+ where A1 is the result of applying F
10709
+ to every variable mentioned in A.
10710
+ </pre>
10711
+ <p>
10712
+ The Projection Expression Variable Remapping yields an algrebra expression that
10713
+ evaluates to the same results as the Project argument. No variable of `ProjectMap(Project(A, PV))`
10714
+ that is not in `PV` is mentioned anywhere else in the algebra expression for the query.
10715
+ </p>
10716
+ </div>
10717
+ <p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10718
+ <div class="defn">
10719
+ <b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10720
+ <p>
10721
+ For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
10722
+ of algebra expression `X`:
10723
+ </p>
10724
+ <pre>PrjMap(X) = replace all project operations Project(P, PV)
10725
+ with ProjectMap(P, PV) for each projection in X.</pre>
10726
+ </div>
10727
+ <p>
10728
+ The outcome of `PrjMap` is independent of the order of replacement
10729
+ (e.g. bottom-up or top-down).
10730
+ Replacements may happen several times, depending on recursive order
10731
+ but each time a replacement is made, the variable not used anywhere else.
10732
+ </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>
10738
+ </section>
10739
+ <section>
10740
+ <h4>Values Insertion</h4>
10741
+ <div class="defn">
10742
+ <div>
10743
+ <b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10744
+ <p>
10745
+ Define the Values Insertion function `ValuesInsert(X, μ)`
10746
+ </p>
10747
+ <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10748
+
10749
+ Replace each occurence of `Y` in X where `Y` is one of
10750
+ <a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10751
+ <a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10752
+ <a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10753
+ <a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10754
+ with `join(Y, Table(μ))`.</pre>
10755
+
10756
+ </div>
10757
+ <p>@@ rename as ???correllate</p>
10758
+ </div>
10759
+
10760
+ <div class="example">
10761
+ <p>
10762
+ Examples
10763
+ </p>
10764
+ </div>
10765
+ </section>
10766
+ <section>
10767
+ <h4>Evaluation of EXISTS</h4>
10768
+ <div class="defn">
10769
+ <b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b>
10770
+ <p>
10771
+ Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10772
+ define the Evaluation of Exists `exists(X)`
10773
+ </p>
10774
+ <pre>exists(X) = true
10775
+ if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10776
+ is a non-empty solution sequence.
10777
+ exists(X) = false otherwise</pre>
10778
+ </div>
10779
+ </section>
10780
+ </section>
10781
+ <!-- ValuesInsertion -->
10782
+
10643
10783
</section>
10784
+
10644
10785
<section id="sparqlBGPExtend">
10645
10786
<h3>Extending SPARQL Basic Graph Matching</h3>
10646
10787
<p>The overall SPARQL design can be used for queries which assume a more elaborate form of
0 commit comments