diff --git a/spec/index.html b/spec/index.html index 05e9e3d..0ea2c52 100644 --- a/spec/index.html +++ b/spec/index.html @@ -10425,7 +10425,152 @@
The following sections contain draft of material for a revised + "`exists`" operation. +
++ Background: SPARQL CG SEP-0007 +
+ +Additional [[[#sparqlGrammar]]] note:
++ Any variable that is assigned to in the graph pattern of `EXISTS`/`NOT EXISTS` must not be in-scope. + This applies to `BIND`, variables introduced by `AS` in a `SELECT` clause, variables in a `VALUES` + clause, and variables introduced by `AS` in `GROUP BY`. ++
Extend the "in-scope" rules to include the variables in-scope from the current row:
+Syntax Form | +In-scope variables | +
---|---|
`EXISTS` and `NOT EXISTS` filters | +v is in-scope if it is in-scope for the pattern to which the `FILTER` is applied.
+ |
+
+ This restriction means that values inserted + do not conflict with values assigned to variables with the pattern. +
++ Remapping ensures that a variable name used inside a project expression, + but which is not part of the results of the evaluation of the project expression, + does not coincide with a variable mentioned anywhere else in the + algebra expression of a query. +
++ Renaming these variables does not change the results of evaluating + the project expresssion. +
++ For a projection algebra operation #sparqlProjection `Project(A, PV)` acting on algreg express `A` and with set of variables `PV`, define + a partial mapping `F` from + `V`, + the set of all variables, to `V` where: +
+F(v) = v1 if v is in PV, where v1 is a fresh variable +F(v) = v if v is not in PV+
+ Define the Projection Expression Variable Remapping `ProjectMap(P,PV)` +
+ProjectMap(Project(A, PV)) = Project(A1, PV) + where A1 is the result of applying F + to every variable mentioned in A. ++
+ The Projection Expression Variable Remapping yields an algrebra expression that + evaluates to the same results as the Project argument. No variable of `ProjectMap(Project(A, PV))` + that is not in `PV` is mentioned anywhere else in the algebra expression for the query. +
+This process is applied throughout the graph pattern of EXISTS
:
+ For any algebra expression `X`, define the Variable Remapping `PrjMap(X)` + of algebra expression `X`: +
+PrjMap(X) = replace all project operations Project(P, PV) + with ProjectMap(P, PV) for each projection in X.+
+ The outcome of `PrjMap` is independent of the order of replacement + (e.g. bottom-up or top-down). + Replacements may happen several times, depending on recursive order + but each time a replacement is made, the variable not used anywhere else. +
+ ++ A variable inside a project expression that is not in the variables projected + is not affected by the values insertion operation because it is renamed apart. +
++ Define the Values Insertion function `ValuesInsert(X, μ)` +
+Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1 + +Replace each occurence of `Y` in X where `Y` is one of + Basic Graph Pattern, + Property Path Expression, + `Graph(Var, pattern)`, + Inline Data +with `join(Y, Table(μ))`.+ +
@@ rename as ???correllate
++ Examples +
++ Let `μ` be the current solution mapping for a filter, and `X` a graph pattern, + define the Evaluation of Exists `exists(X)` +
+exists(X) = true + if eval( D(G), ValuesInsert(PrjMap(X), μ) ) + is a non-empty solution sequence. +exists(X) = false otherwise+
The overall SPARQL design can be used for queries which assume a more elaborate form of