Proofs
Proofs
Discrete Mathematics
Methods of Proof
Hubert Chan (Chapters 1.6, 1.7, 4.1)
1
Fallacy: Beware of Wrong Proofs
• Claim: All girls have the same hairstyle.
2
k+1
Y Remove a girl, say X
X
X
Remove a girl, k Induction
say Y Y hypothesis:
Induction Y and others have
hypothesis: the same hairstyle
Y k X and others have
X the same hairstyle
x (C(x) B(x))
x (C(x) P(x))
------------------------
x (P(x) B(x)) Is the argument valid?
Yes.
x (C(x) B(x)) implies that there is a student x0 in the class that C(x0) and B(x0)
x (C(x) P(x)) implies that for all students in the class, if C(x) then P(x).
Since C(x0), we have P(x0). Hence we have P(x0) and B(x0), which means
x (P(x) B(x))
4
Methods of Proof
1. Theorem: p is true.
1)
1) We
Wecan
canstart
startwith
withsome
somerelated
relatedproposition
propositionqqwhich
whichisistrue
true
2)
2) Then,
Then,show
showthatthatqqppisistrue
true
3)
3) Since
Sinceqqisistrue,
true,so
soppmust
mustbe betrue
true
5
Theorem. 2 is irrational
Assume 2 is rational.
$ integers a, b > 0 such that 2 = a/b;
and a and b are relatively prime.
2b2 = a2.
a2 is even.
a is even.
a = 2c for some integer c.
b2 = a2/2 = 2c2
b2 is even.
b is even.
a and b have a common factor 2.
A contradiction occurs.
6
2. Theorem: p q is true.
Direct Proof
7
Indirect Proof (Contrapositive)
e.g. If 3n+2 is odd, then n is odd. Suppose n is even.
Then, 3n is even
1. 3n+2 is even
1. Assume
Assumethat
thatqqisisfalse.
false. So, 3n+2 is odd n is odd
2.
2. Show
Showthat
thatppisisfalse.
false.
(p q) (q p)
8
(p q) (p q) Its negation is: p q
Hence, contradiction!
9
(p q) (p q) Its negation is: p q
10
Proof by Cases
Case 1: n mod 3 = 1.
Then, n = 3k + 1 for some integer k.
Thus, n2 = 9k2 + 6k + 1 = 3(3k2 + 2k) + 1.
So, n2 mod 3 = 1.
Case 2: n mod 3 = 2.
Then, n = 3k + 2 for some integer k.
Thus, n2 = 9k2 + 12k + 4 = 3(3k2 + 4k +1) + 1.
So, n2 mod 3 = 1.
So, p q is true
11
Mathematical Induction
When we complete both steps, we have proved that P(n) is true for all positive
integer n 1.
12
Prove the following using mathematical induction.
(1) 1 + 3 + 5 + .... + (2n-1) = n2
(2) 2n < n! for all n > 3
13
Another form of mathematical induction
14
Every integer k 2 is either a prime number or can be written as a product of
prime numbers.
15
All girls have the same hairstyle?
An incorrect Proof:
By induction on the number of girls.
Basis step: Obviously true for any group of one girl.
Induction step:
Assume that any group of k 1 girls have same hairstyle.
Let us then consider any group of (k+1) girls.
Delete a girl x, the remaining k girls have the same hairstyle
Delete another girl y, the remaining k girls have the same hairstyle
Hence the (k+1) girls have the same hairstyle!
The
Theargument
argumentworks
worksonly onlywhen
when
kk>>1,
1,(at
(atleast
least33girls
girlsininthethegroup
groupto
tostart
startwith)
with)i.e.,
i.e.,ititmakes
makesuse
useof ofthe
the
hypothesis
hypothesisthat
thatititisistrue
truefor
forkk==2,
2,but
butthis
thisisisnot
notyet
yetproved
provedininthe
the
base
basecase!
case!
16
Recursive Algorithms [O1]
To solve P(n) for n ≥ 1, where P(n) is a problem of size n
when n = 1, solve P(1) directly
when n > 1, solve P(n) based on the solution of P(n-1)
Why this approach works? mathematical induction.
For example:
To compute F(n) = n! = n(n-1)(n-2)…1 = n*(n-1)!
Procedure F(n)
if n=1 then return (1) else return (n*F(n-1))
Try F(4) = 4*F(3); needed to solve F(3)Output 24
F(3) = 3*F(2); needed to solve F(2)Output 6
F(2) = 2*F(1); needed to solve F(1)Output 2
F(1) = 1; Output 1
17
Representation of Recursive Algorithm
F(n)
*n
F(n-1)
F(1)
18
Another example:
Covering Problem by L-tiles
Show that any 2n x 2n chessboard with one square
removed can be filled using L-shaped pieces.
19
Basis step
n=1
20
Covering Chessboard with L-tiles
Any 2n x 2n chessboard missing one square can be
filled by L-tiles based on induction (recursion).
21
Hanoi Problem (Chapter 7.1)
Given 3 pegs with n disks of different sizes. Initially all the disks are placed
on the first peg in the order of sizes, with the largest on the bottom.
The game is to move all disks to another peg under the following rules:
Disks are moved one at a time
No disk is placed on top of a smaller disk.
Example: moving 3 disks from Disk A to Disk B.
A B C
A B C A B C
A B C A B C
A B C A B C
A B C A B C 22
Hanoi Problem
Hanoi Problem
M(n) = number of moves for solving the n-disks Hanoi
problem
= 2M(n1) + 1 n > 1Procedure Move (n, X, Y)
1 n=1 (move n disks from peg X to peg Y)
M(n) = 2 (2M(n2) + 1) + 1 If n = 1, then move the disk from X to Y
= 22M(n2) + 2 + 1 else move (n-1, X, Z)
move disk n from X to Y
= 23M(n3) + 22 + 2 + 1
move (n-1, Z, Y)
= 2n-1M(1) + 2n-2 + … + 2 + 1
= 2n 1
24
Divide and Conquer Strategy
Divide the problem into sub-problems
Solve all subproblems (recursively)
Combine subproblems’ solutions to find the solution of the whole.
problem of size n
divide cost
….. a subproblems altogether
subproblem of size n/b subproblem of size n/b
…..
combine cost
Solution for the
original problem
f(n) = number of operations required to solve the
problem of size n.
= a f(n/b) + divide cost and combine cost
25
Divide and Conquer Examples
Binary Search - Search a sorted list of n elements for a given x
Method compare x with the middle element of the list and reduce the
search window by half (left half or right half)
f(n) stands for the number of comparisons
n
f ( ) 1 n 1
f ( n) 2
1 n 1
26
A log2n Solution - Intuition
n
f ( ) 1 n 1
f ( n) 2
1 n 1 F(n)
• If n=1, output x
Number of multiplication: f(1)=0
• If n>1, consider two cases:
If n is even, x n x n / 2 x n / 2
n
Number of multiplications: f ( n) f ( ) 1
2
If n is odd, x n x(n 1)/ 2 x ( n 1) / 2
x
Number of multiplications: n -1 n
f ( n) f ( ) 2 f ( ) 2
2 2
• For all n>1, f (n) f ( n ) 2
2
Define k log n
2
f (n) f ( n ) 2 f ( n ) 2 2 ... f ( n ) 2 k 2 log n
2 22 2k 2
28
Fibonacci Numbers
• F(0) = 0, F(1) = 1
• For n > 1, F(n) = F(n-1) + F(n-2).
29