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