(deftemplate stage (slot value )) (deftemplate mains_light_on (slot value)) (deftemplate boots (slot value)) (deftemplate crashes (slot value)) (defrule start => (assert (stage (value 1))) (printout t "Is the mains light on?") (assert (mains_light_on (value (readline)))) (printout t "Does it boot?") (assert (boots (value (readline)))) (printout t "Does it crash later?") (assert (crashes (value (readline)))) ) (defrule idiot_check (stage (value 1)) (mains_light_on (value "no")) => (printout t "Your problem is that your computer isn't plugged in!" crlf) ) (defrule try_reinstalling (boots (value "yes")) ?cr <- (crashes (value "yes")) ?st <- (stage (value 1)) => (printout t "Try reinstalling the operating system" crlf) (printout t "Now does it crash?") (retract ?st ?cr) (assert (crashes (value (readline)))) (assert (stage (value 2))) ) (defrule dunno (stage (value 2)) (crashes (value "yes")) => (printout t "Take it to a specialist service centre" crlf)) (defrule watch_it (stage (value 2)) (crashes (value "no")) => (printout t "Let's hope you've fixed it. Keep an eye on it." crlf)) (reset) (run)