嗨我已经创建了一个剪辑程序,在我的defrule否定中,我正在模拟命题法,并希望程序接受任何符号,而不仅仅是P符号。无论那里的符号如何,我都希望无法开除。
我试过把?符号代替P但是还没有解决我的问题。
(deftemplate andprop (slot symbol1)(slot symbol2))
(deftemplate orprop (slot symbol1)(slot symbol2))
(deftemplate implies (multislot premise)(multislot implication))
(deftemplate sentence (multislot sent))
(defrule read-from-user
=>
(printout t "Please enter a sentence: Use ~ for not and => for implies please " crlf)
(bind ?response (readline))
(assert (sentence(sent ?response))))
(defrule negative
(sentence(sent "~(~P)"))
=>
(printout t "HI " crlf))
因此,无论符号中的符号如何,只要符号为P,我希望触发否定符号
我建议使用explode $函数将句子拆分为单独的标记。
CLIPS (6.31 2/3/18)
CLIPS>
(deftemplate andprop
(slot symbol1)
(slot symbol2))
CLIPS>
(deftemplate orprop
(slot symbol1)
(slot symbol2))
CLIPS>
(deftemplate implies
(multislot premise)
(multislot implication))
CLIPS>
(deftemplate sentence
(multislot sent))
CLIPS>
(defrule read-from-user
=>
(printout t "Please enter a sentence: Use ~ for not and => for implies please " crlf)
(bind ?response (readline))
(assert (sentence (sent (explode$ ?response)))))
CLIPS>
(defrule negative
(sentence (sent "~" "(" "~" ?symbol ")"))
=>
(printout t "HI " ?symbol crlf))
CLIPS> (run)
Please enter a sentence: Use ~ for not and => for implies please
~(~P)
HI P
CLIPS> (reset)
CLIPS> (run)
Please enter a sentence: Use ~ for not and => for implies please
~(~XYZ)
HI XYZ
CLIPS> (facts)
f-0 (initial-fact)
f-1 (sentence (sent "~" "(" "~" XYZ ")"))
For a total of 2 facts.
CLIPS>