0% found this document useful (0 votes)
15 views29 pages

Proofs

Uploaded by

Brandon Tay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views29 pages

Proofs

Uploaded by

Brandon Tay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

COMP2121

Discrete Mathematics

Methods of Proof
Hubert Chan (Chapters 1.6, 1.7, 4.1)

[O1 Abstract Concepts]


[O2 Proof Techniques]

1
Fallacy: Beware of Wrong Proofs
• Claim: All girls have the same hairstyle.

• 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.

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

Thus, X, Y and the rest What is wrong


have the same hairstyle with that proof?
3
Example of a proof
A student in this class has not read the discrete mathematics textbook.
Everyone in this class passed the first quiz.
Hence, someone who passed the first quiz has not read the book.

C(x): x is in this class


B(x): x has read the book
P(x): x has passed the first quiz

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.

e.g. n2+4 > 0 n2  0


 n2 + 4  4
 n2 + 4 > 0

1)
1) We
Wecan
canstart
startwith
withsome
somerelated
relatedproposition
propositionqqwhich
whichisistrue
true
2)
2) Then,
Then,show
showthatthatqqppisistrue
true
3)
3) Since
Sinceqqisistrue,
true,so
soppmust
mustbe betrue
true

e.g. 2n+5 is odd Assume that 2n + 5 is even


Þ2n is odd
A contradiction occurs.
1)
1) Show
Showthatthatp
p FFisistrue
true
2)
2) That
Thatis,
is,we
weassume
assumethatthatppisisfalse,
false,then
thenlead
leadto
tosome
someproposition
propositionwhich
which
isisalways
alwaysfalse.
false.
3)
3) So,
So,ppmust
mustbe betrue
true
“Proof
“Proofbybycontradiction”
contradiction” [O2] [O2]

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

e.g. If n is odd, then n2 is odd. Suppose n is odd.


Then, n=2k+1 for some integer k.
It follows that n2 = 4k2+4k+1,
n2 = 2(2k2+2k)+1.
1.
1. Assume
Assumethat
thatppisistrue.
true. So, n2 is odd.
2.
2. Show
Showthat
thatqqisistrue.
true.

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

Proof by contradiction [O2]


Assume
Assumethat
thatpq
pqisisfalse
falseand
andleads
leadsto
toaacontradiction
contradiction

Example 1. If 6x + 9y = 101, then either x or y is not an integer.

Suppose that 6x + 9y = 101, and both x and y are integers.

Then, 3(2x+3y) = 101


and 2x + 3y = 101/3
Since 101/3 is not an integer

However, since we assume both x and y are integers,


we conclude that 2x + 3y is an integer.

Hence, contradiction!

9
(p  q)  (p  q) Its negation is: p  q

Proof by contradiction [O2]


Example 2. Prove that if x is irrational and y is rational, then x+y is irrational
Assume
Assumethat
thatpq
pqisisfalse
falseand
andleads
leadsto
toaacontradiction
contradiction

Suppose x is irrational and y is rational, but x+y is rational.


Then, x + y can be rewritten as a/b for two integers a,b
That is, (x+y) = a/b.
Since y is also rational, so y = c/d for two integers c, d
Then, x = a/b – c/d = (ad-cb)/bd
Since (ad-cb) and bd are both integers, it follows that x is rational.
A contradiction occurs.

10
Proof by Cases

e.g. If n is an integer not divisible by 3, then n2 mod 3 = 1.

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

pp==pp1 pp2 ...


...ppnn
1 2
To
Toprove
prove(p (p11pp22...
...ppnn)) q,q,
we
wecan
canprove
prove(p (p1q)  (p2 q)  ....  (pn q)
1q)  (p2 q)  ....  (pn q)
That
Thatis,
is,we
wehave
haveto toprove
prove(pi (pi q)
q)one
oneby
byone
onefor
foreach
eachi i

11
Mathematical Induction

Theorem: P(n) for all positive integers n.

A proof by mathematical induction consists of two steps.


Basis step: P(1) is true.
Inductive step: for any positive integer i, if P(i) is true, then P(i+1) is true
(induction hypothesis)

When we complete both steps, we have proved that P(n) is true for all positive
integer n  1.

Why mathematical induction works?


Since P(1) is true, so P(2) is true (inductive step)
Similarly, P(2) is true, so P(3) is true (inductive step again)
P(3) is true, so P(4) is true (...)
...
P(n) is true if n  1

Basic philosophy: [P(1) k>0 (P(k)  P(k+1))]


 n≥1 P(n)

12
Prove the following using mathematical induction.
(1) 1 + 3 + 5 + .... + (2n-1) = n2
(2) 2n < n! for all n > 3

(1) Base case:


n = 1, LHS = RHS, so the statement is true for n = 1.

(2) Induction step:


Assume that the statement is true for n = k. (Hypothesis)
Consider n = k + 1.
L.H.S. = 1 + 3 + 5 + … (2k – 1) + (2(k+1) – 1)
[by the hypothesis:]
L.H.S. = k2 + 2(k+1) – 1
= k2 + 2k + 1
= (k + 1)2
= R.H.S.
So, the statement is true for n = k + 1.

Therefore, the statement is true for all n = 1, 2, ….

13
Another form of mathematical induction

Basis step: P(1) is true.


Inductive step: for any positive integer i, if P(i) is true, then P(i+1) is true
if P(k) is true for all k  i, then P(i+1) is true
Since P(1) is true, so P(2) is true (inductive step)
Since P(1) and P(2) is true, so P(3) is true (inductive step again)
Again, P(1), P(2), and P(3) is true, so P(4) is true (...)
......
P(n) is true if n  1
Example.
Every integer k  2 is either a prime number or can be written as a product of
prime numbers.

14
Every integer k  2 is either a prime number or can be written as a product of
prime numbers.

Base case: k = 2, the statement is true.


Induction step: Assume that the statement is true for k  i (with k  2).
Consider k = i+1.
Case (a) – If k is a prime number, then the statement is true.
Case (b) – Otherwise, k is a composite number, k = k1  k2 where k1, k2  i.
By the hypothesis,
Both k1 and k2 can be written as a product of prime numbers.
Thus, k can also 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)

*(n-1) Time complexity


F(n-2)
= number of calls (nodes)
=n

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

Induction step: Assume it is true for n > 0 consider the case


for n+1.
Divide the chessboard into 4 2n x 2n boards.
The figure shows that each of the four
2n x 2n boards has exactly a missing square.
By the induction hypothesis, they can be
covered by the L-shaped pieces, so is the 2n+1
x 2n+1 board.

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

Procedure Move (n, X, Y)


(move n disks from peg X to peg Y)
If n = 1, X Y Z
then move the disk from X to Y
else Move (n-1, X, Z)
move disk n from X
to Y
Move (n-1, Z, Y)

Correctness can be proved by


mathematical induction.
23
Recursive Algorithms
Recursive algorithm is a common technique for problem solving.
Advantages:
Easy to debug implement/comprehend, good structure,
correctness can be proved easily by mathematical induction.
Attention should be paid to the recursive step and the initial cases.

Hanoi Problem
M(n) = number of moves for solving the n-disks Hanoi
problem
= 2M(n1) + 1 n > 1Procedure Move (n, X, Y)
1 n=1 (move n disks from peg X to peg Y)
M(n) = 2 (2M(n2) + 1) + 1 If n = 1, then move the disk from X to Y
= 22M(n2) + 2 + 1 else move (n-1, X, Z)
move disk n from X to Y
= 23M(n3) + 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)

Assume n = 2k , k = log2n F(n/2)


f(n) = f(n/2) + 1
= f(n/22) + 1 + 1
F(n/4)
:
= f(n/2k) + k
= f(1) + k
F(1)
= k+1
= log2n + 1
27
Evaluating x 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

You might also like