Re: [ACTION-18] use case on !ASK in FILTERS to emulate negation

On 19 May 2009, at 14:25, Axel Polleres wrote:

> Seaborne, Andy wrote:
>>> -----Original Message-----
>>> From: public-rdf-dawg-request@w3.org [mailto:public-rdf-dawg-
>>> request@w3.org] On Behalf Of Axel Polleres
>>> Sent: 19 May 2009 13:24
>>> To: public-rdf-dawg@w3.org
>>> Subject: [ACTION-18] use case on !ASK in FILTERS to emulate negation
>>>
>>> This completes Action-18:
>>>
>>> http://www.w3.org/2009/sparql/track/actions/18
>>>
>>> =============================================================
>>>
>>> The current spec has the following example of a query emulating
>>> NEGATION, asking for people with a name but no expressed date:
>>>
>>>
>>> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
>>> PREFIX dc:   <http://purl.org/dc/elements/1.1/>
>>> SELECT ?name
>>>  WHERE { ?x foaf:givenName  ?name .
>>>          OPTIONAL { ?x dc:date ?date } .
>>>          FILTER (!bound(?date)) }
>>>
>>> If ASK queries were allowed within FILTER expressions, this could be
>>> written as:
>>>
>>>
>>> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
>>> PREFIX dc:   <http://purl.org/dc/elements/1.1/>
>>> SELECT ?name
>>>  WHERE { ?x foaf:givenName  ?name .
>>>          FILTER (! {ASK { ?x dc:date ?date }})
>>>        }
>>>
>>>
>>> Note here, that the subquery in the FILTER needs to "access" the
>>> bindings from the superquery. This should not be a problem with the
>>> algebra or order dependence since per definition, FILTER expressions
>>> need to have access to the bindings of the group they appear in,  
>>> but it
>>> would mean that such ASK queries in FILTERS (similar to OPTIONAL
>>> patterns in FILTERs) are not entirely compositional in their  
>>> evaluation.
>> Because the evaluation semantics of this FILTER ASK are different  
>> [*] to plain subquery, I currently prefer to have a clearer syntax  
>> keword like EXISTS, !EXISTS.
>
> You mean in FILTERs "EXISTS" instead of "ASK", yes?
> Indeed, makes sense to me.

If we're going to have a new verb, why put it in FILTER expressions?

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc:   <http://purl.org/dc/elements/1.1/>
SELECT ?name
WHERE {
   ?x foaf:givenName  ?name .
   NOTEXISTS { ?x dc:date ?date }
}

or similar is clearer IMHO.

- Steve

-- 
Steve Harris
Garlik Limited, 2 Sheen Road, Richmond, TW9 1AE, UK
+44(0)20 8973 2465  http://www.garlik.com/
Registered in England and Wales 535 7233 VAT # 849 0517 11
Registered office: Thames House, Portsmouth Road, Esher, Surrey, KT10  
9AD

Received on Tuesday, 19 May 2009 13:47:46 UTC