Quantum search with an unknown number of marked items #
Grover's algorithm (Cslib.Quantum.grover) finds one of t marked items among N with
O(√(N / t)) queries when t is known, but a fixed number of iterations can fail badly for an
unknown t. Boyer, Brassard, Høyer and Tapp choose the number of iterations at random
Boyer, Brassard, Høyer, Tapp. This file formalizes their analysis in
the query model of Cslib.Quantum.run, the resulting fixed-budget search algorithm, and an
algorithm computing OR_N with error 1/3 and O(√N) queries.
Shared Grover analysis. The general marked-weight analysis is provided by
CslibFrontier.Computability.QueryComplexity.Quantum.Grover. Let θ = searchAngle N t, so
sin² θ = t / N.
After k queries every marked item has amplitude sin((2k + 1) θ) / √t and every other item
cos((2k + 1) θ) / √(N - t) (Cslib.Quantum.run_grover_of_weight), so a marked item is measured
with probability sin²((2k + 1) θ) (Cslib.Quantum.sum_regProb_run_grover).
A random number of iterations. If the number j of iterations is uniform below m, a marked
item is found with probability P_m = 1/2 - sin(4mθ) / (4m sin 2θ)
(Cslib.Quantum.sum_sin_sq_div, from the cosine sum Cslib.Quantum.two_mul_sin_mul_sum_cos), so
P_m ≥ 1/4 when m ≥ 1 / sin 2θ (Cslib.Quantum.le_sum_sin_sq). If N ≤ m², then
m ≥ 1 / sin 2θ for every 1 ≤ t < N (Cslib.Quantum.le_mul_sin_two_mul_searchAngle), and
t = N succeeds with certainty.
The algorithm. Cslib.Quantum.randomGrover realizes the random choice inside the query model:
its workspace holds a classical register j < m, prepared in uniform superposition
(Cslib.Quantum.randomGroverInit); on the slice where the register holds j, Grover's algorithm
runs j iterations and is then parked (Cslib.Quantum.controlled, Cslib.Quantum.park). Every
outcome probability is then the average over j (Cslib.Quantum.sum_regProb_run_randomGrover).
With m = ⌊√N⌋ + 1 it makes ⌊√N⌋ ≤ √N queries from a unit initial state and measures a marked
item with probability at least 1/4 on every input with at least one marked item
(Cslib.Quantum.randomGrover_search), whatever their number.
Deciding OR_N. With the larger range m = 4 (⌊√N⌋ + 1) (Cslib.Quantum.orRange), so that
m sin 2θ ≥ 4, a marked item is found with probability at least 7/16. A stage
(Cslib.Quantum.orStage) runs randomGrover and then checks the measured index with one more
query (Cslib.Quantum.check), so it accepts with exactly the success probability P, which is 0
on the all-zero input. Running the stage twice (Cslib.Quantum.orSearch, Cslib.Quantum.twice)
and accepting when either check succeeds gives acceptance probability 1 - (1 - P)²
(Cslib.Quantum.measureProb_run_orSearch): 0 if OR_N(x) = 0, and at least
1 - (9/16)² > 2/3 if OR_N(x) = 1. So 8 (⌊√N⌋ + 1) ≤ 8√N + 8 queries compute OR_N with
error at most 1/3 (Cslib.Quantum.orSearch_spec), matching the polynomial-method lower bound
N ≤ 16 T² (Cslib.Quantum.card_le_sixteen_mul_sq_of_threshold_one_right) up to a constant.
Source mapping (numbering of arXiv:quant-ph/9605034v1). The closed form is equation (3) of §3,
where k_j and ℓ_j are the amplitudes of a marked and an unmarked item after j iterations and
sin² θ = t / N; here it is proved for every 0 ≤ t ≤ N. Queries are counted as in
Cslib.Quantum.run, one application of the phase oracle per Grover iteration, whereas BBHT count
two table look-ups per iteration with a bit oracle (§3.1). In §4, Lemma 1 is the sum
∑_{j < m} cos(α + 2βj), of which two_mul_sin_mul_sum_cos is the special case α = β stated
there, multiplied out by 2 sin α. Lemma 2 is sum_sin_sq_div, and its bound P_m ≥ 1/4 for
m ≥ 1 / sin 2θ follows from le_sum_sin_sq. BBHT then search with a range m growing by a
factor λ = 6/5 after each failed round, observe and check the outcome, and prove an expected
O(√(N / t)) time for 1 ≤ t ≤ 3N/4 (Theorem 3); they dispose of t > 3N/4 by classical
sampling and of t = 0 by a time-out. Here the range is fixed, which gives a single algorithm
with a fixed query budget ⌊√N⌋, and its success probability is bounded for every t ≥ 1 at
once, including t > 3N/4. This fixed-budget packaging, the bound for 1 ≤ t < N from
c² N ≤ m², the realization of the random j by a classical register in the workspace, and the
decision algorithm for OR_N (a check query and two independent stages, with its constants) are
not from the source; they are original here.
Main definitions #
Cslib.Quantum.randomGrover,Cslib.Quantum.randomGroverInit: search with a random number of Grover iterations belowm.Cslib.Quantum.orSearch,Cslib.Quantum.orSearchInit,Cslib.Quantum.orAccept: the decision algorithm forOR_N.
Main results #
Cslib.Quantum.sum_regProb_run_grover: its success probabilitysin²((2k + 1) θ).Cslib.Quantum.two_mul_sin_mul_sum_cos,Cslib.Quantum.sum_sin_sq_div,Cslib.Quantum.le_sum_sin_sq: Lemmas 1 and 2 of Boyer, Brassard, Høyer, Tapp.Cslib.Quantum.sum_regProb_run_randomGrover: the success probability ofrandomGrover.Cslib.Quantum.le_sum_regProb_run_randomGrover: ifc² N ≤ m², a marked item is found with probability at least1/2 - 1/(4c).Cslib.Quantum.randomGrover_search:⌊√N⌋queries find a marked item with probability at least1/4, for every number of marked items.Cslib.Quantum.orSearch_spec:8 (⌊√N⌋ + 1)queries computeOR_Nwith error at most1/3.
References #
The success probability of Grover's algorithm with any number of marked items Boyer,
Brassard, Høyer, Tapp: after k queries, a marked item is measured
with probability sin²((2k + 1) θ), where sin² θ = t / N for t marked items.
Random iteration counts #
The average success probability of a random number of iterations Boyer, Brassard, Høyer,
Tapp (Lemma 2): for j uniform below m, a marked item is found
with probability P_m = 1/2 - sin(4mθ) / (4m sin 2θ), where sin² θ = t / N.
A lower bound on the average success probability Boyer, Brassard, Høyer,
Tapp (Lemma 2): if sin 2θ > 0, then
∑_{j < m} sin²((2j + 1) θ) ≥ m / 2 - 1 / (4 sin 2θ). In particular P_m ≥ 1/4 when
m ≥ 1 / sin 2θ.
Searching with an unknown number of marked items #
The isometries of search with a random number of Grover iterations below m, after
Boyer, Brassard, Høyer, Tapp: a classical register j < m holds the
number of iterations; on the slice where it holds j, Grover's algorithm runs j iterations and
is then parked.
The initial state of randomGrover: the uniform superposition of the query indices, with
control bit 1, and of the iteration counts j < m.
After T ≥ m - 1 queries, the slice of randomGrover where the register holds j is the
state of Grover's algorithm after j queries, parked and scaled by 1 / √m.
The success probability of a random number of iterations: after T ≥ m - 1 queries,
randomGrover measures a marked item with probability
(1 / m) ∑_{j < m} sin²((2j + 1) θ), the average over j < m of the success probability of j
Grover iterations.
Quantum search with an unknown number of marked items Boyer, Brassard, Høyer,
Tapp: if c² N ≤ m² with c > 0, then on every input with at least
one marked item, randomGrover measures a marked item with probability at least 1/2 - 1/(4c)
after m - 1 queries.
Quantum search with an unknown number of marked items in ⌊√N⌋ queries Boyer, Brassard,
Høyer, Tapp: with iteration counts below ⌊√N⌋ + 1, randomGrover
starts from a unit state, makes ⌊√N⌋ ≤ √N queries, and on every input with at least one marked
item measures a marked item with probability at least 1/4.
Deciding OR_N with error 1/3 #
The range of iteration counts for deciding OR_N: m = 4 (⌊√N⌋ + 1), so that 16 N ≤ m².
One stage for OR_N: randomGrover with range orRange N for orRange N - 1 queries, then
a check of the measured index, which writes its queried bit into the control bit. It makes
orRange N queries.
The algorithm for OR_N: two independent stages (Cslib.Quantum.twice), making
2 orRange N queries.
A stage accepts with the average success probability of randomGrover.
The initial state of orSearch is a unit vector.
The acceptance probability of orSearch: 1 - (1 - P)², where P is the average success
probability of randomGrover with range orRange N.
Deciding OR_N with O(√N) queries after Boyer, Brassard, Høyer,
Tapp: orSearch accepts every input x with probability within
1/3 of OR_N(x). It accepts the all-zero input with probability 0, and every other input with
probability at least 1 - (9/16)².
An O(√N)-query algorithm for OR_N with error 1/3, matching the polynomial-method
lower bound N ≤ 16 T² up to a constant: orSearch starts from a unit state, makes
8 (⌊√N⌋ + 1) ≤ 8 √N + 8 queries, and accepts every input x with probability within 1/3 of
OR_N(x).