(defun !rules () (clrhash *rules*) (<- (female janet)) (<- (male tim)) (<- (male donald)) (<- (male gordon)) (<- (parent tim donald)) (<- (parent janet donald)) (<- (parent gordon donald)) (<- (father ?x ?y) (and (parent ?x ?y) (male ?y))) (<- (= ?x ?x)) (<- (data (emps ((emp tim john) (emp susan jane))))) (<- (person ?x) (or (male ?x) (female ?x))) (<- (sibling ?x ?y) (and (person ?x) (person ?y) (not (= ?x ?y)) (parent ?x ?z) (parent ?y ?z))) (<- (append nil ?xs ?xs)) (<- (append (?x . ?xs) ?ys (?x . ?zs)) (append ?xs ?ys ?zs)) ) (deftest !pl0 () (!rules) (with-answer (data (emps ?base)) (format t "(data ~a)~%" ?base))) (deftest !pl1 () (!rules) (with-answer (father ?x ?y) (format t "~a is the father of ~a. ~%" ?y ?x))) (deftest !pl2() (!rules) (with-answer (sibling ?x ?y) (format t "~a is the sibling of ~a.~%" ?x ?y))) (deftest !pl3 () "shows how our prolog can't do lists" (!rules) (with-answer (append ?x (c d) (a b c d)) (format t "Left: ~A~%" ?x)) (with-answer (append (a b) ?x (a b c d)) (format t "Right: ~A~%" ?x)) (with-answer (append (a b) (c d) ?x) (format t "Whole: ~A~%" ?x)) (with-answer (append ?x ?y (a b c)) (format t "Left: ~A Right: ~A~%" ?x ?y)))