Probabilistic Proofs and How Certain Is Certain Enough
See how random tests can verify primes, products and identities with tiny error chances, and why mathematicians still separate that from proof.
Key takeaways
- A good randomized test has a proven bound on its error probability for every input, not just typical ones.
- Independent repetitions shrink the error bound geometrically, so a few dozen rounds go a very long way.
- The bound describes the chance that a false claim passes the test, which is different from the chance that a passing claim is false.
- The probabilistic method uses randomness inside a completely rigorous proof and should not be confused with random testing.
- Mathematicians generally label results verified only by random tests as probable, not as theorems.
A probabilistic check uses random choices to test a claim, with a guaranteed limit on how often it can be fooled. Repeat it enough times and the chance of wrongly accepting a false statement can be made far smaller than almost any other risk in a calculation. It still does not produce a proof in the traditional sense.
The gap between "overwhelmingly likely" and "proved" is narrow in practice and wide in principle. Understanding both sides shows what mathematicians mean when they claim to know something.
Two very different uses of chance
Chance can appear inside an ordinary proof. To show that an object with some property exists, you can pick an object at random and prove that the probability of success is greater than zero. If it were impossible, the probability would be zero, so such an object exists. This is the probabilistic method, and its conclusions are fully certain.
The subject here is different. A randomized verification procedure actually flips coins, looks at the outcome, and reports "false" or "probably true". The theorem about the procedure is rigorous. What any particular run tells you about your particular claim carries a small uncertainty.
Checking a matrix multiplication
Suppose someone hands you three large square matrices and claims that AB = C. Recomputing the product takes a lot of work. In the 1970s Rusins Freivalds proposed a shortcut: choose a random column r of zeros and ones, and compare A(Br) with Cr. This needs only multiplications of a matrix by a column.
A = [1 2; 3 4] B = [2 0; 1 2] (rows separated by ;)
true product AB = [4 4; 10 8]
claimed C = [4 4; 10 9] one wrong entry
r = (1, 1): A(Br) = (8, 18) Cr = (8, 19) different: caught
r = (1, 0): A(Br) = (4, 10) Cr = (4, 10) equal: missed If AB = C, the two sides always agree. If AB ≠ C, a random zero-one column detects the difference with probability at least 1/2. In the example, two of the four possible columns catch the error.
With 30 independent columns, a wrong product slips through with probability at most 1/2³⁰, which is less than one in a billion.
Testing for primes
A famous example is the Miller-Rabin test. Given an odd number n, you pick a random base a and perform a calculation based on powers of a modulo n. A prime always passes. For an odd composite number, at most a quarter of the possible bases let it pass.
So after k independent random bases, a composite number survives with probability at most (1/4)ᵏ. For k = 50 that is 1/2¹⁰⁰, roughly 8 × 10⁻³¹.
The guarantee holds for every composite number, including the troublemakers. A simpler test based only on Fermat's little theorem has no such guarantee: numbers called Carmichael numbers, of which 561 = 3 × 11 × 17 is the smallest, pass it for every base that shares no factor with them.
A deterministic polynomial-time primality test, found by Agrawal, Kayal and Saxena in 2002, settles the question with certainty. In practice the randomized test is much faster and remains widely used. Background is in testing large numbers for primality.
Where does the one half come from? Let D = AB − C, which has at least one nonzero entry. Look at a row containing it. Whatever the other choices in r, flipping the bit that multiplies that entry changes the row's result by a nonzero amount. So at least one of the two settings of the bit must give a nonzero answer. That short argument is an ordinary, complete proof about the behavior of a random procedure.
Checking identities by plugging in numbers
Is a complicated polynomial expression identically zero? Expanding it might be hopeless. A nonzero polynomial, however, cannot vanish too often.
The precise statement, usually called the Schwartz-Zippel lemma, says this. Let a nonzero polynomial in several variables have total degree d. Choose each variable independently and uniformly from a set of S numbers. The probability that the result is zero is at most d/S.
For instance, suppose someone claims (x + y)² = x² + y². The difference is 2xy, of degree 2. Choosing x and y from the integers 1 to 1,000, you get a nonzero value every time, so the claim is refuted with certainty. Had the difference been identically zero, every trial would give zero, and each agreeing trial with a large set of choices would strengthen the case.
Notice the asymmetry. A single nonzero value is a complete disproof. Agreement is only evidence.
How fast the doubt shrinks
The power of repetition comes from independence. If each round fools you with probability at most p, and the rounds use separate random choices, then all k rounds fool you with probability at most p multiplied by itself k times.
| Miller-Rabin rounds | Bound on a composite passing |
|---|---|
| 1 | 1/4 |
| 5 | about 1 in 1,000 |
| 10 | about 1 in a million |
| 20 | about 1 in a trillion |
| 50 | about 8 × 10⁻³¹ |
The cost grows only in proportion to k, while the bound falls exponentially. Doubling the work squares the error bound. Few other tradeoffs in computing are so generous.
Note also that these tests err in one direction only. When Miller-Rabin says "composite", it has found definite evidence, and that answer is a proof of compositeness even though it may not name a factor. Only the answer "probably prime" carries doubt. The same is true of the matrix and polynomial checks, where a mismatch is final.
Which probability is being bounded
The error bound answers the question: if the claim is false, how likely is it to pass? People often want the reverse: given that it passed, how likely is it to be false? These differ, in the same way as in the prosecutor's fallacy.
The second question depends on how likely the claim was before testing. Say you pick a random 1,000-bit odd number. Primes among such numbers are rare, roughly 1 in 350. After a single test round, if composites really did pass a quarter of the time, most passing numbers would still be composite. Actual pass rates for typical large composites are far lower than the worst case, but the logic stands: one round and a worst-case bound do not say "75 percent sure it is prime".
After many rounds the bound on false passes becomes so small that it overwhelms any reasonable prior odds.
What can go wrong outside the theorem
The probability bound assumes ideal random choices. Real programs use pseudorandom numbers, and a poor generator or a predictable seed can undermine the guarantee. An adversary who can guess your bases may construct an input that passes.
Software bugs and hardware faults also exist. Once the theoretical error is below something like 10⁻³⁰, these other risks are plainly the larger ones, and they affect long deterministic computations too.
Is that good enough
One view holds that a theorem means a deductive proof. On this account, a number that has passed many tests is a "probable prime" and nothing more, however small the doubt. Mathematics gets its character from not accepting evidence in place of argument, and large numbers of checks have misled before.
Another view points out that every proof is checked by fallible people or machines, and that the chance of an undetected error in a long argument may well exceed 10⁻³⁰. Doron Zeilberger and others have suggested that some identities might reasonably be accepted on probabilistic grounds, clearly labeled as such.
Common practice lies between. Engineers and cryptographers routinely rely on probable primes. Mathematicians state such results honestly and reserve "theorem" for what has been proved. The two kinds of confidence also differ in structure: the doubt in a randomized test is quantified and can be reduced by running it again, while doubt about a subtle written argument is harder to measure.
It helps to say exactly what has been established when reporting such a result. A clear statement names the test, the number of independent trials, the error bound and the source of randomness. "The identity held at 40 random points chosen from a set of a million values, for a polynomial of degree at most 100" tells a reader precisely how much doubt remains: if the identity were false, each point would miss it with probability at most 100 in a million.
Some randomized procedures can also be upgraded. A run may hand you a certificate, an extra piece of data that anyone can check deterministically. When that happens, chance was only used to find the evidence, and the final result is a proof in the ordinary sense. For primes there are certificate methods of this kind, including ones based on elliptic curves.
Where the idea leads
Theoretical computer science has taken random checking much further. The PCP theorem, proved in the early 1990s, implies that proofs of a broad class of statements can be rewritten so that a verifier reads only a few randomly chosen symbols and still catches false claims with substantial probability. Related ideas let one party convince another while revealing nothing else, the subject of zero-knowledge proofs.