finding stable OPTIONAL query results [Was: question about combining patterns]

We discussed this also in Tcon yesterday and I did another attempt
to find stable OPTIONAL query results using MGU [1] but failed..

For instance for following ?x ?y ?z substitutions
(we do OPTIONAL with set of different queries
and we keep var if it is unbound)

?x ?y ?z
========
?x :b :c
:a ?y :c
:a :d ?z

we either find

?x ?y ?z
========
:a :b :c
:a :d ?z

or

?x ?y ?z
========
?x :b :c
:a :d :c


What I now do is returning

?x ?y ?z
========
[] :b :c
:a [] :c
:a :d []

where the [] is a blank node


-- 
Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/

[1] http://www.cis.temple.edu/~ingargio/cis587/readings/logic1.html#4




Jos De_Roo
03/02/2005 14:54


        To:     "Seaborne, Andy" <andy.seaborne@hp.com>@AGFASMTP
        cc:     "Alberto Reggiori" <alberto@asemantics.com>, "RDF Data Access Working 
Group" <public-rdf-dawg@w3.org>, public-rdf-dawg-request@w3.org
        Subject:        RE: question about combining patterns

agreed with your answer Andy

[...]

> The order issue is a separate matter - I have been working on a
> generalisation of the optional variables rule that also covers
> constraints to get consistent answers. I have an action item to report
> the ordering and optionals issue.

in our implementation the answers are depending on the
ordering of the different queries (which are written in N3)
and I can't find a generic way to do canonical reordering
in order to remove that dependency..


-- 
Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/




"Seaborne, Andy" <andy.seaborne@hp.com>
Sent by: public-rdf-dawg-request@w3.org
02/02/2005 19:34

 
        To:     "Alberto Reggiori" <alberto@asemantics.com>, "RDF Data Access Working 
Group" <public-rdf-dawg@w3.org>
        cc:     (bcc: Jos De_Roo/AMDUS/MOR/Agfa-NV/BE/BAYER)
        Subject:        RE: question about combining patterns



-------- Original Message --------
> From: Alberto Reggiori <>
> Date: 2 February 2005 11:23
> 
> hi all,
> 
> I have small question about an example I came up to test grouping
> 
> Given the following data:
> 
> <http://example.org/book/book1>
<http://purl.org/dc/elements/1.1/title>
> "SPARQL Tutorial" .
> <http://example.org/book/book1> <http://example.org/ns#price>
> "42"^^<http://www.w3.org/2001/XMLSchema#integer> .
> <http://example.org/book/book2>
<http://purl.org/dc/elements/1.1/title>
> "The Semantic Web" .
> <http://example.org/book/book2> <http://example.org/ns#price>
> "23"^^<http://www.w3.org/2001/XMLSchema#integer> .
> 
> is the following query
> 
> PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
> PREFIX  ns:  <http://example.org/ns#>
> SELECT  ?title ?price
> WHERE
> {
>     ( ?x dc:title ?title )
>     ( ?x ns:price ?price )
> }
> AND ( ( ?price < 30 ) || ( ?price > 40 ) )
> 
> going to fail accordingly to what stated in
> 
>                http://www.w3.org/2001/sw/DataAccess/rq23/#CombiningPatterns
> 
> ?
> 
> I think so - due the above query has two graph-patterns, and that the
> constraints by definition do not bind any var - it should fail


It should be OK - what about #CombiningPatterns is suggesting this to
you?

{
    ( ?x dc:title ?title )
    ( ?x ns:price ?price )
}

is a group of patterns that just generates bindings for ?title and
?price these go into the cosntraint.

Variables are NOT scoped by blocks - they are global to the query.  Is
this the reading you are making?

There is an outer group containing this inner group (redundantly) and
the AND clause.  The AND applies to the outer group "all solutions are
such that ?price < 30 || ? price > 40"

The example in that section shows that the query can include {} nesting
and return the same solutions.  Suggestions for improvement?


> 
> While the following query would succeed
> 
> PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
> PREFIX  ns:  <http://example.org/ns#>
> SELECT  ?title ?price
> WHERE
> ( ?x ns:price ?price )
> {
>     ( ?x dc:title ?title )
> }
> AND ( ( ?price < 30 ) || ( ?price > 40 ) )
> 
> due that the first (top most) graph-pattern binds ?x and ?price
> accordingly
> 
> In other words, in the implementation, while processing the blocks
> stack one should execute any "binding graph-pattern" first or fail if
> not possible.

Not sure about "stack" given that variables are in a flat global space.

The order issue is a separate matter - I have been working on a
generalisation of the optional variables rule that also covers
constraints to get consistent answers. I have an action item to report
the ordering and optionals issue.

The rule has to be that for constraints, if a variable is used
elsewhere, that part is executed first.  This naturally follows from the
declarative interpretation.

More soon :-)

                 Andy

> 
> is this the correct behavior?
> 
> thanks
> 
> Alberto
> 
> -
> Alberto Reggiori, @Semantics S.R.L.
> www.asemantics.com

Received on Wednesday, 9 February 2005 12:16:59 UTC