Docsity

Mathematical Induction Proofs in Computer Science, Papers of Computer Science

Toggle sidebar
bg1
CMPS 101
Algorithms and Abstract Data Types
Summer 2006
Induction Proofs
Let
)(nP
be a propositional function, i.e. P is a function whose domain is (some subset of) the set of
integers and whose codomain is the set {True, False}. Informally, this means
)(nP
is a sentence,
statement, or assertion whose truth or falsity depends on the integer n. Mathematical Induction is a proof
technique which can be used to prove statements of the form
)(:
0
nPnn
(“for all n greater than or
equal to
0
n
,
)(nP
is true”), where
0
n
is a fixed integer. A proof by Mathematical Induction contains
two steps:
I. Base Step: Prove directly that the proposition
)(
0
nP
is true.
IIa. Induction Step: Prove
))1()((:
0
nPnPnn
.
To do this pick an arbitrary
0
nn
, and assume for this n that
)(nP
is true. Then show as a
consequence that
)1( nP
is true. The statement
)(nP
is often called the induction hypothesis,
since it is what is assumed in the induction step.
When I and II are complete we conclude that
)(nP
is true for all
0
nn
. Induction is sometimes
explained in terms of a domino analogy. Consider an infinite set of dominos which are lined up and ready
to fall. Each domino is labeled by a positive integer, starting with
0
n
. (It is often the case that
1
0
n
,
which we assume here for the sake of definiteness). Let
)(nP
be the assertion: “the nth domino falls”.
First prove
, i.e. “the first domino falls”, then prove
))1()((: 1 nPnPn
which says “if any
particular domino falls, then the next domino must also fall”. When this is done we may conclude
)(:1 nPn
, “all dominos fall”. There are a number of variations on the induction step. The first is
just a reparametrization of IIa.
IIb. Induction Step: Prove
))()1((:
0
nPnPnn
Let
, assume
)1( nP
is true, then prove
)(nP
is true.
Forms IIa and IIb are said to be based on the first principle of mathematical induction. The validity of
this principle is proved in the appendix of this handout. Another important variation is called the second
principle of mathematical induction, or strong induction.
IIc. Induction Step: Prove
))1())( :((:
0
nPkPnknn
Let
0
nn
, assume for all k in the range
nkn
0
that
)(kP
is true. Then prove as a
consequence that
)1( nP
is true. In this case the term induction hypothesis refers to the stronger
assumption:
)( : kPnk
.
The strong induction form is often reparametrized as in IIb:
IId. Induction Step: Prove
))())(:((:
0nPkPnknn
Let
, assume for all k in the range
nkn
0
, that
)(kP
is true, then prove as a
consequence that
)(nP
is true. In this case the induction hypothesis is
)( : kPnk
.
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Mathematical Induction Proofs in Computer Science and more Papers Computer Science in PDF only on Docsity!

CMPS 101

Algorithms and Abstract Data Types

Summer 2006

Induction Proofs

Let P^ ( n ) be a propositional function, i.e. P is a function whose domain is (some subset of) the set of

integers and whose codomain is the set {True, False}. Informally, this means P (^ n ) is a sentence,

statement, or assertion whose truth or falsity depends on the integer n. Mathematical Induction is a proof

technique which can be used to prove statements of the form  n^^  n 0 : P ( n ) (“for all n greater than or

equal to n 0^ , P^ ( n )is true”), where n 0^ is a fixed integer. A proof by Mathematical Induction contains

two steps:

I. Base Step: Prove directly that the proposition P (^^ n 0 ) is true.

IIa. Induction Step: Prove ^ n^  n 0 :( P ( n ) P ( n ^1 )).

To do this pick an arbitrary n^  n^0 , and assume for this n that P (^ n ) is true. Then show as a

consequence that P^ (^ n ^1 ) is true. The statement P (^ n )is often called the induction hypothesis ,

since it is what is assumed in the induction step.

When I and II are complete we conclude that P^ ( n ) is true for all n^  n^0. Induction is sometimes

explained in terms of a domino analogy. Consider an infinite set of dominos which are lined up and ready

to fall. Each domino is labeled by a positive integer, starting with n 0^. (It is often the case that n 0^ ^1 ,

which we assume here for the sake of definiteness). Let P^ ( n ) be the assertion: “the n th domino falls”.

First prove P (^^1 ), i.e. “the first domino falls”, then prove ^ n^ ^1 :^ ( P ( n ) P ( n ^1 ))which says “if any

particular domino falls, then the next domino must also fall”. When this is done we may conclude

 n  1 : P ( n ), “all dominos fall”. There are a number of variations on the induction step. The first is

just a reparametrization of IIa.

IIb. Induction Step: Prove  n^  n 0 :( P ( n ^1 ) P ( n ))

Let n^ ^ n 0 , assume P (^^ n ^1 )is true, then prove P^ ( n )is true.

Forms IIa and IIb are said to be based on the first principle of mathematical induction. The validity of

this principle is proved in the appendix of this handout. Another important variation is called the second

principle of mathematical induction , or strong induction.

IIc. Induction Step: Prove ^ n  n 0 :(( k  n : P ( k )) P ( n ^1 ))

Let n^  n^0 , assume for all k in the range n^ 0  k  n that P (^ k ) is true. Then prove as a

consequence that P^ (^ n ^1 ) is true. In this case the term induction hypothesis refers to the stronger

assumption:  k^^  n :^ P ( k ).

The strong induction form is often reparametrized as in IIb :

IId. Induction Step: Prove  n^  n 0 :(( k  n : P ( k )) P ( n ))

Let n^ ^ n 0 , assume for all k in the range n^ 0  k  n , that P^ ( k ) is true, then prove as a

consequence that P^ ( n )is true. In this case the induction hypothesis is  k^^  n :^ P ( k ).

In terms of the Domino analogy, the strong induction form IId says we must show: (I) the first domino

falls, and (II) for any n , if all dominos up to but not including the n th domino fall, then the n th domino

falls. From (I) and (II) we may conclude that all dominos fall. Strong Induction is most often

parameterized as in IId, and form IIc is uncommon. We present here a number of examples of IIa, IIb,

and IId.

Example 1 Prove that for all n^ ^1 :

2 (^1 )(^21 )

1

^  

nn n

i

n i

Proof:

Let P^ ( n )be the boxed equation above. We begin the induction at n 0^ ^1.

I. Base step Clearly

1 1

i

i , showing that P ( 1 ) is true.

IIa. Induction Step Let n^ ^1 and assume P (^ n )is true. That is, for this particular value of n , the

boxed equation holds. Then

2 2 1 2 1 1  ^  (^ ^1 )   

i i n

n i n i ( 1 )^2 6

n n n n

(by the induction hypothesis)

(  1 )( 2  1 ) 6 (  1 )^2

nn n n    

n n n

(by some algebra)

showing that P (^^ n ^1 ) is true.

We conclude that P^ ( n )is true for all n  1. ///

When writing an induction proof, always state the induction hypothesis explicitly. Also make note of the

point in the proof where the induction hypothesis is used.

Example 2 Let x  R and x  1. Show that for all n  0 :

  

x

x

x

n i n i

Proof:

Here we will use form IIb. Again let P (^ n )be the boxed equation. We begin the induction at n 0^ ^0.

I. Base step

0 0

  ^ 

 x

x

x x

i i

, showing that P (^^1 ) is true.

IIb. Induction Step Let n^ ^0 and assume that P (^^ n ^1 )is true, i.e. assume for this particular n that:

^  

 x

x

x

n i n i

. Then

There are many other variations on the induction technique. Occasionally double induction is called for,

which involves a modification of both the base and induction steps.

Base Step: Prove P (^^ n 0 ) and P (^^ n 0 ^1 ).

Induction Step: Prove  n^^ (^ n 0 ^2 ):( P ( n ^2 ) P ( n ^1 ) P ( n )).

When these steps are complete, we conclude  n^^  n 0 : P ( n ). In terms of our domino analogy, we prove:

(I) the first two dominos fall, and (II) if any two consecutive dominos fall, then the very next domino

falls, and from (I) and (II) we deduce that all dominos fall. The next example uses double induction and

concerns the Fibonacci sequence Fn^ defined by: F 0^ ^0 , F 1^ ^1 , and Fn^ ^ Fn  1  Fn  2 , i.e. each term

in the sequence is the sum of the preceding two. Using this recurrence formula, the first few terms of the

Fibonacci sequence are easily computed: F 0^ ^0 , F 1^ ^1 , F 2^ ^1 , F 3^ ^2 , F 4^ ^3 , F 5^ ^5 , etc.

Example 4 Let

2 1  5

a  , and

2 1  5 b . Prove that for all n^ ^0 , ^  n n F nab 5

Proof:

Let P^ ( n )denote the boxed equation above.

I. Base Step Observe that P (^^0 )and P^ (^1 ) are true since ^ ^0

a  b   F and

 1 1  (^11) 5

a  b   F.

II. Induction Step Let n^ ^2 and assume that both P (^^ n ^2 ) and P^ (^ n ^1 )are true, i.e. we assume

for this n that

2 ^22  5

 ^ 

n n F n a b and ^  1 1 1 5

 ^ 

n n

F n a b.

The induction hypothesis yields

 ( 1 ) ( 1 ) 5

  F FFa a b b n n

n n n.

One checks that a and b are roots of the quadratic equation x^2  x  1  0 , whence a^2  a  1 , and

b^2  b  1. Therefore

F n   an   abn   b    anbn  5

showing that P (^ n )is true.

Together (I) and (II) imply that ^  n n F nab 5

for all n^ ^0. ///

Exercise 3 Let Fn^ be the Fibonacci sequence and define a as above. Show that

n ^2

F n a for all

n  2 , and hence F n  ( an ). (Prove this by double induction, not as a consequence of the last

example.)

A Short Introduction to Graphs

Often the propositional function P^ ( n ) is some assertion concerning other types of mathematical

structures, such as graphs, or trees. A graph G is a pair of sets G^ (^ V^ , E ). The elements of V^  are

called vertices , and the elements of E are called edges. Each edge joins two distinct vertices, called it’s

ends , and no two edges have the same ends. Abstractly, an edge is an unordered pair of vertices, i.e. a 2-

element subset of V. Two vertices that are joined by an edge are said to be adjacent , and an edge is said

to be incident with it’s two end vertices. Two edges are said to be adjacent if they are incident with a

common end vertex. Thus in the example below: vertex 1 is adjacent to vertex 4, vertex 2 is incident with

edge 26, and edge 45 is adjacent to edge 53.

V {1, 2, 3, 4, 5, 6} E {12, 14, 23, 24, 25, 26, 35, 36, 45, 56}

Let x^ ,^ y  V. An x - y path in G is a sequence of vertices starting with x and ending with y , in which each

consecutive pair of vertices are adjacent. We require that all vertices other than x and y be distinct. If

x  y , i.e. if the initial and terminal vertices in a path are identical, then the path is called a cycle. The

length of a path is the number of edges traversed by the sequence. In the above example we have:

A 1-6 path of length 5: 1, 2, 4, 5, 3, 6

A 1-6 path of length 3: 1, 4, 5, 6

Another 1-6 path of length 3: 1, 2, 3, 6

A cycle of length 6: 1, 2, 6, 3, 5, 4, 1

A cycle of length 3: 6, 2, 5, 6

A graph is said to be connected if it contains an x - y path for every x^ ,^ y  V , otherwise it is called

disconnected. The example above is clearly connected, while the following example is disconnected.

V {1, 2, 3, 4, 5, 6, 7, 8, 9} E {12, 15, 25, 26, 56, 37, 38, 78, 49}

A subgraph of a graph G is a graph H in which V^ (^ H )^ V ( G ), and E^ (^ H )^ E ( G ). In the above

example ({1, 2, 5}, {12, 15, 25}) is a connected subgraph, while ({2, 3, 6, 7}, {26, 37}) is a disconnected

subgraph. A subgraph H is called a connected component of G if it is (i) connected, and (ii) maximal with

respect to property (i), i.e. any other subgraph of G that contains H is disconnected. The above example

clearly has three connected components: ({1, 2, 5, 6}, {12, 15, 25, 26, 56}), ({3, 7, 8}, {37, 38, 78}), and

({4, 9}, {49}). Obviously a graph is connected if and only if it has exactly one connected component.

A graph G is called acyclic if it contains no cycles. A tree is a graph that is both connected and acyclic.

The connected components of an acyclic graph are obviously trees. For this reason an acyclic graph is

sometimes called a forest. The following graph is a forest with three connected components.

First note that the base step is identical to that in Example 5, and is correct. For the induction step, the

argument attempts to follow IIa, but does not do so. In this example P^ ( n ) is of the form A (^^ n ) B ( n )

where A (^ n ) is the statement “ T is a tree on n vertices”, and B^ ( n ) is “ T has n  1 edges”. The

induction step should therefore be to prove, for all n^ ^1 , that P^ (^ n )^ P ( n ^1 ), i.e.

( A ( n ) B ( n ))( A ( n  1 ) B ( n  1 )).

To prove this, we should assume A (^^ n )^ B ( n ), then assume A (^^ n ^1 ), then show as a consequence that

B ( n  1 )is true. In other words we should:

 Assume all trees on n vertices have n^ ^1 edges

 Assume T has n  1 vertices

 Show as a consequence that T has n edges

The argument did not follow this format however. Instead it does the following.

 Assume T has n vertices

 Assume T has n^ ^1 edges

 Construct a new tree from T having n  1 vertices and n edges

Therefore the argument was not a proof by induction. Some students would nevertheless hold that the

argument is still valid, even though it is not a true induction proof. The next example shows convincingly

that it cannot be valid.

Example B For all n  1 , if G is a connected graph on n vertices, then G has n  1 edges. ( False! )

We notice right away that the above statement is false, since the graph below provides an elementary

counter-example. But consider the following “proof” in light of Example A.

Proof: (Invalid)

Base Step: If n  1 then G has no edges, since each edge must have distinct end vertices.

Induction Step: Let n  1 and let G be a connected graph on n vertices. Assume that G has n  1

edges. Add a new vertex and join it to G with a new edge. The resulting graph has n  1 vertices and n

edges, and is clearly connected. By the principle of mathematical induction, all connected graphs on n

vertices have n^ ^1 edges.

Observe that Example B follows the format of Example A exactly. Thus if A is valid, so must B be valid.

But the assertion “proved” in B is false! Therefore B cannot be a valid argument, and so neither is A.

Example C All horses are of the same color.

Proof: (Invalid)

We prove that for all n  1 : if S is a set of n horses, then all horses in S have the same color. The result

follows on letting S be the set of all horses. Let P (^ n )be the boxed statement, and proceed by induction

on n.

Base Step: Let n^ ^1. Obviously if S is a set consisting of just one horse, then all horses in S must have

the same color. Thus P^ (^1 ) is true.

Induction Step: Let n^ ^1 and assume that in any set of n horses, all horses are of the same color. Let S

be a set of n^ ^1 horses, say S^ ^ h 1 ,^ h 2 , h 3 ,^ , hn  1 . Then the sets

S ^ { h 2 , h 3 ,, hn  1 } S { h 1 }

and

S ^ { h 1 , h 3 ,, hn  1 } S { h 2 }

each contain exactly n horses, and so by the induction hypothesis all horses in S ^ are of one color, and likewise for S ^. Observe that h^ 3  S  S and that h 3^ can have only one color. Therefore the color of the horses in S ^ is identical to that of the horses in S ^. (Note n  1  n  2  n  1  3 , so there is in fact a third horse, and he can have only one color.) Since SS  S it follows that all horses in S are

of the same color. Thus P (^^ n ^1 ) is true, showing that P (^^ n )^ P ( n ^1 ) for all n^ ^1. The result now

follows by induction.

Obviously the proposition being proved is false, so there is something wrong with the proof, but what?

The base step is certainly correct, and the induction step, as stated, is also correct. The problem is that the

induction step was not quantified properly. We should have proved ^ n^ ^1 : P ( n ) P ( n ^1 ) Instead we

proved (correctly) that ^ n^ ^1 : P ( n ) P ( n ^1 ). Indeed it is true that P^ (^2 )^ P (^3 ), P (^^3 )^ P (^4 ), and

P ( 4 ) P ( 5 ), etc., but we never proved (and it is false that) P ( 1 ) P ( 2 ). In terms of the domino

analogy, it is as if the first domino falls; and if any domino indexed 2 or above were to fall, then the next

domino would fall; but the first domino is not sufficient to topple the second domino, and hence no

domino other than the first actually falls.

Justification of the Induction Principles

Here we prove the validity of the first and second principles of mathematical induction. Both proofs are

based on the well ordering property of the positive integers Z , which says: Any non-empty set of

positive integers contains a least element. We assume this property without proof.

Theorem 1 (weak induction form IIb)

For any propositional function P^ ( n )defined on the positive integers, the following sentence is true:

P ( 1 )   n  1 : P ( n  1 ) P ( n )  n  1 : P ( n )

Proof:

Assume that P (^^1 ) and  n^^ ^1 : P ( n ^1 ) P ( n ) are both true. Let S^ {^ n^  Z | P ( n )is false}. It is

sufficient to show that S , since then P^ ( n )is true for all n  1. Assume, to get a contradiction, that

S  . Then, by the well ordering property of Z , S contains a least element, call it m. Since P^ (^1 ) is

true, we have 1  S. Therefore m  1 , and m  1 is a positive integer. Since m is the smallest element

in S , we must have m^ ^1  S , whence P (^^ m ^1 ) is true. We have assumed for all n^ ^1 that

P ( n  1 ) P ( n )is true. In particular for nm , we have P ( m  1 ) P ( m ). Since both P ( m  1 )and

P ( m  1 ) P ( m ) are true, we must conclude that P ( m ) is also true. Thus m  S , contradicting the

very definition of m as the smallest element in S. Thus our assumption was false, and hence S  as

required. ///

Theorem 2 (strong induction form IId)

For any propositional function P^ ( n )defined on the positive integers, the following sentence is true: