In today's class I proved several theorems. Here I only recount one of them. The definitions are (defun mem (e x) (if (endp x) nil (if (equal e (car x)) t (mem e (cdr x))))) (defun nth (i x) (if (zp i) (car x) (nth (- i 1) (cdr x)))) Theorem: (mem e x) --> (exists i : (natp i) & (< i (len x)) & (nth i x)e) Proof: Use Exists-concl and replace i by (index e x), where: (defun index (e x) (if (endp x) 0 (if (equal e (car x)) 0 (+ 1 (index e (cdr x)))))) Thus, our goal is (mem e x) --> (natp (index e x)) & (< (index e x) (len x)) & (nth (index e x) x)e We clearly need to prove three things: (a) (mem e x) --> (natp (index e x)) & (< (index e x) (len x)) & (nth (index e x) x)e) (b) (mem e x) --> (< (index e x) (len x)) (c) (mem e x) --> (nth (index e x) x)e I will prove just (c). (mem e x) --> (nth (index e x) x)e Induct on x. Base Case: (endp x) --> (mem e x) --> (nth (index e x) x)e which is trivial because (mem e x) is false. Induction Step: ~(endp x) & ((mem e (cdr x)) --> (nth (index e (cdr x)) (cdr x))e) --> (mem e x) --> (nth (index e x) x)e By promotion we get ~(endp x) & ((mem e (cdr x)) --> (nth (index e (cdr x)) (cdr x))e) & (mem e x) --> (nth (index e x) x)e Expanding (mem e x): ~(endp x) & ((mem e (cdr x)) --> (nth (index e (cdr x)) (cdr x))e) & (e(car x) | (mem e (cdr x))) --> (nth (index e x) x)e We consider two cases: Case 1: e(car x). The formula we are proving is ~(endp x) & ((mem e (cdr x)) --> (nth (index e (cdr x)) (cdr x))e) & e(car x) --> (nth (index e x) x)e But expanding (index e x) gives 0 hyps 1 and 3; and (nth 0 x) is (car x), which is e by the last hyp. Case 2: e!(car x) & (mem e (cdr x)): The formula we are proving is ~(endp x) & ((mem e (cdr x)) --> (nth (index e (cdr x)) (cdr x))e) & e!(car x) & (mem e (cdr x)) --> (nth (index e x) x)e But now we can forward chain from hyp 4 into hyp 2 to get: ~(endp x) & (nth (index e (cdr x)) (cdr x))e & e!(car x) & (mem e (cdr x)) --> (nth (index e x) x)e Then, expanding (index e x) under hyps 1 and 3, and then expanding the containing nth and using arithmetic we get ~(endp x) & (nth (index e (cdr x)) (cdr x))e & e!(car x) & (mem e (cdr x)) --> (nth (index e (cdr x)) (cdr x))e Which is a tautology. Q.E.D.