PRIMES is in P Jhann Gumundsson Hskli slands Reykjavk, nvember - - PowerPoint PPT Presentation

primes is in p
SMART_READER_LITE
LIVE PREVIEW

PRIMES is in P Jhann Gumundsson Hskli slands Reykjavk, nvember - - PowerPoint PPT Presentation

PRIMES is in P Jhann Gumundsson Hskli slands Reykjavk, nvember 2008 Determine primality Initial guessing: Try deviding n with every number m < n , if m || n then n is composite. This is inefficient and takes ( n ) a


slide-1
SLIDE 1

PRIMES is in P

Jóhann Guðmundsson Háskóli Íslands Reykjavík, nóvember 2008

slide-2
SLIDE 2

Determine primality

Initial guessing: Try deviding n with every number m < √n, if m||n then n is composite. This is inefficient and takes Ω(√n)a steps. Would prefer a polynomial number of steps in the size of the input ⌈log2 n⌉

aWhere if f(n) ∈ Ω(n) means ∃(k > 0), n0 ∈ N : ∀(n >

n0) kg(n) ≤ f(n)

1

slide-3
SLIDE 3

Generalization of Fermat’s Little Theorem

Lemma: Let a ∈ Z, n ∈ N and (a, n) = 1. Then n is prime iff: (X + a)n = Xn + a (mod n) We also have n is prime for appropriatly chosen r and a iff (X + a)n = Xn + a (mod Xr − 1, n) (1)

2

slide-4
SLIDE 4

Equation (1) reduces the number of coefficiets and therefore speeds up the calculation. Now faced with a new problem, if the equation holds n is not nececarily prime. The remedy is to choose an appropriate r and test the equation for several a’s. Then n must be a prime power.

3

slide-5
SLIDE 5

The Algorithm

Input: integer n > 1.

  • 1. If (n = ab for a ∈ N and b > 1), output COMPOSITE.
  • 2. Find the smallest r such that or(n) > log2 n.
  • 3. If 1 < (a, n) < n for some a ≤ r, output COMPOSITE.
  • 4. If n ≤ r, output PRIME.
  • 5. For a = 1 to ⌊
  • φ(r) log n⌋ do

if ((X + a)n = Xn + a (mod Xr − 1, n)),

  • utput COMPOSITE;
  • 6. Output PRIME;

4

slide-6
SLIDE 6

Important functions

Here or(n) is the order of n wrt. r and φ(r) is Euler’s totient function, giving the number of numbers less than r, relati- vely prime to r.

5

slide-7
SLIDE 7

The Time Complexity

Theorem: The asymptotic time complexity of the algo- rithm is O˜(log21/2 n), where O˜(t(n)) = O(t(n) log(t(n))c) for some constant c.

6