;;;====================================================== ;;; Zoo - forward chaining ;;; ;;; ;;; CLIPS Version 6.0 Example ;;; ;;; To execute, merely load this and one of the zoosimplefwstart_.clp files, reset and run. ;;;====================================================== (defrule mammal1 (hair) => (assert (catg mammal)) ) (defrule mammal2 (nurses) => (assert (catg mammal)) ) (defrule bird1 (feathers) => (assert (catg bird)) ) (defrule bird2 (flies) (birth lays-eggs) => (assert (catg bird)) ) (defrule carnivore1 (eats meat) => (assert (carnivore)) ) (defrule carnivore2 (catg mammal) (pointedTeeth) (claws) (eyes forward-pointing) => (assert (carnivore)) ) (defrule ungulate1 (catg mammal) (hoofs) => (assert (ungulate)) ) (defrule ungulate2 (catg mammal) (chews cud) => (assert (ungulate) (toes even) ) ) (defrule cheetah (catg mammal) (carnivore) (color tawny) (spots dark) => (assert (answer cheetah)) ) (defrule tiger (catg mammal) (carnivore) (color tawny) (stripes black) => (assert (answer tiger)) ) (defrule giraffe (ungulate) (neck long) (legs long) (spots dark) => (assert (answer giraffe)) ) (defrule zebra (ungulate) (stripes black) => (assert (answer zebra)) ) (defrule ostrich (catg bird) (flies no) (legs long) (neck long) (color black white) => (assert (answer ostrich)) ) (defrule penguin (catg bird) (flies no) (swims) (color black white) => (assert (answer penguin)) ) (defrule albatross (catg bird) (flies well) => (assert (answer albatross)) ) (defrule lion (catg mammal) (carnivore) (color tawny) (mane) => (assert (answer lion)) ) (defrule cow (ungulate) (sound moo) => (assert (answer cow)) ) ;;; display result (defrule print-answer (answer ?answ) => (printout t t t "The animal is a " ?answ t t t) )