CLIPS 缺少模板的函数声明

CLIPS missing function declaration for template

我正在尝试编写一个程序,要求用户提供今天生日的人的姓名以更新他的年龄,但我收到此错误(缺少数据函数声明。)

(deftemplate data 
(slot name) (slot height) (slot weight) (slot age) (multislot blood-pressure))

(deffacts s1
(data (name Anna) (height 160) (weight 56) (age 21) (blood-pressure 12 8))
(data (name Jack) (height 180) (weight 82) (age 38) (blood-pressure 19 10))
)

(deffunction ask-q (?question)
    (printout t ?question)
    (bind ?answer (read))
    ?answer
)
(defrule r1
    (not (starter-state ?))
    =>(bind ?answer (ask-q "whose birthday is today?"))
    if (lexemep ?answer)
    then ?num <-(data (name ?answer)(age ?age)))
    (modify ?fact-number (age(+ ?age 1)))
)

模式在规则中排在第一位,然后是操作。您不能将模式置于规则的操作中。创建一个单独的规则来处理规则 r1 创建的信息。

         CLIPS (6.31 6/12/19)
CLIPS> 
(deftemplate data 
   (slot name)
   (slot height)
   (slot weight)
   (slot age)
   (multislot blood-pressure))
CLIPS> 
(deffacts s1
   (data (name Anna) (height 160) (weight 56) (age 21) (blood-pressure 12 8))
   (data (name Jack) (height 180) (weight 82) (age 38) (blood-pressure 19 10)))
CLIPS> 
(deffunction ask-q (?question)
   (printout t ?question " ")
   (read))
CLIPS>     
(defrule r1
   =>
   (assert (birthday (ask-q "Whose birthday is today?"))))
CLIPS> 
(defrule r2
   ?b <- (birthday ?name)
   ?num <- (data (name ?name) (age ?age))
   =>
   (retract ?b)
   (modify ?num (age (+ ?age 1))))
CLIPS> (reset)
CLIPS> (run)
Whose birthday is today? Anna
CLIPS> (facts)
f-0     (initial-fact)
f-2     (data (name Jack) (height 180) (weight 82) (age 38) (blood-pressure 19 10))
f-4     (data (name Anna) (height 160) (weight 56) (age 22) (blood-pressure 12 8))
For a total of 3 facts.
CLIPS> (reset)
CLIPS> (run)
Whose birthday is today? Jack
CLIPS> (facts)
f-0     (initial-fact)
f-1     (data (name Anna) (height 160) (weight 56) (age 21) (blood-pressure 12 8))
f-4     (data (name Jack) (height 180) (weight 82) (age 39) (blood-pressure 19 10))
For a total of 3 facts.
CLIPS>