Lecture 13: Some simple proofs I did in the class. Def app: (app x y) = (if (endp x) y (cons (car x) (app (cdr x) y))) Question 189: (app a b) = (app b a) This is not a theorem. A counterexample is a = 12 and b = nil. (app a b) = (app 12 nil) = nil (app b a) = (app nil 12) = 12 --- Proof: I'll simplify the lhs and then the rhs. lhs = (app a b) = {def app} (if (endp a) b (cons (car a) (app (cdr a) b))) rhs = (if (endp b) a (cons (car b) (app (cdr b) a))) Case 1 (endp a) <--> t lhs = b rhs = (if (endp b) a (cons (car b) (app (cdr b) a))) Case 1.1 (endp b) <--> t lhs = b rhs = a ??? Ah ha! A counterexample is one where a and b are both endp and different. So let a = 12 and b = nil. ================================================================= Lemma endp-nil: (endp nil) = t Proof: (endp nil) = {def endp} (not (consp nil) = {comp, twice} t Q.E.D. Lemma if-t: (if t x y) = x Question 190: (app nil b) = b Proof: (app nil b) = {def app} (if (endp nil) b (cons (car nil) (app (cdr nil) b))) = {endp-nil} (if t b (cons (car nil) (app (cdr nil) b))) = {if-t} b Q.E.D. ================================================================= Question 199: (R & Q) --> (Q --> R) Proof: (R & Q) --> (Q --> R) <--> {hyp R} (R & Q) --> (Q --> T) <--> {short circuit} (R & Q) --> T <--> {short circuit} T Q.E.D. ================================================================= Question 200: (A --> B) v (B --> A) Proof: (A --> B) v (B --> A) <--> {implicative disjunction, twice} (!A v B) v (!B v A) <--> {assoc} !A v (B v (!B v A)) <--> {commut, twice} !A v ((A v !B) v B) <--> (!A v A) v (!B v B) <--> {basic} T v (!B v B) <--> {short circuit} T Q.E.D. New Theorem: (A --> B) v (C --> A) ================================================================= Lemma p-and-not-p (P & !P) <--> NIL Proof: (P & !P) <--> {DeMorgan, Double Negation} !(!P v P) <--> {basic} !T {comp} <--> NIL Q.E.D. Question 201: (R --> !P) --> ((P & R) --> S) Proof: (R --> !P) --> ((P & R) --> S) <--> {Promotion} (R --> !P) & (P & R) --> S <--> {assoc} (R --> !P) & P & R --> S <--> {Hyp R} (T --> !P) & P & R --> S <--> {short circuit} (!P & P & R) --> S <--> {p-and-not-p} (NIL & R) --> S <--> {short circuit} NIL --> S <--> {short circuit} T Q.E.D. ================================================================= Question: (P a) & (a = b) --> (P b) Proof: (P a) & (a = b) --> (P b) <--> {Hyp a=b} (P a) & (a = b) --> (P a) <--> {basic: x & y --> x} T Q.E.D. ================================================================= Question: (P a) & (a = b) --> (Q b) Proof: (P a) & (a = b) --> (Q b) <--> {hyp a=b} (P a) & (a = b) --> (Q a) ??? Ah ha! If I don't know anything else about P and Q, then this isn't a theorem. For example, suppose (defun P (x) t) (defun Q (x) nil) a = 1 and b = 1. Thus, (P a) & (a = b) --> (Q b) <--> (P 1) & (1 = 1) --> (Q 1) <--> (P 1) --> (Q 1) <--> {comp} T --> NIL <--> {comp} NIL ================================================================= Question: Suppose it is a theorem that T1: (f x) = x Is the following a theorem? (P a) --> (P (f a)) Proof: (P a) --> (P (f a)) <--> {Rewrite T1} (P a) --> (P a) <--> {basic} T Q.E.D. ================================================================= Question: Suppose it is a theorem that T1: (P x) --> (f x) = x let sigma={x <-- a}, relieve the hyp (P a), check the equivalence Is the following a theorem? (P a) --> (P (f a)) Proof: (P a) --> (P (f a)) <--> {Rewrite T1} (P a) --> (P a) ... [the rest is obvious given the proof above.] =================================================================