Re: interesting examples revised

On 11/28/2016 08:26 AM, Andy Seaborne wrote:
> 
> 
> On 26/11/16 21:39, Peter F. Patel-Schneider wrote:

> Example 2
>> SELECT ?x WHERE {
>>   ?x :p :v .
>>   FILTER ( EXISTS {
>>     SELECT (?y as ?x) WHERE {
>>       ?y :r :w .
>>       }
>>     } )
>>   }
>>
>> Specification    error issue 2
>> Proposal A    { }
>> Proposal B    { { (x,:s) } }  << I think.
> 
> No - syntax error by assignment rule.
> 
> Assigning to an already assigned variable is an error in SPARQL and proposal B
> sets ?x inside the SELECT

Why make this example be a syntax error?  It should work fine.

>> Expected    { }
> ? Why?

The inner select doesn't use ?x inside itself at all.  Therefore that should
be unaffected by the EXISTS processing.   All that the extension and
projection do is rename the inner ?y to ?x, which should also be fine.  The
effect of the inner select should thus be the same as
  ?x :r :w .
which would produce an empty result in the example graph.

> Digression:
> 
> Both proposals need to deal with
> 
>    EXISTS { BIND(... AS ?x) }
> 
> Proposal-B forbids it statically (see also grammar notes 12 and 13)

As does Proposal A, via a very similar mechanism - modifying the scoping rules
to put the filter variables in-scope for the EXISTS argument.

There may be a difference in BINDs deeper inside.  Proposal A allows

EXISTS { { BIND (... AS ?x) } }

and

EXISTS { SELECT * { BIND ( ... AS ?x ) } }

peter

Received on Monday, 28 November 2016 17:44:23 UTC