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

On UCR Document as on May 18 2008

From: Adrian Giurca <giurca@tu-cottbus.de>
Date: Tue, 20 May 2008 13:00:17 +0200
Message-ID: <4832AF41.1040103@tu-cottbus.de>
To: "'Public-Rif-Wg (E-mail)'" <public-rif-wg@w3.org>

May I suggest a more "object-oriented" encoding for rules in UC 2.1? In 
many cases (Drools, JRules, F-Logic, Jess) people uses object oriented 
rule languages to encode their rules.

Assuming  John has rules in F-Logic (here is the basic syntax of 
F-Logic) the rule "If an item is perishable and it is delivered more 
than 10 days after the scheduled delivery date then the item will be 
rejected" looks like:

RULE R1 I:item[status -> "rejected"] <- I:item[isPerishable -> true] AND
                              I[actualDeliveryDate -> A] AND 
                              I[scheduledDeliveryDate -> S] AND 
                              R is (A - S) AND R > 10.


Then a  RIF encoding (abridged syntax) is:

Rule ("http://john.com/R1"
      ?i#<j:Item>[(<j:isRejected>->"true"^^xs:boolean) :-
                   And(
                     ?i#Item[(<j:isPerishable>->"true"^^xs:boolean) 
                             (<j:actualDeliveryDate>->?actualDeliveryDate ) 
                             (<j:scheduledDeliveryDate> ->?scheduledDeliveryDate)
                     ]
                     External(<fn:subtract-dateTimes-yielding-dayTimeDuration>(?actualDeliveryDate ?scheduledDeliveryDate ?diffduration))
                     External(<fn:get-days-from-dayTimeDuration>(?diffduration ?diffdays))
                     External(<op:numeric-greater-than>(?diffdays "10"^^xs:int))
                   )
)

which can be easily translated to Drools such as:

rule "R1"
 when
  i : Item(isPerishable==true, actualDeliveryDate : actualDeliveryDate, 
           scheduledDeliveryDate : scheduledDeliveryDate 
      )
  eval( actualDeliveryDate.getDay() - scheduledDeliveryDate.getDay() > 10)
 then
  i.isRejected(true);
  modify(i);
end

I maintain a number of documents  on rule interchange our wiki: 
http://hydrogen.informatik.tu-cottbus.de/wiki/index.php/Category:Rule_Interchange 


-Adrian G
Received on Tuesday, 20 May 2008 11:01:15 GMT

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