W3C home > Mailing lists > Public > www-rdf-rules@w3.org > October 2003

RE: Query, rules and RDF datatyping

From: Geoff Chappell <geoff@sover.net>
Date: Wed, 8 Oct 2003 11:00:43 -0400
To: "'Graham Klyne'" <gk@ninebynine.org>, <www-rdf-rules@w3.org>
Message-ID: <012201c38dac$f626b8d0$0100a8c0@gsclaptop>



> -----Original Message-----
> From: www-rdf-rules-request@w3.org
[mailto:www-rdf-rules-request@w3.org]
> On Behalf Of Graham Klyne
> Sent: Wednesday, October 08, 2003 10:10 AM
> To: www-rdf-rules@w3.org
> Subject: Query, rules and RDF datatyping
> 
> 
[...]

> 
> I'll build this up by example, using bits of (approximate) RDQL.
Consider
> the query:
> 
> SELECT ?x, ?y
> WHERE
>    :vehicle :standingCapacity ?x .
>    :vehicle :seatedCapacity ?y .
> 
> This is pretty boring, and doesn't come close to what I want to
> achieve.  But RDQL offers <SUCHTHAT> clauses, which I think are
introduced
> by "AND" (the grammar in citation [1] doesn't actually say):
> 
> SELECT ?x, ?y
> WHERE
>    :vehicle :standingCapacity ?x .
>    :vehicle :seatedCapacity ?y .
> AND
>    ?x + ?y = 60 .
> 
> This allows me to build conditions based on arithmetic operations, but
> doesn't give access to the results.  But if I say:
> 
> SELECT ?z
> WHERE
>    :vehicle :standingCapacity ?x .
>    :vehicle :seatedCapacity ?y .
> AND
>    ?x + ?y = ?z .

So do I understand correctly that it's not currently possible to return
bindings from constraints in a RDQL query? And that's what you need to
support your datatyping rules? I'd always wondered why the two pieces
were separate - triple bindings and additional constraints - i.e. why
isn't it just:

 WHERE
    :vehicle :standingCapacity ?x .
    :vehicle :seatedCapacity ?y .
    ?x + ?y = ?z .

We treat them that way in RDFQL - e.g.

WHERE {[standingCapacity] [vehicle] ?x} 
	AND  {[seatedCapacity] [vehicle] ?y}
	AND ?z=add(?x, ?y)


> Here, the constraint clause is treated not simply as returning a
> true/false
> result, but is extended so that (like a clause in Prolog) any variable
> bindings that may added to make the clause true are also returned.
The
> simple constraint case simply returns the existing variable binding or
> none
> at all.  If there is more than one possible binding for ?z, then
> additional
> query results may be generated.
> 
> So consider the query:
> 
> SELECT ?x, ?y, ?z
> WHERE
>    :vehicle :standingCapacity ?x .
>    :vehicle :seatedCapacity ?y .
> AND
>    ?x + ?y <= ?z . && ( ?z = 30 . || ?z = 60 . )
> 
> applied to the following target graphs:
> 
> (1)  :vehicle :standingCapacity 20 .     -->   [(?x=20,?y=30,?z=60)]
>       :vehicle :seatedCapacity 30 .
> (just one result)
> 
> (2)  :vehicle :standingCapacity 30 .     -->   []
>       :vehicle :seatedCapacity 40 .
> (no result)
> 
> (2)  :vehicle :standingCapacity 10 .     -->   [(?x=10,?y=20,?z=30),
>       :vehicle :seatedCapacity 20 .              (?x=10,?y=20,?z=60)]
> (two results)
> 
> This begs questions about how new variable bindings may be generated,
> particularly since I want to be able to use this with both forward and
> backward rule chaining, but I have some ideas that I think I can see
how
> to
> prototype.

This gets you into the finite domain constraint world, doesn't it - i.e.
you need some way of enumerating the possible (finite) values for a
particular variable (and hopefully some means of propagating constraints
to avoid combinatorial hell and make it practical with non-toy domains.)

 
> #g
> --


Geoff Chappell
Received on Wednesday, 8 October 2003 11:01:03 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 2 March 2016 11:10:14 UTC