Skip to content

Commit 7e6e82a

Browse files
committed
Initial values-insertion draft
1 parent dc25411 commit 7e6e82a

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

spec/index.html

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

0 commit comments

Comments
 (0)