Randomized Complexity Classes and Derandomization
Learning Objectives
- Define the randomized classes BPP, RP, coRP, and ZPP and the error each allows.
- Show with a Chernoff bound that BPP's error constant 1/3 is arbitrary: majority voting over runs drives the error below .
- State the Schwartz-Zippel lemma and use it to put polynomial identity testing in coRP, and verify matrix products with Freivalds's algorithm.
- Explain the evidence for the conjecture P = BPP, including the hardness-versus-randomness connection to circuit lower bounds.
Context & Motivation
Earlier concepts in this track used randomness as a design tool: Karger's contractions, hash families, sketches. Complexity theory asks whether randomness is fundamentally necessary for efficient computation. Are there problems a polynomial-time algorithm can solve with coin flips but not without them?
For decades the answer seemed to be yes. Testing whether a number is prime had fast randomized algorithms (Solovay-Strassen 1977, Miller-Rabin 1980) but no known deterministic polynomial one until Agrawal, Kayal, and Saxena's AKS algorithm in 2002. Testing whether a polynomial given as a formula or circuit is identically zero still has a trivial randomized algorithm and no known deterministic polynomial one. Yet the modern consensus, built on results by Nisan, Wigderson, and Impagliazzo in the 1990s, is that randomness can probably always be removed: P = BPP. This concept presents the classes, the tools, and the evidence, following Arora and Barak, Sipser's 18.404J, and Vadhan's monograph on pseudorandomness.
Core Theory
The classes
A probabilistic Turing machine flips fair coins and must run in polynomial time on every input and every coin sequence. For a language :
- BPP (bounded-error probabilistic polynomial time): for every , . Two-sided error.
- RP: if , accept with probability at least ; if , always reject. One-sided error: an acceptance is a proof.
- coRP: the complement of RP languages; errors only on "yes" instances.
- ZPP = RP coRP: always correct, polynomial expected time (Las Vegas).
Known relations: , and (an accepting coin sequence is a certificate). Whether is open, although (Sipser-Gács-Lautemann) and (Adleman) are known.
Amplification
The constant is arbitrary. Run a BPP algorithm times independently and output the majority answer. Let be the number of correct runs, so . The majority is wrong only if , which is a deviation of at least a quarter below the mean (). The Chernoff lower-tail bound from the min-cut concept gives
so runs reduce the error below . Any constant gap above 1/2, even for a polynomial, can be amplified the same way. For RP, runs and accepting if any run accepts gives error directly.
Polynomial identity testing
Given an arithmetic expression (or circuit) for a polynomial , decide whether . Expanding it symbolically can take exponential time, since has monomials.
Schwartz-Zippel lemma. If is a nonzero polynomial of total degree over a field and are chosen independently and uniformly from a finite set , then
So evaluate at a random point (cheap, by plugging numbers into the expression): if the result is always 0; if not, it is nonzero with probability at least . Taking puts identity testing in coRP. No deterministic polynomial-time algorithm is known, and Kabanets and Impagliazzo (2004) showed that finding one would imply new circuit lower bounds, a statement of how deep the question is.
The same idea gives Freivalds's algorithm for verifying a matrix product: to check for matrices, pick a random vector and compare with . Each side costs , far less than multiplying the matrices. If , the check fails to notice with probability at most ; repeating times reduces that to .
Hardness versus randomness
Why believe P = BPP? A BPP algorithm only uses its random bits to make some test statistically representative. A pseudorandom generator stretches a short truly random seed into a long string that no efficient test can distinguish from random. If a generator with seed length existed, a BPP algorithm could be derandomized by trying all seeds and taking the majority.
Nisan and Wigderson showed that such generators can be built from hard functions. Impagliazzo and Wigderson (1997) proved: if some problem solvable in time requires Boolean circuits of size , then P = BPP. Since most functions do require exponential circuits, the hypothesis is widely believed. Hardness and randomness are two sides of one coin: either strong lower bounds exist and randomness is unnecessary, or some problems are easy in a surprising way.
Worked Examples
Example 1: how many repetitions
Problem: A BPP algorithm is correct with probability . How many independent runs with a majority vote guarantee error at most using the bound above?
Trace: Require , so . About a thousand runs. The bound is loose; an exact binomial calculation gives a few hundred. Either way the cost is a constant factor that depends only on the desired error, not on the input size, which is why BPP is considered as practical as P.
Example 2: catching a wrong matrix product
Problem: , , and a claimed product . Run Freivalds with and with .
Trace: With : , , . They differ, so the product is wrong, detected with work. With : , , . They agree, so this choice misses the error, because the wrong entry is in the second column and ignores that column. The difference matrix has a nonzero entry, and the test misses it only if happens to lie in a set containing at most half of , which is where the bound comes from.
Common Misconceptions & Pitfalls
- "BPP algorithms might be wrong, so they are not real solutions." With error after amplification, the chance of a wrong answer is far below the chance of a hardware error. The theoretical question is whether the coins are needed, not whether the answers are trustworthy.
- "Primality was the main evidence for BPP being larger than P." It was a famous example, but AKS removed it in 2002. Polynomial identity testing is the most prominent problem in BPP (indeed in coRP) still lacking a deterministic polynomial algorithm.
- "Proving P = BPP would be easy if it is true." Unconditional derandomization of identity testing implies circuit lower bounds that are far beyond current techniques; the conjecture is believed largely because the alternative contradicts other strongly believed hardness assumptions.
Summary
BPP captures efficient computation with coin flips and bounded two-sided error; RP and coRP allow one-sided error and ZPP none. Majority voting with a Chernoff bound shrinks the error exponentially, so the 2/3 in the definition is arbitrary. The Schwartz-Zippel lemma puts polynomial identity testing in coRP by evaluating at a random point, and Freivalds verifies matrix products in quadratic time the same way. Pseudorandom generators built from hard functions would derandomize BPP, and Impagliazzo and Wigderson showed that exponential circuit lower bounds imply P = BPP. The next concept adds randomness to the verifier rather than the algorithm, and lets the prover and verifier talk.