- From: <jos.deroo@agfa.com>
- Date: Sun, 13 Mar 2005 13:47:16 +0100
- To: syosi@MIT.EDU
- Cc: public-cwm-bugs@w3.org
Yosi Scharf wrote:
> Quoting jos.deroo@agfa.com:
>
>>
>> given
>>
>> ### test-rules.n3
>> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
>> @prefix : <test#>.
>>
>> :Z :allOf (:A :B :C).
>>
>> {?L rdf:first ?I} => {?L :item ?I}.
>> {?L rdf:rest ?R. ?R :item ?I} => {?L :item ?I}.
>> ###
>>
>
> This is NOT a bug. This is just how cwm's foreward chainer works.
> ?L rdf:first ?I would run a builtin, and cwm will never simply
> try every node to see if the builtin will run. You need some way
> of narrowing down to select a node.
>
> These rules can become something like:
>
> :Z :allOf (:A :B :C).
> {?m :allOf ?x} => {:x a :NeedsItem}
> {?L a :NeedsItem; rdf:first ?I; rdf:rest ?x} => {?L :item ?I; ?x a
:NeedsItem}.
> {?L a :NeedsItem; rdf:rest ?R. ?R :item ?I} => {?L :item ?I}.
>
> and then they should work.
OK
instead of :NeedsItem I tried with rdf:List
:Z :allOf (:A :B :C).
{?M :allOf ?X} => {?X a rdf:List}.
{?L rdf:rest ?X; a rdf:List} => {?X a rdf:List}.
{?L rdf:first ?I; a rdf:List} => {?L :item ?I}.
{?L rdf:rest ?R; a rdf:List. ?R :item ?I} => {?L :item ?I}.
and then query
[] q:select {?I :okFor ?Y}; q:where {?Y :allOf ?L. ?L :item ?I}.
indeed gives
@prefix : <test#> .
:A :okFor :Z .
:B :okFor :Z .
:C :okFor :Z .
> Yosi Scharf
--
Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/
Received on Sunday, 13 March 2005 12:48:02 UTC