Dan Grossman; Graduate Programming Languages; Lecture 2 Proofs Note: It is instructive to write out proofs "live" in class. ========= Theorem: There exist expressions with three constants. Reasonable proof: Consider (1+2)+3 and the definition of expressions. More pedenatic proof: Consider (1+2)+3 and the definition of E. Since E_3 is subset of E, it suffices to show (1+2)+3 is in E_3. By definition of E_3, it suffices to show that (1+2) is in E_2 and 3 is in E_2. To show (1+2) is in E_2, it suffices to show 1 is in E_1 and 2 is in E_1. 1 is in E_1 by definition of E_1 (includes all constants). 2 is in E_1 by definition of E_1 (includes all constants). 3 is in E_2 (includes all constants). ========= Theorem: All expressions contain a constant or variable. Proof #1 (induction on height): By induction on the height of an arbitrary expression e. Base case: Height h = 0 If an expression has height 0, it must be a variable or a constant. Therefore it contains one. Inductive case: Height h > 0 If an expression e has height h > 0, then it is either e1+e2 or e1*e2 for some e1 and e2. In either case, e1 has height at most h-1. So by induction e1 contains a constant or variable. Therefore, e also contains a constant or variable. Proof #2 (structural induction): By induction on the structure of an arbitrary expression e. There are four cases: If e is a variable, then it contains a variable or constant. If e is a constant, then it contains a variable or constant. If e is e1+e2 for some e1 and e2, then by induction e1 contains a variable or constant. Therefore, e also contains a constant or variable. If e is e1*e2 for some e1 and e2, then by induction e1 contains a variable or constant. Therefore, e also contains a constant or variable.