From 676ac00591402790461c85ab6c14f883b9de1e12 Mon Sep 17 00:00:00 2001 From: Olaf Hartig Date: Fri, 12 Dec 2025 13:00:09 +0100 Subject: [PATCH 1/3] adds the formal definition of the evaluation of EXISTS --- spec/index.html | 50 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/spec/index.html b/spec/index.html index 272e758..560ffb8 100644 --- a/spec/index.html +++ b/spec/index.html @@ -5688,30 +5688,45 @@
COALESCE
NOT EXISTS and EXISTS

There is a filter operator EXISTS that takes a graph pattern. EXISTS returns true/false depending on whether the - pattern matches the dataset given the bindings in the current group graph pattern, the - dataset and the active graph at this point in the query - evaluation. No additional binding of variables occurs. The NOT EXISTS form - translates into fn:not(EXISTS{...}).

+ pattern matches the dataset given solution mapping with respect to which + the expression is evaluated. + No additional binding of variables occurs. The NOT EXISTS form + translates into fn:fn:not(EXISTS {...}).

 
 xsd:boolean  NOT EXISTS { pattern }
             
-

Returns false if pattern matches. Returns true +

Returns false if pattern matches. Returns `true` otherwise.

-

NOT EXISTS { pattern } is equivalent to fn:not(EXISTS { pattern +

NOT EXISTS { pattern } is equivalent to fn:not(EXISTS { pattern }).

 
 xsd:boolean EXISTS { pattern }
             
-

Returns true if pattern matches. Returns false +

Returns true if pattern matches. Returns `false` otherwise.

-

Variables in the pattern that are bound in the current - solution mapping take the value that they - have from the solution mapping. Variables in the pattern pattern that are - not bound in the current solution mapping take part in pattern matching.

-

To facilitate this, we introduce a function Exists that - evaluates a SPARQL Algebra expression and returns true or false, depending on whether - there are any solutions to the pattern, given the solution mapping being tested by the - filter operation.

+

Formally, for every expression |expr| + that is of the form `EXISTS { pattern }`, + the result of evaluating |expr| + with respect to a solution mapping μ, + in the context of a dataset |D| + with active graph |G|, + is:

+ +

where |A| is the algebraic query expression + obtained by translating `{ pattern }` as per .

+

+ As per the ExistsFunc production + of the grammar, + `{ pattern }` matches the GroupGraphPattern production. + The specific subsection of + that covers the translation of any GroupGraphPattern + is .

logical-or
@@ -10670,6 +10685,11 @@

Evaluation Semantics

in correlation with solution mapping μctx.

The active graph is initially the default graph of |D| and μctx is initially the empty solution mapping μ0.

+

The case in which μctx + may be different from μ0 + is when evaluating an expression + of the form `EXISTS pattern` or `NOT EXISTS pattern`, + as defined in .

Further symbols used in the following definitions are:

  • |P|, P1, P2 : graph patterns
  • From eae3925cdade59d8445865c847393f72e5522e2b Mon Sep 17 00:00:00 2001 From: Olaf Hartig Date: Fri, 12 Dec 2025 18:14:13 +0100 Subject: [PATCH 2/3] Consistent code fencing Co-authored-by: Thomas Tanon --- spec/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/index.html b/spec/index.html index 560ffb8..0d2bc70 100644 --- a/spec/index.html +++ b/spec/index.html @@ -5695,14 +5695,14 @@
    NOT EXISTS and EXISTS
     
     xsd:boolean  NOT EXISTS { pattern }
                 
    -

    Returns false if pattern matches. Returns `true` +

    Returns `false` if pattern matches. Returns `true` otherwise.

    NOT EXISTS { pattern } is equivalent to fn:not(EXISTS { pattern }).

     
     xsd:boolean EXISTS { pattern }
                 
    -

    Returns true if pattern matches. Returns `false` +

    Returns `true` if pattern matches. Returns `false` otherwise.

    Formally, for every expression |expr| that is of the form `EXISTS { pattern }`, From b3780fde73d4e66027a1548e535fd37dad839d01 Mon Sep 17 00:00:00 2001 From: Olaf Hartig Date: Thu, 18 Dec 2025 09:15:00 +0100 Subject: [PATCH 3/3] Consistent code fencing --- spec/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/index.html b/spec/index.html index 0d2bc70..9077f48 100644 --- a/spec/index.html +++ b/spec/index.html @@ -5695,14 +5695,14 @@

    NOT EXISTS and EXISTS
     
     xsd:boolean  NOT EXISTS { pattern }
                 
    -

    Returns `false` if pattern matches. Returns `true` +

    Returns `false` if `pattern` matches. Returns `true` otherwise.

    NOT EXISTS { pattern } is equivalent to fn:not(EXISTS { pattern }).

     
     xsd:boolean EXISTS { pattern }
                 
    -

    Returns `true` if pattern matches. Returns `false` +

    Returns `true` if `pattern` matches. Returns `false` otherwise.

    Formally, for every expression |expr| that is of the form `EXISTS { pattern }`,