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

RE: [PRD] PRD ch1 review

From: Paul Vincent <pvincent@tibco.com>
Date: Thu, 19 Jun 2008 13:33:36 -0700
Message-ID: <637B7E7B51291C48838F5AE1F2ACA1D714CF56@NA-PA-VBE02.na.tibco.com>
To: "RIF WG" <public-rif-wg@w3.org>
I thought Christian had done a good job on this. I'll split my review by
chapter + my comments are relatively minor:

 

1.1 Introduction 

This document specifies the production rule dialect of the W3C rule
interchange format (RIF-PRD). It is mostly intended for the designers of
RIF-PRD implementations. 

 

Intended for the designers of RIF-PRD translators? Or is the wording
"implementations" intended to convey that RIF-PRD is also targeting a
new class of rule engines?

 

1.3 Running example 

 

Every potato owned by a chicken gets mashed, the daily grain allowance
of every chicken that owns a potato is increased by 10%, and the mashed
potatoes are deleted from the ownership table IF the chicken is older
than 8 months, the potato's weight (in decigrams) is more than half the
chicken's age (in months), it's not Tuesday, and there is no fox in the
hen house. Jim calls it the "Chicken and Mashed Potatoes", or CMP, rule.


 

This definition seems particularly obtuse! It is neither correct English
(with apologies if that is the intent, but I assume not), nor is it
"pseudo code". While I would not go to the extent of replacing this with
SBVR type syntax (:-)) I would suggest saying something like (and it can
probably be improved further):

 

The following sequence of actions occur: chickens' own potatoes are
mashed, chickens owning potatoes have their daily grain allowance
increased by 10%, and mashed potatoes are no longer considered owned by
the chickens  

When: chickens are older than 8 months, their potatoes weight (in
decigrams) is more than half the chicken owners' age (in months), today
is not Tuesday, and no fox is inside the henhouse.  

 

It would also be worth listing any implied assumptions: chickens are
assumed to own potatoes that are mashed during the execution of the
rule. Etc.

 

Rephrased in RIF-PRD Presentation syntax: 

 

 (* jim:ChickenAndMashedPotatoes *)

 Forall ?chicken ?potato ?allowance ?age ?weight (

   Do( Execute(jim:mash(?potato)) 

 
Assign(?chicken[jim:allowance->External(func:numeric-multiply(?allowance
1.1))])

       Retract(jim:owns(?chicken ?potato)) )

   :-

   And( ?chicken#jim:Chicken 

        ?chicken[jim:age->?age jim:allowance->?allowance]

        External(pred:numeric-greater-than(?age, 8))

        ?potato#jim:Potato 

        ?potato[jim:weight->?weight]

        jim:owns(?chicken ?potato)

        External(pred:numeric-greater-than(?weight
External(func:numeric-divide(?age 2))))

        External(pred:string-not-equal(External(jim:today()),
"Tuesday"))

        Not(External(jim:foxAlarm())) ))

 

I stared at this like a headless chicken for a while, trying to work out
what it means. I conclude that (a) it needs annotating at this part of
the PRD document (b) as RIF is meant to be about interchange, it could
also benefit by being preceded by Jrules and OBR versions (or similar).
Of course, I could have just read the next paragraph, but as a serial
thinker I got stuck trying to interpret symbols without the key.

 

My attempt at annotation below:

(* jim:ChickenAndMashedPotatoes *) 

// rule identifier is "jim"

 Forall ?chicken ?potato ?allowance ?age ?weight ( 

 // local variables for theCurrentChicken, etc, will map onto
rulevariables or attributes of rulevariables

   Do(  

   // rule action list

 Execute(jim:mash(?potato))  

 // rule action: mash theCurrentPotato

 
Assign(?chicken[jim:allowance->External(func:numeric-multiply(?allowance
1.1))]) 

       // rule action: for theCurrentChicken, assign
theCurrentAllowance*1.1 to theCurrentAllowance

       Retract(jim:owns(?chicken ?potato)) ) 

       // remove the fact that theCurrentChicken owns theCurrentPotato

   :-

   And( ?chicken#jim:Chicken 

         // associate some Chicken to theCurrentChicken

         // fails if no Chicken

        ?chicken[jim:age->?age jim:allowance->?allowance]

         // associate theCurrentChicken's properties age and allowance
to the approprate theCurrentAge and theCurrentAllowance

         // fails if no such attributes

        External(pred:numeric-greater-than(?age, 8))

         // check if theCurrentAge is > 8

        ?potato#jim:Potato 

         // associate some Potato to theCurrentPotato

        ?potato[jim:weight->?weight]

         // associate theCurrentPotato's weight to theCurrentWeight

         // fails if no such attribute

        jim:owns(?chicken ?potato)

         // check if theCurrentChicken owns theCurrentPotato

        External(pred:numeric-greater-than(?weight
External(func:numeric-divide(?age 2))))

         // check if theCurrentWeight > theCurrentAge / 2

        External(pred:string-not-equal(External(jim:today()),
"Tuesday"))

         // check if today not Tuesday 

        Not(External(jim:foxAlarm())) ))

         // check no foxAlarm

 

Probably this is still too obtuse / introduces theCurrentX which may be
more confusing. 

The example also makes a big assumption that fact retraction can be
easily mapped to/from the underlying data representation.

 

 

Paul Vincent

TIBCO | Business Optimization | Business Rules & CEP

 

 

> -----Original Message-----

> From: public-rif-wg-request@w3.org
[mailto:public-rif-wg-request@w3.org]

> On Behalf Of Christian de Sainte Marie

> Sent: 10 June 2008 18:28

> To: RIF WG

> Subject: [PRD] PRD ready to review

> 

> 

> Adrian, Gary, all,

> 

> I finished updating the draft of PRD (except for the "compatibility
with

> BLD" appendix): as far as I am concerned, you can start reviewing the

> changes in http://www.w3.org/2005/rules/wiki/PRD.

> 

> I modified section 1 (Overview) quite a lot, to make it more palatable

> for the outside reader (hopefully).

> 

> In section 2 (Syntax), I mostly updated the syntax, to align it with

> BLD. I also removed all the editor notes that were for internal use,
and

> added some to ask for feedback or to warn about the syntax being still

> in flux.

> 

> Re the action part, I left only Assert, Retract and Execute: we

> discussed removing Execute, but it is used in the running example, and

> it is quite typical of production rules, so I decided unilaterally to

> leave it in. Also, I removed the 'Assert'+'target' wrapper around the

> 'Atom' or 'Frame' to be asserted, with an editor note asking for
feedback.

> 

> Re nested 'Forall' and 'pattern', I added an editor note asking for

> feedback, as discussed. And I removed the Ruleset construct, pointing
to

> the Group construct instead (and added an editor note asking for

> feedback :-)

> 

> Finally, I added a subsection for Document, Groups and metadata.

> 

> In section 3, the diff will show a lots of differences, so you should

> probably not care about it and read the new text directly.

> 

> Beside removing internal-purpose editor notes, I added an editor note
re

> the semantics of actions (3.3), as discussed, and I corrected and

> simplified the semantics of Rulesets (3.4), and I added textual

> explanations.

> 

> Regarding the specification of PICK, it was not much easier to specify

> the "no-repeat"+"random" default than to go a bit farther (as I had to

> go a bit farther to understand how to do it properly, anyway), so I

> included the more complete specification. I stopped short of
specifying

> the "priority", "recency" and "all at once" strategies completely,

> because they do not make sense if the syntax does not provide a way to

> indicate that they are intended, and this is something that we did not

> discuss.

> 

> Here again, I added an editor note asking for feedback, as discussed.

> 

> And I added a default specification for FINAL, with an editor note

> asking for feedback, as we discussed.

> 

> What remains to be done (before publication; that is, assuming you do

> not require anymore changes :-):

> - add the links and the references. I will do that by next week;

> - raise the issues that are mentioned in editor notes (and add the
ones

> that are raised by those of your comments that are not addressed in
the

> new version, as well as some that were raised in internal-purpose
editor

> notes that I commented out). I will do that by next week, at least for

> the ones that are mentioned in the doc;

> - Finalize the compatibility with BLD section. I have most of it done,

> but I must check it wrt to the changes I made when aligning the
syntax.

> I should be able to have a version that is consistent with this
version

> of the draft by Friday night;

> - The UML-like diagram. I have the one that corresopnds to the
previous

> version of the draft, so it should not take me more than 10mn. But I

> will do that last...

> 

> Cheers,

> 

> Christian

> 

 
Received on Thursday, 19 June 2008 20:34:25 GMT

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