I want to know how CLIPS works so I thought of taking problems already solved and see how they work. It's this problem which I don't know how to get it to work. The requirements say:

Fires are classified according to the principal burning material. Translate the following information to rules for determining fire class.

  • Type A fires involve ordinary combustibles such as paper, wood, and cloth.
  • Type B fires involve flammable and combustible liquids (such as oil and gas), greases, and similar materials.
  • Type C fires involve energized electrical equipment.
  • Type D fires involve combustible metals such as magnesium, sodium, and potassium.

    The type of extinguisher that should be used on a fire depends on the fire class. Translate the following information to rules.

  • Class A fires should be extinguished with heat-absorbing or combustion-retarding extinguishers such as water or water-based liquids and dry chemicals.

  • Class B fires should be extinguisher by excluding air, inhibiting the release of combustible vapors, or interrupting the combustion chain reaction. Extinguishers include dry chemicals, carbon dioxide, foam, and bromotrifluoromethane.
  • Class C fires should be extinguished with a non conducting agent to prevent short circuits. If possible the power should be cut. Extinguishers include dry chemicals, carbon dioxide, and bromotrifluoromethane.
  • Class D fires should be extinguished with smothering and heat- absorbing chemicals that do not react with the burning metals. Such chemicals include trimethoxyboroxine and screened graphitized coke.

    Describe the facts used in the rules. The input to the program should be made by asserting the type of burning material as a fact. The output should indicate which extinguishers may be used and other actions that should be taken, such as cutting off the power. Show that your program works for one material form each of the fire classes.

The problem was solved by someone at Berkely:

; Define templates used in rules

(deftemplate fire (slot burning-material)) 

(deftemplate extinguisher-system (multislot function) (multislot extinguisher)) 

(deftemplate response (multislot actions)) 

(deftemplate fire-class (slot class))

; Define rules for determining fire classes 

(defrule class-A-fire
(fire (burning-material paper | wood | cloth | other-ordinary-combustibles)) =>
(assert (fire-class (class A))))

(defrule class-B-fire
(fire (burning-material oil | gas | greases | other-flammable-combustible-liquids)) =>
(assert (fire-class (class B))))

(defrule class-C-fire
(fire (burning-material energized-electrical-equipment)) =>
(assert (fire-class (class C))))

(defrule class-D-fire
(fire (burning-material megnesium | sodium | potassium | other-combustible-metals)) =>
(assert (fire-class (class D))))

; Define rules for determining the type of extinguisher that should be used on a fire 

(defrule class-A-emergency
(fire-class (class A))
(assert (response (actions activate-extinguisher-A))) (assert (extinguisher-system (function heat-absorbing combustion-retarding) (extinguisher water water-based-liquids dry-chemicals)))) 

(defrule class-B-emergency
(fire-class (class B))
(assert (response (actions activate-extinguisher-B))) (assert (extinguisher-system (function excluding-air inhibiting-release-of-combustible-vapors interrupting-combustion-chain-reaction) (extinguisher dry-chemicals carbon-dioxide foam bromotrifluoromethane))))

(defrule class-C-emergency
(fire-class (class C))
(assert (response (actions activate-extinguisher-C power-cut))) (assert (extinguisher-system (function nonconducting-agent) (extinguisher dry-chemicals carbon-dioxide bromotrifluoromethoane)))) 

(defrule class-D-emergency
(fire-class (class D))
(assert (response (actions activate-extinguisher-D))) (assert (extinguisher-system (function smothering-heatabsorbing-chemicals) (extinguisher trimethoxyboroxine screened-graphitized-coke))))

How can I make this program display the things they ask?

This question has already been answered. Start a new discussion instead.