CS1231 Tutorial 1 Informal Introduction to Methods of Proof It is

advertisement
CS1231
Tutorial 1
Informal Introduction to Methods of Proof
It is recommended that you explore the available resources in the library and on the Internet to answer
the quesions. This tutorial must be prepared in writing. Make two copies of your answers: one for you
and one for the tutor. Bring your lecture notes to the tutorial.
1. Prove that the product of two odd natural numbers is an odd natural number.
Solution: IN CLASS
What are the different types of proof that we have seen in the lecture?
• Direct Proof,
• Equivalence Proof,
• Proof by Exhaustion,
• Proof by Counter Example,
• Proof by Construction,
• Pure Existence Proof.
• Contrapositive Proof,
• Proof by Contradiction,
• Proof by Induction,
• Pigeon Hole Principle,
• Combinatorial Proof,
• Inclusion-Exclusion Principle.
Proof Sketch. This is a direct proof. We compute the product and show that it is odd.
Proof.
1. Let n and m be two odd natural numbers.
2. We know that there exists a natural number k such that n = (2 × k) + 1 by definition of
an odd natural number.
3. We know that there exists a natural number p such that m = (2 × p) + 1 by definition of
an odd natural number.
4. Therefore n × m = ((2 × k) + 1) × ((2 × p) + 1).
5. Therefore n × m = ((2 × k) × ((2 × p) + 1)) + ((2 × p) + 1) by distributivity of × over +.
6. Therefore n × m = (((2 × k) × (2 × p)) + (2 × k)) + ((2 × p) + 1) by distributivity of × over
+.
7. Therefore n × m = (2 × k × 2 × p) + (2 × k) + (2 × p) + 1 by associativity of × and +.
8. Therefore n×m = 2×((k ×2×p)+k +p)+1 by distributivity of × over + and associativity
of +.
CS1231
9. Therefore n × m is of the form (2 × q) + 1 where q = ((k × 2 × p) + k + p) is a natural
number.
10. Therefore n × m is odd.
Q.E.D.
IN CLASS
What is the contrapositive of the statement “the product of two odd natural numbers is an odd
natural number”? Is it true?
if a natural number is even then it is not the product of two odd natural numbers.
the initial proposition is true therefore the contrapositive is true.
Note that it does not mean that it is the product of two even numbers (proof by counter
example 12 = 3 × 4).
IN CLASS
What is the converse of the statement “the product of two odd natural numbers is an odd natural
number”? Is it true?
if a natural number is odd then it is the product of two odd natural numbers.
It could be true or false. The relationship between a proposition and its converse is only
syntactical.
In this case it is true. Every odd number is the product of 1, which is odd, with itself.
This constitutes a proof of existence by construction.
2. Prove that 2p×q − 1 = (2p − 1) × (
Pq−1
i=0
2p×i ) for two natural numbers p and q.
Solution: IN CLASS
Explain the big Sigma notation.
Pq−1
Proof Sketch. This is a direct proof. We transform (2p − 1) × ( i=0 2p×i ).
Proof.
1. Let p and q be two natural numbers.
Pq−1
Pq−1
Pq−1
2. We know that (2p − 1) × ( i=0 2p×i ) = 2p × ( i=0 2p×i ) − ( i=0 2p×i ).
Pq−1
Pq
Pq−1
3. Therefore (2p − 1) × ( i=0 2p×i ) = ( i=1 2p×i ) − ( i=0 2p×i ).
Pq−1
4. Therefore (2p − 1) × ( i=0 2p×i ) = 2q×p − 1.
Q.E.D.
IN CLASS
What known properties have been used?
3. Find a definition of a prime number (for natural numbers).
Solution: A natural number is prime iff it not divisible by any other natural number than 1
and itself.
Page 2
CS1231
4. Prove that if 2n − 1 is prime, then n is prime for n being a natural number.
Solution:
Proof Sketch. We prove the contrapositive, namely that if n is not prime then 2n − 1 is not
prime.
Proof.
1. Let n be a natural number.
2. We know that n is not prime, then 2n − 1 can be written 2p×q − 1 by definition of prime.
Pq−1
3. Therefore2n − 1 = (2p − 1) × ( i=0 2p×i )where both these factors are different from n and
1 (Why? We should make two subproofs here ”Let us prove that ...”)
Q.E.D.
IN CLASS
Prime numbers of the form 2n − 1 are called Mersenne primes. We only know 47 such numbers.
The largest is (243112609 − 1). It is also the largest known prime number.
5. Find a proof by contradiction that there does not exist one largest prime natural number (larger
than all other prime natural numbers).
Solution:
Proof Sketch. We assume that there are only n prime natural numbers p1 , ..., pn in increasing
order (at least 3) and derive a contradiction.
Proof.
1. We know that there are at least three prime numbers: 2, 3 and 5.
2. Let us assume that there exists a largest prime number.
(2.1) Therefore there are only n prime natural numbers p1 , ..., pn in increasing order for n
at least equal to 3.
Qn
(2.2) Let us consider the number N = i=1 pi .
(2.3) Therefore N − 1 is larger that all the pi .
(2.4) Therefore N − 1 is not prime by hypothesis.
(2.5) Therefore it is divisible by at least one of the pi , say p.
(2.6) Therefore N − (N − 1) = 1 is dividable by p.
(2.7) This is a contradiction.
3. Therefore there does not exist a largest prime number.
Q.E.D.
6. What is the sum of the first n odd numbers? Find the expression. Enounce the corresponding
proposition. Prove it by induction. Suggest an algorithm for computing the square root of a perfect
square using multiplication, addition and subtraction only.
Solution: We first notice that:
• 1 + 3 = 4 = 22 .
Page 3
CS1231
• 1 + 3 + 5 = 9 = 32 .
• 1 + 3 + 5 + 7 = 16 = 42 .
Proposition The sum of the first n odd numbers is n2 . This can be written:
n−1
X
2 × i + 1 = n2
i=1
Proof Sketch. We prove the proposition by induction on n.
Proof.
1. Base case: for n = 1:
0
X
(2 × i + 1) = 1 = 12
i=0
2. Induction Hypothesis: Let us assume that for n:
Pn−1
i=0
(2 × i + 1) = n2 .
3. Induction step:
(3.1) Therefore
(3.2) Therefore
(3.3) Therefore
Pn
i=0 (2
Pn
i=0 (2
Pn
i=0 (2
Pn−1
× i + 1) = ( i=0 (2 × i + 1)) + (2n + 1).
× i + 1) = n2 + 2n + 1.
× i + 1) = (n + 1)2 .
Q.E.D.
Algorithm
INPUT: s, a perfect square;
r = 0;
REPEAT
s := s − (2 × r + 1);
r := r + 1;
UNTIL s = 0;
RETURN r;
7. A file is a sequence of 1 and 0. The length of the file in bits is the number of 1 and 0. A lossless
compression algorithm (for example as used in ZIP) compresses the file into another file (hopefully
smaller) such that the file can be decompressed without any loss (we can recover the original file).
Argue (give a proof skecth in English), by contradiction and using the pigeonhole principle, that a
lossless compression necessarily compresses some files into files of the same or possibly larger size.
Consider the lossless compression of files of size n.
Solution:
Proof Sketch. Let us assume that there exists a lossless compression algorithm that compresses
all files of size n into strictly smaller files (at most size n − 1). In order to be able to decompress
without loss all the compressed files must be different. However there are 2n − 1 files of size
n − 1 (sum of the powers of 2) which is smaller than the number of files of size n (2n ). By
the pigeonhole principle, two different files will be compressed into the same file and therefore
cannot be decompressed without loss (confusing them). This is a contradiction.
IN CLASS
If time permits, write the complete proof.
Page 4
CS1231
8. Forrest Gump has a box of chocolate containing 100 pieces. Exactly 77 are not filled with liquor,
exactly 75 are not filled with nuts, and exactly 5 are filled with both nuts and liquor. Forrest Gump
is allergic to liquor and to nuts. How many chocolates can he safely eat?
Solution:
Proposition He can safely eat 57 chocolates.
Proof Skecth. There are (100 − 77) + (100 − 75) − 5 = 43 filled with chocolate or nuts, by the
inclusion exclusion principle. He can safely eat the 57 remaining chocolates.
IN CLASS
If time permits write the complete proof. Notice that if we ask if there exists a chocolate that
he can eat safely, the answer is yes and the above would be a pure existence proof.
Page 5
Download