A strange thing has happened to me this semester. I’ve been spending more time thinking about physics and computer science than math! Granted, most of what I have been thinking about is pretty mathematical in nature, and I’ve tried to think of it that way if not.
So today in my algorithms class we were talking a bit about primality testing. It is, of course, necessary to know in practice if a given number of, say, digits is prime, for instance to use the RSA algorithm. To do this efficiently, we want our algorithm to be polynomial in . The existence of such an algorithm (the AKS algorithm) is fairly recent, and only appeared in 2002. But before that, partial results were known.
Let us consider the language that consists of all . Integers are represented in their binary expansion (or more generally their -ary expansion where ). The AKS algorithm shows that lies in the complexity class .
It is straightforward to see that ; that is, there exist short certificates to show efficiently that a number is composite. This is easy: just take a factoring as the certificate. It was also shown in the 1970s by V. Pratt that succinct certificates for primality exist, or that . I would like to explain this result, which is of course immediate from the AKS algorithm, but which has an elegant approach of its own.
So, the idea of is that given a number of bits, I must be able to produce “evidence” of length polynomial in that is in fact prime. This evidence can be checked by a polynomial-time Turing machine. If I feed it the right proof for a given prime, this machine will return that it is convinced the number is prime. If I feed it a composite number and anything as its proof, then it will return no, no matter what.
Now the idea behind Pratt certificates is that a number is prime if and only if the multiplicative group is cyclic of order . So if we can produce an element such that but for all primes , then it will follow that contains a cyclic group of order . This will imply that is prime, because otherwise .
Here is a way of convincing someone (or a machine) that a number is prime. Exhibit a number (which will turn out to be a primitive root mod ) such that but for each prime . If you present the other person this data, she can check that you are not lying pretty efficiently: computing the mod exponents can be done in polynomial time (in or ) by repeated squaring.
So the person can check that your choice of was legitimate. What might be harder is to determine which ‘s to check for the . A priori, we don’t know the other person can factor efficiently. We need a little more for the certificate to be sound. Namely, we will need to include the prime factorization of in the certificate so that the other person can check the .
Of course, the other person will be able to check that the factorization is valid—just by multiplying the numbers together. It will be harder, though, for the other person to know that the numbers in the factorization that we are giving her are in fact prime. Namely, we need to produce evidence that each of the elements of the factorization are in fact prime! We can thus do this in the same way. So, if we want to convince someone that a number is prime, here is the evidence we present:
- An integer .
- A prime factorization of
- (Inductively) prime certificates for every prime in the factorization of .
Suppose inductively that the verifier has checked that every element in the factorization we have presented is in fact prime. The verifier will then check that and for each prime in the prime factorization. By the above observations, this verifier cannot be fooled.
So we now see that primality certificates exist and are efficient. It is clear that the above expression takes polynomial space, because there aren’t going to be too many primes that keep occurring in repeated factorizations. Computationally, though, if we wanted to find a given prime number, this is not helpful, as is not (probably) a reasonable model of computation. We can be quickly convinced that a number is prime, but we don’t see how to find one ourselves.
It turns out that there is a simple and efficient probabilistic algorithm for doing so; that is, belongs to the class BPP. Next time, I’ll explain this. And sometime later, maybe I’ll try to work through the AKS paper and explain that too.