Documentation

CslibFrontier.Computability.QueryComplexity.Quantum.Simon

Simon's algorithm and the exponential quantum–classical query separation #

Simon's problem (CslibFrontier/Computability/QueryComplexity/Simon.lean, Simon, de Wolf, §3.1): given f : {0,1}^n → {0,1}^n with the promise that for some s, f(a) = f(b) exactly when b ∈ {a, a ⊕ s} (Cslib.QueryComplexity.SimonPromise), decide whether s ≠ 0. The input is the truth table X : Fin N → Bool of the N = n 2^n output bits of f, indexed by E : Fin N ≃ {0,1}^n × Fin n (Cslib.QueryComplexity.simonFun), and queries are bit queries (Cslib.Quantum.bitQueryAlg): each query reads one bit f(a)_j.

The algorithm (Cslib.Quantum.simonAlg m E i₀, de Wolf §3.2) runs m rounds of Simon's subroutine side by side. Its workspace (Cslib.Quantum.SimonWork m n) holds an input register xs and an output register ys of m strings of n bits each. It starts in |i₀, 0, 0, 0⟩ for a fixed query index i₀ (Cslib.Quantum.simonInit), applies the Hadamard transform to xs, computes ys_{r,j} = f(xs_r)_j with m n bit queries, and applies the Hadamard transform to xs again. For query (r, j) the basis permutation Cslib.Quantum.simonRoute moves the position E⁻¹(xs_r, j) of the bit f(xs_r)_j into the query register and the target bit ys_{r,j} into the control bit; after the bit query the same permutation moves them back. Measuring gives m rows z_1, …, z_m ∈ {0,1}^n, and the algorithm accepts when they have a common nonzero orthogonal vector (Cslib.Quantum.simonAccept), which Gaussian elimination decides without further queries.

Analysis. The final amplitude of |i₀, 0, z, y⟩ is 2^{-mn} ∑_{a : f(a) = y} (-1)^{a ⬝ z}, with f applied rowwise (Cslib.Quantum.run_simonAlg_apply). If s ≠ 0 and z_r ⬝ s = 1 for a row r, then adding s to row r of a pairs the terms of this sum with opposite signs. So every measured row is orthogonal to s, and the algorithm accepts with certainty (Cslib.Quantum.measureProb_simonAlg_of_ne_zero). If f is injective (s = 0), each row matrix z is measured with probability 2^{-mn}, and a fixed nonzero w is orthogonal to all rows of 2^{(n-1)m} of the 2^{nm} matrices, so the algorithm accepts with probability at most (2^n - 1) / 2^m (Cslib.Quantum.measureProb_simonAlg_le_of_injective). With m = n + 2 rounds, n (n + 2) bit queries decide Simon's problem with one-sided error below 1/4 (Cslib.Quantum.simonAlg_spec).

The separation. Every randomized decision tree that decides Simon's problem with error 1/3 has depth q with 2^n ≤ q² (Cslib.QueryComplexity.simon_two_pow_le_depth_sq), so the separation is exponential: n (n + 2) quantum bit queries against 2^{n/2} randomized ones (Cslib.Quantum.simon_separation). In terms of the input length N = n 2^n, for which n ≤ log₂ N, the quantum algorithm makes at most 3 log₂² N queries and every such randomized decision tree has N ≤ q² log₂ N, so q ≥ (N / log₂ N)^{1/2} = N^{1/2 - o(1)} (Cslib.Quantum.simon_separation_inputLength). Both sides count bit queries, so the comparison is like for like; the quantum side pays a factor n over the n + 2 value queries of de Wolf §3.2. Simulating value queries by bit queries transfers the classical bound to value queries only up to that factor (q_v ≥ 2^{n/2} / n); the coupling argument, which uses only that q queries touch at most q inputs a, would give 2^n ≤ q_v² directly, but that is not formalized.

Source mapping. de Wolf §3.2 repeats the subroutine O(n) times and solves the resulting linear system to find s; de Wolf §3.3.2 proves the classical lower bound for the decision version, which is the version separated here. Running the rounds side by side in one bit-query algorithm, accepting by the rank test, and the union bound (2^n - 1) / 2^m with its constants are formulated here. Finding s itself (the search version) is in CslibFrontier/Computability/QueryComplexity/Quantum/SimonSearch.lean, which uses the general bound Cslib.Quantum.measureProb_simonAlg_le on the outcome probabilities.

Main definitions #

Main results #

References #

structure Cslib.Quantum.SimonWork (m n : ℕ) :

The workspace of Simon's algorithm with m rounds: the input register xs and the output register ys, each holding m strings of n bits.

  • xs : Fin m × Fin n → Bool

    The input register holding m query strings of n bits.

  • ys : Fin m × Fin n → Bool

    The output register holding m answer strings of n bits.

Instances For
    theorem Cslib.Quantum.SimonWork.ext {m n : ℕ} {x y : SimonWork m n} (xs : x.xs = y.xs) (ys : x.ys = y.ys) :
    x = y
    theorem Cslib.Quantum.SimonWork.ext_iff {m n : ℕ} {x y : SimonWork m n} :
    x = y ↔ x.xs = y.xs ∧ x.ys = y.ys
    @[instance_reducible]
    def Cslib.Quantum.instDecidableEqSimonWork.decEq {m✝ n✝ : ℕ} (x✝ x✝¹ : SimonWork m✝ n✝) :
    Decidable (x✝ = x✝¹)
    def Cslib.Quantum.SimonWork.equiv {m n : ℕ} :
    SimonWork m n ≃ (Fin m × Fin n → Bool) × (Fin m × Fin n → Bool)

    Equivalence between SimonWork m n and the pair (xs, ys).

    @[instance_reducible]
    def Cslib.Quantum.simonEquiv {N n m : ℕ} :
    Fin N × Bool × SimonWork m n ≃ (Fin m × Fin n → Bool) × Fin N × Bool × (Fin m × Fin n → Bool)

    The basis of Simon's algorithm regrouped for the Hadamard transform on the input register: (i, b, ⟨xs, ys⟩) ↦ (xs, (i, b, ys)).

    @[simp]
    theorem Cslib.Quantum.simonEquiv_apply {N n m : ℕ} (i : Fin N) (b : Bool) (w : SimonWork m n) :
    simonEquiv (i, b, w) = (w.xs, i, b, w.ys)
    @[simp]
    theorem Cslib.Quantum.simonEquiv_symm_apply {N n m : ℕ} (xs : Fin m × Fin n → Bool) (i : Fin N) (b : Bool) (ys : Fin m × Fin n → Bool) :
    simonEquiv.symm (xs, i, b, ys) = (i, b, { xs := xs, ys := ys })
    def Cslib.Quantum.simonRoute {N n m : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) (k : Fin m × Fin n) :

    The routing permutation of query k = (r, j) with resting query index i₀: it exchanges the query index i₀ with the position E⁻¹(xs_r, j) of the bit f(xs_r)_j, and the control bit with the output bit ys_{r,j}. It is an involution.

    noncomputable def Cslib.Quantum.simonAlg {N n : ℕ} (m : ℕ) (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) :

    Simon's algorithm with m rounds and resting query index i₀: the Hadamard transform on the input register, m n bit queries computing ys_{r,j} = f(xs_r)_j, each between two routing permutations Cslib.Quantum.simonRoute, and the Hadamard transform on the input register.

    noncomputable def Cslib.Quantum.simonInit {N n m : ℕ} (i₀ : Fin N) :

    The initial state |i₀, 0, 0, 0⟩ of Simon's algorithm.

    @[simp]
    theorem Cslib.Quantum.norm_simonInit {N n m : ℕ} (i₀ : Fin N) :
    def Cslib.Quantum.simonG {N n m : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (X : Fin N → Bool) (xs : Fin m × Fin n → Bool) :
    Fin m × Fin n → Bool

    The values f(xs_r)_j of the function Cslib.QueryComplexity.simonFun E X on the rows xs_r of xs.

    theorem Cslib.Quantum.simonG_apply {N n m : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (X : Fin N → Bool) (xs : Fin m × Fin n → Bool) (k : Fin m × Fin n) :
    theorem Cslib.Quantum.run_simonAlg_apply {N n m : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) (X : Fin N → Bool) (i : Fin N) (b : Bool) (w : SimonWork m n) :
    (run (simonAlg m E i₀) (simonInit i₀) X (m * n)).ofLp (i, b, w) = if i = i₀ ∧ b = false then ↑(√(2 ^ Fintype.card (Fin m × Fin n)))⁻¹ * ↑(√(2 ^ Fintype.card (Fin m × Fin n)))⁻¹ * ∑ a : Fin m × Fin n → Bool with simonG E X a = w.ys, ↑(BitString.signVal (a ⬝ᵥ w.xs)) else 0

    The final state of Simon's algorithm: the amplitude of |i₀, 0, z, y⟩ is 2^{-mn} ∑_{a : f(a) = y} (-1)^{a ⬝ z}, with f applied rowwise, and every other amplitude is 0.

    The accepting outcomes of Simon's algorithm: the measured rows z_r (of the input register) have a common nonzero orthogonal vector w, so they do not span {0,1}^n.

    @[simp]
    theorem Cslib.Quantum.mem_simonAccept {N n m : ℕ} {i : Fin N} {b : Bool} {w : SimonWork m n} :
    (i, b, w) ∈ simonAccept m n ↔ ∃ (u : Fin n → Bool), u ≠ 0 ∧ ∀ (r : Fin m), Function.curry w.xs r ⬝ᵥ u = false
    theorem Cslib.Quantum.measureProb_simonAlg_of_ne_zero {N n m : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) {X : Fin N → Bool} {s : Fin n → Bool} (hX : QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s) (hs : s ≠ 0) :
    measureProb (run (simonAlg m E i₀) (simonInit i₀) X (m * n)) (simonAccept m n) = 1

    Simon's algorithm accepts with certainty when s ≠ 0: every measured row is orthogonal to the hidden string s.

    theorem Cslib.Quantum.measureProb_simonAlg_le {N n m : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) {X : Fin N → Bool} {s : Fin n → Bool} (hX : QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s) {K : ℕ} (hK : ∀ (ys : Fin m × Fin n → Bool), {a : Fin m × Fin n → Bool | simonG E X a = ys}.card ≤ K) (Z : Finset (Fin m × Fin n → Bool)) :
    measureProb (run (simonAlg m E i₀) (simonInit i₀) X (m * n)) {x : Fin N × Bool × SimonWork m n | match x with | (fst, fst_1, w) => w.xs ∈ Z} ≤ ↑K * ↑{zs ∈ Z | ∀ (r : Fin m), Function.curry zs r ⬝ᵥ s = false}.card / 2 ^ (m * n)

    Outcome probabilities of Simon's algorithm. Under Simon's promise with hidden string s, if every fiber of the rowwise f has at most K elements, then the measured rows lie in a set Z of row matrices with probability at most K / 2^{mn} times the number of matrices in Z whose rows are all orthogonal to s.

    theorem Cslib.Quantum.measureProb_simonAlg_le_of_injective {N n m : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) {X : Fin N → Bool} (hf : Function.Injective (QueryComplexity.simonFun E X)) :
    measureProb (run (simonAlg m E i₀) (simonInit i₀) X (m * n)) (simonAccept m n) ≤ (2 ^ n - 1) / 2 ^ m

    Simon's algorithm rarely accepts when f is injective: with probability at most (2^n - 1) / 2^m.

    theorem Cslib.Quantum.simonAlg_spec {N n : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) :
    ‖simonInit i₀‖ = 1 ∧ ∀ (X : Fin N → Bool) (s : Fin n → Bool), QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s → |measureProb (run (simonAlg (n + 2) E i₀) (simonInit i₀) X ((n + 2) * n)) (simonAccept (n + 2) n) - BitString.bitVal ℝ (decide (s ≠ 0))| < 1 / 4

    Simon's algorithm decides Simon's problem with n (n + 2) bit queries: from a unit initial state, with n + 2 rounds, it accepts every promise input with acceptance probability within 1/4 of the answer s ≠ 0; the error is one-sided, as it accepts with certainty when s ≠ 0.

    theorem Cslib.Quantum.simon_separation {N n : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) (hn : 1 ≤ n) :
    (∀ (X : Fin N → Bool) (s : Fin n → Bool), QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s → |measureProb (run (simonAlg (n + 2) E i₀) (simonInit i₀) X ((n + 2) * n)) (simonAccept (n + 2) n) - BitString.bitVal ℝ (decide (s ≠ 0))| < 1 / 4) ∧ ∀ (μ : RandomizedDecisionTree (Fin N) Bool) (F : (Fin N → Bool) → Bool), (∀ (X : Fin N → Bool) (s : Fin n → Bool), QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s → F X = decide (s ≠ 0)) → (∀ (X : Fin N → Bool) (s : Fin n → Bool), QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s → μ.errorProb F X ≤ 1 / 3) → 2 ^ n ≤ μ.depth ^ 2

    The exponential quantum–classical separation for Simon's problem, in the bit-query model on the truth table X : Fin N → Bool of f : {0,1}^n → {0,1}^n, for n ≥ 1: Simon's algorithm decides Simon's problem with n (n + 2) queries and error below 1/4, while every randomized decision tree deciding it with error 1/3 (as the restriction to the promise inputs of a total function F) has depth q with 2^n ≤ q².

    theorem Cslib.Quantum.simon_separation_inputLength {N n : ℕ} (E : Fin N ≃ (Fin n → Bool) × Fin n) (i₀ : Fin N) (hn : 1 ≤ n) :
    (∀ (X : Fin N → Bool) (s : Fin n → Bool), QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s → |measureProb (run (simonAlg (n + 2) E i₀) (simonInit i₀) X ((n + 2) * n)) (simonAccept (n + 2) n) - BitString.bitVal ℝ (decide (s ≠ 0))| < 1 / 4) ∧ (n + 2) * n ≤ 3 * Nat.log 2 N ^ 2 ∧ ∀ (μ : RandomizedDecisionTree (Fin N) Bool) (F : (Fin N → Bool) → Bool), (∀ (X : Fin N → Bool) (s : Fin n → Bool), QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s → F X = decide (s ≠ 0)) → (∀ (X : Fin N → Bool) (s : Fin n → Bool), QueryComplexity.SimonPromise (QueryComplexity.simonFun E X) s → μ.errorProb F X ≤ 1 / 3) → N ≤ Nat.log 2 N * μ.depth ^ 2

    The separation in the input length N = n 2^n, for n ≥ 1: Simon's algorithm decides Simon's problem with error below 1/4 using n (n + 2) queries, which is at most 3 log₂² N, while every randomized decision tree deciding it with error 1/3 (as the restriction to the promise inputs of a total function F) has depth q with N ≤ q² log₂ N, so q ≥ (N / log₂ N)^{1/2} = N^{1/2 - o(1)}.