;file: genealogy.lsp

;purpose: run genealogy problem on inference.lsp

;programmer: Tom Shultz

;started: 16 mar 00

;current: 21 sep 00

 

;(trace prove-simple)

 

(defun genealogy (facts)

  "(facts)

Genealogy example."

  (clrhash *rules*)

  (rule '((father ?x ?y) (and (parent ?x ?y)

                              (male ?x))))

  (rule '((mother ?x ?y) (and (parent ?x ?y)

                              (female ?x))))

  (rule '((paternal-grandfather ?x ?z) (and (father ?x ?y)

                                            (father ?y ?z))))

  (rule '((maternal-grandfather ?x ?z) (and (father ?x ?y)

                                            (mother ?y ?z))))

  (rule '((grandfather ?x ?y)

          (or (paternal-grandfather ?x ?y)

              (maternal-grandfather ?x ?y))))

  (enter-facts facts)

  (with-answer (grandfather ?x ?y)

               (format t "grandfather ~a ~a ~%" ?x ?y)))

 

(genealogy '((parent tom sarah)

             (parent tom daniel)

             (parent richard tom)

             (parent judy sarah)

             (parent judy daniel)

             (parent albert judy)

             (male tom)

             (male richard)

             (male albert)

             (female judy)))