Mathematics for Computer Science Structural Induction MIT 6.042J/18.062J To prove P(x) holds for all x in Structural recursively defined set R, prove • P(b) for each base case b ∈ R Induction • P(c(x)) for each constructor, c, assuming ind. hyp. P(x) lec 5M.1 Albert R Meyer, February 29, 2012 Albert R Meyer, February 29, 2012 7W.2 E ⊆ Even Matched Paren Strings M by structural induction Lemma: Every s in M has the on x ∈ E with ind. hyp. same number of ] ’s and [ ’s. “x is even” Proof by structural induction • 0 is even on the definition of M • if n is even, then so is n+2, -n Albert R Meyer, February 29, 2012 lec 5M.3 Albert R Meyer, February 29, 2012 lec 5M.4 1
Matched Paren Strings M Structural Induction on M Proof: Lemma: Every s in M has the Ind. Hyp. P(s) ::= (s ∈ EQ) same number of ] ’s and [ ’s. Base case (s = λ ): Let EQ ::= {strings with same λ has 0 ] ’s and 0 [ ’s, number of ] and [ } so P( λ ) is true. Lemma (restated): M ⊆ EQ base case is OK lec 5M.5 lec 5M.6 Albert R Meyer, February 29, 2012 Albert R Meyer, February 29, 2012 Structural Induction on M Structural Induction on M Constructor step: s = [ r ] t so by struct. induct. can assume P(r) and P(t) M ⊆ EQ # ] in s = # ] in r + # ] in t + 1 # [ in s = # [ in r + # [ in t + 1 QED = by P(r) = by P(t) so = so P(s) is true constrct case is OK Albert R Meyer, February 29, 2012 lec 5M.7 Albert R Meyer, February 29, 2012 lec 5M.8 2
The 18.01 Functions, F18 Lemma. F18 is closed under taking derivatives: if f ∈ F18, then f´ ∈ F18 Class Problem lec 5M.11 Albert R Meyer, February 29, 2012 3
MIT OpenCourseWare http://ocw.mit.edu 6.042J / 18.062J Mathematics for Computer Science Spring 20 15 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Recommend
More recommend