The appropriate transformation looks like this:

(defrule foo
 (or (A) (B))
 (C)
 (or (D) (E))
  =>
 )

  ---\
  ---/

(defrule foo-1  (defrule foo-2
  (A)             (A)
  (C)             (C)
  (D)             (E) 
  =>              =>
  )               )
  
(defrule foo-3  (defrule foo-4
  (B)             (B)
  (C)             (C)
  (D)             (E) 
  =>              =>
  )               )
  

This is not too terribly difficult to carry out mechanically. The four
left-hand-sides of these rules will together constitute the most
efficient possible translation of the LHS of the original rule. Jess
will recombine the LHS using the normal Rete-network sharing
mechanisms such that no nonessential duplicate work will be done. No
extra facts or machinery are needed.

Of course, a full implementation (of the sort that Jess will hopefully
soon include) has to include (and) and (not) CEs arbitrarily nesting
inside (or)s, which are somewhat harder. The one downside of this
approach is that there are four separate rule RHS, andthis will show
up in trace information, etc. When Jess gets ORs, this, too, will be
overcome. 

But anyway, for the simple kind of case shown above, the
transofmration can eb done textually on the rues, and it's not too bad.




I think Blaine Bell wrote:
> It is my understanding (correct me if I am wrong), it is not possible to
> define a rule in which the LHS is a combination of facts ORed together.
> It is quite easy to write functions for this problem, however, writing
> functions on the LHS can produce performance problems.  One of our
> proposed solutions is to generate multiple rules, one for each
> sub-expression that is ORed together.  These sub-expression rules will
> assert a "sub-expression" fact that will be checked for by a rule that
> has the RHS for the complete expression.  This is fine, and it performs
> better, except I do believe that I am trying to re-invent the wheel.
> Because multiple rules have similar sub-expressions, in order to perform
> better, I would need to recognize these similarities, and combine them
> with each other to form sub-expressions so that they do not get
> evaluated multiple times.  This is exactly what JESS is suppose to do,
> right?  My question is: is there a better way to do this in JESS?
> 
> Thanks in advance..
> 
> Blaine
> 
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list (use your own address!) List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> 



---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to