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