Re: FILTER inside FILTER?

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 UTC