Экспертная система генеалогического дерева CLIPS - PullRequest
1 голос
/ 26 сентября 2019

Я пытаюсь создать программу 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))

Напишите правила, которые определяют следующие отношения.Опишите шаблоны, которые вы используете для решения проблемы.a) Дядя, тетя b) Двоюродный брат c) Дедушка и бабушка d) Дедушка, бабушка e) Сестра, надоедающая Запустите экспертную систему для вашего собственного генеалогического древа.

Я посмотрел похожие примеры и попытался сделать что-то похожее, но яЯ все еще пытаюсь понять, что мне нужно сделать

1 Ответ

0 голосов
/ 26 сентября 2019

Вот как вы можете сделать это для определения сестры:

         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> 
...