首页 > 解决方案 > 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) 姐姐,麻烦运行专家系统为您自己的家谱。

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

标签: clips

解决方案


以下是确定姐妹的方法:

         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> 

推荐阅读