CLIPS 谁是儿子或女儿、父亲或母亲、祖父或祖母
CLIPS who is son or daughter, father or mother, grandfather or grandmother
我有一个非常简单的程序,但从未使用过 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> (run)
[ROUTER1] Logical name Set was not recognized by any routers
Ewa is near_descendant to Set
[ROUTER1] Logical name Abel was not recognized by any routers
Ewa is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers
Ewa is near_descendant to Kain
[ROUTER1] Logical name Set was not recognized by any routers
Ewa is near_descendant to Set
[ROUTER1] Logical name Set was not recognized by any routers
Ewa is near_descendant to Set
[ROUTER1] Logical name Abel was not recognized by any routers
Ewa is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers
Ewa is near_descendant to Kain
[ROUTER1] Logical name Abel was not recognized by any routers
Ewa is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers
Ewa is near_descendant to Kain
[ROUTER1] Logical name Set was not recognized by any routers
Adam is near_descendant to Set
[ROUTER1] Logical name Abel was not recognized by any routers
Adam is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers
Adam is near_descendant to Kain
[ROUTER1] Logical name Set was not recognized by any routers
Adam is near_descendant to Set
[ROUTER1] Logical name Set was not recognized by any routers
Adam is near_descendant to Set
[ROUTER1] Logical name Abel was not recognized by any routers
Adam is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers
Adam is near_descendant to Kain
[ROUTER1] Logical name Abel was not recognized by any routers
Adam is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers
Adam is near_descendant to Kain
我一直坚持下去。
我将不胜感激任何帮助
你代码中的这一行
(printout ?z " is near_ancestor to " ?x crlf)
应该是这个
(printout t ?z " is near_ancestor to " ?x crlf)
我有一个非常简单的程序,但从未使用过 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> (run)
[ROUTER1] Logical name Set was not recognized by any routers Ewa is near_descendant to Set
[ROUTER1] Logical name Abel was not recognized by any routers Ewa is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers Ewa is near_descendant to Kain
[ROUTER1] Logical name Set was not recognized by any routers Ewa is near_descendant to Set
[ROUTER1] Logical name Set was not recognized by any routers Ewa is near_descendant to Set
[ROUTER1] Logical name Abel was not recognized by any routers Ewa is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers Ewa is near_descendant to Kain
[ROUTER1] Logical name Abel was not recognized by any routers Ewa is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers Ewa is near_descendant to Kain
[ROUTER1] Logical name Set was not recognized by any routers Adam is near_descendant to Set
[ROUTER1] Logical name Abel was not recognized by any routers Adam is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers Adam is near_descendant to Kain
[ROUTER1] Logical name Set was not recognized by any routers Adam is near_descendant to Set
[ROUTER1] Logical name Set was not recognized by any routers Adam is near_descendant to Set
[ROUTER1] Logical name Abel was not recognized by any routers Adam is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers Adam is near_descendant to Kain
[ROUTER1] Logical name Abel was not recognized by any routers Adam is near_descendant to Abel
[ROUTER1] Logical name Kain was not recognized by any routers Adam is near_descendant to Kain
我一直坚持下去。
我将不胜感激任何帮助
你代码中的这一行
(printout ?z " is near_ancestor to " ?x crlf)
应该是这个
(printout t ?z " is near_ancestor to " ?x crlf)