This is the Karp–Lipton theorem. It is enough to place inside . Let , so for a polynomial-time predicate and polynomially bounded strings,
The NP search problem that receives and seeks such a has, by part (i), a polynomial-size circuit family producing a valid witness whenever one exists. For each input length there is therefore a polynomial-size circuit such that, for every relevant , existence of a witness implies .
Consequently
where the existentially guessed circuit description has polynomial length and evaluation of is polynomial time. This is a description. Hence ; complementation gives the reverse inclusion, and merging adjacent equal quantifier blocks collapses every higher level. Thus the polynomial hierarchy satisfies
Let be a polynomial-time verifier for , with witnesses of length . Consider the prefix language
This language lies in NP, so the assumption supplies a polynomial-size circuit family deciding .
Apply the usual search-to-decision reduction. Starting with the empty prefix, append zero if the circuit says that some accepting witness has that extended prefix; otherwise append one. Repeat for positions. Composing the polynomially many copies of the decision circuit produces a polynomial-size circuit . Whenever , at least one accepting extension exists at every step, so the final string satisfies
On negative inputs the output may be arbitrary, as required.
A language belongs to RP when a polynomial-time randomized algorithm rejects every and accepts every with probability at least .
Amplify the algorithm on length- inputs with independent repetitions, accepting if any repetition accepts. Its error on each positive input is at most , while it still never accepts a negative input. Choose all random bits for all repetitions in advance. By the union bound, the probability that this one fixed choice fails on at least one of the at most positive strings is at most
Thus some random string works simultaneously for every input of length . Hardwire that string into the polynomial-time computation and compile it into a Boolean circuit. The resulting polynomial-size circuit family decides , proving