CLIPS家族树专家系统

时间:2019-09-26 14:10:24

标签: clips

我正在尝试创建描述家庭关系的CLIPS程序。我完全迷路了,我什至不知道从哪里开始。 考虑到以下对描述家谱的事实的预解。

    (deftemplate father‐of (slot father) (slot child))
    (deftemplate mother‐of (slot mother) (slot child))
    (deftemplate male (slot person))
    (deftemplate female (slot person))
    (deftemplate wife‐of (slot wife) (slot husband))
    (deftemplate husband‐of (slot husband) (slot wife))

编写推断以下关系的规则。描述您用来解决的deftemplates 问题。       a)叔叔阿姨       b)表弟       c)祖父母      d)祖父,祖母      e)姊姊 为您自己的家谱运行专家系统。

我查看了类似的示例并尝试做类似的事情,但我仍在努力理解我需要做的事情

1 个答案:

答案 0 :(得分:0)

这是确定姐姐的方法:

         CLIPS (6.31 6/12/19)
CLIPS> (deftemplate father-of (slot father) (slot child))
CLIPS> (deftemplate mother-of (slot mother) (slot child))
CLIPS> (deftemplate male (slot person))
CLIPS> (deftemplate female (slot person))
CLIPS> 
(deffacts info
   (father-of (father Bill) (child Mary))
   (mother-of (mother Jane) (child Mary))
   (father-of (father Bill) (child John))
   (mother-of (mother Jane) (child John))
   (male (person Bill))
   (male (person John))
   (female (person Jane))
   (female (person Mary)))
CLIPS>    
(defrule sister-of
   (or (male (person ?person))
       (female (person ?person)))
   (female (person ?sister&~?person))
   (father-of (father ?father) (child ?person))
   (father-of (father ?father) (child ?sister))
   (mother-of (mother ?mother) (child ?person))
   (mother-of (mother ?mother) (child ?sister))
   =>
   (printout t ?sister " is the sister of " ?person crlf))
CLIPS> (reset)
CLIPS> (run)
Mary is the sister of John
CLIPS> 
相关问题