我可以在事实中进行一次尝试吗?

问题描述 投票:0回答:1
(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 value: " crlf)
(bind ?response (read))
(assert (sentence (sent andprop(symbol1 ?response) 
(symbol2 ?response)))))

我正在编写一个CLIPS程序来模拟命题逻辑标识但是当我尝试运行这段代码时,我得到以下内容

[EXPRNPSR3] Missing function declaration for 'symbol1'.

ERROR:
(defrule MAIN::read-from-user
   =>
   (printout t "Please enter a value: " crlf)
   (bind ?response (read))
   (assert (sentence (sent andprop (symbol1
clips
1个回答
0
投票

您可以将插槽的值设置为另一个事实:

         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 value: " crlf)
   (bind ?response (read))
   (bind ?sent (assert (andprop (symbol1 ?response)
                                (symbol2 ?response))))
   (assert (sentence (sent ?sent))))
CLIPS> (run)
Please enter a value: 
45678
CLIPS> (facts)
f-0     (initial-fact)
f-1     (andprop (symbol1 45678) (symbol2 45678))
f-2     (sentence (sent <Fact-1>))
For a total of 3 facts.
CLIPS> 
© www.soinside.com 2019 - 2024. All rights reserved.