(bind ?answer (读取)) (while (or ( < ?answer ?a1) ( > ?answer ?a2)) do (printout t ?question) (bind ?answer (读取)) ) ?answer) (deffunction yes-or-no-p (?question) (bind ?response (ask-question ?question yes no yn)) (if (or (eq ?response yes) (eq ?response y)) then TRUE else FALSE)) ;;;**************************** ;;;* 启动规则 * ;;;**************************** ;;;;此规则打印横幅消息 (defrule system-banner "" (declare (salience 10)) => (printout t crlf crlf) (printout t " 计算机故障排除专家系统") (printout t crlf crlf)) ;;;;打印最终诊断和建议的规则 (defrule print-diagnosis"" (declare (salience 10)) (recommend ?item2) => (printout t crlf crlf) (printout t " suggestions:" ?item2) (printout t crlf crlf) ) (defrule Q1 "" (not (troublshoot ?)) (not (recommend ?)) (not (Q1 ?)) => (if (yes-or-no-p "Q1:Is there sound problem? ") then (assert (Q1 yes)) else (assert (Q1 no)) ) ) (defrule Q2 "" (not (troublshoot ?)) (not (recommend ?)) (not (Q2 ?)) (Q1 yes) => (if (yes-or-no-p "Q2: Sound Card is not ? ") then (assert (Q2 是))否则(断言(Q2 否))))
主要关键词