Example not-necessarily-terminating rules

As Jos pointed out, without a specific definition of 
guaranteed-terminating safeness it is hard to construct a clear cut example.

However, here's a simple example which I believe would fail for any such 
definition.

Length of an RDF list:

    length(rdf:nil, 0).
    length(?list, ?len) :- ?list[rdf:rest->?next],
                           length(?next, ?l), ?len = ?l + 1 .

For well-formed RDF data then lists are linear and finite and this will 
terminate with either a forward or backward chaining proof strategy. RDF 
does not preclude circular lists so it would be possible to construct a 
RIF+RDF combination which would not terminate with this rule set, hence 
no reasonable definition of terminating-safeness would admit this rule 
set. Yet I assert that counting of finite things (e.g. the number of 
items in an invoice, or number of authors on a paper) is a reasonable 
thing to want to do within Core.

Note that the original proposal [1] did not allow for assignment and had 
no distinction between recursive and non-recursive rule sets so in fact 
a simple "business" rule like:

    finalPrice(?x, ?p) :-  price(?x, ?r), discount(?x ?d), ?p = ?r * ?d.

would, I believe, have been unsafe.

Does this help?

Dave

[1] http://lists.w3.org/Archives/Public/public-rif-wg/2008Sep/0178.html

Received on Tuesday, 3 February 2009 23:51:40 UTC