W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > October to December 2010

Re: FILTER inside FILTER?

From: Birte Glimm <birte.glimm@comlab.ox.ac.uk>
Date: Tue, 2 Nov 2010 11:15:54 +0000
Message-ID: <AANLkTinwCo6Ty62Xw9Z4g97A1+jTQooXevsWjpnUJyMY@mail.gmail.com>
To: Andy Seaborne <andy.seaborne@epimorphics.com>
Cc: SPARQL Working Group <public-rdf-dawg@w3.org>
Trying Reply All this time...
see below

On 1 November 2010 20:59, Andy Seaborne <andy.seaborne@epimorphics.com> wrote:
>
>
> On 01/11/10 16:12, Birte Glimm wrote:
>>
>> Hi all,
>> I  was just wondering whether I can have something like double
>> negation/not exists within not exists, e.g., is
>>   SELECT ?X WHERE { { ?x a ex:A } FILTER NOT EXISTS { FILTER NOT
>> EXISTS { ?x a ex:B } } }
>> a legal query?
>
> yes.
>
>> According to the grammar it seems to be, but from
>> looking at the algebra, I can't see how I would translate that into a
>> proper query algebra expression. There is still @@NOT EXISTS, so maybe
>> all will be clear once that is defined, but inuitively, I would expect
>> that when evaluating the innermost FILTER NOT EXISTS, I substract
>> solutions from the ?x a ex:A evaluation according to the filer, but
>> then it is unclear what the outer FILTER NOT EXISTS works on.
>>
>> E.g., my default graph has:
>> ex:a1 a ex:A .
>> ex:a2 a ex:A .
>> ex:a2 a ex:B .
>>
>> For the BGP ?x a ex:A, I get mu1=(x/ex:a1) and mu2=(x/ex:a2). When I
>> then evaluate FILTER NOT EXISTS { ?x a ex:B }, it remains
>> mu1=(x/ex:a1), but then?
>
> s/?X/?x/
>
> ---------
> | x     |
> =========
> | ex:a2 |
> ---------
>
> SELECT ?x WHERE
> { { ?x a ex:A }
>  FILTER NOT EXISTS
>      { FILTER NOT EXISTS { ?x a ex:B } }
>  }
>
> NOT EXISTS works by substituting the variables, executing the pattern and
> seeing if there are any rows.
>
> The inner
>      { FILTER NOT EXISTS { ?x a ex:B } }
> is a filter on the result of the empty pattern

Ah, that's what I didn't get, that it then operates on the empty
pattern, but that makes sense.

The rest is clear then. Thanks for the detailed explanation.

Birte

[snip]

-- 
Dr. Birte Glimm, Room 309
Computing Laboratory
Parks Road
Oxford
OX1 3QD
United Kingdom
+44 (0)1865 283520
Received on Tuesday, 2 November 2010 11:16:27 GMT

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