CS1021'
&
$
%
The natural numbers
N = (N,+,×, 0, 1)
where the elements of N are
0,1,2,3,4,5, . . .
(the non-negative integers).
In many ways this structure is similar to the integers Z, but has an important
extra property.
The Principle of Induction
Induction 5-1
CS1021 The natural numbers (continued)'
&
$
%
One form of this principle is as follows
The induction principle for natural numbers
Suppose that X is a set of natural numbers such that both
(Base) 0 ∈ X
(Step) ∀n ∈ N, n ∈ X ⇒ n + 1 ∈ X
hold. Then ∀n ∈ N, n ∈ X . In other words X = N
Induction 5-2
CS1021 The natural numbers (continued)'
&
$
%
An alternative formulation is the following
Suppose that P(n) is a property defined for all natural numbers n
such that both
(Base) P(0) is true
(Step) ∀n ∈ N, if P(n) is true, then so is P(n + 1)
hold. Then ∀n ∈ N, P(n) is true.
Induction 5-4
CS1021 The natural numbers (continued)'
&
$
%
There are many places where we need to verify a fact of the form
For each natural number n · · ·n · · ·
where · · ·n · · · is some assertion about arbitrary numbers n.
Induction 5-5
CS1021'
&
$
%
Example – recursive function
Suppose the function
f : N > Z
satisfies
f (0) = 0
f (1) = 1
f (r + 2) = 2 f (r + 1)− f (r)+ 2
∀r ∈ N.
f (0) = 0
f (1) = 1
f (2) = 2−0 + 2 = 4
Induction 5-6
CS1021'
&
$
%
f (3) = 8−1 + 2 = 9
f (4) = 18−4 + 2 = 16
...
In general, ∀r ∈ N,
f (r) = r2.
How do we prove this?
Induction 5-7
CS1021'
&
$
%
Example – Divisibility
Consider the expression
f (n) = 32n + 4n+1
n f (n)
0 30 + 41 = 5
1 32 + 42 = 25
2 34 + 43 = 145
3 36 + 44 = 985
4 38 + 45 = 7585
Claim that f (n) is always divisible by 5.
How do we prove it?
Induction 5-8
CS1021'
&
$
%
Example – sum of a series
Let Sum(n) be the sum of the first n + 1 natural numbers, i.e.
Sum(n) = 0 + 1 + 2 + 3 + · · ·+ n.
Can we find a compact formula for Sum(n)?
Notation:-
s
∑i=r
ai = ar + ar+1 + · · ·+ as
in particular
Sum(n) =n
∑i=0
i.
Induction 5-9
CS1021'
&
$
%
Three summation problems
Find compact formulas for the following.
(i)n∑
i=0i i.e. 0 + 1 + 2 + 3 · · ·+ n
(ii)n∑
i=0i2 i.e. 0 + 1 + 4 + 9 · · ·+ n2
(iii)n∑
i=0i(i + 1) i.e. 0 + 2 + · · ·+ n(n + 1)
We will show that
Induction 5-10
CS1021'
&
$
%
n∑
i=0i = n(n+1)
2
n∑
i=0i2 = n(n+1)(2n+1)
6
n∑
i=0i(i + 1) = n(n+1)(n+2)
3
Induction 5-11
CS1021'
&
$
%
Special ‘trick’ method
Let
Sum(n) =n
∑i=0
i
so that
Sum(n) = 0+ 1+ · · · +(n−1) +n
Induction 5-12
CS1021'
&
$
%
Special ‘trick’ method
Let
Sum(n) =n
∑i=0
i
so that
Sum(n) = 0+ 1+ · · · +(n−1) +n
Sum(n) = n+ (n−1)+ · · · +1 +0
Induction 5-12
CS1021'
&
$
%
Special ‘trick’ method
Let
Sum(n) =n
∑i=0
i
so that
Sum(n) = 0+ 1+ · · · +(n−1) +n
Sum(n) = n+ (n−1)+ · · · +1 +0
Adding gives
Induction 5-12
CS1021'
&
$
%
Special ‘trick’ method
Let
Sum(n) =n
∑i=0
i
so that
Sum(n) = 0+ 1+ · · · +(n−1) +n
Sum(n) = n+ (n−1)+ · · · +1 +0
Adding gives
2Sum(n) = n+ n+ · · · +n +n
Induction 5-12
CS1021 Special ‘trick’ method (continued)'
&
$
%
2Sum(n) = n + n + n + · · ·+ n + n = n(n + 1)
there are n + 1 terms each of value n. So
Induction 5-13
CS1021 Special ‘trick’ method (continued)'
&
$
%
2Sum(n) = n + n + n + · · ·+ n + n = n(n + 1)
there are n + 1 terms each of value n. So
Sum(n) =n(n + 1)
2.
Induction 5-13
CS1021 Special ‘trick’ method (continued)'
&
$
%
2Sum(n) = n + n + n + · · ·+ n + n = n(n + 1)
there are n + 1 terms each of value n. So
Sum(n) =n(n + 1)
2.
This trick won’t work in general. Need a more general method.
Induction 5-13
CS1021'
&
$
%
A more general method
∀n ∈ N let
L(n) =n
∑i=0
i , R(n) =n(n + 1)
2
so we want to show the following.
∀n ∈ N, L(n) = R(n)
We can verify directly that
Induction 5-14
CS1021'
&
$
%
L(0) = 0 = R(0)
L(1) = 1 = R(1)
L(2) = 3 = R(2)
L(3) = 6 = R(3)
L(4) = 10 = R(4)...
...
but we need a proof for all n ∈ N.
Induction 5-15
CS1021 A more general method (continued)'
&
$
%
We can verify directly that:
∀n ∈ N, if
L(n) = R(n)
then also
L(n + 1) = R(n + 1).
i.e. the Induction Step
(Step) L(n) = R(n) ⇒ L(n + 1) = R(n + 1)
and then
Induction 5-16
CS1021 A more general method (continued)'
&
$
%
(0) L(0) = R(0) by direct computation
(1) L(1) = R(1) from (0), (Step)
(2) L(2) = R(2) from (1), (Step)
(3) L(3) = R(3) from (2), (Step)...
and hence
∀n ∈ N, L(n) = R(n).
Induction 5-17
CS1021 A more general method (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i Definition of L
= (n∑
i=0i)+(n + 1) Isolate the last term
Induction 5-18
CS1021 A more general method (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i Definition of L
= (n∑
i=0i)+(n + 1) Isolate the last term
= L(n)+(n + 1) Definition of L
Induction 5-18
CS1021 A more general method (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i Definition of L
= (n∑
i=0i)+(n + 1) Isolate the last term
= L(n)+(n + 1) Definition of L
= R(n)+(n + 1) Induction Hypothesis
Induction 5-18
CS1021 A more general method (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i Definition of L
= (n∑
i=0i)+(n + 1) Isolate the last term
= L(n)+(n + 1) Definition of L
= R(n)+(n + 1) Induction Hypothesis
= n(n+1)2 +(n + 1) Definition of R
Induction 5-18
CS1021 A more general method (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i Definition of L
= (n∑
i=0i)+(n + 1) Isolate the last term
= L(n)+(n + 1) Definition of L
= R(n)+(n + 1) Induction Hypothesis
= n(n+1)2 +(n + 1) Definition of R
∗= (n+1)(n+2)
2 Simple arithmetic
Induction 5-18
CS1021 A more general method (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i Definition of L
= (n∑
i=0i)+(n + 1) Isolate the last term
= L(n)+(n + 1) Definition of L
= R(n)+(n + 1) Induction Hypothesis
= n(n+1)2 +(n + 1) Definition of R
∗= (n+1)(n+2)
2 Simple arithmetic
= R(n + 1) Definition of R
Induction 5-18
CS1021 A more general method (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i Definition of L
= (n∑
i=0i)+(n + 1) Isolate the last term
= L(n)+(n + 1) Definition of L
= R(n)+(n + 1) Induction Hypothesis
= n(n+1)2 +(n + 1) Definition of R
∗= (n+1)(n+2)
2 Simple arithmetic
= R(n + 1) Definition of R
The equality∗= is the only non-routine step.
Induction 5-18
CS1021 A more general method (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i Definition of L
= (n∑
i=0i)+(n + 1) Isolate the last term
= L(n)+(n + 1) Definition of L
= R(n)+(n + 1) Induction Hypothesis
= n(n+1)2 +(n + 1) Definition of R
∗= (n+1)(n+2)
2 Simple arithmetic
= R(n + 1) Definition of R
The equality∗= is the only non-routine step.
This means that L(n) = R(n) ∀n ∈ N
Induction 5-18
CS1021'
&
$
%
A second example
∀n ∈ N let
L(n) =n
∑i=0
i2 , R(n) =n(n + 1)(2n + 1)
6.
We show the following.
∀n ∈ N, L(n) = R(n)
Induction 5-19
CS1021 A second example (continued)'
&
$
%
Note first that
L(0) = 0 = R(0).
We now show the Induction Step:
∀n ∈ NL(n) = R(n) ⇒ L(n + 1) = R(n + 1).
Induction 5-20
CS1021 A second example (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i2 Definition of L
= (n∑
i=0i2)+(n + 1)2 Isolate last term
Induction 5-21
CS1021 A second example (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i2 Definition of L
= (n∑
i=0i2)+(n + 1)2 Isolate last term
= L(n)+(n + 1)2 Definition of L
Induction 5-21
CS1021 A second example (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i2 Definition of L
= (n∑
i=0i2)+(n + 1)2 Isolate last term
= L(n)+(n + 1)2 Definition of L
= R(n)+(n + 1)2 Induction Hypothesis
Induction 5-21
CS1021 A second example (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i2 Definition of L
= (n∑
i=0i2)+(n + 1)2 Isolate last term
= L(n)+(n + 1)2 Definition of L
= R(n)+(n + 1)2 Induction Hypothesis
= n(n+1)(2n+1)6 +(n + 1)2 Definition of R
Induction 5-21
CS1021 A second example (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i2 Definition of L
= (n∑
i=0i2)+(n + 1)2 Isolate last term
= L(n)+(n + 1)2 Definition of L
= R(n)+(n + 1)2 Induction Hypothesis
= n(n+1)(2n+1)6 +(n + 1)2 Definition of R
∗= (n+1)(n+2)(2n+3)
6 Arithmetic
Induction 5-21
CS1021 A second example (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i2 Definition of L
= (n∑
i=0i2)+(n + 1)2 Isolate last term
= L(n)+(n + 1)2 Definition of L
= R(n)+(n + 1)2 Induction Hypothesis
= n(n+1)(2n+1)6 +(n + 1)2 Definition of R
∗= (n+1)(n+2)(2n+3)
6 Arithmetic
= R(n + 1) Definition of R
Induction 5-21
CS1021 A second example (continued)'
&
$
%
L(n + 1)
=n+1∑
i=0i2 Definition of L
= (n∑
i=0i2)+(n + 1)2 Isolate last term
= L(n)+(n + 1)2 Definition of L
= R(n)+(n + 1)2 Induction Hypothesis
= n(n+1)(2n+1)6 +(n + 1)2 Definition of R
∗= (n+1)(n+2)(2n+3)
6 Arithmetic
= R(n + 1) Definition of R
The equality∗= is the only non-routine step.
Induction 5-21
CS1021'
&
$
%
A general pattern
∀n ∈ N let
L(n) =n
∑i=0
ai , R(n) = explicit formula.
We wish to show that
∀n ∈ N, L(n) = R(n)
Induction 5-22
CS1021 A general pattern (continued)'
&
$
%
This follows from
Base : L(0) = R(0)
and
Induction Step: ∀n ∈ N,
L(n) = R(n) ⇒ L(n + 1) = R(n + 1).
Induction 5-23
CS1021'
&
$
%
Proof of Induction Step
L(n + 1)
=n+1∑
i=0ai Definition of L
= (n∑
i=0ai)+ an+1 Isolate the last term
= L(n)+ an+1 Definition of L
= R(n)+ an+1 Induction Hypothesis∗= R(n + 1) Arithmetic
The equality∗= is the crucial step.
Induction 5-24
CS1021'
&
$
%
Divisibility problem
Show that if
f (n) = 32n + 4n+1
then f (n) is divisible by 5 ∀n ∈ NBase: f (0) = 30 + 41 = 5
Induction 5-25
CS1021 Divisibility problem (continued)'
&
$
%
Step: Suppose n is such that f (n) is divisible by 5
We need to show that f (n + 1) is also divisible by 5
f (n + 1) = 32(n+1) + 4(n+1)+1
= 32n+2 + 4n+2
= 32n.32 + 4n+1.4
= 32n.9 + 4n+1.4
= 32n(5 + 4)+ 4n+1.4
= 5.32n + 4(32n + 4n+1)
Now 32n + 4n+1 is divisible by 5 (by inductive assumption), and so is 5.32n,
therefore so is f (n + 1), which completes the proof.
Induction 5-26
CS1021'
&
$
%
Recursive function problem
f : N > Z
satisfies
f (0) = 0
f (1) = 1
f (r + 2) = 2 f (r + 1)− f (r)+ 2
∀r ∈ N.
We want to show that
∀r ∈ N, f (r) = r2
holds.
Induction 5-27
CS1021 Recursive function problem (continued)'
&
$
%
We use induction on r.
Base (r = 0) Need to show that f (0) = 02
(This is trivial.)
Step (r 7→ r + 1)
Need to show that if f (r) = r2 then f (r + 1) = (r + 1)2.
This induction hypothesis doesn’t work
Induction 5-28
CS1021 Recursive function problem (continued)'
&
$
%
We show the following.
∀r ∈ N, both
f (r) = r2 , f (r + 1) = (r + 1)2
hold.
Base (r = 0) Need to show that f (0) = 02 , f (1) = 12
(This is trivial.)
Step (r 7→ r + 1)
Need to show that if
f (r) = r2 , f (r + 1) = (r + 1)2
then
f (r + 1) = (r + 1)2 , f (r + 2)∗= (r + 2)2.
We derive the second conclusion ∗ from both hypotheses.
Induction 5-29
CS1021 Recursive function problem (continued)'
&
$
%
f (r + 2)
= 2 f (r + 1)− f (r)+ 2 from the spec
= 2(r + 1)2− r2 + 2 by I. H.
= r2 + 4r + 4 arithmetic
= (r + 2)2 arithmetic
Induction 5-30
CS1021'
&
$
%
A currency example
UK currency has coins of denominations 1p, 2p, 5p, 10p, 20p, 50p
Show that, if the 1p coin was abolished, the only quantities no longer
obtainable would be 1p and 3p.
Since 10p, 20p and 50p are all multiples of 5p we can clearly ignore them
and consider only 2p and 5p.
Induction 5-31
CS1021 A currency example (continued)'
&
$
%
Without the 1p coin we can not obtain 1p and 3p (obvious).
We now need to show that for any amount n (≥ 4), we can make up n using
only 2p and 5p coins.
Base: (n=4)
4 = 2 + 2, so this is ok
Induction 5-32
CS1021 A currency example (continued)'
&
$
%
Step: Suppose n is obtainable using 2p and 5p coins only. We will show that
(n + 1) is also obtainable.
2 possible cases. Since n≥ 4, we must use either
i) At least 2 2p coins, or
ii) at least 1 5 p coin
In case i), we can replace 2×2 by a single 5p coin to make n + 1.
In case ii), we can replace a single 5p coin by 3×2 to make n + 1.
Induction 5-33
CS1021'
&
$
%
Structural Induction
The reason induction works on the natural numbers is because of their
recursive structure. Every natural number is either
• zero
• the successor of another natural number
Other structures are also built recursively and their structure can be used to
provide an induction mechanism
Induction 5-34
CS1021'
&
$
%
Induction on Formal Languages
Recall that we define a formal language by giving a set of rules for producing
the words or expressions of the language.
These definitions are almost always recursive, and so induction techniques
similar to those above can be used to prove properties of the language
Induction 5-35
CS1021 Induction on Formal Languages (continued)'
&
$
%
Suppose we define a formal language L of strings of 0’s and 1’s as follows
1. The empty string is in L
2. If a string s is in L , then so is the string 1s. The set of strings generated
by this rule is called M .
3. If a string s is in M , then 0s is in L
4. All strings in L are generated by the above rules.
The following strings are all members of L .
1
11
111
0111
10111
Induction 5-36
CS1021 Induction on Formal Languages (continued)'
&
$
%
100111 is not a member of L . Why?
Prove that, for all members s of L , s contains at least as many 1’s as 0’s, and
if s is a member of M it contains more 1’s than 0’s.
Call this property P(s)
Induction 5-37
CS1021 Induction on Formal Languages (continued)'
&
$
%
1. Base case: Empty string, ok
2. If s satisfies P(s), then clearly, so does 1s. By adding an extra 1 we
ensure that the string 1s contains more 1’s than 0’s.
3. Suppose s is in M , then the string 0s contains at least as many 1’s as
0’s (s had more 1’s than 0’s)
By induction, P(s) is true ∀s ∈ L
Induction 5-38
Top Related