Documentation

CslibFrontier.Computability.Complexity.Classes.BQP.Amplification

Error reduction for BQP #

The error 1 / 3 in the definition of BQP (Cslib.Complexity.BQP) can be made exponentially small: A ∈ BQP enc exactly when for every polynomial q some uniform family accepts members with probability at least 1 - 2^{-q(n)} and other instances with probability at most 2^{-q(n)}, where n is the length of the encoded instance (Cslib.Complexity.mem_BQP_iff_forall_errorExponent).

This is the majority-vote error reduction of BPP (Cslib.Complexity.mem_BPP_iff_forall_decidesWithErrorExponent), carried out inside a quantum circuit, since acceptance is the measurement of a single qubit at the end. The threshold vote of a family (Cslib.Quantum.UniformCircuitFamily.threshold) runs k copies of the circuit side by side and reversibly decides whether more than t of them accept. On inputs of length n its register holds the input, k blocks of the original width w, and the ancillas of a threshold counter:

  1. CNOT gates copy the input into each block (Cslib.Quantum.Amplify.copyCodes);
  2. each block runs the original circuit, with its qubit numbers shifted (Cslib.Quantum.Amplify.copiesCodes);
  3. a reversible counter computes whether more than t of the blocks' first qubits are one (Cslib.Quantum.Counter.codes);
  4. three CNOT gates swap that answer into qubit 0 (Cslib.Quantum.GateCode.swapCodes).

The copies act on disjoint blocks, so their measurement outcomes are independent (Cslib.Quantum.Circuit.matrix_flatMap_mapWires), and the classical steps permute the outcomes. The acceptance probability of the threshold vote is therefore the probability that more than t of k independent trials succeed, each with the original acceptance probability (Cslib.Quantum.UniformCircuitFamily.acceptProb_threshold). The amplified family (Cslib.Quantum.UniformCircuitFamily.amplify) is the strict majority k = 2 r, t = r. The exponential-moment bound Cslib.sum_prod_le_of_card_filter_le makes its error at most (8 / 9) ^ r, and r = 6 q gives 2^{-q}. Other thresholds amplify any constant gap, also away from 1 / 2 (Cslib.Complexity.mem_BQP_of_gap).

Main definitions #

Main results #

The argument is the standard one; no source locator is claimed for it. BQP itself follows Bernstein, Vazirani and Arora, Barak (see Cslib.Complexity.BQP).

References #

CNOT gates copying the first n qubits into the blocks 1, …, k of width w.

The circuit gs on each of the blocks 1, …, k of width w.

The first ancilla of the counter, after the input block and k copies of width w.

The register width of the threshold circuit: the blocks and the counter's ancillas, t + 1 levels for each of its k + 1 stages.

The counter's qubit that reads whether more than t of the k copies accept.

The threshold circuit: copy the input of length n into k blocks of width w, run the circuit gs on each, count the blocks whose first qubit is one, and swap into qubit 0 whether more than t of them are.

theorem Cslib.Quantum.Amplify.base_eq (w k : ℕ) :
base w k = k * w + w
theorem Cslib.Quantum.Amplify.block_lt {w k j i : ℕ} (hj : j < k) (hi : i < w) :
i + (j + 1) * w < base w k
def Cslib.Quantum.Amplify.blocks {m : ℕ} (w k t : ℕ) (hm : m ≤ w) :
Fin k × Fin m ↪ Fin (width w k t)

The first m ≤ w qubits of each of the blocks 1, …, k of the threshold register.

@[simp]
theorem Cslib.Quantum.Amplify.blocks_apply_val {w k t m : ℕ} (hm : m ≤ w) (p : Fin k × Fin m) :
↑((blocks w k t hm) p) = ↑p.2 + (↑p.1 + 1) * w
theorem Cslib.Quantum.Amplify.block_le_width {w k t j : ℕ} (hj : j < k) :
(j + 1) * w + w ≤ width w k t
def Cslib.Quantum.Amplify.block {w k t m : ℕ} (hm : m ≤ w) (j : Fin k) :
Fin m ↪ Fin (width w k t)

The first m ≤ w qubits of block j of the threshold register.

theorem Cslib.Quantum.Amplify.block_apply {w k t m : ℕ} (hm : m ≤ w) (j : Fin k) (i : Fin m) :
(block hm j) i = (blocks w k t hm) (j, i)

The classical steps #

theorem Cslib.Quantum.Amplify.isClassical_copyCodes {n w k N : ℕ} (hn : n ≤ w) (hN : base w k ≤ N) :

The CNOT layer is well formed on any register that contains all the copy blocks.

theorem Cslib.Quantum.Amplify.readBit_classicalRun_copyCodes {n w k N : ℕ} (hn : n ≤ w) (hN : base w k ≤ N) (X : Fin N → Bool) (p : ℕ) :
readBit (GateCode.classicalRun (copyCodes n w k) X) p = if ∃ j < k, ∃ i < n, p = i + (j + 1) * w then readBit X p ^^ readBit X (p % w) else readBit X p

In each copy block the CNOT gates XOR the first n source bits into the destination. All other bits retain their initial values. The destination may contain arbitrary data.

theorem Cslib.Quantum.Amplify.classicalRun_copyCodes_comp_block {n w k t m : ℕ} (hn : n ≤ m) (hm : m ≤ w) {x : List Bool} (hx : x.length ≤ n) (j : Fin k) :

After the copy step every block holds the input: started from the input x of length n ≤ m ≤ w, the first m qubits of each block read x.

theorem Cslib.Quantum.Amplify.readBit_classicalRun_copyCodes_of_base_le {n w k t : ℕ} (hn : n ≤ w) {x : List Bool} (hx : x.length ≤ n) {c : ℕ} (hc : base w k ≤ c) :

The copy step keeps the counter's ancillas zero: started from the input x of length n ≤ w, the qubits from base w k on read zero.

theorem Cslib.Quantum.Amplify.isClassical_counter_swap {w k t : ℕ} (hw : 0 < w) :
GateCode.IsClassical (width w k t) (Counter.codes (base w k) (t + 1) (fun (s : ℕ) => (s + 1) * w) k ++ GateCode.swapCodes (answer w k t))
theorem Cslib.Quantum.Amplify.readBit_classicalRun_counter_swap {w k t : ℕ} (hw : 0 < w) (Y : Fin (width w k t) → Bool) (hY : ∀ (p : ℕ), base w k ≤ p → readBit Y p = false) :
readBit (GateCode.classicalRun (Counter.codes (base w k) (t + 1) (fun (s : ℕ) => (s + 1) * w) k ++ GateCode.swapCodes (answer w k t)) Y) 0 = decide (t < Counter.count Y (fun (s : ℕ) => (s + 1) * w) k)

The classical steps vote by threshold: on a register whose qubits from the counter on are zero, the counter and the swap leave in qubit 0 whether more than t of the blocks' first qubits are one.

The parallel copies #

theorem Cslib.Quantum.Amplify.ofCodes_copiesCodes {w k t m : ℕ} (hm : m ≤ w) {gs : List GateCode} (hgs : ∀ g ∈ gs, GateCode.WellFormed m g) :
theorem Cslib.Quantum.Amplify.pairwise_block {w k t m : ℕ} (hm : m ≤ w) :
List.Pairwise (fun (e e' : Fin m ↪ Fin (width w k t)) => ∀ (i i' : Fin m), e i ≠ e' i') (List.map (block hm) (List.finRange k))

The threshold measurement #

theorem Cslib.Quantum.Amplify.sum_accepting_counter_swap {w k t m : ℕ} (hm : m ≤ w) (hm0 : 0 < m) {X : Fin (width w k t) → Bool} (hX : ∀ (c : ℕ), base w k ≤ c → readBit X c = false) {M : Type u_1} [AddCommMonoid M] (F : (Fin k → Fin m → Bool) → M) :
(∑ Y : Fin (width w k t) → Bool, if GateCode.classicalRun (Counter.codes (base w k) (t + 1) (fun (s : ℕ) => (s + 1) * w) k ++ GateCode.swapCodes (answer w k t)) Y ∈ accepting (width w k t) then if AgreeOff (blocks w k t hm) Y X then F fun (j : Fin k) => Y ∘ ⇑(block hm j) else 0 else 0) = ∑ u : Fin k → Fin m → Bool with t < {j : Fin k | u j ⟨0, hm0⟩ = true}.card, F u

The threshold measurement: on a register that is zero from the counter on, the counter and the swap accept exactly when more than t of the blocks' first qubits are one. So summing a function of the blocks' contents over the accepted outcomes that agree with X off the blocks is summing it over the blocks' contents with more than t ones among their first qubits.

Acceptance probability of the threshold circuit #

theorem Cslib.Quantum.acceptProb_threshold_codes {n w k t : ℕ} {gs : List GateCode} (hw : 0 < w) (hn : n ≤ w) (hgs : ∀ g ∈ gs, GateCode.WellFormed w g) (x : List Bool) (hx : x.length = n) :
acceptProb (Amplify.width w k t) (Amplify.codes n w k t gs) x = ∑ b : Fin k → Bool with t < {j : Fin k | b j = true}.card, ∏ j : Fin k, if b j = true then acceptProb w gs x else 1 - acceptProb w gs x

The acceptance probability of the threshold circuit is the probability that more than t of k independent runs of the original circuit accept.

The threshold circuit is constructed in polynomial time #

The threshold vote of a family: on inputs of length n, k(n) copies of the family's circuit run side by side, and the final measurement reads whether more than t(n) of them accept.

The acceptance probability of the threshold vote is the probability that more than t(n) of k(n) independent runs of the family accept, on inputs of length n.

The amplified family: on inputs of length n, 2 r(n) copies of the family's circuit run side by side, and a reversible strict majority vote of their answers is measured.

The acceptance probability of the amplified family is the probability that more than r(n) of 2 r(n) independent runs of the family accept, on inputs of length n.

Amplifying acceptance: a family accepting with probability at least 2 / 3 gives a family accepting with probability at least 1 - (8 / 9) ^ r(n).

Amplifying rejection: a family accepting with probability at most 1 / 3 gives a family accepting with probability at most (8 / 9) ^ r(n).

theorem Cslib.Complexity.eight_ninths_pow_le (m : ℕ) :
(8 / 9) ^ (6 * m) ≤ (2 ^ m)⁻¹

(8 / 9) ^ (6 m) ≤ 2 ^ (-m), since 2 * 8 ^ 6 < 9 ^ 6.

theorem Cslib.Complexity.mem_BQP_iff_forall_errorExponent {α : Type} {enc : α ↪ List Bool} {A : Set α} :
A ∈ BQP enc ↔ ∀ (q : Polynomial ℕ), ∃ (F : Quantum.UniformCircuitFamily), ∀ (a : α), (a ∈ A → 1 - (2 ^ Polynomial.eval (enc a).length q)⁻¹ ≤ F.acceptProb (enc a)) ∧ (a ∉ A → F.acceptProb (enc a) ≤ (2 ^ Polynomial.eval (enc a).length q)⁻¹)

Error reduction for BQP: a problem is in BQP exactly when, for every polynomial q, some polynomial-time uniform family accepts the encodings of members with probability at least 1 - 2^{-q(n)} and those of other instances with probability at most 2^{-q(n)}, where n is the length of the encoding.