Skip to content

Commit 3f606dd

Browse files
committed
Initial values-insertion draft
1 parent 8390906 commit 3f606dd

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

spec/index.html

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10369,7 +10369,151 @@

Evaluation Semantics

1036910369
eval(D(G), Slice(L, start, length)) = Slice(eval(D(G), L), start, length)
1037010370
1037110371
10372+
10373+
10374+
10375+

Value Insertion and `EXISTS`

10376+

The following sections contain draft of material for a revised

10377+
"`exists`" operation.
10378+

10379+

Background:

10380+
    10381+
    10382+
    10383+
    10384+
    10385+

    Syntax Restriction

    10386+

    Additional [[[#sparqlGrammar]]] note:

    10387+
    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+
    10392+

    Extend the "in-scope" rules to include the variables in-scope from the current row:

    10393+
    10394+
    10395+
    10396+
    Syntax Form
    10397+
    In-scope variables
    10398+
    10399+
    10400+
    `EXISTS` and `NOT EXISTS` filters
    10401+
    v is in-scope if it is in-scope for pattern to which the `FILTER` is applied.
    10402+
    10403+
    10404+
    10405+
    10406+

    10407+
    This restriction means that values inserted
    10408+
    do not conflict with values assigned to varibales with the pattern.
    10409+

    10410+
    10411+
    10412+
    10413+

    Remapping

    10414+

    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+

    10420+

    10421+
    Renaming these variables does not change the results of evalauting
    10422+
    the project expresssion.
    10423+

    10424+
    10425+
    Definition: Projection Expression Variable Remapping
    10426+

    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+
    `V`,
    10430+
    the set of all variables, to `V` where:
    10431+

    10432+
    F(v) = v1 if v is in PV, where v1 is a fresh variable
    10433+
    F(v) = v if v is not in PV
    10434+

    10435+
    Define the Projection Expression Variable Remapping `ProjectMap(P,PV)`
    10436+

    10437+
    ProjectMap(Project(A, PV)) = Project(A1, PV) 
    10438+
    where A1 is the result of applying F
    10439+
    to every variable mentioned in A.
    10440+
    10441+

    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+

    10446+
    10447+
    10448+

    This process is applied throughout the graph pattern of EXISTS:

    10449+
    10450+
    10451+
    Definition: Variable Remapping
    10452+

    10453+
    For any algebra expression `X`, define the Variable Remapping `PrjMap(X)`of algebra expression `X`:
    10454+

    10455+
    PrjMap(X) = replace all project operations Project(P, PV) 
    10456+
    with ProjectMap(P,PV) for each projection in X.
    10457+
    10458+

    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+

    10464+
    10465+

    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+

    10469+
    10470+
    10471+
    10472+

    Values Insertion

    10473+
    10474+
    10475+
    Definition: Values Insertion
    10476+

    10477+
    Define the Values Insertion function `ValuesInsert(X, μ)`
    10478+

    10479+
    Let Table(μ) = { μ } and multiplicity( μ | Table(μ) = { μ } ) = 1
    10480+
    10481+
    Replace each occurence of `Y` in X where `Y` is one of
    10482+
    10483+
    10484+
    10485+
    with `join(Y, Table(μ))`.
    10486+
    10487+
    10488+

    @@ rename as ???correllate

    10489+
    10490+
    10491+
    10492+

    10493+
    Examples
    10494+

    10495+
    10496+
    10497+
    10498+
    10499+

    Evaluation of EXISTS

    10500+
    10501+
    Definition: Evaluation of Exists
    10502+

    10503+
    Let `μ` be the current solution mapping for a filter, and `X` a graph pattern,
    10504+
    define the Evaluation of Exists `exists(X)`
    10505+

    10506+
    exists(X) = true 
    10507+
    if eval( D(G), ValuesInsert(PrjMap(X), μ) )
    10508+
    is a non-empty solution sequence.
    10509+
    exists(X) = false otherwise
    10510+
    10511+
    10512+
    10513+
    10514+
    1037210515
    10516+
    1037310517
    1037410518

    Extending SPARQL Basic Graph Matching

    1037510519

    The overall SPARQL design can be used for queries which assume a more elaborate form of

    0 commit comments

    Comments
     (0)