Mathematical Foundations of Computer Science Lecture Outline
Mathematical Foundations of Computer Science Lecture Outline
Lecture Outline
September 25, 2018
Example. Let n be a non-negative integer. Show that any 2n ×2n region with one central
square removed can be tiled using L-shaped pieces, where the pieces cover three squares at
a time (Figure 1).
Solution. (Attempt 1) Let Rn denote a 2n × 2n region. Let P (n) be the property that
Rn with one central square removed can be tiled using L-shaped pieces.
Surprisingly, we can get around this obstacle by proving the following stronger claim.
“For all positive integers n, any Rn region with any one square removed can be L-tiled.”
Let P (n) be the property that Rn without one square can be L-tiled.
Induction Hypothesis: Assume that P (k) is true for some k.
2 Lecture Outline September 25, 2018
Base Case: We want to prove that P (0) is true. This is true because a 1 × 1 region with
one square removed requires 0 tiles.
Induction Step: We want to prove that P (k + 1) is true, i.e., region Rk+1 wthout one square
that is located anywhere can be L-tiled. Divide Rk+1 into four Rk regions. One of the
four Rk regions that does not have one square can be L-tiled (using induction hypothesis).
Each of the other three Rk regions without the corner square that is located at the center
of Rk+1 can be L-tiled (using induction hypothesis). By using one more L-tile we can cover
the three central squares of Rk+1 .
Strong Induction.
For any property P , if P (0) and ∀n ∈ N, P (0) ∧ P (1) ∧ P (2) ∧ · · · ∧ P (n) → P (n + 1), then
∀n ∈ N, P (n).
Example. Prove that if n is an integer greater than 1 then either n is a prime or it can
be written as a product of primes.
Example. Prove that, for any positive integer n, if x1 , x2 , . . . , xn are n distinct real
numbers, then no matter how the parenthesis are inserted into their product, the number
of multiplications used to compute the product is n − 1.
Solution. Let P (n) be the property that “If x1 , x2 , . . . , xn are n distinct real numbers,
then no matter how the parentheses are inserted into their product, the number of multi-
plications used to compute the product is n − 1”.
Induction Hypothesis: Assume that P (j) is true for all j such that 1 ≤ j ≤ k.
Base Case: P (1) is true, since x1 is computed using 0 multiplications.
Induction Step: We want to prove P (k + 1). Consider the product of k + 1 distinct fac-
tors, x1 , x2 , . . . , xk+1 . When parentheses are inserted in order to compute the product of
factors, some multiplication must be the final one. Consider the two terms, of this final
multiplication. Each one is a product of at most k factors. Suppose the first and the second
term in the final multiplication contain fk and sk factors. Clearly, 1 ≤ fk , sk ≤ k. Thus,
by induction hypothesis, the number of multiplications to obtain the first term of the final
multiplication is fk − 1 and the number of multiplications to obtain the second term of the
final multiplication is sk − 1. It follows that the number of multiplications to compute the
product of x1 , x2 , . . . , xk , xk+1 is
(fk − 1) + (sk − 1) + 1 = fk + sk − 1 = k + 1 − 1 = k
Example. The game of NIM is played as follows: Some positive number of sticks are
placed on the ground. Two players take turns, removing one, two or three sticks. The
player to remove the last stick loses.
A winning strategy is a rule for how many sticks to remove when there are n left. Prove
that the first player has a winning strategy iff the number of sticks, n, is not 4k + 1 for any
k ∈ N.
Solution. We will show that if n = 4k + 1 then player 2 has a strategy that will force a
win for him, otherwise, player 1 has a strategy that will force a win for him.
Let P (n) be the property that if n = 4k + 1 for some k ∈ N then the first player loses, and
if n = 4k, 4k + 2, or 4k + 3, the first player wins. This exhausts all possible cases for n.
Induction Hypothesis: Assume that for some z ≥ 1, P (j) is true for all j such that 1 ≤ j ≤ z.
Base Case: P (1) is true. The first player has no choice but to remove one stick and lose.
Induction Step: We want to prove P (z + 1). We consider the following four cases.
Case I: z + 1 = 4k + 1, for some k. We have already handled the base case, so we can
assume that z + 1 ≥ 5. Consider what the first player might do to win: he can remove 1,
2, or 3 sticks. If he removes one stick then the remaining number of sticks n = 4k. By
strong induction, the player who plays at this point has a winning strategy. So the player
who played first loses. Similarly, if the first player removes two sticks or three sticks, the
remaining number of sticks is 4(k − 1) + 3 and 4(k − 1) + 2 respectively. Again, the first
player loses (using induction hypothesis). Thus, in this case, the first player loses regardless
of what move he/she makes.
Case II: z + 1 = 4k, or z + 1 = 4k + 2, or z + 1 = 4k + 3. If the first player removes three
4 Lecture Outline September 25, 2018
sticks in the first case, one stick in the second case, and two sticks in the third case then
the second player sees 4(k − 1) + 1 sticks in the first case and 4k + 1 sticks in the other two
cases. By induction hypothesis, in each case the second player loses.
Example. Prove that the two forms of induction, weak induction and strong induction,
are equivalent. In other words, prove that any statement that admits a strong induction
proof can be proved using weak induction and vice-versa.
Solution. Suppose we want to show that a P (n) is true for all positive integers n ≥ n0 .
The two forms of inductive proofs are as follows.
We will show that it is always possible to convert a strong induction proof into a weak
induction proof and vice-versa.
The conversion from a weak induction proof to a strong induction proof is trivial, since (bs )
implies (bw ).
We now show that a strong induction proof can be converted to a weak induction proof.
Let
.
Q(n) = P (n0 ) ∧ P (n0 + 1) ∧ · · · ∧ P (n)
Induction Hypothesis: Assume that Q(k) is true for some k ≥ n0 .
Base Case: Since Q(n0 ) = P (n0 ) and we know that P (n0 ) is true from (as ), Q(n0 ) is true.
Induction Step: We want to show that Q(k) =⇒ Q(k + 1). We have