Unit 4 - Induction and Recursion - Complete
Unit 4 - Induction and Recursion - Complete
Unit 4
4.1 Induction
The truth of basis and inductive steps implies the truthness of P (n0 ), P (n0 + 1), P (n0 + 2), · · ·
as follows. The truthness of P (n0 ) is shown in the basis step. The truthness of inductive
step for k = n0 implies that P (n0 ) → P (n0 + 1) is also true and hence by modus ponens,
P (n0 + 1) must be true. Again taking k = n0 + 1 in the inductive step we get the truthness
of P (n0 + 1) → P (n0 + 2) and together with the truthness of P (n0 + 1) we conclude that
P (n0 + 2) is also true. Continuing in this fashion, we can show that P (k) is true for all k ≥ n0 .
Example:
n(n + 1)
1. Show that 1 + 2 + · · · + n = for all n ≥ 1.
2
Proof: We have to prove that
n(n + 1)
1 + 2 + ··· + n =
2
for all n ≥ 1.
Basis step: We have to show that the equality is true for n = 1. When n = 1, we have
LHS = 1
and
1(1 + 1)
RHS = =1
2
so that LHS = RHS. Hence the equality is true for n = 1.
Inductive step: Suppose that the equality is true when n = k i.e.,
k(k + 1)
1 + 2 + ··· + k = .
2
We now need to prove that the equality is true when n = k + 1 i.e.,
(k + 1)[(k + 1) + 1]
1 + 2 + · · · + k + (k + 1) = .
2
Now,
k(k + 1) k(k + 1) + 2(k + 1)
LHS = 1 + 2 + · · · + k + (k + 1) = + (k + 1) =
2 2
(k + 1)(k + 2) (k + 1)[(k + 1) + 1]
= = = RHS.
2 2
Therefore inductive step is true as well.
n(n + 1)
Hence 1 + 2 + · · · + n = for all n ≥ 1.
2
2. Prove that n3 − n is divisible by 3 for all n ≥ 1.
Proof: We need to prove that n3 − n is divisible by 3 for all n ≥ 1 i.e., n3 − n = 3m for
some integer m.
Basis Step: We show that n3 − n = 3m for some integer m when n = 1. Now when
n = 1, we have
n3 − n = 13 − 1 = 1 − 1 = 0 = 3 × 0.
Hence n3 − n = 3m when n = 1.
Inductive Step: Suppose that n3 − n = 3m for some integer m when n = k i.e., k 3 − k =
3m. We now need to prove that n3 − n is again a multiple of 3 when n = k + 1 i.e.,
(k + 1)3 − (k + 1) is a multiple of 3. Now
(k + 1)3 − (k + 1) = k 3 + 3k 2 + 3k + 1 − k − 1 = k 3 − k + 3(k 2 + k)
Comparing this with the proof by (normal) induction, we can see that the only difference is in
the inductive step: unlike normal induction, in strong induction one assumes the truthness of not
only P (n0 ) but also of P (n0 + 1), · · · , P (k) and uses these to prove the truthness of P (k + 1).
However, it can be proved that both the proof techniques are equivalent i.e., anything that can
be proved using strong induction can also be proved using normal induction and vice-versa.
Example:
i.e., if A ⊆ {0, 1, 2, 3, · · · } and A 6= ∅, then A must have a least element. This property can
be used to prove the validity of the principle of mathematical induction as well as the principle
of strong induction. In fact, one can show that the well-ordering property is equivalent to both
these principles of induction.
Example: Use the well-ordering property to prove the division algorithm: “If a is an integer
and d is a positive integer, then there are unique integers q and r with 0 ≤ r < d and a = dq+r.”
Proof: Let
S = {a − dm : a − dm ≥ 0 and m is an integer}.
Then S is a set of nonnegative integers. Also, S is nonempty because by taking m a negative
integer with large absolute value, we can make −dm as large as we like thus making a−dm ≥ 0.
Therefore by the well-ordering property, S has a least element, say r = a − dq. Since r ∈ S,
so r ≥ 0. Also, r < d because if r ≥ d then a − d(q + 1) = a − dq − d = r − d ≥ 0 so
a − d(q + 1) ∈ S. But a − d(q + 1) = r − d < r which contradicts that r is the least element
in S. So 0 ≤ r < d.
To prove the uniqueness of q and r, suppose that there is another pair q1 and r1 with 0 ≤ r1 < d
and a = dq1 + r1 . First we prove that r1 = r. For if not, let r < r1 so that 0 < r − r1 < d
because 0 ≤ r < d and 0 ≤ r1 < d. But
4.2 Recursion
The process of defining objects such as functions, sets or sequences in terms of itself is called
recursion. When such objects are defined using recursion, we say that they are recursively
defined.
Examples:
Then f is a recursively defined function. Its functional values for integers can be calcu-
lated as follows:
f (1) = 2f (0) + 3 = 2 × 3 + 3 = 9
f (2) = 2f (1) + 3 = 2 × 9 + 3 = 21
f (3) = 2f (2) + 3 = 2 × 21 + 3 = 45
and so on.
f (1) = 1 × f (0) = 1 × 1 = 1 = 1!
f (2) = 2 × f (1) = 2 × 1 = 2!
f (3) = 3 × f (2) = 3 × 2 × 1 = 3!
f (4) = 4 × f (3) = 4 × 3 × 2 × 1 = 4!
and so on.
3. While defining a recursive function, basis step may require declaration of functional val-
ues at more than one initial point as in example below:
Then
and so on.
Basis Step: Specify the elements that initially belongs to the set S.
Recursive Step: Give rules for forming new elements in the set S from those
already known to be in S.
Examples:
Basis Step: 3 ∈ S
Recursive Step: If x, y ∈ S then x + y ∈ S.
Basis Step: 5 ∈ S
Recursive Step: If x, y ∈ S, then x + y ∈ S and x − y ∈ S.
3. Let S be the set of all well-formed formulae for compound propositions formed from T ,
F , propositional variables p, q, r, s etc and logical operators ¬, ∧, ∨, →, ↔. Then S can
be defined recursively as follows:
Basis Step: Show that the result holds for all elements specified in the basis step of
the recursive definition of the set.
Recursive Step: Show that if the statement is true for each of the elements used to
construct new elements in the recursive step of the definition, the result holds for
these new elements.
Example:
1. Show that the set S defined recursively in previous example 1. is the set of all the positive
integers that are multiples of 3.
Proof: We have to prove that if x is any element of the set S, then x = 3m for some
positive integer m. We proceed by structural induction.
Basis step: Since 3 = 3 × 1 is a positive integer multiple of 3, so the result holds for the
element 3 specified in the basis step of recursive definition.
Recursive step: Now suppose x, y are some positive integer multiples of 3 i.e., x = 3m
and y = 3n for some positive integers m and n. Then
x + y = 3m + 3n = 3(m + n)
2. Show that every well-formed formulae for compound propositions contains an equal num-
ber of left and right parentheses.
Proof:
Basis step: Since the formulae T , F , p, q, r, s etc do not have any parentheses, so they
have an equal number (i.e. zero number) of left and right parentheses.
Recursive step: Now suppose U and V are well-formed formulae each containing an
equal number of left and right parentheses. That is, if LU , RU , LV , RV are the number
of left and right parentheses in U and V respectively then LU = RU and LV = RV . To
complete the induction step, we need to show that (¬U ), (U ∧ V ), (U ∨ V ), (U → V ),
(U ↔ V ) also contain an equal number of left and right parentheses. The number of left
parentheses in (¬U ) is LU + 1 and in others there are LU + LV + 1. The number of right
parentheses in (¬U ) is RU + 1 and in others there are RU + RV + 1. Since LU = RU and
LV = RV , so LU + 1 = RU + 1 and LU + LV + 1 = RU + RV + 1. Therefore each of
these compound propositions also contain the same number of left and right parentheses.
LHS = RHS
when n = 0.
Inductive Step: Suppose that the equality is true when n = k i.e.,
power(a, k) = ak .
power(a, k + 1) = ak+1 .
Hence the inductive step is also true and therefore, power(a, n) = an for all n ≥ 0.
f actorial(k) = k!.
f actorial(k + 1) = (k + 1)!.
f actorial(k + 1) = (k + 1) · f actorial(k).
Hence the inductive step is also true and therefore, factorial(n) = n! for all n ≥ 0.
4.3 Exercise
4.3.1 Induction
1. Use mathematical induction to prove the following:
n(n + 1)(2n + 1)
(a) 12 + 22 + · · · n2 = for n ≥ 1.
6
n(n + 1)(n + 2)
(b) 1.2 + 2.3 + .... + n(n + 1) = for n ≥ 1.
3
2
3 3 3 n(n + 1)
(c) 1 + 2 + .... + n = for n ≥ 1.
2
n(2n − 1)(2n + 1)
(d) 12 + 32 + · · · + (2n − 1)2 = for n ≥ 1.
3
1 1 1 n
(e) + + ··· + = for n ≥ 1.
1·2 2·3 n(n + 1) n+1
(f) 1 + 2 + 22 + · · · + 2n = 2n+1 − 1 for all n ≥ 0.
(g) 1.1! + 2.2! + · · · + n.n! = (n + 1)! − 1 for all n ≥ 1.
(h) The sum of the first n odd positive integers is n2 i.e. 1 + 3 + 5 + · · · + (2n − 1) = n2
for all n ≥ 1.
(i) If 0 ≤ a < 1 then show that (1 − a)n ≥ 1 − na for all n ≥ 1.
(j) f02 + f12 + · · · + fn2 = fn fn+1 for all n ≥ 0 where fi ’s are the ith Fibonacci numbers.
(k) Prove that n2 + n is divisible by 2 for all n ≥ 1.
(l) Prove that 3 divides n3 + 2n whenever n is a positive integer.
(m) Prove that 5 divides n5 − n for all n ≥ 0.
(n) Prove that n3 − n is divisible by 6 whenever n ≥ 0.
(o) 2n < n! for all n ≥ 4.
(p) n2 < 2n for all n ≥ 5.
2. Use strong
induction to prove that the nth Fibonacci number Fn satisfies the inequality
n
13
Fn < for n ≥ 1.
8
4.3.2 Recursion
1. Find a recursive definition of the functions
(a) f (n) = n2 , n ≥ 0
(b) f (n) = 2n + 1, n ≥ 1
1
(c) f (n) = , n ≥ 1
n
P RAJWAL K ANSAKAR - for CSIT @Prime
UNIT 4. INDUCTION AND RECURSION 80