2 About Induction - UML Computer Science

2 About Induction
Induction is one of the main tools we use for reasoning about discrete objects,
such as programs and data structures. Most of you already have some experience
with induction. Your experience falls into two categories:
Natural Induction means developing a hunch, based on pattern recognition.
For instance, if you see the sequence of numbers 1 4 9 16, then you naturally
guess that the next number in the series is 25.
Mathematical Induction is a term for a proof method based on propositions, implication, and the natural numbers. From the prerequisite courses,
you have experience in proving certain formulas by induction, such as
Xn i
i=1
= n(n2+ 1)
Whereas natural induction is the process of developing a hunch, mathematical induction is a method of proving a proposition | and that proposition
is only a hunch until it is proven correct or disproven.
The reason we are interested in induction is that we want to extend its use to
help us reason about programs, data structures, and tools for analyzing programs. In order to develop the necessary skills, we use mathematical induction
to prove propositions that are not necessarily statements or formulas about natural numbers. For instance, suppose we want to answer the question: What is
the maximum number of sub-areas formed in the plane by n lines? First we can
play around with some diagrams to get a hunch. But how do we know our hunch
is correct? Call the hunch a hypothesis. Prove that the hypothesis is correct for
base cases, for example one line in the plane. Then using mathematical induction, we prove the hypothesis correct for n lines, where n can be any natural
number.
This may seem simple, but there are a number of subtle points that make it
worthwhile to look at some examples. One diculty is that the hunch can be
wrong. Suppose a circle is drawn and n points are distributed evenly around
the circle. Now draw line segments between every pair of these points. The rst
few cases are:
1
1
2
2
4
3
2
1
5
6
7
8
4
3
1
What is the resulting number of regions carved up in the circle? It looks at
rst like the formula 2(n;1) must be the number of regions | it certainly is for
n = 1 2 3. What about n = 4? It works for that as well. But in order to
prove this formula correct, we need to use induction. Unfortunately, this is not
possible, because the hunch is wrong!
There are other common mistakes in the use of induction, which are best illustrated with examples (found in many textbooks). The mistakes usually have to
do with \boundary cases" for proving the hypothesis correct | for instance, the
hypothesis is proved correct for all but one instance.
3 Ingredients of Induction
All proofs by induction have the following ingredients:
A countable (meaning nite or in a one-to-one correspondence with the naturals) domain of hypotheses. Although introductory examples are proofs
of formulas with natural numbers, we can generalize the idea to any set
that corresponds to natural numbers. In order to prove a proposition
P, we nd some way to express the proposition in terms of hypotheses,
H1 H2 H3 : : : so that P = fH1 H2 H3 : : :g.
Base cases. Some subset of the hypotheses is directly shown to be true.
Usually one just proves H1 is true by some simple argument.
The chain of implications. To illustrate this idea, we use a diagram where
the arrows stand for implication. An implication of the form
(A
^
B
^
C)
)
Z
is represented as
C
A
Z
B
A chain of implications is a structure represented by a diagram where
the hypotheses H1, H2, H3, : : :are nodes, arrows between hypotheses
are implications, and there is a special base node. For this chain to be
valid each arrow must represent a proven implication and there must be
a path, starting from base, to every hypothesis. The most common form
of diagram is
base ;! H1 ;! H2 ;! H3 ;! ;! Hk ;! Hk+1 ;! 2
(note that the diagram is innite). The truth of hypothesis Hk is implied
transitively by the truth of H1. The \cookbook" recipie for induction is
to prove the base case, which is the arrow from base to H1, and then
prove that every arrow from Hi to H(i+1) is an implication, where i is any
natural number. This method assures a valid chain. But there are other
possibilities, for instance
base ;! H1 ;! H3 ;! H5 ;! base ;! H2 ;! H4 ;! H6 ;! is also a valid chain it uses the cookbook method separately for the odd
and even numbers. Another possibility is so-called strong induction, which
is too complicated to show easily with a diagram we show only the arrow
pointing to hypothesis Hk+1:
H.0 H.1 H.2 H.3 ... H.k
•••
H.(k+1)
In words, the truth of all of hypotheses H0 H1 H2 H3 : : : Hk taken together imply the truth of H(k+1).
Yet another variation arises from taking more unusual domains of hypothesis. For instance, we may want to prove a fact about certain kinds
of data structures using induction on the size of the data structure. Suppose the size of the data structure is measured in bytes, but the size is
always a multiple of eight. Then we might have as a set of hypotheses
H8 H16 H32 : : : Since this is a countable set of hypothesis, the cookbook
method works: H8 must be proved true then it must be shown that Hk
implies Hk+8 for any k that is a multiple of eight.
Less obvious is the way to treat two-dimensional hypotheses. Suppose the
set of hypotheses consists of Hij for every possible combination of natural
numbers i and j. Although it may not be immediately apparent, this is a
countable set of hypotheses. A possible induction chain could be
3
base
H.1.1
H.1.2
H.1.3
•••
H.2.1
H.2.2
H.2.3
•••
H.3.1
H.3.2
H.3.3
•••
•••
•••
•••
•••
(In the above diagram, Hij is denoted by H.i.j). The proof method for
this diagram is to show rst the base case H11 is true then prove for any
j, that Hij implies H(i+1)j for all i | this corresponds to proving all the
downward arrows nally, prove for any i, that Hij implies Hi(j +1) for all
j. Sometimes this, or a similar technique, is called double induction: it is
quite similar to nested iteration in programs that process matrices.
4 Implication is the Engine
Although the general outline of induction shows how to correctly set up a chain
of implications, no advice is yet given on how to prove an implication. It is
useful to consider some facts about implication. The simple \A implies B" can
be stated in a number of ways:
A ) B :A _ B
A ) B :B ) :A
(A ) B ^ B ) C) ) (A ) C)
A ) B (A _ B) = B
A ) B (A ^ B) = A
A ) B (A ^ :B) ) false
A ) true true
A ) false (A = false )
Each of these re-writings of \A implies B" gives us a dierent way to prove the
implication. Two ways of proving this implication deserve special mention:
The indirect proof method consists of starting with some known fact, for
example 1 > 0, and then transforming that fact into other facts by rules
4
of arithmetic, logic, or other proven theorems. For instance, from 1 >
0 and because adding x to both sides is an equivalent relation, we get
x + 1 > x + 0. This process of transforming an established fact to another
is continued, but somewhere along the line we assume that A is true to
make a transformation. If A is the only extra assumption, and the series
of transformations ends up with B, then we have an indirect proof that A
implies B.
Working backwards is often helpful. Instead of trying to prove that A
implies B, try instead to prove that for B to be true, A must be true as
well. In other words, B \follows from" A.
5 A Proof Format
Proofs can sometimes get to be complicated arguments. Good formatting can
help us to understand proofs just as indenting program text in the appropriate
way for if and for keywords helps us to read programs. Suppose we want to
prove something like A = B and the proof consists of several steps. First, it is
shown that A = A1 using some law of algebra. Then it is shown that A1 = A2 ,
then A2 = B. Therefore, by transitivity, A = B is true. A nice way to format
this is:
A
= f hint or explanation on why A = A1 g
A1
= f hint or explanation why A1 = A2 g
A2
= f hint or explanation why A2 = B g
B
If you read this format's left column, you only see equal signs (=) { which means
the proof is just shows that the rst line and last line are mathematically equal.
An advantage of this format is that you have a built-in way to comment the
reasoning for each step using the f hint g lines. The same format can also be
used to show implications, for example, that A implies B:
A
= f hint or explanation on why A = A1 g
A1
) f hint or explanation why A1 ) A2 g
A2
= f hint or explanation on why A2 = A3 g
A3
) f hint or explanation why A3 ) A4 g
5
A4
= f hint or explanation why A4 = B g
B
This example also uses transitivity (implication is transitive). Again, if we
just read the left column, it only contains equal signs and implications, so the
structure of the proof is clear | the rst line implies the last line. The exact
same proof could also be presented in reverse:
B
= f hint or explanation why A4 = B g
A4
( f hint or explanation why A4 ( A3 g
A3
= f hint or explanation on why A2 = A3 g
A2
( f hint or explanation why A2 ( A1 g
A1
= f hint or explanation on why A = A1 g
A
Reading the left column, the structure is clear: the rst line is implied (transitively) by the last line.
There are a number of variations on this format. For instance, instead of proving
equivalence or implication, numeric inequalities can be shown in a similar way.
The most important thing to remember is: the left column never changes the
\direction" of its operators | for instance, you never have a right double-arrow
implication and then a few lines later a left double-arrow (reverse implication).
The proof format introduced here is an excellent way to present indirect proofs
of implication. Suppose we need to show that Hk implies H(k+1), where Hk is
some formula of natural numbers m and k.
true
= f the squares of natural numbers are positive g
m2 > 0
= f assume that hypothesis Hk is true g
H(k+1)
When you read the left column, you see the proof as an equivalence between true
and H(k+1). But because Hk was assumed to make one of the steps possible, the
proof is actually an indirect proof that Hk implies H(k+1).
Danger! The `=' appearing in the left column is not equality in the sense of
numeric equality. Perhaps more appropriate would be the symbol , or , since
the meaning intended is \if and only if". In other words, when you see
6
A
= f hint or explanation why A = B g
B
the two statements A ) B and B ) A should be true. Here is an example of
an incorrect step:
x = a+b
= f multiply both sides by (m ; 1) g
(m ; 1)x = (m ; 1)(a + b)
The problem is that, although this step looks correct reading from top to bottom
(the ) direction of `=' in the left column), the other direction (the ( direction)
is not correct unless we know something about m. To be more specic, consider
the step
(m ; 1)x = (m ; 1)a + b
= f divide both sides by (m ; 1) g
x = a+b
But this step only makes sense if (m ; 1) 6= 0! In summary, every time you see
an `=' in the left column, the step from one line to the next should be correct in
both forward and backward directions.
6 Learning Induction: Forward and Backward
In earlier courses, you learned how to prove induction using forward implication,
meaning that you proved H(k+1) by assuming that Hk is true. In symbols, you
proved that Hk ) H(k+1) holds for all k starting from the base case for k. The
rst valuable principle for scientic analysis of algorithms is:
It is often useful to reason about a property by reasoning backwards
| asking what would need to be true in order for the property to
hold.
Although this will initially seem unnatural in some instances, it is really just
the standard, rational sort of deduction that a detective | or scientist | uses
to form and validate a theory. This principle applied to induction is just the
following question: what would need to be true in order for H(k+1) to also be
true? There could be many answers to such a question, but if Hk being true is
enough ammunition to show that H(k+1) is true, we have the implication part
of the induction: the reverse implication H(k+1) ( Hk is exactly what must be
shown (plus the base case, of course).
7
7 Examples of Induction
Here are some examples of induction. Most of the problems are simple and
could be proven without using induction however they are short examples and
illustrate some of the techniques used on larger problems. Examples 1{4 are
the familiar \formula" kind of induction, where the hypotheses have to do with
arithmetic of natural numbers. Examples 5{7 are perhaps less familiar, since
they have a geometric avor.
7.1 Example 1
Show for integer x satisfying x > 1 and n a positive integer, that (xn) ; 1 is
equal to some integer multiplied by (x ; 1).
Solution
Proof by induction on n. First, let us dene the hypothesis Hi to be the statement
\m(x ; 1) = (xi ) ; 1 for some integer m".
The base case for the induction chain is the smallest i | so H1 must be shown
correct. This is easy to do, since x1 is just x, and the equality is trivially true.
To show H(i+1) ( Hi , which completes the induction chain, let us use a backward
and indirect approach. We start with H(i+1), which requires us to show that
m(x ; 1) = (x(i+1) ) ; 1 is true for some integer m. Notice that we can directly
compute m by the formula m = ((x(i+1) ) ; 1)=(x ; 1), but we don't know from
this formula whether or not m is an integer. The problem is then to show,
starting from m(x ; 1) = (x(i+1)) ; 1, that m is an integer.
m(x ; 1) = xi+1 ; 1
= f simplify right-hand side of the equality g
m(x ; 1) = (x xi ) ; 1
= f arithmetic to isolate the form of Hi g
m(x ; 1) = (x ; 1) + x(xi ; 1)
= f assume Hi is true, i.e. xi ; 1 = m0 (x ; 1) for some natural number m0 g
m(x ; 1) = (x ; 1) + xm0 (x ; 1)
= f we know (x ; 1) is positive since x > 1 divide all terms by (x ; 1) g
m = 1 + xm0
) f all that's needed is to show that m is a postive integer
because x and m0 are positive integers, we deduce that g
m is an integer
Look carefully at this example. The proof of the reverse implication of H(i+1)
from Hi is indirect the way that the form of Hi was \discovered" by starting
with H(i+1) is a useful technique. But wait! Doesn't the last step of the proof
8
go in the wrong direction ()) if we want a backward induction? The answer is
no, because the proof that m is an integer, starting from the formula for H(i+1),
used Hi, so the proof is indeed an indirect proof that H(i+1) ( Hi .
7.2 Example 2
Show that (1=2) + (1=4) + (1=8) + + (1=2n) is less than one.
Solution
Proof by induction on n. The hypothesis Hi is the inequality
(1=2) + (1=4) + (1=8) + + (1=2i) < 1
Again, we start with H(i+1) and work backwards:
H(i+1)
=fP
by denition g
i+1 1 < 1
k=1 2k
= f isolatePthe form of Hi using arithmetic g
1 + 1 i 1k < 1
2 2 k=1 2
= f subtract
1=2 from each side g
1 Pi 1k < 1
2 k=1 2
2
=fP
multiply both sides by two g
i 1 <1
k=1 2k
= f by denition g
Hi
Unfortunately, this proof has a bug | can you see what it is?
7.3 Example 3
Prove that for any positive natural number n, if x > ;1, then (1+x)n (1+nx).
Solution
We dene the hypothesis Hn to be (1 + x)n (1 + nx).
The basis of the induction is n = 0. We verify H0 :
(1 + x)0 (1 + 0x)
= f algebra g
11
= f trivial g
true
9
What remains is to prove all the implications: for n 0, we need to show H(n+1)
follows from Hn. The \dierence" between Hn and H(n+1) is multiplying by
(x + 1), so we try to manipulate H(n+1) to uncover Hn:
H(n+1)
= f by denition g
(1 + x)n+1 1 + (n + 1)x
( f observe: a b ( a b + c if c 0 | then notice that nx2 0 g
(1 + x)n+1 1 + (n + 1)x + nx2
= f more algebra to collect terms: try to get \form" of Hn g
(1 + x)(1 + x)n 1 + nx + x + nx2
= f algebra to collect right-hand side terms g
(1 + x)(1 + x)n (1 + nx)(1 + x)
= f divide both sides by (1 + x) g
(1 + x)n 1 + nx
= f by denition g
Hn
Reading top to bottom, the proof shows H(n+1) ( Hn.
7.4 Example 4
Show that if ai = ai;1 + C holds for all positive i, then
Xn a = n + 1 (a
i=0
i
2
0 + an )
holds for all natural numbers n (where C is some constant value).
Solution
Hypothesis Hn consists of the above summation formula. The base case H0 is
veried by
H0
=fP
by denition g
i=0 a = 0+1 (a + a )
i=0 i
2 0 0
= f simplify both sides g
a0 = 12 (2a0 )
= f both sides are equal g
true
We'll show H(n+1) is implied by Hn | proceeding backwards | and looking
for the pattern of Hn by playing around with H(n+1).
10
H(n+1)
=fP
by denition g
i=n+1 a = n+2 (a + a )
i
i=0
2 0 n+1
= f arithmetic
g
P
2 ii==0n+1 ai = (n + 2)(a0 + an+1 )
= f rewritePleft-hand sidePto get sums with Hn pattern g
(a0 + ii==1n+1 ai ) + ( ii==0n ai ) + an+1 = (n + 2)(a0 + an+1 )
= f subtract
P a0 and Pan+1 from both sides g
( ii==1n+1 ai) + ( ii==0n ai ) = (n + 1)(a0 + an+1 )
= f apply Hn to both terms on left-hand side |
this is possible because both are sums of (n + 1) terms notice
that Hn is used twice, and in two dierent ways! g
n+1 (a0 + an) + n+1 (a1 + an+1 ) = (n + 1)(a0 + an+1 )
2
2
= f substitute a1 = a0 + C and an+1 = an + C g
n+1 (a0 + an) + n+1 (a0 + an + 2C) = (n + 1)(a0 + an + C)
2
2
= f collect terms g
n+1 (2a0 + 2an + 2C) = (n + 1)(a0 + an + C)
2
= f arithmetic g
(n + 1)(a0 + an + C) = (n + 1)(a0 + an + C)
= f trivial g
true
This is a good example of indirect proof of the implication the \application"
of the Hn equality allows us to conclude that H(n+1) is true. Most students
solve this problem another way: rst, using induction, prove that ai = a0 + iC.
After this has been proved by induction, then prove the base case H0 and then
show that H(n+1) ( Hn using the previously shown ai = a0 +iC to simplify the
algebra.
7.5 Example 5
Denition This is a geometric problem about regions in the plane. Instead of
a formal denition of regions in words, the following diagram shows the various
cases of regions.
(In this diagram, lines are understood to be innitely long). There are nine
11
regions in this diagram | six are innite (open regions) and three are nite
(enclosed regions). The gure also contains ve intersection points.
Problem Show that if n lines in the plane are arranged so that no two lines
are parallel and no three lines having a common intersection, then the number
of regions is 1 + (1=2)n(n + 1).
Solution
Let Hn be the statement of the problem for n lines. To verify the base case,
consider the following diagram, which depicts H1, H2, and H3. (This is not
necessary | we could start with H0 as the base case, since 1+(1=2)0(0+1) = 1
and the entire plane is one region | that shows H0 is true.)
2
2
1
3
1
3
1
7
2
n=1
4
6
5
n=2
4
n=3
The base case is checked. Now it remains to complete the induction chain by
proving that H(n+1) ( Hn. The hypothesis is not, however, a simple statement
about integers. Each hypothesis is a statement about innitely many arrangements of lines in the plane. For instance, there are an innite number of ways
to array six lines (with no two parallel, no three intersecting at any point), yet
there is one hypothesis H6 ! Thus H6 is a statement about an innite number
of cases of six lines in the plane. What will enable us to use induction is the
following key observation:
Every arrangement of (n + 1) lines in the plane can be obtained by
adding some line to an arrangement of n lines.
Conversely, some arrangement of n lines can be can be obtained by
removing some line from any arrangement of (n + 1) lines.
Based on this observation, the way to show that H(n+1) ( Hn is clear: for
H(n+1) to be true for every possible arrangement of (n + 1) lines in the plane,
then we only need to consider removing a line from an arrangement of (n + 1)
lines to obtain an arrangement of n lines and use the hypothesis that Hn holds.
Back to the proof. Consider removing a line L from an arbitrary conguration
of (n + 1) lines. Since no two lines are parallel, the removed line L intersected
all the remaining n lines exactly once in the conguration. And because no three
12
lines intersect at any point, no intersection of L simultaneously intersected more
than one line. Therefore removing L removes n intersections. Also, removing
L joins together regions that were previously separated by L. How may regions
are joined together by removing L? Imagine a point p on L that is not between
any of the intersections point p is \outside" all of the enclosed regions, as in the
diagram:
p
The part of L that contains p separates two regions that will be joined when L is
removed. If we trace the path from p towards and through all the intersections,
we nd that prior to each new intersection, removing L joins two regions. Also,
along this tracing, the part of L following the nal intersection also joins two
regions. To sum up, since there are n intersections, (n+1) regions will be joined
when L is removed. The number of regions as a result can be calculated: take
the number of existing regions before removing L and subtract (n+1) to account
for the regions joined. By hypothesis Hn , the conguration after removing L
contains 1 + (1=2)n(n + 1) regions. The number of regions before removing L is
therefore
+ 2)
1 + n(n2+ 1) + (n + 1) = 1 + (n + 1)(n
2
which proves H(n+1) ( Hn.
7.6 Example 6
Show that the largest number of intersections that n circles can make on the
plane is n(n ; 1).
Solution
The hypothesis Hn is that n circles can make at most n(n ; 1) intersections.
The base case, H1 is easy to verify since one circle has no intersections.
Before working on the implication chain, let's look at the possibilities for two
circles and intersections:
13
or
or
or
From the diagram we see that two circles can make zero, one or two intersections
| so the maximum number of intersections for two circles is two. In general,
it is possible that each of n circles intersects every other circle twice | and to
make the number of intersections as large as possible, we suppose that there is
no point at which three circles intersect1 .
The previous paragraph characterizes an arrangement of n circles to have the
maximum number of intersections. By the same kind of argument given in x??,
some conguration of n circles can be obtained by removing a circle from any
conguration of (n + 1) circles. To prove that H(n+1) ( Hn, consider removing
a circle from a conguration of (n + 1) circles. The removed circle can intersect
each other circle at most twice, so at most 2n intersections are lost by removing
one circle. The total number of intersections is calculated by adding 2n to the
n(n ; 1) intersections given by Hn, which is
2n + n(n ; 1) = 2n + n2 ; n = n2 + n = (n + 1)n
and this total for (n + 1) circles proves H(n+1) ( Hn.
7.7 Example 7
Call two regions in the plane adjacent if there is a line segment common to both
regions (regions are not adjacent if they share only points in common). For
example,
1 To see how such an arrangement is possible, draw a single circle in the plane of radius
1 ; ", for some small positive real number ". Distribute k points, evenly on this circle. Now
erase the circle, but leave the k points. Let there be a circle of radius 1 around each one of
the k points. There will be k circles, and each will intersect the (k ; 1) other circles in two
points. Also, no intersection point is shared by more than two circles.
14
X
Y
Z
X and Y are not adjacent
X and Z are adjacent
X and Y are not adjacent, because these two regions intersect at two points,
but have no line segment in common. The problem is to show that the regions
in the plane formed by n circles can be colored with only two colors so that no
two adjacent regions have the same color.
Solution
The induction is on the number of circles. The hypothesis Hn is that regions
formed by Hn circles can be colored with only two colors so that no adjacent
regions have the same color.
The basis of the induction, H1, is trivial since we can color the one circle blue
and color the rest of the plane red.
To prove H(n+1) ( Hn, consider removing some circle C in a conguration of
(n + 1) circles. Notice that removing C joins existing regions { because the C
is either entirely within an existing region or because C may intersect partially
with several regions. After removing C, by the hypothesis Hn, the conguration
can be colored with two colors. Call X the conguration after removing C, but
colored with exactly two colors (possible by Hn). Now we can consider adding
C back, exactly where it was, and selectively changing some region's colors. For
every region inside the circle C, reverse that region's color (red to blue and blue
to red). This new conguration satises H(n+1) because:
For regions outside C, adjacency relations are unaected.
For regions entirely within C, any adjacency relation remains true because
both colors are involved in the switch.
For regions that are crossed (i.e. created) by C's perimeter, the part
outside C remains its original color while the part inside C will have the
color opposite to the original color | so these adjacent regions will have
opposite colors.
There are no other cases.
No new colors are introduced.
15
7.8 Example 8
Denition A tree is a set of nodes and a set of links connecting these nodes
so that (1) every link connects a pair of nodes, (2) there is a sequence of links
connecting every two nodes, and (3) there is no cycle of links connecting a node
to itself. The following diagram illustrates cases of trees and non-trees.
non-tree
(has cycle)
non-tree
(disconnected)
tree
Problem Show that a tree of n nodes contains exactly (n ; 1) links.
Solution
Although it may seem obvious to induct on n, the number of nodes in a tree, the
reason for doing so is complicated. Just as with the geometric problem of lines
in the plane (see x??), an appropriate induction chain must rst be set up.
The hypothesis Hn is: a tree of n nodes contains exactly (n ; 1) links. To show
H(n+1) ( Hn, we must show \any tree of (n+1) nodes contains n links" follows
from \any tree of n nodes contains (n ; 1) links. The method is exactly the
same used for the key observation of x??:
Every tree of (n + 1) nodes can be obtained by adding one node and
one link to some tree of n nodes.2
Conversely, some tree of n nodes can be can be obtained by removing
a link and a node from any tree of (n + 1) nodes.
Based on this observation, the way to show that H(n+1) ( Hn is clear: we only
need to consider removing a node and a link to a tree of (n + 1) nodes to obtain
a tree of n nodes.
2 To see that this is true, observe that every non-empty tree has at least one node p with
only one link attached to p | otherwise we could make a cycle of links from p to itself, which
contradicts the denition of a tree. So by removing p and the single link attached to it, all the
other nodes remain connected in a tree of n nodes.
16
Back to the proof. We take H1 as the base case, which is a single node with no
links | and that validates H1. To prove the induction chain, let Tk be the set
of all trees of k nodes. Consider any tree S in T(n+1) | such a tree S has more
than one node. Find a node s in S that is a leaf, meaning that it is connected
to only a single link. Now remove s and the link connected to s. The result is
a tree with n nodes and one fewer link than S has. By hypothesis Hn, every
tree in Tn has (n ; 1) links. This implies S has n links. Because S was chosen
arbitrarily from T(n+1) , the theorem is proved.
7.9 Example 9
Consider a triangular layout of the odd natural numbers in the format
row
row
row
row
row
...
1
2
3
4
5
-->
-->
-->
-->
-->
21
13
7
3
1
5
11
17 19
23 25 27 29
...
15
9
Show using induction that the sum of numbers in row i is i3 .
Solution
This problem is a theorem of Nicomachus (circa 100 A.D.) for which there are
many solutions. The one presented here is a straightforward use of induction.
First, what do we know? The following facts need no proof, since they are part
of the problem's denition:
(1) The rst row consists of the single number one.
(2) There are k numbers in row k.
(3) The rst number in row (k + 1) equals the last number in row k plus two.
(4) Each successive number within a row is two larger than the number that
comes before it.
It is helpful to introduce some notation for the rows and numbers. Let dkj denote
the j-th number in row k. The problem is then to show:
Xk d
j =1
kj = k3
The rst thing to do is exploit property (4) in the summation. Therefore, we
need a small (but obvious) lemma:
17
Claim: dkj = dk1 + 2(j ; 1). The proof of the claim is by induction.
The hypothesis Hj is just the claim.
The base case is H1: dk1 = dk1 + 2(1 ; 1) veries the base case.
Now let's start with H(j +1):
H(j +1)
= f by denition g
dk(j +1) = dk1 + 2((j + 1) ; 1)
= f by arithmetic g
dk(j +1) = dk1 + 2j
= f by property (4) g
dkj + 2 = dk1 + 2j
= f arithmetic g
dkj = dk1 + 2(j ; 1)
= f assume that the inductive hypothesis Hj is true g
true
And this argument proves, indirectly, that H(j +1) ( Hj .
The claim shown above can now be used to restate the main theorem, by substituting the formula for dkj in the summation. We need to show
Xk d
j =1
k1 + 2 (j ; 1) = k3
This sum can be simplied using arithmetic:
Pkj=1 dk1 + 2(j ; 1) = k3
=fP
split the sum into
two sums g
P
k d
k 2(j ; 1) = k3
+
k
1
j =1
j =1
= f simplify the P
rst sum using arithmetic g
k dk1 + kj=1 2(j ; 1) = k3
= f factor 2 out ofPthe sum, substitute j + 1 for j in the summation g
;1 j = k3
k dk1 + 2 kj =0
= f use fact known from 22C:019: 1 + 2 + + n = n(n + 1)=2 g
k dk1 + 2k(k ; 1)=2 = k3
= f arithmetic g
k(dk1 + (k ; 1)) = k3
Now the proof obviously boils down to nding some expression for dk1. We can
use property (3), which will give us dk1 = 2 + d(k;1)k, but does this help? We
can further simplify using the formula above for numbers in each row to get
18
dk1 = d(k;1)1 + 2k, but the game continues. Now we need to nd an expression
for d(k;1)1, which will be in terms of d(k;2)1 and so on. After some playing
around, we come up with the following hypothesis: dk1 = 1+k(k ; 1) { call this
hypothesis Hk. Using induction, we prove that Hk is true for all k. The base
case H1 is easy:
d11 = 1 + 1(1 ; 1) = 1
And this is true by property (1). Now to show that H(k+1) ( Hk , so we start
with H(k+1):
H(k+1)
= f by denition g
d(k+1)1 = 1 + (k + 1)k
= f use property (3) and (2) to rewrite d(k+1)1 g
dkk + 2 = 1 + (k + 1)k
= f use the formula proved in the claim above to rewrite dkk g
dk1 + 2(k ; 1) + 2 = 1 + (k + 1)k
= f arithmetic g
dk1 + 2k = 1 + (k + 1)k
= f use hypothesis Hk to simplify dk1 g
1 + k(k ; 1) + 2k = 1 + (k + 1)k
= f subtract 1 from each side g
k(k ; 1) + 2k = (k + 1)k
= f arithmetic g
k((k ; 1) + 2) = (k + 1)k
= f arithmetic g
k(k + 1) = (k + 1)k
= f arithmetic g
true
By the indirect method, this shows H(k+1) follows from Hk and completes the
proof that dk1 = 1 + k(k ; 1). But to nish the theorem, we still must show
k(dk1 + (k ; 1)) = k3
= f now substitute expression for dk1 proved above g
k(1 + k(k ; 1) + (k ; 1)) = k3
= f arithmetic g
k(1 + (k + 1)(k ; 1)) = k3
= f arithmetic g
k(1 + k2 ; 1) = k3
= f arithmetic g
k3 = k3
= f obvious g
true
And the theorem is proved.
19
7.10 Example 10
Prove the following three inequalities using induction:
1. For all positive integer n,
Xn i n2
i=1
2. For all positive integer n and any xed positive integer p,
Xn ip
i=1
np+1
3. Given are K a positive integer and a set A of positive integers
A = f a1 a2 a3 : : : g
such that each element of A is less than or equal to K. Prove:
Xn a kp
k=1
Solution
(1) For the rst problem, dene
Hn
k
Knp+1
Xn i n2
i=1
The base case H1 is veried by substitution:
X1 i = 1 12
For the induction,
i=1
H(n+1)
=fP
by denition g
n+1 i (n + 1)2
i=1
= f arithmeticPg n
(n + 1) + i=1 i n2 + 2n + 1
=fP
subtract
(n + 1) from both sides g
n i n2 + n
i=1
( f we know n 1 and the law, for positive a:
Pni=1 i b n2 c ) b c + a g
= f denition g
Hn
20
(2) For the second problem, dene
Hn
Xn ip
i=1
np+1
The base case H1 is veried by substitution:
X1 ip = 1p 1p+1
i=1
For the induction,
H(n+1)
=fP
by denition g
n+1 ip (n + 1)p+1
i=1
= f arithmetic gPn
(n + 1)p + i=1 ip (n + 1)(n + 1)p
=fP
subtract
(n + 1)p from both sides g
n ip n(n + 1)p
i=1
( f we know n 1 and the law, for positive a and c, a < c:
Pni=1 ip nbp+1ak+1 ) b a ck g
= f denition g
Hn
The above derivation, read bottom to top, shows that Hn implies H(n+1) as
needed.
(3) The third problem is to show
Xn a ip
i=1
i
Knp+1
This is best done by showing rst that
Xn a ip Xn Kip
i=1
i
i=1
= K
Then by the result of problem (2), we get
K
Xn ip
i=1
Xn ip
i=1
Knp+1
Therefore, by transitivity the problem is solved. To be absolutely correct, we
can prove the distributive property
Xn a ip Xn Kip
i=1
i
i=1
by induction, but that we'll take that law of algebra over inequality for granted
here.
21
7.11 Example 11
Suppose n points are placed on a circle, equally spaced apart. Suppose a point
can be colored either red or blue. Prove, using induction, that if n is an even
number, then the n points can be colored so that colors alternate going around
the circle.
Solution
Let Hk be the inductive hypothesis, dened as follows: if there are 2k points on
the circle, they can be colored so that colors alternate red and blue. The basis
for the induction can be H0 or H1 in the case of H1 the circle has two points
and they are red and blue. For the induction, take any circle of 2(k + 1) points.
Then remove any consecutive pair (p q) of points, which leaves a circle of 2k
points. By hypothesis, the circle of 2k points can be colored alternately red and
blue. Now insert the points (p q) exactly where they were removed: this means
(p q) are inserted between two points (s t). If s is red, then t is blue { so we
color p and q so that colors alternate. This makes a circle of 2(k +1) points with
alternating colors nally we can \slide" the points so as to redistribute them so
they are equally spaced.
7.12 Example 12
This is a problem related to chessboards. A triomino is an L-shaped object
that covers three squares. It is a fact that triominos can cover all except one of
the squares of a 2n 2n chessboard, for any n > 0. For instance, the following
diagram shows how all but one square covered can be covered on an 8 8
chessboard.
Prove, by induction on n, that triominos can be arranged to leave any desired
square uncovered in a 2n 2n chessboard, while all the other squares are covered.
(Note that triominos don't overlap in a covering.)
22
Solution
Let Hn be \Any 2n 2n chessboard can be covered by triominoes so that every
square except one desired square is covered". To prove that Hn is true for all
n, n 1, induction is used:
Basis n = 1. A single triomino covers all but one square of a 2 2 board, and
rotating the triomino allows us to leave any of the 4 squares uncovered.
Induction n 1. Suppose we have a 2n+1 2n+1 chessboard. To prove that
H(n+1) holds, we must show that triominoes can cover all the squares
except one desired square. Call this desired square p (there are 22n+2
possible locations for p). The 2n+1 2n+1 chessboard can be seen as four
2n 2n chessboards. The square p therefore lies in exactly one of these
four 2n 2n boards, call it board A (and call the remaining three boards
B, C, and D). If Hn is true, then p can be uncovered in board A and all
the remaining squares of board A are covered by triominoes | and none
of these triominoes goes outside the border of board A. Similarly, if Hn
is true, then one of the corners of board B can be left uncovered, while all
the remaining squares are covered by triominoes. The same observation
holds for C and D. Therefore we can leave four squares uncovered on the
2n+1 2n+1 board, where one of the four squares is p and the other three
are at corners (marked by x in the gure below):
x
x
x
p
2
n
2
n+1
Now we only need to observe that a single triomino can t in the three
x squares (by choosing the open x squares in the right way), and this
constructs a covering of the 2n+1 2n+1 board leaving only the square p
uncovered, thus proving H(n+1) is true for any chosen location for p.
7.13 Example 13
Prove that any integer postage value greater than 7 cents can be formed using
only 3-cent and 5-cent stamps.
23
Solution
First, a sketch of the argument. Suppose we have some large postage amount,
for instance $100.01. We can write 100:01 = 50:00 + 50:01. And by induction,
we assume that both $50.00 and $50.01 can be made from 3-cent and 5-cent
stamps, so it is clear that $100.01 can be made by 3-cent and 5-cent stamps.
The induction is then H10001 ( H5000 ^ H5001. But what about the basis?
Clearly, this idea of \dividing in half" (or approximately in half) works for every
Hk provided k=2 > 7. But that leaves H7, H8, : : :, H13 needing some other kind
of proof: they are the base cases. Each of these can be proved directly by playing
around with a few 3-cent and 5-cent stamps.
More formally, we prove the hypothesis Hk , that k cents can be composed of
three and ve cent amounts, for any k > 15. If k is even, then k = m + m,
where m = k=2. By hypothesis Hm , the m cent amount can be composed of
three and ve cent amounts. If k is odd, then k = m + m0 , where m = (k ; 1)=2
and m0 = (k + 1)=2. By hypotheses Hm and Hm , the amounts m and m0 can
be made of three and ve cent stamps. Therefore, for either odd or even k, Hk
follows from some hypotheses with smaller index than k. The base cases are Hi
for i 2 f8 : : :15g. Verication of the base cases is left to the reader.
0
7.14 Example 14
Let f(k) be a function that takes a positive integer and returns a positive integer
f(k) also has the peculiar property that
f(f(k)) < f(k + 1)
for any positive integer k. Prove that
(8n : n j ) f(n) j)
is true for all positive numbers j, by induction on j.
Solution
Base case, j = 1:
n 1 ) f(n) 1
Since f(n) always returns a positive integer this implication is true.
Induction Starting with Hj+1, for positive j,
(8n : n (j + 1) ) f(n) (j + 1))
= f express inequality dierently using fact that f(n) is a positive integer g
(8n : n > j) ) f(n) > j)
24
(f
use the curious property of f and transitivity g
(8n : n > j
)
f(f(n ; 1)) j)
( f Here a small discussion helps. Under the condition n > j, it follows that
(n ; 1) j. By the hypothesis Hj , we see that f(n ; 1) (n ; 1). So the
formula above will be true if we prove the following more general formula g
(8m : m > j
)
f(m ; 1) j)
This formula is more general because, some value in the range of (m ; 1) has to
be equal to f(n ; 1) since f(n ; 1) always returns a positive integer greater than
or equal to (n ; 1) by hypothesis Hj and (m ; 1) is quantied over all integers
greater than or equal to j.
= f rewrite the rst inequality g
(8m : m ; 1 j
)
f(m ; 1) j)
= f since (m ; 1) is a positive integer (because j is positive), we simply substitute
k for (m ; 1) in the terms to get g
(8k : k j
= f by denition g
)
Hj
25
f(k) j)