Skip to content

Commit b665b6c

Browse files
committed
Initial values-insertion draft
1 parent b5336fa commit b665b6c

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
@@ -10638,7 +10638,148 @@ <h3>Evaluation Semantics</h3>
1063810638
<a href="#defn_eval" class="evalFct">eval</a>( |D|(|G|), <a href="#defn_absSlice" class="absOp">Slice</a>(|L|, |start|, |length|) ) = <a href="#defn_algSlice" class="algFct">Slice</a>( <a href="#defn_eval" class="evalFct">eval</a>(|D|(|G|), |L|), |start|, |length| )
1063910639
</p>
1064010640
</div>
10641+
10642+
<!-- ValuesInsertion -->
10643+
<section>
10644+
<h3>Values Insertion and `EXISTS`</h3>
10645+
<div class="ednote">
10646+
<p>The following subsections contain draft of material for a revised
10647+
"`exists`" operation.
10648+
</p>
10649+
<p>
10650+
Background: <a href="https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0007/sep-0007.md">SPARQL CG SEP-0007</a>
10651+
</p>
10652+
</div>
10653+
<section>
10654+
<h4>Syntax Restriction</h4>
10655+
<p><i>Additional [[[#sparqlGrammar]]] note:</i></p>
10656+
<blockquote>
10657+
Any variable that is assigned to in the graph pattern of `EXISTS`/`NOT EXISTS` must not be in-scope.
10658+
This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES`
10659+
clause, and variables introduced by `AS` in `GROUP BY`.
10660+
</blockquote>
10661+
<p>Extend the "in-scope" rules to include the variables in-scope from the current row:</p>
10662+
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
10663+
<tbody>
10664+
<tr>
10665+
<th>Syntax Form</th>
10666+
<th>In-scope variables</th>
10667+
</tr>
10668+
<tr>
10669+
<td>`EXISTS` and `NOT EXISTS` filters </td>
10670+
<td><code>v</code> is in-scope if it is in-scope for the pattern to which the `FILTER` is applied.
10671+
</td>
10672+
</tr>
10673+
</tbody>
10674+
</table>
10675+
<p class="note">
10676+
This restriction means that <a href="#defn_valuesinsertion">values inserted</a>
10677+
do not conflict with values assigned to variables within the pattern.
10678+
</p>
10679+
</section>
10680+
<section>
10681+
<h4>Remapping</h4>
10682+
<p>
10683+
Remapping ensures that a variable name used inside a project expression,
10684+
but which is not part of the results of the evaluation of the project expression,
10685+
does not coincide with a variable mentioned anywhere else in the
10686+
algebra expression of a query.
10687+
</p>
10688+
<p>
10689+
Renaming these variables does not change the results of evaluating
10690+
the project expresssion.
10691+
</p>
10692+
<div class="defn">
10693+
<b>Definition: <span id="defn_projmap" name="defn_projmap">Projection Expression Variable Remapping</span></b>
10694+
<p>
10695+
For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define
10696+
a partial mapping `F` from
10697+
`<a href="#sparqlQueryVariables">V</a>`,
10698+
the set of all variables, to `V` where:
10699+
</p>
10700+
<pre>F(v) = v1 if v is in PV, where v1 is a fresh variable
10701+
F(v) = v if v is not in PV</pre>
10702+
<p>
10703+
Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
10704+
</p>
10705+
<pre>ProjectMap(Project(A, PV)) = Project(A1, PV)
10706+
where A1 is the result of applying F
10707+
to every variable mentioned in A.
10708+
</pre>
10709+
<p>
10710+
The Projection Expression Variable Remapping yields an algrebra expression that
10711+
evaluates to the same results as the Project argument. No variable of `ProjectMap(Project(A, PV))`
10712+
that is not in `PV` is mentioned anywhere else in the algebra expression for the query.
10713+
</p>
10714+
</div>
10715+
<p>This process is applied throughout the graph pattern of <code>EXISTS</code>:</p>
10716+
<div class="defn">
10717+
<b>Definition: <span id="defn_varrename" name="defn_varrename">Variable Remapping</span></b>
10718+
<p>
10719+
For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`
10720+
of algebra expression `X`:
10721+
</p>
10722+
<pre>PrjMap(X) = replace all project operations Project(P, PV)
10723+
with ProjectMap(P, PV) for each projection in X.</pre>
10724+
</div>
10725+
<p>
10726+
The outcome of `PrjMap` is independent of the order of replacement
10727+
(e.g. bottom-up or top-down).
10728+
Replacements may happen several times, depending on recursive order
10729+
but each time a replacement is made, the variable not used anywhere else.
10730+
</p>
10731+
10732+
<p class="note">
10733+
A variable inside a project expression that is not in the variables projected
10734+
is not affected by the values insertion operation because it is renamed apart.
10735+
</p>
10736+
</section>
10737+
<section>
10738+
<h4>Values Insertion</h4>
10739+
<div class="defn">
10740+
<div>
10741+
<b>Definition: <span id="defn_valuesinsertion" name="defn_valuesinsertion">Values Insertion</span></b>
10742+
<p>
10743+
Define the Values Insertion function `ValuesInsert(X, μ)`
10744+
</p>
10745+
<pre>Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
10746+
10747+
Replace each occurence of `Y` in X where `Y` is one of
10748+
<a href="#sparqlTranslateBasicGraphPatterns">Basic Graph Pattern</a>,
10749+
<a href="#sparqlTranslatePathExpressions">Property Path Expression</a>,
10750+
<a href="#sparqlTranslateGraphPatterns">`Graph(Var, pattern)`</a>,
10751+
<a href="#https://www.w3.org/TR/sparql12-query/#sparqlTranslateGraphPatterns">Inline Data</a>
10752+
with `join(Y, Table(μ))`.</pre>
10753+
10754+
</div>
10755+
<p>@@ rename as ???correllate</p>
10756+
</div>
10757+
10758+
<div class="example">
10759+
<p>
10760+
Examples
10761+
</p>
10762+
</div>
10763+
</section>
10764+
<section>
10765+
<h4>Evaluation of EXISTS</h4>
10766+
<div class="defn">
10767+
<b>Definition: <span id="x-defn_evalExists" name="x-defn_evalExists">Evaluation of Exists</span></b>
10768+
<p>
10769+
Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
10770+
define the Evaluation of Exists `exists(X)`
10771+
</p>
10772+
<pre>exists(X) = true
10773+
if eval( D(G), ValuesInsert(PrjMap(X), μ) )
10774+
is a non-empty solution sequence.
10775+
exists(X) = false otherwise</pre>
10776+
</div>
10777+
</section>
10778+
</section>
10779+
<!-- ValuesInsertion -->
10780+
1064110781
</section>
10782+
1064210783
<section id="sparqlBGPExtend">
1064310784
<h3>Extending SPARQL Basic Graph Matching</h3>
1064410785
<p>The overall SPARQL design can be used for queries which assume a more elaborate form of

0 commit comments

Comments
 (0)