3.15 KnowleDge-BaseD system tools 85
The undeffacts statement can be used to eliminate a (deffact) from
memory. Facts may be pulled back in rule actions, but you should attach the
fact address to a variable on the left side of the rule. It is also possible to list
the fact set using
(list-deffacts)or to delete a fact set using (undeffacts
<deffacts-name>).
3.15.1.4 Rules
In order to define a rule, you should use defrule:
CLIPS> (defrulesibling-1 ; rule name
(brother-of ?b1 ?b2) ; condition
=> ; then arrow
(assert (brother-of ?b1 ?b2))) ; action
Here, the expressions ?b1 and ?b2 are variables. You can use the (run)
command to execute rules. Likewise, rules can have multiple conditions and
actions and an optional comment:
(defrule rule-name “optional ...