PRIMES is in P Jóhann Guðmundsson Háskóli Íslands Reykjavík, nóvember 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 steps. Would prefer a polynomial number of steps in the size of the input ⌈ log 2 n ⌉ a Where if f ( n ) ∈ Ω( n ) means ∃ ( k > 0) , n 0 ∈ N : ∀ ( n > n 0 ) kg ( n ) ≤ f ( n ) 1
Generalization of Fermat’s Little Theorem Lemma: Let a ∈ Z , n ∈ N and ( a, n ) = 1 . Then n is prime iff: X n + a ( X + a ) n ( mod n ) = We also have n is prime for appropriatly chosen r and a iff X n + a ( mod X r − 1 , n ) ( X + a ) n (1) = 2
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
The Algorithm Input: integer n > 1 . 1. If ( n = a b for a ∈ N and b > 1 ), output COMPOSITE. 2. Find the smallest r such that o r ( n ) > log 2 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 � = X n + a ( mod X r − 1 , n )) , output COMPOSITE; 6. Output PRIME; 4
Important functions Here o r ( 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
The Time Complexity Theorem: The asymptotic time complexity of the algo- rithm is O ˜(log 21 / 2 n ) , where O ˜( t ( n )) = O ( t ( n ) log( t ( n )) c ) for some constant c . 6
Recommend
More recommend