У меня есть скрипт CLIPS ниже.Я пытаюсь получить значения p1, p2, p3
Последнее правило get-p2-2
должно быть активировано, если p2
неизвестно и p3
известно.
(defrule main
(initial-fact)
=>
(assert(fact (read))) ; user enters 1
(assert(p1 unknown))
(assert(p2 unknown))
(assert(p3 unknown))
)
;;;=====================================================
(defrule get-p1
(fact 1)
(p1 unknown)
=>
(printout t"p1 known"crlf)
(assert (p1 known)))
;;;======================================================
(defrule get-p2
(fact 1)
(p1 known)
(p2 unknown)
=>
(printout t "p2 known"crlf)
(assert (p2 known))
(assert (fact 2)))
;;;======================================================
(defrule get-p3
(fact 2)
(p3 unknown)
=>
(printout t"p3 known"crlf)
(assert (p3 known)))
;;;======================================================
(defrule get-p2-2
(fact 2)
(p2 unknown)
(p3 known)
=>
(printout t "p2 known"crlf)
(assert (p2 known)))
Но p2
становится известным в правиле get-p2
.Таким образом, правило get-p2-2
никогда не должно было активироваться.Но он активируется, и я получаю вывод
p1 known
p2 known
p3 known
p2 known ; this should not be here
Почему get-p2-2
активирован?