Continuation of Proofs from Lecture
We finished the induction proofs from Lecture 9: induction on the set of natural numbers, and induction on the length of lists.
More inductive proofs
Here are some more induction proofs to try:
Summation
fun sum(l:int list) : int =
case l of
[] => 0
| x::xs => x + sum(xs)
Use induction on length of list. Proposition:

Towers of Hanoi
fun solve((p as (_,pstack):Towers.peg, q:Towers.peg,
r:Towers.peg):towers):Towers.towers * Towers.move list =
let
fun moveN(from:Towers.peg, to:Towers.peg,
aux:Towers.peg, n:int):Towers.towers * move list =
if n = 0 then ((from, to, aux),[]) else
let
val ((from1, aux1, to1), mlist) =
moveN(from, aux, to, n-1)
val (from2 as(fname,_), to2 as(tname,ts)) =
moveDisc(from1, to1)
val mlist1 = (top ts, fname, tname)::mlist
val ((aux2, to3, from3),mlist2) =
moveN(aux1, to2, from2, n-1)
in
((from3, to3, aux2), mlist2 @ mlist1)
end
val (tresult, moves) = moveN(p, q, r, height pstack)
in
(tresult, rev moves)
end
Use induction on the natural numbers. First, prove a proposition on moveN:
P(n) = For all valid configurations such that
- from contains n or more discs
- to and aux have top discs that are bigger than the n top discs on from
moveN keeps aux unchanged, moves top n discs on from to to, and generates a valid move sequence.
Note that we needed to strengthen both sides of the hypothesis with some extra conditions to push the proof through.
Then, show that the starting configuration satisfies these conditions.
Fallacious induction proofs
P(n) = Everyone in a group of n people has the same eye color
"Proof":
1. P(n) = Groups of n people have the same eye color
2. We will do induction on size of sets
3. Base case
Everyone in a group of one person has the same eye color, since there
is only one person in the group, and she must have the same eye color
as herself.
4. Induction step
P(n) => P(n+1)
Let S be a set of n+1 people. Let S' = S - {i}, where i is any person in S. Then S' is a set of n people. By induction hypothesis, everyone in S' has the same eye color. Let S' ' = S' - {j}, where j is any person in S' . j has the same eye color as everyone in S' , and hence has the same eye color as those in S' ' .
Now form T = S' ' + {i}. Since T has n people, everyone in T has the same eye color. By transitivity, everyone in T has the same eye color as those in S' ' , hence S' . So i has the same eye color as everyone in S' . It follows that everyone in S = S' + {i} has the same eye color.
This "proof" breaks down because the induction step removes 2 people from the set. Consider a set of size 2. The transitivity property breaks because our intermediate set is empty: we can't make an eye color statement about T with S' , and hence know nothing about the eye color of i with respect to S' .
Therefore, we need to add a new base case for P(2): any two people have the same eye color. This is clearly false, so this particular proof structure cannot prove P(n).