Skip to content

Commit 0f7b66d

Browse files
committed
Initial values-insertion draft
1 parent 5615dfa commit 0f7b66d

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

spec/index.html

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10424,7 +10424,148 @@ <h3>Evaluation Semantics</h3>
1042410424
<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| )
1042510425
</p>
1042610426
</div>
10427+
10428+
<!-- ValuesInsertion -->
10429+
<section>
10430+
<h3>Values Insertion and `EXISTS`</h3>
10431+
<div class="ednote">
10432+
<p>The following subsections 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+
</div>
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 within the pattern.
10464+
</p>
10465+
</section>
10466+
<section>
10467+
<h4>Remapping</h4>
10468+
<p>
10469+
Remapping ensures that a variable name used inside a project expression,
10470+
but which is not part of the results of the evaluation of the project expression,
10471+
does not coincide with a variable mentioned anywhere else in the
10472+
algebra expression of a query.
10473+
</p>
10474+
<p>
10475+
Renaming these variables does not change the results of evaluating
10476+
the project expresssion.
10477+
</p>
10478+
<div class="defn">
10479+
<b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10480+
<p>
10481+
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10482+
a partial mapping `F` from
10483+
`<a href="#sparqlQueryVariables">V</a>`,
10484+
the set of all variables, to `V` where:
10485+
</p>
10486+
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10487+
F(v) = v if v is not in PV</pre>
10488+
<p>
10489+
Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10490+
</p>
10491+
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10492+
where A1 is the result of applying F
10493+
to every variable mentioned in A.
10494+
</pre>
10495+
<p>
10496+
The Projection Expression Variable Remapping yields an algrebra expression that
10497+
evaluates to the same results as the Project argument. No variable of `ProjectMap(Project(A, PV))`
10498+
that is not in `PV` is mentioned anywhere else in the algebra expression for the query.
10499+
</p>
10500+
</div>
10501+
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10502+
<div class="defn">
10503+
<b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10504+
<p>
10505+
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
10506+
of algebra expression `X`:
10507+
</p>
10508+
<pre>PrjMap(X) = replace all project operations Project(P, PV)
10509+
with ProjectMap(P, PV) for each projection in X.</pre>
10510+
</div>
10511+
<p>
10512+
The outcome of `PrjMap` is independent of the order of replacement
10513+
(e.g. bottom-up or top-down).
10514+
Replacements may happen several times, depending on recursive order
10515+
but each time a replacement is made, the variable not used anywhere else.
10516+
</p>
10517+
10518+
<p class="note">
10519+
A variable inside a project expression that is not in the variables projected
10520+
is not affected by the values insertion operation because it is renamed apart.
10521+
</p>
10522+
</section>
10523+
<section>
10524+
<h4>Values Insertion</h4>
10525+
<div class="defn">
10526+
<div>
10527+
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10528+
<p>
10529+
Define the Values Insertion function `ValuesInsert(X, μ)`
10530+
</p>
10531+
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10532+
10533+
Replace each occurence of `Y` in X where `Y` is one of
10534+
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10535+
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10536+
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10537+
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10538+
with `join(Y, Table(μ))`.</pre>
10539+
10540+
</div>
10541+
<p>@@ rename as ???correllate</p>
10542+
</div>
10543+
10544+
<div class="example">
10545+
<p>
10546+
Examples
10547+
</p>
10548+
</div>
10549+
</section>
10550+
<section>
10551+
<h4>Evaluation of EXISTS</h4>
10552+
<div class="defn">
10553+
<b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b>
10554+
<p>
10555+
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10556+
define the Evaluation of Exists `exists(X)`
10557+
</p>
10558+
<pre>exists(X) = true
10559+
if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10560+
is a non-empty solution sequence.
10561+
exists(X) = false otherwise</pre>
10562+
</div>
10563+
</section>
10564+
</section>
10565+
<!-- ValuesInsertion -->
10566+
1042710567
</section>
10568+
1042810569
<section id="sparqlBGPExtend">
1042910570
<h3>Extending SPARQL Basic Graph Matching</h3>
1043010571
<p>The overall SPARQL design can be used for queries which assume a more elaborate form of

0 commit comments

Comments
 (0)