CISC-102 Fall 2017 Week 6

Similar documents
CISC-102 Winter 2016 Lecture 11 Greatest Common Divisor

2 Elementary number theory

Integers and Division

CS250: Discrete Math for Computer Science

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

Ch 4.2 Divisibility Properties

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

Proofs. Methods of Proof Divisibility Floor and Ceiling Contradiction & Contrapositive Euclidean Algorithm. Reading (Epp s textbook)

PRACTICE PROBLEMS: SET 1

Notes on Systems of Linear Congruences

Discrete Mathematics GCD, LCM, RSA Algorithm

8 Primes and Modular Arithmetic

Number Theory and Divisibility

Proof 1: Using only ch. 6 results. Since gcd(a, b) = 1, we have

WORKSHEET ON NUMBERS, MATH 215 FALL. We start our study of numbers with the integers: N = {1, 2, 3,...}

18 Divisibility. and 0 r < d. Lemma Let n,d Z with d 0. If n = qd+r = q d+r with 0 r,r < d, then q = q and r = r.

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points.

Chapter 5. Number Theory. 5.1 Base b representations

Chapter V. Theory of the Integers. Mathematics is the queen of the sciences and number theory is the queen of mathematics. Carl Friedrich Gauss

Introduction to Number Theory

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

MATH 145 Algebra, Solutions to Assignment 4

Homework #2 solutions Due: June 15, 2012

Discrete Structures Lecture Primes and Greatest Common Divisor

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

NUMBER THEORY AND CODES. Álvaro Pelayo WUSTL

Chapter 7. Number Theory. 7.1 Prime Numbers

COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

1. multiplication is commutative and associative;

a the relation arb is defined if and only if = 2 k, k

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Ma/CS 6a Class 2: Congruences

Number Theory Math 420 Silverman Exam #1 February 27, 2018

Number Theory and Graph Theory. Prime numbers and congruences.

INTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes.

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

The Euclidean Algorithm and Multiplicative Inverses

2. THE EUCLIDEAN ALGORITHM More ring essentials

Senior Math Circles Cryptography and Number Theory Week 2

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

Introduction to Sets and Logic (MATH 1190)

MATH 361: NUMBER THEORY FOURTH LECTURE

NOTES ON SIMPLE NUMBER THEORY

NOTES ON INTEGERS. 1. Integers

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

WORKSHEET MATH 215, FALL 15, WHYTE. We begin our course with the natural numbers:

The following is an informal description of Euclid s algorithm for finding the greatest common divisor of a pair of numbers:

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

4 Number Theory and Cryptography

4 Powers of an Element; Cyclic Groups

Review. CS311H: Discrete Mathematics. Number Theory. Computing GCDs. Insight Behind Euclid s Algorithm. Using this Theorem. Euclidian Algorithm

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

3 The fundamentals: Algorithms, the integers, and matrices

Chapter 3 Basic Number Theory

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

Number Theory Notes Spring 2011

Beautiful Mathematics

12x + 18y = 50. 2x + v = 12. (x, v) = (6 + k, 2k), k Z.

EUCLID S ALGORITHM AND THE FUNDAMENTAL THEOREM OF ARITHMETIC after N. Vasiliev and V. Gutenmacher (Kvant, 1972)

Number Theory and Group Theoryfor Public-Key Cryptography

1. (16 points) Circle T if the corresponding statement is True or F if it is False.

With Question/Answer Animations. Chapter 4

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

Math 109 HW 9 Solutions

MATH 2112/CSCI 2112, Discrete Structures I Winter 2007 Toby Kenney Homework Sheet 5 Hints & Model Solutions

Discrete mathematics I - Number theory

M381 Number Theory 2004 Page 1

Module 1. Integers, Induction, and Recurrences

Objective Type Questions

SOLUTIONS TO PROBLEM SET 1. Section = 2 3, 1. n n + 1. k(k + 1) k=1 k(k + 1) + 1 (n + 1)(n + 2) n + 2,

Wilson s Theorem and Fermat s Little Theorem

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

Mathematics for Computer Science Exercises for Week 10

PMATH 340 Lecture Notes on Elementary Number Theory. Anton Mosunov Department of Pure Mathematics University of Waterloo

Algorithms CMSC Basic algorithms in Number Theory: Euclid s algorithm and multiplicative inverse

Math 131 notes. Jason Riedy. 6 October, Linear Diophantine equations : Likely delayed 6

Solution Sheet (i) q = 5, r = 15 (ii) q = 58, r = 15 (iii) q = 3, r = 7 (iv) q = 6, r = (i) gcd (97, 157) = 1 = ,

CMPUT 403: Number Theory

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.

ECE 646 Lecture 5. Motivation: Mathematical Background: Modular Arithmetic. Public-key ciphers. RSA keys. RSA as a trap-door one-way function

PROBLEMS ON CONGRUENCES AND DIVISIBILITY

Number Theory Solutions Packet

Sets. We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth

Introduction to Number Theory

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

CPSC 467b: Cryptography and Computer Security

C-N Math 207 Discrete Math

C-N Math 207 Discrete Math

3.2 Solving linear congruences. v3

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

LARGE PRIME NUMBERS (32, 42; 4) (32, 24; 2) (32, 20; 1) ( 105, 20; 0).

Number Theory Proof Portfolio

CSE 20 DISCRETE MATH. Winter

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

Introduction to Number Theory. The study of the integers

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

Transcription:

Week 6 page 1! of! 15 CISC-102 Fall 2017 Week 6 We will see two different, yet similar, proofs that there are infinitely many prime numbers. One proof would surely suffice. However, seeing two different ways of proving the same result is instructive, as it demonstrates that there are often many ways in which to make a mathematical argument. I prefer the first proof, but that s simply a matter of taste. Which proof do you prefer?. Theorem: There exists a prime greater than n for all positive integers n. (We could also say that there are infinitely many primes.) Proof: (Given any value n we construct a larger value that is either prime or has a prime factor greater than n.) Consider y = n! and x = n! + 1. Let p be a prime divisor of x, such that p n. This implies that p is also a divisor of y, because n! is the product of all natural numbers from 1 to n. So we have p x and p y. According to one of the divisibility theorems we have p x - y. But x - y = 1 and the only divisor of 1 is -1, or 1, both not prime. So there are no prime divisors of x less than n. And since every integer is either prime or a product if primes, we either have x > n is prime, or there exists a prime p, p > n in the prime factorization of x. 1

Week 6 page 2! of! 15 Theorem: There is no largest prime. Proof: (Proof by contradiction.) Suppose there is a largest prime. So we can write down all of the finitely many primes as: { }. p 1,p 2,...,p! Now let n =. Observe that n must be larger the product of primes. Let pk n And since pk { the largest prime. Therefore n is composite and is a denote a prime factor of n. Thus we have } we also have pk (n-1) We know that pk n and pk (n-1) implies that pk n - (n-1) or pk 1. But no integer divides 1 except 1, and 1 is not prime, so pk 1 is impossible, and raises a mathematical contradiction. This implies that our assumption that is the largest prime is false, and so we conclude that there is no largest prime. p 1 p 2 p! +1 p k p! p 1,p 2,...,p! p! 2

Week 6 page 3! of! 15 Greatest Common Divisor Consider any two integers, a,b, at least one non-zero. If we list the positive divisors in numeric order from smallest to largest, we would get two lists: a: (1, c1, c2,... a ) b: (1, d1, d2,... b ) Since both lists must contain the number 1, we see that 1 is a common divisor of a and b. Since the greatest divisor of a is a and the greatest divisor of b is b, we can deduce that amongst the common divisors of a and b, there must be one that is the greatest. Thus we can say that given two integers a,b, at least one not zero, there is a unique greatest common divisor of a and b. Computing the greatest common divisor of a non-zero integer a, and 0, is somewhat boring because all non-zero integers divide 0, so the greatest common divisor of a and 0 is always a. So let s just assume from now on that neither a nor b is 0. Example: Let a = 111, and b = 250. We can construct sorted lists of divisors of a and b yielding: a: (1, 3, 37, 111) b: (1, 2, 5, 10, 25, 50, 125, 250) And by inspection we can deduce that 1 is the greatest common divisor of a and b. When the greatest common divisor of two numbers a,b is 1 we say that a and b are relatively prime or coprime. Another example: Let a = 250, and b = 575. We can construct sorted lists of divisors of a and b yielding: a: (1, 2, 5, 10, 25, 50, 125, 250) b:(1, 5, 23, 25, 115, 575) And by inspection we can deduce that 25 is the greatest common divisor of a and b. This method of obtaining all divisors of a and b is very computationally intensive, and would make some essential steps of public key encryption schemes un-feasible. Remarkably an algorithm invented by Euclid (~ 300 BC) finds greatest common divisors in a much more efficient way. 3

Week 6 page 4! of! 15 Euclid s Algorithm Suppose a,b are non-zero integers. We can define a function on the integers: gcd(a,b) that returns the greatest common divisor of a and b. It will be convenient to further assume that a b. Euclid s algorithm to compute gcd(a,b) is way more efficient than computing all the divisors of a and b, and is based on the following observation. Euclid s Theorem: Let a,b,q,r be positive integers such that a = qb + r then gcd (a,b) = gcd(b,r) For example: a = 575, b = 250. 575 = (2)(250) + 75 (Use long division to get q & r) So the claim is that gcd(575, 250) = gcd(250,75). This can be verified by listing the divisors of 250 and 75. 250: (1, 2, 5, 10, 25, 50, 125, 250) 75: (1, 3, 5, 15, 25, 75) 4

Week 6 page 5! of! 15 We can now iterate this process by renaming a = 250, b = 75 and repeat the previous calculation. That is: 250 = (3)(75) + 25 We can again verify that gcd(250,75) = gcd(75,25). Let s repeat this again, so a = 75 and b = 25 75 = (3)(25) + 0 so we have gcd(75,25) = gcd(25,0), and we have already seen that the greatest common divisor of any non-zero integer a and 0 is a. Therefore by Euclid s algorithm we have gcd(575,250) = 25. NOTE: Euclid s algorithm is given for positive integers. However, gcd(a,b) = gcd (-a,b) = gcd(a,-b) = gcd(-a,-b) so there is no loss of generality if we simply focus on positive integers. 5

Week 6 page 6! of! 15 Observe that as a side effect of Euclid s algorithm we can always find integers x,y such that gcd(a,b) = ax + by. This can be illustrated with the previous example. (1) 575 = (2) 250 + 75 implies 75 = 575 - (2)250 (2) 250 = (3) 75 + 25 implies 25 = 250 - (3)75 (3) 75 = (3) 25 + 0 Now we can write gcd(575,250) = 25 as: 25 = 250 - (3)75 (Using (2) above) 25 = 250 - (3)[575 - (2)250] (Using (1) above) 25 = (7)250 - (3)575 (Simplify) 6

Week 6 page 7! of! 15 To prove Euclid s Theorem we will need a preliminary result. (Math convention uses the word lemma for preliminary results that are proved in preparation for the proof of the main theorem. Lemma: If g a and g b then g (pa + b) for all integers p. Proof: Since g a and g b we can write ( 1 ) a = pag and b = pbg. Replacing the values of a and b in g (pa + b) using equations ( 1 ) we get: which simplifies to: g (ppag + pbg) g g(ppa + pb) Now it should be clear that g divides g(ppa+pb) and thus we conclude that g divides pa + b. 7

Week 6 page 8! of! 15 Theorem: Let a,b,q,r be positive integers such that: a = qb + r, 0 r < b, then gcd (a,b) = gcd(b,r) Strategy of the proof: We show that the gcd(a,b) is a common divisor of b & r and that gcd(b,r) is a common divisor of a & b. Proof: ( 0 ) Let g1= gcd(a,b) and g2 = gcd(b,r). ( 1 ) Observe that g2 b and g2 r, so g2 pb + r for all integers p, and in particular for q, where a = qb + r. ( a ) Therefore, g2 a, so we have established that g2 is a common divisor of both a and b. ( b) Furthermore, observe that g2 g1 = gcd(a,b) ( 2 ) Using the equation a = qb + r we can write r = - qb + a. g1 b and g1 a so use the lemma (with p = -q) to get g1 -qb + a or g1 r. ( a ) Therefor g1 r and we have established that g1 is a common divisor of b and r. ( b ) Furthermore, observe that g1 g2 = gcd(b,r) ( 3 ) g2 g1 and g1 g2 implies that g1 = g2, so we can conclude that gcd(a,b) = gcd(b,r). 8

Week 6 page 9! of! 15 Euclid s Algorithm in the Python programming language. def euclid_gcd(a,b): # Assume a >= b > 0 r = a % b # this returns r such that a = bq + r while r > 0: a,b = b,r r = a % b # this returns r s.t. a = bq + r return b NOTE: The % (mod) operator is found in many programming languages and returns the remainder when doing integer division. We will argue that euclid_gcd(a,b) finds gcd(a,b) assuming that a b > 0. We first argue that the loop terminates, that is r eventually becomes 0. This is easy to see because the remainder when we divide a by b is less than b. The value of r begins positive and always decreases so it eventually must be zero. The correctness follows from Euclid s theorem. It can also be shown that this function is extremely efficient when compared to looking at all the divisors of a and b. 9

Week 6 page 10! of! 15 Let a = 250, and b = 575. We can construct a prime factorization of a and b. Prime factorization: 250 = (2)(5 3 ) 575 = (5 2 )(23) We can inspect the prime factorization of a and b to obtain a greatest common divisor. Observe that 5 2 is the greatest number that divides both a and b, that is the gcd(a,b). Using the prime factorizations of a and b is much less efficient than Euclid s algorithm. Nevertheless, the prime factorization is useful for obtaining other properties of the greatest common divisor. 10

Week 6 page! 11 of! 15 Least Common Multiple Given two non-zero 1 integers a,b we can have many values that are positive common multiples of both a & b. By the well ordering principle we know that amongst all of those multiples there is one that is smallest, and this is known as the least common multiple of a and b. We can define a function lcm(a,b) that returns this value. Example: Suppose a = 12, and b = 24, so we have lcm(a,b) = 24. In general if a b then lcm(a,b) = b. At this point it is worth mentioning that if a b then gcd(a,b) = a, and that lcm(a,b) gcd(a,b) = ab. Example: Suppose a = 13, and b = 24, we have lcm(a,b) = (13)(24). In general if a and b are relatively prime, that is, if gcd(a,b) = 1 then lcm(a,b) = ab So when gcd(a,b) = 1, we can observe that lcm(a,b) gcd(a,b) = ab. Let a = 250, and b = 575. We can construct a prime factorization of a and b Prime factorization 250 = (2)(5 3 ) 575 = (5 2 )(23) We can inspect the prime factorization of a and b to obtain the least common multiple. 250 575 = (2)(5 3 ) (5 2 )(23) = (5 2 ) (2)(5 3 )(23) And since gcd(a,b) = 5 2 we can conclude that lcm(a,b) = (2) (5 3 ) (23). So in this case we also have lcm(a,b) gcd(a,b) = ab 1 Multiples of zero are always zero, so this is a boring case. 11

Week 6 page 12! of! 15 Let p1, p2,, pk denote all of the prime factors of both a and b ordered from smallest to largest. In our example the list of prime factors would be 2,5,23. Let ai denote the exponent of prime factor pi, for i, 1 i k, in a prime factorization of a. In our example a1 = 1, a2 = 3, a3 = 0. Similarly we define bi for i 1 i k. In our example b1 = 0, b2 = 2, b3 = 1. Again referring to our example we have: gcd(a,b) = 2 min(1,0) 5 min(3,2) 23 min(0,1) and, lcm(a,b) = 2 max(1,0) 5 max(3,2) 23 max(0,1). In general using pi, ai, and bi as defined above we can express this formula as gcd(a, b) =p min(a1,b1) 1 p min(a2,b2) 2 p min(a k,b k ) k and lcm(a, b) =p max(a1,b1) 1 p max(a2,b2) 2 p max(a k,b k ) k One more example 630 = ( 2 ) (3 2 ) ( 5 ) ( 7 ) 84 = (2 2 ) ( 3 ) ( 7 ) By inspection we can see that gcd(630,84) = ( 2 ) ( 3 ) ( 7 ) = 42 And lcm(630,84) = (2 2 ) (3 2 ) ( 5 ) ( 7 ) = 1260 Again we have 630 84 = ( 2 ) (3 2 ) ( 5 ) ( 7 ) (2 2 ) ( 3 ) ( 7 ) = ( 2 ) ( 3 ) ( 7 ) (2 2 ) (3 2 ) ( 5 ) ( 7 ) = gcd(630,84) lcm(630,84) These ideas lead to the following theorem that is given without proof. Theorem: Let a,b be non-zero integers, then gcd(a,b)lcm(a,b) = ab. 12

Week 6 page 13! of! 15 Factoring vs. GCD Factoring an integer N into its prime factors will use roughly p N operations. Computing gcd(n,m) with Euclid s algorithm for log 2 N N > m 0 will use roughly! operations. N log 2 N p N 1024 10 32 1099511627776 40 1,048,576 1 10 301 1000 3.27 10 150 The efficiency of Euclid s gcd algorithm is essential for implementing current public key crypto systems that are commonly used for e-commerce applications. With a key decoding an encrypted message using Euclid s algorithm takes about 1000 operations. Without a key breaking an encrypted messaged takes about 3.27 10 150 operations. This amounts to a small fraction of a second for decoding and many millions of years for breaking the encrypted message. 13

Week 6 page 14! of! 15 Congruence Relations We say that a is congruent to b modulo m written as: a b (mod m) and defined as follows: a b (mod m) if m (a-b). For example: 64 4 (mod 2) and we can verify that 2 60. 2 Example: Let m = 12. Then we have: 13 1 (mod 12) 17 5 (mod 12) Which is familiar to everyone who uses a 24 hour clock. And we can also have: 241 1 (mod 12) 166 10 (mod 12) 120 0 (mod 12) Similarly 90 30 (mod 60) 75 15 (mod 60) 120 0 (mod 60) 2 Observe that 2-60 too. 14

Week 6 page 15! of! 15 We now show that congruence is an equivalence relation. Theorem: Let m be a positive integer then 1. For any integer a we have a a (mod m) (reflexive) 2. if a b (mod m) then b a (mod m) (symmetric) 3. if a b (mod m) and b c (mod m) then a c (mod m) (transitive) I will prove 3. Congruence is an equivalence relation. Proof: If a b (mod m) then m (a-b), (by definition) and if b c (mod m) then m (b-c). And by one of the divisibility theorems we have: m (a-b+b-c) or, m (a-c) so a c (mod m). 15