@@ -10467,7 +10467,148 @@ <h3>Evaluation Semantics</h3>
10467
10467
<a href="#defn_eval" class="evalFct">eval</a>( |D|(|G|), Slice(|L|, |start|, |length|) ) = <a href="#defn_algSlice" class="algFct">Slice</a>( <a href="#defn_eval" class="evalFct">eval</a>(|D|(|G|), |L|), |start|, |length| )
10468
10468
</p>
10469
10469
</div>
10470
+
10471
+ <!-- ValuesInsertion -->
10472
+ <section>
10473
+ <h3>Values Insertion and `EXISTS`</h3>
10474
+ <div class="ednote">
10475
+ <p>The following subsections contain draft of material for a revised
10476
+ "`exists`" operation.
10477
+ </p>
10478
+ <p>
10479
+ Background: <a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">SPARQL CG SEP-0007</a>
10480
+ </p>
10481
+ </div>
10482
+ <section>
10483
+ <h4>Syntax Restriction</h4>
10484
+ <p><i>Additional [[[#sparqlGrammar]]] note:</i></p>
10485
+ <blockquote>
10486
+ Any variable that is assigned to in the graph pattern of `EXISTS`/`NOT EXISTS` must not be in-scope.
10487
+ This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
10488
+ clause, and variables introduced by `AS` in `GROUP BY`.
10489
+ </blockquote>
10490
+ <p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10491
+ <table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
10492
+ <tbody>
10493
+ <tr>
10494
+ <th>Syntax Form</th>
10495
+ <th>In-scope variables</th>
10496
+ </tr>
10497
+ <tr>
10498
+ <td>`EXISTS` and `NOT EXISTS` filters </td>
10499
+ <td><code>v</code> is in-scope if it is in-scope for the pattern to which the `FILTER` is applied.
10500
+ </td>
10501
+ </tr>
10502
+ </tbody>
10503
+ </table>
10504
+ <p class="note">
10505
+ This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10506
+ do not conflict with values assigned to variables within the pattern.
10507
+ </p>
10508
+ </section>
10509
+ <section>
10510
+ <h4>Remapping</h4>
10511
+ <p>
10512
+ Remapping ensures that a variable name used inside a project expression,
10513
+ but which is not part of the results of the evaluation of the project expression,
10514
+ does not coincide with a variable mentioned anywhere else in the
10515
+ algebra expression of a query.
10516
+ </p>
10517
+ <p>
10518
+ Renaming these variables does not change the results of evaluating
10519
+ the project expresssion.
10520
+ </p>
10521
+ <div class="defn">
10522
+ <b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10523
+ <p>
10524
+ For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10525
+ a partial mapping `F` from
10526
+ `<a href="#sparqlQueryVariables">V</a>`,
10527
+ the set of all variables, to `V` where:
10528
+ </p>
10529
+ <pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10530
+ F(v) = v if v is not in PV</pre>
10531
+ <p>
10532
+ Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10533
+ </p>
10534
+ <pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10535
+ where A1 is the result of applying F
10536
+ to every variable mentioned in A.
10537
+ </pre>
10538
+ <p>
10539
+ The Projection Expression Variable Remapping yields an algrebra expression that
10540
+ evaluates to the same results as the Project argument. No variable of `ProjectMap(Project(A, PV))`
10541
+ that is not in `PV` is mentioned anywhere else in the algebra expression for the query.
10542
+ </p>
10543
+ </div>
10544
+ <p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10545
+ <div class="defn">
10546
+ <b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10547
+ <p>
10548
+ For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
10549
+ of algebra expression `X`:
10550
+ </p>
10551
+ <pre>PrjMap(X) = replace all project operations Project(P, PV)
10552
+ with ProjectMap(P, PV) for each projection in X.</pre>
10553
+ </div>
10554
+ <p>
10555
+ The outcome of `PrjMap` is independent of the order of replacement
10556
+ (e.g. bottom-up or top-down).
10557
+ Replacements may happen several times, depending on recursive order
10558
+ but each time a replacement is made, the variable not used anywhere else.
10559
+ </p>
10560
+
10561
+ <p class="note">
10562
+ A variable inside a project expression that is not in the variables projected
10563
+ is not affected by the values insertion operation because it is renamed apart.
10564
+ </p>
10565
+ </section>
10566
+ <section>
10567
+ <h4>Values Insertion</h4>
10568
+ <div class="defn">
10569
+ <div>
10570
+ <b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10571
+ <p>
10572
+ Define the Values Insertion function `ValuesInsert(X, μ)`
10573
+ </p>
10574
+ <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10575
+
10576
+ Replace each occurence of `Y` in X where `Y` is one of
10577
+ <a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10578
+ <a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10579
+ <a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10580
+ <a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10581
+ with `join(Y, Table(μ))`.</pre>
10582
+
10583
+ </div>
10584
+ <p>@@ rename as ???correllate</p>
10585
+ </div>
10586
+
10587
+ <div class="example">
10588
+ <p>
10589
+ Examples
10590
+ </p>
10591
+ </div>
10592
+ </section>
10593
+ <section>
10594
+ <h4>Evaluation of EXISTS</h4>
10595
+ <div class="defn">
10596
+ <b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b>
10597
+ <p>
10598
+ Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10599
+ define the Evaluation of Exists `exists(X)`
10600
+ </p>
10601
+ <pre>exists(X) = true
10602
+ if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10603
+ is a non-empty solution sequence.
10604
+ exists(X) = false otherwise</pre>
10605
+ </div>
10606
+ </section>
10607
+ </section>
10608
+ <!-- ValuesInsertion -->
10609
+
10470
10610
</section>
10611
+
10471
10612
<section id="sparqlBGPExtend">
10472
10613
<h3>Extending SPARQL Basic Graph Matching</h3>
10473
10614
<p>The overall SPARQL design can be used for queries which assume a more elaborate form of
0 commit comments