next up previous

5.4.4 And Conditional Element

CLIPS assumes that all rules have an implicit and conditional element surrounding the conditional elements on the LHS. This means that all conditional elements on the LHS must be satisfied before the rule can be activated. An explicit and conditional element is provided to allow the mixing of and CEs and or CEs. This allows other types of conditional elements to be grouped together within or and not CEs. The and CE is satisfied if all of the CEs inside of the explicit and CE are satisfied. If all other LHS conditions are true, the rule will be activated. Any number of conditional elements may be placed within an and CE.

Syntax

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

Example

(defrule system-flow
   (error-status confirmed)
   (or (and (temp high)
            (valve closed))
       (and (temp low)
            (valve open)))
   =>
   (printout t "The system is having a flow problem." crlf))

An and CE that has a test or not CE as its first CE has the pattern (initialfact) or (initialobject) added as the first CE. Note that the LHS of any rule is enclosed within an implied and CE. For example, the following rule

(defrule nothing-to-schedule
  (not (schedule ?))
  =>
  (printout t "Nothing to schedule." crlf))

is converted to

(defrule nothing-to-schedule
  (and (initial-fact)
       (not (schedule ?)))
  =>
  (printout t "Nothing to schedule." crlf))


next up previous