PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) PRIMALITY TESTING ALGORITHMS Introduction

The Problem

Core Idea behind the Prerona Chatterjee Algorithms (Roll No.: 142123029) Preliminaries

The Miller-Rabin Department of Mathematics Primality IIT Guwahati Testing Algorithm

The Agrawal- April, 2016 Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 1 / 60 Introduction

PRIMALITY TESTING AL- GORITHMS

Prerona 1 Introduction Chatterjee (Roll No.: 142123029) 2 The Problem

Introduction The Problem 3 Core Idea behind the Algorithms Core Idea behind the Algorithms 4 Preliminaries Preliminaries

The Miller-Rabin 5 The Miller-Rabin Primality Testing Algorithm Primality Testing Algorithm 6 The Agrawal-Biswas Primality Testing Algorithm The Agrawal- Biswas Primality Testing 7 Algorithm The AKS Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 2 / 60 Introduction

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Importance of Prime Numbers 142123029) Prime numbers are of fundamental importance in mathematics Introduction in general, and number theory in particular. So, it is of great The Problem interest to study different properties of prime numbers, Core Idea behind the especially those properties that allow one to determine Algorithms efficiently if a number is prime. Such efficient tests are also Preliminaries useful in practice. For example, a number of cryptographic The Miller-Rabin protocols need large prime numbers. Infact, primality testing is Primality Testing one of the fundamental problems in computational number Algorithm theory with important applications in complexity theory, coding The Agrawal- Biswas theory, cryptography, computer algebra systems and elsewhere. Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 3 / 60 Biswas and Agrawal introduced a new technique, which generalises the idea of Fermat’s little theorem to a similar identity over polynomial rings which resulted in a simple probabilistic polynomial time algorithm which completely bypasses the issue of pseudoprimes. In 2004, , Neeraj Kayal and , gave a deterministic polynomial time algorithm by derandomizing the previous algorithm.

Introduction

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Developments in the field (Roll No.: 142123029) Most of the early algorithms are based on Fermat’s little theorem and differ in their treatment to handle the Introduction Fermat’s pseudoprimes. The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 4 / 60 In 2004, Manindra Agrawal, Neeraj Kayal and Nitin Saxena, gave a deterministic polynomial time algorithm by derandomizing the previous algorithm.

Introduction

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Developments in the field (Roll No.: 142123029) Most of the early algorithms are based on Fermat’s little theorem and differ in their treatment to handle the Introduction Fermat’s pseudoprimes. The Problem

Core Idea Biswas and Agrawal introduced a new technique, which behind the Algorithms generalises the idea of Fermat’s little theorem to a similar

Preliminaries identity over polynomial rings which resulted in a simple The probabilistic polynomial time algorithm which completely Miller-Rabin Primality bypasses the issue of pseudoprimes. Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 4 / 60 Introduction

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Developments in the field (Roll No.: 142123029) Most of the early algorithms are based on Fermat’s little theorem and differ in their treatment to handle the Introduction Fermat’s pseudoprimes. The Problem

Core Idea Biswas and Agrawal introduced a new technique, which behind the Algorithms generalises the idea of Fermat’s little theorem to a similar

Preliminaries identity over polynomial rings which resulted in a simple The probabilistic polynomial time algorithm which completely Miller-Rabin Primality bypasses the issue of pseudoprimes. Testing Algorithm In 2004, Manindra Agrawal, Neeraj Kayal and Nitin The Agrawal- Biswas Saxena, gave a deterministic polynomial time algorithm by Primality derandomizing the previous algorithm. Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 4 / 60 The Problem

PRIMALITY TESTING AL- GORITHMS

Prerona 1 Introduction Chatterjee (Roll No.: 142123029) 2 The Problem

Introduction The Problem 3 Core Idea behind the Algorithms Core Idea behind the Algorithms 4 Preliminaries Preliminaries

The Miller-Rabin 5 The Miller-Rabin Primality Testing Algorithm Primality Testing Algorithm 6 The Agrawal-Biswas Primality Testing Algorithm The Agrawal- Biswas Primality Testing 7 Algorithm The AKS Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 5 / 60 The problem we are looking at: The goal of primality testing is to devise an algorithm which, given an integer n, decides whether n is a prime number. To represent an integer n we need O(log n) bits. Hence, the input size is O(log n) and by polynomial-time algorithm we mean algorithms with running time polynomial in log(n).

The Problem

PRIMALITY TESTING AL- Aim of the Project GORITHMS

Prerona In this project we study some Primality testing algorithms Chatterjee (Roll No.: (probabilistic or deterministic) that take time polynomial in 142123029) log n. Our main focus is to study the AKS algorithm which

Introduction gives an unconditional deterministic polynomial time algorithm The Problem that determines whether a given input number is prime or not. Core Idea However, before that we study two of its precursers, namely, behind the Algorithms the Miller-Rabin test and Agrawal-Biswas test, which give Preliminaries probablistic polynomial time algorithms to check for primality. The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 6 / 60 The Problem

PRIMALITY TESTING AL- Aim of the Project GORITHMS

Prerona In this project we study some Primality testing algorithms Chatterjee (Roll No.: (probabilistic or deterministic) that take time polynomial in 142123029) log n. Our main focus is to study the AKS algorithm which

Introduction gives an unconditional deterministic polynomial time algorithm The Problem that determines whether a given input number is prime or not. Core Idea However, before that we study two of its precursers, namely, behind the Algorithms the Miller-Rabin test and Agrawal-Biswas test, which give Preliminaries probablistic polynomial time algorithms to check for primality. The Miller-Rabin Primality Testing The problem we are looking at: Algorithm The goal of primality testing is to devise an algorithm which, The Agrawal- Biswas given an integer n, decides whether n is a prime number. To Primality Testing represent an integer n we need O(log n) bits. Hence, the input Algorithm size is O(log n) and by polynomial-time algorithm we mean The AKS Primality algorithms with running time polynomial in log(n). Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 6 / 60 Problem Give a (probabilistic or deterministic) algorithm which, given an integer n in binary representation, decides whether n is a prime number in time O(logk n) where k is an integer independent of n.

The Problem

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) Formal Statement of the Problem Introduction Formally, the problem stated as follows: The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 7 / 60 The Problem

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) Formal Statement of the Problem Introduction Formally, the problem stated as follows: The Problem Core Idea Problem behind the Algorithms Give a (probabilistic or deterministic) algorithm which, given an Preliminaries integer n in binary representation, decides whether n is a prime The k Miller-Rabin number in time O(log n) where k is an integer independent of Primality Testing n. Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 7 / 60 Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona 1 Introduction Chatterjee (Roll No.: 142123029) 2 The Problem

Introduction The Problem 3 Core Idea behind the Algorithms Core Idea behind the Algorithms 4 Preliminaries Preliminaries

The Miller-Rabin 5 The Miller-Rabin Primality Testing Algorithm Primality Testing Algorithm 6 The Agrawal-Biswas Primality Testing Algorithm The Agrawal- Biswas Primality Testing 7 Algorithm The AKS Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 8 / 60 Integer factorization is a much harder problem than primality testing and not even a probabilistic polynomial time algorithm is known for that. The effective approach to primality testing is to come up with mathematical identities which are satisfied by n if and only if n is a prime. This allows us to solve the decision problem without having knowledge of the factors of n.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Difficulty in the Naive Approach and how to overcome it (Roll No.: 142123029) The naive algorithm which tries to find a factor by √ Introduction checking whether n is divisible by 2, 3,..., b nc takes √ The Problem Θ( n) time which is exponential in the input-length. Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 9 / 60 The effective approach to primality testing is to come up with mathematical identities which are satisfied by n if and only if n is a prime. This allows us to solve the decision problem without having knowledge of the factors of n.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Difficulty in the Naive Approach and how to overcome it (Roll No.: 142123029) The naive algorithm which tries to find a factor by √ Introduction checking whether n is divisible by 2, 3,..., b nc takes √ The Problem Θ( n) time which is exponential in the input-length. Core Idea behind the Integer factorization is a much harder problem than Algorithms primality testing and not even a probabilistic polynomial Preliminaries time algorithm is known for that. The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 9 / 60 Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Difficulty in the Naive Approach and how to overcome it (Roll No.: 142123029) The naive algorithm which tries to find a factor by √ Introduction checking whether n is divisible by 2, 3,..., b nc takes √ The Problem Θ( n) time which is exponential in the input-length. Core Idea behind the Integer factorization is a much harder problem than Algorithms primality testing and not even a probabilistic polynomial Preliminaries time algorithm is known for that. The Miller-Rabin The effective approach to primality testing is to come up Primality Testing with mathematical identities which are satisfied by n if and Algorithm only if n is a prime. This allows us to solve the decision The Agrawal- Biswas problem without having knowledge of the factors of n. Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 9 / 60 2 “Suitably choose” a ring Rn and a subset S of Rn.

3 For suitably chosen elements a1,..., al ∈ S, if ai does not satisfy a “special identity” then return COMPOSITE (else we may need to perform some “other checks”).

4 If each ai satisfies the “special identity” in Rn then return PRIME.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Core Idea (Roll No.: 142123029) 1 If n is less than some constant then check whether n is k Introduction prime by brute force. Also, if n = a for some integers a

The Problem and k , where k > 2, then return COMPOSITE Core Idea (isPower(n) shows than it can be checked efficiently). behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 10 / 60 3 For suitably chosen elements a1,..., al ∈ S, if ai does not satisfy a “special identity” then return COMPOSITE (else we may need to perform some “other checks”).

4 If each ai satisfies the “special identity” in Rn then return PRIME.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Core Idea (Roll No.: 142123029) 1 If n is less than some constant then check whether n is k Introduction prime by brute force. Also, if n = a for some integers a

The Problem and k , where k > 2, then return COMPOSITE Core Idea (isPower(n) shows than it can be checked efficiently). behind the Algorithms 2 “Suitably choose” a ring Rn and a subset S of Rn. Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 10 / 60 4 If each ai satisfies the “special identity” in Rn then return PRIME.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Core Idea (Roll No.: 142123029) 1 If n is less than some constant then check whether n is k Introduction prime by brute force. Also, if n = a for some integers a

The Problem and k , where k > 2, then return COMPOSITE Core Idea (isPower(n) shows than it can be checked efficiently). behind the Algorithms 2 “Suitably choose” a ring Rn and a subset S of Rn. Preliminaries 3 For suitably chosen elements a1,..., al ∈ S, if ai does not The Miller-Rabin satisfy a “special identity” then return COMPOSITE (else Primality Testing we may need to perform some “other checks”). Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 10 / 60 Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Core Idea (Roll No.: 142123029) 1 If n is less than some constant then check whether n is k Introduction prime by brute force. Also, if n = a for some integers a

The Problem and k , where k > 2, then return COMPOSITE Core Idea (isPower(n) shows than it can be checked efficiently). behind the Algorithms 2 “Suitably choose” a ring Rn and a subset S of Rn. Preliminaries 3 For suitably chosen elements a1,..., al ∈ S, if ai does not The Miller-Rabin satisfy a “special identity” then return COMPOSITE (else Primality Testing we may need to perform some “other checks”). Algorithm 4 The Agrawal- If each ai satisfies the “special identity” in Rn then return Biswas Primality PRIME. Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 10 / 60 ∗ S = Zn ∗ a1,..., al are randomly chosen elements from Zn n−1 The “special identity” is ai = 1. This identity is motivated by Fermat’s little theorem which says, if n is ∗ n−1 prime then for all a ∈ Zn, a = 1.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Miller-Rabin Test Introduction Rn = Zn The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 11 / 60 ∗ a1,..., al are randomly chosen elements from Zn n−1 The “special identity” is ai = 1. This identity is motivated by Fermat’s little theorem which says, if n is ∗ n−1 prime then for all a ∈ Zn, a = 1.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Miller-Rabin Test Introduction Rn = Zn The Problem ∗ Core Idea S = Zn behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 11 / 60 n−1 The “special identity” is ai = 1. This identity is motivated by Fermat’s little theorem which says, if n is ∗ n−1 prime then for all a ∈ Zn, a = 1.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Miller-Rabin Test Introduction Rn = Zn The Problem ∗ Core Idea S = Zn behind the ∗ Algorithms a1,..., al are randomly chosen elements from Zn Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 11 / 60 Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Miller-Rabin Test Introduction Rn = Zn The Problem ∗ Core Idea S = Zn behind the ∗ Algorithms a1,..., al are randomly chosen elements from Zn Preliminaries n−1 The “special identity” is ai = 1. This identity is The Miller-Rabin motivated by Fermat’s little theorem which says, if n is Primality ∗ n−1 Testing prime then for all a ∈ Zn, a = 1. Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 11 / 60 Rn = Zn[x] S is the set of all monic polynomial of degree dlog ne Q(x) is randomly chosen from S Check whether (x + 1)n − (xn + 1) is zero modulo the polynomial Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Agrawal-Biswas Test n n Introduction Fermat’s little theorem is generalised to: (x + a) = x + a ∗ The Problem if and only if n is prime (where a is any element from Zn) Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 12 / 60 S is the set of all monic polynomial of degree dlog ne Q(x) is randomly chosen from S Check whether (x + 1)n − (xn + 1) is zero modulo the polynomial Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Agrawal-Biswas Test n n Introduction Fermat’s little theorem is generalised to: (x + a) = x + a ∗ The Problem if and only if n is prime (where a is any element from Zn) Core Idea behind the Rn = Zn[x] Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 12 / 60 Q(x) is randomly chosen from S Check whether (x + 1)n − (xn + 1) is zero modulo the polynomial Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Agrawal-Biswas Test n n Introduction Fermat’s little theorem is generalised to: (x + a) = x + a ∗ The Problem if and only if n is prime (where a is any element from Zn) Core Idea behind the Rn = Zn[x] Algorithms S is the set of all monic polynomial of degree dlog ne Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 12 / 60 Check whether (x + 1)n − (xn + 1) is zero modulo the polynomial Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Agrawal-Biswas Test n n Introduction Fermat’s little theorem is generalised to: (x + a) = x + a ∗ The Problem if and only if n is prime (where a is any element from Zn) Core Idea behind the Rn = Zn[x] Algorithms S is the set of all monic polynomial of degree dlog ne Preliminaries

The Q(x) is randomly chosen from S Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 12 / 60 Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Agrawal-Biswas Test n n Introduction Fermat’s little theorem is generalised to: (x + a) = x + a ∗ The Problem if and only if n is prime (where a is any element from Zn) Core Idea behind the Rn = Zn[x] Algorithms S is the set of all monic polynomial of degree dlog ne Preliminaries

The Q(x) is randomly chosen from S Miller-Rabin n n Primality Check whether (x + 1) − (x + 1) is zero modulo the Testing Algorithm polynomial Q(x) The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 12 / 60 If the output is COMPOSITE then n is a composite number. If the ouput is PRIME then, n is prime with a high probability greater than a constant value. The probability can be boosted arbitrarity close to 1 by increasing l by a constant factor. However, without checking the identity for O(|S|) elements in S we cannot make the probability to be exactly 1. Since, for both the algorithms, the size of S is superpolynomial, it would take superpolynomial time to make them deterministic.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The Probabilistic Nature of these Algorithms Prerona Chatterjee Both of these algorithms are probabilistic and exhibits one (Roll No.: 142123029) sided error.

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 13 / 60 If the ouput is PRIME then, n is prime with a high probability greater than a constant value. The probability can be boosted arbitrarity close to 1 by increasing l by a constant factor. However, without checking the identity for O(|S|) elements in S we cannot make the probability to be exactly 1. Since, for both the algorithms, the size of S is superpolynomial, it would take superpolynomial time to make them deterministic.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The Probabilistic Nature of these Algorithms Prerona Chatterjee Both of these algorithms are probabilistic and exhibits one (Roll No.: 142123029) sided error.

Introduction If the output is COMPOSITE then n is a composite

The Problem number.

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 13 / 60 The probability can be boosted arbitrarity close to 1 by increasing l by a constant factor. However, without checking the identity for O(|S|) elements in S we cannot make the probability to be exactly 1. Since, for both the algorithms, the size of S is superpolynomial, it would take superpolynomial time to make them deterministic.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The Probabilistic Nature of these Algorithms Prerona Chatterjee Both of these algorithms are probabilistic and exhibits one (Roll No.: 142123029) sided error.

Introduction If the output is COMPOSITE then n is a composite

The Problem number. Core Idea If the ouput is PRIME then, n is prime with a high behind the Algorithms probability greater than a constant value. Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 13 / 60 Since, for both the algorithms, the size of S is superpolynomial, it would take superpolynomial time to make them deterministic.

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The Probabilistic Nature of these Algorithms Prerona Chatterjee Both of these algorithms are probabilistic and exhibits one (Roll No.: 142123029) sided error.

Introduction If the output is COMPOSITE then n is a composite

The Problem number. Core Idea If the ouput is PRIME then, n is prime with a high behind the Algorithms probability greater than a constant value. Preliminaries The probability can be boosted arbitrarity close to 1 by The Miller-Rabin increasing l by a constant factor. However, without Primality Testing checking the identity for O(|S|) elements in S we cannot Algorithm make the probability to be exactly 1. The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 13 / 60 Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The Probabilistic Nature of these Algorithms Prerona Chatterjee Both of these algorithms are probabilistic and exhibits one (Roll No.: 142123029) sided error.

Introduction If the output is COMPOSITE then n is a composite

The Problem number. Core Idea If the ouput is PRIME then, n is prime with a high behind the Algorithms probability greater than a constant value. Preliminaries The probability can be boosted arbitrarity close to 1 by The Miller-Rabin increasing l by a constant factor. However, without Primality Testing checking the identity for O(|S|) elements in S we cannot Algorithm make the probability to be exactly 1. The Agrawal- Biswas Primality Since, for both the algorithms, the size of S is Testing superpolynomial, it would take superpolynomial time to Algorithm

The AKS make them deterministic. Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 13 / 60 Equivalently, (by theorem 8) check: For all Q(x) ∈ S = {(x + a)r − 1 | a = 1,..., l}, (x + 1)n − (xn + 1) is zero modulo Q(x) This is exactly like the Agrawal-Biswas test, except the size of S is reduced from O(nlog n) to log6 n, which allows us to check the “identity” exhaustively for all the elements in S which leads to the deterministic algorithm. r 5 Rn = Zn/(x − 1) where r = O(log n) S = {(x + a)r − 1 | a = 1,..., l} For all Q(x) ∈ S = {(x + a)r − 1 | a = 1,..., l}, (x + 1)n − (xn + 1) is zero modulo Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The AKS Test Prerona n n Chatterjee Check whether (x + a) = x + a, in Rn, for a = 1, 2,..., l (Roll No.: 6 142123029) where l = O(log n).

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 14 / 60 This is exactly like the Agrawal-Biswas test, except the size of S is reduced from O(nlog n) to log6 n, which allows us to check the “identity” exhaustively for all the elements in S which leads to the deterministic algorithm. r 5 Rn = Zn/(x − 1) where r = O(log n) S = {(x + a)r − 1 | a = 1,..., l} For all Q(x) ∈ S = {(x + a)r − 1 | a = 1,..., l}, (x + 1)n − (xn + 1) is zero modulo Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The AKS Test Prerona n n Chatterjee Check whether (x + a) = x + a, in Rn, for a = 1, 2,..., l (Roll No.: 6 142123029) where l = O(log n). Equivalently, (by theorem 8) check: For all Introduction r The Problem Q(x) ∈ S = {(x + a) − 1 | a = 1,..., l}, n n Core Idea (x + 1) − (x + 1) is zero modulo Q(x) behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 14 / 60 r 5 Rn = Zn/(x − 1) where r = O(log n) S = {(x + a)r − 1 | a = 1,..., l} For all Q(x) ∈ S = {(x + a)r − 1 | a = 1,..., l}, (x + 1)n − (xn + 1) is zero modulo Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The AKS Test Prerona n n Chatterjee Check whether (x + a) = x + a, in Rn, for a = 1, 2,..., l (Roll No.: 6 142123029) where l = O(log n). Equivalently, (by theorem 8) check: For all Introduction r The Problem Q(x) ∈ S = {(x + a) − 1 | a = 1,..., l}, n n Core Idea (x + 1) − (x + 1) is zero modulo Q(x) behind the Algorithms This is exactly like the Agrawal-Biswas test, except the log n 6 Preliminaries size of S is reduced from O(n ) to log n, which allows The us to check the “identity” exhaustively for all the elements Miller-Rabin Primality in S which leads to the deterministic algorithm. Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 14 / 60 S = {(x + a)r − 1 | a = 1,..., l} For all Q(x) ∈ S = {(x + a)r − 1 | a = 1,..., l}, (x + 1)n − (xn + 1) is zero modulo Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The AKS Test Prerona n n Chatterjee Check whether (x + a) = x + a, in Rn, for a = 1, 2,..., l (Roll No.: 6 142123029) where l = O(log n). Equivalently, (by theorem 8) check: For all Introduction r The Problem Q(x) ∈ S = {(x + a) − 1 | a = 1,..., l}, n n Core Idea (x + 1) − (x + 1) is zero modulo Q(x) behind the Algorithms This is exactly like the Agrawal-Biswas test, except the log n 6 Preliminaries size of S is reduced from O(n ) to log n, which allows The us to check the “identity” exhaustively for all the elements Miller-Rabin Primality in S which leads to the deterministic algorithm. Testing Algorithm r 5 Rn = Zn/(x − 1) where r = O(log n) The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 14 / 60 For all Q(x) ∈ S = {(x + a)r − 1 | a = 1,..., l}, (x + 1)n − (xn + 1) is zero modulo Q(x)

Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The AKS Test Prerona n n Chatterjee Check whether (x + a) = x + a, in Rn, for a = 1, 2,..., l (Roll No.: 6 142123029) where l = O(log n). Equivalently, (by theorem 8) check: For all Introduction r The Problem Q(x) ∈ S = {(x + a) − 1 | a = 1,..., l}, n n Core Idea (x + 1) − (x + 1) is zero modulo Q(x) behind the Algorithms This is exactly like the Agrawal-Biswas test, except the log n 6 Preliminaries size of S is reduced from O(n ) to log n, which allows The us to check the “identity” exhaustively for all the elements Miller-Rabin Primality in S which leads to the deterministic algorithm. Testing Algorithm r 5 Rn = Zn/(x − 1) where r = O(log n) The Agrawal- r Biswas S = {(x + a) − 1 | a = 1,..., l} Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 14 / 60 Core Idea behind the Algorithms

PRIMALITY TESTING AL- GORITHMS The AKS Test Prerona n n Chatterjee Check whether (x + a) = x + a, in Rn, for a = 1, 2,..., l (Roll No.: 6 142123029) where l = O(log n). Equivalently, (by theorem 8) check: For all Introduction r The Problem Q(x) ∈ S = {(x + a) − 1 | a = 1,..., l}, n n Core Idea (x + 1) − (x + 1) is zero modulo Q(x) behind the Algorithms This is exactly like the Agrawal-Biswas test, except the log n 6 Preliminaries size of S is reduced from O(n ) to log n, which allows The us to check the “identity” exhaustively for all the elements Miller-Rabin Primality in S which leads to the deterministic algorithm. Testing Algorithm r 5 Rn = Zn/(x − 1) where r = O(log n) The Agrawal- r Biswas S = {(x + a) − 1 | a = 1,..., l} Primality Testing r Algorithm For all Q(x) ∈ S = {(x + a) − 1 | a = 1,..., l}, n n The AKS (x + 1) − (x + 1) is zero modulo Q(x) Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 14 / 60 Preliminaries

PRIMALITY TESTING AL- GORITHMS

Prerona 1 Introduction Chatterjee (Roll No.: 142123029) 2 The Problem

Introduction The Problem 3 Core Idea behind the Algorithms Core Idea behind the Algorithms 4 Preliminaries Preliminaries

The Miller-Rabin 5 The Miller-Rabin Primality Testing Algorithm Primality Testing Algorithm 6 The Agrawal-Biswas Primality Testing Algorithm The Agrawal- Biswas Primality Testing 7 Algorithm The AKS Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 15 / 60 Groups Order of a finite group is the cardinality of that group. Order of a group element g is he smallest positive integer n for which g n is identity. If no such integer exists then order of g is defined to be zero.

Proposition

The follwing properties of groups are well-known. 1 (Lagrange Theorem) If H is a subgroup of a finite group G, the order of H divides the order of G. 2 If g is an element of a finite group G, the order of g divides the order of G. 3 Let H be a non-empty finite subset of a group G. H is a subgroup of G iff ∀a, b ∈ H, ab ∈ H.

Preliminaries

PRIMALITY We state some of the very basic definitions and results about TESTING AL- GORITHMS algebra and algorithms which will later be used. Prerona Chatterjee (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 16 / 60 Order of a group element g is he smallest positive integer n for which g n is identity. If no such integer exists then order of g is defined to be zero.

Proposition

The follwing properties of groups are well-known. 1 (Lagrange Theorem) If H is a subgroup of a finite group G, the order of H divides the order of G. 2 If g is an element of a finite group G, the order of g divides the order of G. 3 Let H be a non-empty finite subset of a group G. H is a subgroup of G iff ∀a, b ∈ H, ab ∈ H.

Preliminaries

PRIMALITY We state some of the very basic definitions and results about TESTING AL- GORITHMS algebra and algorithms which will later be used. Prerona Chatterjee Groups (Roll No.: 142123029) Order of a finite group is the cardinality of that group.

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 16 / 60 Proposition

The follwing properties of groups are well-known. 1 (Lagrange Theorem) If H is a subgroup of a finite group G, the order of H divides the order of G. 2 If g is an element of a finite group G, the order of g divides the order of G. 3 Let H be a non-empty finite subset of a group G. H is a subgroup of G iff ∀a, b ∈ H, ab ∈ H.

Preliminaries

PRIMALITY We state some of the very basic definitions and results about TESTING AL- GORITHMS algebra and algorithms which will later be used. Prerona Chatterjee Groups (Roll No.: 142123029) Order of a finite group is the cardinality of that group.

Introduction Order of a group element g is he smallest positive integer n The Problem n for which g is identity. If no such integer exists then Core Idea order of g is defined to be zero. behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 16 / 60 2 If g is an element of a finite group G, the order of g divides the order of G. 3 Let H be a non-empty finite subset of a group G. H is a subgroup of G iff ∀a, b ∈ H, ab ∈ H.

Preliminaries

PRIMALITY We state some of the very basic definitions and results about TESTING AL- GORITHMS algebra and algorithms which will later be used. Prerona Chatterjee Groups (Roll No.: 142123029) Order of a finite group is the cardinality of that group.

Introduction Order of a group element g is he smallest positive integer n The Problem n for which g is identity. If no such integer exists then Core Idea order of g is defined to be zero. behind the Algorithms Preliminaries Proposition The Miller-Rabin Primality The follwing properties of groups are well-known. Testing Algorithm 1 (Lagrange Theorem) If H is a subgroup of a finite group The Agrawal- G, the order of H divides the order of G. Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 16 / 60 3 Let H be a non-empty finite subset of a group G. H is a subgroup of G iff ∀a, b ∈ H, ab ∈ H.

Preliminaries

PRIMALITY We state some of the very basic definitions and results about TESTING AL- GORITHMS algebra and algorithms which will later be used. Prerona Chatterjee Groups (Roll No.: 142123029) Order of a finite group is the cardinality of that group.

Introduction Order of a group element g is he smallest positive integer n The Problem n for which g is identity. If no such integer exists then Core Idea order of g is defined to be zero. behind the Algorithms Preliminaries Proposition The Miller-Rabin Primality The follwing properties of groups are well-known. Testing Algorithm 1 (Lagrange Theorem) If H is a subgroup of a finite group The Agrawal- G, the order of H divides the order of G. Biswas Primality 2 If g is an element of a finite group G, the order of g Testing Algorithm divides the order of G. The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 16 / 60 Preliminaries

PRIMALITY We state some of the very basic definitions and results about TESTING AL- GORITHMS algebra and algorithms which will later be used. Prerona Chatterjee Groups (Roll No.: 142123029) Order of a finite group is the cardinality of that group.

Introduction Order of a group element g is he smallest positive integer n The Problem n for which g is identity. If no such integer exists then Core Idea order of g is defined to be zero. behind the Algorithms Preliminaries Proposition The Miller-Rabin Primality The follwing properties of groups are well-known. Testing Algorithm 1 (Lagrange Theorem) If H is a subgroup of a finite group The Agrawal- G, the order of H divides the order of G. Biswas Primality 2 If g is an element of a finite group G, the order of g Testing Algorithm divides the order of G. The AKS Primality 3 Let H be a non-empty finite subset of a group G. H is a Testing Algorithm subgroup of G iff ∀a, b ∈ H, ab ∈ H.

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 16 / 60 For a ring R, the set of units forms a multiplicative group which we write as R∗. For an element r in ring R, rR is the ideal generated by r and R/rR is the quotient ring. For a ∈ R, a + rR is the coset of rR in R with respect to a. However, we often abuse the notation to identify a + rR with a. Hence, whenever we use an expression of like, a ∈ R/rR, where a is an element of R itself, it should be understood that we mean a + rR ∈ R/rR.Order of a finite group is the cardinality of that group.

Preliminaries

PRIMALITY TESTING AL- GORITHMS

Prerona Rings Chatterjee (Roll No.: By “ring” we always mean commutative ring with 142123029) multiplicative identity.

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 17 / 60 For an element r in ring R, rR is the ideal generated by r and R/rR is the quotient ring. For a ∈ R, a + rR is the coset of rR in R with respect to a. However, we often abuse the notation to identify a + rR with a. Hence, whenever we use an expression of like, a ∈ R/rR, where a is an element of R itself, it should be understood that we mean a + rR ∈ R/rR.Order of a finite group is the cardinality of that group.

Preliminaries

PRIMALITY TESTING AL- GORITHMS

Prerona Rings Chatterjee (Roll No.: By “ring” we always mean commutative ring with 142123029) multiplicative identity. Introduction For a ring R, the set of units forms a multiplicative group The Problem which we write as R∗. Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 17 / 60 For a ∈ R, a + rR is the coset of rR in R with respect to a. However, we often abuse the notation to identify a + rR with a. Hence, whenever we use an expression of like, a ∈ R/rR, where a is an element of R itself, it should be understood that we mean a + rR ∈ R/rR.Order of a finite group is the cardinality of that group.

Preliminaries

PRIMALITY TESTING AL- GORITHMS

Prerona Rings Chatterjee (Roll No.: By “ring” we always mean commutative ring with 142123029) multiplicative identity. Introduction For a ring R, the set of units forms a multiplicative group The Problem which we write as R∗. Core Idea behind the For an element r in ring R, rR is the ideal generated by r Algorithms and R/rR is the quotient ring. Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 17 / 60 Preliminaries

PRIMALITY TESTING AL- GORITHMS

Prerona Rings Chatterjee (Roll No.: By “ring” we always mean commutative ring with 142123029) multiplicative identity. Introduction For a ring R, the set of units forms a multiplicative group The Problem which we write as R∗. Core Idea behind the For an element r in ring R, rR is the ideal generated by r Algorithms and R/rR is the quotient ring. Preliminaries

The For a ∈ R, a + rR is the coset of rR in R with respect to Miller-Rabin Primality a. However, we often abuse the notation to identify a + rR Testing Algorithm with a. Hence, whenever we use an expression of like,

The Agrawal- a ∈ R/rR, where a is an element of R itself, it should be Biswas Primality understood that we mean a + rR ∈ R/rR.Order of a finite Testing Algorithm group is the cardinality of that group.

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 17 / 60 Z denotes the ring of integers. For n ∈ Z \{0}, Z/nZ is written as Zn. As mentioned above, when a is an integer, expression of the form a ∈ Zn actually mean a + nZ ∈ Zn. For ring R, R[x] is the univariate polynomial ring over R and we use R[x]/f (x) to denote the quotient ring R[x]/f (x)R[x].

Cartesian product of two rings R1 and R2 can be identified as a ring by defining (a, b) + (c, d) = (a + c, b + d) and (a, b)(c, d) = (ac, bd) for all a, c ∈ R1 and b, d ∈ R2.

Preliminaries

PRIMALITY TESTING AL- Rings (contd...) GORITHMS

Prerona Chatterjee If R is a euclidean domain then, (Roll No.: 142123029) Proposition

Introduction 1 For a ∈ R, a ∈ R/rR∗ if and only if gcd(a, r) = 1. The Problem 2 R/rR is a field if and only if r is a prime element of R. Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 18 / 60 Cartesian product of two rings R1 and R2 can be identified as a ring by defining (a, b) + (c, d) = (a + c, b + d) and (a, b)(c, d) = (ac, bd) for all a, c ∈ R1 and b, d ∈ R2.

Preliminaries

PRIMALITY TESTING AL- Rings (contd...) GORITHMS

Prerona Chatterjee If R is a euclidean domain then, (Roll No.: 142123029) Proposition

Introduction 1 For a ∈ R, a ∈ R/rR∗ if and only if gcd(a, r) = 1. The Problem 2 R/rR is a field if and only if r is a prime element of R. Core Idea behind the Algorithms Z denotes the ring of integers. For n ∈ Z \{0}, Z/nZ is Preliminaries written as Zn. As mentioned above, when a is an integer, The Miller-Rabin expression of the form a ∈ Zn actually mean a + nZ ∈ Zn. Primality Testing For ring R, R[x] is the univariate polynomial ring over R Algorithm and we use R[x]/f (x) to denote the quotient ring The Agrawal- Biswas R[x]/f (x)R[x]. Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 18 / 60 Preliminaries

PRIMALITY TESTING AL- Rings (contd...) GORITHMS

Prerona Chatterjee If R is a euclidean domain then, (Roll No.: 142123029) Proposition

Introduction 1 For a ∈ R, a ∈ R/rR∗ if and only if gcd(a, r) = 1. The Problem 2 R/rR is a field if and only if r is a prime element of R. Core Idea behind the Algorithms Z denotes the ring of integers. For n ∈ Z \{0}, Z/nZ is Preliminaries written as Zn. As mentioned above, when a is an integer, The Miller-Rabin expression of the form a ∈ Zn actually mean a + nZ ∈ Zn. Primality Testing For ring R, R[x] is the univariate polynomial ring over R Algorithm and we use R[x]/f (x) to denote the quotient ring The Agrawal- Biswas R[x]/f (x)R[x]. Primality Testing Cartesian product of two rings R and R can be identified Algorithm 1 2

The AKS as a ring by defining (a, b) + (c, d) = (a + c, b + d) and Primality Testing (a, b)(c, d) = (ac, bd) for all a, c ∈ R1 and b, d ∈ R2. Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 18 / 60 Theorem (Fermat’s Little Theorem)

∗ p−1 Let p be a prime number. For all a ∈ Fp, a = 1.

Proof. ∗ Since p is prime, by Proposition 18.1, Fp = Fp \{0} and ∗ ∗ ∗ |Fp | |Fp| = p − 1. By Proposition 16.2, for all a ∈ Fp, a = 1.

Preliminaries

PRIMALITY TESTING AL- Fields GORITHMS Prerona From Proposition 18.2 it follows that Zn is a field iff n is prime Chatterjee (Roll No.: and, for a finite field F, F[x]/f (x) is a field iff f (x) is 142123029) irreducible over F. It is also well-known that there exists a d Introduction finite field of order q iff q = p where p is prime and d is a

The Problem positive integer. All finite fields of same order are isomorphic,

Core Idea and hence we can talk about “the” finite field of order q behind the d Algorithms denoting it by Fq. For q = p , p is the characteristic of Fq. Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 19 / 60 Proof. ∗ Since p is prime, by Proposition 18.1, Fp = Fp \{0} and ∗ ∗ ∗ |Fp | |Fp| = p − 1. By Proposition 16.2, for all a ∈ Fp, a = 1.

Preliminaries

PRIMALITY TESTING AL- Fields GORITHMS Prerona From Proposition 18.2 it follows that Zn is a field iff n is prime Chatterjee (Roll No.: and, for a finite field F, F[x]/f (x) is a field iff f (x) is 142123029) irreducible over F. It is also well-known that there exists a d Introduction finite field of order q iff q = p where p is prime and d is a

The Problem positive integer. All finite fields of same order are isomorphic,

Core Idea and hence we can talk about “the” finite field of order q behind the d Algorithms denoting it by Fq. For q = p , p is the characteristic of Fq. Preliminaries

The Miller-Rabin Theorem (Fermat’s Little Theorem) Primality Testing ∗ p−1 Algorithm Let p be a prime number. For all a ∈ Fp, a = 1. The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 19 / 60 Preliminaries

PRIMALITY TESTING AL- Fields GORITHMS Prerona From Proposition 18.2 it follows that Zn is a field iff n is prime Chatterjee (Roll No.: and, for a finite field F, F[x]/f (x) is a field iff f (x) is 142123029) irreducible over F. It is also well-known that there exists a d Introduction finite field of order q iff q = p where p is prime and d is a

The Problem positive integer. All finite fields of same order are isomorphic,

Core Idea and hence we can talk about “the” finite field of order q behind the d Algorithms denoting it by Fq. For q = p , p is the characteristic of Fq. Preliminaries

The Miller-Rabin Theorem (Fermat’s Little Theorem) Primality Testing ∗ p−1 Algorithm Let p be a prime number. For all a ∈ Fp, a = 1. The Agrawal- Biswas Primality Proof. Testing Algorithm ∗ Since p is prime, by Proposition 18.1, Fp = Fp \{0} and The AKS ∗ ∗ ∗ |Fp | Primality |Fp| = p − 1. By Proposition 16.2, for all a ∈ Fp, a = 1. Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 19 / 60 For a field F, the polynomial ring F[x] is an integral domain which implies the following. Theorem If F is a field and f (x) ∈ F[x] is a polynomial of degree d, then f cannot have more than d roots.

Preliminaries

PRIMALITY TESTING AL- GORITHMS Theorem Prerona Chatterjee (Roll No.: Let n ∈ and n = n n such that gcd(n , n ) = 1, then is 142123029) Z 1 2 1 2 Zn isomorphic to Zn1 × Zn2 . In particular φ : Zn → Zn1 × Zn2 as Introduction defined below is an isomorphism: The Problem Core Idea φ(x + n ) = (x + n1 , x + n2 ). behind the Z Z Z Algorithms ∗ ∗ ∗ Preliminaries Thus in particular, Zn is isomorphic to Zn1 × Zn2

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 20 / 60 Preliminaries

PRIMALITY TESTING AL- GORITHMS Theorem Prerona Chatterjee (Roll No.: Let n ∈ and n = n n such that gcd(n , n ) = 1, then is 142123029) Z 1 2 1 2 Zn isomorphic to Zn1 × Zn2 . In particular φ : Zn → Zn1 × Zn2 as Introduction defined below is an isomorphism: The Problem Core Idea φ(x + n ) = (x + n1 , x + n2 ). behind the Z Z Z Algorithms ∗ ∗ ∗ Preliminaries Thus in particular, Zn is isomorphic to Zn1 × Zn2

The Miller-Rabin For a field , the polynomial ring [x] is an integral domain Primality F F Testing which implies the following. Algorithm The Agrawal- Theorem Biswas Primality Testing If F is a field and f (x) ∈ F[x] is a polynomial of degree d, then Algorithm f cannot have more than d roots. The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 20 / 60 isPower(n) checks whether the integer n can be expressed as xk where x, k are integers and k > 2. Step 3 of isPower(n) can be done in O(log n) time and hence the total time complexity is O(log2 n). gcd(a, b) computes the gcd of two integers using Euclid’s method. If a and b are O(n), it can be shown that the while loop in gcd(a, b) iterates O(log n) times. Mod-Exp(a, b, n) gives an algorithm which takes time polynomial in log n for modular exponentiation. We cannot directly compute ab first and then take modulo n because it will take O(n log n) bits to represent ab and hence the time will be superpolynomial in input size.

Preliminaries

PRIMALITY Some Basic Algorithms TESTING AL- GORITHMS

Prerona Inputs are an integer or integers of O(n). Hence in binary Chatterjee (Roll No.: representation, the input size is O(log n). Thus in order to have 142123029) polynomial time algorithm, it is required that the time

Introduction complexities are polynomial in log n.

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 21 / 60 gcd(a, b) computes the gcd of two integers using Euclid’s method. If a and b are O(n), it can be shown that the while loop in gcd(a, b) iterates O(log n) times. Mod-Exp(a, b, n) gives an algorithm which takes time polynomial in log n for modular exponentiation. We cannot directly compute ab first and then take modulo n because it will take O(n log n) bits to represent ab and hence the time will be superpolynomial in input size.

Preliminaries

PRIMALITY Some Basic Algorithms TESTING AL- GORITHMS

Prerona Inputs are an integer or integers of O(n). Hence in binary Chatterjee (Roll No.: representation, the input size is O(log n). Thus in order to have 142123029) polynomial time algorithm, it is required that the time

Introduction complexities are polynomial in log n. The Problem isPower(n) checks whether the integer n can be Core Idea k behind the expressed as x where x, k are integers and k > 2. Step 3 Algorithms of isPower(n) can be done in O(log n) time and hence Preliminaries the total time complexity is O(log2 n). The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 21 / 60 Mod-Exp(a, b, n) gives an algorithm which takes time polynomial in log n for modular exponentiation. We cannot directly compute ab first and then take modulo n because it will take O(n log n) bits to represent ab and hence the time will be superpolynomial in input size.

Preliminaries

PRIMALITY Some Basic Algorithms TESTING AL- GORITHMS

Prerona Inputs are an integer or integers of O(n). Hence in binary Chatterjee (Roll No.: representation, the input size is O(log n). Thus in order to have 142123029) polynomial time algorithm, it is required that the time

Introduction complexities are polynomial in log n. The Problem isPower(n) checks whether the integer n can be Core Idea k behind the expressed as x where x, k are integers and k > 2. Step 3 Algorithms of isPower(n) can be done in O(log n) time and hence Preliminaries the total time complexity is O(log2 n). The Miller-Rabin gcd(a, b) computes the gcd of two integers using Euclid’s Primality Testing method. If a and b are O(n), it can be shown that the Algorithm while loop in (a, b) iterates O(log n) times. The Agrawal- gcd Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 21 / 60 Preliminaries

PRIMALITY Some Basic Algorithms TESTING AL- GORITHMS

Prerona Inputs are an integer or integers of O(n). Hence in binary Chatterjee (Roll No.: representation, the input size is O(log n). Thus in order to have 142123029) polynomial time algorithm, it is required that the time

Introduction complexities are polynomial in log n. The Problem isPower(n) checks whether the integer n can be Core Idea k behind the expressed as x where x, k are integers and k > 2. Step 3 Algorithms of isPower(n) can be done in O(log n) time and hence Preliminaries the total time complexity is O(log2 n). The Miller-Rabin gcd(a, b) computes the gcd of two integers using Euclid’s Primality Testing method. If a and b are O(n), it can be shown that the Algorithm while loop in (a, b) iterates O(log n) times. The Agrawal- gcd Biswas Primality Mod-Exp(a, b, n) gives an algorithm which takes time Testing Algorithm polynomial in log n for modular exponentiation. We b The AKS cannot directly compute a first and then take modulo n Primality b Testing because it will take O(n log n) bits to represent a and Algorithm hence the time will be superpolynomial in input size. Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 21 / 60 Preliminaries

PRIMALITY TESTING AL- Algorithm 1 Check if a Number is an Integral Power GORITHMS 1: procedure isPower(n) Prerona Chatterjee 2: for k = 1 to lg n do (Roll No.: 3: Use bisection method to find the largest integer x s.t. xk ≤ n 142123029) 4: if xk = n then 5: return True Introduction 6: end if The Problem 7: end for Core Idea 8: return False behind the 9: end procedure Algorithms

Preliminaries

The Miller-Rabin Algorithm 2 Compute GCD of two integers Primality Testing 1: procedure gcd(a, b) Algorithm 2: while b does not divide a do 0 The Agrawal- 3: b = a mod b Biswas 4: a = b Primality 0 Testing 5: b = b Algorithm 6: end while 7: return b The AKS Primality 8: end procedure Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 22 / 60 Preliminaries

PRIMALITY TESTING AL- GORITHMS Algorithm 3 Modular Exponentiation: Given integers a, b, n b Prerona compute a mod n Chatterjee (Roll No.: 1: procedure Mod-Exp(a, b, n) 142123029) 2: c = 0

Introduction 3: d = 1 The Problem 4: let {bk , bk−1, ...., b0} be the binary representation of b Core Idea 5: for i=k downto 0 do behind the Algorithms 6: c = 2c Preliminaries 7: d = d2 (mod n) The 8: Miller-Rabin if bi == 1 then Primality 9: c = c + 1 Testing Algorithm 10: d = d.a (mod n) The Agrawal- 11: Biswas end if Primality 12: end for Testing Algorithm 13: return d The AKS 14: Primality end procedure Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 23 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona 1 Introduction Chatterjee (Roll No.: 142123029) 2 The Problem

Introduction The Problem 3 Core Idea behind the Algorithms Core Idea behind the Algorithms 4 Preliminaries Preliminaries

The Miller-Rabin 5 The Miller-Rabin Primality Testing Algorithm Primality Testing Algorithm 6 The Agrawal-Biswas Primality Testing Algorithm The Agrawal- Biswas Primality Testing 7 Algorithm The AKS Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 24 / 60 However, there are composite numbers called ‘Fermat’s pseudoprimes’ for which equation 1 is also true. There are 2 key concepts behind the algorithm. If n is not a pseudoprime then the converse of equation 1 is almost true. In particular, for at least half of the ∗ elements a in Zn equation 1 does not hold. If n is a pseudoprime then with very high probability we can find a non trivial square root of unity in Zn which actually allows us to factorise n.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS The Key Concepts Prerona Chatterjee (Roll No.: We know that if n is prime then, by Fermat’s little theorem 142123029) an−1 = 1 ∀a ∈ ∗ (1) Introduction Zn

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 25 / 60 There are 2 key concepts behind the algorithm. If n is not a pseudoprime then the converse of equation 1 is almost true. In particular, for at least half of the ∗ elements a in Zn equation 1 does not hold. If n is a pseudoprime then with very high probability we can find a non trivial square root of unity in Zn which actually allows us to factorise n.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS The Key Concepts Prerona Chatterjee (Roll No.: We know that if n is prime then, by Fermat’s little theorem 142123029) an−1 = 1 ∀a ∈ ∗ (1) Introduction Zn

The Problem However, there are composite numbers called ‘Fermat’s Core Idea behind the pseudoprimes’ for which equation 1 is also true. Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 25 / 60 If n is not a pseudoprime then the converse of equation 1 is almost true. In particular, for at least half of the ∗ elements a in Zn equation 1 does not hold. If n is a pseudoprime then with very high probability we can find a non trivial square root of unity in Zn which actually allows us to factorise n.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS The Key Concepts Prerona Chatterjee (Roll No.: We know that if n is prime then, by Fermat’s little theorem 142123029) an−1 = 1 ∀a ∈ ∗ (1) Introduction Zn

The Problem However, there are composite numbers called ‘Fermat’s Core Idea behind the pseudoprimes’ for which equation 1 is also true. Algorithms There are 2 key concepts behind the algorithm. Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 25 / 60 If n is a pseudoprime then with very high probability we can find a non trivial square root of unity in Zn which actually allows us to factorise n.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS The Key Concepts Prerona Chatterjee (Roll No.: We know that if n is prime then, by Fermat’s little theorem 142123029) an−1 = 1 ∀a ∈ ∗ (1) Introduction Zn

The Problem However, there are composite numbers called ‘Fermat’s Core Idea behind the pseudoprimes’ for which equation 1 is also true. Algorithms There are 2 key concepts behind the algorithm. Preliminaries

The If n is not a pseudoprime then the converse of equation 1 Miller-Rabin Primality is almost true. In particular, for at least half of the Testing ∗ Algorithm elements a in Zn equation 1 does not hold. The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 25 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS The Key Concepts Prerona Chatterjee (Roll No.: We know that if n is prime then, by Fermat’s little theorem 142123029) an−1 = 1 ∀a ∈ ∗ (1) Introduction Zn

The Problem However, there are composite numbers called ‘Fermat’s Core Idea behind the pseudoprimes’ for which equation 1 is also true. Algorithms There are 2 key concepts behind the algorithm. Preliminaries

The If n is not a pseudoprime then the converse of equation 1 Miller-Rabin Primality is almost true. In particular, for at least half of the Testing ∗ Algorithm elements a in Zn equation 1 does not hold. The Agrawal- If n is a pseudoprime then with very high probability we Biswas Primality can find a non trivial square root of unity in which Testing Zn Algorithm actually allows us to factorise n. The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 25 / 60 Check if n is an integral power. Otherwise, rewrite n − 1 as 2t u. Pick some a in the range {1, 2, ..., n − 1} and check whether gcd(n, a) = 1

Otherwise, check for non-trivial square-roots of unity in Zn by first putting x = au and then repeatedly squaring it till x becomes equal to an−1. Check the Fermat's condition, namely check whether n−1 ∗ a = 1 for a ∈ Zn. If n fails in either of the two tests, then n is definitely composite. Otherwise n is probably prime. We can repeat the process a constant number of times by taking different a's so as to decrease the probability of error.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- The Algorithm GORITHMS Let n be the given number which we have to test for primality. Prerona Chatterjee (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 26 / 60 Pick some a in the range {1, 2, ..., n − 1} and check whether gcd(n, a) = 1

Otherwise, check for non-trivial square-roots of unity in Zn by first putting x = au and then repeatedly squaring it till x becomes equal to an−1. Check the Fermat's condition, namely check whether n−1 ∗ a = 1 for a ∈ Zn. If n fails in either of the two tests, then n is definitely composite. Otherwise n is probably prime. We can repeat the process a constant number of times by taking different a's so as to decrease the probability of error.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- The Algorithm GORITHMS Let n be the given number which we have to test for primality. Prerona Chatterjee (Roll No.: Check if n is an integral power. Otherwise, rewrite n − 1 142123029) as 2t u.

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 26 / 60 Otherwise, check for non-trivial square-roots of unity in Zn by first putting x = au and then repeatedly squaring it till x becomes equal to an−1. Check the Fermat's condition, namely check whether n−1 ∗ a = 1 for a ∈ Zn. If n fails in either of the two tests, then n is definitely composite. Otherwise n is probably prime. We can repeat the process a constant number of times by taking different a's so as to decrease the probability of error.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- The Algorithm GORITHMS Let n be the given number which we have to test for primality. Prerona Chatterjee (Roll No.: Check if n is an integral power. Otherwise, rewrite n − 1 142123029) as 2t u.

Introduction Pick some a in the range {1, 2, ..., n − 1} and check The Problem whether gcd(n, a) = 1 Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 26 / 60 Check the Fermat's condition, namely check whether n−1 ∗ a = 1 for a ∈ Zn. If n fails in either of the two tests, then n is definitely composite. Otherwise n is probably prime. We can repeat the process a constant number of times by taking different a's so as to decrease the probability of error.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- The Algorithm GORITHMS Let n be the given number which we have to test for primality. Prerona Chatterjee (Roll No.: Check if n is an integral power. Otherwise, rewrite n − 1 142123029) as 2t u.

Introduction Pick some a in the range {1, 2, ..., n − 1} and check The Problem whether gcd(n, a) = 1 Core Idea behind the Otherwise, check for non-trivial square-roots of unity in Zn Algorithms by first putting x = au and then repeatedly squaring it till Preliminaries x becomes equal to an−1. The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 26 / 60 If n fails in either of the two tests, then n is definitely composite. Otherwise n is probably prime. We can repeat the process a constant number of times by taking different a's so as to decrease the probability of error.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- The Algorithm GORITHMS Let n be the given number which we have to test for primality. Prerona Chatterjee (Roll No.: Check if n is an integral power. Otherwise, rewrite n − 1 142123029) as 2t u.

Introduction Pick some a in the range {1, 2, ..., n − 1} and check The Problem whether gcd(n, a) = 1 Core Idea behind the Otherwise, check for non-trivial square-roots of unity in Zn Algorithms by first putting x = au and then repeatedly squaring it till Preliminaries x becomes equal to an−1. The Miller-Rabin Primality Check the Fermat's condition, namely check whether Testing an−1 = 1 for a ∈ ∗. Algorithm Zn

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 26 / 60 We can repeat the process a constant number of times by taking different a's so as to decrease the probability of error.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- The Algorithm GORITHMS Let n be the given number which we have to test for primality. Prerona Chatterjee (Roll No.: Check if n is an integral power. Otherwise, rewrite n − 1 142123029) as 2t u.

Introduction Pick some a in the range {1, 2, ..., n − 1} and check The Problem whether gcd(n, a) = 1 Core Idea behind the Otherwise, check for non-trivial square-roots of unity in Zn Algorithms by first putting x = au and then repeatedly squaring it till Preliminaries x becomes equal to an−1. The Miller-Rabin Primality Check the Fermat's condition, namely check whether Testing an−1 = 1 for a ∈ ∗. Algorithm Zn

The Agrawal- If n fails in either of the two tests, then n is definitely Biswas Primality composite. Otherwise n is probably prime. Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 26 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- The Algorithm GORITHMS Let n be the given number which we have to test for primality. Prerona Chatterjee (Roll No.: Check if n is an integral power. Otherwise, rewrite n − 1 142123029) as 2t u.

Introduction Pick some a in the range {1, 2, ..., n − 1} and check The Problem whether gcd(n, a) = 1 Core Idea behind the Otherwise, check for non-trivial square-roots of unity in Zn Algorithms by first putting x = au and then repeatedly squaring it till Preliminaries x becomes equal to an−1. The Miller-Rabin Primality Check the Fermat's condition, namely check whether Testing an−1 = 1 for a ∈ ∗. Algorithm Zn

The Agrawal- If n fails in either of the two tests, then n is definitely Biswas Primality composite. Otherwise n is probably prime. Testing Algorithm We can repeat the process a constant number of times by The AKS taking different a s so as to decrease the probability of Primality ' Testing error. Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 26 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Algorithm 4 Miller-Rabin Primality Test GORITHMS 1: procedure MillerRabin(n) Prerona Chatterjee 2: if isPower(n) or n is even with n 6= 2 then (Roll No.: 3: return COMPOSITE 142123029) 4: end if 5: Choose a to be a random number in the range {1, 2, ..., n − 1} Introduction 6: if gcd(a, n) 6= 1 then The Problem 7: return COMPOSITE 8: end if Core Idea t behind the 9: Find t, u such that (n − 1) = 2 u and u is odd Algorithms 10: Put x0 = Mod-Exp(a, u, n) Preliminaries 11: for i=1 to t do 2 12: xi = xi−1 (mod n) The if x == 1 and x 6= 1 and x 6= −1 then Miller-Rabin 13: i i−1 i−1 Primality 14: return COMPOSITE Testing 15: //Checking for non-trivial square roots of unity Algorithm 16: end if The Agrawal- 17: end for Biswas 18: if x 6= 1 then Primality t Testing 19: return COMPOSITE //Checking Fermat’s Condition Algorithm 20: end if The AKS 21: return PRIME Primality 22: end procedure Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 27 / 60 If n is composite, we divide the analysis into two cases in ∗ both of which, we try to find a proper subgroup of Zn which contains all the elements for which MillerRabin(n) returns PRIME and hence all the elements for which the algorithm can err. 1 Thus, the error in the algorithm becomes less than 2 , and so can be made arbitrarily small by repeating the procedure a constant number of times.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Correctness (Roll No.: 142123029) If n is prime, then it can be trivially shown that the output

Introduction is always correct.

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 28 / 60 1 Thus, the error in the algorithm becomes less than 2 , and so can be made arbitrarily small by repeating the procedure a constant number of times.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Correctness (Roll No.: 142123029) If n is prime, then it can be trivially shown that the output

Introduction is always correct. The Problem If n is composite, we divide the analysis into two cases in Core Idea ∗ behind the both of which, we try to find a proper subgroup of Zn Algorithms which contains all the elements for which Preliminaries MillerRabin(n) returns PRIME and hence all the The Miller-Rabin elements for which the algorithm can err. Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 28 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Correctness (Roll No.: 142123029) If n is prime, then it can be trivially shown that the output

Introduction is always correct. The Problem If n is composite, we divide the analysis into two cases in Core Idea ∗ behind the both of which, we try to find a proper subgroup of Zn Algorithms which contains all the elements for which Preliminaries MillerRabin(n) returns PRIME and hence all the The Miller-Rabin elements for which the algorithm can err. Primality Testing 1 Algorithm Thus, the error in the algorithm becomes less than 2 , and so

The Agrawal- can be made arbitrarily small by repeating the procedure a Biswas Primality constant number of times. Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 28 / 60 Proof As explained in the key concepts, if n is prime, then the output of the procedure MillerRabin(n) is always PRIME. On the other hand, if n is composite, we have the following two cases: Case 1: n is not a pseudoprime ∗ Any a that has reached line 9 is in Zn ∗ n−1 ∃x ∈ Zn such that x 6= 1 (mod n) ∗ n−1 B = {z ∈ Zn : z = 1 (mod n)} is a proper non empty ∗ subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Theorem GORITHMS If n is prime, MillerRabin(n) outputs PRIME with Prerona Chatterjee probability one, and if n is composite, it outputs COMPOSITE (Roll No.: 1 142123029) with probability > 2 .

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 29 / 60 On the other hand, if n is composite, we have the following two cases: Case 1: n is not a pseudoprime ∗ Any a that has reached line 9 is in Zn ∗ n−1 ∃x ∈ Zn such that x 6= 1 (mod n) ∗ n−1 B = {z ∈ Zn : z = 1 (mod n)} is a proper non empty ∗ subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Theorem GORITHMS If n is prime, MillerRabin(n) outputs PRIME with Prerona Chatterjee probability one, and if n is composite, it outputs COMPOSITE (Roll No.: 1 142123029) with probability > 2 .

Introduction Proof The Problem

Core Idea As explained in the key concepts, if n is prime, then the output behind the Algorithms of the procedure MillerRabin(n) is always PRIME.

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 29 / 60 Case 1: n is not a pseudoprime ∗ Any a that has reached line 9 is in Zn ∗ n−1 ∃x ∈ Zn such that x 6= 1 (mod n) ∗ n−1 B = {z ∈ Zn : z = 1 (mod n)} is a proper non empty ∗ subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Theorem GORITHMS If n is prime, MillerRabin(n) outputs PRIME with Prerona Chatterjee probability one, and if n is composite, it outputs COMPOSITE (Roll No.: 1 142123029) with probability > 2 .

Introduction Proof The Problem

Core Idea As explained in the key concepts, if n is prime, then the output behind the Algorithms of the procedure MillerRabin(n) is always PRIME.

Preliminaries On the other hand, if n is composite, we have the following two

The cases: Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 29 / 60 ∗ Any a that has reached line 9 is in Zn ∗ n−1 ∃x ∈ Zn such that x 6= 1 (mod n) ∗ n−1 B = {z ∈ Zn : z = 1 (mod n)} is a proper non empty ∗ subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Theorem GORITHMS If n is prime, MillerRabin(n) outputs PRIME with Prerona Chatterjee probability one, and if n is composite, it outputs COMPOSITE (Roll No.: 1 142123029) with probability > 2 .

Introduction Proof The Problem

Core Idea As explained in the key concepts, if n is prime, then the output behind the Algorithms of the procedure MillerRabin(n) is always PRIME.

Preliminaries On the other hand, if n is composite, we have the following two

The cases: Miller-Rabin Primality Case 1: n is not a pseudoprime Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 29 / 60 ∗ n−1 ∃x ∈ Zn such that x 6= 1 (mod n) ∗ n−1 B = {z ∈ Zn : z = 1 (mod n)} is a proper non empty ∗ subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Theorem GORITHMS If n is prime, MillerRabin(n) outputs PRIME with Prerona Chatterjee probability one, and if n is composite, it outputs COMPOSITE (Roll No.: 1 142123029) with probability > 2 .

Introduction Proof The Problem

Core Idea As explained in the key concepts, if n is prime, then the output behind the Algorithms of the procedure MillerRabin(n) is always PRIME.

Preliminaries On the other hand, if n is composite, we have the following two

The cases: Miller-Rabin Primality Case 1: n is not a pseudoprime Testing ∗ Algorithm Any a that has reached line 9 is in Zn The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 29 / 60 ∗ n−1 B = {z ∈ Zn : z = 1 (mod n)} is a proper non empty ∗ subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Theorem GORITHMS If n is prime, MillerRabin(n) outputs PRIME with Prerona Chatterjee probability one, and if n is composite, it outputs COMPOSITE (Roll No.: 1 142123029) with probability > 2 .

Introduction Proof The Problem

Core Idea As explained in the key concepts, if n is prime, then the output behind the Algorithms of the procedure MillerRabin(n) is always PRIME.

Preliminaries On the other hand, if n is composite, we have the following two

The cases: Miller-Rabin Primality Case 1: n is not a pseudoprime Testing ∗ Algorithm Any a that has reached line 9 is in Zn The Agrawal- ∗ n−1 Biswas ∃x ∈ Zn such that x 6= 1 (mod n) Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 29 / 60 ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Theorem GORITHMS If n is prime, MillerRabin(n) outputs PRIME with Prerona Chatterjee probability one, and if n is composite, it outputs COMPOSITE (Roll No.: 1 142123029) with probability > 2 .

Introduction Proof The Problem

Core Idea As explained in the key concepts, if n is prime, then the output behind the Algorithms of the procedure MillerRabin(n) is always PRIME.

Preliminaries On the other hand, if n is composite, we have the following two

The cases: Miller-Rabin Primality Case 1: n is not a pseudoprime Testing ∗ Algorithm Any a that has reached line 9 is in Zn The Agrawal- ∗ n−1 Biswas ∃x ∈ Zn such that x 6= 1 (mod n) Primality ∗ n−1 Testing B = {z ∈ : z = 1 (mod n)} is a proper non empty Algorithm Zn subgroup of ∗ The AKS Zn Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 29 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- Theorem GORITHMS If n is prime, MillerRabin(n) outputs PRIME with Prerona Chatterjee probability one, and if n is composite, it outputs COMPOSITE (Roll No.: 1 142123029) with probability > 2 .

Introduction Proof The Problem

Core Idea As explained in the key concepts, if n is prime, then the output behind the Algorithms of the procedure MillerRabin(n) is always PRIME.

Preliminaries On the other hand, if n is composite, we have the following two

The cases: Miller-Rabin Primality Case 1: n is not a pseudoprime Testing ∗ Algorithm Any a that has reached line 9 is in Zn The Agrawal- ∗ n−1 Biswas ∃x ∈ Zn such that x 6= 1 (mod n) Primality ∗ n−1 Testing B = {z ∈ : z = 1 (mod n)} is a proper non empty Algorithm Zn subgroup of ∗ The AKS Zn ∗ Primality |Zn | Testing |B| ≤ 2 Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 29 / 60 ∗ Any a that has reached line 9 is in Zn ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) ∗ ∗ B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn For any n such that the algorithm has reached 6, n is not an integral power

∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and ∗ ∼ ∗ ∗ so by Theorem 3, Zn = Zn1 × Zn2 ∗ ∼ ∃a ∈ Zn\B such that a = (1, −1) ∗ B is a proper subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) ∗ ∗ B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn For any n such that the algorithm has reached 6, n is not an integral power

∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and ∗ ∼ ∗ ∗ so by Theorem 3, Zn = Zn1 × Zn2 ∗ ∼ ∃a ∈ Zn\B such that a = (1, −1) ∗ B is a proper subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029) ∗ Any a that has reached line 9 is in Zn Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 ∗ ∗ B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn For any n such that the algorithm has reached 6, n is not an integral power

∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and ∗ ∼ ∗ ∗ so by Theorem 3, Zn = Zn1 × Zn2 ∗ ∼ ∃a ∈ Zn\B such that a = (1, −1) ∗ B is a proper subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029) ∗ Any a that has reached line 9 is in Zn Introduction ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 For any n such that the algorithm has reached 6, n is not an integral power

∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and ∗ ∼ ∗ ∗ so by Theorem 3, Zn = Zn1 × Zn2 ∗ ∼ ∃a ∈ Zn\B such that a = (1, −1) ∗ B is a proper subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029) ∗ Any a that has reached line 9 is in Zn Introduction ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) The Problem ∗ ∗ Core Idea B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 ∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and ∗ ∼ ∗ ∗ so by Theorem 3, Zn = Zn1 × Zn2 ∗ ∼ ∃a ∈ Zn\B such that a = (1, −1) ∗ B is a proper subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029) ∗ Any a that has reached line 9 is in Zn Introduction ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) The Problem ∗ ∗ Core Idea B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn behind the Algorithms For any n such that the algorithm has reached 6, n is not Preliminaries an integral power The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 ∗ ∼ ∃a ∈ Zn\B such that a = (1, −1) ∗ B is a proper subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029) ∗ Any a that has reached line 9 is in Zn Introduction ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) The Problem ∗ ∗ Core Idea B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn behind the Algorithms For any n such that the algorithm has reached 6, n is not Preliminaries an integral power The Miller-Rabin ∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and Primality ∗ ∼ ∗ ∗ Testing so by Theorem 3, Zn = Zn1 × Zn2 Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 ∗ B is a proper subgroup of Zn ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029) ∗ Any a that has reached line 9 is in Zn Introduction ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) The Problem ∗ ∗ Core Idea B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn behind the Algorithms For any n such that the algorithm has reached 6, n is not Preliminaries an integral power The Miller-Rabin ∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and Primality ∗ ∼ ∗ ∗ Testing so by Theorem 3, Zn = Zn1 × Zn2 Algorithm ∗ ∼ ∃a ∈ n\B such that a = (1, −1) The Agrawal- Z Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 ∗ |Zn | |B| ≤ 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029) ∗ Any a that has reached line 9 is in Zn Introduction ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) The Problem ∗ ∗ Core Idea B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn behind the Algorithms For any n such that the algorithm has reached 6, n is not Preliminaries an integral power The Miller-Rabin ∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and Primality ∗ ∼ ∗ ∗ Testing so by Theorem 3, Zn = Zn1 × Zn2 Algorithm ∗ ∼ ∃a ∈ n\B such that a = (1, −1) The Agrawal- Z Biswas ∗ Primality B is a proper subgroup of Zn Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Proof (contd...) Prerona Chatterjee (Roll No.: Case 2: n is a pseudoprime 142123029) ∗ Any a that has reached line 9 is in Zn Introduction ∗ n−1 ∀x ∈ Zn, x = 1 (mod n) The Problem ∗ ∗ Core Idea B = {y ∈ Zn : y = ±1 (mod n)} is a subgroup of Zn behind the Algorithms For any n such that the algorithm has reached 6, n is not Preliminaries an integral power The Miller-Rabin ∃n1, n2 ∈ N such that n = n1n2 where gcd(n1, n2) = 1 and Primality ∗ ∼ ∗ ∗ Testing so by Theorem 3, Zn = Zn1 × Zn2 Algorithm ∗ ∼ ∃a ∈ n\B such that a = (1, −1) The Agrawal- Z Biswas ∗ Primality B is a proper subgroup of Zn Testing ∗ |Zn | Algorithm |B| ≤ 2 The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 30 / 60 ∗ Any element in Zn that is a non-witness to the compositeness of n is a member of B ∗ |Zn |/2 1 The probability of error is ≤ ∗ = |Zn | 2 1 The output is COMPOSITE with probability > 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) Proof (contd...) Introduction For any ‘a’ such that PRIME is returned by The Problem MillerRabin(n), a is a member of B Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 31 / 60 ∗ |Zn |/2 1 The probability of error is ≤ ∗ = |Zn | 2 1 The output is COMPOSITE with probability > 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) Proof (contd...) Introduction For any ‘a’ such that PRIME is returned by The Problem MillerRabin(n), a is a member of B Core Idea behind the Any element in ∗ that is a non-witness to the Algorithms Zn

Preliminaries compositeness of n is a member of B

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 31 / 60 1 The output is COMPOSITE with probability > 2

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) Proof (contd...) Introduction For any ‘a’ such that PRIME is returned by The Problem MillerRabin(n), a is a member of B Core Idea behind the Any element in ∗ that is a non-witness to the Algorithms Zn

Preliminaries compositeness of n is a member of B ∗ |Zn |/2 1 The The probability of error is ≤ ∗ = Miller-Rabin |Zn | 2 Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 31 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) Proof (contd...) Introduction For any ‘a’ such that PRIME is returned by The Problem MillerRabin(n), a is a member of B Core Idea behind the Any element in ∗ that is a non-witness to the Algorithms Zn

Preliminaries compositeness of n is a member of B ∗ |Zn |/2 1 The The probability of error is ≤ ∗ = Miller-Rabin |Zn | 2 Primality 1 Testing The output is COMPOSITE with probability > 2 Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 31 / 60 Step 6 takes O(log n) time Step 9 takes O(log n) time since t (and hence u) can be found in atmost log n steps of dividing (n − 1) by 2 Mod-Exp(a, b, n) gives a polynomial time algorithm in log n for modular exponentiation as we have already seen in Section 21 and thus Step 10 takes time polynomial in log n. Since no step in the for loop takes more that polynomial time in log n, and since t = O(log n), Miller-Rabin(n) requires no more than time polynomial in log n.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Running Time Analysis Prerona Chatterjee 2 (Roll No.: If n is the input, isPower(n) takes O(log n) time and 142123029) thus, Step 2 takes O(log2 n) time

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 32 / 60 Step 9 takes O(log n) time since t (and hence u) can be found in atmost log n steps of dividing (n − 1) by 2 Mod-Exp(a, b, n) gives a polynomial time algorithm in log n for modular exponentiation as we have already seen in Section 21 and thus Step 10 takes time polynomial in log n. Since no step in the for loop takes more that polynomial time in log n, and since t = O(log n), Miller-Rabin(n) requires no more than time polynomial in log n.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Running Time Analysis Prerona Chatterjee 2 (Roll No.: If n is the input, isPower(n) takes O(log n) time and 142123029) thus, Step 2 takes O(log2 n) time Introduction Step 6 takes O(log n) time The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 32 / 60 Mod-Exp(a, b, n) gives a polynomial time algorithm in log n for modular exponentiation as we have already seen in Section 21 and thus Step 10 takes time polynomial in log n. Since no step in the for loop takes more that polynomial time in log n, and since t = O(log n), Miller-Rabin(n) requires no more than time polynomial in log n.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Running Time Analysis Prerona Chatterjee 2 (Roll No.: If n is the input, isPower(n) takes O(log n) time and 142123029) thus, Step 2 takes O(log2 n) time Introduction Step 6 takes O(log n) time The Problem Step 9 takes O(log n) time since t (and hence u) can be Core Idea behind the found in atmost log n steps of dividing (n − 1) by 2 Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 32 / 60 Since no step in the for loop takes more that polynomial time in log n, and since t = O(log n), Miller-Rabin(n) requires no more than time polynomial in log n.

The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Running Time Analysis Prerona Chatterjee 2 (Roll No.: If n is the input, isPower(n) takes O(log n) time and 142123029) thus, Step 2 takes O(log2 n) time Introduction Step 6 takes O(log n) time The Problem Step 9 takes O(log n) time since t (and hence u) can be Core Idea behind the found in atmost log n steps of dividing (n − 1) by 2 Algorithms

Preliminaries Mod-Exp(a, b, n) gives a polynomial time algorithm in

The log n for modular exponentiation as we have already seen Miller-Rabin Primality in Section 21 and thus Step 10 takes time polynomial in Testing Algorithm log n.

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 32 / 60 The Miller-Rabin Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Running Time Analysis Prerona Chatterjee 2 (Roll No.: If n is the input, isPower(n) takes O(log n) time and 142123029) thus, Step 2 takes O(log2 n) time Introduction Step 6 takes O(log n) time The Problem Step 9 takes O(log n) time since t (and hence u) can be Core Idea behind the found in atmost log n steps of dividing (n − 1) by 2 Algorithms

Preliminaries Mod-Exp(a, b, n) gives a polynomial time algorithm in

The log n for modular exponentiation as we have already seen Miller-Rabin Primality in Section 21 and thus Step 10 takes time polynomial in Testing Algorithm log n. The Agrawal- Since no step in the for loop takes more that polynomial Biswas Primality time in log n, and since t = O(log n), Miller-Rabin(n) Testing Algorithm requires no more than time polynomial in log n. The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 32 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona 1 Introduction Chatterjee (Roll No.: 142123029) 2 The Problem

Introduction The Problem 3 Core Idea behind the Algorithms Core Idea behind the Algorithms 4 Preliminaries Preliminaries

The Miller-Rabin 5 The Miller-Rabin Primality Testing Algorithm Primality Testing Algorithm 6 The Agrawal-Biswas Primality Testing Algorithm The Agrawal- Biswas Primality Testing 7 Algorithm The AKS Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 33 / 60 It uses the following generalisation of Fermat’s little theorem over polynomial ring. Theorem

n n ∗ Let Pn(x) = (a + x) − (a + x ) where a ∈ Zn and n ∈ N. Then, Pn(x) = 0 in Zn[x] iff n is prime. Unlike Fermat’s little theorem, the identity is always false when n is a composite number. The issue of pseudoprimes is completely sidestepped leading to the following simple algorithm: If (x + 1)n = (xn + 1) mod n then return PRIME else return COMPOSITE.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- The Key Concept GORITHMS It is a randomised primality testing algorithm which Prerona Chatterjee reduces primality testing for a number n to testing if a (Roll No.: 142123029) specific univariate identity over Zn holds.

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 34 / 60 Unlike Fermat’s little theorem, the identity is always false when n is a composite number. The issue of pseudoprimes is completely sidestepped leading to the following simple algorithm: If (x + 1)n = (xn + 1) mod n then return PRIME else return COMPOSITE.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- The Key Concept GORITHMS It is a randomised primality testing algorithm which Prerona Chatterjee reduces primality testing for a number n to testing if a (Roll No.: 142123029) specific univariate identity over Zn holds.

Introduction It uses the following generalisation of Fermat’s little

The Problem theorem over polynomial ring.

Core Idea behind the Theorem Algorithms n n ∗ Preliminaries Let Pn(x) = (a + x) − (a + x ) where a ∈ Zn and n ∈ N. The Then, Pn(x) = 0 in n[x] iff n is prime. Miller-Rabin Z Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 34 / 60 The issue of pseudoprimes is completely sidestepped leading to the following simple algorithm: If (x + 1)n = (xn + 1) mod n then return PRIME else return COMPOSITE.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- The Key Concept GORITHMS It is a randomised primality testing algorithm which Prerona Chatterjee reduces primality testing for a number n to testing if a (Roll No.: 142123029) specific univariate identity over Zn holds.

Introduction It uses the following generalisation of Fermat’s little

The Problem theorem over polynomial ring.

Core Idea behind the Theorem Algorithms n n ∗ Preliminaries Let Pn(x) = (a + x) − (a + x ) where a ∈ Zn and n ∈ N. The Then, Pn(x) = 0 in n[x] iff n is prime. Miller-Rabin Z Primality Testing Algorithm Unlike Fermat’s little theorem, the identity is always false

The Agrawal- when n is a composite number. Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 34 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- The Key Concept GORITHMS It is a randomised primality testing algorithm which Prerona Chatterjee reduces primality testing for a number n to testing if a (Roll No.: 142123029) specific univariate identity over Zn holds.

Introduction It uses the following generalisation of Fermat’s little

The Problem theorem over polynomial ring.

Core Idea behind the Theorem Algorithms n n ∗ Preliminaries Let Pn(x) = (a + x) − (a + x ) where a ∈ Zn and n ∈ N. The Then, Pn(x) = 0 in n[x] iff n is prime. Miller-Rabin Z Primality Testing Algorithm Unlike Fermat’s little theorem, the identity is always false

The Agrawal- when n is a composite number. Biswas Primality The issue of pseudoprimes is completely sidestepped Testing Algorithm leading to the following simple algorithm: If n n The AKS (x + 1) = (x + 1) mod n then return PRIME else Primality Testing return COMPOSITE. Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 34 / 60 We check the identity modulo a randomly chosen monic polynomial of degree log n at the cost of introducing one sided error. The analysis of the algoritm shows that even in this case, when n is COMPOSITE, the identity does not hold with probability greater than 2/3.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Key Concept (contd.)

Introduction The polynomials in both side expands into O(n) term and

The Problem we need O(n) time to compute them.

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 35 / 60 The analysis of the algoritm shows that even in this case, when n is COMPOSITE, the identity does not hold with probability greater than 2/3.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Key Concept (contd.)

Introduction The polynomials in both side expands into O(n) term and

The Problem we need O(n) time to compute them. Core Idea We check the identity modulo a randomly chosen monic behind the Algorithms polynomial of degree log n at the cost of introducing one Preliminaries sided error. The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 35 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Key Concept (contd.)

Introduction The polynomials in both side expands into O(n) term and

The Problem we need O(n) time to compute them. Core Idea We check the identity modulo a randomly chosen monic behind the Algorithms polynomial of degree log n at the cost of introducing one Preliminaries sided error. The Miller-Rabin The analysis of the algoritm shows that even in this case, Primality Testing when n is COMPOSITE, the identity does not hold with Algorithm probability greater than 2/3. The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 35 / 60 Check whether (x + 1)n − (xn + 1) is zero modulo the polynomial Q(x) Using Theorem 6 with a = 1, we see that if that does not happen, then n is definitely composite 2 Otherwise n is prime with a probability > 3 The process can be repeated a constant number of times by taking different Q(x)'s so as to decrease the probability of error arbitrarily.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Algorithm (Roll No.: 142123029) Choose Q(x) randomly to be monic polynomial of degree

Introduction dlog ne

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 36 / 60 Using Theorem 6 with a = 1, we see that if that does not happen, then n is definitely composite 2 Otherwise n is prime with a probability > 3 The process can be repeated a constant number of times by taking different Q(x)'s so as to decrease the probability of error arbitrarily.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Algorithm (Roll No.: 142123029) Choose Q(x) randomly to be monic polynomial of degree

Introduction dlog ne n n The Problem Check whether (x + 1) − (x + 1) is zero modulo the Core Idea polynomial Q(x) behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 36 / 60 2 Otherwise n is prime with a probability > 3 The process can be repeated a constant number of times by taking different Q(x)'s so as to decrease the probability of error arbitrarily.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Algorithm (Roll No.: 142123029) Choose Q(x) randomly to be monic polynomial of degree

Introduction dlog ne n n The Problem Check whether (x + 1) − (x + 1) is zero modulo the Core Idea polynomial Q(x) behind the Algorithms Using Theorem 6 with a = 1, we see that if that does not Preliminaries happen, then n is definitely composite The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 36 / 60 The process can be repeated a constant number of times by taking different Q(x)'s so as to decrease the probability of error arbitrarily.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Algorithm (Roll No.: 142123029) Choose Q(x) randomly to be monic polynomial of degree

Introduction dlog ne n n The Problem Check whether (x + 1) − (x + 1) is zero modulo the Core Idea polynomial Q(x) behind the Algorithms Using Theorem 6 with a = 1, we see that if that does not Preliminaries happen, then n is definitely composite The Miller-Rabin Otherwise n is prime with a probability > 2 Primality 3 Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 36 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee The Algorithm (Roll No.: 142123029) Choose Q(x) randomly to be monic polynomial of degree

Introduction dlog ne n n The Problem Check whether (x + 1) − (x + 1) is zero modulo the Core Idea polynomial Q(x) behind the Algorithms Using Theorem 6 with a = 1, we see that if that does not Preliminaries happen, then n is definitely composite The Miller-Rabin Otherwise n is prime with a probability > 2 Primality 3 Testing Algorithm The process can be repeated a constant number of times The Agrawal- by taking different Q(x)'s so as to decrease the probability Biswas Primality of error arbitrarily. Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 36 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Algorithm 5 Agrawal-Biswas Primality Test Prerona Chatterjee 1: procedure ABPrime(n) (Roll No.: 2: if n = 2, 3, 5, 7, 11, 13 then 142123029) 3: return PRIME 4: else Introduction 5: if n is divisible by any of the above numbers then The Problem 6: return COMPOSITE Core Idea 7: end if behind the 8: end if Algorithms 9: if isPower(n) then Preliminaries 10: return COMPOSITE 11: end if The n n Miller-Rabin 12: Pn(x) = (1 + x) − (1 − x ) Primality 13: Choose Q(x) to be a random dlog ne degree monic polynomial in Zn[x] Testing Algorithm 14: if Q(x) divides Pn(x) over Zn then 15: return PRIME The Agrawal- 16: else Biswas Primality 17: return COMPOSITE Testing 18: end if Algorithm 19: end procedure The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 37 / 60 However, if n is composite, the probability that a monic 2 polynomial p with deg(p) = l does not divide Pn(x) > 3 , 2 so that the error in the algorithm becomes ≤ 3 . To show this: Define a set I of monic irreducible polynomials having degree in a certain range with upper bound l.

For each polynomial f in I, define a set Cf of degree l polynomials having f as a factor.

Note that these Cf 's are mutually disjoint, and hence find a lower bound for the number of degree l polynomials with factors in I.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Correctness Prerona Chatterjee If n is prime, then it can be trivially shown that the output (Roll No.: 142123029) is always correct.

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 38 / 60 To show this: Define a set I of monic irreducible polynomials having degree in a certain range with upper bound l.

For each polynomial f in I, define a set Cf of degree l polynomials having f as a factor.

Note that these Cf 's are mutually disjoint, and hence find a lower bound for the number of degree l polynomials with factors in I.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Correctness Prerona Chatterjee If n is prime, then it can be trivially shown that the output (Roll No.: 142123029) is always correct. However, if n is composite, the probability that a monic Introduction polynomial p with deg(p) = l does not divide P (x) > 2 , The Problem n 3 2 Core Idea so that the error in the algorithm becomes ≤ 3 . behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 38 / 60 For each polynomial f in I, define a set Cf of degree l polynomials having f as a factor.

Note that these Cf 's are mutually disjoint, and hence find a lower bound for the number of degree l polynomials with factors in I.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Correctness Prerona Chatterjee If n is prime, then it can be trivially shown that the output (Roll No.: 142123029) is always correct. However, if n is composite, the probability that a monic Introduction polynomial p with deg(p) = l does not divide P (x) > 2 , The Problem n 3 2 Core Idea so that the error in the algorithm becomes ≤ 3 . behind the Algorithms To show this: Preliminaries Define a set I of monic irreducible polynomials having The Miller-Rabin degree in a certain range with upper bound l. Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 38 / 60 Note that these Cf 's are mutually disjoint, and hence find a lower bound for the number of degree l polynomials with factors in I.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Correctness Prerona Chatterjee If n is prime, then it can be trivially shown that the output (Roll No.: 142123029) is always correct. However, if n is composite, the probability that a monic Introduction polynomial p with deg(p) = l does not divide P (x) > 2 , The Problem n 3 2 Core Idea so that the error in the algorithm becomes ≤ 3 . behind the Algorithms To show this: Preliminaries Define a set I of monic irreducible polynomials having The Miller-Rabin degree in a certain range with upper bound l. Primality Testing For each polynomial f in I, define a set C of degree l Algorithm f

The Agrawal- polynomials having f as a factor. Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 38 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Correctness Prerona Chatterjee If n is prime, then it can be trivially shown that the output (Roll No.: 142123029) is always correct. However, if n is composite, the probability that a monic Introduction polynomial p with deg(p) = l does not divide P (x) > 2 , The Problem n 3 2 Core Idea so that the error in the algorithm becomes ≤ 3 . behind the Algorithms To show this: Preliminaries Define a set I of monic irreducible polynomials having The Miller-Rabin degree in a certain range with upper bound l. Primality Testing For each polynomial f in I, define a set C of degree l Algorithm f

The Agrawal- polynomials having f as a factor. Biswas Primality Note that these Cf 's are mutually disjoint, and hence find Testing Algorithm a lower bound for the number of degree l polynomials with The AKS factors in I. Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 38 / 60 Note that this also gives a lower bound on the number of monic polynomials of degree l that do not divide Pn(x) and hence we get the required result.

We formalise this as follows: Theorem If n is prime, ABPrime(n) outputs PRIME with probability 2 one, and if n is composite, its probability of error ≤ 3 .

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Correctness (contd.) Chatterjee (Roll No.: Get an upper bound on the number of monic polynomials 142123029) of degree l with factors in I that divide Pn(x), and hence Introduction get a lower bound on the number of monic polynomials of The Problem degree l with factors in I that do not divide Pn(x). Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 39 / 60 We formalise this as follows: Theorem If n is prime, ABPrime(n) outputs PRIME with probability 2 one, and if n is composite, its probability of error ≤ 3 .

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Correctness (contd.) Chatterjee (Roll No.: Get an upper bound on the number of monic polynomials 142123029) of degree l with factors in I that divide Pn(x), and hence Introduction get a lower bound on the number of monic polynomials of The Problem degree l with factors in I that do not divide Pn(x). Core Idea behind the Note that this also gives a lower bound on the number of Algorithms monic polynomials of degree l that do not divide Pn(x) Preliminaries and hence we get the required result. The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 39 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Correctness (contd.) Chatterjee (Roll No.: Get an upper bound on the number of monic polynomials 142123029) of degree l with factors in I that divide Pn(x), and hence Introduction get a lower bound on the number of monic polynomials of The Problem degree l with factors in I that do not divide Pn(x). Core Idea behind the Note that this also gives a lower bound on the number of Algorithms monic polynomials of degree l that do not divide Pn(x) Preliminaries and hence we get the required result. The Miller-Rabin Primality Testing We formalise this as follows: Algorithm Theorem The Agrawal- Biswas Primality If n is prime, ABPrime(n) outputs PRIME with probability Testing 2 Algorithm one, and if n is composite, its probability of error ≤ 3 . The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 39 / 60 If n is composite, Pn(x) 6= 0 in Zn[x] Let p be any prime factor of n The algorithm is correct when n is a prime power or when divisible by primes upto 13, and so we only have to analyse when n is odd, not a prime power and its every prime factor is atleast 17.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof 142123029) If n is prime, Pn(x) = 0 in Zn[x] Introduction ⇒ for any Q(x) chosen, Q(x) | Pn(x), and so the output The Problem of the algorithm is PRIME. Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 40 / 60 Let p be any prime factor of n The algorithm is correct when n is a prime power or when divisible by primes upto 13, and so we only have to analyse when n is odd, not a prime power and its every prime factor is atleast 17.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof 142123029) If n is prime, Pn(x) = 0 in Zn[x] Introduction ⇒ for any Q(x) chosen, Q(x) | Pn(x), and so the output The Problem of the algorithm is PRIME. Core Idea behind the If n is composite, P (x) 6= 0 in [x] Algorithms n Zn

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 40 / 60 The algorithm is correct when n is a prime power or when divisible by primes upto 13, and so we only have to analyse when n is odd, not a prime power and its every prime factor is atleast 17.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof 142123029) If n is prime, Pn(x) = 0 in Zn[x] Introduction ⇒ for any Q(x) chosen, Q(x) | Pn(x), and so the output The Problem of the algorithm is PRIME. Core Idea behind the If n is composite, P (x) 6= 0 in [x] Algorithms n Zn

Preliminaries Let p be any prime factor of n

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 40 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof 142123029) If n is prime, Pn(x) = 0 in Zn[x] Introduction ⇒ for any Q(x) chosen, Q(x) | Pn(x), and so the output The Problem of the algorithm is PRIME. Core Idea behind the If n is composite, P (x) 6= 0 in [x] Algorithms n Zn

Preliminaries Let p be any prime factor of n The The algorithm is correct when n is a prime power or when Miller-Rabin Primality divisible by primes upto 13, and so we only have to analyse Testing Algorithm when n is odd, not a prime power and its every prime The Agrawal- factor is atleast 17. Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 40 / 60 I is the set of all monic irreducible polynomials of degree l between 1 + 2 and l over Fp I (d) be the number of monic irreducible polynomials of degree d over Fp By the distribution theorem of irreducible polynomials[5], pk k pk k 2 2 k − p ≤ I (d) ≤ k + p For f ∈ I, Cf is the set of l degree polynomials that have f as a factor.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof (contd.) 142123029) l = dlog ne Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 41 / 60 I (d) be the number of monic irreducible polynomials of degree d over Fp By the distribution theorem of irreducible polynomials[5], pk k pk k 2 2 k − p ≤ I (d) ≤ k + p For f ∈ I, Cf is the set of l degree polynomials that have f as a factor.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof (contd.) 142123029) l = dlog ne Introduction I is the set of all monic irreducible polynomials of degree The Problem l between 1 + and l over Fp Core Idea 2 behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 41 / 60 By the distribution theorem of irreducible polynomials[5], pk k pk k 2 2 k − p ≤ I (d) ≤ k + p For f ∈ I, Cf is the set of l degree polynomials that have f as a factor.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof (contd.) 142123029) l = dlog ne Introduction I is the set of all monic irreducible polynomials of degree The Problem l between 1 + and l over Fp Core Idea 2 behind the I (d) be the number of monic irreducible polynomials of Algorithms

Preliminaries degree d over Fp

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 41 / 60 For f ∈ I, Cf is the set of l degree polynomials that have f as a factor.

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof (contd.) 142123029) l = dlog ne Introduction I is the set of all monic irreducible polynomials of degree The Problem l between 1 + and l over Fp Core Idea 2 behind the I (d) be the number of monic irreducible polynomials of Algorithms

Preliminaries degree d over Fp The By the distribution theorem of irreducible polynomials[5], Miller-Rabin Primality pk k pk k 2 2 Testing k − p ≤ I (d) ≤ k + p Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 41 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Proof (contd.) 142123029) l = dlog ne Introduction I is the set of all monic irreducible polynomials of degree The Problem l between 1 + and l over Fp Core Idea 2 behind the I (d) be the number of monic irreducible polynomials of Algorithms

Preliminaries degree d over Fp The By the distribution theorem of irreducible polynomials[5], Miller-Rabin Primality pk k pk k 2 2 Testing k − p ≤ I (d) ≤ k + p Algorithm For f ∈ I, C is the set of l degree polynomials that have The Agrawal- f Biswas f as a factor. Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 41 / 60 Cf1 ∩ Cf1 = ∅

l X X l−k |Cf | = I (k)p f ∈I l k=1+ 2 l k X p l−k k l−k ≥ p − p 2 p k l k=1+ 2 l ! X 1 1 = pl − k k l p 2 k=1+ 2 l X  1 1   1  = pl − ≥ ln 2 − pl k pk−2 48 l k=1+ 2

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS l−deg(f ) Prerona |Cf | = p Chatterjee (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 42 / 60 l X X l−k |Cf | = I (k)p f ∈I l k=1+ 2 l k X p l−k k l−k ≥ p − p 2 p k l k=1+ 2 l ! X 1 1 = pl − k k l p 2 k=1+ 2 l X  1 1   1  = pl − ≥ ln 2 − pl k pk−2 48 l k=1+ 2

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS l−deg(f ) Prerona |Cf | = p Chatterjee (Roll No.: Cf ∩ Cf = ∅ 142123029) 1 1

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 42 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS l−deg(f ) Prerona |Cf | = p Chatterjee (Roll No.: Cf ∩ Cf = ∅ 142123029) 1 1

Introduction l X X l−k The Problem |Cf | = I (k)p

Core Idea f ∈I l k=1+ 2 behind the Algorithms l k X p l−k k l−k Preliminaries ≥ p − p 2 p k The l Miller-Rabin k=1+ 2 Primality Testing l ! Algorithm X l 1 1 = p − k The Agrawal- k p 2 Biswas k=1+ l Primality 2 Testing l     Algorithm X 1 1 1 = pl − ≥ ln 2 − pl The AKS k pk−2 48 Primality l Testing k=1+ 2 Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 42 / 60 l−deg(f ) l −1 |Cf | = p ≤ p 2 The number of monic irreducible polynomials of degree l n 2n > 2 over Fp that divide Pn(x) is < l/2 = l The number of monic polynomials of degree l with factors l pl 2n  2 −1 in I that divide Pn(x) ≤ l p ≤ 8nl The total number of monic polynomials of degree l with 1 1  l factors in I that do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The total number of monic polynomials with degree l that 1 1  l do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The probability that a monic polynomial p with 1 1 2 deg(p) = l does not divide Pn(x) ≥ (ln 2 − 48 − 8nl ) > 3 2 The output is COMPOSITE with probability > 3

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona The total number of monic polynomials of degree l with Chatterjee factors in I ≥ ln 2 − 1  pl . (Roll No.: 48 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 43 / 60 The number of monic irreducible polynomials of degree l n 2n > 2 over Fp that divide Pn(x) is < l/2 = l The number of monic polynomials of degree l with factors l pl 2n  2 −1 in I that divide Pn(x) ≤ l p ≤ 8nl The total number of monic polynomials of degree l with 1 1  l factors in I that do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The total number of monic polynomials with degree l that 1 1  l do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The probability that a monic polynomial p with 1 1 2 deg(p) = l does not divide Pn(x) ≥ (ln 2 − 48 − 8nl ) > 3 2 The output is COMPOSITE with probability > 3

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona The total number of monic polynomials of degree l with Chatterjee factors in I ≥ ln 2 − 1  pl . (Roll No.: 48 142123029) l−deg(f ) l −1 |Cf | = p ≤ p 2 Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 43 / 60 The number of monic polynomials of degree l with factors l pl 2n  2 −1 in I that divide Pn(x) ≤ l p ≤ 8nl The total number of monic polynomials of degree l with 1 1  l factors in I that do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The total number of monic polynomials with degree l that 1 1  l do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The probability that a monic polynomial p with 1 1 2 deg(p) = l does not divide Pn(x) ≥ (ln 2 − 48 − 8nl ) > 3 2 The output is COMPOSITE with probability > 3

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona The total number of monic polynomials of degree l with Chatterjee factors in I ≥ ln 2 − 1  pl . (Roll No.: 48 142123029) l−deg(f ) l −1 |Cf | = p ≤ p 2 Introduction The number of monic irreducible polynomials of degree The Problem l n 2n > over p that divide Pn(x) is < = Core Idea 2 F l/2 l behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 43 / 60 The total number of monic polynomials of degree l with 1 1  l factors in I that do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The total number of monic polynomials with degree l that 1 1  l do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The probability that a monic polynomial p with 1 1 2 deg(p) = l does not divide Pn(x) ≥ (ln 2 − 48 − 8nl ) > 3 2 The output is COMPOSITE with probability > 3

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona The total number of monic polynomials of degree l with Chatterjee factors in I ≥ ln 2 − 1  pl . (Roll No.: 48 142123029) l−deg(f ) l −1 |Cf | = p ≤ p 2 Introduction The number of monic irreducible polynomials of degree The Problem l n 2n > over p that divide Pn(x) is < = Core Idea 2 F l/2 l behind the Algorithms The number of monic polynomials of degree l with factors l pl 2n  2 −1 Preliminaries in I that divide Pn(x) ≤ l p ≤ 8nl The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 43 / 60 The total number of monic polynomials with degree l that 1 1  l do not divide Pn(x) ≥ ln 2 − 48 − 8nl p The probability that a monic polynomial p with 1 1 2 deg(p) = l does not divide Pn(x) ≥ (ln 2 − 48 − 8nl ) > 3 2 The output is COMPOSITE with probability > 3

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona The total number of monic polynomials of degree l with Chatterjee factors in I ≥ ln 2 − 1  pl . (Roll No.: 48 142123029) l−deg(f ) l −1 |Cf | = p ≤ p 2 Introduction The number of monic irreducible polynomials of degree The Problem l n 2n > over p that divide Pn(x) is < = Core Idea 2 F l/2 l behind the Algorithms The number of monic polynomials of degree l with factors l pl 2n  2 −1 Preliminaries in I that divide Pn(x) ≤ l p ≤ 8nl The The total number of monic polynomials of degree l with Miller-Rabin Primality factors in I that do not divide P (x) ≥ ln 2 − 1 − 1  pl Testing n 48 8nl Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 43 / 60 The probability that a monic polynomial p with 1 1 2 deg(p) = l does not divide Pn(x) ≥ (ln 2 − 48 − 8nl ) > 3 2 The output is COMPOSITE with probability > 3

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona The total number of monic polynomials of degree l with Chatterjee factors in I ≥ ln 2 − 1  pl . (Roll No.: 48 142123029) l−deg(f ) l −1 |Cf | = p ≤ p 2 Introduction The number of monic irreducible polynomials of degree The Problem l n 2n > over p that divide Pn(x) is < = Core Idea 2 F l/2 l behind the Algorithms The number of monic polynomials of degree l with factors l pl 2n  2 −1 Preliminaries in I that divide Pn(x) ≤ l p ≤ 8nl The The total number of monic polynomials of degree l with Miller-Rabin Primality factors in I that do not divide P (x) ≥ ln 2 − 1 − 1  pl Testing n 48 8nl Algorithm The total number of monic polynomials with degree l that The Agrawal- 1 1  l Biswas do not divide Pn(x) ≥ ln 2 − 48 − 8nl p Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 43 / 60 2 The output is COMPOSITE with probability > 3

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona The total number of monic polynomials of degree l with Chatterjee factors in I ≥ ln 2 − 1  pl . (Roll No.: 48 142123029) l−deg(f ) l −1 |Cf | = p ≤ p 2 Introduction The number of monic irreducible polynomials of degree The Problem l n 2n > over p that divide Pn(x) is < = Core Idea 2 F l/2 l behind the Algorithms The number of monic polynomials of degree l with factors l pl 2n  2 −1 Preliminaries in I that divide Pn(x) ≤ l p ≤ 8nl The The total number of monic polynomials of degree l with Miller-Rabin Primality factors in I that do not divide P (x) ≥ ln 2 − 1 − 1  pl Testing n 48 8nl Algorithm The total number of monic polynomials with degree l that The Agrawal- 1 1  l Biswas do not divide Pn(x) ≥ ln 2 − 48 − 8nl p Primality Testing The probability that a monic polynomial p with Algorithm deg(p) = l does not divide P (x) ≥ (ln 2 − 1 − 1 ) > 2 The AKS n 48 8nl 3 Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 43 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona The total number of monic polynomials of degree l with Chatterjee factors in I ≥ ln 2 − 1  pl . (Roll No.: 48 142123029) l−deg(f ) l −1 |Cf | = p ≤ p 2 Introduction The number of monic irreducible polynomials of degree The Problem l n 2n > over p that divide Pn(x) is < = Core Idea 2 F l/2 l behind the Algorithms The number of monic polynomials of degree l with factors l pl 2n  2 −1 Preliminaries in I that divide Pn(x) ≤ l p ≤ 8nl The The total number of monic polynomials of degree l with Miller-Rabin Primality factors in I that do not divide P (x) ≥ ln 2 − 1 − 1  pl Testing n 48 8nl Algorithm The total number of monic polynomials with degree l that The Agrawal- 1 1  l Biswas do not divide Pn(x) ≥ ln 2 − 48 − 8nl p Primality Testing The probability that a monic polynomial p with Algorithm deg(p) = l does not divide P (x) ≥ (ln 2 − 1 − 1 ) > 2 The AKS n 48 8nl 3 Primality 2 Testing The output is COMPOSITE with probability > 3 Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 43 / 60 In Step 14, the algorithm does O(log n) multiplications of two degree O(log n) polynomials over Zn and computes same number of remainders modulo a third degree O(log n) polynomial and each of these requires O∼(log3 n) Since these are the only two non trivial steps in the algorithm, the time complexity of the algorithm is O∼(log4 n)

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Running Time Analysis 142123029) n is the input, isPower(n) takes O(log2 n) time and Introduction thus, Step 9 takes O(log2 n) time The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 44 / 60 Since these are the only two non trivial steps in the algorithm, the time complexity of the algorithm is O∼(log4 n)

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Running Time Analysis 142123029) n is the input, isPower(n) takes O(log2 n) time and Introduction thus, Step 9 takes O(log2 n) time The Problem

Core Idea In Step 14, the algorithm does O(log n) multiplications of behind the Algorithms two degree O(log n) polynomials over Zn and computes

Preliminaries same number of remainders modulo a third degree ∼ 3 The O(log n) polynomial and each of these requires O (log n) Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 44 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: Running Time Analysis 142123029) n is the input, isPower(n) takes O(log2 n) time and Introduction thus, Step 9 takes O(log2 n) time The Problem

Core Idea In Step 14, the algorithm does O(log n) multiplications of behind the Algorithms two degree O(log n) polynomials over Zn and computes

Preliminaries same number of remainders modulo a third degree ∼ 3 The O(log n) polynomial and each of these requires O (log n) Miller-Rabin Primality Since these are the only two non trivial steps in the Testing Algorithm algorithm, the time complexity of the algorithm is ∼ 4 The Agrawal- O (log n) Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 44 / 60 2 S is the set of all monic polynomials of degree dlog ne in Zn and if n is composite then there are at most |S|/3 many Q(x)’s in S such that P(x) = 0 mod Q(x). 3 A naive approach to derandomize this algorithm is to check whether P(x) = 0 mod Q(x) for more than |S|/3 many Q(x). But this will take O(|S|) time and |S| = O(nlog n). 4 The AKS algorithm implies that, we can compute a O(log5 n) integer r and a O(log6 n) integer l s.t. if n is composite then there exists an integer a between 1 and l s.t. P(x) 6= 0 mod (x + a)r − 1. 5 The AKS algorithm does not use exactly this test. It checks whether for all a between 1 and l, n n r (x − a) = (x − a) over Zn[x]/(x − 1).

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Moving towards the AKS Algorithm GORITHMS 1 The AKS algorithm is a derandomisation this algorithm. Prerona Chatterjee (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 45 / 60 3 A naive approach to derandomize this algorithm is to check whether P(x) = 0 mod Q(x) for more than |S|/3 many Q(x). But this will take O(|S|) time and |S| = O(nlog n). 4 The AKS algorithm implies that, we can compute a O(log5 n) integer r and a O(log6 n) integer l s.t. if n is composite then there exists an integer a between 1 and l s.t. P(x) 6= 0 mod (x + a)r − 1. 5 The AKS algorithm does not use exactly this test. It checks whether for all a between 1 and l, n n r (x − a) = (x − a) over Zn[x]/(x − 1).

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Moving towards the AKS Algorithm GORITHMS 1 The AKS algorithm is a derandomisation this algorithm. Prerona Chatterjee 2 (Roll No.: S is the set of all monic polynomials of degree dlog ne in 142123029) Zn and if n is composite then there are at most |S|/3 Introduction many Q(x)’s in S such that P(x) = 0 mod Q(x).

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 45 / 60 4 The AKS algorithm implies that, we can compute a O(log5 n) integer r and a O(log6 n) integer l s.t. if n is composite then there exists an integer a between 1 and l s.t. P(x) 6= 0 mod (x + a)r − 1. 5 The AKS algorithm does not use exactly this test. It checks whether for all a between 1 and l, n n r (x − a) = (x − a) over Zn[x]/(x − 1).

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Moving towards the AKS Algorithm GORITHMS 1 The AKS algorithm is a derandomisation this algorithm. Prerona Chatterjee 2 (Roll No.: S is the set of all monic polynomials of degree dlog ne in 142123029) Zn and if n is composite then there are at most |S|/3 Introduction many Q(x)’s in S such that P(x) = 0 mod Q(x). The Problem 3 A naive approach to derandomize this algorithm is to Core Idea behind the check whether P(x) = 0 mod Q(x) for more than |S|/3 Algorithms many Q(x). But this will take O(|S|) time and Preliminaries |S| = O(nlog n). The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 45 / 60 5 The AKS algorithm does not use exactly this test. It checks whether for all a between 1 and l, n n r (x − a) = (x − a) over Zn[x]/(x − 1).

The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Moving towards the AKS Algorithm GORITHMS 1 The AKS algorithm is a derandomisation this algorithm. Prerona Chatterjee 2 (Roll No.: S is the set of all monic polynomials of degree dlog ne in 142123029) Zn and if n is composite then there are at most |S|/3 Introduction many Q(x)’s in S such that P(x) = 0 mod Q(x). The Problem 3 A naive approach to derandomize this algorithm is to Core Idea behind the check whether P(x) = 0 mod Q(x) for more than |S|/3 Algorithms many Q(x). But this will take O(|S|) time and Preliminaries |S| = O(nlog n). The Miller-Rabin 4 The AKS algorithm implies that, we can compute a Primality 5 6 Testing O(log n) integer r and a O(log n) integer l s.t. if n is Algorithm composite then there exists an integer a between 1 and l The Agrawal- Biswas s.t. P(x) 6= 0 mod (x + a)r − 1. Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 45 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- Moving towards the AKS Algorithm GORITHMS 1 The AKS algorithm is a derandomisation this algorithm. Prerona Chatterjee 2 (Roll No.: S is the set of all monic polynomials of degree dlog ne in 142123029) Zn and if n is composite then there are at most |S|/3 Introduction many Q(x)’s in S such that P(x) = 0 mod Q(x). The Problem 3 A naive approach to derandomize this algorithm is to Core Idea behind the check whether P(x) = 0 mod Q(x) for more than |S|/3 Algorithms many Q(x). But this will take O(|S|) time and Preliminaries |S| = O(nlog n). The Miller-Rabin 4 The AKS algorithm implies that, we can compute a Primality 5 6 Testing O(log n) integer r and a O(log n) integer l s.t. if n is Algorithm composite then there exists an integer a between 1 and l The Agrawal- Biswas s.t. P(x) 6= 0 mod (x + a)r − 1. Primality Testing 5 Algorithm The AKS algorithm does not use exactly this test. It

The AKS checks whether for all a between 1 and l, Primality n n r Testing (x − a) = (x − a) over Zn[x]/(x − 1). Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 45 / 60 The Agrawal-Biswas Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: The following lemma shows that these two tests are equivalent. 142123029) Lemma Introduction The Problem Fix any r > 0 and any l > 0. Then, Core Idea behind the n n r Algorithms (x + 1) = (x + 1) (mod n, (x + a) − 1) for 1 ≤ a ≤ l (2)

Preliminaries

The if and only if Miller-Rabin Primality n n r Testing (x − a) = (x − a) (mod n, x − 1) for 1 ≤ a ≤ l (3) Algorithm

The Agrawal- Biswas This can be easily proved using induction on l. Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 46 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona 1 Introduction Chatterjee (Roll No.: 142123029) 2 The Problem

Introduction The Problem 3 Core Idea behind the Algorithms Core Idea behind the Algorithms 4 Preliminaries Preliminaries

The Miller-Rabin 5 The Miller-Rabin Primality Testing Algorithm Primality Testing Algorithm 6 The Agrawal-Biswas Primality Testing Algorithm The Agrawal- Biswas Primality Testing 7 Algorithm The AKS Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 47 / 60 The third step is equivalent to the condition that for all Q(x) ∈ S = {(x + a)r − 1 | a = 1,..., l},(x + 1)n − (xn + 1) is zero modulo Q(x).

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Algorithm Introduction 1 Determine whether the input is an integral power The Problem 2 Core Idea Determine whether the input has a small prime divisor behind the n n r Algorithms 3 Check whether (x + a) = (x + a) (mod n, x − 1).

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 48 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029) The Algorithm Introduction 1 Determine whether the input is an integral power The Problem 2 Core Idea Determine whether the input has a small prime divisor behind the n n r Algorithms 3 Check whether (x + a) = (x + a) (mod n, x − 1). Preliminaries The third step is equivalent to the condition that for all The r n n Miller-Rabin Q(x) ∈ S = {(x + a) − 1 | a = 1,..., l},(x + 1) − (x + 1) Primality Testing is zero modulo Q(x). Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 48 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Algorithm 6 AKS Primality Test Prerona Chatterjee 1: procedure AKS(n) (Roll No.: 2: if isPower(n) then 142123029) 3: return COMPOSITE 4: end if Introduction 2 5: Find the smallest r such that or (n) > 4 log n The Problem 6: Set l = or (n) − 1 //or (n) is the order of n modulo r Core Idea 7: if 1 < gcd(a, n) < n for any a ∈ {1, 2, ..., r} then behind the 8: return COMPOSITE Algorithms 9: end if Preliminaries 10: if n ≤ r then 11: return PRIME The Miller-Rabin 12: end if Primality 13: for a = 1 to l do Testing n n r Algorithm 14: if (x + a) 6= (x + a) (mod n, x − 1) then 15: return COMPOSITE The Agrawal- 16: end if Biswas Primality 17: end for Testing 18: return PRIME Algorithm 19: end procedure The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 49 / 60 For the converse, if AKS(n) returns PRIME in step 11, then it is easy to show that n is prime If AKS(n) returns PRIME in step 18, then we assume that n is composite and that it has a non-trivial prime factor p

F = Fp[x]/ < h(x) > where h(x) is the irreducible part of the r th cyclotomic polynomial Consider G =< {x + a : a ∈ {1, 2, ..., l}} >, which is a ∗ subgroup of F where l = or (n) − 1 Contradictory bounds are derived for | G |

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Prerona Correctness Chatterjee (Roll No.: If n is prime, then it can be trivially shown that the output 142123029) is always correct Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 50 / 60 If AKS(n) returns PRIME in step 18, then we assume that n is composite and that it has a non-trivial prime factor p

F = Fp[x]/ < h(x) > where h(x) is the irreducible part of the r th cyclotomic polynomial Consider G =< {x + a : a ∈ {1, 2, ..., l}} >, which is a ∗ subgroup of F where l = or (n) − 1 Contradictory bounds are derived for | G |

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Prerona Correctness Chatterjee (Roll No.: If n is prime, then it can be trivially shown that the output 142123029) is always correct Introduction For the converse, if AKS(n) returns PRIME in step 11, The Problem then it is easy to show that n is prime Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 50 / 60 F = Fp[x]/ < h(x) > where h(x) is the irreducible part of the r th cyclotomic polynomial Consider G =< {x + a : a ∈ {1, 2, ..., l}} >, which is a ∗ subgroup of F where l = or (n) − 1 Contradictory bounds are derived for | G |

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Prerona Correctness Chatterjee (Roll No.: If n is prime, then it can be trivially shown that the output 142123029) is always correct Introduction For the converse, if AKS(n) returns PRIME in step 11, The Problem then it is easy to show that n is prime Core Idea behind the Algorithms If AKS(n) returns PRIME in step 18, then we assume that

Preliminaries n is composite and that it has a non-trivial prime factor p

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 50 / 60 Consider G =< {x + a : a ∈ {1, 2, ..., l}} >, which is a ∗ subgroup of F where l = or (n) − 1 Contradictory bounds are derived for | G |

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Prerona Correctness Chatterjee (Roll No.: If n is prime, then it can be trivially shown that the output 142123029) is always correct Introduction For the converse, if AKS(n) returns PRIME in step 11, The Problem then it is easy to show that n is prime Core Idea behind the Algorithms If AKS(n) returns PRIME in step 18, then we assume that

Preliminaries n is composite and that it has a non-trivial prime factor p The F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Miller-Rabin th Primality the r cyclotomic polynomial Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 50 / 60 Contradictory bounds are derived for | G |

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Prerona Correctness Chatterjee (Roll No.: If n is prime, then it can be trivially shown that the output 142123029) is always correct Introduction For the converse, if AKS(n) returns PRIME in step 11, The Problem then it is easy to show that n is prime Core Idea behind the Algorithms If AKS(n) returns PRIME in step 18, then we assume that

Preliminaries n is composite and that it has a non-trivial prime factor p The F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Miller-Rabin th Primality the r cyclotomic polynomial Testing Algorithm Consider G =< {x + a : a ∈ {1, 2, ..., l}} >, which is a The Agrawal- ∗ Biswas subgroup of F where l = or (n) − 1 Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 50 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Prerona Correctness Chatterjee (Roll No.: If n is prime, then it can be trivially shown that the output 142123029) is always correct Introduction For the converse, if AKS(n) returns PRIME in step 11, The Problem then it is easy to show that n is prime Core Idea behind the Algorithms If AKS(n) returns PRIME in step 18, then we assume that

Preliminaries n is composite and that it has a non-trivial prime factor p The F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Miller-Rabin th Primality the r cyclotomic polynomial Testing Algorithm Consider G =< {x + a : a ∈ {1, 2, ..., l}} >, which is a The Agrawal- ∗ Biswas subgroup of F where l = or (n) − 1 Primality Testing Contradictory bounds are derived for | G | Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 50 / 60 gcd(a, b) is 1 if n - a and n if n | a, and so COMPOSITE cannot be returned by AKS(n) at step 8 (a + x)n = (a + xn) (mod n) ∀a and so (a + x)n = a + xn (mod n, xr − 1) ∀a ∈ {1, 2, ..., l}. Thus, COMPOSITE cannot be returned by AKS(n) at step 15 Hence, PRIME must be returned by AKS(n).

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Theorem Prerona Chatterjee (Roll No.: If n is prime, AKS(n) returns PRIME. 142123029)

Introduction Proof. The Problem Suppose n is prime. Core Idea k behind the n 6= p for any k > 1 and p prime and so, COMPOSITE Algorithms cannot be returned by AKS(n) at step 3 Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 51 / 60 (a + x)n = (a + xn) (mod n) ∀a and so (a + x)n = a + xn (mod n, xr − 1) ∀a ∈ {1, 2, ..., l}. Thus, COMPOSITE cannot be returned by AKS(n) at step 15 Hence, PRIME must be returned by AKS(n).

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Theorem Prerona Chatterjee (Roll No.: If n is prime, AKS(n) returns PRIME. 142123029)

Introduction Proof. The Problem Suppose n is prime. Core Idea k behind the n 6= p for any k > 1 and p prime and so, COMPOSITE Algorithms cannot be returned by AKS(n) at step 3 Preliminaries

The gcd(a, b) is 1 if n - a and n if n | a, and so COMPOSITE Miller-Rabin Primality cannot be returned by AKS(n) at step 8 Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 51 / 60 Hence, PRIME must be returned by AKS(n).

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Theorem Prerona Chatterjee (Roll No.: If n is prime, AKS(n) returns PRIME. 142123029)

Introduction Proof. The Problem Suppose n is prime. Core Idea k behind the n 6= p for any k > 1 and p prime and so, COMPOSITE Algorithms cannot be returned by AKS(n) at step 3 Preliminaries

The gcd(a, b) is 1 if n - a and n if n | a, and so COMPOSITE Miller-Rabin Primality cannot be returned by AKS(n) at step 8 Testing n n n n Algorithm (a + x) = (a + x ) (mod n) ∀a and so (a + x) = a + x r The Agrawal- (mod n, x − 1) ∀a ∈ {1, 2, ..., l}. Thus, COMPOSITE Biswas Primality cannot be returned by AKS(n) at step 15 Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 51 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS Theorem Prerona Chatterjee (Roll No.: If n is prime, AKS(n) returns PRIME. 142123029)

Introduction Proof. The Problem Suppose n is prime. Core Idea k behind the n 6= p for any k > 1 and p prime and so, COMPOSITE Algorithms cannot be returned by AKS(n) at step 3 Preliminaries

The gcd(a, b) is 1 if n - a and n if n | a, and so COMPOSITE Miller-Rabin Primality cannot be returned by AKS(n) at step 8 Testing n n n n Algorithm (a + x) = (a + x ) (mod n) ∀a and so (a + x) = a + x r The Agrawal- (mod n, x − 1) ∀a ∈ {1, 2, ..., l}. Thus, COMPOSITE Biswas Primality cannot be returned by AKS(n) at step 15 Testing Algorithm Hence, PRIME must be returned by AKS(n). The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 51 / 60 Proof. Suppose AKS(n) returns prime at step 11. n ≤ r If n were composite, ∃p < n ≤ r such that 1 < gcd(p, n) = p < n Then COMPOSITE would have been returned at step 8 This is not possible, as the program has reached step 11

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Theorem (Roll No.: 142123029) If AKS(n) returns PRIME in step 11, then n is prime.

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 52 / 60 n ≤ r If n were composite, ∃p < n ≤ r such that 1 < gcd(p, n) = p < n Then COMPOSITE would have been returned at step 8 This is not possible, as the program has reached step 11

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Theorem (Roll No.: 142123029) If AKS(n) returns PRIME in step 11, then n is prime.

Introduction

The Problem Proof. Core Idea Suppose AKS(n) returns prime at step 11. behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 52 / 60 If n were composite, ∃p < n ≤ r such that 1 < gcd(p, n) = p < n Then COMPOSITE would have been returned at step 8 This is not possible, as the program has reached step 11

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Theorem (Roll No.: 142123029) If AKS(n) returns PRIME in step 11, then n is prime.

Introduction

The Problem Proof. Core Idea Suppose AKS(n) returns prime at step 11. behind the Algorithms n ≤ r Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 52 / 60 Then COMPOSITE would have been returned at step 8 This is not possible, as the program has reached step 11

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Theorem (Roll No.: 142123029) If AKS(n) returns PRIME in step 11, then n is prime.

Introduction

The Problem Proof. Core Idea Suppose AKS(n) returns prime at step 11. behind the Algorithms n ≤ r Preliminaries If n were composite, ∃p < n ≤ r such that The Miller-Rabin 1 < gcd(p, n) = p < n Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 52 / 60 This is not possible, as the program has reached step 11

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Theorem (Roll No.: 142123029) If AKS(n) returns PRIME in step 11, then n is prime.

Introduction

The Problem Proof. Core Idea Suppose AKS(n) returns prime at step 11. behind the Algorithms n ≤ r Preliminaries If n were composite, ∃p < n ≤ r such that The Miller-Rabin 1 < gcd(p, n) = p < n Primality Testing Algorithm Then COMPOSITE would have been returned at step 8

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 52 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Theorem (Roll No.: 142123029) If AKS(n) returns PRIME in step 11, then n is prime.

Introduction

The Problem Proof. Core Idea Suppose AKS(n) returns prime at step 11. behind the Algorithms n ≤ r Preliminaries If n were composite, ∃p < n ≤ r such that The Miller-Rabin 1 < gcd(p, n) = p < n Primality Testing Algorithm Then COMPOSITE would have been returned at step 8 The Agrawal- This is not possible, as the program has reached step 11 Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 52 / 60 Proof Suppose AKS(n) returns PRIME in step 18. n > r and gcd(n, r) = 1 as otherwise COMPOSITE would have been returned at line 8 when a = r r R = Zn[x]/< x − 1 > l is as defined in the algorithm (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l} Let n be composite, and p be a prime divisor of n ∗ gcd(p, r) = 1 as gcd(n, r) = 1, and thus n, p ∈ Zr

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Theorem Chatterjee (Roll No.: If AKS(n) returns PRIME in step 18, then n is prime. 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 53 / 60 n > r and gcd(n, r) = 1 as otherwise COMPOSITE would have been returned at line 8 when a = r r R = Zn[x]/< x − 1 > l is as defined in the algorithm (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l} Let n be composite, and p be a prime divisor of n ∗ gcd(p, r) = 1 as gcd(n, r) = 1, and thus n, p ∈ Zr

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Theorem Chatterjee (Roll No.: If AKS(n) returns PRIME in step 18, then n is prime. 142123029)

Introduction Proof The Problem Suppose AKS(n) returns PRIME in step 18. Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 53 / 60 r R = Zn[x]/< x − 1 > l is as defined in the algorithm (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l} Let n be composite, and p be a prime divisor of n ∗ gcd(p, r) = 1 as gcd(n, r) = 1, and thus n, p ∈ Zr

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Theorem Chatterjee (Roll No.: If AKS(n) returns PRIME in step 18, then n is prime. 142123029)

Introduction Proof The Problem Suppose AKS(n) returns PRIME in step 18. Core Idea behind the n > r and gcd(n, r) = 1 as otherwise COMPOSITE would Algorithms

Preliminaries have been returned at line 8 when a = r

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 53 / 60 l is as defined in the algorithm (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l} Let n be composite, and p be a prime divisor of n ∗ gcd(p, r) = 1 as gcd(n, r) = 1, and thus n, p ∈ Zr

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Theorem Chatterjee (Roll No.: If AKS(n) returns PRIME in step 18, then n is prime. 142123029)

Introduction Proof The Problem Suppose AKS(n) returns PRIME in step 18. Core Idea behind the n > r and gcd(n, r) = 1 as otherwise COMPOSITE would Algorithms

Preliminaries have been returned at line 8 when a = r r The R = Zn[x]/< x − 1 > Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 53 / 60 (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l} Let n be composite, and p be a prime divisor of n ∗ gcd(p, r) = 1 as gcd(n, r) = 1, and thus n, p ∈ Zr

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Theorem Chatterjee (Roll No.: If AKS(n) returns PRIME in step 18, then n is prime. 142123029)

Introduction Proof The Problem Suppose AKS(n) returns PRIME in step 18. Core Idea behind the n > r and gcd(n, r) = 1 as otherwise COMPOSITE would Algorithms

Preliminaries have been returned at line 8 when a = r r The R = Zn[x]/< x − 1 > Miller-Rabin Primality Testing l is as defined in the algorithm Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 53 / 60 Let n be composite, and p be a prime divisor of n ∗ gcd(p, r) = 1 as gcd(n, r) = 1, and thus n, p ∈ Zr

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Theorem Chatterjee (Roll No.: If AKS(n) returns PRIME in step 18, then n is prime. 142123029)

Introduction Proof The Problem Suppose AKS(n) returns PRIME in step 18. Core Idea behind the n > r and gcd(n, r) = 1 as otherwise COMPOSITE would Algorithms

Preliminaries have been returned at line 8 when a = r r The R = Zn[x]/< x − 1 > Miller-Rabin Primality Testing l is as defined in the algorithm Algorithm (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l} The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 53 / 60 ∗ gcd(p, r) = 1 as gcd(n, r) = 1, and thus n, p ∈ Zr

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Theorem Chatterjee (Roll No.: If AKS(n) returns PRIME in step 18, then n is prime. 142123029)

Introduction Proof The Problem Suppose AKS(n) returns PRIME in step 18. Core Idea behind the n > r and gcd(n, r) = 1 as otherwise COMPOSITE would Algorithms

Preliminaries have been returned at line 8 when a = r r The R = Zn[x]/< x − 1 > Miller-Rabin Primality Testing l is as defined in the algorithm Algorithm (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l} The Agrawal- Biswas Let n be composite, and p be a prime divisor of n Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 53 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Theorem Chatterjee (Roll No.: If AKS(n) returns PRIME in step 18, then n is prime. 142123029)

Introduction Proof The Problem Suppose AKS(n) returns PRIME in step 18. Core Idea behind the n > r and gcd(n, r) = 1 as otherwise COMPOSITE would Algorithms

Preliminaries have been returned at line 8 when a = r r The R = Zn[x]/< x − 1 > Miller-Rabin Primality Testing l is as defined in the algorithm Algorithm (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l} The Agrawal- Biswas Let n be composite, and p be a prime divisor of n Primality Testing ∗ Algorithm gcd(p, r) = 1 as gcd(n, r) = 1, and thus n, p ∈ Zr The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 53 / 60 (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so (a + x)n = a + xn in F , ∀a ∈ {1, 2, ...., l} ∗ G =< n, p > is a subgroup of Zr , and t = | G | ∗ G ≤ Zr ⇒ t < r < n > ≤ < n, p >⇒ or (n) < t G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ m is said to be introspective for f (x) ∈ F if f (xm) = f (x)m m is introspective for f ∀m ∈ G and ∀f ∈ G

m1, m2 are introspective for f ⇒ m1m2 is introspective for f m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 ∗ G =< n, p > is a subgroup of Zr , and t = | G | ∗ G ≤ Zr ⇒ t < r < n > ≤ < n, p >⇒ or (n) < t G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ m is said to be introspective for f (x) ∈ F if f (xm) = f (x)m m is introspective for f ∀m ∈ G and ∀f ∈ G

m1, m2 are introspective for f ⇒ m1m2 is introspective for f m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 ∗ G ≤ Zr ⇒ t < r < n > ≤ < n, p >⇒ or (n) < t G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ m is said to be introspective for f (x) ∈ F if f (xm) = f (x)m m is introspective for f ∀m ∈ G and ∀f ∈ G

m1, m2 are introspective for f ⇒ m1m2 is introspective for f m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem ∗ G =< n, p > is a subgroup of Zr , and t = | G | Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 < n > ≤ < n, p >⇒ or (n) < t G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ m is said to be introspective for f (x) ∈ F if f (xm) = f (x)m m is introspective for f ∀m ∈ G and ∀f ∈ G

m1, m2 are introspective for f ⇒ m1m2 is introspective for f m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem ∗ G =< n, p > is a subgroup of Zr , and t = | G | Core Idea ∗ behind the G ≤ r ⇒ t < r Algorithms Z

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ m is said to be introspective for f (x) ∈ F if f (xm) = f (x)m m is introspective for f ∀m ∈ G and ∀f ∈ G

m1, m2 are introspective for f ⇒ m1m2 is introspective for f m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem ∗ G =< n, p > is a subgroup of Zr , and t = | G | Core Idea ∗ behind the G ≤ r ⇒ t < r Algorithms Z

Preliminaries < n > ≤ < n, p >⇒ or (n) < t

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 m is said to be introspective for f (x) ∈ F if f (xm) = f (x)m m is introspective for f ∀m ∈ G and ∀f ∈ G

m1, m2 are introspective for f ⇒ m1m2 is introspective for f m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem ∗ G =< n, p > is a subgroup of Zr , and t = | G | Core Idea ∗ behind the G ≤ r ⇒ t < r Algorithms Z

Preliminaries < n > ≤ < n, p >⇒ or (n) < t The G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 m is introspective for f ∀m ∈ G and ∀f ∈ G

m1, m2 are introspective for f ⇒ m1m2 is introspective for f m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem ∗ G =< n, p > is a subgroup of Zr , and t = | G | Core Idea ∗ behind the G ≤ r ⇒ t < r Algorithms Z

Preliminaries < n > ≤ < n, p >⇒ or (n) < t The G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ Miller-Rabin Primality Testing m is said to be introspective for f (x) ∈ F if Algorithm f (xm) = f (x)m The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 m1, m2 are introspective for f ⇒ m1m2 is introspective for f m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem ∗ G =< n, p > is a subgroup of Zr , and t = | G | Core Idea ∗ behind the G ≤ r ⇒ t < r Algorithms Z

Preliminaries < n > ≤ < n, p >⇒ or (n) < t The G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ Miller-Rabin Primality Testing m is said to be introspective for f (x) ∈ F if Algorithm f (xm) = f (x)m The Agrawal- Biswas m is introspective for f ∀m ∈ G and ∀f ∈ G Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 m is introspective for f , g ⇒ m is introspective for fg

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem ∗ G =< n, p > is a subgroup of Zr , and t = | G | Core Idea ∗ behind the G ≤ r ⇒ t < r Algorithms Z

Preliminaries < n > ≤ < n, p >⇒ or (n) < t The G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ Miller-Rabin Primality Testing m is said to be introspective for f (x) ∈ F if Algorithm f (xm) = f (x)m The Agrawal- Biswas m is introspective for f ∀m ∈ G and ∀f ∈ G Primality Testing Algorithm m1, m2 are introspective for f ⇒ m1m2 is introspective for

The AKS f Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS

Prerona F = Fp[x]/ < h(x) > where h(x) is the irreducible part of Chatterjee the r th cyclotomic polynomial (Roll No.: 142123029) (a + x)n = a + xn in R, ∀a ∈ {1, 2, ...., l}, and so n n Introduction (a + x) = a + x in F , ∀a ∈ {1, 2, ...., l} The Problem ∗ G =< n, p > is a subgroup of Zr , and t = | G | Core Idea ∗ behind the G ≤ r ⇒ t < r Algorithms Z

Preliminaries < n > ≤ < n, p >⇒ or (n) < t The G =< {x + a : a ∈ {1, 2, ..., l}} > is a subgroup of F ∗ Miller-Rabin Primality Testing m is said to be introspective for f (x) ∈ F if Algorithm f (xm) = f (x)m The Agrawal- Biswas m is introspective for f ∀m ∈ G and ∀f ∈ G Primality Testing Algorithm m1, m2 are introspective for f ⇒ m1m2 is introspective for

The AKS f Primality Testing m is introspective for f , g ⇒ m is introspective for fg Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 54 / 60 For each K ⊆ {1, 2, ..., l}, consider Q fK (x) = a∈K (x − a) ∈ Z[x] Each fK is distinct since they have distinct roots There are 2l > 2t−1 of such polynomials since there are 2l subsets of 1, 2, ..., l th In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) ∀m ∈ G m ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a polynomial of degree < t − 1 and | G |= t

This is not possible unless fk1 = fk2 which is a contradiction

fK1 6= fK2 in F for K1 6= K2 and hence in G | G | > 2t−1

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 Each fK is distinct since they have distinct roots There are 2l > 2t−1 of such polynomials since there are 2l subsets of 1, 2, ..., l th In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) ∀m ∈ G m ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a polynomial of degree < t − 1 and | G |= t

This is not possible unless fk1 = fk2 which is a contradiction

fK1 6= fK2 in F for K1 6= K2 and hence in G | G | > 2t−1

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: For each K ⊆ {1, 2, ..., l}, consider 142123029) Q fK (x) = a∈K (x − a) ∈ Z[x] Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 There are 2l > 2t−1 of such polynomials since there are 2l subsets of 1, 2, ..., l th In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) ∀m ∈ G m ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a polynomial of degree < t − 1 and | G |= t

This is not possible unless fk1 = fk2 which is a contradiction

fK1 6= fK2 in F for K1 6= K2 and hence in G | G | > 2t−1

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: For each K ⊆ {1, 2, ..., l}, consider 142123029) Q fK (x) = a∈K (x − a) ∈ Z[x] Introduction Each fK is distinct since they have distinct roots The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 th In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) ∀m ∈ G m ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a polynomial of degree < t − 1 and | G |= t

This is not possible unless fk1 = fk2 which is a contradiction

fK1 6= fK2 in F for K1 6= K2 and hence in G | G | > 2t−1

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: For each K ⊆ {1, 2, ..., l}, consider 142123029) Q fK (x) = a∈K (x − a) ∈ Z[x] Introduction Each fK is distinct since they have distinct roots The Problem There are 2l > 2t−1 of such polynomials since there are 2l Core Idea behind the subsets of 1, 2, ..., l Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 m ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a polynomial of degree < t − 1 and | G |= t

This is not possible unless fk1 = fk2 which is a contradiction

fK1 6= fK2 in F for K1 6= K2 and hence in G | G | > 2t−1

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: For each K ⊆ {1, 2, ..., l}, consider 142123029) Q fK (x) = a∈K (x − a) ∈ Z[x] Introduction Each fK is distinct since they have distinct roots The Problem There are 2l > 2t−1 of such polynomials since there are 2l Core Idea behind the subsets of 1, 2, ..., l Algorithms th Preliminaries In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m The in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) Miller-Rabin Primality ∀m ∈ G Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 This is not possible unless fk1 = fk2 which is a contradiction

fK1 6= fK2 in F for K1 6= K2 and hence in G | G | > 2t−1

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: For each K ⊆ {1, 2, ..., l}, consider 142123029) Q fK (x) = a∈K (x − a) ∈ Z[x] Introduction Each fK is distinct since they have distinct roots The Problem There are 2l > 2t−1 of such polynomials since there are 2l Core Idea behind the subsets of 1, 2, ..., l Algorithms th Preliminaries In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m The in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) Miller-Rabin Primality ∀m ∈ G Testing m Algorithm ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a The Agrawal- polynomial of degree < t − 1 and | G |= t Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 fK1 6= fK2 in F for K1 6= K2 and hence in G | G | > 2t−1

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: For each K ⊆ {1, 2, ..., l}, consider 142123029) Q fK (x) = a∈K (x − a) ∈ Z[x] Introduction Each fK is distinct since they have distinct roots The Problem There are 2l > 2t−1 of such polynomials since there are 2l Core Idea behind the subsets of 1, 2, ..., l Algorithms th Preliminaries In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m The in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) Miller-Rabin Primality ∀m ∈ G Testing m Algorithm ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a The Agrawal- polynomial of degree < t − 1 and | G |= t Biswas Primality Testing This is not possible unless fk1 = fk2 which is a Algorithm contradiction The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 | G | > 2t−1

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: For each K ⊆ {1, 2, ..., l}, consider 142123029) Q fK (x) = a∈K (x − a) ∈ Z[x] Introduction Each fK is distinct since they have distinct roots The Problem There are 2l > 2t−1 of such polynomials since there are 2l Core Idea behind the subsets of 1, 2, ..., l Algorithms th Preliminaries In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m The in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) Miller-Rabin Primality ∀m ∈ G Testing m Algorithm ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a The Agrawal- polynomial of degree < t − 1 and | G |= t Biswas Primality Testing This is not possible unless fk1 = fk2 which is a Algorithm contradiction The AKS Primality fK1 6= fK2 in F for K1 6= K2 and hence in G Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS Claim: | G | > 2t−1 Prerona Chatterjee (Roll No.: For each K ⊆ {1, 2, ..., l}, consider 142123029) Q fK (x) = a∈K (x − a) ∈ Z[x] Introduction Each fK is distinct since they have distinct roots The Problem There are 2l > 2t−1 of such polynomials since there are 2l Core Idea behind the subsets of 1, 2, ..., l Algorithms th Preliminaries In F , x is the r root of unity, ζr , and so, fK1 (x) = fK2 (x) m m The in F for K1 6= K2 would mean fK1 (ζr ) = fK2 (ζr ) Miller-Rabin Primality ∀m ∈ G Testing m Algorithm ζr is a root for g = fK1 − fK2 ∀m ∈ G where g is a The Agrawal- polynomial of degree < t − 1 and | G |= t Biswas Primality Testing This is not possible unless fk1 = fk2 which is a Algorithm contradiction The AKS Primality fK1 6= fK2 in F for K1 6= K2 and hence in G Testing Algorithm | G | > 2t−1 Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 55 / 60 √ S = {ni pj , 0 ≤ i, j ≤ t} i j If n is not a prime√ power, then each n p is distinct, and hence | S | = ( t + 1)2 > t Considering the elements of S modulo r, they become elements of G

Since | G | = t, ∃m1, m2 with m1 6= m2 such that m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z ∀f ∈ G, f (x)m1 = f (xm1 ) = f (xm2+rk ) = f (xm2 xrk ) = f (xm2 ) = f (x)m2 as xr = 1 f (x) is a root of g = xm1 − xm2 ∀f ∈ G √ √ √ √ √ t 2 t t 2 t deg(g) = max{m1, m2} = n p < n n = n √ √ The number of roots of g = n2 t and so | G | ≤ n2 t

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona 2 t Chatterjee Claim: | G | ≤ n (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 i j If n is not a prime√ power, then each n p is distinct, and hence | S | = ( t + 1)2 > t Considering the elements of S modulo r, they become elements of G

Since | G | = t, ∃m1, m2 with m1 6= m2 such that m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z ∀f ∈ G, f (x)m1 = f (xm1 ) = f (xm2+rk ) = f (xm2 xrk ) = f (xm2 ) = f (x)m2 as xr = 1 f (x) is a root of g = xm1 − xm2 ∀f ∈ G √ √ √ √ √ t 2 t t 2 t deg(g) = max{m1, m2} = n p < n n = n √ √ The number of roots of g = n2 t and so | G | ≤ n2 t

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona Claim: | G | ≤ n2 t Chatterjee √ (Roll No.: i j 142123029) S = {n p , 0 ≤ i, j ≤ t}

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 Considering the elements of S modulo r, they become elements of G

Since | G | = t, ∃m1, m2 with m1 6= m2 such that m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z ∀f ∈ G, f (x)m1 = f (xm1 ) = f (xm2+rk ) = f (xm2 xrk ) = f (xm2 ) = f (x)m2 as xr = 1 f (x) is a root of g = xm1 − xm2 ∀f ∈ G √ √ √ √ √ t 2 t t 2 t deg(g) = max{m1, m2} = n p < n n = n √ √ The number of roots of g = n2 t and so | G | ≤ n2 t

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona Claim: | G | ≤ n2 t Chatterjee √ (Roll No.: i j 142123029) S = {n p , 0 ≤ i, j ≤ t} If n is not a prime power, then each ni pj is distinct, and Introduction √ 2 The Problem hence | S | = ( t + 1) > t

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 Since | G | = t, ∃m1, m2 with m1 6= m2 such that m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z ∀f ∈ G, f (x)m1 = f (xm1 ) = f (xm2+rk ) = f (xm2 xrk ) = f (xm2 ) = f (x)m2 as xr = 1 f (x) is a root of g = xm1 − xm2 ∀f ∈ G √ √ √ √ √ t 2 t t 2 t deg(g) = max{m1, m2} = n p < n n = n √ √ The number of roots of g = n2 t and so | G | ≤ n2 t

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona Claim: | G | ≤ n2 t Chatterjee √ (Roll No.: i j 142123029) S = {n p , 0 ≤ i, j ≤ t} If n is not a prime power, then each ni pj is distinct, and Introduction √ 2 The Problem hence | S | = ( t + 1) > t Core Idea Considering the elements of S modulo r, they become behind the Algorithms elements of G Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 ∀f ∈ G, f (x)m1 = f (xm1 ) = f (xm2+rk ) = f (xm2 xrk ) = f (xm2 ) = f (x)m2 as xr = 1 f (x) is a root of g = xm1 − xm2 ∀f ∈ G √ √ √ √ √ t 2 t t 2 t deg(g) = max{m1, m2} = n p < n n = n √ √ The number of roots of g = n2 t and so | G | ≤ n2 t

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona Claim: | G | ≤ n2 t Chatterjee √ (Roll No.: i j 142123029) S = {n p , 0 ≤ i, j ≤ t} If n is not a prime power, then each ni pj is distinct, and Introduction √ 2 The Problem hence | S | = ( t + 1) > t Core Idea Considering the elements of S modulo r, they become behind the Algorithms elements of G Preliminaries Since | G | = t, ∃m1, m2 with m1 6= m2 such that The Miller-Rabin m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 f (x) is a root of g = xm1 − xm2 ∀f ∈ G √ √ √ √ √ t 2 t t 2 t deg(g) = max{m1, m2} = n p < n n = n √ √ The number of roots of g = n2 t and so | G | ≤ n2 t

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona Claim: | G | ≤ n2 t Chatterjee √ (Roll No.: i j 142123029) S = {n p , 0 ≤ i, j ≤ t} If n is not a prime power, then each ni pj is distinct, and Introduction √ 2 The Problem hence | S | = ( t + 1) > t Core Idea Considering the elements of S modulo r, they become behind the Algorithms elements of G Preliminaries Since | G | = t, ∃m1, m2 with m1 6= m2 such that The Miller-Rabin m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z Primality m m m +rk m rk Testing ∀f ∈ G, f (x) 1 = f (x 1 ) = f (x 2 ) = f (x 2 x ) = Algorithm f (xm2 ) = f (x)m2 as xr = 1 The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 √ √ √ √ √ t 2 t t 2 t deg(g) = max{m1, m2} = n p < n n = n √ √ The number of roots of g = n2 t and so | G | ≤ n2 t

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona Claim: | G | ≤ n2 t Chatterjee √ (Roll No.: i j 142123029) S = {n p , 0 ≤ i, j ≤ t} If n is not a prime power, then each ni pj is distinct, and Introduction √ 2 The Problem hence | S | = ( t + 1) > t Core Idea Considering the elements of S modulo r, they become behind the Algorithms elements of G Preliminaries Since | G | = t, ∃m1, m2 with m1 6= m2 such that The Miller-Rabin m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z Primality m m m +rk m rk Testing ∀f ∈ G, f (x) 1 = f (x 1 ) = f (x 2 ) = f (x 2 x ) = Algorithm f (xm2 ) = f (x)m2 as xr = 1 The Agrawal- Biswas m1 m2 Primality f (x) is a root of g = x − x ∀f ∈ G Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 √ √ The number of roots of g = n2 t and so | G | ≤ n2 t

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona Claim: | G | ≤ n2 t Chatterjee √ (Roll No.: i j 142123029) S = {n p , 0 ≤ i, j ≤ t} If n is not a prime power, then each ni pj is distinct, and Introduction √ 2 The Problem hence | S | = ( t + 1) > t Core Idea Considering the elements of S modulo r, they become behind the Algorithms elements of G Preliminaries Since | G | = t, ∃m1, m2 with m1 6= m2 such that The Miller-Rabin m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z Primality m m m +rk m rk Testing ∀f ∈ G, f (x) 1 = f (x 1 ) = f (x 2 ) = f (x 2 x ) = Algorithm f (xm2 ) = f (x)m2 as xr = 1 The Agrawal- Biswas m1 m2 Primality f (x) is a root of g = x − x ∀f ∈ G Testing √ √ √ √ √ t 2 t t 2 t Algorithm deg(g) = max{m1, m2} = n p < n n = n The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Proof (contd.) GORITHMS √ Prerona Claim: | G | ≤ n2 t Chatterjee √ (Roll No.: i j 142123029) S = {n p , 0 ≤ i, j ≤ t} If n is not a prime power, then each ni pj is distinct, and Introduction √ 2 The Problem hence | S | = ( t + 1) > t Core Idea Considering the elements of S modulo r, they become behind the Algorithms elements of G Preliminaries Since | G | = t, ∃m1, m2 with m1 6= m2 such that The Miller-Rabin m1 = m2 (mod r) and so m1 = m2 + rk for some k ∈ Z Primality m m m +rk m rk Testing ∀f ∈ G, f (x) 1 = f (x 1 ) = f (x 2 ) = f (x 2 x ) = Algorithm f (xm2 ) = f (x)m2 as xr = 1 The Agrawal- Biswas m1 m2 Primality f (x) is a root of g = x − x ∀f ∈ G Testing √ √ √ √ √ t 2 t t 2 t Algorithm deg(g) = max{m1, m2} = n p < n n = n √ √ The AKS 2 t 2 t Primality The number of roots of g = n and so | G | ≤ n Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 56 / 60 As t > 4 log2 n, the bounds for | G | are contradictory We thus have the required contradiction if we assume n to be composite.

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029)

Introduction Proof (contd.)

The Problem √ 2t−1 ≤ | G | ≤ n2 t Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 57 / 60 We thus have the required contradiction if we assume n to be composite.

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029)

Introduction Proof (contd.)

The Problem √ 2t−1 ≤ | G | ≤ n2 t Core Idea behind the 2 Algorithms As t > 4 log n, the bounds for | G | are contradictory

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 57 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029)

Introduction Proof (contd.)

The Problem √ 2t−1 ≤ | G | ≤ n2 t Core Idea behind the 2 Algorithms As t > 4 log n, the bounds for | G | are contradictory Preliminaries We thus have the required contradiction if we assume n to be The Miller-Rabin composite. Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 57 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029)

Introduction Proof (contd.)

The Problem √ 2t−1 ≤ | G | ≤ n2 t Core Idea behind the 2 Algorithms As t > 4 log n, the bounds for | G | are contradictory Preliminaries We thus have the required contradiction if we assume n to be The Miller-Rabin composite. Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 57 / 60 Using this, we can show the following result. Lemma

5 2 There exists an r ≤ 16 lg n, such that or (n) > 4 lg n.

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Running Time Analysis (Roll No.: 142123029) Before we start the running time analysis, we need the following lemma: Introduction The Problem Lemma Core Idea behind the Algorithms Let LCM(m) denote the lcm of the first m numbers. For m m−1 Preliminaries odd, LCM(m) ≥ 2 .

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 58 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee Running Time Analysis (Roll No.: 142123029) Before we start the running time analysis, we need the following lemma: Introduction The Problem Lemma Core Idea behind the Algorithms Let LCM(m) denote the lcm of the first m numbers. For m m−1 Preliminaries odd, LCM(m) ≥ 2 .

The Miller-Rabin Using this, we can show the following result. Primality Testing Algorithm Lemma The Agrawal- Biswas 5 2 Primality There exists an r ≤ 16 lg n, such that or (n) > 4 lg n. Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 58 / 60 2 To find an r such that or (n) > 4 log n, successive values of r are tried and tested whether nk 6= 1 (mod r) for every k ≤ 4 log2 n For a particular r, this will involve at most O(log2 n) multipications modulo r and so will take time O∼(log2 n log r) Only O(log5 n) different r’s need to be checked, and so the total complexity of this step is polynomial in log n Each gcd computation takes time O(log2 n) and since r is of O(log5 n), Step 8 will also be taking only time O(log7 n)

We have to verify l equations where l = or (n) − 1 < or (n) which divides φ(r) and hence, l < φ(r) < r is O(log5 n) Each equation takes O(log n) multipications of r degree polynomials with coefficients of size O(log n) and so, each equation can be verified in time O∼(r log2 n) steps Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 59 / 60 For a particular r, this will involve at most O(log2 n) multipications modulo r and so will take time O∼(log2 n log r) Only O(log5 n) different r’s need to be checked, and so the total complexity of this step is polynomial in log n Each gcd computation takes time O(log2 n) and since r is of O(log5 n), Step 8 will also be taking only time O(log7 n)

We have to verify l equations where l = or (n) − 1 < or (n) which divides φ(r) and hence, l < φ(r) < r is O(log5 n) Each equation takes O(log n) multipications of r degree polynomials with coefficients of size O(log n) and so, each equation can be verified in time O∼(r log2 n) steps Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029) 2 To find an r such that or (n) > 4 log n, successive values k Introduction of r are tried and tested whether n 6= 1 (mod r) for every 2 The Problem k ≤ 4 log n Core Idea behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 59 / 60 Only O(log5 n) different r’s need to be checked, and so the total complexity of this step is polynomial in log n Each gcd computation takes time O(log2 n) and since r is of O(log5 n), Step 8 will also be taking only time O(log7 n)

We have to verify l equations where l = or (n) − 1 < or (n) which divides φ(r) and hence, l < φ(r) < r is O(log5 n) Each equation takes O(log n) multipications of r degree polynomials with coefficients of size O(log n) and so, each equation can be verified in time O∼(r log2 n) steps Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029) 2 To find an r such that or (n) > 4 log n, successive values k Introduction of r are tried and tested whether n 6= 1 (mod r) for every 2 The Problem k ≤ 4 log n Core Idea 2 behind the For a particular r, this will involve at most O(log n) Algorithms multipications modulo r and so will take time Preliminaries O∼(log2 n log r) The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 59 / 60 Each gcd computation takes time O(log2 n) and since r is of O(log5 n), Step 8 will also be taking only time O(log7 n)

We have to verify l equations where l = or (n) − 1 < or (n) which divides φ(r) and hence, l < φ(r) < r is O(log5 n) Each equation takes O(log n) multipications of r degree polynomials with coefficients of size O(log n) and so, each equation can be verified in time O∼(r log2 n) steps Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029) 2 To find an r such that or (n) > 4 log n, successive values k Introduction of r are tried and tested whether n 6= 1 (mod r) for every 2 The Problem k ≤ 4 log n Core Idea 2 behind the For a particular r, this will involve at most O(log n) Algorithms multipications modulo r and so will take time Preliminaries O∼(log2 n log r) The Miller-Rabin Only O(log5 n) different r’s need to be checked, and so Primality Testing the total complexity of this step is polynomial in log n Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 59 / 60 We have to verify l equations where l = or (n) − 1 < or (n) which divides φ(r) and hence, l < φ(r) < r is O(log5 n) Each equation takes O(log n) multipications of r degree polynomials with coefficients of size O(log n) and so, each equation can be verified in time O∼(r log2 n) steps Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029) 2 To find an r such that or (n) > 4 log n, successive values k Introduction of r are tried and tested whether n 6= 1 (mod r) for every 2 The Problem k ≤ 4 log n Core Idea 2 behind the For a particular r, this will involve at most O(log n) Algorithms multipications modulo r and so will take time Preliminaries O∼(log2 n log r) The Miller-Rabin Only O(log5 n) different r’s need to be checked, and so Primality Testing the total complexity of this step is polynomial in log n Algorithm 2 The Agrawal- Each gcd computation takes time O(log n) and since r is Biswas 5 7 Primality of O(log n), Step 8 will also be taking only time O(log n) Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 59 / 60 Each equation takes O(log n) multipications of r degree polynomials with coefficients of size O(log n) and so, each equation can be verified in time O∼(r log2 n) steps Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029) 2 To find an r such that or (n) > 4 log n, successive values k Introduction of r are tried and tested whether n 6= 1 (mod r) for every 2 The Problem k ≤ 4 log n Core Idea 2 behind the For a particular r, this will involve at most O(log n) Algorithms multipications modulo r and so will take time Preliminaries O∼(log2 n log r) The Miller-Rabin Only O(log5 n) different r’s need to be checked, and so Primality Testing the total complexity of this step is polynomial in log n Algorithm 2 The Agrawal- Each gcd computation takes time O(log n) and since r is Biswas 5 7 Primality of O(log n), Step 8 will also be taking only time O(log n) Testing Algorithm We have to verify l equations where l = or (n) − 1 < or (n) 5 The AKS which divides φ(r) and hence, l < φ(r) < r is O(log n) Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 59 / 60 Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029) 2 To find an r such that or (n) > 4 log n, successive values k Introduction of r are tried and tested whether n 6= 1 (mod r) for every 2 The Problem k ≤ 4 log n Core Idea 2 behind the For a particular r, this will involve at most O(log n) Algorithms multipications modulo r and so will take time Preliminaries O∼(log2 n log r) The Miller-Rabin Only O(log5 n) different r’s need to be checked, and so Primality Testing the total complexity of this step is polynomial in log n Algorithm 2 The Agrawal- Each gcd computation takes time O(log n) and since r is Biswas 5 7 Primality of O(log n), Step 8 will also be taking only time O(log n) Testing Algorithm We have to verify l equations where l = or (n) − 1 < or (n) 5 The AKS which divides φ(r) and hence, l < φ(r) < r is O(log n) Primality Testing Algorithm Each equation takes O(log n) multipications of r degree

Prerona Chatterjee(Roll No.: 142123029)polynomials (DepartmentPRIMALITY with of Mathematics coefficients TESTING IIT ALGORITHMS Guwahati) of size O(log n) andApril, 2016so, each 59 / 60 equation can be verified in time O∼(r log2 n) steps Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n

The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029) 2 To find an r such that or (n) > 4 log n, successive values k Introduction of r are tried and tested whether n 6= 1 (mod r) for every 2 The Problem k ≤ 4 log n Core Idea 2 behind the For a particular r, this will involve at most O(log n) Algorithms multipications modulo r and so will take time Preliminaries O∼(log2 n log r) The Miller-Rabin Only O(log5 n) different r’s need to be checked, and so Primality Testing the total complexity of this step is polynomial in log n Algorithm 2 The Agrawal- Each gcd computation takes time O(log n) and since r is Biswas 5 7 Primality of O(log n), Step 8 will also be taking only time O(log n) Testing Algorithm We have to verify l equations where l = or (n) − 1 < or (n) 5 The AKS which divides φ(r) and hence, l < φ(r) < r is O(log n) Primality Testing Algorithm Each equation takes O(log n) multipications of r degree

Prerona Chatterjee(Roll No.: 142123029)polynomials (DepartmentPRIMALITY with of Mathematics coefficients TESTING IIT ALGORITHMS Guwahati) of size O(log n) andApril, 2016so, each 59 / 60 equation can be verified in time O∼(r log2 n) steps Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- Running Time Analysis (contd.) GORITHMS 2 Prerona If n is the input, isPower(n) takes O(log n) time and Chatterjee so, step 3 takes O(log2 n) time (Roll No.: 142123029) 2 To find an r such that or (n) > 4 log n, successive values k Introduction of r are tried and tested whether n 6= 1 (mod r) for every 2 The Problem k ≤ 4 log n Core Idea 2 behind the For a particular r, this will involve at most O(log n) Algorithms multipications modulo r and so will take time Preliminaries O∼(log2 n log r) The Miller-Rabin Only O(log5 n) different r’s need to be checked, and so Primality Testing the total complexity of this step is polynomial in log n Algorithm 2 The Agrawal- Each gcd computation takes time O(log n) and since r is Biswas 5 7 Primality of O(log n), Step 8 will also be taking only time O(log n) Testing Algorithm We have to verify l equations where l = or (n) − 1 < or (n) 5 The AKS which divides φ(r) and hence, l < φ(r) < r is O(log n) Primality Testing Algorithm Each equation takes O(log n) multipications of r degree

Prerona Chatterjee(Roll No.: 142123029)polynomials (DepartmentPRIMALITY with of Mathematics coefficients TESTING IIT ALGORITHMS Guwahati) of size O(log n) andApril, 2016so, each 59 / 60 equation can be verified in time O∼(r log2 n) steps Thus the time taken for Step 15 is O(r 2 log2 n) = O(log 12n). Step 15 dominates all the other steps and so, the time complexity for the AKS algorithm is O(log 12n) which is polynomial in log n The AKS Primality Testing Algorithm

PRIMALITY Manindra Agrawal and Somenath Biswas. TESTING AL- GORITHMS Primality and identity testing via chinese remaindering. Prerona Chatterjee Journal of the ACM (JACM), 50(4):429–443, 2003. (Roll No.: 142123029) Manindra Agrawal, Neeraj Kayal, and Nitin Saxena.

Introduction Primes is in p.

The Problem Annals of mathematics, pages 781–793, 2004.

Core Idea behind the Leiserson Coremen. Algorithms Rivest, stein introduction to algorithm. Preliminaries PHI publication. The Miller-Rabin Primality David Steven Dummit and Richard M Foote. Testing Algorithm Abstract algebra, volume 1984.

The Agrawal- Wiley Hoboken, 2004. Biswas Primality Testing Rudolf Lidl and Harald Niederreiter. Algorithm Introduction to finite fields and their applications. The AKS Primality Cambridge University Prepp, 1986. Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 59 / 60 The AKS Primality Testing Algorithm

PRIMALITY Gary L Miller. TESTING AL- GORITHMS Riemann’s hypothesis and tests for primality. Prerona Chatterjee Journal of computer and system sciences, 13(3):300–317, (Roll No.: 142123029) 1976. Michael O Rabin. Introduction Probabilistic algorithm for testing primality. The Problem

Core Idea Journal of number theory, 12(1):128–138, 1980. behind the Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 60 / 60 The AKS Primality Testing Algorithm

PRIMALITY TESTING AL- GORITHMS

Prerona Chatterjee (Roll No.: 142123029)

Introduction

The Problem

Core Idea behind the Thankyou Algorithms

Preliminaries

The Miller-Rabin Primality Testing Algorithm

The Agrawal- Biswas Primality Testing Algorithm

The AKS Primality Testing Algorithm

Prerona Chatterjee(Roll No.: 142123029) (DepartmentPRIMALITY of Mathematics TESTING IIT ALGORITHMS Guwahati) April, 2016 60 / 60