Amplification with One NP Oracle Query

We provide a complete picture of the extent to which amplification of success probability is possible for randomized algorithms having access to one NP oracle query, in the settings of two-sided, onesided, and zero-sided error. We generalize this picture to amplifying one-query algorithms with q-query algorithms, and we show our inclusions are tight for relativizing techniques.


Introduction
Amplification of the success probability of randomized algorithms is a ubiquitous tool in complexity theory.We investigate amplification for randomized reductions to NP-complete problems, which can be modeled as randomized algorithms with the ability to make queries to an NP oracle.The usual amplification strategy involves running multiple independent trials, which would also increase the number of NP oracle queries, so this does not generally work if we restrict the number of queries.We study, and essentially completely answer, the following question: If a language is solvable with success probability p by a randomized polynomial-time algorithm with access to one NP oracle query, what is the highest success probability achievable with one query (or q > 1 many queries) to an NP oracle?
The question makes sense for two-sided error (BPP NP[1] ), one-sided error (RP NP[1] ), and zero-sided error (ZPP NP[1] ), and it was mentioned in Cai & Chakaravarthy (2006) as "an interesting problem worthy of further investigation."Partial results for zero-sided error were shown in Chang & Purini (2008).The question is also relevant to the extensive literature on bounded NP queries (the boolean hierarchy); e.g., ZPP NP[1] shows up frequently in the context of the "two queries problem" (Tripathi 2010), which was the main application area of the results from Chang & Purini (2008).A complementary question (about lowering the success probability in exchange for fewer NP queries) was studied in Rohatgi (1995).
Our first contribution characterizes the best amplification achievable by relativizing techniques in the two-sided error setting.In general, the best strategy for amplifying plain randomized algorithms is to take the majority vote of q independent trials, which in our setting would naively involve q NP oracle queries.One may suspect this majority vote strategy is optimal for us.We show this intuition is a red herring; it is possible to do better by "combining" NP oracle queries across different trials.As an extreme example, consider the special case of randomized mapping reductions to NP problems.These are equivalent to Arthur-Merlin games (AM), for which amplification is possible by running independent trials and simply having Merlin's message consist of certificates for a majority of the trials.However, if we allow one NP oracle query, but do not necessarily output the same bit the oracle returns, then combining queries is less straightforward, and it turns out amplification is only possible to a limited extent.
Our main take-home message is that starting with success probability greater than 1 2 + 1 2 • 1 k+1 , where k is an integer, we can get arbitrarily close to 1 2 + 1 2 • 1 k success probability while still using one NP query; using q nonadaptive queries, roughly a factor q improvement over this is possible.
We give precise definitions in Section 2, but we now clarify our notation before stating the theorem.For ∈ (0, 1] (the advantage), BPP NP[1] is the set of all languages solvable by a randomized polynomial-time algorithm that may make one query to an NP oracle and produces the correct output with probability ≥ 1 2 + 1 on each input.For convenience, we define BPP

NP[1] >
by requiring that for some constant c there exists such an algorithm with advantage ≥ + n −c , and we define BPP NP[1] > by requiring that for every constant d there exists such an algorithm with advantage ≥ − 2 −n d ; the reason for these conventions is just that they naturally arise in the proofs (e.g., standard majority amplification implies BPP >0 = BPP 1> ).We make similar definitions for BPP NP [q]  but allowing q nonadaptive NP oracle queries.Allowing q adaptive NP queries is equivalent to allowing 2 q − 1 nonadaptive NP queries (Beigel 1991).Like with the boolean hierarchy (which contains the classes P NP [q] ), it is helpful to distinguish between an odd or even number of queries q.
Theorem 1.1 (Two-sided error).For integers 1 ≤ q ≤ k: r If q is odd: q/k> and BPP >q/k relative to an oracle.r If q, k are even: BPP q/k> and BPP NP [1] 1/(k−1) ⊆ BPP NP [q] >q/k relative to an oracle.The word "oracle" has two meanings here.Besides the bounded NP oracle queries of central interest, "relative to an oracle" means there exists a language such that the separation holds when all computations (the randomized algorithm and the NP verifier) can make polynomially many adaptive queries to an oracle for that language.In particular, in the context of our relativized separations, randomized algorithms have access to two oracles.The separations in Theorem 1.1 are tight since the inclusions relativize.This implies that using "black-box simulation" techniques, it is not possible to significantly improve any of our inclusions.
If we start with advantage > 1 k+1 where k is an integer, then Theorem 1.1 tells us the best advantage achievable with q nonadaptive NP queries using relativizing techniques: if k is even we can amplify to essentially q k ; if k is odd we can amplify to essentially q k if q is odd, and q k+1 if q is even.(Theorem 1.1 does not explicitly mention the case where q is even and k is odd, but in this case the best inclusion and separation are obtained by applying the theorem to the even integer k + 1.) 3 Page 4 of 47

Thomas Watson cc
A subtle issue is whether "q/k >" in the inclusion subscripts can be improved to "q/k"; e.g., it remains open to show that BPP relative to an oracle.
The proof of Theorem 1.1 appears in Section 3. No such nontrivial inclusion was known before; for relativized separations, the case q = 1, k = 2 was shown in Watson (2020).
One-sided error algorithms must always output 0 if the answer is 0, and must output 1 with probability at least some ∈ (0, 1] if the answer is 1.We define the advantage (the subscript of RP NP [q] ) to be this .In contrast to BPP NP [q] (where the advantage measures how much better than1 2 the success probability is), for RP NP [q] the advantage measures how much better than 0 the success probability is.
The proof of Theorem 1.2 appears in Section 4 and is relatively straightforward (and could serve as a warm-up for Theorem 1.1 if the reader would like that).The inclusion RP 1/2> ) uses a trick described in Chang & Purini (2008) for getting a tiny boost in the advantage.
Zero-sided error algorithms must output the correct bit with probability at least some ∈ (0, 1] and output ⊥ (plead ignorance) with the remaining probability.We define the advantage (the subscript of ZPP NP [q] ) to be this .Chang & Purini (2008) proved that ZPP 1> , 1 and left it unresolved what happens between advantages 1 4 and 1 2 .We settle this decade-old open problem: amplification is possible between 1 4 and 1 3 and between 1 3 and 1 2 .
Moreover, the "q/k >" in the inclusion subscripts can be improved to "q/k" if q < k and k ≥ 3. The proof of Theorem 1.3 appears in Section 5.The "moreover" part uses the trick from Chang & Purini (2008) for a tiny boost in the advantage.Like the situation with BPP NP [1] , it remains open to show that ZPP 1/2 relative to an oracle.There is no reason to consider k > 4 in Theorem 1.3, since then ZPP q/4> .We conjecture that the third bullet in Theorem 1.3 also holds for q > 1 (i.e., the relativized separations ZPP >2/3 ).This remains open, though we are aware of how to prove that ZPP >3/4 .Anyway, q = 1 is the most natural case, and we provide a complete proof for it.
Finally, we point out that none of the inclusions in this paper can be strengthened to yield advantage exactly 1 via relativizing techniques, since BPP ⊆ ZPP

Definitions
We formally define the relevant complexity classes in Section 2.1 and their decision tree analogues (which are used for relativized separations) in Section 2.2.

Time complexity.
We think of a randomized algorithm M as taking a uniformly random string s ∈ {0, 1} r (for some number of coins r that depends on the input length); we let M s (x) denote M running on input x with outcome s.
For ∈ (0, 1] (the advantage) and integer q ≥ 1, language L is in BPP NP [q] iff there is a polynomial-time randomized algorithm M (taking input x and coin tosses s ∈ {0, 1} r ) and a language L ∈ NP such that the following hold.
RP NP [q] is defined similarly except for correctness, we require the output is always 0 if L(x) = 0, and is 1 with probability ≥ if L(x) = 1.ZPP NP [q] is defined similarly except out : {0, 1} q → {0, 1, ⊥} and for correctness, we require the output is always L(x) or ⊥, and is L(x) with probability ≥ .For C ∈ BPP NP [q] , RP NP [q] , ZPP NP [q] , we define When q = 1 we may drop the from the superscripts.

Decision tree complexity.
We think of a randomized decision tree T as the uniform distribution over a multiset of corresponding deterministic decision trees T s indexed by s ∈ {0, 1} r ; we denote this as T ∼ T s : s ∈ {0, 1} r .In this setting, "query" actually has two meanings for us: a decision tree makes queries to individual input bits, then it forms an NP-type (DNF-Disjunctive Normal Form formula) oracle query.(This DNF does not represent a language in the time-bounded class NP, but it plays the same role.) We define a BPP NP [q] -type decision tree T for f : {0, 1} n → {0, 1} on input x as follows.
Syntax: T ∼ T s : s ∈ {0, 1} r where each T s makes queries to the bits of x until it reaches a leaf, which is la-beled with a tuple of DNFs (ϕ 1 , . . ., ϕ q ) and a function out : {0, 1} q → {0, 1}; then out(ϕ 1 (x), . . ., ϕ q (x)) is the output.Correctness: The output is f (x) with probability ≥ 1 2 + 1 2 .Cost: The maximum height of any T s , plus the maximum width (maximum number of literals in any term) of any DNF appearing at a leaf.(The sizes of the DNFs do not matter.) An RP NP [q] -type decision tree is defined similarly except for correctness we require the output is always 0 if f (x) = 0, and is 1 with probability ≥ if f (x) = 1.A ZPP NP [q] -type decision tree is defined similarly except out : {0, 1} q → {0, 1, ⊥} and for correctness, we require the output is always f (x) or ⊥, and is f (x) with probability ≥ .We follow the convention of overloading complexity class names as decision tree complexity measures: for C ∈ BPP NP [q] , RP NP [q] , ZPP NP [q] , C dt (f ) denotes the minimum cost of any C -type decision tree for a partial function f , and C dt also denotes the class of all families of f 's with C dt (f ) ≤ polylog(n), and we define If f (x) = b then we say x is a b-input of f .When we use decision tree complexity separations to prove relativized separations of time-bounded complexity classes, the decision tree's input is not the same as the time-bounded algorithm's input-it is the truth table of the oracle language at some input length.

Two-sided error
To prove Theorem 1.1, we first restate it in a more convenient form.
Theorem 3.1 (Two-sided error, restated).For integers 1 ≤ q ≤ k: q/k> .(iii) If q, k are even: BPP >q/k relative to an oracle.(iv) If q is odd: >q/k relative to an oracle.
We prove the inclusions (i) and (ii) in Section 3.1 and the separations (iii) and (iv) in Section 3.2.
3.1.Inclusions.We prove the q = 1 case of (i) in Section 3.1.1and the q = 1 case of (ii) in Section 3.1.3(together these show that BPP 1/k> for all integers k ≥ 1), and we generalize to the q > 1 case of (i) in Section 3.1.2and the q > 1 case of (ii) in Section 3.1.4.The techniques from Chang & Purini (2008) for the zero-sided error setting are not particularly helpful for the two-sided error setting, so we develop the ideas from scratch.
We now describe the common setup.For some constant c we have L ∈ BPP

NP[1]
1/(k+1)+n −c , witnessed by a polynomial-time randomized algorithm M (taking input x and coin tosses s ∈ {0, 1} r ) and a language L ∈ NP.For an arbitrary constant d, we wish to show L ∈ BPP Fix an input x.The first step is to sample a sequence of m = O(n 2c+d ) many independent strings s 1 , . . ., s m ∈ {0, 1} r , so with probability ≥ 1 − 2 −n d −1 , the sequence is good in the sense that on input x, M still has advantage strictly greater than 1 k+1 when its coin tosses are chosen uniformly from the multiset {s 1 , . . ., s m }.Then we design a polynomial-time randomized algorithm which, given a good sequence, outputs L(x) with advantage ≥ q k after making q nonadaptive NP oracle queries.Hence, over the random s 1 , . . ., s m and the other randomness of our algorithm, Henceforth, fix a good sequence s 1 , . . ., s m , and let z h and out h : {0, 1} → {0, 1} be the query string and truth table produced cc by M s h (x) (so the output is out h (L (z h ))).We assume w.l.o.g. that each out h is nonconstant and is hence either identity or negation.Henceforth, assume that identity is at least as common as negation among out 1 , . . ., out m ; the proof is completely analogous if negation is more common.
Taking probabilities over a uniformly random h ∈ [m], we make the following definitions.
The key observation is now because of M 's advantage w.r.t. a good sequence s 1 , . . ., s m .This figure shows an example of how these values may fall on the number line if L(x) = 1:

Thomas Watson cc
The following summarizes the key properties so far.
Also, for any rational p, testing whether a ≥ p can be expressed as an NP oracle query: a witness consists of a list of witnesses for L (z h ) = 1 for at least (p+α)m many h's with out h = id.Similarly, testing whether b ≥ p can be expressed as an NP oracle query.

Proof of (i):
Δ.This figure shows an example with k = 7: Our algorithm now picks one of these k possibilities uniformly at random: 2 r for some odd i ∈ 2 many even i's (j + 1, j + 3, . . ., k − 1).Hence, the probability of outputting 1 is at least 2 Of course, if k is not a power of 2 and we insist on using uniform coin flips as our only source of randomness, then we must incur a tiny error since it is not possible to exactly sample i ∈ [k] uniformly.We sweep this pedantic issue under the rug throughout the paper.cc Amplification with One NP Oracle Query Page 11 of 47 3 at least j−1 2 many even i's (2, 4, . . ., j − 1).Hence, the probability of outputting 0 is at least That concludes the formal proof, but here is an intuitive way to visualize what is happening: Call γ i for odd i "upper marks," and call γ i for even i "lower marks," and assume for convenience all lower marks are in (−β, β).Suppose L(x) = 1 and b = −β so a > γ 1 ; then at least one upper mark is left of a and all k−1 2 lower marks are right of b, resulting in k+1 2 of the algorithm's possibilities outputting 1.Now as we continuously sweep a and b to the right, keeping a − b fixed, a passes each upper mark before b passes the preceding lower mark, so at all times at least k+1 2 of the possibilities output 1. Suppose L(x) = 0 and b = β so a < γ k ; then at least one upper mark is right of a and all k−1 2 lower marks are left of b, resulting in k+1 2 of the algorithm's possibilities outputting 0. Now as we continuously sweep a and b to the left, keeping b − a fixed, a passes each upper mark before b passes the succeeding lower mark, so at all times at least k+1 2 of the possibilities output 0.

Proof of (i):
q > 1.For i ∈ [k] define I i as the set of q successive integers starting with i and wrapping around to 1 when k is exceeded: , and → } alternates between odd and even numbers.
Our algorithm picks i ∈ [k] uniformly at random and for each i ∈ I i does an oracle query to see whether The intuition is that if I i were the whole set [k], then with certainty we would have , comparing i and i gives our best guess for L(x) based on the "limited view" provided by these oracle queries.About q of the I i sets are close enough to a to detect whether a or b is larger.Among the other k − q sets, about half get it right through luck.Thus, q + k−q 2 out of the k sets lead to correct output, which implies the advantage is q k .Careful case analysis is needed for the I i sets that wrap around.Here is the formal proof.
First, suppose L(x) = 1.Consider the greatest odd j ∈ [k] such that a ≥ γ j (which exists since a > γ 1 ).We have i > i if one of the following mutually exclusive events holds: There are q many type-(1) i's.If j > q then there are j−q 2 many type-(2) i's (1, 3, . . ., j − q − 1) and k−j 2 many type-(3) i's (j + 1, j + 3, . . ., k − 1).If j ≤ q then there are k−q 2 many type-(3) i's (j + 1, j + 3, . . ., j − q − 1 + k).Either way, i > i holds for at least q + k−q 2 = k+q 2 many i's, and hence, the probability of outputting 1 is at least We have i > i if one of the following mutually exclusive events holds: cc Amplification with One NP Oracle Query Page 13 of 47 3 There are q many type-(1) i's.If j > q then there are j−q−2 2 many type-(2) i's (2, 4, . . ., j − q − 2) and k−j+2 2 many type-(3) i's (j, j + 2, . . ., k).If j ≤ q then there are k−q 2 many type-(3) i's (j, j + 2, . . ., j − q − 2 + k).Either way, i > i holds for at least q + k−q 2 = k+q 2 many i's, and hence, the probability of outputting 0 is at least Our algorithm now picks one of these 2k possibilities uniformly at random: Thomas Watson cc a − b > Δ and a < η j +2 ; thus, b < η i for at least k−j 2 many odd i's (j + 1, j + 3, . . ., k − 1).Hence, the probability of outputting 1 is at least 2 many odd i's (1, 3, . . ., j − 1).Hence, the probability of outputting 0 is at least That concludes the formal proof, but here is an intuitive way to visualize what is happening: Call ζ i for odd i and η i for even i "upper marks," and call ζ i for even i and η i for odd i "lower marks," and assume for convenience all lower marks are in (−β, β).Suppose L(x) = 1 and b = −β so a > ζ 1 ; then at least one upper mark is left of a and all k lower marks are right of b, resulting in k + 1 of the algorithm's possibilities outputting 1.Now as we continuously sweep a and b to the right, keeping a − b fixed, a passes each upper mark (ζ i or η i ) before b passes the corresponding preceding lower mark (ζ i−1 or η i−1 respectively), so at all times at least k + 1 of the possibilities output 1. Suppose L(x) = 0 and b = β so a < η k ; then at least one upper mark is right of a and all k lower marks are left of b, resulting in k + 1 of the algorithm's possibilities outputting 0. Now as we continuously sweep a and b to the left, keeping b − a fixed, a passes each upper mark (ζ i or η i ) before b passes the corresponding succeeding lower mark (ζ i+1 or η i+1 respectively), so at all times at least k + 1 of the possibilities output 0.
3.1.4.Proof of (ii): q > 1.We retain the definition of I i from Section 3.1.2.Now we have separate cases for whether q is even or odd.The case q is even involves a natural combination of the ideas from Section 3.1.2and Section 3.1.3,but the case q is odd is more subtle.
Our algorithm picks i ∈ [k] uniformly at random, and with probability 1 2 each: Consider the greatest i ∈ I ≥,odd Consider the greatest i ∈ I ≥,even i ∪ I <,odd i such that the corresponding oracle query returns 1, or let i = i → if it does not exist.Consider the greatest i ∈ I ≥,odd i ∪ I <,even i such that the corresponding oracle query returns 1, or let which happens for k+q+1 2 many i's in the first bullet (1 and 2, 4, . . ., k − q + 1 and k − q + 2, k − q + 3, . . ., k) and k+q−1 2 many i's in the second bullet (1, 3, . . ., k − q and k − q + 2, k − q + 3, . . ., k).
Otherwise, consider the greatest odd j ∈ [k] such that a ≥ ζ j and the greatest even j ∈ [k] such that a ≥ η j , and note that j ∈ {j − 1, j + 1} since β > α − Δ.
3 Page 22 of 47 Thomas Watson cc 3.2.Separations.The relativized separations follow from the corresponding decision tree complexity separations: (iii) If q, k are even: BPP We prove (iii) in Section 3.2.1 and (iv) in Section 3.2.2; the arguments are similar in structure.Our proof of (iv) also works if q is even, but in that case the result is subsumed by (iii).The case q = 1, k = 2 of (iv) was proven in Watson ( 2020), but our proof is somewhat different even specialized to that case.
For completeness, in Section 3.2.3we explain the standard argument for translating these decision tree separations into relativized separations for the corresponding time-bounded complexity classes.See Vereshchagin (1999) for a general discussion of this phenomenon.
Let wt(•) refer to Hamming weight.Henceforth, fix the constants q and k, and assume q < k since otherwise there is nothing to prove.

Proof of (iii).
Define the partial function f : {0, 1} n → {0, 1} that interprets its input as (x, y) ∈ {0, 1} n/2 ×{0, 1} n/2 , such that (The valid inputs of this f are those (x, y) such that either wt(x) = wt(y) + 1 ≤ k 2 or wt(x) = wt(y) ≤ k 2 − 1.In the proof of the relativized separation, (x, y) will correspond to an oracle truth table, and we will only need to consider oracles whose truth tables are valid inputs of f .) The separation follows by taking δ = log −c n for any constant c.
Proof (of 3.2).Given (x, y), pick one of these k − 1 possibilities uniformly at random: The decision tree does not directly query any bits of (x, y), and the DNF has width i ≤ k 2 (it is the or over all i-subsets of either x's bits or y's bits, of the and of those bits), so the cost is k 2 .If f (x, y) = 1 with wt(x) = j and wt(y) = j − 1, then the probability of outputting 1 is j+((k/2−1)−(j−1)) k−1 since conditioned on picking x, the output is 1 iff i ≤ j, and conditioned on picking y, the output is 1 iff i ≥ j.Similarly, if f (x, y) = 0 with wt(x) = wt(y) = j, then the probability of outputting 1 is j+((k/2−1)−j) Proof (of Lemma 3.3).By the minimax principle, it suffices to show that for some distribution on valid inputs (x, y) to f , every cost-o(δn) P NP [q] -type decision tree T has advantage < q k + δ over a random input.Let T (x, y) denote the output produced after T receives the answers to its DNF queries.Let u be the leaf reached after seeing only 0's, and say u is labeled with DNFs (ϕ 1 , . . ., ϕ q ) and function out : {0, 1} q → {0, 1} (so if (x, y) leads to u then T (x, y) = out(ϕ 1 (x, y), . . ., ϕ q (x, y))).

Thomas Watson cc
We claim that from which it follows that We argue claim (1).Since the path to u queries o(δn) locations, with probability ≥ 1−o(kδ) > 1− δ 4 each of the 1's placed throughout v and w avoids these locations, in which case the first bullet holds in the definition of good.Fixing j and i in the second bullet, if we condition on ϕ i (v j−1 , w j−1 ) = 1 and choose an arbitrary term of ϕ i that accepts (v j−1 , w j−1 ), then since the term has width o(δn), with probability ≥ 1 − o(δ) the 1 that is placed to obtain v j from v j−1 avoids this term, in which case the term continues to accept (v j , w j−1 ) and so ϕ i (v j , w j−1 ) = 1.Thus, A union bound over j and i shows that the second bullet holds with probability ≥ 1 − o(kqδ) > 1 − δ 4 , so finally the two bullets hold simultaneously with probability > 1 − δ 2 .We argue claim (2).Condition on any particular good (v, w).We abbreviate the q-tuple (ϕ 1 (x, y), . . ., ϕ q (x, y)) as ϕ(x, y) ∈ {0, 1} q .Consider the sequence of k inputs (v 0 , w 0 ), (v 1 , w 0 ), (v 1 , w 1 ), (v 2 , w 1 ), . . .(like climbing a ladder but placing both feet on each rung).Each of these possibilities for (x, y) leads to u and thus T (x, y) = out(ϕ(x, y)).Also, the corresponding sequence of ϕ(x, y)'s is monotonically nondecreasing in each of the q coordinates.Thus, the sequence of inputs can be partitioned into segments of lengths say 0 , 1 , . . ., q (which sum to k) such that for the first 0 (x, y)'s in the sequence, ϕ(x, y) has weight 0 (hence T (x, y) is the same), and for the next 1 (x, y)'s in the sequence, ϕ(x, y) is the same weight-1 string (hence T (x, y) is the same), and so on.Since each segment alternates between 0-inputs and 1-inputs of f , we have T (x, y) = f (x, y) for at most i 2 ≤ i +1 2 inputs in the i th segment.
Thus, out of the k possibilities for (x, y) given (v, w), at most which is almost what we want.This issue can be fixed by observing that since k is even and q + 1 (the number of segments) is odd, at least one segment must have even length, in which case i 2 = i 2 .Thus, out of the k possibilities for (x, y) given (v, w), T (x, y) = f (x, y) holds for at most k 2 + q 2 of them, which gives (2).

Proof of (iv). Define the partial function
The separation follows by taking δ = log −c n for any constant c.
Proof (of Lemma 3.4).Given (x, y), pick one of these 2k possibilities uniformly at random: The decision tree does not directly query any bits of (x, y), and the DNF has width i ≤ k (it is the or over all i-subsets of either x's bits or y's bits, of the and of those bits), so the cost is k.If f (x, y) = 1 with wt(x) = j and wt(y) = j − 1, then the probability of outputting 1 is j+(k−(j−1))

2k
= 1 2 + 1 2 • 1 k since conditioned on picking x, the output is 1 iff i ≤ j, and conditioned on picking y, the output is 1 iff i ≥ j.The correctness argument is analogous if f (x, y) = 0.

Thomas Watson cc
Proof (of Lemma 3.5).By the minimax principle, it suffices to show that for some distribution on valid inputs (x, y) to f , every cost-o(δn) P NP [q] -type decision tree T has advantage < q k + δ over a random input.Let T (x, y) denote the output produced after T receives the answers to its DNF queries.Let u be the leaf reached after seeing only 0's, and say u is labeled with DNFs (ϕ 1 , . . ., ϕ q ) and function out : {0, 1} q → {0, 1} (so if (x, y) leads to u then T (x, y) = out(ϕ 1 (x, y), . . ., ϕ q (x, y))).
We generate the distribution on valid inputs (x, y) as follows.Let v 0 = w 0 ∈ {0, 1} n/2 be the all-0 string, and for i = 1, . . ., k obtain v i by flipping a uniformly random 0 of v i−1 to a 1, and obtain w i by flipping a uniformly random 0 of w i−1 to a 1. Pick a uniformly random j ∈ [k], and then let (x, y) be either the 1-input (v j , w j−1 ) or the 0-input (v j−1 , w j ) with probability 1 2 each.Let v denote (v 0 , . . ., v k ) and w denote (w 0 , . . ., w k ), and call (v, w) good iff: both inputs (v j , w j−1 ) and (v j−1 , w j ) lead to u, and r for each j ∈ [k − 1] and each i ∈ [q]: ϕ i (v j , w j+1 ) ≥ ϕ i (v j , w j−1 ) and ϕ i (v j+1 , w j ) ≥ ϕ i (v j−1 , w j ).
We claim that from which it follows that We argue claim (1).Since the path to u queries o(δn) locations, with probability ≥ 1 − o(kδ) > 1 − δ 4 each of the 1's placed throughout v and w avoids these locations, in which case the first bullet holds in the definition of good.Fixing j and i in the second bullet, if we condition on ϕ i (v j , w j−1 ) = 1 and choose an arbitrary term of ϕ i that accepts (v j , w j−1 ), then since the term has width o(δn), with probability ≥ 1 − o(δ) both of the 1's placed to obtain w j+1 from w j−1 avoid this term, in which case the term continues to accept (v j , w j+1 ) and so ϕ i (v j , w j+1 ) = 1.Thus, A union bound over j and i shows that the second bullet holds with probability ≥ 1 − o(kqδ) > 1 − δ 4 , so finally the two bullets hold simultaneously with probability > 1 − δ 2 .We argue claim (2).Condition on any particular good (v, w).We abbreviate the q-tuple (ϕ 1 (x, y), . . ., ϕ q (x, y)) as ϕ(x, y) ∈ {0, 1} q .Consider the sequence of k inputs (v 1 , w 0 ), (v 1 , w 2 ), (v 3 , w 2 ), (v 3 , w 4 ), . . .(climbing the ladder starting with the left foot).Each of these possibilities for (x, y) leads to u and thus T (x, y) = out(ϕ(x, y)).Also, the corresponding sequence of ϕ(x, y)'s is monotonically nondecreasing in each of the q coordinates.Thus, the sequence of inputs can be partitioned into segments of lengths say 0 , 1 , . . ., q (which sum to k) such that for the first 0 (x, y)'s in the sequence, ϕ(x, y) has weight 0 (hence T (x, y) is the same), and for the next 1 (x, y)'s in the sequence, ϕ(x, y) is the same weight-1 string (hence T (x, y) is the same), and so on.Since each segment alternates between 0-inputs and 1-inputs of f , we have T (x, y) = f (x, y) for at most i 2 ≤ i +1 2 inputs in the i th segment.Similarly, the sequence of k inputs (v 0 , w 1 ), (v 2 , w 1 ), (v 2 , w 3 ), (v 4 , w 3 ), . . .(climbing the ladder starting with the right foot) can be partitioned into segments of lengths say 0 , 1 , . . ., q such that T (x, y) = f (x, y) for at most i +1 2 inputs in the i th segment.Thus, out of the 2k possibilities for (x, y) given (v, w), at most This issue can be fixed using the following observation.Since there is only one string in {0, 1} q of weight 0, T (x, y) must actually be the same for all 0 + 0 inputs in the union of the 0 th segments from the two sequences.Since the number of 0-inputs and the number of 1-inputs in this union differ by at most 1, we have T (x, y) = f (x, y) for at most 0 + 0 +1 2 of these inputs.Now, 3 Page 28 of 47 Thomas Watson cc out of the 2k possibilities for (x, y) given (v, w), T (x, y) = f (x, y) holds for at most 0 + 0 +1 2 Since this count is an integer, it is in fact at most k + q, which gives (2).(Alternatively, the + 1 2 can be removed using a similar observation for the q th segments.)

Decision tree separations imply relativized separations.
To illustrate this, we just consider the case q = 1, k = 2, but exactly the same approach works for all cases, as well as for the separations in Theorem 1.2 and Theorem 1.3.
We showed that BPP . Now we explain how to construct an oracle language O : {0, 1} * → {0, 1} such that BPP O .For all even N , let f N : {0, 1} N → {0, 1} be the partial function from Section 3.2.2 with For any O : {0, 1} * → {0, 1}, let O n : {0, 1} n → {0, 1} be its restriction to input length n, and also interpret this truth table as a bit string O n ∈ {0, 1} N of length N = 2 n indexed by the elements of {0, 1} n .Say that O is valid iff O n is a valid input to f N for every n.For any valid O, define the unary language L O : where the quantifiers are over valid O.
To see O , note that an algorithm for L O on input 1 n can run the BPP 1/2 -type decision tree for f N (from the proof of Lemma 3.4) on input O n : Denoting the halves of O n as (x, y) ∈ {0, 1} N/2 × {0, 1} N/2 , pick one of these 4 possibilities uniformly at random: We enumerate the (M, M , c) triples in an arbitrary order, defining O n for various input lengths n as we go along (finitely many at a time).For each (M, M , c), we select some n such that O n has not been defined yet, and we use it to diagonalize against (M, M , c).For all n = n such that O n has not been defined yet but running M (1 n ) with M (for the NP O oracle) might cause a query to a bit of O n , we define O n to be an arbitrary valid input to f N (where N = 2 n ).Now when we run M (1 n ) with M , both algorithms have oracle access to the bits of O n , and all other bits of O they might access have already been fixed.
We claim that if M (1 n ) with M outputs f N (O n ) with advantage 1 2 + n −c for all valid O n , then we can turn the computation into a BPP

NP[1]
1/2+n −c -type decision tree for f N : First, the decision tree samples the same random string as M does.Then it adaptively queries bits of O n as M does.Then when M produces z and out, the decision tree uses the same out and forms a DNF ϕ which evaluates M (z) as a function of O n -for each possible witness, the computation of M (z) is a deterministic decision tree that queries bits of O n , and it is a standard fact that the disjunction of these trees (over all possible witnesses) can be expressed as a DNF.(Each term in ϕ corresponds to a root-to-leaf path that outputs 1 in one of these trees.Each positive literal is a query M makes to O n that returns 1, and each negative literal is a query M makes to O n that returns 0.) Since M and M run in time poly(n), this BPP 1/2+n −c -type decision tree would have cost polylog(N ), but Lemma 3.5 says such a tree must have cost Ω(N/ log c N ), which is a contradiction if n is large enough.Thus, there exists an We fix this choice of O n and move on to the next triple (M, M , c).

One-sided error
We now prove Theorem 1.2, restated here for convenience.
>1/2 relative to an oracle.We prove the inclusions (i) and (ii) in Section 4.1 and the separation (iii) in Section 4.2.4.1.Inclusions.We prove (i) in Section 4.1.1 and then (ii) in Section 4.1.2.

Proof of (i).
For some constant c we have L ∈ RP

NP[1]
1/2+n −c , witnessed by a polynomial-time randomized algorithm M (taking input x and coin tosses s ∈ {0, 1} r ) and a language L ∈ NP.For an arbitrary constant d, we wish to show L ∈ RP Fix an input x.The first step is to sample a sequence of m = O(n 2c+d ) many independent strings s 1 , . . ., s m ∈ {0, 1} r , so if L(x) = 1 then with probability ≥ 1 − 2 −n d , the sequence is good in the sense that on input x, M still has advantage strictly greater than 1 2 when its coin tosses are chosen uniformly from the multiset {s 1 , . . ., s m }.Then we design a polynomial-time deterministic algorithm which, given s 1 , . . ., s m , makes one NP oracle query and outputs 1 if L(x) = 1 and s 1 , . . ., s m is good, and outputs 0 if Henceforth, fix a sequence s 1 , . . ., s m , and let z h and out h : {0, 1} → {0, 1} be the query string and truth table produced by M s h (x) (so the output is out h (L (z h ))).We assume w.l.o.g. that out h is nonconstant and is hence either identity or negation.
If identity is more common among out 1 , . . ., out m , then our algorithm makes an NP oracle query to test whether there exists an h such that out h = id and L (z h ) = 1, and outputs 1 if so and 0 otherwise.If L(x) = 1 and s 1 , . . ., s m is good, then there must exist such an h (since the set of h's for which M s h (x) outputs 1 has size > m 2 and so must intersect the set of h's for which out h = id).If L(x) = 0 then there is no such h (since otherwise M (x) would output 1 with positive probability).
If negation is at least as common as identity among out 1 , . . ., out m , then our algorithm makes an NP oracle query to test whether there does not exist an h such that out h = neg and L (z h ) = 0 (a witness for the nonexistence of such an h consists of a witness for L (z h ) = 1 for each h such that out h = neg), and outputs 0 if so and 1 otherwise.If L(x) = 1 and s 1 , . . ., s m is good, then there must exist such an h (since the set of h's for which M s h (x) outputs 1 has size > m 2 and so must intersect the set of h's for which out h = neg).If L(x) = 0 then there is no such h (since otherwise M (x) would output 1 with positive probability).

Proof of (ii). Let
(the argument is very similar to (i)), then later we show how to strengthen the q = 1 case using a trick from Chang & Purini (2008).
For some constant c we have L ∈ RP

NP[1]
n −c , witnessed by a polynomial-time randomized algorithm M (taking input x and coin tosses s ∈ {0, 1} r ) and a language L ∈ NP.For an arbitrary constant d, we wish to show L ∈ RP Fix an input x.The first step is to sample a sequence of m = O(n c+d ) many independent strings s 1 , . . ., s m ∈ {0, 1} r , so if L(x) = 1 then with probability ≥ 1 − 2 −n d , the sequence is good in the sense that M still has advantage strictly greater than 0 when its coin tosses are chosen uniformly from the multiset {s 1 , . . ., s m }.
Then we design a polynomial-time randomized algorithm which, given s 1 , . . ., s m , makes q nonadaptive NP oracle queries and outputs 1 with probability ≥ q 2 if L(x) = 1 and s 1 , . . ., s m is good, and always outputs 0 if L(x) = 0. Hence, over the random s 1 , . . ., s m and the other randomness of our algorithm, Henceforth, fix a sequence s 1 , . . ., s m , and let z h and out h : {0, 1} → {0, 1} be the query string and truth table produced by M s h (x) (so the output is out h (L (z h ))).We assume w.l.o.g. that out h is nonconstant and is hence either identity or negation.
If q = 2 then our algorithm does the "id" NP oracle query (∃ h : out h = id and L (z h ) = 1 ?) and the "neg" NP oracle query (¬∃ h : out h = neg and L (z h ) = 0 ?).These two queries tell us whether there exists an h for which M s h (x) outputs 1 (which is the case if L(x) = 1 and s 1 , . . ., s m is good), so we output 1 if so and 0 otherwise.
If q = 1 then our algorithm picks one of the two queries with probability 1 2 each, and outputs 1 iff the result of that query indicates the existence of an h for which M s h (x) outputs 1.If L(x) = 1 and s 1 , . . ., s m is good, then at least one of the two queries will cause us to output 1.
To strengthen the q = 1 result to RP 1/2 , suppose the bit length of witnesses for L is n b , and then use d = b + 1 and consider the following algorithm: Pick uniformly random h ∈ [m] and w ∈ {0, 1} n b ; if out h = id and w witnesses L (z h ) = 1, then output 1, otherwise do the "id" query with probability 1 2 − 2 −n d and do the "neg" query with probability 1 2 + 2 −n d (and output 1 iff the query indicates the existence of an h for which M s h (x) outputs 1).If L(x) = 0, then this still always outputs 0. If L(x) = 1 and s 1 , . . ., s m is good, then at least one of the following holds.
r There is an h with out h = id and L (z h ) = 1, in which case we find one with probability ≥ in the first phase and thus output 1 with probability ≥ 2 2 + 2 −n d because of the "id" query.r There is an h with out h = neg and L (z h ) = 0, in which case we output 1 with probability ≥ 1 2 + 2 −n d because of the "neg" query.
Either way, overall we have

Separation: Proof of (iii).
We prove the corresponding decision tree complexity separation RP >1/2 ; the relativized separation follows routinely from this by the same approach as in Section 3.2.3.
Let wt(•) refer to Hamming weight.Define the partial function for every δ(n).The separation follows by taking δ = log −c n for any constant c.
This has cost 1 (since the or function is a width-1 DNF), and it outputs 1 with probability 1 2 if f (x, y) = 1 and with probability 0 if f (x, y) = 0.

Thomas Watson cc
Proof (of Lemma 4.3).By the minimax principle, it suffices to show that for some distribution on 1-inputs (x, y) to f , every costo(δn) P NP [1] -type decision tree T has either P[T (x, y) = 1] < 1 2 + δ over this distribution or T (x, y) = 1 for some 0-input (x, y), where T (x, y) denotes the output produced after T receives the answer to its DNF query.Let u be the leaf reached after seeing only 0's, and say u is labeled with DNF ϕ and function out : {0, 1} → {0, 1} (so if (x, y) leads to u then T (x, y) = out(ϕ(x, y))).W.l.o.g., out is nonconstant and ϕ contains no terms with multiple positive literals from x or from y, since such terms would never accept a valid input to f .We generate the distribution on 1-inputs (x, y) as follows.With probability 1 2 let x = y = 0 n/2 , and with probability 1 2 let x and y be independent uniformly random weight-1 strings.If out = id then either ϕ has a term with no positive literals, in which case some 0-input leads to u and is accepted by ϕ, or every term has a positive literal, in which case 0 n leads to u and is rejected by ϕ and so P[T (x, y) = 1] ≤ P[(x, y) = 0 n ] = 1 2 < 1 2 + δ.Now assume out = neg and there is no 0-input that leads to u and is rejected by ϕ.Note that if a 0-input (0 n/2 , y) leads to u and we choose an arbitrary term of ϕ that accepts (0 n/2 , y), then with probability ≥ 1 − o(δ) the 1 that is placed in a uniformly random weight-1 x avoids both this term and all the bits queried on the path to u, in which case (x, y) continues to lead to u and be accepted by that term and hence by ϕ, so T (x, y) = 0. Thus, P[T (x, y) = 1] ≤ 1 2 + 1 2 P T (x, y) = 1 wt(x) = wt(y) = 1 ≤ 1 2 + 1 2 P (0 n/2 , y) does not lead to u wt(y) = 1 +P T (x, y) = 1 wt(x) = wt(y) = 1 and (0 n/2 , y) leads to u ≤ 1 2 + 1 2 (o(δ) + o(δ)) < 1 2 + δ.
cc Amplification with One NP Oracle Query Page 35 of 47 3

Zero-sided error
We now prove Theorem 1.3, restated here for convenience.
Moreover, the "q/k >" in the inclusion subscripts can be improved to "q/k" if q < k and k ≥ 3.
We prove the inclusions (i) and (ii) in Section 5.1 and the separations (iii) in Section 5.2.

Inclusions. Straightforwardly generalizing the proof that ZPP NP[1] >0
⊆ ZPP in Chang & Purini (2008) yields (i), but we take a different tack by showing in Section 5.1.1 that (i) follows directly from Theorem 1.2.We prove (ii) from first principles in Section 5.1.2;our proof for the case k = 1 is equivalent to the one in Chang & Purini (2008), but we include it for completeness.by some algorithm M 2 .

Proof of (i). Let L ∈ ZPP
We let each of these four M -algorithms refer to the entire computation, including the NP oracle queries, which we elide for convenience.(Note that M i does not mean "complement of M i "-it is a different algorithm.)We assume M 2 and M 2 have advantage ≥ 1 − 2 −n d for an arbitrary constant d.Furthermore, we assume Thomas Watson cc all four algorithms have been modified to output ⊥ instead of 0, and M 1 and M 2 have been modified to output 0 instead of 1.
by running M 1 or M 1 with probability 1 2 each.
If q = 2: L ∈ ZPP by running M 1 and M 1 , and if one of them outputs a bit, outputting that bit or ⊥ otherwise.
by running M 2 and M 2 , and if one of them outputs a bit, outputting that bit or ⊥ otherwise.
3/4> by running M 1 and M 2 with probability 1 2 , or M 2 and M 1 with probability 1 2 , and if one of them outputs a bit, outputting that bit or ⊥ otherwise.This falls slightly short of our promise of showing L ∈ ZPP , but that can be fixed by noting that the proof of Theorem 1.2 actually shows that M 1 and M 1 can have advantage ≥ 1 2 + 2 −n e for some constant e depending on L. Then taking d ≥ e ensures we get advantage ≥ 1 2 1 2 + 2 −n e + 1 2 1 − 2 −n d ≥ 3 4 .

NP [q]
q/k> ; the "moreover" part follows by exactly the same trick (due to Chang & Purini (2008)) for strengthening RP 1/2 , which is described in Section 4.1.2.For some constant c we have L ∈ ZPP

NP[1]
1/(k+1)+n −c , witnessed by a polynomial-time randomized algorithm M (taking input x and coin tosses s ∈ {0, 1} r ) and a language L ∈ NP.For an arbitrary constant d, we wish to show L ∈ ZPP NP [q] q/k−2 −n d .Fix an input x.The first step is to sample a sequence of m = O(n 2c+d ) many independent strings s 1 , . . ., s m ∈ {0, 1} r , so with probability ≥ 1 − 2 −n d , the sequence is good in the sense that on input x, M still has advantage strictly greater than 1 k+1 when its coin tosses are chosen uniformly from the multiset {s 1 , . . ., s m }.Then we design a polynomial-time randomized algorithm which, given a good sequence, outputs L(x) with probability ≥ q k after making q nonadaptive NP oracle queries, and which has zero-sided error for all sequences (good and bad).Hence, over the random s 1 , . . ., s m and the other randomness of our algorithm, P[output is L(x)] ≥ P output is L(x) s 1 , . . ., s m is good − P[s 1 , . . ., s m is bad] Henceforth, fix a good sequence s 1 , . . ., s m , and let z h and out h : {0, 1} → {0, 1, ⊥} be the query string and truth table produced by M s h (x) (so the output is out h (L (z h ))).We assume w.l.o.g. that out h is nonconstant.If there is an h such that out h ∈ {id, neg}, then our algorithm simply uses the NP oracle to evaluate L (z h ) and then outputs out h (L (z h )) = L(x).Otherwise, each out h is one of the four functions out ab (for ab ∈ {0, 1} 2 ) that maps a to b and 1 − a to ⊥: For each ab ∈ {0, 1} 2 consider the "ab" query, which asks whether H ∩ H ab = ∅: ∃ h : out h = out ab and L (z h ) = a ?If a = 1 then the "ab" query can be expressed as an NP oracle query: a witness consists of an h with out h = out ab and a witness for L (z h ) = 1.If a = 0 then the "ab" query can be expressed as the negation of an NP oracle query: a witness for the nonexistence β > α − Δ: We handle the case β ≤ α − Δ later, in a different way.The assumption β > α − Δ ensures the ζ and η marks are perfectly interspersed (as shown in the figure in Section 3.1.3),which is essential for the algorithm we now describe.For this case, we form ζ 1 , . . ., ζ k and η 1 , . . ., η k into one big cycle, rather than two separate cycles.Thus, when I i "wraps 3 Page 18 of 47 Thomas Watson cc

)
corresponding oracle query returns 1, or let i = i → if it does not exist.Consider the greatest i ∈ I ≥,even i ∪ I <,odd i such that the corresponding oracle query returns 1, or let i = i → if it does not exist.Output 1 if i > i , or 0 if i > i .− k.For each i ∈ I i do an oracle query to see whether b

cc
Amplification with One NP Oracle Query Page 29 of 47 3 r ask the NP O oracle whether wt(x) ≥ 1, and output the same answer r ask the NP O oracle whether wt(x) ≥ 2, and output the same answer r ask the NP O oracle whether wt(y) ≥ 1, and output the opposite answer r ask the NP O oracle whether wt(y) ≥ 2, and output the opposite answerTo achieve L O ∈ BPP NP[1] 1/2+n −cO for every constant c, we design a valid O such that for every polynomial-time randomized algorithm M , every polynomial-time nondeterministic algorithm M , and every constant c, L O is not solved with advantage 1 2 + n −c by running M with oracle access to O and one query to the language decided by M with oracle access to O.

3
Page 00 out 01 out 10 out 11 Now [m] is partitioned into four sets H 00 ∪ H 01 ∪ H 10 ∪ H 11 whereH ab = {h ∈ [m] : out h = out ab }.Let H = {h ∈ [m] : M s h (x) outputs L(x)} and note that |H| > m k+1 by the assumption that s 1 , . . ., s m is good.If h ∈ H ∩ H ab then M s h (x) outputs b, so if we detect that H ∩ H ab = ∅ then we can safely output b.Note that H ⊆ H 0b ∪ H 1b for b = L(x).