• No results found

2.4 ➜ Mathematical Induction

Applying (2.3.1) to expressions 4 and 7, we derive 8. d.

Now 5 and 8 combine to give a contradiction, and the proof is complete.

It can be shown that resolution is correct and refutation complete. “Resolution is correct” means that if resolution derives a contradiction from a set of clauses, the clauses are inconsistent (i.e., the clauses are not all true). “Resolution is refutation complete”

means that resolution will be able to derive a contradiction from a set of inconsistent clauses. Thus, if a conclusion follows from a set of hypotheses, resolution will be able to derive a contradiction from the hypotheses and the negation of the conclusion. Un-fortunately, resolution does not tell us which clauses to combine in order to deduce the contradiction. A key challenge in automating a reasoning system is to help guide the search for clauses to combine. References on resolution and automated reasoning are [Gallier; Genesereth; and Wos].

Problem-Solving Tips

To construct a resolution proof, first replace any of the hypotheses or conclusion that is not a clause with one or more clauses. Then replace pairs of hypotheses of the form p∨ q and ¬p ∨ r with q ∨ r until deriving the conclusion. Remember that resolution can be combined with proof by contradiction.

Section Review Exercises

1. What rule of logic does proof by resolution use?

2. What is a clause?

3. Explain how a proof by resolution proceeds.

Exercises

1. Write a truth table that proves (2.3.1).

Use resolution to derive each conclusion in Exercises 2–6. Hint:

In Exercises 5 and 6, replace→ and ↔ with logically equivalent expressions that use or and and.

2. ¬p ∨ q ∨ r

¬q

¬r

¬p

3. ¬p ∨ r

¬r ∨ q p

q

4. ¬p ∨ t

¬q ∨ s

¬r ∨ st p∨ q ∨ r ∨ u

s∨ t ∨ u

5. p→ q p∨ q

q

6. p↔ r r

p

7. Use resolution and proof by contradiction to reprove Exer-cises 2–6.

8. Use resolution and proof by contradiction to reprove Exam-ple 2.3.6.

2.4 ➜ Mathematical Induction

Suppose that a sequence of blocks numbered 1, 2,. . . sits on an (infinitely) long table (see Figure 2.4.1) and that some blocks are marked with an “X.” (All of the blocks visible in Figure 2.4.1 are marked.) Suppose that

The first block is marked. (2.4.1)

For all n, if block n is marked, then block n+ 1 is also marked. (2.4.2) We claim that (2.4.1) and (2.4.2) imply that every block is marked.

1 x 2 x 3 x 4 x 5 x

Figure 2.4.1 Numbered blocks on a table.

We examine the blocks one by one. Statement (2.4.1) explicitly states that block 1 is marked. Consider block 2. Since block 1 is marked, by (2.4.2) (taking n= 1), block 2 is also marked. Consider block 3. Since block 2 is marked, by (2.4.2) (taking n = 2), block 3 is also marked. Continuing in this way, we can show that every block is marked.

For example, suppose that we have verified that blocks 1–5 are marked, as shown in Figure 2.4.1. To show that block 6, which is not shown in Figure 2.4.1, is marked, we note that since block 5 is marked, by (2.4.2) (taking n= 5), block 6 is also marked.

The preceding example illustrates the Principle of Mathematical Induction. To show how mathematical induction can be used in a more profound way, let Sn denote the sum of the first n positive integers:

Sn= 1 + 2 + · · · + n. (2.4.3)

Suppose that someone claims that Sn= n(n+ 1)

2 for all n≥ 1. (2.4.4)

A sequence of statements is really being made, namely, S1= 1(2)

2 = 1 S2= 2(3)

2 = 3 S3= 3(4)

2 = 6

S1 = 1(2) ...

2 ×

S2 = 2(3)

2 ×

...

Sn−1 = (n− 1)n

2 ×

Sn = n(n+ 1)

2 ×

Sn+1 = (n+ 1)(n + 2)

2 ?

...

Figure 2.4.2 A sequence of statements.

True statements are marked with×.

Suppose that each true equation has an “×” placed beside it (see Figure 2.4.2).

Since the first equation is true, it is marked. Now suppose we can show that for all n, if equation n is marked, then equation n+ 1 is also marked. Then, as in the example involving the blocks, all of the equations are marked; that is, all the equations are true and the formula (2.4.4) is verified.

We must show that for all n, if equation n is true, then equation n+ 1 is also true.

Equation n is

Sn =n(n+ 1)

2 . (2.4.5)

Assuming that this equation is true, we must show that equation n+ 1 Sn+1= (n+ 1)(n + 2)

2

2.4 ◆ Mathematical Induction

95

is true. According to definition (2.4.3),

Sn+1 = 1 + 2 + · · · + n + (n + 1).

We note that Snis contained within Sn+1, in the sense that

Sn+1 = 1 + 2 + · · · + n + (n + 1) = Sn+ (n + 1). (2.4.6) Because of (2.4.5) and (2.4.6), we have

Sn+1= Sn+ (n + 1) =n(n+ 1)

2 + (n + 1).

Since

n(n+ 1)

2 + (n + 1) = n(n+ 1)

2 +2(n+ 1) 2

=n(n+ 1) + 2(n + 1) 2

=(n+ 1)(n + 2)

2 ,

we have

Sn+1= (n+ 1)(n + 2)

2 .

Therefore, assuming that equation n is true, we have proved that equation n+ 1 is true.

We conclude that all of the equations are true.

Our proof using mathematical induction consisted of two steps. First, we verified that the statement corresponding to n= 1 was true. Second, we assumed that statement n was true and then proved that statement n+1 was also true. In proving statement n +1, we were permitted to make use of statement n; indeed, the trick in constructing a proof using mathematical induction is to relate statement n to statement n+ 1.

We next formally state the Principle of Mathematical Induction.

Principle of

Mathematical Induction Suppose that we have a propositional function S(n) whose domain of discourse is the set of positive integers. Suppose that

S(1) is true; (2.4.7)

for all n≥ 1, if S(n) is true, then S(n + 1) is true. (2.4.8) Then S(n) is true for every positive integer n.

Condition (2.4.7) is sometimes called the Basis Step and condition (2.4.8) is sometimes called the Inductive Step. Hereafter, “induction” will mean “mathematical induction.”

After defining n factorial, we illustrate the Principle of Mathematical Induction with another example.

Definition 2.4.1 n factorial is defined as

n!=

1 if n= 0

n(n− 1)(n − 2) · · · 2 · 1 if n ≥ 1.

That is, if n≥ 1, n! is equal to the product of all the integers between 1 and n inclusive.

As a special case, 0! is defined to be 1.

Example 2.4.2 0!= 1! = 1, 3! = 3 · 2 · 1 = 6, 6! = 6 · 5 · 4 · 3 · 2 · 1 = 720

Example 2.4.3 Use induction to show that

n!≥ 2n−1 for all n≥ 1. (2.4.9)

Basis Step (n= 1)

[Condition (2.4.7)] We must show that (2.4.9) is true if n= 1. This is easily accomplished, since 1!= 1 ≥ 1 = 21−1.

Inductive Step

[Condition (2.4.8)] We assume that the inequality is true for n≥ 1; that is, we assume that

n!≥ 2n−1 (2.4.10)

is true. We must then prove that the inequality is true for n+ 1; that is, we must prove that

(n+ 1)! ≥ 2n (2.4.11)

is true. We can relate (2.4.10) and (2.4.11) by observing that (n+ 1)! = (n + 1)(n!).

Now

(n+ 1)! = (n + 1)(n!)

≥ (n + 1)2n−1 by (2.4.10)

≥ 2 · 2n−1 since n+ 1 ≥ 2

= 2n.

Therefore, (2.4.11) is true. We have completed the Inductive Step.

Since the Basis Step and the Inductive Step have been verified, the Principle of Mathematical Induction tells us that (2.4.9) is true for every positive integer n.

If we want to verify that the statements

S(n0), S(n0+ 1), . . . , where n0= 1, are true, we must change the Basis Step to

S(n0) is true.

In words, the Basis Step is to prove that the propositional function S(n) is true for the smallest value n0in the domain of discourse.

The Inductive Step then becomes

for all n≥ n0, if S(n) is true, then S(n+ 1) is true.

2.4 ◆ Mathematical Induction

97

Example 2.4.4 Geometric Sum

Use induction to show that if r = 1,

a+ ar1+ ar2+ · · · + arn =a(rn+1− 1)

r− 1 (2.4.12)

for all n≥ 0.

The sum on the left is called the geometric sum. In the geometric sum in which a= 0 and r = 0, the ratio of adjacent terms [(ari+1)/(ari)= r] is constant.

Basis Step (n= 0)

Since the smallest value in the domain of discourse{n | n ≥ 0} is n = 0, the Basis Step is to prove that (2.4.12) is true for n= 0. For n = 0, (2.4.12) becomes

a=a(r1− 1) r− 1 , which is true.

Inductive Step

Assume that statement (2.4.12) is true for n. Now

a+ ar1+ ar2+ · · · + arn+ arn+1 = a(rn+1− 1)

r− 1 + arn+1

= a(rn+1− 1)

r− 1 +arn+1(r− 1) r− 1

= a(rn+2− 1) r− 1 .

Since the Basis Step and the Inductive Step have been verified, the Principle of Mathe-matical Induction tells us that (2.4.12) is true for all n≥ 0.

As an example of the use of the geometric sum, if we take a = 1 and r = 2 in (2.4.12), we obtain the formula

1+ 2 + 22+ 23+ · · · + 2n =2n+1− 1

2− 1 = 2n+1− 1.

The reader has surely noticed that in order to prove the previous formulas, one has to be given the correct formulas in advance. A reasonable question is: How does one come up with the formulas? There are many answers to this question. One technique to derive a formula is to experiment with small values and try to discover a pattern.

(Another technique is discussed in Exercises 67–70.) For example, consider the sum 1+3+· · ·+(2n −1). The following table gives the values of this sum for n = 1, 2, 3, 4.

n 1+ 3 + · · · + (2n − 1)

1 1

2 4

3 9

4 16

Since the second column consists of squares, we conjecture that

1+ 3 + · · · + (2n − 1) = n2 for every positive integer n.

The conjecture is correct and the formula can be proved by mathematical induction (see Exercise 1).

At this point, the reader may want to read the Problem-Solving Corner that follows this section. This Problem-Solving Corner gives an extended, detailed exposition of how to do proofs by mathematical induction.

Our final examples show that induction is not limited to proving formulas for sums and verifying inequalities.

Example 2.4.5 Use induction to show that 5n− 1 is divisible by 4 for all n ≥ 1.

Basis Step (n= 1)

If n= 1, 5n− 1 = 51− 1 = 4, which is divisible by 4.

Inductive Step

We assume that 5n− 1 is divisible by 4. We must then show that 5n+1− 1 is divisible by 4. We use the fact that if p and q are each divisible by k, then p+ q is also divisible by k. In our case, k= 4. We leave the proof of this fact to the exercises (see Exercise 71).

We relate the (n+ 1)st case to the nth case by writing 5n+1− 1 = 5n− 1 + to be determined.

Now, by the inductive assumption, 5n − 1 is divisible by 4. If “to be determined” is also divisible by 4, then the preceding sum, which is equal to 5n+1− 1, will also be divisible by 4, and the Inductive Step will be complete. We must find the value of “to be determined.”

Now

5n+1− 1 = 5 · 5n− 1 = 4 · 5n+ 1 · 5n− 1.

Thus, “to be determined” is 4· 5n, which is divisible by 4. Formally, we could write the Inductive Step as follows.

By the inductive assumption, 5n− 1 is divisible by 4 and, since 4 · 5nis divisible by 4, the sum

(5n− 1) + 4 · 5n = 5n+1− 1 is divisible by 4.

Since the Basis Step and the Inductive Step have been verified, the Principle of Mathematical Induction tells us that 5n− 1 is divisible by 4 for all n ≥ 1.

We next give the proof promised in Section 1.1 that if a set X has n elements, the power set of X ,P(X), has 2n elements.

2.4 ◆ Mathematical Induction

99

Theorem 2.4.6 If |X| = n, then

|P (X)| = 2n (2.4.13)

for all n≥ 0.

Proof The proof is by induction on n.

Basis Step (n= 0)

If n= 0, X is the empty set. The only subset of the empty set is the empty set itself;

thus,

|P (X)| = 1 = 20= 2n. Thus, (2.4.13) is true for n= 0.

Inductive Step

Assume that (2.4.13) holds for n. Let X be a set with n+ 1 elements. Choose x ∈ X.

We claim that exactly half of the subsets of X contain x, and exactly half of the subsets of X do not contain x. To see this, notice that each subset S of X that contains x can be paired uniquely with the subset obtained by removing x from S (see Figure 2.4.3).

Thus exactly half of the subsets of X contain x, and exactly half of the subsets of X do not contain x.

If we let Y be the set obtained from X by removing x, Y has n elements. By the inductive assumption,|P(Y )| = 2n. But the subsets of Y are precisely the subsets of X that do not contain x. From the argument in the preceding paragraph, we conclude that

|P(Y )| =|P(X)|

2 .

Therefore,

|P(X)| = 2|P(Y )| = 2 · 2n= 2n+1.

Thus (2.4.13) holds for n+ 1 and the inductive step is complete. By the Principle of Mathematical Induction, (2.4.13) holds for all n≥ 0.

Subsets of X classes: those that contain a and those that do not contain a. Each subset in the right column is obtained from the corresponding subset in the left column by deleting the element a from it.

Example 2.4.7 A Tiling Problem

A right tromino, hereafter called simply a tromino, is an object made up of three squares, as shown in Figure 2.4.4. A tromino is a type of polyomino. Since polyominoes were introduced by Solomon W. Golomb in 1954 (see [Golomb, 1954]), they have been a favorite topic in recreational mathematics. A polyomino of order s consists of s squares joined at the edges. A tromino is a polyomino of order 3. Three squares in a row form the only other type of polyomino of order 3. (No one has yet found a simple formula for the number of polyominoes of order s.) Numerous problems using polyominoes have been devised (see [Martin]).

Figure 2.4.4 A tromino.

We give Golomb’s inductive proof (see [Golomb, 1954]) that if we remove one square from an n× n board, where n is a power of 2, we can tile the remaining squares with right trominoes (see Figure 2.4.5). By a tiling of a figure by trominoes, we mean an exact covering of the figure by trominoes without having any of the trominoes overlap

Figure 2.4.5 Tiling a 4× 4 deficient board with trominoes.

2k1

2k1

2k 2k 2k 2k

2k 2k 2k 2k T

Figure 2.4.6 Using mathematical induction to tile a 2k+1× 2k+1 deficient board with trominoes.

each other or extend outside the figure. We call a board with one square missing a deficient board.

We now use induction on k to prove that we can tile a 2k× 2kdeficient board with trominoes for all k≥ 1.

Basis Step (k= 1)

If k= 1, the 2 × 2 deficient board is itself a tromino and can therefore be tiled with one tromino.

Inductive Step

Assume that we can tile a 2k×2kdeficient board. We show that we can tile a 2k+1×2k+1 deficient board.

Consider a 2k+1× 2k+1deficient board. Divide the board into four 2k× 2kboards, as shown in Figure 2.4.6. Rotate the board so that the missing square is in the upper-left quadrant. By the inductive assumption, the upper-left 2k× 2kboard can be tiled. Place one tromino T in the center, as shown in Figure 2.4.6, so that each square of T is in each of the other quadrants. If we consider the squares covered by T as missing, each of these quadrants is a 2k× 2kdeficient board. Again, by the inductive assumption, these boards can be tiled. We now have a tiling of the 2k+1× 2k+1 board. By the Principle of Mathematical Induction, it follows that any 2k× 2kdeficient board can be tiled with trominoes, k= 1, 2, . . . .

If we can tile an n×n deficient board, where n is not necessarily a power of 2, then the number of squares, n2− 1, must be divisible by 3. [Chu] showed that the converse is true, except when n is 5. More precisely, if n= 5, any n × n deficient board can be tiled with trominoes if and only if 3 divides n2− 1 (see Exercises 27 and 28, Section 2.5).

[Some 5× 5 deficient boards can be tiled and some cannot (see Exercises 32 and 33).]

Some real-world problems can be modeled as tiling problems. One example is the VLSI layout problem—the problem of packing many components on a computer chip (see [Wong]). (VLSI is short for Very Large Scale Integration.) The problem is to tile a rectangle of minimum area with the desired components. The components are sometimes modeled as rectangles and L-shaped figures similar to (right) trominoes. In practice, other constraints are imposed such as the proximity of various components that must be interconnected and restrictions on the ratios of width to height of the resulting rectangle.

2.4 ◆ Mathematical Induction

101

A loop invariant is a statement about program variables that is true just before a loop begins executing and is also true after each iteration of the loop. In particular, a loop invariant is true after the loop finishes, at which point the invariant tells us something about the state of the variables. Ideally, this statement tells us that the loop produces the ex-pected result, that is, that the loop is correct. For example, a loop invariant for a while loop

while (condition) // loop body

is true just before condition is evaluated the first time, and it is also true each time the loop body is executed.

We can use mathematical induction to prove that an invariant has the desired behavior. The Basis Step proves that the invariant is true before the condition that controls looping is tested for the first time. The Inductive Step assumes that the invariant is true and then proves that if the condition that controls looping is true (so that the loop body is executed again), the invariant is true after the loop body executes. Since a loop iterates a finite number of times, the form of mathematical induction used here proves that a finite sequence of statements is true, rather than an infinite sequence of statements as in our previous examples. Whether the sequence of statements is finite or infinite, the steps needed for the proof by mathematical induction are the same. We illustrate a loop invariant with an example.

Example 2.4.8 We use a loop invariant to prove that when the pseudocode i = 1

fact= 1 while (i< n) {

i = i + 1 fact= fact ∗ i }

terminates, fact is equal to n!.

We prove that fact= i! is an invariant for the while loop. Just before the while loop begins executing, i= 1 and fact = 1, so fact = 1!. We have proved the Basis Step.

Assume that fact= i!. If i < n is true (so that the loop body executes again), i becomes i+ 1 and fact becomes

fact∗ (i + 1) = i! ∗ (i + 1) = (i + 1)!.

We have proved the Inductive Step. Therefore, fact= i! is an invariant for the while loop.

The while loop terminates when i = n. Because fact = i! is an invariant, at this point, fact= n!.

Problem-Solving Tips To prove

a1+ a2+ · · · + an= F(n), for all n≥ 1, where F(n) is the formula for the sum, first verify the equation for n= 1

a1= F(1) (Basis Step). This is usually straightforward.

Now assume that the statement is true for n; that is, assume

To verify the preceding equation, use algebra to manipulate the left-hand side of the equation [F(n)+ an+1] until you get F(n+ 1). Look at F(n + 1) so you know where you’re headed. (It’s somewhat like looking up the answer in the back of the book!) You’ve shown that

a1+ a2+ · · · + an+1 = F(n + 1), which is the Inductive Step. Now the proof is complete.

Proving an inequality is handled in a similar fashion. The difference is that instead of obtaining equality [F(n)+ an+1= F(n + 1) in the preceding discussion], you obtain an inequality.

In general, the key to devising a proof by induction is to find case n “within” case n+ 1. Review the tiling problem (Example 2.4.7), which provides a striking example of case n “within” case n+ 1.

Section Review Exercises

1. State the Principle of Mathematical Induction.

2. Explain how a proof by mathematical induction proceeds.

3. Give a formula for the sum 1+ 2 + · · · + n.

4. What is the geometric sum? Give a formula for it.

Exercises

In Exercises 1–11, using induction, verify that each equation is true for every positive integer n.

provided that sin(x/2) = 0.

11. 1 sin x+ 2 sin 2x + · · · + n sin nx

= sin [(n+ 1)x]

4 sin2(x/2)(n+ 1) cos[(2n + 1)x/2]

2 sin (x/2) provided that sin(x/2) = 0.

2.4 ◆ Mathematical Induction

103

In Exercises 12–17, using induction, verify the inequality.

12. 1 the aiare positive numbers

17. (1+ x)n≥ 1 + nx, for x ≥ −1 and n ≥ 1 18. Use the geometric sum to prove that

r0+ r1+ · · · + rn< 1 previous exercise, compare the sum of the terms in

r r2 r3 r4 · · · rn

in the diagonal direction () with the sum of the terms by columns.

In Exercises 21–24, use induction to prove the statement.

21. 7n− 1 is divisible by 6, for all n ≥ 1.

28. By experimenting with small values of n, guess a formula for

the given sum, 1 1· 2+ 1

2· 3+ · · · + 1 n(n+ 1); then use induction to verify your formula.

29. Use induction to show that n straight lines in the plane divide the plane into (n2+ n + 2)/2 regions. Assume that no two lines are parallel and that no three lines have a common point.

30. Show that the regions of the preceding exercise can be colored red and green so that no two regions that share an edge are the same color.

31. Given n 0’s and n 1’s distributed in any manner whatsoever around a circle (see the following figure), show, using induc-tion on n, that it is possible to start at some number and proceed clockwise around the circle to the original starting position so that, at any point during the cycle, we have seen at least as many 0’s as 1’s. In the following figure, a possible starting point is marked with an arrow.

0 0

32. Give a tiling of a 5× 5 board with trominoes in which the upper-left square is missing.

33. Show a 5× 5 deficient board that is impossible to tile with trominoes. Explain why your board cannot be tiled with tro-minoes.

34. Show that any (2i )× (3 j) board, where i and j are positive integers, with no square missing, can be tiled with trominoes.

35. Show that any 7× 7 deficient board can be tiled with tromi-noes.

36. Show that any 11× 11 deficient board can be tiled with tromi-noes. Hint: Subdivide the board into overlapping 7×7 and 5×5 boards and two 6×4 boards. Then, use Exercises 32, 34, and 35.

37. This exercise and the one that follows are due to Anthony Quas. A 2n× 2nL-shape, n≥ 0, is a figure of the form

2n 2n

2n 2n 2n 2n

with no missing squares. Show that any 2n× 2nL-shape can be tiled with trominoes.

38. Use the preceding exercise to give a different proof that any 2n× 2ndeficient board can be tiled with trominoes.

A straight tromino is an object made up of three squares in a row:

39. Which 4× 4 deficient boards can be tiled with straight tro-minoes? Hint: Number the squares of the 4× 4 board, left to right, top to bottom: 1, 2, 3, 1, 2, 3, and so on. Note that if there is a tiling, each straight tromino covers exactly one 2 and exactly one 3.

40. Which 5× 5 deficient boards can be tiled with straight trominoes?

41. Which 8× 8 deficient boards can be tiled with straight trominoes?

42. Use a loop invariant to prove that when the pseudocode i= 1

terminates, pow is equal to an.

43. Prove that, after the following pseudocode terminates, a[h]= val; for all p, i≤ p < h, a[p] < val; and for all p, h < p ≤ j,

43. Prove that, after the following pseudocode terminates, a[h]= val; for all p, i≤ p < h, a[p] < val; and for all p, h < p ≤ j,