Re: test cases for SPARQL CONSTRUCT

Andy Seaborne wrote:
> jos.deroo@agfa.com wrote:
>> making use of the excellent service at
>> http://sparql.org/query.html
>> 
>> I asked
>> 
>> 1/
>> 
>> PREFIX dc:      <http://purl.org/dc/elements/1.1/>
>> PREFIX owl:     <http://www.w3.org/2002/07/owl#>
>> PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>> CONSTRUCT ($book rdf:type owl:Nothing) WHERE ($book dc:title $title)
> 
> Great! (sigh of relief that it worked - the log file has a warning 
abount the 
> unbound variables.
> 

:)good good

>> 
>> 
>> and got result graph
>> 
>> @prefix dc:      <http://purl.org/dc/elements/1.1/> .
>> @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
>> @prefix owl:     <http://www.w3.org/2002/07/owl#> .
>> 
>> <http://example.org/book/book2>
>>       a       owl:Nothing .
>> 
>> <http://example.org/book/book4>
>>       a       owl:Nothing .
>> 
>> <http://example.org/book/book1>
>>       a       owl:Nothing .
>> 
>> <http://example.org/book/book5>
>>       a       owl:Nothing .
>> 
>> <http://example.org/book/book3>
>>       a       owl:Nothing .
>> 
>> 
>> which is inconsistent and that is because the query
>> (when seen as rule) is inconsistent.
> 
> There isn't an OWL processor behind the data so you only get the 
RDF-isms.
> 

ok, was just to indicate that some results, especially when
(sub)queries are further delegated to other services (which are
using CONSTRUCT WHERE's that one is not necessarily aware of),
can contain wrong evidence..

>> 
>> 
>> 2/
>> 
>> PREFIX dc:      <http://purl.org/dc/elements/1.1/>
>> PREFIX owl:     <http://www.w3.org/2002/07/owl#>
>> PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>> CONSTRUCT ($book dc:title $test) WHERE ($book dc:title $title)
>> 
>> 
>> and got empty result graph
> 
> Yes - I made the arbitrary-at-the-time decision that unbound variables 
are an 
> error.  The code isn't fixed - may it should stop the whole substitution 
for 
> that query solution and and I think I only stop the triple.
> 
> Tries ...
> 
> PREFIX dc:      <http://purl.org/dc/elements/1.1/>
> PREFIX owl:     <http://www.w3.org/2002/07/owl#>
> PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX :        <http://www.example.org/>
> CONSTRUCT ($book dc:title $test) ($book rdf:type :book)
> WHERE ($book dc:title $title)
> 
> and gets ...
> 
> @prefix dc:      <http://purl.org/dc/elements/1.1/> .
> @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix :        <http://www.example.org/> .
> @prefix owl:     <http://www.w3.org/2002/07/owl#> .
> 
> <http://example.org/book/book2>
>        a       :book .
> 
> <http://example.org/book/book4>
>        a       :book .
> 
> <http://example.org/book/book1>
>        a       :book .
> 
> <http://example.org/book/book5>
>        a       :book .
> 
> <http://example.org/book/book3>
>        a       :book .
> 
> Yep - I'll do whatever the WG decides.
> 

I think this returned graph is OK..
also Cwm returns such a graph for

@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix q: <http://www.w3.org/2004/ql#>.
@prefix : <http://www.example.org/> .

[] q:select { ?book dc:title ?test . ?book rdf:type :book } ;
   q:where  { ?book dc:title ?title } .

the rule
{ ?book dc:title ?title } => { ?book dc:title ?test } .
just sits there I guess
whereas the rule
{ ?book dc:title ?title } => { ?book rdf:type :book } .
constructs the answer.

 
>> 
>> My implementation actually returns
>> :Paper :authorName ?test.
>> 
>> which is because we made it so to return
>> substitution results (constructed as RDF graph)
>> for unbound variables (e.g. in the case of OR
>> or OPTIONAL)
> 
> That would require returning query variables which can't be expressed in 
RDF (or 
> we have to have a DAWG-convention) but I see nothing to stop that being 
done at 
> the practical level.  I look for guidance on the theoretical level.
> 
>> 
>> But I can understand the returning of the empty graph
>> as it is according to my understanding that the proof
>> result atoms should be in the Herbrand base of the
>> query formula.
>> 
>> (Herbrand Base is the set of all ground atoms that can
>> be formed from predicate symbols from a clause in Skolemized
>> form S and terms from the Herbrand universe H of S.
>> Herbrand universe of S is the set of all closed terms
>> constructed from the constant and function symbols of S)
>> 
>> 
> 
> That would suggest that my test case should create the (?book rdf:type 
:book) 
> triples even when ?test is unbound - have I got this right?
> 

I would actually think so
(and start changing my implementation :))


>                Andy
> 

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

PS on the other hand for the query

@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix q: <http://www.w3.org/2004/ql#>.
@prefix : <http://www.example.org/> .

[] q:select { (?book ?test) a q:Answer } ;
   q:where  { ?book dc:title ?title } .


Cwm produces

     @prefix : <booksQ.n3#> .
     @prefix q: <http://www.w3.org/2004/ql#> .
 
      ( <http://example.org/book/book1> 
        :test  )
         a q:Answer .
      ( <http://example.org/book/book2> 
        :test  )
         a q:Answer .
      ( <http://example.org/book/book3> 
        :test  )
         a q:Answer .
      ( <http://example.org/book/book4> 
        :test  )
         a q:Answer .
      ( <http://example.org/book/book5> 
        :test  )
         a q:Answer .

which is a remarkable use of :test
??





"Seaborne, Andy" <andy.seaborne@hp.com>
Sent by: public-rdf-dawg-request@w3.org
11/11/2004 16:30
Please respond to andy.seaborne

 
        To:     Jos De_Roo/AMDUS/MOR/Agfa-NV/BE/BAYER@AGFA
        cc:     public-rdf-dawg@w3.org
        Subject:        Re: test cases for SPARQL CONSTRUCT



jos.deroo@agfa.com wrote:
> making use of the excellent service at
> http://sparql.org/query.html
> 
> I asked
> 
> 1/
> 
> PREFIX dc:      <http://purl.org/dc/elements/1.1/>
> PREFIX owl:     <http://www.w3.org/2002/07/owl#>
> PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> CONSTRUCT ($book rdf:type owl:Nothing) WHERE ($book dc:title $title)

Great! (sigh of relief that it worked - the log file has a warning abount 
the 
unbound variables.

> 
> 
> and got result graph
> 
> @prefix dc:      <http://purl.org/dc/elements/1.1/> .
> @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix owl:     <http://www.w3.org/2002/07/owl#> .
> 
> <http://example.org/book/book2>
>       a       owl:Nothing .
> 
> <http://example.org/book/book4>
>       a       owl:Nothing .
> 
> <http://example.org/book/book1>
>       a       owl:Nothing .
> 
> <http://example.org/book/book5>
>       a       owl:Nothing .
> 
> <http://example.org/book/book3>
>       a       owl:Nothing .
> 
> 
> which is inconsistent and that is because the query
> (when seen as rule) is inconsistent.

There isn't an OWL processor behind the data so you only get the RDF-isms.

> 
> 
> 2/
> 
> PREFIX dc:      <http://purl.org/dc/elements/1.1/>
> PREFIX owl:     <http://www.w3.org/2002/07/owl#>
> PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> CONSTRUCT ($book dc:title $test) WHERE ($book dc:title $title)
> 
> 
> and got empty result graph

Yes - I made the arbitrary-at-the-time decision that unbound variables are 
an 
error.  The code isn't fixed - may it should stop the whole substitution 
for 
that query solution and and I think I only stop the triple.

Tries ...

PREFIX dc:      <http://purl.org/dc/elements/1.1/>
PREFIX owl:     <http://www.w3.org/2002/07/owl#>
PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX :        <http://www.example.org/>
CONSTRUCT ($book dc:title $test) ($book rdf:type :book)
WHERE ($book dc:title $title)

and gets ...

@prefix dc:      <http://purl.org/dc/elements/1.1/> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix :        <http://www.example.org/> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .

<http://example.org/book/book2>
       a       :book .

<http://example.org/book/book4>
       a       :book .

<http://example.org/book/book1>
       a       :book .

<http://example.org/book/book5>
       a       :book .

<http://example.org/book/book3>
       a       :book .

Yep - I'll do whatever the WG decides.


> 
> My implementation actually returns
> :Paper :authorName ?test.
> 
> which is because we made it so to return
> substitution results (constructed as RDF graph)
> for unbound variables (e.g. in the case of OR
> or OPTIONAL)

That would require returning query variables which can't be expressed in 
RDF (or 
we have to have a DAWG-convention) but I see nothing to stop that being 
done at 
the practical level.  I look for guidance on the theoretical level.

> 
> But I can understand the returning of the empty graph
> as it is according to my understanding that the proof
> result atoms should be in the Herbrand base of the
> query formula.
> 
> (Herbrand Base is the set of all ground atoms that can
> be formed from predicate symbols from a clause in Skolemized
> form S and terms from the Herbrand universe H of S.
> Herbrand universe of S is the set of all closed terms
> constructed from the constant and function symbols of S)
> 
> 

That would suggest that my test case should create the (?book rdf:type 
:book) 
triples even when ?test is unbound - have I got this right?

                 Andy

Received on Thursday, 11 November 2004 16:27:01 UTC