;;;====================================================== ;;; Family Tree ;;; ;;; Describes extended family relationships ;;; (sister, brother, grandparent, grandmother, grandfather, etc.) ;;; ;;; ;;; ;;; ;;; CLIPS Version 6.0 Example ;;; ;;; To execute: Load, reset and run. ;;; Some modifications by Franz Kurfess: ;;; - additional deftemplates ;;; - family facts ;;;====================================================== ;;;************* ;;;* 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