;; ;; assign-2-lisp.txt ;; ;; Modify the theorem prover defined in theorem-prover-1.txt ;; so it will handle all of the cases supported by dbaseIII as ;; detailed and tested by (first-test dbaseIII) ;; ;; dbaseIII is the database for the assignment -- the only ;; necessary relations are MALE, FEMALE, SON, DAUGHTER, and HUSBAND ;; the relations WIFE, SPOUSE, PARENT, CHILD should be inferred ;; ;; Turn in: ;; 1. a listing of your code (as efficient as possible, with comments) ;; 2. a listing of a successful execution of "first-test" ;; 3. a listing of dbaseIII ;; ;; Hint ;; 1. the key to the assignment is to modify theorem-prover-1 ;; so it will handle complex consequent theorems with ;; logically conjoined or disjoined goals ;; ;; Sample Output (yours should be quite similar) ;; (load "lisp/theorem-prover-1.txt") ;; Loading file lisp\theorem-prover-1.txt . ;; Loaded file lisp\theorem-prover-1.txt ;; T ; (load "lisp/assign-2-lisp.txt") ;; Loading file lisp\assign-2-lisp.txt ... ;; Loaded file lisp\assign-2-lisp.txt ;; T ;; (first-test dbaseIII) ;; PROVING: Daniel is MALE ;; TRUE: DANIEL is MALE ;; END OF PROOF ;; ;; PROVING: Eileen is MALE ;; CANNOT PROVE: EILEEN is MALE ;; END OF PROOF ;; ;; PROVING: Daniel is the HUSBAND of Eileen ;; TRUE: DANIEL is the HUSBAND of EILEEN ;; END OF PROOF ;; ;; etc.... ;; (setq dbaseIII '( ; first generation members (MALE Daniel) (FEMALE Eileen) ; second generation members (MALE John) (FEMALE Mary) (MALE Christopher) (FEMALE Clare) ; third generation members (FEMALE Jane) (MALE Fred) (FEMALE Margaret) (FEMALE Violet) (MALE Patrick) ; fourth generation members (MALE Tom) (FEMALE Penny) (MALE Billy) ; first generation relations (HUSBAND Daniel Eileen) ; second generation relations (HUSBAND John Mary) (DAUGHTER Mary Daniel) (DAUGHTER Mary Eileen) (SON Christopher Daniel) (SON Christopher Eileen) (DAUGHTER Clare Daniel) (DAUGHTER Clare Eileen) ; third generation relations (HUSBAND Fred Jane) (HUSBAND Patrick Violet) (SON Fred John) (SON Fred Mary) (DAUGHTER Margaret John) (DAUGHTER Margaret Mary) (DAUGHTER Violet John) (DAUGHTER Violet Mary) ; fourth generation relation (SON Tom Fred) (SON Tom Jane) (DAUGHTER Penny Patrick) (DAUGHTER Penny Violet) (SON Billy Patrick) (SON Billy Violet) ; some example rules (CONSE (WIFE ?x ?y) (GOAL (HUSBAND ?y ?x))) (CONSE (SPOUSE ?x ?y) (GOAL (or (HUSBAND ?x ?y) (WIFE ?x ?y)))) (CONSE (PARENT ?x ?y) (GOAL (or (SON ?y ?x) (DAUGHTER ?y ?x)))) (CONSE (CHILD ?x ?y) (GOAL (or (SON ?x ?y) (DAUGHTER ?x ?y)))) )) ;; the database should pass this test (defun check-db (dbase) (cond ((null dbase) (princ "No Errors Found")(terpri)) ((member (caar dbase) '(MALE FEMALE HUSBAND SON DAUGHTER CONSE)) (check-db (cdr dbase))) (t (princ "Invalid Rule: ")(princ (car dbase))(terpri)) )) ;; the theorem prover should pass this test (defun first-test (dbase-in) (princ "PROVING: Daniel is MALE")(terpri) (prove '(MALE Daniel) dbase-in) (princ "PROVING: Eileen is MALE")(terpri) (prove '(MALE Eileen) dbase-in) (princ "PROVING: Daniel is the HUSBAND of Eileen")(terpri) (prove '(HUSBAND Daniel Eileen) dbase-in) (princ "PROVING: Eileen is the HUSBAND of Daniel")(terpri) (prove '(HUSBAND Eileen Daniel) dbase-in) (princ "PROVING: Eileen is the WIFE of Daniel")(terpri) (prove '(WIFE Eileen Daniel) dbase-in) (princ "PROVING: Daniel is the WIFE of Eileen")(terpri) (prove '(WIFE Daniel Eileen) dbase-in) (princ "PROVING: Daniel is the SPOUSE of Eileen")(terpri) (prove '(SPOUSE Daniel Eileen) dbase-in) (princ "PROVING: Eileen is the SPOUSE of Daniel")(terpri) (prove '(SPOUSE Eileen Daniel) dbase-in) (princ "PROVING: Eileen is the SPOUSE of Billy")(terpri) (prove '(SPOUSE Eileen Billy) dbase-in) (princ "PROVING: Eileen is the PARENT of Christopher")(terpri) (prove '(PARENT Eileen Christopher) dbase-in) (princ "PROVING: Christopher is the PARENT of Eileen")(terpri) (prove '(PARENT Christopher Eileen) dbase-in) (princ "PROVING: Christopher is the CHILD of Eileen")(terpri) (prove '(CHILD Christopher Eileen) dbase-in) (princ "PROVING: Eileen is the CHILD of Christopher")(terpri) (prove '(CHILD Eileen Christopher) dbase-in) )