Re: indication of intended meaning for EXISTS from SPARQL specifications

On 02/11/2018 11:00 AM, Andy Seaborne wrote:
> Peter,
>
> The SPARQL 1.1 charter [0] contains the required feature description:
>
> """
> Negation. In the current SPARQL Recommendation “Negation As Failure” is
> possible by combining OPTIONAL, FILTER and !BOUND. It is yet difficult to
> write and can be a burden for learning and using SPARQL. Hence, dedicated
> language constructs for expressing negation will be introduced.
> """
>
> which does not require equivalence with SPARQL 1.0 OPTIONAL/!bound.
>
> It is the motivation for the work item which lead to two language features -
> MINUS and FILTER-NOTEXISTS.
>
> [0] https://www.w3.org/2011/05/sparql-charter
>
> The quotes below have additional context:
>
> On 09/02/18 14:11, Peter F. Patel-Schneider wrote:
>> I was reading a paper on adding preferences to SPARQL [1] and came across an
>> intriguing comment:
>>
>> "Similarly, NOT EXISTS could be replaced by a well-known combination of
>> OPTIONAL and FILTER(!bound) (cf. [[SPARQL 1.0 Query Language specification],
>> Section 11.4.1])"
>
> That phase is from the position paper version of the work. The extend report
> version says "As for the SPARQL1.0 version of the same query," so they are
> talking about the query under discussion and in relation to the translation
> of PREFERRING.

The technical report version of the paper, available at
ftp://ftp.cs.toronto.edu/csrg-technical-reports/619/619.pdf, says

note again that in SPARQL 1.0 NOT EXISTS is
replaced by the well-known combination of OPTIONAL and FILTER(!bound) (cf.
(Prud’hommeaux &
Seaborne, 2008, Section 11.4.1)) to emulate set difference,

again making the point that the authors consider NOT EXISTS to work the same
as a combination of OPTIONAL and FILTER, at least for their uses.  The
authors' approach actually breaks for some preferences because of the
divergences between NOT EXISTS and the OPTIONAL/FILTER combination.

>
>> I checked the specification for both the SPARQL 1.0 Query Language [10] and
>> the SPARQL 1.1 Query Language [11].  From both of these documents,
>>
>> "One may test that a graph pattern is not expressed by specifying an OPTIONAL
>> graph pattern that introduces a variable and testing whether the variable is
>> not bound."
>>
>> This matches up directly with the stated intent of EXISTS from [11]
>>
>> "The NOT EXISTS filter expression tests whether a graph pattern does not match
>> the dataset"
>
> The rest of the sentence says:
>
> """
> given the values of variables in the group graph pattern in which the filter
> occurs.
> """
>
> which is where the replacement-substitution comes from (yes, it has some
> issues as identified by the CG).

I will be sending out a separate message on this point.

>
>> The first quote forms a very good source for the intent of NOT EXISTS, i.e.,
>>
>>    SELECT DISTINCT * WHERE {
>>      alpha
>>      FILTER NOT EXISTS { beta }
>>    }
>>
>> should behave as close as possible to
>>
>>    SELECT DISTINCT * WHERE {
>>      alpha
>>      OPTIONAL { beta BIND ( 1 AS ?exists ) }
>>      FILTER ( ! BOUND( ?exists ) )
>>    }
>>
>> (I deliberately added DISTINCT to eliminate one potential source of
>> divergence.)
>>
>>
>> Aspects of EXISTS that interfere with the above equivalence should be
>> considered mistakes to be corrected.
>
> MINUS (without domain condition) would be a better focus for a
> OPTIONAL/!bound comparison.

Perhaps, but there is this existing comparison between NOT EXISTS and
OPTIONAL/!bound that I noticed and that I think gives a good intuition for
what NOT EXISTS should be.

>
>     Andy
>
>> peter
>>
>>
>> [1] SPARQL with Qualitative and Quantitative Preferences.  Marina Gueroussova,
>> Axel Polleres, and Sheila A. McIlraith.  Proceedings of the 2nd International
>> Work- shop on Ordering and Reasoning (OrdRing 2013), at ISWC 2013, Sydney,
>> Australia, 22 October 2013. CEUR Workshop Proceedings, vol. 1059 (2013).
>>
>> [10] SPARQL 1.0 Query Language
>> https://www.w3.org/TR/rdf-sparql-query/
>>
>> [11] SPARQL 1.1 Query Language specification
>> https://www.w3.org/TR/sparql11-query/
>>
>>
>

Received on Monday, 12 February 2018 15:19:20 UTC