@@ -10369,7 +10369,151 @@ <h3>Evaluation Semantics</h3>
10369
10369
eval(D(G), Slice(L, start, length)) = Slice(eval(D(G), L), start, length)
10370
10370
</pre>
10371
10371
</div>
10372
+
10373
+ <!-- ValuesInsertion -->
10374
+ <section>
10375
+ <h3>Value Insertion and `EXISTS`</h3>
10376
+ <p>The following sections contain draft of material for a revised
10377
+ "`exists`" operation.
10378
+ </p>
10379
+ <p>Background:</p>
10380
+ <ul>
10381
+ <li><a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">SPARQL CG SEP-0007</a></li>
10382
+ </ul>
10383
+
10384
+ <section>
10385
+ <h4>Syntax Restriction</h4>
10386
+ <p><i>Additional [[[#sparqlGrammar]]] note:</i></p>
10387
+ <blockquote>
10388
+ Any variable that is assigned to in the graph pattern of `EXISTS`/`NOT EXISTS` must not be in-scope.
10389
+ This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
10390
+ clause, and variables intrucded by `AS` in `GROUP BY`.
10391
+ </blockquote>
10392
+ <p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10393
+ <table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
10394
+ <tbody>
10395
+ <tr>
10396
+ <th>Syntax Form</th>
10397
+ <th>In-scope variables</th>
10398
+ </tr>
10399
+ <tr>
10400
+ <td>`EXISTS` and `NOT EXISTS` filters </td>
10401
+ <td><code>v</code> is in-scope if it is in-scope for pattern to which the `FILTER` is applied.
10402
+ </td>
10403
+ </tr>
10404
+ </tbody>
10405
+ </table>
10406
+ <p class="note">
10407
+ This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10408
+ do not conflict with values assigned to varibales with the pattern.
10409
+ </p>
10410
+ </section>
10411
+
10412
+ <section>
10413
+ <h4>Remapping</h4>
10414
+ <p>
10415
+ Remapping ensures that a variable name used inside a project expression,
10416
+ but which is not part of the results of the evaluation of the project expression,
10417
+ does not coincide with a variable mentioned anywhere else in the
10418
+ algebra expression of a query.
10419
+ </p>
10420
+ <p>
10421
+ Renaming these variables does not change the results of evalauting
10422
+ the project expresssion.
10423
+ </p>
10424
+ <div class="defn">
10425
+ <b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10426
+ <p>
10427
+ For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10428
+ a partial mapping `F` from
10429
+ `<a href="#sparqlQueryVariables">V</a>`,
10430
+ the set of all variables, to `V` where:
10431
+ </p>
10432
+ <pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10433
+ F(v) = v if v is not in PV</pre>
10434
+ <p>
10435
+ Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10436
+ </p>
10437
+ <pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10438
+ where A1 is the result of applying F
10439
+ to every variable mentioned in A.
10440
+ </pre>
10441
+ <p>
10442
+ The Projection Expression Variable Remapping yields an algrebra expression that
10443
+ evalautes to the same results as the Project argument. No variable of `ProjectMap(Project(A, PV))`
10444
+ that is not in `PV` is mentioned anywhere else in the algebra expression for the query.
10445
+ </p>
10446
+ </div>
10447
+
10448
+ <p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10449
+
10450
+ <div class="defn">
10451
+ <b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10452
+ <p>
10453
+ For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`of algebra expression `X`:
10454
+ </p>
10455
+ <pre>PrjMap(X) = replace all project operations Project(P, PV)
10456
+ with ProjectMap(P,PV) for each projection in X.</pre>
10457
+ </div>
10458
+ <p>
10459
+ The outcome of `PrjMap` is independent of the order of replacement
10460
+ (e.g. bottom-up or top-down).
10461
+ Replacements may happen several times, depending on recusive order
10462
+ but each time a replacement is made, the variable not used anywhere else.
10463
+ </p>
10464
+
10465
+ <p class="note">
10466
+ A variable inside a project expression that is not in the variables projected
10467
+ is not affected by value insertion because it is renamed apart.
10468
+ </p>
10469
+ </section>
10470
+
10471
+ <section>
10472
+ <h4>Values Insertion</h4>
10473
+ <div class="defn">
10474
+ <div>
10475
+ <b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10476
+ <p>
10477
+ Define the Values Insertion function `ValuesInsert(X, μ)`
10478
+ </p>
10479
+ <pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10480
+
10481
+ Replace each occurence of `Y` in X where `Y` is one of
10482
+ <a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10483
+ <a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10484
+ <a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>
10485
+ with `join(Y, Table(μ))`.</pre>
10486
+
10487
+ </div>
10488
+ <p>@@ rename as ???correllate</p>
10489
+ </div>
10490
+
10491
+ <div class="example">
10492
+ <p>
10493
+ Examples
10494
+ </p>
10495
+ </div>
10496
+ </section>
10497
+
10498
+ <section>
10499
+ <h4>Evaluation of EXISTS</h4>
10500
+ <div class="defn">
10501
+ <b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b>
10502
+ <p>
10503
+ Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10504
+ define the Evaluation of Exists `exists(X)`
10505
+ </p>
10506
+ <pre>exists(X) = true
10507
+ if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10508
+ is a non-empty solution sequence.
10509
+ exists(X) = false otherwise</pre>
10510
+ </div>
10511
+ </section>
10512
+ </section>
10513
+ <!-- ValuesInsertion -->
10514
+
10372
10515
</section>
10516
+
10373
10517
<section id="sparqlBGPExtend">
10374
10518
<h3>Extending SPARQL Basic Graph Matching</h3>
10375
10519
<p>The overall SPARQL design can be used for queries which assume a more elaborate form of
0 commit comments