Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

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)

Albert R Meyer, February 29, 2012 lec 5M.1 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
number of ] and [} λ has 0 ]’s and 0 [’s,
Lemma (restated): M ⊆ EQ so P(λ) is true.
base case is OK
Albert R Meyer, February 29, 2012 lec 5M.5 Albert R Meyer, February 29, 2012 lec 5M.6

Structural Induction on M Structural Induction on M


Constructor step: s = [r]t
can assume P(r) and P(t) so by struct. induct.
#] in s = #] in r + #] in t + 1
#[ in s = #[ in r + #[ in t + 1
M ⊆E Q
so = = by P(r) = by P(t) QED
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
Albert R Meyer, February 29, 2012 lec 5M.11

3
MIT OpenCourseWare
http://ocw.mit.edu

6.042J / 18.062J Mathematics for Computer Science


Spring 2015

For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

You might also like