Greetings:

I've been criticized by JM recently for not getting more involved in
Jess solutions.  So, here goes.  The example below violates one of the
basic principles of all rulebased systems.  The logic (i.e., the
Conditional Elements, CE) "should" ALL be in the LHS of the rules.  By
putting IF conditions in the RHS you have put CEs where there should
be nothing but Action Elements, AE.  The one thing that most folks
don't realize is that a rule that states

IF A or B THEN C

is actually two Rules.  IF A THEN C, IF B THEN C

at the same time, an ELSE condition is the negation of the entire LHS
of the rule.  For example

Rule1
IF (A and B and C and D) THEN D

To enter the ELSE you would have

Rule2
IF (A and B and C and D) THEN D ELSE E

which is nothing more than

Rule2a
IF (A and B and C and D) THEN D;
Rule2b
IF !(A and B and C and D) THEN E;

of which the else rule is

Rule2b-1
IF (A or B or C or D) THEN E
which is
Rule2b-1a
IF A THEN E
Rule2b-1b
IF B THEN E
Rule2b-1c
IF C THEN E
Rule2b-1d
IF D THEN E

The OR statements and the ELSE statements are usually handled by the
engine - sometimes called syntatical sugar.  What we need to do is get
back to basics and understand that rules are to solve complex problems
in logic and not used to run through massive sets of numbers looking
for a needle in a haystack - that's something far better handled by
Java, C++, C or even ASM.

Reading through the emails is like reading the old "Obfuscated C"
programs - most of them wondering how complex to make a procedural
problem and thereby justify using a rulebase?  We should be using
procedural languages for procedural problems, not an inference engine.

Jason Morris used to have a blog called "The Zen of Jess" wherein he
basically taught how to use a rulebase.  Not sure why he quit writing
except maybe he just got tired of doing the same thing day after day
after day after...  My suggestion is that everyone should Read The
Fabulous Manual (or the Fabulous Book - JIA) BEFORE beginning to write
the first rule for a practical application or asking questions online!

SDG
jco
"This above all: to thine own self be true,
And it must follow, as the night the day,
Thou canst not then be false to any man."
Hamlet, Act 1, Scene III
http://www-tech.mit.edu/Shakespeare/hamlet/hamlet.1.3.html

On Dec 11, 2008, at 5:03 AM, Joao Antunes Mourao wrote:

(defrule name-of-the-rule
  (put here your conditions for the rule, if any)
=>
(if (condition) then
  (put your things here)
)
(if (condition) then
  (put your things here)
else
  (put your things here)
))

Simple. Good luck.

Joao
-----------
unclassified email

On 10-12-2008 05:47, hansari wrote:
I need rule for

if (condtion1)
then (acton1)
if else (conditon2)
then   (action2)
if else (condition3)
then (action3)
else (acton4)

how can perform this by using defrule please help me.

thank you.


------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify
the sender and delete it. Any unauthorized copying, disclosure or
distribution of this email or its attachment(s) is forbidden. Thales
Nederland BV will not accept liability for any damage caused by this
email or its attachment(s). Thales Nederland BV is seated in Hengelo
and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------

<joao.mourao.vcf>

Reply via email to