否定的な条件に基づいて事実を削除する方法を探しています。たとえば、次のファクトを作成した後:
CLIPS>
(deffacts Cars
(color red)
(color green)
(color yellow)
(doors three)
(doors five))
CLIPS>
(defrule combinations
(color ?color)
(doors ?doors)
=>
(assert (car ?color ?doors)))
CLIPS> (reset)
CLIPS> (run)
CLIPS> (facts)
f-0 (initial-fact)
f-1 (color red)
f-2 (color green)
f-3 (color yellow)
f-4 (doors three)
f-5 (doors five)
f-6 (car red five)
f-7 (car green five)
f-8 (car yellow five)
f-9 (car red three)
f-10 (car green three)
f-11 (car yellow three)
For a total of 12 facts.
CLIPS>
次のステートメントを使用して、いくつかの事実を削除することを検討しています。
(defrule clear
?q1 <- (car ?color~green five)
=>
(retract ?q1 )
(printout t "Cars cleared " ?q1 crlf)
)
これにより、ドアが 5 つあり、色が緑色ではない車が削除されます。したがって、ID f-6 と f-8 は削除する必要があります。そして、削除された事実を印刷します。
ステートメントでエラーは発生しませんが、実行 (実行) すると、ステートメントが撤回または出力されません。条件が正しくないと推測していますが、そうでなければこの負の条件を記述する方法がわかりません。
ありがとう