(set! *PROLOG-CLAUSES* nil) ; Small family tree (assertz '(parent PHILIP CHARLES)) (assertz '(parent ELIZABETH CHARLES)) (assertz '(parent CHARLES WILLIAM)) ; Recursive definition of ancestor. (assertz '(ancestor (*VAR* X) (*VAR* X))) (assertz '(<- (ancestor (*VAR* X) (*VAR* Y)) (parent (*VAR* X) (*VAR* Z)) (ancestor (*VAR* Z) (*VAR* Y)))) ; Arithmetic on unary numerals (that is, numbers in the form ; (s (s (s (s 0)))) (= 4) (assertz '(plus 0 (*VAR* M) (*VAR* M))) (assertz '(<- (plus (s (*VAR* M)) (*VAR* A) (s (*VAR* B))) (plus (*VAR* M) (*VAR* A) (*VAR* B)))) (assertz '(times 0 (*VAR* M) 0)) (assertz '(<- (times (s (*VAR* A)) (*VAR* B) (*VAR* C)) (times (*VAR* A) (*VAR* B) (*VAR* D)) (plus (*VAR* D) (*VAR* B) (*VAR* C)))) ; Sample queries ; (query '(parent elizabeth (*VAR* X))) ; (query '(ancestor elizabeth william)) ; (query '(plus (s (s 0)) (s (s 0)) (*VAR* M)))) ; (query '(times (s (s 0)) (s (s 0)) (*VAR* P)))) ; (query '(plus (*VAR* A) (s (s 0)) (s (s (s (s 0)))))) ; (query '(times (*VAR* F) (s (s 0)) (s (s (s (s 0))))))