W3C home > Mailing lists > Public > public-rif-wg@w3.org > August 2008

Re: Some testcases for numeric operations...

From: Gary Hallmark <gary.hallmark@oracle.com>
Date: Tue, 19 Aug 2008 12:23:52 -0700
Message-ID: <48AB1DC8.8050402@oracle.com>
To: Axel Polleres <axel.polleres@deri.org>
CC: "Public-Rif-Wg (E-mail)" <public-rif-wg@w3.org>

Very interesting test cases.  The first test case, which I will 
paraphrase as

a(?x) :- a(?x - 1)

cannot be translated directly to a forward chaining PR system like OBR 
or Jess because the ?x is unbound.
The translator needs to know the algebra of the builtins to rewrite to

a(?x + 1) :- a(?x)

This will indeed produce a(3) in working memory before filling memory 
with similar facts.

I guess the converse holds true of a backward chaining system, i.e. when 
presented with

a(?x + 1) :- a(?x)

it would be easier to evaluate if algebraically transformed to

a(?x) :- a(?x - 1)

Clearly, we want both phrasings of the rule to be in core and to be 
equivalent, which seems to imply that some amount of algebraic rewrite 
must happen in translators to avoid unbound variables to builtins.   At 
least it seems like it will be required for my OBR<->Core translator.  I 
hadn't fully realized this until confronted with this concrete test case.


Axel Polleres wrote:
>
> ... that should stress the different behavior of fwd-chaining, 
> bwd-chaining engines. not yet in proper syntax.
>
> Axel
>
> ====================================
> Testcase numeric-minus 1:
>
>   Ruleset:
>
>   a(X) :- a ( External ( func:numeric-minus(X 1 ) ) ) .
>   a(1).
>
> Entailment test:   a(3) ?
>
> ====================================
>
> Testcase numeric-minus 2:
>
>   Ruleset:
>
>   a( External ( func:numeric-minus(X 1 ) )) :-
>          a ( X ),
>          External ( pred:numeric-greater-than-or-equal ( X 0 ) ).
>   a(10).
>
> Entailment test:   a(3) ?
>
> ====================================
> Testcase numeric-add 1:
>
> Ruleset:
>
> a( External ( func:numeric-add(X 1 ) ) :- a ( X ) .
> a( 1 ).
>
> Entailment test:   a(3) ?
> ====================================
>
> Testcase numeric-add 2:
>
>   Ruleset:
>
>   a( X )  :- a (   a( External ( func:numeric-add( X 1 ) )) ),
>              External ( pred:numeric-greater-than ( X 0 ) ).
>   a(10).
>
> Entailment test:   a(3) ?
>
> ====================================
>
Received on Tuesday, 19 August 2008 19:25:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 2 June 2009 18:33:53 GMT