SM242 Week 5 (Notes based on Epp Chapter 3) II. Methods of Proof and Number Theory 10. The Fundamental Theorem of Arithmetic “The Unique Factorization Theorem” (1801) A. Any positive integer greater than one can be written as a product of prime numbers. That is, given any integer n > 1, there exist distinct prime numbers p1 , p2 ,... pk and positive integers e1 , e2 ,...ek such that n p1e1 p2 e2 p3e3 ...pk ek This factorization is unique. B. Example: What is the prime factorization of 100? C. The process of finding a prime factorization can be simplified by noting that: If n is a composite integer, then n has a prime divisor less than or equal to n Example: Show that 101 is prime. You may be surprised to learn that the process of finding “large” prime numbers is extremely important nowadays. It may also surprise you to hear that it is very hard to determine the unique factorization of very large numbers. We will discuss a simple procedure that can easily lend itself to pen-and-paper calculations (and a simple implementation as a program). D. We summarize our results by presenting a simple procedure to determine the prime factorization of an integer n: Begin by dividing n by successive primes, starting with 2, but not ever checking primes that are n . Suppose we find a prime factor p. p will now be part of the factorization of n. We continue n n the process by finding the prime factors of , starting with p, but not checking above . p p Continue the process until the factorization has been reduced to a prime. 1 E. Example: Find the prime factorization of 7007. 11. The Quotient Remainder Theorem A. Consider dividing 19 by 5: 3 5 19 15 4 We have a quotient of 3 and a remainder of 4. We can write the above calculation as 19 = 3·5 + 4 Note that the remainder of a division of 5 into anything must be less than 5. In general, when we divide an integer a by another integer b, the result is some quotient q and a remainder that must be smaller than b. B. Quotient Remainder Theorem Given any integer a and a positive integer b, there exist unique integers q and r such that a b q r and 0 r b . Terminology: In the Quotient Remainder Theorem above, a is called the dividend b is called the divisor q is called the quotient r is called the remainder 2 C. Examples Suppose a = 25, b = 7. Find values of q and r such that a b q r with 0 r b 25 = 3 · 7 + 4 quotient remainder Suppose a = - 25, b = 7. Find values of q and r such that a b q r with 0 r b Suppose a = 59, b = 60. Find values of q and r such that a b q r with 0 r b 12. div and mod A. div Given a nonnegative integer a and a positive integer b, a div b is the integer quotient obtained when a is divided by b. Note that the div operator is the same as the familiar integer division operation in C++. B. Example: What is 50 div 6 ? C. mod Given a nonnegative integer a and a positive integer b, a mod b is the integer remainder obtained when a is divided by b. Note that the mod operator is the same as the familiar % operator in C++. D. Example: What is 50 mod 6 E. div and mod and the Quotient-Remainder Theorem. a b q r q = a div b r = a mod b F. Example. Today is Friday. What day of the week will it be one year from today? 3 13. Examples Example 1: When an integer a is divided by 7, the remainder is 4. What is the remainder when 5a is divided by 7? Example 1: When an integer a is divided by 12, the remainder is 5. What is the remainder when 8a is divided by 12? 14. The Division Algorithm The Quotient Remainder Theorem says that given any integer a and a positive integer b, there exist unique integers q and r such that a b q r and 0 r b . The Division Algorithm provides a method for determining q and r (the quotient and remainder) from the division of a by b. The algorithm is very simple: We subtract b repeatedly from a until the result of the subtraction is less than b. The total number of subtractions performed is the quotient q. The remainder r is then a – (b · q). 15. Some C++ Examples 1. Write a C++ program to implement the Division Algorithm You should convince yourself that the program on the next page will do the trick. 4 #include<iostream> using namespace std; int main( ) { int r, a, d, q = 0; cout << "Enter a nonnegative integer a: "; cin >> a; cout << "Enter a positive integer d: "; cin >> d; r = a; while ( r >= d ) { r = r - d; q = q + 1; } cout<<"The quotient is " << q <<" and the reaminder is "<< r << endl; return 0; } 2. What is the output of the following simple C++ program below: #include<iostream> using namespace std; int main( ) { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); double crucial_parameter = 1000000000000; int crucial_parameter_int; cout<<"The crucial parameter is \t\t\t "<< crucial_parameter << endl; crucial_parameter_int = crucial_parameter ; cout<<"As an integer, this crucial parameter is \t"<< crucial_parameter_int<<endl; return 0; } 5 3. Consider the program below, which has the output shown to the right. #include<iostream> using namespace std; int main( ) { const int size = 4; double array[ size ] = { 1.5 , -2.3 , 7.8 , 9.9 }; cout << "array = " << array << endl; return 0; } Part A. What is the meaning of the output? Part B. What binary number corresponds to the hexadecimal number appearing in the output? Part C. What would be the hexadecimal address of the location of array[3]? Briefly explain your answer 16. Proof Technique 5: Proof by Contradiction (“Reductio ad Absurdum” or “Indirect Proof”) A. Introductory Example A crime has been committed!!! The slogan “SM242 is the best!” has been spray-painted all over the exterior of the Superintendent’s House. It is a known for a fact that this crime occurred on Wednesday between 0900-0930. MIDN Tublin has been charged with the crime and is in prison in Bancroft Hall. He has—for some completely unknown reason—hired the famous sea-lawyer firm of Miller, Waymouth and Craner. You are the jury that will decide MIDN Tublin’s fate. 6 His legal team argues as follows: My client is innocent Your Honor! If MIDN Tublin is guilty, then MIDN Tublin spray-painted the house. 7 B. Key idea underlying Proof by Contradiction: As we mentioned in the first lecture, a statement must be either true of false. C. Basic steps to demonstrate a Proof by Contradiction: You want to prove that a certain statement is true. D. Example. Prove the statement: “There is no largest integer.” Proof by contradiction: 8 E. Example. Prove the statement: The sum of any rational number and any irrational number is irrational. Proof by contradiction: The original statement can be written symbolically as: The negation of this statement is Suppose the original statement is false, so that the negation is true. That is, suppose, we have a: Then we can say that: F. Example. Prove the statement: For all real numbers a and b, if a b 2 then either a 1 or b 1 . Proof by contradiction: The original statement can be written symbolically as: real numbers a and b, if a b 2 then either a 1 or b 1 . The negation of this statement is Suppose the original statement is false, so that the negation is true. That is, suppose: So, we have 9 G. Example. Prove the statement: For any integer a and any prime number p, if p | a then p ∤ (a+1). Proof by contradiction: Suppose not. Suppose instead that: H. Example. Prove the statement: There are infinitely many prime numbers. Note: This is one of the most famous theorems in mathematics, attributed to Euclid (300 BC). Proof by contradiction: Suppose not. Suppose instead that: 10 I. Example. Prove the statement: For any integer n, if n 2 is even, then n is even. Proof by contradiction: The original statement can be written symbolically as: integers n, if n 2 is even, then n is even. The negation of this statement is Suppose the original statement is false, so that the negation is true. That is, suppose we have an integer n, such that J. A fact about fractions Any fraction can be rewritten in a way such that the numerator and denominator have no common divisors. 9 3 3 3 10 2 5 2 ; Examples: 12 3 4 4 15 3 5 3 K. Example. Prove that 2 is irrational. Another famous proof. (Aristotle 350 B.C.) Since any fraction can be rewritten in a way such that the numerator and denominator have no common divisors, we assume that a and b have no common divisors. Squaring the equation above, we obtain 11 Then, a 2 2b 2 . Since b 2 is an integer, this shows that Using the theorem proved on the prior page, we can conclude that If a = 2k, then a 2 4k 2 2b2 so that b2 2k 2 . I insist that we do another example. L. Example. Prove the statement: If 3n + 2 is odd, then n is odd. Proof by contradiction: The statement can be written symbolically as: integers n, if 3n + 2 is odd, then n is odd. The negation of this statement is Let’s assume the original statement is false, so that the negation is true. Thus, we suppose there is an n such that: and we try to show that this leads to a contradiction. 12