我有一个非常简单的程序,但是从不使用 CLIPS 。 我的任务是显示谁是谁,为谁。 我试图从我的类中重新制作代码,但是它不起作用:
(defrule MAIN::son
(or (father ?x ?y)
(mother ?x ?y)
)
(m ?y)
=>
(assert(son ?y ?x))
(printout t ?y " is son to " ?x crlf)
)
(defrule MAIN::daughter
(or (father ?x ?y)
(mother ?x ?y)
)
(f ?y)
=>
(assert(daughter ?y ?x))
(printout t ?y " is daughter to " ?x crlf)
)
(defrule MAIN::grandfather
(or (father ?x ?y)
(mother ?x ?y)
)
(father ?z ?x)
(m ?z)
=>
(assert(grandfather ?z ?y))
(printout t ?z " is grandfather to " ?y crlf)
)
(defrule MAIN::grandmother
(or (father ?x ?y)
(mother ?x ?y)
)
(mother ?z ?x)
(f ?z)
=>
(assert(grandmother ?z ?y))
(printout t ?z " is grandmother to " ?y crlf)
)
(defrule MAIN::grandson
(or (father ?x ?y)
(mother ?x ?y)
)
(or (father ?y ?z)
(mother ?y ?z)
)
(m ?z)
=>
(assert(grandson ?z ?x))
(printout t ?z " is grandson to " ?x crlf)
)
(defrule MAIN::granddaughter
(or (father ?x ?y)
(mother ?x ?y)
)
(or (father ?y ?z)
(mother ?y ?z)
)
(f ?z)
=>
(assert(grandson ?z ?x))
(printout t ?z " is granddaughter to " ?x crlf)
)
(defrule MAIN::brother
(or (father ?x ?y)
(mother ?x ?y)
)
(or (father ?x ?z)
(mother ?x ?z)
)
(notancestor ?y ?z)
(m ?z)
=>
(assert(brother ?z ?y))
(printout t ?z " is brother "to ?x crlf)
)
(defrule MAIN::sister
(or (father ?x ?y)
(mother ?x ?y)
)
(or (father ?x ?z)
(mother ?x ?z)
)
(notancestor ?y ?z)
(f ?z)
=>
(assert(sister ?z ?y))
(printout t ?z " is sister to " ?x crlf)
)
(defrule MAIN::near_ancestor
(or (father ?x ?y)
(mother ?x ?y)
)
(or (father ?x ?z)
(mother ?x ?z)
)
=>
(assert(near_ancestor ?z ?y))
(printout ?z " is near_ancestor to " ?x crlf)
)
(defrule MAIN::ancestor
(ancestor ?x ?y)
(near_ancestor ?y ?z)
=>
(assert(ancestor ?x ?z))
(printout t ?z " is ancestor to " ?x crlf)
)
(defrule MAIN::near_descendant
(or (father ?x ?y)
(mother ?x ?y)
)
(or (father ?x ?z)
(mother ?x ?z)
)
=>
(assert(near_descendant ?y ?z))
(printout t ?x " is near_descendant to" ?z crlf)
)
(defrule MAIN::descendant
(descendant ?x ?y)
(near_descendant ?y ?z)
=>
(assert(descendant ?z ?x))
(printout t ?x " is descendant to " ?z crlf)
)
我不确定条目数据:
(deffacts startup
(father Adam Kain)
(father Adam Abel)
(father Adam Set)
(mother Ewa Kain)
(mother Ewa Abel)
(mother Ewa Set)
)
我在 CLIPS
中遇到此类错误CLIPS>(运行)
[ROUTER1]逻辑名称集未被任何路由器识别 伊娃是Set的近人
[ROUTER1]路由器不识别逻辑名称Abel 伊娃(Ewa)是亚伯(Abel)的近亲
[ROUTER1]路由器未识别逻辑名称Kain 伊娃是凯恩的近代人
[ROUTER1]逻辑名称集未被任何路由器识别 伊娃是Set的近人
[ROUTER1]逻辑名称集未被任何路由器识别 伊娃是Set的近人
[ROUTER1]路由器不识别逻辑名称Abel 伊娃(Ewa)是亚伯(Abel)的近亲 [ROUTER1]路由器未识别逻辑名称Kain 伊娃是凯恩的近代人
[ROUTER1]路由器不识别逻辑名称Abel 伊娃(Ewa)是亚伯(Abel)的近亲
[ROUTER1]路由器未识别逻辑名称Kain 伊娃是凯恩的近代人
[ROUTER1]逻辑名称集未被任何路由器识别 亚当是Set的近人
[ROUTER1]路由器不识别逻辑名称Abel 亚当是亚伯的近亲
[ROUTER1]路由器未识别逻辑名称Kain 亚当是凯恩的近亲
[ROUTER1]逻辑名称集未被任何路由器识别 亚当是Set的近人
[ROUTER1]逻辑名称集未被任何路由器识别 亚当是Set的近人
[ROUTER1]路由器不识别逻辑名称Abel 亚当是亚伯的近亲
[ROUTER1]路由器未识别逻辑名称Kain 亚当是凯恩的近亲
[ROUTER1]路由器不识别逻辑名称Abel 亚当是亚伯的近亲
[ROUTER1]路由器未识别逻辑名称Kain 亚当是凯恩的近亲
我一直坚持下去。
感谢您的帮助
答案 0 :(得分:0)
代码中的这一行
(printout ?z " is near_ancestor to " ?x crlf)
应该是这个
(printout t ?z " is near_ancestor to " ?x crlf)