Fw: A question about the OPTIONAL pattern

I believe that Lu Jing's last example touches on the FILTER scope issue.

I think that in my view of the world (FILTER scoped to innermost { ... } 
group) that the !bound FILTER in the last query does not constrain 
anything (since the solution the innermost group containing the FILTER 
does not have ?z bound and then that entire group is the first argument to 
the OPTIONAL which adds back in the binding to ?z).

If the FILTER were placed as a sibling to the {...}UNION{...}OPTIONAL{...} 
construct, then i'd expect the query to have no solutions.

I'd like to know if other DAWG members agree with these expectations?

Unless I'm misunderstanding something, I'll be glad to reply to Lu Jing to 
explain that this is an issue that the WG is working through, with or 
without what I think the answers are. (I'm not sure I agree that there is 
any new issue here with regard to OPTIONAL, as opposed to the FILTER scope 
issue that we're working on.)

Lee

----- Forwarded by Lee Feigenbaum/Cambridge/IBM on 09/21/2006 01:59 AM 
-----

"Lu Jing" <robert_lu00@hotmail.com> 
Sent by: public-rdf-dawg-comments-request@w3.org
09/21/2006 01:00 AM

To
public-rdf-dawg-comments@w3.org
cc

Subject
A question about the OPTIONAL pattern







I feel that the semantics of OPTIONAL pattern is still not clear.  If my 
understanding is correct, according to the specification, OPTIONAL pattern 

can modify the solutions of a pattern by adding new bindings to unbounded 
variables.  The problem is, in some cases, add additional binding to a 
unbounded variable may cause this solution no longer a valid solution of 
the original pattern.  We can see the following example.

Assume the data is:

:a :p1 :b
:a :p2 :c

If we have the following SPARQL:

SELECT ?x ?y ?z WHERE { { ?x :p1 ?y } UNION { ?x :p3 ?z } }

The result should contain only one solution:

( :a :b _ )
Here, I use "_" to represent a unbound variable.

Now if we add an optional pattern to the above query, that is:

SELECT ?x ?y ?z WHERE { { { ?x :p1 ?y } UNION { ?x :p3 ?z } } . OPTIONAL { 

?x :p2 ?z } }

According to the definition, the optional pattern additionally add a 
binding to the variable ?z. So the solution should be:
( :a :b :c )

It seems OK in this case, as the ( :a :b :c ) is also a solution to the 
UNION pattern.
But now if we add a filter to the first query, that is:

SELECT ?x ?y ?z WHERE { { { ?x :p1 ?y } UNION { ?x :p3 ?z } } . FILTER ( 
!BOUND(?z) ) }

The solution of this query should be:
( :a :b _ )
That is, not changed from the first query.  But now if we again add an 
option pattern to it, that is:

SELECT ?x ?y ?z WHERE { { { { ?x :p1 ?y } UNION { ?x :p3 ?z } } . FILTER ( 

!BOUND(?z) ) } . OPTIONAL { ?x :p2 ?z } }

If we follow the definition, the solution should be still:
( :a :b :c )
But this time, we have a filter in the first pattern that says the ?z 
should not be bound.  That means, this answer is not a solution of the 
pattern without the optional pattern.

So I wonder what is the exact definition of an optional pattern, and what 
should the answers of the above querys be?

Received on Thursday, 21 September 2006 06:03:55 UTC