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