CLIPS

 

 

Strategies

 

Deffacts

(Deffacts aname factsinalistofcourseeachsurroundedbyparens )

 

Watches

 

Traces

 

Debugging

 

 

A Step Up – Variables

(defrule houseshape

            (triangle ?tri)

            (square ?sq)

            (supports ?sq ?tri)

            ;;; only matches if there can be found facts in which the square supports the triangle, NOT with the following facts:

(triangle A)

(square B)

(square C)

(supports B C)

(defrule mammal1

     ?f1 <- (hair)

      =>

      (assert (catg mammal))

      (retract ?f1) ; sometimes might want to retract a fact after using it

)

 

(defrule color

            (color black ?)

=>

;;; matches if there is any fact  involving two colors, the first being black

;;; would not match (color black) or (color black white red) but would match

;;; (color black white)

 

 

Another Step Up – Control Facts (an idiom)

 

 

Templates – allow you to define a structure  for facts and rules

 

(Deftemplate  nameoftemplate

        “ optional comment “

            (slot slotname1

                        (type SYMBOL)

                        (default avalue)    )

            (slot slotname2

                        (type SYMBOL)   ;;; or NUMBER or STRING or

                        (default avalue)    )

            …

)