next up previous

5.4.9.2 Test and Not CEs as the First CE of an And CE

Test CEs and not CEs that are the first CE within an and CE have an initialfact or an initialobject pattern added immediately before them. An initialfact pattern is added if the first pattern CE preceding the CE in question is a fact pattern. An initialobject pattern is added if the first pattern CE preceding the CE in question is an object pattern. If there are no preceding pattern CEs, the type of pattern is determined by the succeeding pattern CEs using the same methodology. If there are no pattern CEs in the rule at all, then an initialfact pattern is placed before the CE in question (unless facts have been disabled by configuring CLIPS in which case the initialobject pattern is added before the CE). For example, the following rules

(defrule example-2
   (test (> 80 (startup-value)))
   =>)
(defrule example-3
   (test (> 80 (startup-value)))
   (object (is-a MACHINE))
   =>)
(defrule example-4
   (machine ?x)
   (not (and (not (part ?x ?y))
             (inventoried ?x)))
   =>)

would be changed as follows.

(defrule example-2
   (initial-fact)
   (test (> 80 (startup-value)))
   =>)
(defrule example-3
   (object (is-a INITIAL-OBJECT) (name [initial-object]))
   (test (> 80 (startup-value)))
   (object (is-a MACHINE))
   =>)
(defrule example-4
   (machine ?x)
   (not (and (initial-fact)
             (not (part ?x ?y))
             (inventoried ?x)))
   =>)


next up previous