clips - 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 (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>
推荐阅读
- python - pytest-html 无法识别的参数 --html
- html - 引导弹出框仅显示一次
- r - 需要从 r 中的不规则曲线中找到一条斜线的斜率
- nunit - 无法在 Allure Reporting 中获取包的结构
- python - 如何使用admitad api获取优惠券数据
- sonarqube - environment.ts 文件中的打字稿安全热点,SonarQube
- c# - 使用 Roslyn 进行运行时编译 - 如何生成 AoT 编译
- php - PHP 脚本总是超过内存限制和最大执行时间 - phpseclib
- c++ - 尝试使用 C++ 读取 CSV 文件出现 invalid_argument 错误
- sql - 如何计算 SQL 中连续时间戳的差异?