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