Running Time of Euclidean Algorithm

Induction (Section 3.3)
Agenda
Mathematical Induction Proofs
Well Ordering Principle
Simple Induction
Strong Induction (Second Principle of
Induction)
Program Correctness

L14
Correctness of iterative Fibonacci program
2
Mathematical Induction
Suppose we have a sequence of propositions
which we would like to prove:
P (0), P (1), P (2), P (3), P (4), … P (n), …
EG: P (n) =
“The sum of the first n positive odd numbers
is the nth perfect square”
We can picture each proposition as a domino:
P (n)
L14
3
Mathematical Induction
So sequence of propositions is a
sequence of dominos.
P (0)
P (1)
P (2)
P (n)
P (n+1)
…
L14
4
Mathematical Induction
When the domino falls, the corresponding
proposition is considered true:
P (n)
L14
5
Mathematical Induction
When the domino falls (to right), the
corresponding proposition is considered
true:
P (n)
true
L14
6
Mathematical Induction
Suppose that the dominos satisfy two
constraints.
1) Well-positioned: If any domino falls
(to right), next domino (to right) must
P (n+1)
fall also. P (n)
2) First domino has fallen to right
P (0)
true
L14
7
Mathematical Induction
Suppose that the dominos satisfy two
constraints.
1) Well-positioned: If any domino falls
to right, the next domino to right must
P (n) P (n+1)
fall also.
2) First domino has fallen to right
P (0)
true
L14
8
Mathematical Induction
Suppose that the dominos satisfy two
constraints.
1) Well-positioned: If any domino falls
to right, the next domino to right must
fall also.
P (n)
true
P (n+1)
true
2) First domino has fallen to right
P (0)
true
L14
9
Mathematical Induction
Then can conclude that all the dominos
fall!
P (0)
P (1)
P (2)
P (n)
P (n+1)
…
L14
10
Mathematical Induction
Then can conclude that all the dominos
fall!
P (0)
P (1)
P (2)
P (n)
P (n+1)
…
L14
11
Mathematical Induction
Then can conclude that all the dominos
fall!
P (1)
P (0)
true
L14
P (2)
P (n)
P (n+1)
…
12
Mathematical Induction
Then can conclude that all the dominos
fall!
P (2)
P (0)
true
L14
P (1)
true
P (n)
P (n+1)
…
13
Mathematical Induction
Then can conclude that all the dominos
fall!
P (n)
P (0)
true
L14
P (1)
true
P (2)
true
P (n+1)
…
14
Mathematical Induction
Then can conclude that all the dominos
fall!
P (n)
P (0)
true
L14
P (1)
true
P (2)
true
P (n+1)
…
15
Mathematical Induction
Then can conclude that all the dominos
fall!
P (n+1)
P (0)
true
L14
P (1)
true
P (2)
true
…
P (n)
true
16
Mathematical Induction
Then can conclude that all the dominos
fall!
P (0)
true
L14
P (1)
true
P (2)
true
…
P (n)
true
P (n+1)
true
17
Mathematical Induction
Principle of Mathematical Induction:
If:
1) [basis] P (0) is true
2) [induction] n P(n)P(n+1) is true
P (0)
true
P (1)
true
P (2)
true
…
P (n)
true
P (n+1)
true
Then:
n P(n) is true
This
formalizes what occurred to dominos.18
L14
Mathematical Induction
Example
EG: Prove n  0 P(n) where
P(n) = “The sum of the first n positive
odd numbers is the nth perfect square.”
n
2
=
 (2i  1)  n
i 1
L14
19
Mathematical
Induction
n
2
 (2i  1)  n Example
i 1 Every
induction proof has two parts, the basis
and the induction step.
1) Basis: Show that the statement holds for n
= 1. In our case, plugging in 0, we would
like to show that:
1
 (2i  1)  1
2
i 1
L14

20
Mathematical Induction
Example
2) Induction: Show that if statement holds for
k, then statement holds for k+1.
k 1
k
i 1
i 1
 (2i  1)  (2i  1)  [2(k  1)  1]
 k 2  [2k  1]
 (k  1) 2 
L14
(induction hypothesis)
This completes proof. •
21
More Examples
In class notes
L14
22