- From: Graham Klyne <gk@ninebynine.org>
- Date: Wed, 08 Oct 2003 15:10:06 +0100
- To: www-rdf-rules@w3.org
I've been thinking about how to implement inference rules that take account
of RDF datatypes, and operations that may be defined on them. A simple
example would be a rule expressed in CWM thus:
{ :vehicle :standingCapacity ?x ; :seatedCapacity ?y .
(?x ?y) math:plus ?z . }
log:implies
{ :vehicle :totalCapacity ?z . } .
I'm also interested in rules that can be used in either forward- or
backward-chaining mode, but I won't go into that here.
I've been mulling this, and think I have a framework that feels plausible
to me, and which is sufficient to implement CWM-style "magic" properties
(like math:plus in the above example).
[1] http://www.hpl.hp.com/semweb/rdql.htm
Using RDQL [1] as my starting point, the extra step I'm contemplating is to
generalize the idea of a query constraint, ala Prolog. Instead of just
offering a predicate that must be true for some possible query result to be
used, to allow a constraint to add variable bindings to a query result.
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 .
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.
#g
--
[1] http://www.hpl.hp.com/semweb/rdql.htm
------------
Graham Klyne
GK@NineByNine.org
Received on Wednesday, 8 October 2003 10:15:28 UTC