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

Re: exists

From: Andy Seaborne <andy.seaborne@talis.com>
Date: Tue, 25 May 2010 14:26:09 +0100
Message-ID: <4BFBCFF1.9010602@talis.com>
To: SPARQL Working Group <public-rdf-dawg@w3.org>
As we move forward from ideas to last call and beyond, I'd find it quite 
helpful if questions are framed against the document.  This checks the 
text is the right text. I realise that this isn't always possible, and 
also the doc is not yet complete or organised yet.

Alternatively, another useful thing would be to submit test cases, that 
three files (query, data, results) and a manifest entry so we can build 
the test suite up from questions arising.

- - - - - - - - - -

[[ http://www.w3.org/2009/sparql/docs/query-1.1/rq25.xml#defn_exists

exists(pattern, μ) = true if and only if eval(substitute(pattern, μ),
D[g]) has any solutions.
]]

and

[[http://www.w3.org/2009/sparql/docs/query-1.1/rq25.xml#defn_substitute

substitute(pattern, μ) = the pattern formed by replacing every
	  occurrence of a variable in pattern by its value in μ.
]]

so the exists test works as currently proposed works from outside in, 
within the current solution.

That means

select * where {
?x p ?y
filter(! exists[1] {?y q ?z
                        filter(! exists [2] {?x r ?z})
                      })
}

will have the inner ?x replaced by it's value from "?x p ?y" by the 
outer exists operator[1], then the eval of the substituted pattern 
occurs. The inner exists [2] pattern {?x r ?z} is already {<x> r ?z} if 
?x=<x>.

	Andy

On 25/05/2010 1:37 PM, Axel Polleres wrote:
> I would assume that existing bindings should prevail in an exists
> pattern... i.e. before computing the filter, you replace all variables with all existing (non-null) bindings...
> do you see any problem with that?
>
>
> just thinking out loud... would that also work with unbounds from optionals?
> seems not to be a problem... e.g.
>
> let't assume graph:
>
> g1:
>   a p b
>   a q p
>
> q1:
>> select ?x ?y where {
>> ?x p ?y OPTIONAL { ?y q ?z}
>> filter( ! exists {?y q ?z })
>
>
> would return {?x/a ?y/b}, whereas
>
> q2:
>> select ?x ?y where {
>> ?x p ?y OPTIONAL { ?y q ?z}
>> filter( ! exists {?v q ?z FILTER(?y != ?v) })
>
> would return the empty solution set {}
>
> on graph
>
> g2:
>   a p b
>   b q p
>
> in reverse, q1 would return {} and q2 would return  {?x/a ?y/b}, yes?
>
> Axel
>
>
>
>
> On 25 May 2010, at 12:44, Olivier Corby wrote:
>
>> What is the scope of variables in nested exists pattern?
>> For example, is the inner ?x the same as the outer ?x
>>
>>
>> select * where {
>> ?x p ?y
>> filter(! exists {?y q ?z
>>                          filter(! exists {?x r ?z})
>>                        })
>>
>> }
>>
>>
>> Olivier
>>
>>
>
>
>
> Please consider the environment before printing this email.
>
> Find out more about Talis at http://www.talis.com/
> shared innovation™
>
> Any views or personal opinions expressed within this email may not be those of Talis Information Ltd or its employees. The content of this email message and any files that may be attached are confidential, and for the usage of the intended recipient only. If you are not the intended recipient, then please return this message to the sender and delete it. Any use of this e-mail by an unauthorised recipient is prohibited.
>
> Talis Information Ltd is a member of the Talis Group of companies and is registered in England No 3638278 with its registered office at Knights Court, Solihull Parkway, Birmingham Business Park, B37 7YB.
Received on Tuesday, 25 May 2010 13:26:44 GMT

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