CPE 481
Knowledge-Based Systems
Winter 2003
CPE 481Knowledge-Based SystemsWinter 2003
Assignment 1
Points
35
Deadline
Jan. 30
Below you find a partial listing for a CLIPS knowledge base
on family relationships. Your task is to complete the rules
so that the following relationships are covered:
mother, father, parent
brother, sister, sibling
uncle, aunt
brother in law, sister in law, mother in law, father in law
grandfather, grandmother, grandparent
great-grandfather, great-grandmother, great-grandparent
ancestor
You do not need to consider more complex relationships that may
arise as a consequence of divorce, adoption, or similar events.
In case of doubt, specify the exact relationship as a comment
in the rule. You may replace or enhance the facts about the persons
(e.g. by using your own or some other family, or cartoon characters).
You must submit the following items:
a diagram of the family tree you're using
a file containing the knowledge base (facts and rules) for the family tree
a file with at least one test run for each of the requested relationships
a README file with instructions for using your program
I will use the following grading guidelines:
6 points for the tree diagram
20 points in total for the correct formulation of the relationships
6 points for the test runs
3 points for the README file and documentation of the source code
;;;======================================================
;;; Family Tree
;;;
;;; Describes extended family relationships
;;; (sister, brother, grandparent, grandmother, grandfather, etc.)
;;;
;;;
;;;
;;;
;;; CLIPS Version 6.0 Example
;;;
;;; To execute: Load, reset and run.
;;;======================================================
;;;*************
;;;* TEMPLATES *
;;;*************
(deftemplate father-of (slot father) (slot child))
(deftemplate mother-of (slot mother) (slot child))
(deftemplate parent-of (slot parent) (slot child))
(deftemplate sister-of (slot sister) (slot sibling))
(deftemplate brother-of (slot brother) (slot sibling))
(deftemplate aunt-of (slot aunt) (slot nephew-or-niece))
(deftemplate uncle-of (slot uncle) (slot nephew-or-niece))
(deftemplate cousin-of (slot cousin-1) (slot cousin-2))
(deftemplate grandfather-of (slot grandfather) (slot grandchild))
(deftemplate grandmother-of (slot grandmother) (slot grandchild))
(deftemplate grandparent-of (slot grandparent) (slot grandchild))
(deftemplate wife-of (slot wife) (slot husband))
(deftemplate husband-of (slot husband) (slot wife))
(deftemplate ancestor-of (slot ancestor)(slot person))
(deftemplate male (slot person))
(deftemplate female (slot person))
;;; more deftemplates as needed
;;;*****************
;;;* INITIAL STATE *
;;;*****************
(deffacts family
(father-of (father "Franz Xaver") (child "Franz Anton"))
(father-of (father "Franz Xaver") (child "Erwin"))
(mother-of (mother "Josefine") (child "Franz Anton"))
(mother-of (mother "Josefine") (child "Erwin"))
(father-of (father "Xaver") (child "Margarethe"))
(father-of (father "Xaver") (child "Anna"))
(mother-of (mother "Maria") (child "Margarethe"))
(mother-of (mother "Maria") (child "Anna"))
(father-of (father "Franz Anton") (child "Franz Josef"))
(father-of (father "Franz Anton") (child "Hubert"))
(father-of (father "Franz Anton") (child "Bernhard"))
(father-of (father "Franz Anton") (child "Heinrich"))
(father-of (father "Franz Anton") (child "Irmgard"))
(mother-of (mother "Margarethe") (child "Franz Josef"))
(mother-of (mother "Margarethe") (child "Hubert"))
(mother-of (mother "Margarethe") (child "Bernhard"))
(mother-of (mother "Margarethe") (child "Heinrich"))
(mother-of (mother "Margarethe") (child "Irmgard"))
(wife-of (wife "Margarethe") (husband "Franz Anton"))
(husband-of (husband "Franz Anton") (wife "Margarethe"))
(father-of (father "Erwin") (child "Josef"))
(father-of (father "Erwin") (child "Klaus"))
(father-of (father "Erwin") (child "Markus"))
(father-of (father "Erwin") (child "Annemarie"))
(father-of (father "Erwin") (child "Regina"))
(father-of (father "Erwin") (child "Roswitha"))
(mother-of (mother "Anna") (child "Josef"))
(mother-of (mother "Anna") (child "Klaus"))
(mother-of (mother "Anna") (child "Markus"))
(mother-of (mother "Anna") (child "Annemarie"))
(mother-of (mother "Anna") (child "Regina"))
(mother-of (mother "Anna") (child "Roswitha"))
(wife-of (wife "Anna") (husband "Erwin"))
(husband-of (husband "Erwin") (wife "Anna"))
(male (person "Franz Anton"))
(male (person "Erwin"))
(male (person "Franz Josef"))
(male (person "Hubert"))
(male (person "Bernhard"))
(male (person "Heinrich"))
(female (person "Margarethe"))
(female (person "Anna"))
(female (person "Irmgard")))
;;; more facts as needed
;;;******************
;;;* RULES *
;;;******************
(defrule mother-is-parent
(mother-of (mother ?mom) (child ?child))
=>
(assert (parent-of (mother ?mom) (child ?child)))
(printout t ?mom " is a parent of " ?child crlf))
;;; more rules as needed
Last modified: Thursday, 16-Jan-2003 14:51:19 PST