Download 02-proof

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Philosophy of mathematics wikipedia , lookup

Addition wikipedia , lookup

Georg Cantor's first set theory article wikipedia , lookup

Foundations of mathematics wikipedia , lookup

Principia Mathematica wikipedia , lookup

Wiles's proof of Fermat's Last Theorem wikipedia , lookup

Fermat's Last Theorem wikipedia , lookup

Halting problem wikipedia , lookup

Elementary mathematics wikipedia , lookup

Brouwer–Hilbert controversy wikipedia , lookup

Fundamental theorem of algebra wikipedia , lookup

Theorem wikipedia , lookup

Collatz conjecture wikipedia , lookup

Natural deduction wikipedia , lookup

Mathematical proof wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Transcript
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,
say Y
Y
Y
k
X
k
Induction
hypothesis:
X and others have
the same hairstyle
Thus, X, Y and the rest
have the same hairstyle
Induction
hypothesis:
Y and others have
the same hairstyle
What is wrong
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
1)
2)
3)


n2  0
n2 + 4  4
n2 + 4 > 0
We can start with some related proposition q which is true
Then, show that q  p is true
Since q is true, so p must be true
e.g. 2n+5 is odd
Assume that 2n + 5 is even
2n is odd
A contradiction occurs.
Show that p  F is true
That is, we assume that p is false, then lead to some proposition which
is always false.
3) So, p must be true
“Proof by contradiction” [O2]
1)
2)
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.
1.
2.
Assume that p is true.
Show that q is true.
Suppose n is odd.
Then, n=2k+1 for some integer k.
It follows that n2 = 4k2+4k+1,
n2 = 2(2k2+2k)+1.
So, n2 is odd.
7
Indirect Proof (Contrapositive)
e.g. If 3n+2 is odd, then n is odd.
1.
2.
Assume that q is false.
Show that p is false.
Suppose n is even.
Then, 3n is even
3n+2 is even
So, 3n+2 is odd  n is odd
(p  q)  (q  p)
8
(p  q)  (p  q)
Its negation is: p  q
Proof by contradiction [O2]
Assume that pq is false and leads to a 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 that pq is false and leads to a 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
p = p1  p2  ...  pn
To prove (p1  p2  ...  pn )  q,
we can prove (p1q)  (p2 q)  ....  (pn q)
That is, we have to prove (pi q) one by one for each 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 argument works only when
k > 1, (at least 3 girls in the group to start with) i.e., it makes use of the
hypothesis that it is true for k = 2, but this is not yet proved in the
base 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)
F(n-2)
Time complexity
= 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.
C
A
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
22
Hanoi Problem
Procedure Move (n, X, Y)
(move n disks from peg X to peg Y)
If n = 1,
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)
X
Y
Z
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>1
Procedure Move (n, X, Y)
1
n=1
M(n)=
=
=
=
=
2 (2M(n2) + 1) + 1
22M(n2) + 2 + 1
23M(n3) + 22 + 2 + 1
2n-1M(1) + 2n-2 + … + 2 + 1
2n  1
(move n disks from peg X to peg Y)
If n = 1, 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)
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
…..
subproblem of size n/b
…..
a subproblems altogether
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

n 1
1
26
A log2n Solution - Intuition


f ( n)  


n
f ( ) 1
2
1
n 1
Assume n = 2k , k = log2n
f(n)
=
f(n/2) + 1
=
f(n/22) + 1 + 1
:
=
f(n/2k) + k
=
f(1) + k
=
k+1
=
log2n + 1
n 1
F(n)
F(n/2)
F(n/4)
F(1)
27
Evaluating xn
• If n=1, output x
 Number of multiplication: f(1)=0
• If n>1, consider two cases:
n
n/2
 If n is even, x  x
 xn/ 2
 Number
of multiplications:
n
(n 1)/ 2
x

x
x
 If n is odd,
 Number
of multiplications:
n
• For all n>1, f (n)  f ( 2 )  2
 Define k  log 2 n
n
f ( n)  f ( )  1
2
( n 1) / 2
x
f ( n)  f (
n -1
n
)  2  f ( )  2
2
2
n
n
n
f
(
n
)

f
(
)

2

f
(
)

2

2

...

f
(

 2 
 2 2 
 2 k  )  2  k  2log 2 n 
28
Fibonacci Numbers
• F(0) = 0, F(1) = 1
• For n > 1, F(n) = F(n-1) + F(n-2).
29