- From: Peter F. Patel-Schneider <pfpschneider@gmail.com>
- Date: Fri, 9 Feb 2018 06:11:36 -0800
- To: public-sparql-exists@w3.org
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])" 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 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. 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 Friday, 9 February 2018 14:12:02 UTC