Documentation

CslibFrontier.Computability.QueryComplexity.Quantum.NayakWuConsequences

Lower bounds of Nayak and Wu for approximate counting, median, and selection #

This module derives the statistical query lower bounds of Nayak and Wu from the adversary weight-layer promise bound Cslib.Quantum.one_sub_mul_add_le_four_mul_mul_abs_sub_of_weight and the value-query simulation results in CslibFrontier/Computability/QueryComplexity/Quantum/ValueQuery.lean.

Let T be the query count of a quantum algorithm whose failure probability on every valid input is at most ε (2 * ε ≤ 1), measured through a multi-outcome classical readout of its final basis state (measureProb ... (univ.filter ...), connected to Cslib.Quantum.measureOut via Cslib.Quantum.le_measureProb_of_le_measureOut):

Notice the T + 1 shift for index-returning algorithms: at n = 3 and δ = 1 / 3, returning a uniformly random index i : Fin 3 in 0 queries already yields an exact median x_i with probability at least 2 / 3 on every 0/1 input, whereas outputting the value x_i itself cannot avoid at least one query.

Main definitions #

Main results #

References #

Problem definitions #

def Cslib.Quantum.IsApproxMedian {ι : Type u_1} {α : Type u_2} [Fintype ι] [LinearOrder α] (X : ι → α) (δ : ℝ) (y : α) :

y is a δ-approximate median of X : ι → α ([NW99], Problem 1) when fewer than (1 + δ) |ι| / 2 entries are strictly smaller than y and fewer than (1 + δ) |ι| / 2 entries are strictly larger than y.

theorem Cslib.Quantum.IsApproxMedian.mono {ι : Type u_1} {α : Type u_2} [Fintype ι] [LinearOrder α] {X : ι → α} {δ₁ δ₂ : ℝ} {y : α} (h : δ₁ ≤ δ₂) (hm : IsApproxMedian X δ₁ y) :
IsApproxMedian X δ₂ y

Monotonicity of IsApproxMedian in the tolerance δ.

def Cslib.Quantum.IsKthSmallest {ι : Type u_1} {α : Type u_2} [Fintype ι] [LinearOrder α] (X : ι → α) (j : ℕ) (y : α) :

y is a j-th smallest element (1-indexed) of X : ι → α: at most j - 1 entries are strictly less than y, and at least j entries are at most y.

def Cslib.Quantum.IsApproxKthSmallest {ι : Type u_1} {α : Type u_2} [Fintype ι] [LinearOrder α] (X : ι → α) (k : ℕ) (Δ : ℝ) (y : α) :

y is a Δ-approximate k-th smallest element of X : ι → α ([NW99], Problem 2): y is a j-th smallest element of X for some 1 ≤ j ≤ |ι| with k - Δ < j < k + Δ.

def Cslib.Quantum.IsApproxKthSmallestRelaxed {ι : Type u_1} {α : Type u_2} [Fintype ι] [LinearOrder α] (X : ι → α) (k : ℕ) (Δ : ℝ) (y : α) :

Relaxed Δ-approximate k-th smallest condition not requiring y to appear in X: y still lies between the minimum and maximum of X and satisfies the rank bounds implied by IsApproxKthSmallest.

theorem Cslib.Quantum.IsApproxKthSmallest.relaxed {ι : Type u_1} {α : Type u_2} [Fintype ι] [LinearOrder α] {X : ι → α} {k : ℕ} {Δ : ℝ} {y : α} (h : IsApproxKthSmallest X k Δ y) :

Every Δ-approximate k-th smallest element satisfies the relaxed rank condition.

theorem Cslib.Quantum.le_measureProb_of_le_measureOut {γ : Type u_3} {β : Type u_4} [Fintype γ] (ψ : EuclideanSpace ℂ γ) (hψ : ‖ψ‖ = 1) (out : γ → β) (P : β → Prop) {p : ℝ} (hp : ENNReal.ofReal p ≤ (measureOut ψ hψ out).toOuterMeasure {b : β | P b}) :
p ≤ measureProb ψ {y : γ | P (out y)}

Converts an ENNReal lower bound on (measureOut ψ hψ out).toOuterMeasure {b | P b} into a measureProb lower bound on univ.filter fun y => P (out y).

Algebraic and error-1/3 helpers #

Theorem 1.11: Δ-approximate counting #

theorem Cslib.Quantum.one_sub_mul_add_le_of_approxCount_aux {n : ℕ} {W : Type u_1} [Fintype W] (U : ℕ → State n W →ₗᵢ[ℂ] State n W) {ψ₀ : State n W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : Fin n × Bool × W → ℝ) {t : ℕ} {Δ ε : ℝ} (ht : t ≤ n) (hΔ : 0 < Δ) (hstep : t + ⌈2 * Δ⌉₊ ≤ n ∨ ⌈2 * Δ⌉₊ ≤ t) (h : ∀ (x : BitString n), 1 - ε ≤ measureProb (run U ψ₀ x T) {p : Fin n × Bool × W | |out p - ↑(BitString.weight x)| < Δ}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * (√(↑n * ↑⌈2 * Δ⌉₊) + √(↑t * (↑n - ↑t))) ≤ 4 * ↑T * ↑⌈2 * Δ⌉₊

Core step of Theorem 1.11 ([NW99]): for 0 < Δ and d = ⌈2Δ⌉₊ with either t + d ≤ n or d ≤ t, any T-query algorithm approximating weight x within < Δ with error ε ≤ 1/2 satisfies (1 - 2√(ε(1-ε))) (√(n d) + √(t (n - t))) ≤ 4 T d.

theorem Cslib.Quantum.one_sub_mul_exactCount_le {n : ℕ} {W : Type u_1} [Fintype W] (U : ℕ → State n W →ₗᵢ[ℂ] State n W) {ψ₀ : State n W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : Fin n × Bool × W → ℝ) {t : ℕ} {Δ ε : ℝ} (hn : 1 ≤ n) (ht : t ≤ n) (hΔ_pos : 0 < Δ) (hΔ_le : Δ ≤ 1 / 2) (h : ∀ (x : BitString n), 1 - ε ≤ measureProb (run U ψ₀ x T) {p : Fin n × Bool × W | |out p - ↑(BitString.weight x)| < Δ}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * (√↑n + √(↑t * (↑n - ↑t))) ≤ 4 * ↑T

Exact-precision counting (0 < Δ ≤ 1 / 2) ([NW99], Theorem 1.11): for 1 ≤ n and 0 < Δ ≤ 1 / 2, approximating the Hamming weight within < Δ requires (1 - 2√(ε(1-ε))) (√n + √(t (n - t))) ≤ 4 T queries.

theorem Cslib.Quantum.one_sub_mul_approxCount_le {n : ℕ} {W : Type u_1} [Fintype W] (U : ℕ → State n W →ₗᵢ[ℂ] State n W) {ψ₀ : State n W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : Fin n × Bool × W → ℝ) {t : ℕ} {Δ ε : ℝ} (ht : t ≤ n) (hΔ_lo : 1 / 2 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑n) (h : ∀ (x : BitString n), 1 - ε ≤ measureProb (run U ψ₀ x T) {p : Fin n × Bool × W | |out p - ↑(BitString.weight x)| < Δ}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * (√(↑n / Δ) + √(↑t * (↑n - ↑t)) / Δ) ≤ 16 * ↑T

Theorem 1.11 ([NW99]): any T-query algorithm approximating the Hamming weight of every x : BitString n within additive error < Δ (1 / 2 ≤ Δ, 4 * Δ ≤ n) with failure probability at most ε ≤ 1 / 2 satisfies (1 - 2√(ε(1-ε))) (√(n / Δ) + √(t (n - t)) / Δ) ≤ 16 T on inputs of weight t ≤ n.

theorem Cslib.Quantum.approxCount_lower_bound {n : ℕ} {W : Type u_1} [Fintype W] (U : ℕ → State n W →ₗᵢ[ℂ] State n W) {ψ₀ : State n W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : Fin n × Bool × W → ℝ) {t : ℕ} {Δ : ℝ} (ht : t ≤ n) (hΔ_lo : 1 / 2 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑n) (h : ∀ (x : BitString n), 1 - 1 / 3 ≤ measureProb (run U ψ₀ x T) {p : Fin n × Bool × W | |out p - ↑(BitString.weight x)| < Δ}) :
√(↑n / Δ) + √(↑t * (↑n - ↑t)) / Δ ≤ 288 * ↑T

Bounded-error (ε = 1 / 3) form of Theorem 1.11 ([NW99]): √(n / Δ) + √(t (n - t)) / Δ ≤ 288 T.

Shared Boolean-simulation adversary bridge #

Theorem 1.5: Δ-approximate k-th smallest element #

theorem Cslib.Quantum.one_sub_mul_kthSmallest_twoValues_le {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) (a₀ a₁ : α) (ha : a₀ < a₁) {k : ℕ} {Δ ε : ℝ} (hk1 : 1 ≤ k) (hkn : k ≤ Fintype.card ι) (hΔ_lo : 1 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - ε ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxKthSmallestRelaxed X k Δ (out p)}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * (√(↑(Fintype.card ι) / Δ) + √(↑k * (↑(Fintype.card ι) - ↑k)) / Δ) ≤ 32 * ↑T

Theorem 1.5 (arbitrary unitary oracle, two-valued domain) ([NW99]): any T-query value-query algorithm outputting an element satisfying IsApproxKthSmallestRelaxed on all {a₀, a₁}-valued inputs (a₀ < a₁) with failure probability ε ≤ 1 / 2 satisfies (1 - 2√(ε(1-ε))) (√(|ι| / Δ) + √(k (|ι| - k)) / Δ) ≤ 32 T.

theorem Cslib.Quantum.one_sub_mul_kthSmallest_le {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] [Nontrivial α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) {k : ℕ} {Δ ε : ℝ} (hk1 : 1 ≤ k) (hkn : k ≤ Fintype.card ι) (hΔ_lo : 1 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), 1 - ε ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxKthSmallestRelaxed X k Δ (out p)}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * (√(↑(Fintype.card ι) / Δ) + √(↑k * (↑(Fintype.card ι) - ↑k)) / Δ) ≤ 32 * ↑T

Theorem 1.5 (arbitrary unitary oracle) ([NW99]): over any nontrivial linear order α, a T-query value-query algorithm approximating the k-th smallest element within < Δ (1 ≤ k ≤ |ι|, 1 ≤ Δ, 4 * Δ ≤ |ι|) with failure probability ε ≤ 1 / 2 satisfies (1 - 2√(ε(1-ε))) (√(|ι| / Δ) + √(k (|ι| - k)) / Δ) ≤ 32 T.

theorem Cslib.Quantum.one_sub_mul_kthSmallest_le_of_involution {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) (a₀ a₁ : α) (ha : a₀ < a₁) (hR : ∀ (φ : EuclideanSpace ℂ V), ((step a₀).symm.trans (step a₁)) (((step a₀).symm.trans (step a₁)) φ) = φ) {k : ℕ} {Δ ε : ℝ} (hk1 : 1 ≤ k) (hkn : k ≤ Fintype.card ι) (hΔ_lo : 1 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - ε ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxKthSmallestRelaxed X k Δ (out p)}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * (√(↑(Fintype.card ι) / Δ) + √(↑k * (↑(Fintype.card ι) - ↑k)) / Δ) ≤ 16 * ↑T

Theorem 1.5 (involutive-difference oracle) ([NW99]): when the relative step (step a₀).symm.trans (step a₁) is an involution (for instance an XOR oracle), each value query costs one phase query, tightening the constant from 32 to 16.

theorem Cslib.Quantum.kthSmallest_lower_bound {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] [Nontrivial α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) {k : ℕ} {Δ : ℝ} (hk1 : 1 ≤ k) (hkn : k ≤ Fintype.card ι) (hΔ_lo : 1 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), 1 - 1 / 3 ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxKthSmallest X k Δ (out p)}) :
√(↑(Fintype.card ι) / Δ) + √(↑k * (↑(Fintype.card ι) - ↑k)) / Δ ≤ 576 * ↑T

Bounded-error (ε = 1 / 3) form of Theorem 1.5 ([NW99]) for IsApproxKthSmallest: √(|ι| / Δ) + √(k (|ι| - k)) / Δ ≤ 576 T.

theorem Cslib.Quantum.kthSmallest_involution_lower_bound {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) (a₀ a₁ : α) (ha : a₀ < a₁) (hR : ∀ (φ : EuclideanSpace ℂ V), ((step a₀).symm.trans (step a₁)) (((step a₀).symm.trans (step a₁)) φ) = φ) {k : ℕ} {Δ : ℝ} (hk1 : 1 ≤ k) (hkn : k ≤ Fintype.card ι) (hΔ_lo : 1 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - 1 / 3 ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxKthSmallest X k Δ (out p)}) :
√(↑(Fintype.card ι) / Δ) + √(↑k * (↑(Fintype.card ι) - ↑k)) / Δ ≤ 288 * ↑T

Bounded-error (ε = 1 / 3) form of Theorem 1.5 ([NW99]) for involutive-difference oracles: √(|ι| / Δ) + √(k (|ι| - k)) / Δ ≤ 288 T.

theorem Cslib.Quantum.one_sub_mul_kthSmallest_index_le {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (v₀ : V) (read : V → α) (a₀ a₁ : α) (ha : a₀ < a₁) (hread₀ : measureProb ((step a₀) (ket v₀)) {v : V | read v = a₀} = 1) (hread₁ : measureProb ((step a₁) (ket v₀)) {v : V | read v = a₁} = 1) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (idx : ι × V × W → ι) {k : ℕ} {Δ ε : ℝ} (hk1 : 1 ≤ k) (hkn : k ≤ Fintype.card ι) (hΔ_lo : 1 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - ε ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxKthSmallestRelaxed X k Δ (X (idx p))}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * (√(↑(Fintype.card ι) / Δ) + √(↑k * (↑(Fintype.card ι) - ↑k)) / Δ) ≤ 32 * (↑T + 1)

Theorem 1.5 (index-returning value-query algorithm) ([NW99]): a T-query algorithm returning an index idx p : ι whose value X (idx p) approximates the k-th smallest element is simulated in T + 1 queries via Cslib.Quantum.exists_sim_index_to_value, giving (1 - 2√(ε(1-ε))) (√(|ι| / Δ) + √(k (|ι| - k)) / Δ) ≤ 32 (T + 1).

theorem Cslib.Quantum.kthSmallest_index_lower_bound {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (v₀ : V) (read : V → α) (a₀ a₁ : α) (ha : a₀ < a₁) (hread₀ : measureProb ((step a₀) (ket v₀)) {v : V | read v = a₀} = 1) (hread₁ : measureProb ((step a₁) (ket v₀)) {v : V | read v = a₁} = 1) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (idx : ι × V × W → ι) {k : ℕ} {Δ : ℝ} (hk1 : 1 ≤ k) (hkn : k ≤ Fintype.card ι) (hΔ_lo : 1 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - 1 / 3 ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxKthSmallest X k Δ (X (idx p))}) :
√(↑(Fintype.card ι) / Δ) + √(↑k * (↑(Fintype.card ι) - ↑k)) / Δ ≤ 576 * (↑T + 1)

Bounded-error (ε = 1 / 3) form of Theorem 1.5 for index-returning algorithms: √(|ι| / Δ) + √(k (|ι| - k)) / Δ ≤ 576 (T + 1).

theorem Cslib.Quantum.one_sub_mul_kthSmallest_perm_index_le {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (π : α → Equiv.Perm V) (v₀ : V) (a₀ a₁ : α) (ha : a₀ < a₁) (hne : (π a₀) v₀ ≠ (π a₁) v₀) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (idx : ι × V × W → ι) {k : ℕ} {Δ ε : ℝ} (hk1 : 1 ≤ k) (hkn : k ≤ Fintype.card ι) (hΔ_lo : 1 ≤ Δ) (hΔ_hi : 4 * Δ ≤ ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - ε ≤ measureProb (runValue (permStep π) U ψ₀ X T) {p : ι × V × W | IsApproxKthSmallestRelaxed X k Δ (X (idx p))}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * (√(↑(Fintype.card ι) / Δ) + √(↑k * (↑(Fintype.card ι) - ↑k)) / Δ) ≤ 32 * (↑T + 1)

Specialization of one_sub_mul_kthSmallest_index_le to permutation oracles permStep π.

Corollary 1.6: δ-approximate median #

theorem Cslib.Quantum.one_sub_mul_median_twoValues_le {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) (a₀ a₁ : α) (ha : a₀ < a₁) {δ ε : ℝ} (hn1 : 1 ≤ Fintype.card ι) (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - ε ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (out p)}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * min (1 / δ) ↑(Fintype.card ι) ≤ 24 * ↑T

Corollary 1.6 (arbitrary unitary oracle, two-valued domain) ([NW99]): any T-query value-query algorithm computing a δ-approximate median (0 < δ < 1, 1 ≤ |ι|) on all {a₀, a₁}-valued inputs (a₀ < a₁) with failure probability ε ≤ 1 / 2 satisfies (1 - 2√(ε(1-ε))) min (1 / δ) |ι| ≤ 24 T.

theorem Cslib.Quantum.one_sub_mul_median_le {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] [Nontrivial α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) {δ ε : ℝ} (hn1 : 1 ≤ Fintype.card ι) (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hgood : ∀ (X : ι → α), 1 - ε ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (out p)}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * min (1 / δ) ↑(Fintype.card ι) ≤ 24 * ↑T

Corollary 1.6 (arbitrary unitary oracle) ([NW99]): over any nontrivial linear order α, a T-query value-query algorithm computing a δ-approximate median (0 < δ < 1, 1 ≤ |ι|) with failure probability ε ≤ 1 / 2 satisfies (1 - 2√(ε(1-ε))) min (1 / δ) |ι| ≤ 24 T.

theorem Cslib.Quantum.one_sub_mul_median_le_of_involution {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) (a₀ a₁ : α) (ha : a₀ < a₁) (hR : ∀ (φ : EuclideanSpace ℂ V), ((step a₀).symm.trans (step a₁)) (((step a₀).symm.trans (step a₁)) φ) = φ) {δ ε : ℝ} (hn1 : 1 ≤ Fintype.card ι) (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - ε ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (out p)}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * min (1 / δ) ↑(Fintype.card ι) ≤ 12 * ↑T

Corollary 1.6 (involutive-difference oracle) ([NW99]): when (step a₀).symm.trans (step a₁) is an involution (for instance an XOR oracle), the constant tightens from 24 to 12: (1 - 2√(ε(1-ε))) min (1 / δ) |ι| ≤ 12 T.

theorem Cslib.Quantum.median_lower_bound {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] [Nontrivial α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) {δ : ℝ} (hn1 : 1 ≤ Fintype.card ι) (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hgood : ∀ (X : ι → α), 1 - 1 / 3 ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (out p)}) :
min (1 / δ) ↑(Fintype.card ι) ≤ 432 * ↑T

Bounded-error (ε = 1 / 3) form of Corollary 1.6 ([NW99]): min (1 / δ) |ι| ≤ 432 T.

theorem Cslib.Quantum.median_inv_delta_lower_bound {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] [Nontrivial α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) {δ : ℝ} (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hδn : 1 ≤ δ * ↑(Fintype.card ι)) (hgood : ∀ (X : ι → α), 1 - 1 / 3 ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (out p)}) :
1 / δ ≤ 432 * ↑T

When 1 ≤ δ * |ι|, min (1 / δ) |ι| = 1 / δ, so Corollary 1.6 gives 1 / δ ≤ 432 T.

theorem Cslib.Quantum.median_involution_lower_bound {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (out : ι × V × W → α) (a₀ a₁ : α) (ha : a₀ < a₁) (hR : ∀ (φ : EuclideanSpace ℂ V), ((step a₀).symm.trans (step a₁)) (((step a₀).symm.trans (step a₁)) φ) = φ) {δ : ℝ} (hn1 : 1 ≤ Fintype.card ι) (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - 1 / 3 ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (out p)}) :
min (1 / δ) ↑(Fintype.card ι) ≤ 216 * ↑T

Bounded-error (ε = 1 / 3) form of Corollary 1.6 ([NW99]) for involutive-difference oracles: min (1 / δ) |ι| ≤ 216 T.

theorem Cslib.Quantum.one_sub_mul_median_index_le {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (v₀ : V) (read : V → α) (a₀ a₁ : α) (ha : a₀ < a₁) (hread₀ : measureProb ((step a₀) (ket v₀)) {v : V | read v = a₀} = 1) (hread₁ : measureProb ((step a₁) (ket v₀)) {v : V | read v = a₁} = 1) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (idx : ι × V × W → ι) {δ ε : ℝ} (hn1 : 1 ≤ Fintype.card ι) (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - ε ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (X (idx p))}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * min (1 / δ) ↑(Fintype.card ι) ≤ 24 * (↑T + 1)

Corollary 1.6 (index-returning value-query algorithm) ([NW99]): a T-query algorithm returning an index idx p : ι whose value X (idx p) is a δ-approximate median satisfies (1 - 2√(ε(1-ε))) min (1 / δ) |ι| ≤ 24 (T + 1).

theorem Cslib.Quantum.median_index_lower_bound {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (step : α → EuclideanSpace ℂ V ≃ₗᵢ[ℂ] EuclideanSpace ℂ V) (v₀ : V) (read : V → α) (a₀ a₁ : α) (ha : a₀ < a₁) (hread₀ : measureProb ((step a₀) (ket v₀)) {v : V | read v = a₀} = 1) (hread₁ : measureProb ((step a₁) (ket v₀)) {v : V | read v = a₁} = 1) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (idx : ι × V × W → ι) {δ : ℝ} (hn1 : 1 ≤ Fintype.card ι) (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - 1 / 3 ≤ measureProb (runValue step U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (X (idx p))}) :
min (1 / δ) ↑(Fintype.card ι) ≤ 432 * (↑T + 1)

Bounded-error (ε = 1 / 3) form of Corollary 1.6 for index-returning algorithms: min (1 / δ) |ι| ≤ 432 (T + 1).

theorem Cslib.Quantum.one_sub_mul_median_perm_index_le {ι : Type u_1} {V : Type u_2} {W : Type u_3} {α : Type u_4} [Fintype ι] [Fintype V] [Fintype W] [LinearOrder α] (π : α → Equiv.Perm V) (v₀ : V) (a₀ a₁ : α) (ha : a₀ < a₁) (hne : (π a₀) v₀ ≠ (π a₁) v₀) (U : ℕ → ValueState ι V W →ₗᵢ[ℂ] ValueState ι V W) {ψ₀ : ValueState ι V W} (hψ₀ : ‖ψ₀‖ = 1) (T : ℕ) (idx : ι × V × W → ι) {δ ε : ℝ} (hn1 : 1 ≤ Fintype.card ι) (hδ₀ : 0 < δ) (hδ₁ : δ < 1) (hgood : ∀ (X : ι → α), (∀ (i : ι), X i = a₀ ∨ X i = a₁) → 1 - ε ≤ measureProb (runValue (permStep π) U ψ₀ X T) {p : ι × V × W | IsApproxMedian X δ (X (idx p))}) (hε : 2 * ε ≤ 1) :
(1 - 2 * √(ε * (1 - ε))) * min (1 / δ) ↑(Fintype.card ι) ≤ 24 * (↑T + 1)

Specialization of one_sub_mul_median_index_le to permutation oracles permStep π.