Mathematical Induction
The principle of mathematical induction is a useful
tool for proving that a certain predicate is true for all
positive integers.
It cannot be used to discover theorems, but only to
prove them.
If we have a propositional function P(n), and we
want to prove that P(n) is true for any positive
integer n, we do the following:
Basis Step: We verify that P(1) is true.
Inductive Step: We show that the conditional
statement P(k) → P(k + 1) is true for all positive
integers k.
Example:
Show that n < 2n for all positive integers n.
Let P(n) be the proposition “n < 2n.”
Show that P(1) is true.(basis step)
P(1) is true, because 1 < 21 = 2.
Show that if P(n) is true, then P(n + 1) is true.(inductive step)
Assume that n < 2n is true.
We need to show that P(n + 1) is true, i.e.n + 1 < 2 n+1
Since n < 2n
n + 1 < 2n + 1
2n + 2n = 2n+1
Therefore, if n < 2n then n + 1 < 2n+1
Then P(n) must be true for any positive
integer.
(conclusion)
Therefore, n < 2n is true for any positive
integer.
Show that
1 + 2 + … + n = n (n + 1)/2
Proof:
1. Show that P(0) is true.(basis step)
For n = 0 we get 0 = 0. True.
2. Show that if P(n) then P(n + 1) for any n Z+.
(inductive step)
1 + 2 + … + n = n (n + 1)/2
1 + 2 + … + n + (n + 1) = n (n + 1)/2 + (n + 1)
= (n + 1) (n/2 + 1)
= (n + 1) (n + 2)/2
= (n + 1) ((n + 1) + 1)/2
3. Then P(n) must be true for any nZ+.
(conclusion)
1 + 2 + … + n = n (n + 1)/2 is true for
all nZ+.
Sums of Geometric Progressions Use
mathematical induction to prove this formula
for the sum of a finite number of terms of a
geometric progression with initial term a and
common ratio r:
where n is a nonnegative integer.
Solution: Let P(n) be the statement that the
sum of the first n + 1 terms of a geometric
progression in this formula is correct.
Basis Step: P (0) is true, because
Inductive Step: Suppose P(k) is true, where k is
an
arbitrary nonnegative integer. That is, P(k) is
the statement that
Adding ark+1 on both sides
Rewriting the right-hand side of this equation
Combining these last two equations gives
Use mathematical induction to prove that n3 − n is divisible by 3
whenever n is a positive integer.
Solution: To construct the proof, let P(n) denote the proposition: “n3
− n is divisible by 3.”
Basis Step: The statement P(1) is true because 13 − 1 = 0 is divisible
by 3.
INDUCTIVE STEP: Assume that P(k) is true; that is, we
assume that k3 − k is divisible by 3 for an arbitrary positive integer k.
We must show that the statement P(k + 1)= (k+1)3 − (k+1) is
divisible by 3, is also true.
Since k3 − k is divisible by 3 and the second term is divisible by 3
because it is 3 times an integer, therefore (k+1)3 − (k+1) is also
divisible by 3.
Strong Induction:
To prove that P(n) is true for all positive
integers n, where P(n) is a propositional
function, we complete two steps:
Basis Step: We verify that the proposition P(1)
is true.
Inductive Step: We show that the conditional
statement [P(1) ∧ P(2) ∧ · · · ∧ P(k)] → P(k + 1)
is true for all positive integers k.
Example: Show that every integer greater than 1 can be written
as the product of primes.
• Show that P(2) is true. (basis step)
2 is the product of one prime: itself.
• Show that if P(2) and P(3) and … and P(n),
then P(n + 1) for any nN. (inductive step)
Two possible cases:
• If (n + 1) is prime, then obviously P(n + 1) is true.
• If (n + 1) is composite, it can be written as the product of two
integers a and b such that
2 a b < n + 1.
By the induction hypothesis, both a and b can be written as
the product of primes.
Therefore, n + 1 = ab can be written as the product of
primes.
Then P(n) must be true for any nN.
(conclusion)
Recursion:
Recursion is a principle closely related to
mathematical induction.
In a recursive definition, an object is
defined in terms of itself.
We can recursively define sequences,
functions and sets.
Recursively Defined Sequences
Example:
The sequence {an} of powers of 2 is given
by
an = 2n for n = 0, 1, 2, … .
The same sequence can also be defined
recursively:
a0 = 1
an+1 = 2an for n = 0, 1, 2, …
How can we recursively define a function for generating
fibonacci numbers?
Solution:
f(0) = 0, f(1) = 1
f(n) = f(n – 1) + f(n - 2)
f(0) = 0
f(1) = 1
f(2) = f(1) + f(0) = 1 + 0 = 1
f(3) = f(2) + f(1) = 1 + 1 = 2
f(4) = f(3) + f(2) = 2 + 1 = 3
f(5) = f(4) + f(3) = 3 + 2 = 5
f(6) = f(5) + f(4) = 5 + 3 = 8
Recursively Defined Functions
We can use the following method to define
a function with the natural numbers as its
domain:
1. Specify the value of the function at zero.
2. Give a rule for finding its value at any
integer
from its values at smaller integers.
Such a definition is called recursive or
inductive definition.
Example:
f(0) = 3
f(n + 1) = 2f(n) + 3 Find f(1),f(2),f(3) and
f(4)
Solution
f(1) = 2f(0) + 3 = 23 + 3 = 9
f(2) = 2f(1) + 3 = 29 + 3 = 21
f(3) = 2f(2) + 3 = 221 + 3 = 45
f(4) = 2f(3) + 3 = 245 + 3 = 93
How can we recursively define the factorial
function f(n) = n! ?
Solution:
f(0) = 1
f(n + 1) = (n + 1)f(n)
0!=f(0) = 1
1!=f(1) = 1f(0) = 11 = 1
2!=f(2) = 2f(1) = 21 = 2
3!=f(3) = 3f(2) = 32 = 6
4!=f(4) = 4f(3) = 46 = 24
Recursively Defined Sets
If we want to recursively define a set, we
need to provide two things:
• an initial set of elements,
• rules for the construction of additional
elements from elements in the set.
Example: Let S be recursively defined by:
3 S
(x + y) S if (x S) and (y S)
S is the set of positive integers divisible by
3.
Proof:
Let A be the set of all positive integers divisible by
3.
To show that A = S, we must show that
A S and S A.
Part I: To prove that A S, we must show that
every positive integer divisible by 3 is in S.
Let P(n) be the statement “3n belongs to S”.
Basis step: P(1) is true, because 3 is in S.
Inductive step: We have to show that if P(n) is
true, then P(n + 1) is true.
Assume 3n is in S. Since 3n is in S and 3 is in S,
it follows from the recursive definition of S that
3n + 3 = 3(n + 1) is also in S.
Conclusion of Part I: A S.
Part II: To show: S A.
Basis step: We have to show that all initial
elements of S are in A.
It is true since 3 is in A.
Inductive step: We have to show that (x + y) is
in A whenever x and y are in A.
If x and y are both in A, it follows that 3 | x
and 3 | y. Therefore it follows that 3 | (x + y).
Conclusion of Part II: S A.
Overall conclusion: A = S.
Another example:
The well-formed formulas of variables,
numerals and operators from {+, -, *, /, ^}
are defined by:
x is a well-formed formula if x is a numeral
or variable.
(f + g), (f – g), (f * g), (f / g), (f ^ g) are
well-formed formulas if f and g are.
With this definition, we can construct
formulas such as:
(x – y)
((z / 3) – y)
((z / 3) – (6 + 5))
((z / (2 * 4)) – (6 + 5))
Recursive Algorithms
An algorithm is called recursive if it solves a
problem by reducing it to an instance of the
same problem with smaller input.
Example I: Recursive Euclidean Algorithm
procedure gcd(a, b: nonnegative integers
with a < b)
if a = 0 then gcd(a, b) := b
else gcd(a, b) := gcd(b mod a, a)
Example II: Recursive Fibonacci Algorithm
procedure fibo(n: nonnegative integer)
if n = 0 then fibo(0) := 0
else if n = 1 then fibo(1) := 1
else fibo(n) := fibo(n – 1) + fibo(n – 2)
Recursive Fibonacci Evaluation:
f(4)
f(3) f(2)
f(2)
f(1) f(1) f(0)
f(1) f(0)
procedure iterative_fibo(n: nonnegative integer)
if n = 0 then y := 0
else
begin
x := 0
y := 1
for i := 1 to n-1
begin
z := x + y
x:=y
y := z
end
end {y is the n-th Fibonacci number}
For every recursive algorithm, there is an
equivalent iterative algorithm.
Recursive algorithms are often shorter,
more elegant, and easier to understand than
their iterative counterparts.
However, iterative algorithms are usually
more efficient in their use of space and time.