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

Similar documents
4 Number Theory and Cryptography

3 The fundamentals: Algorithms, the integers, and matrices

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

Introduction to Sets and Logic (MATH 1190)

Discrete Structures Lecture Primes and Greatest Common Divisor

Algorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division

With Question/Answer Animations. Chapter 4

Integers and Division

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

Notes on Systems of Linear Congruences

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

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

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

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald)

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

Introduction to Number Theory

7.2 Applications of Euler s and Fermat s Theorem.

Basic elements of number theory

Basic elements of number theory

Applied Cryptography and Computer Security CSE 664 Spring 2018

An Algorithm for Prime Factorization

Applied Cryptography and Computer Security CSE 664 Spring 2017

Notes. Number Theory: Applications. Notes. Number Theory: Applications. Notes. Hash Functions I

Introduction to Number Theory. The study of the integers

Number theory. Myrto Arapinis School of Informatics University of Edinburgh. October 9, /29

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

5: The Integers (An introduction to Number Theory)

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

CS March 17, 2009

Chapter 3 Basic Number Theory

PRIMALITY TESTING. Professor : Mr. Mohammad Amin Shokrollahi Assistant : Mahdi Cheraghchi. By TAHIRI JOUTI Kamal

NOTES ON SIMPLE NUMBER THEORY

Chapter 5: The Integers

Primes and Factorization

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

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

CISC-102 Fall 2017 Week 6

M381 Number Theory 2004 Page 1

Chapter 5. Number Theory. 5.1 Base b representations

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

2 Elementary number theory

Definition: div Let n, d 0. We define ndiv d as the least integer quotient obtained when n is divided by d. That is if

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

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

1. Algebra 1.7. Prime numbers

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

Corollary 4.2 (Pepin s Test, 1877). Let F k = 2 2k + 1, the kth Fermat number, where k 1. Then F k is prime iff 3 F k 1

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

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?

NUMBER THEORY. Anwitaman DATTA SCSE, NTU Singapore CX4024. CRYPTOGRAPHY & NETWORK SECURITY 2018, Anwitaman DATTA

MATH 361: NUMBER THEORY FOURTH LECTURE

Ch 4.2 Divisibility Properties

REAL NUMBERS. Any positive integer a can be divided by another positive integer b in such a way that it leaves a remainder r that is smaller than b.

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

[Part 2] Asymmetric-Key Encipherment. Chapter 9. Mathematics of Cryptography. Objectives. Contents. Objectives

1 Overview and revision

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

Introduction Integers. Discrete Mathematics Andrei Bulatov

Summary Slides for MATH 342 June 25, 2018

Algebra for error control codes

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

NUMBER SYSTEMS. Number theory is the study of the integers. We denote the set of integers by Z:

Mathematics for Cryptography

Number Theory and Group Theoryfor Public-Key Cryptography

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

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

Primality Testing. 1 Introduction. 2 Brief Chronology of Primality Testing. CS265/CME309, Fall Instructor: Gregory Valiant

4.3 - Primes and Greatest Common Divisors

Lecture 7: Number Theory Steven Skiena. skiena

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

Number theory (Chapter 4)

CMPUT 403: Number Theory

3 The Fundamentals:Algorithms, the Integers, and Matrices

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

Introduction. How can we say that one algorithm performs better than another? Quantify the resources required to execute:

Number Theory Solutions Packet

CPSC 467: Cryptography and Computer Security

Cryptography: Joining the RSA Cryptosystem

PRIME NUMBERS YANKI LEKILI

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?

Number Theory and Cryptography

Instructor: Bobby Kleinberg Lecture Notes, 25 April The Miller-Rabin Randomized Primality Test

Lecture 4: Number theory

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

4 PRIMITIVE ROOTS Order and Primitive Roots The Index Existence of primitive roots for prime modulus...

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

Definition 6.1 (p.277) A positive integer n is prime when n > 1 and the only positive divisors are 1 and n. Alternatively

ELEMENTS OF NUMBER THEORY

Chapter 1 : The language of mathematics.

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

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

8 Primes and Modular Arithmetic

Wilson s Theorem and Fermat s Little Theorem

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course

Objective Type Questions

PRACTICE PROBLEMS: SET 1

Transcription:

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 1 / 1 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 2.4 2.6 of Rosen

Introduction I When talking about division over the integers, we mean division with no remainder. Definition Let a, b Z, a 0, we say that a divides b if there exists c Z such that b = ac. We denote this, a b and a b when a does not divide b. When a b, we say a is a factor of b. Theorem Let a, b, c Z then 1 If a b and a c then a (b + c). 2 If a b, then a bc for all c Z. 3 If a b and b c, then a c. 2 / 1

Introduction II Corollary If a, b, c Z such that a b and a c then a mb + nc for n, m Z. 3 / 1

Division Algorithm I Let a be an integer and d be a positive integer. Then there are unique integers q and r, with: 0 r d such that a = dq + r Not really an algorithm (traditional name). Further: a is called the divident d is called the divisor q is called the quotient r is called the remainder, and is positive. 4 / 1

Primes I Definition A positive integer p > 1 is called prime if its only positive factors are 1 and p. If a positive integer is not prime, it is called composite. 5 / 1

Primes II Theorem (Fundamental Theorem of Arithmetic, FTA) Every positive integer n > 1 can be written uniquely as a prime or as the product of the powers of two or more primes written in nondecreasing size. That is, for every n Z, n > 1, can be written as n = p 1 k 1 p 2 k2 p l k l where each p i is a prime and each k i 1 is a positive integer. 6 / 1

Sieve of Eratosthenes Preliminaries Given a positive integer, n > 1, how can we determine if n is prime or not? For hundreds of years, people have developed various tests and algorithms for primality testing. We ll look at the oldest (and most inefficient) of these. Lemma If n is a composite integer, then n has a prime divisor x n. 7 / 1

Sieve of Eratosthenes Preliminaries Proof. 8 / 1

Sieve of Eratosthenes Preliminaries Proof. Let n be a composite integer. 9 / 1

Sieve of Eratosthenes Preliminaries Proof. Let n be a composite integer. By definition, n has a prime divisor a with 1 < a < n, thus n = ab. 10 / 1

Sieve of Eratosthenes Preliminaries Proof. Let n be a composite integer. By definition, n has a prime divisor a with 1 < a < n, thus n = ab. Its easy to see that either a n or b n. Otherwise, if on the contrary, a > n and b > n, then ab > n n = n 11 / 1

Sieve of Eratosthenes Preliminaries Proof. Let n be a composite integer. By definition, n has a prime divisor a with 1 < a < n, thus n = ab. Its easy to see that either a n or b n. Otherwise, if on the contrary, a > n and b > n, then ab > n n = n Finally, either a or b is prime divisor or has a factor that is a prime divisor by the Fundamental Theorem of Arithmetic, thus n has a prime divisor x n. 12 / 1

Sieve of Eratosthenes Algorithm This result gives us an obvious algorithm. To determine if a number n is prime, we simple must test every prime number p with 2 p n. Sieve 1 2 3 4 5 6 Input : A positive integer n 4. Output : true if n is prime. foreach prime number p, 2 p n do if p n then output false end end output true 13 / 1 Can be improved by reducing the upper bound to n p iteration. at each

Sieve of Eratosthenes Efficiency? This procedure, called the Sieve of Eratosthenes, is quite old, but works. In addition, it is very inefficient. At first glance, this may seem counter intuitive. 14 / 1

Sieve of Eratosthenes Efficiency? This procedure, called the Sieve of Eratosthenes, is quite old, but works. In addition, it is very inefficient. At first glance, this may seem counter intuitive. The outer for-loop runs for every prime p n. 15 / 1

Sieve of Eratosthenes Efficiency? This procedure, called the Sieve of Eratosthenes, is quite old, but works. In addition, it is very inefficient. At first glance, this may seem counter intuitive. The outer for-loop runs for every prime p n. Assume that we get such a list for free. The loop still executes about n ln n times (see distribution of primes: next topic, also Theorem 5, page 157). 16 / 1

Sieve of Eratosthenes Efficiency? This procedure, called the Sieve of Eratosthenes, is quite old, but works. In addition, it is very inefficient. At first glance, this may seem counter intuitive. The outer for-loop runs for every prime p n. Assume that we get such a list for free. The loop still executes about n ln n times (see distribution of primes: next topic, also Theorem 5, page 157). Assume also that division is our elementary operation. 17 / 1

Sieve of Eratosthenes Efficiency? This procedure, called the Sieve of Eratosthenes, is quite old, but works. In addition, it is very inefficient. At first glance, this may seem counter intuitive. The outer for-loop runs for every prime p n. Assume that we get such a list for free. The loop still executes about n ln n times (see distribution of primes: next topic, also Theorem 5, page 157). Assume also that division is our elementary operation. Then the algorithm is O( n). 18 / 1

Sieve of Eratosthenes Efficiency? This procedure, called the Sieve of Eratosthenes, is quite old, but works. In addition, it is very inefficient. At first glance, this may seem counter intuitive. The outer for-loop runs for every prime p n. Assume that we get such a list for free. The loop still executes about n 19 / 1 ln n times (see distribution of primes: next topic, also Theorem 5, page 157). Assume also that division is our elementary operation. Then the algorithm is O( n). However, what is the actual input size?

Sieve of Eratosthenes Efficiency? Recall that it is log (n). Thus, the algorithm runs in exponential time with respect to the input size. 20 / 1

Sieve of Eratosthenes Efficiency? Recall that it is log (n). Thus, the algorithm runs in exponential time with respect to the input size. To see this, let k = log (n) 21 / 1

Sieve of Eratosthenes Efficiency? Recall that it is log (n). Thus, the algorithm runs in exponential time with respect to the input size. To see this, let k = log (n) Then 2 k = n and so n = 2 k = 2 k/2 22 / 1

Sieve of Eratosthenes Efficiency? Recall that it is log (n). Thus, the algorithm runs in exponential time with respect to the input size. To see this, let k = log (n) Then 2 k = n and so n = 2 k = 2 k/2 Thus the Sieve is exponential in the input size k. 23 / 1

Sieve of Eratosthenes Efficiency? Recall that it is log (n). Thus, the algorithm runs in exponential time with respect to the input size. To see this, let k = log (n) Then 2 k = n and so n = 2 k = 2 k/2 Thus the Sieve is exponential in the input size k. The Sieve also gives an algorithm for determining the prime factorization of an integer. To date, no one has been able to produce an algorithm that runs in sub-exponential time. The hardness of this problem is the basis of public-key cryptography. 24 / 1

Sieve of Eratosthenes I Primality Testing Numerous algorithms for primality testing have been developed over the last 50 years. In 2002, three Indian computer scientists developed the first deterministic polynomial-time algorithm for primality testing, running in time O(log 12 (n)). M. Agrawal and N. Kayal and N. Saxena. Primes is in P. Annals of Mathematics, 160(2):781-793, 2004. Available at http://projecteuclid.org/dienst/ui/1.0/ Summarize/euclid.annm/1111770735 25 / 1

How Many Primes? How many primes are there? Theorem There are infinitely many prime numbers. The proof is a simple proof by contradiction. 26 / 1

How Many Primes? Proof Proof. 27 / 1

How Many Primes? Proof Proof. Assume to the contrary that there are a finite number of primes, p 1, p 2,..., p n. 28 / 1

How Many Primes? Proof Proof. Assume to the contrary that there are a finite number of primes, p 1, p 2,..., p n. Let Q = p 1 p 2 p n + 1 29 / 1

How Many Primes? Proof Proof. Assume to the contrary that there are a finite number of primes, p 1, p 2,..., p n. Let Q = p 1 p 2 p n + 1 By the FTA, Q is either prime (in which case we are done) or Q can be written as the product of two or more primes. 30 / 1

How Many Primes? Proof Proof. Assume to the contrary that there are a finite number of primes, p 1, p 2,..., p n. Let Q = p 1 p 2 p n + 1 By the FTA, Q is either prime (in which case we are done) or Q can be written as the product of two or more primes. Thus, one of the primes p j (1 j n) must divide Q, but then if p j Q, it must be the case that p j Q p 1 p 2 p n = 1 31 / 1

How Many Primes? Proof Proof. Assume to the contrary that there are a finite number of primes, p 1, p 2,..., p n. Let Q = p 1 p 2 p n + 1 By the FTA, Q is either prime (in which case we are done) or Q can be written as the product of two or more primes. Thus, one of the primes p j (1 j n) must divide Q, but then if p j Q, it must be the case that p j Q p 1 p 2 p n = 1 Since this is not possible, we ve reached a contradiction there are not finitely many primes. 32 / 1

Distribution of Prime s Theorem The ratio of the number of prime numbers not exceeding n and approaches 1 as n. n ln n In other words, for a fixed natural number, n, the number of primes not greater than n is about n ln n 33 / 1

Mersenne Primes I A Mersenne prime is a prime number of the form 2 k 1 where k is a positive integer. They are related to perfect numbers (if M n is a Mersenne prime, Mn(Mn+1) 2 is perfect). Perfect numbers are numbers that are equal to the sum of their proper factors, for example 6 = 1 2 3 = 1 + 2 + 3 is perfect. 34 / 1

Mersenne Primes II It is an open question as to whether or not there exist odd perfect numbers. It is also an open question whether or not there exist an infinite number of Mersenne primes. Such primes are useful in testing suites (i.e., benchmarks) for large super computers. To date, 42 Mersenne primes have been found. The last was found on February 18th, 2005 and contains 7,816,230 digits. 35 / 1

Division Theorem (The Division Algorithm ) Let a Z and d Z + then there exists unique integers q, r with 0 r < d such that a = dq + r Some terminology: d is called the divisor. a is called the dividend. q is called the quotient. r is called the remainder. 36 / 1 We use the following notation: q = a div d r = a mod d

Greatest Common Divisor I Definition Let a and b be integers not both zero. The largest integer d such that d a and d b is called the greatest common divisor of a and b. It is denoted gcd(a, b) The gcd is always guaranteed to exist since the set of common divisors is finite. Recall that 1 is a divisor of any integer. Also, gcd(a, a) = a, thus 1 gcd(a, b) min{a, b} 37 / 1

Greatest Common Divisor II Definition Two integers a, b are called relatively prime if gcd(a, b) = 1 Sometimes, such integers are called coprime. There is natural generalization to a set of integers. Definition Integers a 1, a 2,..., a n are pairwise relatively prime if gcd(a i, a j ) = 1 for i j. 38 / 1

Greatest Common Divisor Computing The gcd can easily 1 be found by finding the prime factorization of two numbers. Let a = p 1 a 1 p 2 a2 p n a n b = p 1 b 1 p 2 b2 p n b n Where each power is a nonnegative integer (if a prime is not a divisor, then the power is 0). Then the gcd is simply gcd(a, b) = p min{a 1,b 1 } 1 p min{a 2,b 2 } 2 pn min{an,bn} 39 / 1 1 Easy conceptually, not computationally

Greatest Common Divisor Examples Example What is the gcd(6600, 12740)? The prime decompositions are 6600 = 2 3 3 1 5 2 7 0 11 1 13 0 12740 = 2 2 3 0 5 1 7 2 11 0 13 1 So we have gcd(6600, 12740) = 2 min{2,3} 3 min{0,1} 5 min{1,2} 7 min{0,2} 11 min{0,1} 13 min{0,1} = 2 2 3 0 5 1 7 0 11 0 13 0 = 20 40 / 1

Least Common Multiple Definition The least common multiple of positive integers a, b is the smallest positive integer that is divisible by both a and b. It is denoted lcm(a, b) Again, the lcm has an easy method to compute. We still use the prime decomposition, but use the max rather than the min of powers. lcm(a, b) = p max{a 1,b 1 } 1 p max{a 2,b 2 } 2 p max{an,bn} n 41 / 1

Least Common Multiple Example Example What is the lcm(6600, 12740)? Again, the prime decompositions are 6600 = 2 3 3 1 5 2 7 0 11 1 13 0 12740 = 2 2 3 0 5 1 7 2 11 0 13 1 So we have lcm(6600, 12740) = 2 max{2,3} 3 max{0,1} 5 max{1,2} 7 max{0,2} 11 max{0,1} 13 max{0,1} = 2 3 3 1 5 2 7 2 11 1 13 1 = 4, 204, 200 42 / 1

Intimate Connection There is a very close connection between the gcd and lcm. Theorem Let a, b Z +, then ab = gcd(a, b) lcm(a, b) Proof? 43 / 1

Congruences Definition Often, rather than the quotient, we are only interested in the remainder of a division operation. We introduced the notation before, but we formally define it here. Definition Let a, b Z and m Z +. Then a is congruent to b modulo m if m divides a b. We use the notation a b(mod m) If the congruence does not hold, we write a b(mod m) 44 / 1

Congruences Another Characterization An equivalent characterization can be given as follows. Theorem Let m Z +. Then a b(mod m) if and only if there exists q Z such that a = qm + b i.e. a quotient q. Alert: a, b Z, i.e. can be negative or positive. 45 / 1

Congruences Properties Theorem Let a, b Z, m Z +. Then, a b(mod m) a mod m = b mod m Theorem Let m Z +. If a b(mod m) and c d(mod m) then a + c b + d(mod m) and ac bd(mod m) 46 / 1

Modular Arithmetic Example Example 36 1(mod 5) since the remainder of 36 5 is 1. 47 / 1

Modular Arithmetic Example Example 36 1(mod 5) since the remainder of 36 5 is 1. Similarly, 17 1(mod 2), 17 1(mod 2), 17 3(mod 2), etc. 48 / 1

Modular Arithmetic Example Example 36 1(mod 5) since the remainder of 36 5 is 1. Similarly, 17 1(mod 2), 17 1(mod 2), 17 3(mod 2), etc. However, we prefer to express congruences with 0 b < m. 49 / 1

Modular Arithmetic Example Example 36 1(mod 5) since the remainder of 36 5 is 1. Similarly, 17 1(mod 2), 17 1(mod 2), 17 3(mod 2), etc. However, we prefer to express congruences with 0 b < m. 64 0(mod 2), 64 1(mod 3), 64 4(mod 5), 64 4(mod 6), 64 1(mod 7), etc. 50 / 1

Inverses I Definition An inverse of an element x modulo m is an integer x 1 such that xx 1 1(mod m) Inverses do not always exist, take x = 5, m = 10 for example. The following is a necessary and sufficient condition for an inverse to exist. Theorem Let a and m be integers, m > 1. A (unique) inverse of a modulo m exists if and only if a and m are relatively prime. 51 / 1