next up previous

5.4.3 Or Conditional Element

The or conditional element allows any one of several conditional elements to activate a rule. If any of the conditional elements inside of the or CE is satisfied, then the or CE is satisfied. If all other LHS conditional elements are satisfied, the rule will be activated. Note that a rule will be activated for each conditional element with an or CE that is satisfied (assuming the other conditional elements of the rule are also satisfied). Any number of conditional elements may appear within an or CE. The or CE produces the identical effect of writing several rules with similar LHSís and RHSís.

Syntax

<or-CE> ::= (or <conditional-element>+)

Again, if more than one of the conditional elements in the or CE can be met, the rule will fire multiple times, once for each satisfied combination of conditions.

Example

 (defrule system-fault
   (error-status unknown)
   (or (temp high)
       (valve broken)
       (pump (status off)))
   =>
   (printout t "The system has a fault." crlf))

Note that the above example is exactly equivalent to the following three (separate) rules:

(defrule system-fault
   (error-status unknown)
   (pump (status off))
   =>
   (printout t "The system has a fault." crlf))
(defrule system-fault
   (error-status unknown)
   (valve broken)
   =>
   (printout t "The system has a fault." crlf))
(defrule system-fault
   (error-status unknown)
   (temp high)
   =>
   (printout t "The system has a fault." crlf))


next up previous