Prove by Induction

advertisement
SAMPLE SOLUTIONS, question 8, 1995 to 1998
plus this extra example:
Prove by induction that n, 1 + 2 + 3 + … + n = n( n  1)
2
1(1  1)
1

Base case:
2
Inductive Step:
k (k  1) for some k
Assume: 1  2  3  ...  k 
2
( k  1)(( k  1)  1) for some k
Show: 1  2  3  ...  (k  1) 
2
1  2  3  ...  ( k  1)
 [1  2  3  ...  k ]  ( k  1)
k ( k  1)

 ( k  1)
2
k ( k  1)  2( k  1)

2
( k  1)( k  2)

2
Therefore, the proof is complete.
Final 1995 #8
Proof by Induction that n2-2n > 0 for all n > 2
Base case: n=3, 32-2(3) = 3 > 0
Inductive Step
Assume: k2-2k > 0 for any= k > 2
Show: (k+1)2 – 2(k+1) > 0
LHS = k2 + 2k + 1 – 2k - 2
= k2 – 2k + 2k –1
Since k2-2k > 0 by hypothesis, we need to
prove that 2k-1 >= 0.
Given that k > 2, 2k-1 is obviously > 0.
Therefore the proof is complete.
Final 1996 #8
Use structural induction on the length of the input list to prove that the length
of the output from the following program is greater than the length of the
input, for all finite lists.
expand [ ] = [3]
expand (x:xs) = expand xs ++ expand xs
Base case: To prove that #(expand [ ]) > #[ ]
LHS = #(expand [ ]) = #[3] = 1
RHS = #[ ] = 0
LHS > RHS Base case proved
Inductive Step
Assume: #(expand (a:as)) > #(a:as)
Show: #(expand (e:a:as)) > #(e:a:as)
LHS => #(expand (e:a:as))
(def. of expand)
=> #(expand (a:as) ++ expand (a:as)) (def. of ++ and #)
=> #(expand (a:as)) + #(expand (a:as))
RHS => #(e:a:as)
(def. of : and #)
=> 1 + #(a:as)
Comparing LHS with RHS:
#(expand (a:as)) > #(a:as) by hypothesis. Therefore we now need only
show that #(expand (a:as)) >= 1 With the help of the base case, we can
see that #(expand with any list, the simplest being [ ]) must be >= 1, as
it is the base case (of length 1) or is made by appending two results of
applying expand . Therefore, the proof is complete.
Final 1997 #8
Use structural induction on the length of the input list to show that the length
of the output is greater than the length of the input. That is, show that
#p8 n > #n, for p8 defined as follows:
p8 [ ] = [3]
p8 (x:xs) = x : (p8 xs)
Base case: To prove #(p8 [ ]) > #[ ]
LHS => #(p8 [ ]) => #[3] => 1
RHS => #[ ] => 0
Therefore, #(p8 [ ]) > #[ ] Base case proved.
Inductive Step
Assume for some list a that: #(p8 a) > #(a)
Show #(p8 (e:a)) > #(e:a)
LHS => #(p8 (e:a))
=> #(e : p8 a)
=> 1 + #(p8 a)
RHS => #(e:a)
=> 1 + #(a)
(def. of p8)
(def. of : and #)
(def. of : and #)
Since #(p8 a) > #(a) by hypothesis, we can conclude that
LHS > RHS and the proof is complete.
Final 1998 #8
Consider the following program
p[]
y=[]
p (x:xs) y = y : p xs y, if y > x
= x : p xs y, otherwise
Prove by induction on the length of the first input that the length of the
output is equal to the length of the first input. That is, prove that #(p m n) =
#m for all finite lists.
Base case: To show #(p [ ] y) = #[ ]
LHS => #(p [ ] y)
= #[ ]
=> 0
RHS = #[ ]
=> 0
Inductive Step
Assume for some list a that: #(p a y) = #a
Show: #(p (e:a) y) = #(e:a)
LHS => #(p (e:a) y)
Case 1: (y>e)
Case 2: (y <= e)
=> #(y : p a y) (def. of p)
=> #(e : p a y) (def. of p)
=> 1 + #(p a y) (by hypothesis)
=> 1 + #(p a y) (by hypothesis)
=> 1 + #a
=> 1 + #a
RHS => #(e:a)
=> 1 + #a
=> LHS
Therefore, the proof is complete.
Download