W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2009

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

From: Seaborne, Andy <andy.seaborne@hp.com>
Date: Tue, 19 May 2009 13:47:39 +0000
To: Axel Polleres <axel.polleres@deri.org>
CC: "public-rdf-dawg@w3.org" <public-rdf-dawg@w3.org>
Message-ID: <B6CF1054FDC8B845BF93A6645D19BEA3646B6CA3D7@GVW1118EXC.americas.hpqcorp.net>


> -----Original Message-----
> From: Axel Polleres [mailto:axel.polleres@deri.org]
> Sent: 19 May 2009 14:26
> To: Seaborne, Andy
> Cc: public-rdf-dawg@w3.org
> Subject: Re: [ACTION-18] use case on !ASK in FILTERS to emulate
> negation
> 
> 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.

This is something to be worked through: 
Either in a FILTER, e.g.:

   FILTER(EXISTS{?x dc:date ?date})

 (noting the fact that filters apply to the BGP they are in and so can move to the end), or plain inline exactly where they were written (as EXISTS without the word FILTER).

...
WHERE { ?x foaf:givenName  ?name .
        !EXISTS { ?x dc:date ?date }
      }

If a var inside an EXISTS is used after the EXISTS, but did no tget mentioned before, and the EXISTS is executed exactly is it is placed,  then the results can be different.  We need to work through examples to make sure which problem we are solving.  With use of extra {} onlt one form is needed but it may be unnatural and error prone.  Orri was more in favour of the unembedded form when we had the exchange about fitting EXISTS with other filter operations.  

	Andy
 
> 
> best
> Axel
> 
> > 	Andy
> >
> > [*] A plain subquery being (semantically) like a join with the other
> elements in a group.
> >
> >
> >> =============================================================
> >>
> >>
> >>
> >> --
> >> Dr. Axel Polleres
> >> Digital Enterprise Research Institute, National University of
> Ireland,
> >> Galway
> >> email: axel.polleres@deri.org  url: http://www.polleres.net/
> >
> 
> 
> --
> Dr. Axel Polleres
> Digital Enterprise Research Institute, National University of Ireland,
> Galway
> email: axel.polleres@deri.org  url: http://www.polleres.net/
Received on Tuesday, 19 May 2009 13:49:09 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:38 GMT