44 KiB
Page 284
Definition
If m and n are integers and m \leq n, the symbol \sum_{k=m}^{n}{a_k},
read the summation from k equals m to n of $a$-sub-$k$, is the sum of
all the terms a_m, a_{m + 1}, a_{m + 2}, \dots, a_n. We say that
a_m + a_{m + 1} + a_{m + 2} + \dots + a_n is the expanded form of the sum,
and we write
\sum_{k=m}^{n}{a_k} = a_m + a_{m + 1} + a_{m + 2} + \dots + a_n
We call k the index of the summation, m the lower limit of the
summation, and n the upper limit of the summation.
Page 287
Definition
If m and n are integers and m \leq n, the symbol \prod_{k = m}^{n}{a_k}
read the product from k equals m to n of $a$-sub-$k$, is the product
of all the terms a_m, a_{m + 1}, a_{m + 2}, \dots, a_n.
We write
\prod_{k = m}^{n}{a_k} = a_m \cdot a_{m + 1} \cdot a_{m + 1} \dots a_n
Page 288
Theorem 5.1.1
If a_m, a_{m + 1}, a_{m + 1}, \dots and b_m, b_{m + 1}, b_{m + 1}, \dots are
sequences of real numbers and c is any real number, then the following
equations hold for any integer n \geq m:
-
\sum_{k = m}^{n}{a_k} + \sum_{k = m}^{n}{b_k} = \sum_{k = m}^{n}{(a_k + b_k)} -
c \cdot \sum_{k = m}^{n}{a_k} = \sum_{k = m}^{n}{c \cdot a_k} \quad \text{generalized distributive law} -
\left(\prod_{k = m}^{n}{a_k}\right) \cdot \left(\prod_{k = m}^{n}{b_k}\right) = \prod_{k = m}^{n}{(a_k \cdot b_k)}
Page 291
Definition
For each positive integer n, the quantity n factorial denoted n!, is
defined to be the product of all the integers from 1 to n:
n! = n \cdot (n - 1) \dots 3 \cdot 2 \cdot 1
Zero factorial, denoted 0!, is defined to be 1:
0! = 1
Page 292
Definition
Let n and r be integers with 0 \leq r \leq n. The symbol
\binom{n}{r}
is read "n choose $r$" and represents the number of subsets of size r
that can be chosen from a set with n elements.
Page 292
Formula for Computing $\dbinom{n}{r}$
For all integers n and r with 0 \leq r \leq n,
\binom{n}{r} = \frac{n!}{r!(n - r)!}
Page 295
Algorithm 5.1.1 Decimal to Binary Conversion Using Repeated Division by $2$
[In Algorithm 5.1.1 the input is a nonnegative integer a. The aim of the
algorithm is to produce a sequence of binary digits $r[0], r[1], r[2], \dots
r[k] so that the binary representation of n is
\left(r[k]r[k - 1] \dots r[2]r[1]r[0]\right)_2
That is,
a = 2^k \cdot r[k] + 2^{k - 1} \cdot r[k - 1] + \dots + 2^3 \cdot r[2] + 2^1 \cdot r[1] + 2^0 \cdot r[0]
.]
Input: a [a nonegative integer]
Algorithm Body:
q := a, i := 0
[Repeatedly perform the integer division of q by 2 until q becomes 0.
Store successive remainders in a one-dimensional array
r[0], r[1], r[2], \dots r[k]. Even if the initial-value of q equals 0, the
loop should execute one time (so that r[0] is computed). Thus the guard
condition for the while loop is i = 0 or q \neq 0.]
\text{\textbf{while }}(i = 0 \text{ or } q \neq 0)\\ \ \ r[i] := q \mod 2\\ \ \ q := q \text{ div } 2\\ \ \ \text{[r[i] and q can be obtained by calling the division algorithm.]}\\ \ \ i := i + 1\\ \text{\textbf{end while}}
[After execution of this step, the values of r[0], r[1], \dots, r[i - 1] are
all $0$'s and $1$'s, and
a = \left(r[i - 1]r[i - 2] \dots r[2]r[1]r[0]\right)_2.]
Output: r[0], r[1], r[2], \dots, r[i - 1] [a sequence of integers]
Page 300
Principle of Mathematical Induction
Let P(n) be a property that is defined for integers n, and let a be a
fixed integer. Suppose the following two statements are true:
-
P(a)is true. -
For every integer
k \geq a, ifP(k)is true thenP(k + 1)is true.
Then the statement
\text{for every integer } n \geq a, P(a)
is true.
Page 301
Method of Proof by Mathematical Induction
Consider the statement of the form, "For every integer n \geq a, a property
P(n) is true." To prove such a statement, perform the following two steps:
Step 1 (basis step):
Show that $P(a)$ is true.
Step 2 (inductive step):
Show that for every integer k \geq a, if P(k) is true then P(k + 1) is
true. To perform this step,
suppose that P(k) is true, where k is any particular but arbitrarily
chosen integer with k \geq a. [This supposition is called the inductive
hypothesis.]
Then show that P(k + 1) is true.
Page 303
Theorem 5.2.1 Sum of the First n Integers
For every integer n \geq 1,
1 + 2 + \dots + n = \frac{n(n + 1)}{2}
Proof (by mathematical induction):
Let the property P(n) be the equation
1 + 2 + 3 + \dots + n = \frac{n(n + 1)}{2}
Show that P(1) is true:
To establish P(1), we must show that
1 = \frac{1(1 + 1)}{2}
But the left-hand side of this equation is 1 and the right-hand side is
\frac{1(1 + 1)}{2} = \frac{2}{2} = 1
also. Hence P(1) is true.
Show that for every integer k \geq 1, if P(k) is true then P(k + 1) is
also true:
[Suppose that P(k) is true for a particular but arbitrarily chosen integer
k \geq 1. That is:]
Suppose that k is any integer with k \geq 1 such that
1 + 2 + 3 + \dots + k = \frac{k(k + 1)}{2}
[We must show that P(k + 1) is true. That is:] We must show that
1 + 2 + 3 + \dots + (k + 1) = \frac{(k + 1)[(k + 1) + 1]}{2}
or, equivalently, that
1 + 2 + 3 + \dots + (k + 1) = \frac{(k + 1)(k + 2)}{2}
[We will show that the left-hand side and the right-hand side of P(k + 1) are
equal to the same quantity and thus are equal to each other.]
The left-hand side of P(k + 1) is
1 + 2 + 3 + \dots + (k + 1)
= 1 + 2 + 3 + \dots + k + (k + 1)
= \frac{k(k + 1)}{2} + (k + 1)
= \frac{k(k + 1)}{2} + \frac{2(k + 1)}{2}
= \frac{k^2 + k}{2} + \frac{2k + 2}{2}
= \frac{k^2 + 3k + 2}{2}
And the right-hand side of P(k + 1) is
\frac{(k + 1)(k + 2)}{2} = \frac{k^2 + 3k + 2}{2}
Thus the two sides of P(k + 1) are equal to the same quantity and so they are
equal to each other. Therefore, the equation P(k + 1) is true [as was to be
shown].
[Since we have proved both the basis step and the inductive step, we conclude that the theorem is true.]
Page 304
Definition
If a sum with a variable number of terms is shown to equal an expression that does not contain an ellipsis or a summation symbol, we say that the sum is written in closed form.
Page 306
Theorem 5.2.2 Sum of a Geometric Sequence
For any real number r except 1, and any integer n \geq 0,
\sum_{i = 0}^{n}{r^i} = \frac{r^{n + 1} - 1}{r - 1}
Proof (by mathematical induction):
Suppose r is a particular but arbitrarily chosen real number that is not equal
to 1, and let the property P(n) be the equation
\sum_{i = 0}^{n}{r^i} = \frac{r^{n + 1} - 1}{r - 1}
We must show that P(n) is true for every integer n \geq 0. We do this by
mathematical induction on n.
Show that P(0) is true:
To establish P(0), we must show that
\sum_{i = 0}^{0}{r^i} = \frac{r^{0 + 1} - 1}{r - 1}
The left-hand side of this equation is r^0 = 1 and the right-hand side is
\frac{r^{0 + 1} - 1}{r - 1} = \frac{r - 1}{r - 1} = 1
also because r^1 = r and, since r \neq 1, r - 1 \neq 0. Hence P(0) is
true.
Show that for every integer k \geq 0, if P(k) is true then P(k + 1) is
also true:
[Suppose that P(k) is true for a particular but arbitrarily chosen integer
k \geq 0. That is:]
Let k be any integer with k \geq 0, and suppose that
\sum_{i = 0}^{k}{r^j} = \frac{r^{k + 1} - 1}{r - 1}
[We must show that P(k + 1) is true. That is:] We must show that
\sum_{i = 0}^{k + 1}{r^j} = \frac{r^{(k + 1) + 1} - 1}{r - 1}
or, equivalently, that
\sum_{i = 0}^{k + 1}{r^j} = \frac{r^{k + 2} - 1}{r - 1}
[We will show that the left-hand side of P(k + 1) equals the right-hand
side.]
The left-hand side of P(k + 1) is
\sum_{i = 0}^{k + 1}{r^j} = \sum_{i = 0}^{k}{r^i + r^{k + 1}}
= \frac{r^{k + 1} - 1}{r - 1} + r^{k + 1}
= \frac{r^{k + 1} - 1}{r - 1} + \frac{r^{k + 1}(r - 1)}{r - 1}
= \frac{(r^{k + 1} - 1) + r^{k + 1}(r - 1)}{r - 1}
= \frac{r^{k + 1} - 1 + r^{k + 2} - r^{k + 1}}{r - 1}
= \frac{r^{k + 2} - 1}{r - 1}
which is the right-hand side of P(k + 1) [as was to be shown].
[Since we have proved the basis step and the inductive step, we conclude that the theorem is true.]
Page 314
Proposition 5.3.1
For every integer n \geq 8, $n$¢ can be obtained using $3$¢ and $5$¢ coins.
Proof (by mathematical induction):
Let the property P(n) be the sentence
$n$¢ can be obtained using $3$¢ and $5$¢ coins.
Show that P(8) is true:
P(8) is true because $8$¢ can be obtained using one $3$¢ coin and one $5$¢
coin.
[Suppose that P(k) is true for a particular but arbitrarily chosen integer
k \geq 8. That is:]
Suppose that k is any integer with k \geq 8 such that
$k$¢ can be obtained using $3$¢ and $5$¢ coins.
[We must show that P(k + 1) is true. That is:] We must show that
$(k + 1)$¢ can be obtained using $3$¢ and $5$¢ coins.
Case 1 (There is a $5$¢ coin among those that used to make up the $k$¢.):
In this case replace the $5$¢ coin by two $3$¢ coins; the result will be $(k + 1)$¢.
Case 2 (There is not a $5$¢ coin among those used to make up the $k$¢.):
In this case, because k \geq 8, at least three $3$¢ coins must have been used.
So remove three $3$¢ coins and replace them by two $5$¢ coins; the result will
be $(k + 1)$¢.
Thus in either case $(k + 1)$¢ can be obtained using $3$¢ and $5$¢ coins [as was to be shown].
[Since we have proved the basis step and the inductive step, we conclude that the proposition is true.]
Page 315
Proposition 5.3.2
For each integer n \geq 0, 2^{2n} - 1 is divisible by 3.
Proof (by mathematical induction):
Let the property P(n) be the sentence "2^{2n} - 1 is divisible by 3."
2^{2n} - 1 \text{ is divisible by } 3
Show that P(0) is true:
To establish P(0), we must show that
2^{2 \cdot 0} - 1 \text{ is divisible by 3.}
But
2^{2 \cdot 0} - 1 = 2^0 - 1 = 1 - 1 = 0
and 0 is divisible by 3 because 0 = 3 \cdot 0. Hence P(0) is true.
Show that for any integer k \geq 0, if P(k) is true then P(k + 1) is also
true:
[Suppose that P(k) is true for a particular but arbitrarily chosen integer
k \geq 0. That is:]
Let k be any integer with k \geq 0, and suppose that
2^{2k} - 1 \text{ is divisible by } 3
By definition of divisibility, this means that
2^{2k} - 1 = 3r \text{ for some integer } r
[We must show that P(k + 1) is true. That is:] We must show that
2^{2(k + 1)} - 1 \text{ is divisible by } 3
Now
2^{2(k + 1)} - 1 = 2^{2k + 2} - 1
= 2^{2k} \cdot 2^2 - 1
= 2^{2k} \cdot 4 - 1
= 2^{2k}(3 + 1) - 1
= 2^{2k} \cdot 3 + (2^{2k} - 1)
= 2^{2=} \cdot 3 + 3r
= 3(2^{2k} + r)
But 2^{2k} + r is an integer because it is a sum of products of integers, and
so, by definition of divisibility, 2^{2(k + 1)} - 1 is divisible by 3 [as
was to be shown].
[Since we have proved the basis step and the inductive step, we conclude that the proposition is true.]
Page 317
Proposition 5.3.3
For every integer n \geq 3, 2n + 1 < 2^n.
Proof (by mathematical induction):
Let the property P(n) be the inequality
2n + 1 < 2^n
Show that P(3) is true:
To establish P(3), we must show that
2 \cdot 3 + 1 < 2^3
Now
2 \cdot 3 + 1 = 7 \quad \text{ and } \quad 2^3 = 8 \quad \text{ and } \quad 7 < 8
Hence P(3) is true.
Show that for every integer k \geq 3, if P(k) is true then P(k + 1) is
also true:
[Suppose that P(k) is true for a particular but arbitrarily chosen integer
k \geq 3. That is:]
Suppose that k is any integer with k \geq 3 such that
2k + 1 < 2^k
[We must show that P(k + 1) is true. That is:]
We must show that
2(k + 1) + 1 < 2^{(k + 1)}
Now
2(k + 1) + 1 = 2k + 1 + 2
< 2^k + 2
< 2^k + 2^k
= 2 \cdot 2^k
= 2^{k + 1}
Thus by transitivity of order 2(k + 1) + 1 < 2^{k + 1} [as was to be shown].
[Since we have proved the basis step and the inductive step, we conclude that the proposition is true.]
Page 319
Theorem 5.3.4 Covering a Board with Trominoes
For any integer n \geq 1, if one square is removed from a 2^n \times 2^n
checkerboard, the remaining squares can be completely covered by L-shaped
trominoes.
The main insight leading to a proof of this theorem is the observation that
because 2^{k + 1} = 2 \cdot 2^k, when a 2^{k + 1} \times 2^{k + 1} board is
split in half both vertically and horizontally, each half side will have length
2^k and so each resulting quadrant will be a 2^k \times 2^k checkerboard.
Proof (by mathematical induction):
Let the property P(n) be the sentence
If any square is removed from a 2^n \times 2^n checkerboard, then the
remaining squares can be completely covered by L-shaped trominoes.
Show that P(1) is true:
A 2^1 \times 2^1 checkerboard just consists of four squares. If one square is
removed, the remaining squares form an L, which can be covered by a single
L-shaped tromino, as illustrated in the figure to the left. Hence P(1) is
true.
Show that for every integer k \geq 1, if P(k) is true then P(k + 1) is
also true:
[Suppose that P(k) is true for a particular but arbitrarily chosen integer
k \geq 3. That is:]
Let k be any integer such that k \geq 1, and suppose that
If any square is removed from a 2^k \times 2^k checkerboard, then the
remaining squares can be completely covered by L-shaped trominoes.
P(k) is the inductive hypothesis.
[We must show that P(k + 1) is true. That is:]
We must show that
If any square is removed from a 2^{k + 1} \times 2^{k + 1} checkerboard, then
the remaining squares can be completely covered by L-shaped trominoes.
Consider a 2^{2k + 1} \times 2^{k + 1} checkerboard with one square removed.
Divide it into four equal quadrants: Each will consist of a 2^k \times 2^k
checkerboard. In one of the quadrants, one square will have been removed, and
so, by inductive hypothesis, all the remaining squares in this quadrant can be
completely covered by L-shaped trominoes.
The other three quadrants meet at the center of the checkerboard, and the center of the checkerboard serves as a corner of a square from each of those quadrants. An L-shaped tromino can, therefore, be placed on those three central squares. This situation is illustrated in the figure to the left (see page 320).
By inductive hypothesis, the remaining squares in each of the three quadrants
can be completely covered by L-shaped trominoes. Thus every square in the
2^{k + 1} \times 2^{k + 1} checkerboard except the one that was removed can be
completely covered by L-shaped trominoes [as was to be shown].
Page 324
Principle of Strong Mathematical Induction
Let P(n) be a property that is defined for integers n, and let a and b
be fixed integers with a \leq b. Suppose the following two statements are
true:
-
P(a), P(a + 1), \dots, andP(b)are all true. (basis step) -
For every integer
k \geq b, ifP(i)is true for each integerifromathroughk, thenP(k + 1)is true. (inductive step)
Then the statement
\text{for every integer } n \geq a, P(n)
is true. (The supposition that P(i) is true for each integer i from a
through k is called the inductive hypothesis. Another way to state the
inductive hypothesis is to say that P(a), P(a + 1), \dots, P(k) are all true.)
Page 325
Proof (by strong mathematical induction):
Let the property P(n) be the sentence
n is divisible by a prime number.
Show that P(2) is true:
To establish P(2), we must show that
2 is divisible by a prime number.
But this is true because 2 is divisible by 2 and 2 is a prime number.
Show that for every integer k \geq 2, if P(i) is true for each integer from
2 through k, then P(k + 1) is also true:
Let k be any integer with k \geq 2 and suppose that
i is divisible by a prime number for each integer i from 2 through k.
We must show that
k + 1 is divisible by a prime number.
Case 1(k + 1 is prime):
In this case k + 1 is divisible by a prime number, namely, itself.
Case 2(k + 1 is not prime):
In this case k + 1 = ab where a and b are integers with 1 < a< k + 1 and
1 < b < k + 1. Thus, in particular, 2 \leq a \leq k, and so by inductive
hypothesis, a is divisible by a prime number p. In addition because
k + 1 = ab, we have that k + 1 is divisible by a. Hence, since k + 1 is
divisible by a and a is divisible by p, by transitivity of divisibility,
k + 1 is divisible by the prime number p.
Therefore, regardless of whether k + 1 is prime or not, it is divisible by a
prime number. [as was to be shown.]
[Since we have proved both the basis and the inductive step of the strong mathematical induction, we conclude that the given statement is true.]
Page 326
Proof:
Let s_0, s_1, s_2, \dots be the sequence defined by specifying that
s_0 = 0, s_1 = 4, and s_k = 6a_{k - 1} - 5a_{k - 2} for every integer
k \geq 2, and let the property P(n) be the formula
s_n = 5^n - 1
We will use strong mathematical induction to prove that for every integer
n \geq 0, P(n) is true.
Show that P(0) and P(1) are true:
To establish P(0) and P(1), we must show that
s_0 = 5^0 - 1 \text{ and } s_1= 5^1 - 1
But, by definition of s_0, s_1, s_2, \dots, we have that s_0 = 0 and
s_1 = 4. Since 5^0 - 1 = 1 - 1 = 0 and 5^1 - 1 = 5 - 1 = 4, the values of
s_0 and s_1 agree with the values given by the formula.
Show that for every integer k \geq 1, if P(i) is true for each integer i
from 0 through k, then P(k + 1) is also true:
Let k be any integer with k \geq 1 and suppose that
s_i = 5^i - 1 \text{ for each integer } i \text{ with } 0 \leq i \leq k
We must show that
s_{k + 1} = 5^{k + 1} - 1
But since k \geq 1, we have that k + 1 \geq 2, and so
s_{k + 1} = 6s_k - 5s_{k - 1}
= 6(5^k - 1) - 5(5^{k - 1} - 1)
= 6 \cdot 5^k - 6 - 5^k + 5
= (6 - 1)5^k - 1
= 5 \cdot 5^k - 1
= 5^{k + 1} - 1
[as was to be shown].
[Since we have proved both the basis and the inductive step of the strong mathematical induction, we conclude that the given statement is true.]
Page 328
Convention
Let us agree to say that a single number x_1 is a product with one factor and
can be computed with zero multiplications.
Page 329
Proof (by strong mathematical induction):
Let the property P(n) be the sentence
If x_1, x_2, \dots, x_n are n numbers, then no matter how parentheses are
inserted into their product, the number of multiplications used to compute the
product is n - 1.
Show that P(1) is true:
To establish P(1), we must show that
The number 9f multiplications needed to compute the product of x_1 is 1 - 1.
This is true because, by convention, x_1 is a product that can be computed
with 0 multiplications and 0 = 1 - 1.
Show that for every integer k \geq 1, if P(i) is true for each integer i
from 1 through k, then P(k + 1) is also true:
Let k be any integer with k \geq 1 and suppose that
For each integer i from 1 through k, if x_1, x_2, \dots, x_i are
numbers, then no matter how parentheses are inserted into their product, the
number of multiplications used to compute the product is i - 1.
We must show that
If x_1, x_2, \dots, x_{k + 1} are k + 1 numbers, then no matter how
parentheses are inserted into their product, the number of multiplications used
to compute the product is (k + 1) - 1 = k.
Consider a product of k + 1 factors: x_1, x_2, \dots, x_{k + 1}. When
parentheses are inserted in order to compute the product, some multiplication is
the final one and each of the two factors making up the final multiplication is
a product of fewer than k + 1 factors. Let L be the product of the left-hand
factors and R be the product of the right-hand factors, and suppose that L
is composed of l factors and R is composed of r factors. Then
l + r = k + 1, the total number of factors in the product, and
1 \leq l \leq k \text{ and } 1 \leq r \leq k
By inductive hypothesis, evaluating L takes l - 1 multiplications and
evaluating R takes r - 1 multiplications. Because one final multiplication
is needed to evaluate L \cdot R, the number of multiplications needed to
evaluate the product of all k + 1 factors is
(l - 1) + (r - 1) + 1 = (l + r) - 1 = (k + 1) - 1 = k
[as was to be shown].
[Since we have proved both the basis and the inductive step of the strong mathematical induction, we conclude that the given statement is true.]
Page 330
Theorem 5.4.1 Existence and Uniqueness of Binary Integer Representations
Given any positive integer n, n has a unique representation in the form
n = c_r \cdot 2^r + c_{r - 1} \cdot 2^{r - 1} + \dots + c_2 \cdot 2^2 + c_1 \cdot 2 + c_0
where r is a nonnegative integer, c_r = 1, and c_j = 1 or 0 for each
j = 0, 1, 2, \dots, r - 1.
Proof:
We give separate proofs by strong mathematical induction to show first the existence and second the uniqueness of the binary representation.
Existence (proof by strong mathematical induction):
Let the property P(n) be the equation
n = c_r \cdot 2^r + c_{r - 1} \cdot 2^{r - 1} + \dots + c_2 \cdot 2^2 + c_1 \cdot 2 + c_0
where r is a nonnegative integer, c_r = 1, and c_j = 1 or 0 for each
j = 0, 1, 2, \dots, r - 1.
Show that P(1) is true:
Let r = 0 and c_0 = 1. Then 1 = c_r \cdot 2^r, and so n = 1 can be
written in the required form.
Show that for every integer k \geq 1, if P(i) is true for each integer i
from 1 through k, then P(k + 1) is also true:
Let k be an integer with k \geq 1. Suppose that for each integer i from
1 through k,
= c_r \cdot 2^r + c_{r - 1} \cdot 2^{r - 1} + \dots + c_2 \cdot 2^2 + c_1 \cdot 2 + c_0
where r is a nonnegative integer, c_r = 1, and c_j = 1 or 0 for each
j = 0, 1, 2, \dots, r - 1 . We must show that k + 1 can be written as a sum
of powers of 2 in the required form.
Case 1 (k + 1 is even):
In this case \dfrac{(k + 1)}{2} is an integer, and by inductive hypothesis,
since 1 \leq \dfrac{(k + 1)}{2} \leq k, then
\frac{k + 1}{2} = c_r \cdot 2^r + c_{r - 1} \cdot 2^{r - 1} + \dots + c_2 \cdot 2^2 + c_1 \cdot 2 + c_0
where r is a nonnegative integer, c_r = 1, and c_j = 1 or 0 for each
j = 0, 1, 2, \dots, r - 1. Multiplying both sides of the equation by 2 gives
k + 1= c_r \cdot 2^{r + 1} + c_{r - 1} \cdot 2^r + \dots + c_2 \cdot 2^3 + c_1 \cdot 2^2 + c_0 \cdot 2
which is the sum of powers of 2 of the required form.
Case 2 (k + 1 is odd):
In this case \dfrac{k}{2} is an integer, and by inductive hypothesis, since
1 \leq \dfrac{k}{2} = k, then
\frac{k}{2} = c_r \cdot 2^r + c_{r - 1} \cdot 2^{r - 1} + \dots + c_2 \cdot 2^2 + c_1 \cdot 2 + c_0
where r is a nonnegative integer, c_r = 1, and c_j = 1 or 0 for each
j = 0, 1, 2, \dots r - 1. Multiplying both sides of the equation by 2 and
adding 1 gives
k + 1 = c_r \cdot 2^{r + 1} + c_{r - 1} \cdot 2^r + \dots + c_2 \cdot 2^3 + c_1 \cdot 2^2 + c_0 \cdot 2 + 1
which is also a sum of powers of 2 of the required form.
The preceding arguments show that regardless 9f whether k + 1 is even or odd,
k + 1 has a representation of the required form. [Or, in other words,
P(k + 1) is true as was to be shown.]
[Since we have proved the basis step and the inductive step of the strong mathematical induction, the existence half of the theorem is true.]
Uniqueness:
To prove uniqueness, suppose that there is an integer n with two different
representations as a sum of nonnegative integer powers of 2. Equating the two
representations and canceling all identical terms gives
2^r + c{r - 1} \cdot 2^{4 - 1} + \dots + c_1 \cdot 2 + c_0 = 2^s + d_{s - 1} \cdot 2^{s - 1} + \dots + d_1 \cdot 2 + d_0
where r and s are nonnegative integers and each c_i and each d_i equal
0 or 1. Without loss of generality, we may assume that r < s. Now by the
formula for the sum of a geomatric sequence (Theorem 5.2.2) and because r < s
(which implies that r + 1 \leq s),
2^r + c_{r - 1} \cdot 2^{r - 1} + \dots + c_1 \cdot 2 + \c_0 \leq 2^r + 2^{r - 1} + \dots + 2 + 1 = 2^{r + 1} - 1 < 2^s
Thus
2^r + c_{r - 1} \cdot 2^{r - 1} + \dots + c_1 \cdot 2 + c_0 < 2^s + d_{s - 1} \cdot 2^{s - 1} + \dots + d_1 \cdot 2 + d_0
which contradicts equation (5.4.1). Hence the supposition is false, so any
integer n has only one representation as a sum of nonnegative integer powers
9f 2.
Page 331
Well-Ordering Principle for the Integers
Let S be a set of integers containing one or more integers all of which are
greater than some fixed integer. Then S has a least element.
Page 332
Quotient-Remainder Theorem (Existence Part)
Proof:
Let s be the set of all nonnegative integers of the form
n - dk
where k is an integer. This set has at least one element. [For if n is
nonnegative, then
n - 0 \cdot d = n \geq 0
and so n - 0 \cdot d is in S. And if n is negative then
n - nd = \underbrace{n}_{< 0}\underbrace{(1 - d)}_{\leq 0 \text{ since } d \text{ is a positive integer}} \geq 0
and so n - nd is in S.]
It follows by the well-ordering principle for the integers that S contains a
least element r. Then, for some specific integer value of k, say q,
n - dq = r
[because every integer in S can be written in this form]. Adding dq to
both sides gives
n = dq + r
Furthermore, r < d. [For suppose r \geq d. Then
n - d(q + 1) = n - dq - d = r - d \geq 0
and so n - d(q + 1) would be a nonnegative integer in S that would be
smaller than r. But r is the smallest integer in S. This contradiction
shows that the supposition r \geq d must be false.]
The preceding arguments prove that there exists integers r and q for which
n = dq + r \text{ and } 0 \leq r < d
[as was to be shown.]
Page 339
Definition
A loop is defined as correct with respect to its pre- and post-conditions if, and only if, whenever the algorithm variables satisfy the pre-condition for the loop and the loop terminates after a finite number of steps, the algorithm variables satisfy the post-condition for the loop.
Page 340
Theorem 5.5.1 Loop Invariant Theorem
Let a while loop with guard G be given, together with pre- and
post-conditions that are predicates in the algorithm variables. Also let a
predicate I(n), called the loop invariant, be given. If the following four
properties are true, then the loop is correct with respect to its pre- and
post-conditions.
I. Basis Property: The pre-condition for the loop implies that I(0) is
true before the first iteration of the loop.
II. Inductive Property: For every integer k \geq 0, if the guard G and
the loop invariant I(k) are both true before an iteration of the loop, then
I(k + 1) is true after an iteration of the loop.
III. Eventual Falsity of Guard: After a finite number of iterations of the
loop, the guard G becomes false.
IV. Correctness of the Post-Condition: If N is the least number of
iterations after which G is false and I(N) is true, then the values of the
algorithm variables will be as specified in the post-condition of the loop.
Proof:
The loop invariant theorem follows easily from the principle of mathematical
induction. Assume that I(n) is a predicate that satisfies properties I-IV of
the loop invariant theorem. [We will prove that the loop is correct with
respect to its pre- and post-conditions.] Properties I and II are the basis and
inductive steps needed to prove the truth of the following statement:
For every integer n \geq 0, if the while loop iterates n times, then
I(n) is true.
Thus, by the principle of mathematical induction, since both I and II are true, statement (5.5.1) is also true.
Property III says that the guard G eventually becomes false. At that point the
loop will have been iterated some number, say N, of times. Since I(n) is
true after the $n$th iteration for every n \geq 0, then I(n) is true after
the $N$th iteration. That is, after the $N$th iteration the guard is false and
I(N) is true. But this is the hypothesis of property IV, which is an if-then
statement. Since statement IV is true (by assumption) and its hypothesis is true
(by the argument just given), it follows (by modus ponens) that its conclusion
is also true. That is, the values of all algorithm variables after execution of
the loop are as specified in the post-condition for the loop.
Page 348
Definition
A recurrence relation for a sequence a_0, a_1, a_2, \dots is a formula
that relates each term a_k to certain of its predecessors
a_{k - 1}, a_{k - 2}, \dots, a_{k - i}, where i is an integer with
k - i \geq 0. If i is a fixed integer, the initial conditions for such a
recurrence relation specify the values of a_0, a_1, a_2, \dots, a_{i - 1}. If
i depends on k, the initial conditions specify the values of
a_0, a_1, \dots, a_m, where m is an integer with m \geq 0.
Page 358
Definition
Given numbers a_1, a_2, \dots a_n, where n is a positive integer, the
summation from i = 1 to n of the $a_i$, denoted \sum_{i = 1}^{n}{a_i},
is defined as follows:
\sum_{i = 1}^{1}{a_i} = a_1 \quad \text{ and } \quad \sum_{i = 1}^{n}{a_i} = \left(\sum_{i = 1}^{n - 1}{a_i}\right) + a_n, \quad \text{ if } n > 1
The product from i = 1 to n of the $a_i$, denoted
\prod_{i = 1}^{n}{a_i}, is defined by
\prod_{i = 1}^{1}{a_i} = a_1 \quad \text{ and } \quad \prod_{i = 1}^{n}{a_i} = \left(\prod_{i = 1}^{n - 1}{a_i}\right) \cdot a_n, \quad \text{ if } \quad n > 1
Page 365
Definition
A sequence a_0, a_1, a_2, \dots is called an arithmetic sequence if, and
only if, there is a constant d such that
a_k = a_{k - 1} + d \quad \text{ for each integer } k \geq 1
It follows that
a_n = a_0 + dn \quad \text{ for every integer } n \geq 0
Page 366
Definition
A sequence a_0, a_1, a_2, \dots is called a geometric sequence if, and
only if, there is a constant r such that
a_k = ra_{k - 1} \quad \text{ for each integer } k \geq 1
It follows that
a_n = a_0r^n \quad \text{ for each integer } n \geq 0
Page 376
Definition
A second-order linear homogeneous recurrence relation with constant coefficients is a recurrence relation of the form
a_k = Aa_{k - 1} + Ba_{k - 2} \quad \text{ for every integer } k \geq \text{ some fixed integer}
where A and b are fixed real numbers with B \neq 0.
Page 377
Lemma 5.8.1
Let A and B be real numbers. A recurrence relation of the form
a_k = Aa_{k - 1} + Ba_{k - 2} \quad \text{ for every integer } k \geq 2
is satisfied by the sequence
1, t, t^2, t^3, \dots, t^n, \dots ,
where t is a nonzero real number, if, and only if, t satisfies the equation
t^2 - At - B = 0
Page 377
Definition
Given a second-order linear homogeneous recurrence relation with constant coefficients
a_k = Aa_{k - 1} + Ba_{k - 2} \quad \text{ for every integer } k \geq 2
the characteristic equation of the relation is
t^2 - At - B = 0
Page 378
Lemma 5.8.2
If r_0, r_1, r_2, \dots and s_0, s_1, s_2, \dots are sequences that satisfy
the same second-order linear homogeneous recurrence relation with constant
coefficients, and if C and D are any numbers, then the sequence
a_0, a_1, a_2, \dots defined by the formula
a_n = Cr_n +Ds_n \quad \text{ for every integer } n \geq 0
also satisfies the same recurrence relation.
Proof:
Suppose r_0, r_1, r_2, \dots, and s_0, s_1, s_2, \dots are sequences that
satisfy the same second-order linear homogeneous recurrence relation with
constant coefficients. In other words, suppose that for some real numbers A
and B,
r_k = Ar_{k - 1} + Br_{k - 2} \quad \text{ and } \quad s_k = As_{k - 1} + Bs_{k - 2}
for every integer k \geq 2. Suppose also that C and D are any numbers. Let
a_0, a_1, a_2, \dots be the sequence defined by
a_n = Cr_n + Ds_n \quad \text{ for every integer } n \geq 0
[We must show that a_0, a_1, a_2, \dots satisfies the same recurrence
relation as r_0, r_1, r_2, \dots and s_0, s_1, s_2, \dots. That is we must
show that a_k = Aa_{k - 1} + Ba_{k - 2}, for every integer k \geq 2.]
For every integer k \geq 2,
Aa_{k - 1} + Ba_{k - 2} = A(Cr_{k - 1} + Ds_{k - 1}) + B(Cr_{k - 2} + Ds_{k - 2})
= C(Ar_{k - 1} + Br{k - 2}) + D(As_{k - 1} + Bs_{k - 2})
= Cr_k + Ds_k
= a_k
Hence a_0, a_1, a_2, \dots satisfies the same recurrence relation as
r_0, r_1, r_2, \dots and s_0, s_1, s_2, \dots [as was to be shown].
Page 380
Theorem 5.8.3 Distinct-Roots Theorem
Suppose a sequence a_0, a_1, a_2, \dots satisfies a recurrence relation
a_k = Aa_{k - 1} + Ba_{k - 2}
for some real numbers A and B with B \neq 0 and every integer k \geq 2.
If the characteristic equation
t^2 - At - B = 0
has two distinct roots r and s, then a_0, a_1, a_2, \dots is given by the
explicit formula
a_n = Cr^n + Ds^n
where C and D are the numbers whose values are determined by the values
a_0 and a_1.
Proof:
Suppose that for some real numbers A and B, a sequence
a_0, a_1, a_2, \dots satisfies the recurrence relation
a_k = Aa_{k - 1} + Ba_{k - 2}, for every integer k \geq 2, and suppose the
characteristic equation t^2 - At - B = 0 has two distinct roots r and s.
We will show that
\text{for every integer } n \geq 0, \quad a_n = Cr^n + Ds^n
where C and D are numbers such that
a_0 = Cr^0 + Ds^0 \quad \text{ and } \quad a_1 = Cr^1 + Ds^1
Let P(n) be the equation
a_n = Cr^n + Ds^n
We use strong mathematical induction to prove that P(n) is true for each
integer n \geq 0. In the basis step, we prove that P(0) and P(1) are true.
We do this because in the inductive step we need the equation to hold for
n = 0 and n = 1 in order to prove that it holds for n = 2.
Show that P(0) and P(1) are true:
The truth of P(0) and P(1) is automatic because C and D are exactly
those numbers that make the following equations true:
a_0 = Cr^0 + Ds^0 \quad \text{ and } \quad a_1 = Cr^1 + Ds^1
Show that for every integer k \geq 1, if P(i) is true for each integer i
from 0 through k, then P(k + 1) is also true:
Suppose that k is any integer with k \geq 1 and for each integer i from
0 through k,
a_i = Cr^i + Ds^i
We must show that
a_{k + 1} = Cr^{k + 1} + Ds^{k + 1}
Now by the inductive hypothesis,
a_k = Cr^k + Ds^k \quad \text{ and } \quad a_{k - 1} = Cr^{k - 1} + Ds^{k - 1}
so
a_{k + 1} = Aa_k + Ba_{k - 1}
= A(Cr^k + Ds^k) + B(Cr^{k - 1} + Ds^{k - 1})
= C(Ar^k + Br^{k - 1}) + D(As^k + Bs^{k - 1})
= Cr^{k + 1} + Ds^{k + 1}
This is what was to be shown.
[The reason the last equality follows from Lemma 5.8.1 is that since r and
s satisfy the characteristic equation (5.8.2), the sequences
r^0, r^1, r^2, \dots and s^0, s^1, s^2, \dots satisfy the recurrence
relation (5.8.1).]
Page 384
Lemma 5.8.4
Let A and B be real numbers and suppose the characteristic equation
t^2 - At - B = 0
has a single root r. Then the sequences 1, r^1, r^2, r^3, \dots, r^n, \dots
and 0, r, 2r^2, 3r^3, \dots, nr^n, \dots both satisfy the recurrence relation
a_k = Aa_{k - 1} + Ba_{k - 2}
for each integer k \geq 2.
Page 384
Theorem 5.8.5 Single-Root Theorem
Suppose a sequence a_0, a_1, a_2, \dots satisfies a recurrence relation
a_k = Aa_{k - 1} + Ba_{k - 2}
for some real numbers A and B with B \neq 0 and for every integer
k \geq 2. If the characteristic equation t^2 - At - B = 0 has a single
(real) root r, then a_0, a_1, a_2, \dots is given by the explicit formula
a_n = Cr^n + Dnr^n
where C and D are the real numbers whose values are determined by the values
of a_0 and any other known value of the sequence.
Page 389
Recursive Definition for the Set of All Strings over a Finite Set
Let A be any finite set. Call the elements of A characters, and define the
set S of all strings over A as follows:
I. Base: \lambda is a string in S, where \lambda denotes the null
string, the "string" with no characters.
II. Recursion: New strings are formed according to the following rules:
(a) If u is any string in S and if c is any character in A, then
uc \text{ is a string in } S
where uc is called the concatenation of u and $c$, and is obtained by
appending c on the right of u.
(b) If u is a string in S, then both the concatenation of \lambda and u,
denoted \lambda u, and the concatenation of u and \lambda, denoted
u\lambda, are defined to equal u. Symbolically:
\lambda u = u\lambda = u
c If u and v are any strings in S, and if c is any character in A,
then the concatenation of u and vc is defined to equal the concatenation of
uv and c. Symbolically:
u(vc) = (uv)c
III. Restriction: Nothing is a string in S other than objects obtained from
the base and the recursion.
Page 389
Theorem 5.9.1 Characters are Strings
If A is a finite set and S is the set of all strings over A, then every
character in A is a string in S.
Proof:
(1) Suppose c is any character in A.
(2) By part I of the definition of string, \lambda is a string in S.
(3) By part II(a) of the definition of string, \lambda c is a string in S.
(4) By part I of the definition of string, \lambda c = c.
(5) Thus c is a string in S.
Page 391
Structural Induction for a Recursively Defined Set
Let S be a set that has been defined recursively, and let P(x) be a property
that objects in S may or may not satisfy. To prove that every object in S
satisfies P(x), perform the following two steps:
Step 1 (basis step):
Show that P(a) is true for each object a in the base for S.
Step 2 (inductive step):
Show that for each x in S, if P(x) is true and if y is obtained from x
by applying a rule from the recursion, then P(y) is true. To perform this
step,
suppose that x is an arbitrarily chosen element of S for which P(x) is
true.
[This supposition is the inductive hypothesis.]
Then
show that if y is obtained from x by applying a rule from the recursion
for S, then P(y) is true.
Conclusion: Because no objects other than those obtained from the base and
recursion are contained in S, steps 1 and 2 prove that P(x) is true for
every object x in S.
Page 392
Definition Length of a String
Given the set of all strings S over a finite set A, the length L of a
string in $S$ is defined as follows:
-
L(\lambda) = 0. -
For every string
uinSand for every characterainA, the length ofuais one more than the length ofu. Symbolically:
L(ua) = L(u) + 1 \quad \text{ where } \quad u \in S \text{ and } a \in A
Page 393
Theorem 5.9.2 Additive Property of String Length
If S is the set of all strings over a finite set A, then for all strings u
and v in S, L(uv) = L(u) + L(v).
Proof (by structural induction):
Let S be the set of all strings over a finite set A. Given any string v in
S, let the property P(v) be the sentence
For every string u in S, L(uv) = L(u) + L(v).
We will show that P(v) is true for every string v in S.
Show that P(a) is true for each string a in the base for S:
The only string in the base for S is \lambda, and if u is any string in
S, then
L(u\lambda) = L(u)
= L(u) + 0
= L(u) + L(\lambda)
This shows that P(\lambda) is true.
Show that for each string x in S, if P(x) is true and if y is obtained
from x by applying a rule from the recursion for S, then P(y) is true:
The recursion for S consists of three rules denoted II(a), II(b), II(c), but
rule II(a) is the only one that generates new strings in S. Suppose v is any
string in S such that P(v) is true. In other words, suppose that
L(uv) = L(u) + L(v). [This is the inductive hypothesis.]
When rule II(a) is applied to v, the result is vc, where c is a character
in A. So, to complete the inductive step, we must show that P(vc) is true.
Now
L(u(vc)) = L((uv)c)
= L(uv) + 1
= (L(u) + L(v)) + 1
= L(u) + (L(v) + 1)
= L(u) + L(vc)
Hence P(vc) is true [as was to be shown].
Conclusion:
Because there are no strings in S other than those obtained through the base
and the recursion for S, we conclude that every string in S satisfies the
additive property for string length.
Page 394
Theorem 5.9.3 The Concatenation of Any Two Strings is a String
If S is the set of all strings over a finite set A and u and v are any
strings in S, then uv is a string in S.
Proof (by structural induction):
Let S be the set of all strings over a finite set A. Given any string v in
S, let the property P(v) be the sentence
For every string u in S, uv is a string in S.
We will show that P(v) is true for every string v in S.
Show that P(a) is true for each string a in the base for S:
The only string in the base for S is \lambda, and if u is any string in
S, then by rule II(b) in the definition of string, u\lambda = u. Hence the
concatenation of u and \lambda is a string in S, and so P(\lambda) is
true.
Show that for each string x in S, if P(x) is true and if y is obtained
from x by applying a rule from the recursion for S, then P(y) is true:
The recursive definition for S consists of three rules denoted II(a), II(b),
and II(c), but rule II(a) is the only one that generates new strings in S.
Suppose v is any string in S such that P(v) is true. In other words,
suppose that for every string u in S, uv is a string in S. [This is the
inductive hypothesis.]
Then rule II(a) is applied to v, the result is vc, where c is a character
in A. To complete the inductive step, we must show that P(vc) is true. To do
so, we will show that u(vc) is a string in S.
Now because uv is a string in S, it follows from rule II(a) that (uv)c is
also a string in S. In addition, by rule II(c),
(uv)c = u(vc)
Therefore, u(vc) is a string in S, which means that P(vc) is true [as was
to be shown].
Conclusion:
Because there are no strings in S other than those obtained from 5he base and
the recursion for S, we conclude that the concatenation of any two strings in
S is a string in S.
Page 394
Theorem 5.9.4 Concatenation of Strings is Associative
If S is the set of all strings over a finite set A and u, v, and w are
any strings in S, then u(vw) = (uv)w.
Idea of a proof by structural induction: Let S be the set of all strings
over a finite set A. Given any string w in S, let the property P(w) be
the sentence
For all strings u and v in S, u(vw) = (uv)w.
The proof must show (1) that P(\lambda) is true, and (2) that if w is any
string in S such that P(w) is true and if y is obtained from w by
applying a rule from the recursion for S, then P(y) is true. Now when rule
II(a) is applied to w the result is wc for some character c in A. A
crucial step is to show that u((vw)c) = (u(vw))c. This follows from the
definition of string because u and vw are in S and c is in A.
Exercise 21 at the end of this section asks you to write a complete proof.