CS 103X: Discrete Structures Homework Assignment 3 Solutions



Similar documents
Homework until Test #2

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

8 Divisibility and prime numbers

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

Today s Topics. Primes & Greatest Common Divisors

Section 4.2: The Division Algorithm and Greatest Common Divisors

The last three chapters introduced three major proof techniques: direct,

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

MATH10040 Chapter 2: Prime and relatively prime numbers

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Continued Fractions and the Euclidean Algorithm

8 Primes and Modular Arithmetic

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12

GREATEST COMMON DIVISOR

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, Notes on Algebra

3. Mathematical Induction

6.2 Permutations continued

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Factoring Algorithms

GCDs and Relatively Prime Numbers! CSCI 2824, Fall 2014!

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm.

MATH 289 PROBLEM SET 4: NUMBER THEORY

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

k, then n = p2α 1 1 pα k

Mathematical Induction

Lecture 13 - Basic Number Theory.

Handout NUMBER THEORY

Solutions for Practice problems on proofs

MATH 22. THE FUNDAMENTAL THEOREM of ARITHMETIC. Lecture R: 10/30/2003

Lecture 3: Finding integer solutions to systems of linear equations

Number Theory. Proof. Suppose otherwise. Then there would be a finite number n of primes, which we may

Handout #1: Mathematical Reasoning

Discrete Mathematics, Chapter 4: Number Theory and Cryptography

Factoring & Primality

Lecture 13: Factoring Integers

Quotient Rings and Field Extensions

11 Ideals Revisiting Z

The Euclidean Algorithm

15 Prime and Composite Numbers

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

Elementary Number Theory

1 Homework 1. [p 0 q i+j p i 1 q j+1 ] + [p i q j ] + [p i+1 q j p i+j q 0 ]

The Fundamental Theorem of Arithmetic

Chapter 11 Number Theory

Mathematical Induction. Lecture 10-11

Grade 7/8 Math Circles Fall 2012 Factors and Primes

x a x 2 (1 + x 2 ) n.

Continued Fractions. Darren C. Collins

Theorem3.1.1 Thedivisionalgorithm;theorem2.2.1insection2.2 If m, n Z and n is a positive

Answer Key for California State Standards: Algebra I

SCORE SETS IN ORIENTED GRAPHS

SUM OF TWO SQUARES JAHNAVI BHASKAR

STUDENT S SOLUTIONS MANUAL ELEMENTARY NUMBER THEORY. Bart Goddard. Kenneth H. Rosen AND ITS APPLICATIONS FIFTH EDITION. to accompany.

The Division Algorithm for Polynomials Handout Monday March 5, 2012

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Basic Proof Techniques

Number Theory: A Mathemythical Approach. Student Resources. Printed Version

9. POLYNOMIALS. Example 1: The expression a(x) = x 3 4x 2 + 7x 11 is a polynomial in x. The coefficients of a(x) are the numbers 1, 4, 7, 11.

Notes on Factoring. MA 206 Kurt Bryan

Lemma 5.2. Let S be a set. (1) Let f and g be two permutations of S. Then the composition of f and g is a permutation of S.

Math 3000 Section 003 Intro to Abstract Math Homework 2

Integer roots of quadratic and cubic polynomials with integer coefficients

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

TEXAS A&M UNIVERSITY. Prime Factorization. A History and Discussion. Jason R. Prince. April 4, 2011

Just the Factors, Ma am

DIVISIBILITY AND GREATEST COMMON DIVISORS

Test1. Due Friday, March 13, 2015.

How To Know If A Domain Is Unique In An Octempo (Euclidean) Or Not (Ecl)

SECTION 10-2 Mathematical Induction

SYSTEMS OF PYTHAGOREAN TRIPLES. Acknowledgements. I would like to thank Professor Laura Schueller for advising and guiding me

mod 10 = mod 10 = 49 mod 10 = 9.

Lesson Plan. N.RN.3: Use properties of rational and irrational numbers.

Indices and Surds. The Laws on Indices. 1. Multiplication: Mgr. ubomíra Tomková

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z

Grade 6 Math Circles March 10/11, 2015 Prime Time Solutions

Some Polynomial Theorems. John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA

26 Integers: Multiplication, Division, and Order

A Second Course in Mathematics Concepts for Elementary Teachers: Theory, Problems, and Solutions

Settling a Question about Pythagorean Triples

Discrete Structures. Lecture Notes

1 if 1 x 0 1 if 0 x 1

LAKE ELSINORE UNIFIED SCHOOL DISTRICT

An Introduction to Number Theory Prime Numbers and Their Applications.

it is easy to see that α = a

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

PYTHAGOREAN TRIPLES KEITH CONRAD

ALGEBRAIC APPROACH TO COMPOSITE INTEGER FACTORIZATION

Computer and Network Security

PROBLEM SET 6: POLYNOMIALS

4.2 Euclid s Classification of Pythagorean Triples

Breaking The Code. Ryan Lowe. Ryan Lowe is currently a Ball State senior with a double major in Computer Science and Mathematics and

Indiana State Core Curriculum Standards updated 2009 Algebra I

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Math Workshop October 2010 Fractions and Repeating Decimals

Cubes and Cube Roots

Course Syllabus. MATH 1350-Mathematics for Teachers I. Revision Date: 8/15/2016

Transcription:

CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering principle from the induction principle. Conclude that the principles of induction, strong induction, and well-ordering are equally powerful. (a) Consider the premises of induction - a set A of positive integers exists such that 1 A and, if n A then (n + 1) A for any n N +. Consider the set B = N + \ A, the set of all positive integers not in A. Assume for the sake of contradiction that B is nonempty. By the well ordering principle, B must have a least element. We know that 1 / B because one of the induction premises is 0 A. Thus there is some least element b B with b > 1, which implies b 1 A. But then from the second induction premise, b = (b 1) + 1 A, which contradicts the earlier assertion that b / A. Thus the assumption that B is nonempty is incorrect, so B = and A = N +. Thus, assuming the well-ordering principle, if the premises of induction hold for a set A then A = N +, which proves the induction principle. (b) Recall that in the last homework, we proved that strong induction follows from the induction principle, so proving well-ordering from strong induction will suffice. Again we proceed by contradiction; assume there is a nonempty set A of positive integers without a least element. We will use strong induction to show that this cannot be. Since 1 is the smallest positive integer, 1 / A since it would be the least element. Assume that the positive integers from 1 to k are not in A. Then if (k + 1) A, (k + 1) would be the smallest element so (k + 1) / A. Then by strong induction all positive integers are not in A, so A =, a contradiction. Therefore the assumption was incorrect and any nonempty set of positive integers must have a least element. Thus the well-ordering principle holds if the induction principle holds. To conclude, since each principle can be proved from the other, any problem solvable with one can also be solved by the other. Thus the well-ordering principle, induction principle, and the induction principle are equally powerful. Exercise 2 (20 points). (a) Let s develop another proof that 2 is irrational. Assume as we did in class that there exist two numbers p, q Z, with q 0, such that p q = 2. 1

Show that 2q p p q = 2. Use the well-ordering principle to complete the argument, and write the whole proof formally. (b) Use the Fundamental Theorem of Arithmetic to prove that for n N, n is irrational unless n is a perfect square, that is, unless there exists a N for which n = a 2. (a) From p q = 2, square both sides and multiply by q 2 to get p 2 = 2q 2. Subtract pq from both sides to get p 2 pq = 2q 2 pq, which can be factored as This can be rearranged to p(p q) = q(2q p). p q = 2q p p q (Note that this requires dividing by both q and (p q), so neither of these can be 0. q 0 was one of our initial assumptions, and since p q = 2, p q and p q 0.) Since p q = 2, 2q p p q = 2. Since 2 > 0, we can claim that if integers p, q exist with q 0 and p = 2, natural q numbers m, n must exist with the same properties p and q must have the same sign so we can set m = p and n = q. Let A be the set of all such n N. By the wellordering principle, A must have a least element, so let n be the least element, and m the corresponding natural number such that m = 2. But from the first paragraph, n 2n m = 2 and thus (m n ) A. Since 2 < 2, m < 2n so (m n ) < 2n n m n or (m n ) < n. This contradicts the fact that n was the least element of A, so our initial assumption that 2 is rational is incorrect. This completes the proof. (b) We will prove the statement by contradiction. Assume n N is not a perfect square, yet its square root is a rational number p for coprime integers p, q, where q 0. So n = p q q or n = p2. Without loss of generality, we can assume both p and q are non-negative. q 2 If p = 0, then n = 0 which is a perfect square, contradicting our assumption. So we can assume both p and q are positive. By the Fundamental Theorem of Arithmetic, we can uniquely write both p and q as products of primes, say p = p 1 p 2... p m and q = q 1 q 2... q n. Since p and q are coprime, they have no common factors, so p i q j for all 1 i m, 1 j n. We have: p 2 = (p 1 p 2... p m ) 2 = p 2 1p 2 2... p 2 m 2

and q 2 = (q 1 q 2... q n ) 2 = q 2 1q 2 2... q 2 n Now p 2 and q 2 cannot have any common factors > 1 if they did have a common factor d > 1, any prime factor f of d (and there must be at least one such) must also be a common prime factor of p 2 and q 2 (transitivity of divisibility). By the Fundamental Theorem of Arithmetic, p 2 1p 2 2... p 2 m is the unique prime factorization of p, so f must be one of the primes p 1, p 2,..., p m. Similarly, f must also be one of the primes q 1, q 2,..., q n. But this contradicts our statement that no p i = q j. So p 2 and q 2 are coprime. A ratio of natural numbers in lowest terms is itself a natural number if and only if its denominator is 1. Since n N, we must have q 2 = 1, which implies q = 1. But then n must be the perfect square p 2, which contradicts our assumption. The statement is thus proved by contradiction. Exercise 3 (20 points). Prove or disprove, for integers a, b, c and d: (a) If a b and a c, then a (b + c). (b) If a bc and gcd(a, b) = 1, then a c. (c) If a and b are perfect squares and a b, then a b. (d) If ab cd, then a c or a d. (a) If a b then b = ma for some integer m and if a c then c = na for some integer n. Thus (b + c) = ma + na = (m + n)a. Since m + n is an integer, a (b + c). (b) The proof is essentially identical to that of Theorem 5.1.1.a. Since gcd(a, b) = 1, there exist integers u, v with au + bv = 1. Multiply both sides by c to get c = auc + bcv (by the result of the first part of this exercise). We know that a bc so a bcv and of course a auc, so a (auc + bcv). Thus a c. (c) Proof by contradiction: Assume b is not divisible by a. Consider the prime factorizations of a and b - there must be some prime p that appears m times in the prime factorization of a and n times in the prime factorization of b with m > n. The prime factorizations of perfect squares include every element of their square root s factorization twice, so p must occur 2m times in the prime factorization of a and 2n times in the prime factorization of b. But 2m > 2n, which implies that b is not divisible by a, a contradiction. Therefore a b. (d) False. One possible counterexample is a = 10, b = 1, c = 4, d = 25. Exercise 4 (25 points). On Euclid s algorithm: (a) Write the algorithm in pseudo-code. (10 points) 3

(b) State a theorem that asserts the correctness of the algorithm and prove the theorem. (10 points) (c) Use the algorithm to calculate gcd(5924, 6892). Write out the complete sequence of derivations. (5 points) (a) Procedure GCD-Euclid Input: Integers a, b, not both 0. i. a = a, b = b (These three lines are needed only for the ii. If b > a then swap a and b iii. If b = 0, then return a iv. q = a/b (Quotient) v. r = a q b (Remainder) vi. If r = 0, then return b vii. Return GCD-Euclid(b, r) first recursive call and can be factored out with a second procedure.) The following nonrecursive version also works: Procedure GCD-Euclid-Nonrecursive Input: Integers a, b, not both 0. i. a = a, b = b ii. If b > a then swap a and b iii. If b = 0, then return a iv. Do v. q = a/b (Quotient) vi. r = a q b (Remainder) vii. viii. ix. x. Loop If r = 0, then return b a = b b = r (b) Theorem. Euclid s Algorithm correctly finds the GCD of a and b in a finite number of steps. 4

Proof. We will prove the correctness of the algorithm in the context of the recursive listing above. The proof for the non-recursive version is identical except that it is slightly more difficult to phrase correctly. The first couple of lemmas help to justify the assumption a > b > 0 in the lecture notes. Lemma 1. d a if and only if d a. Proof. First we show that if d x, then d x. By the Division Algorithm, x = qd for some integer q, so x = qd = ( q)d. Since q is obviously integral if q is (and the Division Algorithm guarantees that this is an unique representation given x, d), d divides x. So if d a, then a is either a, which is trivially divisible by d, or a, which by the above reasoning is also divisible by d. Similarly, if d a, then a is either a or a, both of which are divisible by d as above. This proves the result. Lemma 2. gcd(a, b) = gcd( a, b ) = gcd( b, a ) Proof. Let d = gcd(a, b). Since d = gcd(a, b), d a and d b, so by Lemma 1, d a and d b, i.e. d is a common divisor of a and b. Now we prove by contradiction that d is the greatest such divisor. Assume there is some c > d such that c a and c b. Then by Lemma 1, c a and c b. So c is a common divisor of a and b strictly greater than the GCD of a and b, which contradicts the definition of the GCD. Therefore we must have gcd(a, b) = gcd( a, b ). Also, the definition of gcd(x, y) is clearly symmetric in x and y, so gcd( a, b ) = gcd( b, a ). Hence proved. Let P (n) be the following statement: Euclid s Algorithm finds the correct GCD of a and b in a finite number of steps, for all 0 a, b n (a and b not both 0). We will prove P (n) holds for all positive integers n by induction. We assume a b: if not, the first couple of steps of the algorithm will take their absolute values and swap them if necessary so the relation holds, and by Lemma 2 the GCD of these two new values is precisely the same as the GCD of the original values. The base case, n = 1, has two possibilities: a = 1, b = 0, or a = 1, b = 1. In the first case, the third line of the algorithm returns the correct GCD 1, and in the second case r evaluates to 0 before any recursive calls, so the correct GCD b = 1 is returned, in a finite number of steps (no recursive calls, so at most 6 lines of pseudocode). Now assume P (n) is true and consider P (n + 1), where we allow the values of a and b to be at most n + 1. If b = 0, the third line returns the correct GCD, a. If b a, gcd(a, b) = b, which is the value returned by the algorithm since r evaluates to 0. Otherwise, the algorithm recursively computes and returns gcd(b, r). Now by Lemma 4.3.1 in the lecture notes, gcd(a, b) = gcd(b, r). Also, since 0 r < b n + 1, r and b are both at most n (if b was n + 1, a would also be n + 1, which implies b a, which is a 5

case we have already handled) and not both zero. Hence by the inductive hypothesis, Euclid s Algorithm correctly computes gcd(b, r) in a finite number of steps, which implies that it also correctly computes gcd(a, b) in a finite number of steps, since the sequence of steps before the recursive call adds only a finite overhead. Hence P (n + 1) is true. This proves the claim by induction. The truth of P (n) for all n N + obviously implies the theorem. (c) The first step of the algorithm swaps 5924 and 6892 so a = 6892, b = 5924. We tabulate the values of a, b and r in each successive iteration until r = 0: Iteration a b r 1 6892 5924 968 2 5924 968 116 3 968 116 40 4 116 40 36 5 40 36 4 6 36 4 0 The value of b when r is zero is 4, so this is the GCD. Exercise 5 (15 points). Some prime facts: (a) Prove that for every positive integer n, there exist at least n consecutive composite numbers. (10 points) (b) Prove that if an integer n 2 is such that there is no prime p n that divides n, then n is a prime. (5 points) (a) Recall the definition n! = 1 2 3 n for any positive integer n. Consider the consecutive positive integers (n + 1)! + 2, (n + 1)! + 3,...(n + 1)! + (n + 1). By definition of factorial, all integers from 2 to (n + 1) divide (n + 1)!, so 2 ((n + 1)! + 2), 3 ((n+1)!+3), and so on up to (n+1) ((n+1)!+(n+1)) (remember the property of divisibility proved in Exercise 3a.) Thus all members of this sequence are composite, making n consecutive composite numbers. This sequence can be generated for any n, so for all n there exists at least n consecutive composite numbers. (b) Proof by contradiction: Assume n is not prime. By Theorem 5.1.2, n = p 1 p 2...p k for primes p 1 p 2... p k, and since n is not prime k 2. Since no prime less than or equal to n divides n, n < p 1 p 2. Then p 1 p 2 > n, so n = p 1 p 2...p k > n, a contradiction. Thus our assumption was false and n must be prime. 6