Documentation

LeanPool.QuantumQuery.Adversary

Adversary matrices, semidefinite duality, and composition #

Ported from the corresponding upstream modules listed by the source sections below. References beginning with Source name these retained sections.

The negative-weight adversary bound: definitions #

We define the negative-weight adversary bound ADV± of Høyer–Lee–Špalek (quant-ph/0611054, Definition 2) for a total function f : (ι → σ) → O, in the division-free primal form of Belovs–Lee (arXiv:2004.06439, Definition 6):

advPM f = sup { ‖Γ‖ | Γ symmetric, Γ x y = 0 whenever f x = f y, and ‖Γ ⊙ D i‖ ≤ 1 for every input index i }

where D i = advD i is the difference matrix with (D i) x y = 1 iff x i ≠ y i, ⊙ is the Hadamard (entrywise) product, and ‖·‖ is the spectral (L2 operator) norm. Since Γ = 0 is feasible, the value set is nonempty and advPM f ≥ 0; no division or Γ ≠ 0 side condition is needed.

Nothing here uses two-valuedness of the input alphabet σ or of the output type O: advD needs only DecidableEq σ for its if, and IsAdvMatrix uses f x = f y as a proposition, never as a decidable test. The Boolean theory is recovered at σ = O = Bool, which is how every downstream file uses it; the general alphabet is what makes non-Boolean problems such as maximum finding expressible.

We also define the classical nonnegative-weight bound adv (HLŠ Definition 1) by adding the entrywise nonnegativity constraint.

def QuantumQueryComplexity.advD {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] (i : ι) :
Matrix (ι → σ) (ι → σ) ℝ

The difference matrix D_i (HLŠ §2, BL Definition 6): (advD i) x y = 1 if x i ≠ y i and 0 otherwise.

Equations
Instances For
    @[simp]
    theorem QuantumQueryComplexity.advD_apply {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] (i : ι) (x y : ι → σ) :
    advD i x y = if x i = y i then 0 else 1
    theorem QuantumQueryComplexity.advD_isHermitian {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] (i : ι) :
    theorem QuantumQueryComplexity.hadamard_advD_apply {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] (Γ : Matrix (ι → σ) (ι → σ) ℝ) (i : ι) (x y : ι → σ) :
    Γ.hadamard (advD i) x y = if x i = y i then 0 else Γ x y
    def QuantumQueryComplexity.IsAdvMatrix {ι : Type u_1} {σ : Type u_2} {O : Type u_3} (f : (ι → σ) → O) (Γ : Matrix (ι → σ) (ι → σ) ℝ) :

    An adversary matrix for f (HLŠ §2): a real symmetric matrix supported on pairs of inputs with different f-values. Taking x = y shows the diagonal vanishes.

    Equations
    Instances For
      theorem QuantumQueryComplexity.IsAdvMatrix.isHermitian {ι : Type u_1} {σ : Type u_2} {O : Type u_3} {f : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h : IsAdvMatrix f Γ) :
      theorem QuantumQueryComplexity.IsAdvMatrix.apply_eq_zero {ι : Type u_1} {σ : Type u_2} {O : Type u_3} {f : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h : IsAdvMatrix f Γ) {x y : ι → σ} (hxy : f x = f y) :
      Γ x y = 0
      theorem QuantumQueryComplexity.IsAdvMatrix.diag_eq_zero {ι : Type u_1} {σ : Type u_2} {O : Type u_3} {f : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h : IsAdvMatrix f Γ) (x : ι → σ) :
      Γ x x = 0
      theorem QuantumQueryComplexity.IsAdvMatrix.smul {ι : Type u_1} {σ : Type u_2} {O : Type u_3} {f : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h : IsAdvMatrix f Γ) (c : ℝ) :
      IsAdvMatrix f (c • Γ)
      theorem QuantumQueryComplexity.isAdvMatrix_zero {ι : Type u_1} {σ : Type u_2} {O : Type u_3} (f : (ι → σ) → O) :
      noncomputable def QuantumQueryComplexity.advPM {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} (f : (ι → σ) → O) :

      The negative-weight adversary bound ADV±(f) (HLŠ Definition 2, in the division-free form of BL Definition 6).

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        noncomputable def QuantumQueryComplexity.adv {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} (f : (ι → σ) → O) :

        The classical (nonnegative-weight) adversary bound ADV(f) (HLŠ Definition 1).

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Maximum finding: the function and its level counts #

          maxFun x = ⊔ᵢ x i for x : ι → A with A a linear order and ι a nonempty finite index type. This is the non-Boolean function whose adversary bound we study; at A = Bool it is exactly orN.

          We use Finset.sup' over univ rather than Finset.max': max' takes a Finset A, so stating it would force (Finset.univ.image x).max', dragging in [DecidableEq A] and an image-nonemptiness proof. sup' ranges over ι directly and needs neither.

          Alongside it we define cnt p x, the number of coordinates of x on which a Bool-valued predicate p holds, and the normalised indicator wt p x. Predicates are Bool-valued rather than Prop-valued throughout this development so that no Decidable instance ever has to be carried, matched, or unified.

          noncomputable def QuantumQueryComplexity.maxFun {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] (x : ι → A) :
          A

          The maximum of a tuple: maxFun x = ⊔ᵢ x i.

          Equations
          Instances For
            theorem QuantumQueryComplexity.le_maxFun {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] (x : ι → A) (i : ι) :
            x i ≤ maxFun x
            theorem QuantumQueryComplexity.exists_eq_maxFun {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] (x : ι → A) :
            ∃ (i : ι), x i = maxFun x
            theorem QuantumQueryComplexity.maxFun_le {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] {x : ι → A} {b : A} (h : ∀ (i : ι), x i ≤ b) :
            theorem QuantumQueryComplexity.maxFun_eq_iff {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] {x : ι → A} {b : A} :
            maxFun x = b ↔ (∃ (i : ι), x i = b) ∧ ∀ (i : ι), x i ≤ b

            maxFun is characterised by the two conditions defining a maximum.

            Level counts #

            def QuantumQueryComplexity.cnt {ι : Type u_1} [Fintype ι] {A : Type u_2} (p : A → Bool) (x : ι → A) :

            The number of coordinates of x on which the predicate p holds.

            Equations
            Instances For
              theorem QuantumQueryComplexity.cnt_eq_sum {ι : Type u_1} [Fintype ι] {A : Type u_2} {p : A → Bool} (x : ι → A) :
              ↑(cnt p x) = ∑ i : ι, if p (x i) = true then 1 else 0
              theorem QuantumQueryComplexity.cnt_pos_of_maxFun {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] {p : A → Bool} (x : ι → A) (h : p (maxFun x) = true) :
              0 < cnt p x

              If the cut holds at the maximum then some coordinate realises it, so the count is positive. This is what makes the division by cnt in the dual solution harmless.

              theorem QuantumQueryComplexity.cnt_ne_zero_of_maxFun {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] {p : A → Bool} (x : ι → A) (h : p (maxFun x) = true) :
              ↑(cnt p x) ≠ 0
              theorem QuantumQueryComplexity.one_le_cnt_of_maxFun {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] {p : A → Bool} (x : ι → A) (h : p (maxFun x) = true) :
              1 ≤ ↑(cnt p x)

              The normalised indicator of a cut #

              noncomputable def QuantumQueryComplexity.wt {ι : Type u_1} [Fintype ι] {A : Type u_2} (p : A → Bool) (x : ι → A) (i : ι) :

              The indicator of {i | p (x i)}, normalised to sum to 1.

              Equations
              Instances For
                theorem QuantumQueryComplexity.wt_eq_zero {ι : Type u_1} [Fintype ι] {A : Type u_2} {p : A → Bool} (x : ι → A) {i : ι} (h : p (x i) = false) :
                wt p x i = 0
                theorem QuantumQueryComplexity.sum_wt {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] {p : A → Bool} (x : ι → A) (h : p (maxFun x) = true) :
                ∑ i : ι, wt p x i = 1

                The normalised indicator sums to 1 whenever the cut holds at the maximum.

                theorem QuantumQueryComplexity.sum_wt_sq_le_one {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] [Nonempty ι] {p : A → Bool} (x : ι → A) (h : p (maxFun x) = true) :
                ∑ i : ι, wt p x i * wt p x i ≤ 1

                The squared ℓ² mass of the normalised indicator is 1 / cnt ≤ 1.

                Spectral-norm infrastructure for the adversary bound #

                Layer-0 lemmas about the L2 operator norm of real matrices. All EuclideanSpace/WithLp friction is quarantined inside the proofs of this file: every exported statement is phrased with raw Matrix, *ᵥ, ⬝ᵥ and Real.sqrt (x ⬝ᵥ x).

                Main results:

                theorem QuantumQueryComplexity.inner_toLp {n : Type u_1} [Fintype n] (x y : n → ℝ) :
                theorem QuantumQueryComplexity.dotProduct_mulVec_eq_sum {n : Type u_1} [Fintype n] (A : Matrix n n ℝ) (u w : n → ℝ) :
                u ⬝ᵥ A.mulVec w = ∑ x : n, ∑ y : n, u x * A x y * w y
                theorem QuantumQueryComplexity.abs_dotProduct_mulVec_le {n : Type u_1} [Fintype n] [DecidableEq n] (A : Matrix n n ℝ) (x y : n → ℝ) :

                Master bilinear bound for the L2 operator norm.

                theorem QuantumQueryComplexity.l2_opNorm_le_of_forall_dotProduct {n : Type u_1} [Fintype n] [DecidableEq n] (A : Matrix n n ℝ) {c : ℝ} (hc : 0 ≤ c) (h : ∀ (x y : n → ℝ), |x ⬝ᵥ A.mulVec y| ≤ c * √(x ⬝ᵥ x) * √(y ⬝ᵥ y)) :

                Converse of the master bilinear bound.

                theorem QuantumQueryComplexity.abs_entry_le_l2_opNorm {n : Type u_1} [Fintype n] [DecidableEq n] (A : Matrix n n ℝ) (x y : n) :
                |A x y| ≤ ‖A‖

                Every entry is bounded by the L2 operator norm.

                theorem QuantumQueryComplexity.l2_opNorm_le_sum_abs {n : Type u_1} [Fintype n] [DecidableEq n] (A : Matrix n n ℝ) :
                ‖A‖ ≤ ∑ x : n, ∑ y : n, |A x y|

                Crude norm bound: the L2 operator norm is at most the sum of the absolute values of the entries.

                theorem QuantumQueryComplexity.abs_eigenvalue_le_norm {n : Type u_1} [Fintype n] [DecidableEq n] {A : Matrix n n ℝ} {v : n → ℝ} {θ : ℝ} (hv : A.mulVec v = θ • v) (hv0 : v ≠ 0) :

                An eigenvalue of any square real matrix is bounded by the L2 operator norm.

                theorem QuantumQueryComplexity.l2_opNorm_submatrix_le {n : Type u_1} [Fintype n] [DecidableEq n] {m : Type u_2} [Fintype m] [DecidableEq m] (A : Matrix n n ℝ) (e : m ≃ n) :

                Reindexing a square matrix along an injection of index types does not increase the L2 operator norm.

                theorem QuantumQueryComplexity.l2_opNorm_submatrix_equiv {n : Type u_1} [Fintype n] [DecidableEq n] {m : Type u_2} [Fintype m] [DecidableEq m] (A : Matrix n n ℝ) (e : m ≃ n) :
                ‖A.submatrix ⇑e ⇑e‖ = ‖A‖

                Reindexing a square matrix by a bijection preserves the L2 operator norm.

                The eigenvalue layer #

                For a real symmetric matrix, the L2 operator norm equals the sup norm of the eigenvalue vector. Proof: spectral theorem plus unitary invariance of the C*-norm, plus ‖diagonal v‖ = ‖v‖.

                theorem QuantumQueryComplexity.norm_le_of_forall_abs_eigenvalues_le {n : Type u_1} [Fintype n] [DecidableEq n] {A : Matrix n n ℝ} (hA : A.IsHermitian) {B : ℝ} (hB : 0 ≤ B) (h : ∀ (j : n), |hA.eigenvalues j| ≤ B) :
                theorem QuantumQueryComplexity.norm_le_of_eigenvector_family {n : Type u_1} [Fintype n] [DecidableEq n] {A : Matrix n n ℝ} (hA : A.IsHermitian) {κ : Type u_2} (v : κ → n → ℝ) (μ : κ → ℝ) {B : ℝ} (hB : 0 ≤ B) (heig : ∀ (k : κ), A.mulVec (v k) = μ k • v k) (hspan : Submodule.span ℝ (Set.range v) = ⊤) (hμ : ∀ (k : κ), |μ k| ≤ B) :

                Spanning-eigenvector bound. If a family of eigenvectors of a real symmetric matrix spans the whole space and all its eigenvalues are bounded by B in absolute value, then ‖A‖ ≤ B. Members of the family are allowed to be zero.

                theorem QuantumQueryComplexity.l2_opNorm_conj_diagonal_sign {n : Type u_1} [Fintype n] [DecidableEq n] {s : n → ℝ} (hs : ∀ (a : n), s a = 1 ∨ s a = -1) (X : Matrix n n ℝ) :

                Conjugation by a ±1 diagonal matrix preserves the L2 operator norm.

                Basic properties of the adversary bound #

                Accessor lemmas for advPM as a conditionally complete supremum, the a priori bound ‖Γ‖ ≤ card² for feasible matrices (which makes the value set bounded above), and the un-normalized witness lemma norm_div_le_advPM — the workhorse for proving lower bounds on advPM.

                theorem QuantumQueryComplexity.advPM_set_nonempty {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} (f : (ι → σ) → O) :
                {r : ℝ | ∃ (Γ : Matrix (ι → σ) (ι → σ) ℝ), IsAdvMatrix f Γ ∧ (∀ (i : ι), ‖Γ.hadamard (advD i)‖ ≤ 1) ∧ r = ‖Γ‖}.Nonempty
                theorem QuantumQueryComplexity.abs_apply_le_one_of_feasible {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h1 : IsAdvMatrix f Γ) (h2 : ∀ (i : ι), ‖Γ.hadamard (advD i)‖ ≤ 1) (x y : ι → σ) :
                |Γ x y| ≤ 1

                All entries of a feasible matrix are bounded by 1 in absolute value: off-diagonal entries embed into some Γ ⊙ advD i, and entries with f x = f y (in particular the diagonal) vanish.

                theorem QuantumQueryComplexity.norm_le_of_feasible {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h1 : IsAdvMatrix f Γ) (h2 : ∀ (i : ι), ‖Γ.hadamard (advD i)‖ ≤ 1) :
                ‖Γ‖ ≤ ↑(Fintype.card (ι → σ)) ^ 2

                The a priori bound making the advPM value set bounded above.

                theorem QuantumQueryComplexity.bddAbove_advPM_set {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} (f : (ι → σ) → O) :
                BddAbove {r : ℝ | ∃ (Γ : Matrix (ι → σ) (ι → σ) ℝ), IsAdvMatrix f Γ ∧ (∀ (i : ι), ‖Γ.hadamard (advD i)‖ ≤ 1) ∧ r = ‖Γ‖}
                theorem QuantumQueryComplexity.le_advPM {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h1 : IsAdvMatrix f Γ) (h2 : ∀ (i : ι), ‖Γ.hadamard (advD i)‖ ≤ 1) :

                Every feasible matrix certifies a lower bound on advPM.

                theorem QuantumQueryComplexity.advPM_nonneg {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} (f : (ι → σ) → O) :
                theorem QuantumQueryComplexity.advPM_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} {c : ℝ} (hc : ∀ (Γ : Matrix (ι → σ) (ι → σ) ℝ), IsAdvMatrix f Γ → (∀ (i : ι), ‖Γ.hadamard (advD i)‖ ≤ 1) → ‖Γ‖ ≤ c) :
                theorem QuantumQueryComplexity.exists_lt_of_lt_advPM {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} {c : ℝ} (h : c < advPM f) :
                ∃ (Γ : Matrix (ι → σ) (ι → σ) ℝ), IsAdvMatrix f Γ ∧ (∀ (i : ι), ‖Γ.hadamard (advD i)‖ ≤ 1) ∧ c < ‖Γ‖

                ε-accessor: any value below advPM f is beaten by a feasible witness.

                theorem QuantumQueryComplexity.norm_div_le_advPM {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h1 : IsAdvMatrix f Γ) {c : ℝ} (h2 : ∀ (i : ι), ‖Γ.hadamard (advD i)‖ ≤ c) (hc : 0 < c) :

                Un-normalized witness lemma: an adversary matrix all of whose Schur norms are at most c certifies ‖Γ‖ / c ≤ advPM f. This is the paper's ratio formulation, division-free at the point of use.

                theorem QuantumQueryComplexity.adv_le_advPM {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} (f : (ι → σ) → O) :
                theorem QuantumQueryComplexity.advPM_eq_zero_of_forall_eq {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} (h : ∀ (x y : ι → σ), f x = f y) :
                advPM f = 0

                The elementary two-entry witness #

                def QuantumQueryComplexity.pairMatrix {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (x y : ι → σ) :
                Matrix (ι → σ) (ι → σ) ℝ

                The elementary adversary matrix e_{xy} + e_{yx} supported on a single symmetric pair of entries.

                Equations
                Instances For
                  theorem QuantumQueryComplexity.pairMatrix_isHermitian {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (x y : ι → σ) :
                  theorem QuantumQueryComplexity.single_one_mulVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] (a b : ι → σ) (u : (ι → σ) → ℝ) :
                  (Matrix.single a b 1).mulVec u = fun (w : ι → σ) => if a = w then u b else 0
                  theorem QuantumQueryComplexity.pairMatrix_mulVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] (x y : ι → σ) (u : (ι → σ) → ℝ) :
                  (pairMatrix x y).mulVec u = fun (w : ι → σ) => (if x = w then u y else 0) + if y = w then u x else 0
                  theorem QuantumQueryComplexity.pairMatrix_apply_eq_zero {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {x y a b : ι → σ} (h1 : ¬(x = a ∧ y = b)) (h2 : ¬(y = a ∧ x = b)) :
                  pairMatrix x y a b = 0
                  theorem QuantumQueryComplexity.pairMatrix_hadamard_advD {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (x y : ι → σ) (i : ι) :
                  (pairMatrix x y).hadamard (advD i) = if x i = y i then 0 else pairMatrix x y

                  Masking a pair matrix by a difference matrix either leaves it alone or kills it, according to whether the pair differs in that coordinate.

                  theorem QuantumQueryComplexity.norm_pairMatrix {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {x y : ι → σ} (hxy : x ≠ y) :
                  theorem QuantumQueryComplexity.one_le_advPM {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} {x y : ι → σ} (hf : f x ≠ f y) :
                  theorem QuantumQueryComplexity.advPM_eq_zero_iff {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} {f : (ι → σ) → O} :
                  advPM f = 0 ↔ ∀ (x y : ι → σ), f x = f y

                  Bipartite support structure of adversary matrices #

                  An adversary matrix N for g vanishes on same-colored pairs (g u = g v), so it maps vectors supported on one color class into the other class. Consequently an eigenvector with nonzero eigenvalue must have nonzero restriction to both color classes (brestrict_ne_zero, IsAdvMatrix.exists_eigenvector_support). This is the nonvanishing input to the ≥ direction of the composed-matrix norm formula (HLŠ Lemma 16).

                  def QuantumQueryComplexity.brestrict {U : Type u_1} (χ : U → Bool) (b : Bool) (w : U → ℝ) :
                  U → ℝ

                  Restriction of a vector to a color class of the coloring χ.

                  Equations
                  Instances For
                    @[simp]
                    theorem QuantumQueryComplexity.brestrict_apply {U : Type u_1} (χ : U → Bool) (b : Bool) (w : U → ℝ) (u : U) :
                    brestrict χ b w u = if χ u = b then w u else 0
                    theorem QuantumQueryComplexity.brestrict_add_not {U : Type u_1} (χ : U → Bool) (b : Bool) (w : U → ℝ) :
                    brestrict χ b w + brestrict χ (!b) w = w
                    theorem QuantumQueryComplexity.mulVec_brestrict {U : Type u_1} [Fintype U] {M : Matrix U U ℝ} {χ : U → Bool} (hM : ∀ (u v : U), χ u = χ v → M u v = 0) (w : U → ℝ) (b : Bool) :
                    M.mulVec (brestrict χ b w) = brestrict χ (!b) (M.mulVec w)

                    A matrix vanishing on same-colored pairs maps a b-supported vector to a !b-supported one, with the values of the full product.

                    theorem QuantumQueryComplexity.mulVec_brestrict_eigen {U : Type u_1} [Fintype U] {M : Matrix U U ℝ} {χ : U → Bool} (hM : ∀ (u v : U), χ u = χ v → M u v = 0) {w : U → ℝ} {θ : ℝ} (hw : M.mulVec w = θ • w) (b : Bool) :
                    M.mulVec (brestrict χ b w) = θ • brestrict χ (!b) w
                    theorem QuantumQueryComplexity.brestrict_ne_zero {U : Type u_1} [Fintype U] {M : Matrix U U ℝ} {χ : U → Bool} (hM : ∀ (u v : U), χ u = χ v → M u v = 0) {w : U → ℝ} {θ : ℝ} (hw : M.mulVec w = θ • w) (hθ : θ ≠ 0) (hw0 : w ≠ 0) (b : Bool) :
                    brestrict χ b w ≠ 0

                    An eigenvector with nonzero eigenvalue of a color-bipartite matrix has nonzero restriction to each color class.

                    theorem QuantumQueryComplexity.IsAdvMatrix.exists_eigenvector_support {ι : Type u_2} [Fintype ι] [DecidableEq ι] {g : (ι → Bool) → Bool} {N : Matrix (ι → Bool) (ι → Bool) ℝ} (hN : IsAdvMatrix g N) {v : (ι → Bool) → ℝ} {θ : ℝ} (hv : N.mulVec v = θ • v) (hθ : θ ≠ 0) (hv0 : v ≠ 0) (a : Bool) :
                    ∃ (u : ι → Bool), g u = a ∧ v u ≠ 0

                    Wrapper for the composition layer: an eigenvector with nonzero eigenvalue of an adversary matrix for g has support in every color class of g.

                    The Schur-multiplier norm bound #

                    The key estimate ‖X ⊙ P‖ ≤ d * ‖X‖ for a positive semidefinite P whose diagonal entries are at most d (norm_hadamard_posSemidef_le), proved via a Gram decomposition of P and Cauchy–Schwarz. In the composition theorem this replaces the sign-flipping analysis of HLŠ Lemma 16 (following the PSD viewpoint of Belovs–Lee, arXiv:2004.06439 §4).

                    Also: small PSD facts — the all-ones matrix, the 2×2 seed [[R, λ], [λ, R]] for |λ| ≤ R, and M + ‖M‖ • 1 ≥ 0 for symmetric M (BL Lemma 18). The "PSD lift" fact (BL Fact 2) is mathlib's Matrix.PosSemidef.submatrix, which takes an arbitrary index map.

                    theorem QuantumQueryComplexity.posSemidef_allOnes {n : Type u_1} [Finite n] :
                    (Matrix.of fun (x x_1 : n) => 1).PosSemidef

                    The all-ones matrix is positive semidefinite.

                    theorem QuantumQueryComplexity.posSemidef_boolPair {R lam : ℝ} (h : |lam| ≤ R) :
                    (Matrix.of fun (a b : Bool) => if a = b then R else lam).PosSemidef

                    The 2×2 seed: [[R, lam], [lam, R]] is PSD when |lam| ≤ R.

                    theorem QuantumQueryComplexity.norm_hadamard_posSemidef_le {n : Type u_1} [Fintype n] [DecidableEq n] (X : Matrix n n ℝ) {P : Matrix n n ℝ} (hP : P.PosSemidef) {d : ℝ} (hd : 0 ≤ d) (hdiag : ∀ (a : n), P a a ≤ d) :

                    Schur-multiplier bound (Belovs–Lee): if P is positive semidefinite with all diagonal entries at most d, then ‖X ⊙ P‖ ≤ d * ‖X‖.

                    M + ‖M‖ • 1 is positive semidefinite for symmetric M (BL Lemma 18).

                    The composed adversary matrix (hat formulation) #

                    Following Belovs–Lee (arXiv:2004.06439, Definitions 17 and 19), the composed adversary matrix for h = f ∘ gᵏ is built from an outer matrix Γf and inner matrices M i via hat N = N + ‖N‖ • 1:

                    compose g Γf M x y = Γf (tilde g x) (tilde g y) * ∏ i, hat (M i) (x·ᵢ) (y·ᵢ)

                    For a g-shaped N (symmetric, vanishing on pairs with g u = g v), hat N agrees entrywise with the color-block convention of HLŠ Definition 6: same-color blocks are ‖N‖·I, different-color blocks are N.

                    The block decomposition is abstract #

                    The inner inputs are not assumed to form a Boolean cube. Everything below is stated for a composed input type Z equipped with an equivalence e : Z ≃ (α → Y) onto tuples of inner inputs drawn from an arbitrary finite type Y, with a colouring g : α → Y → Bool.

                    This permits composition of promise problems whose inner inputs range over a subtype rather than a cube. The spectral content never sees the cube: the two places two-valuedness is used are the colouring's output and the outer cube α → Bool, and both survive.

                    The original cube statements are recovered verbatim as the instance e := cubeBlocks α β, so no downstream file changes.

                    theorem QuantumQueryComplexity.isHermitian_apply_symm {n : Type u_1} {A : Matrix n n ℝ} (hA : A.IsHermitian) (a b : n) :
                    A a b = A b a

                    The hat matrix #

                    noncomputable def QuantumQueryComplexity.hat {n : Type u_1} [Fintype n] [DecidableEq n] (N : Matrix n n ℝ) :

                    BL Definition 17 in additive form: hat N = N + ‖N‖ • 1.

                    Equations
                    Instances For
                      theorem QuantumQueryComplexity.hat_apply {n : Type u_1} [Fintype n] [DecidableEq n] (N : Matrix n n ℝ) (u v : n) :
                      hat N u v = N u v + ‖N‖ * if u = v then 1 else 0

                      Composition over an abstract block decomposition #

                      def QuantumQueryComplexity.sliceE {α : Type u_1} {Y : Type u_2} {Z : Type u_3} (e : Z ≃ (α → Y)) (z : Z) (i : α) :
                      Y

                      The i-th block of a composed input.

                      Equations
                      Instances For
                        def QuantumQueryComplexity.tildeE {α : Type u_1} {Y : Type u_2} {Z : Type u_3} (e : Z ≃ (α → Y)) (g : α → Y → Bool) (z : Z) :
                        α → Bool

                        The vector of inner-function values of a composed input.

                        Equations
                        Instances For
                          @[simp]
                          theorem QuantumQueryComplexity.sliceE_apply {α : Type u_1} {Y : Type u_2} {Z : Type u_3} (e : Z ≃ (α → Y)) (z : Z) (i : α) :
                          sliceE e z i = e z i
                          @[simp]
                          theorem QuantumQueryComplexity.tildeE_apply {α : Type u_1} {Y : Type u_2} {Z : Type u_3} (e : Z ≃ (α → Y)) (g : α → Y → Bool) (z : Z) (i : α) :
                          tildeE e g z i = g i (sliceE e z i)
                          noncomputable def QuantumQueryComplexity.composeE {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [Fintype Y] [DecidableEq Y] (e : Z ≃ (α → Y)) (g : α → Y → Bool) (Γf : Matrix (α → Bool) (α → Bool) ℝ) (M : α → Matrix Y Y ℝ) :

                          BL Definition 19 over an abstract block decomposition.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            @[simp]
                            theorem QuantumQueryComplexity.composeE_apply {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [Fintype Y] [DecidableEq Y] (e : Z ≃ (α → Y)) (g : α → Y → Bool) (Γf : Matrix (α → Bool) (α → Bool) ℝ) (M : α → Matrix Y Y ℝ) (x y : Z) :
                            composeE e g Γf M x y = Γf (tildeE e g x) (tildeE e g y) * ∏ i : α, hat (M i) (sliceE e x i) (sliceE e y i)
                            theorem QuantumQueryComplexity.composeE_isHermitian {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [Fintype Y] [DecidableEq Y] (e : Z ≃ (α → Y)) (g : α → Y → Bool) {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix Y Y ℝ} (hΓf : Γf.IsHermitian) (hM : ∀ (i : α), (M i).IsHermitian) :
                            (composeE e g Γf M).IsHermitian

                            The cube instance #

                            The original statements, recovered by taking the block decomposition to be the currying equivalence.

                            def QuantumQueryComplexity.cubeBlocks (α : Type u_3) (β : Type u_4) :
                            (α × β → Bool) ≃ (α → β → Bool)

                            The block decomposition of a Boolean cube into α blocks of shape β.

                            Equations
                            Instances For
                              def QuantumQueryComplexity.slice {α : Type u_1} {β : Type u_2} (x : α × β → Bool) (i : α) :
                              β → Bool

                              The i-th block of a composed input.

                              Equations
                              Instances For
                                def QuantumQueryComplexity.tilde {α : Type u_1} {β : Type u_2} (g : α → (β → Bool) → Bool) (x : α × β → Bool) :
                                α → Bool

                                The vector of inner-function values of a composed input.

                                Equations
                                Instances For
                                  @[reducible, inline]
                                  abbrev QuantumQueryComplexity.constFam {α : Type u_1} {β : Type u_2} (g : (β → Bool) → Bool) :
                                  α → (β → Bool) → Bool

                                  The constant family of inner functions (the uniform case).

                                  Equations
                                  Instances For
                                    @[simp]
                                    theorem QuantumQueryComplexity.slice_apply {α : Type u_1} {β : Type u_2} (x : α × β → Bool) (i : α) (j : β) :
                                    slice x i j = x (i, j)
                                    @[simp]
                                    theorem QuantumQueryComplexity.tilde_apply {α : Type u_1} {β : Type u_2} (g : α → (β → Bool) → Bool) (x : α × β → Bool) (i : α) :
                                    tilde g x i = g i (slice x i)
                                    noncomputable def QuantumQueryComplexity.compose {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] [DecidableEq β] (g : α → (β → Bool) → Bool) (Γf : Matrix (α → Bool) (α → Bool) ℝ) (M : α → Matrix (β → Bool) (β → Bool) ℝ) :
                                    Matrix (α × β → Bool) (α × β → Bool) ℝ

                                    BL Definition 19, uniform-alphabet form: the composed matrix.

                                    Equations
                                    Instances For
                                      @[simp]
                                      theorem QuantumQueryComplexity.compose_apply {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] [DecidableEq β] (g : α → (β → Bool) → Bool) (Γf : Matrix (α → Bool) (α → Bool) ℝ) (M : α → Matrix (β → Bool) (β → Bool) ℝ) (x y : α × β → Bool) :
                                      compose g Γf M x y = Γf (tilde g x) (tilde g y) * ∏ i : α, hat (M i) (slice x i) (slice y i)
                                      theorem QuantumQueryComplexity.compose_isHermitian {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] [DecidableEq β] (g : α → (β → Bool) → Bool) {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix (β → Bool) (β → Bool) ℝ} (hΓf : Γf.IsHermitian) (hM : ∀ (i : α), (M i).IsHermitian) :

                                      The dual (minimisation) form of the adversary bound #

                                      The dual of the adversary SDP (Lee–Mittal–Reichardt–Špalek–Szegedy; stated as Theorem 7 of Belovs–Lee, arXiv:2004.06439) asks for two families of vectors u x i, v x i indexed by inputs x and query positions i, satisfying

                                      ∑_{i : x i ≠ y i} ⟪u x i, v y i⟫ = 1 if g x ≠ g y, and = 0 if g x = g y,

                                      with objective max_x ∑_i ‖u x i‖² (and the same for v). The constraints on pairs with g x = g y are the extra ones isolated by LMRSS; they are what makes dual solutions compose.

                                      This section defines feasible dual solutions (DualPair), the dual value advDual as an infimum of costs, and proves weak duality advPM g ≤ advDual g (advPM_le_advDual) by the same Gram-plus-Cauchy–Schwarz argument that underlies the Schur-multiplier bound.

                                      Strong duality is proved later in SourceDualityMain by Hahn–Banach separation: advDual_eq_advPM identifies the two values, and advPM_composeFun_eq gives unconditional exact Boolean block composition.

                                      structure QuantumQueryComplexity.DualPair {ι : Type u_4} [Fintype ι] {σ : Type u_5} [DecidableEq σ] {O : Type u_6} [DecidableEq O] (K : Type u_7) [Fintype K] (g : (ι → σ) → O) :
                                      Type (max (max u_4 u_5) u_7)

                                      A feasible solution of the dual program for g, with vectors of dimension K. DecidableEq σ is what makes the coordinate mask if x i = y i meaningful, and DecidableEq O the output test if g x = g y; no finiteness of σ is needed here, since the constraint never sums over inputs.

                                      • u : (ι → σ) → ι → K → ℝ

                                        The first vector family.

                                      • v : (ι → σ) → ι → K → ℝ

                                        The second vector family.

                                      • constraint (x y : ι → σ) : (∑ i : ι, if x i = y i then 0 else ∑ k : K, self.u x i k * self.v y i k) = if g x = g y then 0 else 1

                                        The dual feasibility constraint, including the LMRSS constraints on pairs with equal g-value.

                                      Instances For
                                        def QuantumQueryComplexity.DualPair.IsCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) (c : ℝ) :

                                        The cost of a dual solution is bounded by c.

                                        Equations
                                        • P.IsCostLe c = ((∀ (x : ι → σ), ∑ i : ι, ∑ k : K, P.u x i k * P.u x i k ≤ c) ∧ ∀ (x : ι → σ), ∑ i : ι, ∑ k : K, P.v x i k * P.v x i k ≤ c)
                                        Instances For
                                          theorem QuantumQueryComplexity.DualPair.IsCostLe.mono {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} {P : DualPair K g} {c d : ℝ} (h : P.IsCostLe c) (hcd : c ≤ d) :
                                          theorem QuantumQueryComplexity.DualPair.isCostLe_nonneg {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} [Nonempty σ] {P : DualPair K g} {c : ℝ} (h : P.IsCostLe c) :
                                          0 ≤ c
                                          def QuantumQueryComplexity.DualPair.reindex {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} {K' : Type u_5} [Fintype K] [Fintype K'] {g : (ι → σ) → O} (P : DualPair K g) (e : K ≃ K') :

                                          Transporting a dual solution along a bijection of the dimension type.

                                          Equations
                                          • P.reindex e = { u := fun (x : ι → σ) (i : ι) (k' : K') => P.u x i (e.symm k'), v := fun (x : ι → σ) (i : ι) (k' : K') => P.v x i (e.symm k'), constraint := ⋯ }
                                          Instances For
                                            theorem QuantumQueryComplexity.DualPair.reindex_isCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} {K' : Type u_5} [Fintype K] [Fintype K'] {g : (ι → σ) → O} {P : DualPair K g} {c : ℝ} (h : P.IsCostLe c) (e : K ≃ K') :

                                            Weak duality #

                                            The two estimates behind weak duality are stated for an arbitrary finite type X of inputs rather than for the cube ι → σ. Nothing in them uses the product structure — only that the matrices are indexed by inputs — and the extra generality is what lets SourcePromiseDefs reuse them verbatim for a promise domain.

                                            theorem QuantumQueryComplexity.sum_reweight_le {ι : Type u_1} [Fintype ι] {X : Type u_4} [Fintype X] {K : Type u_5} [Fintype K] (w : X → ℝ) (U : X → ι → K → ℝ) {c : ℝ} (h : ∀ (x : X), ∑ i : ι, ∑ k : K, U x i k * U x i k ≤ c) :
                                            (∑ p : ι × K, (fun (x : X) => w x * U x p.1 p.2) ⬝ᵥ fun (x : X) => w x * U x p.1 p.2) ≤ c * w ⬝ᵥ w
                                            theorem QuantumQueryComplexity.key_bound {ι : Type u_1} [Fintype ι] {X : Type u_4} [Fintype X] [DecidableEq X] {K : Type u_5} [Fintype K] (M : ι → Matrix X X ℝ) (hM : ∀ (i : ι), ‖M i‖ ≤ 1) (a b : X → ℝ) (U V : X → ι → K → ℝ) {c : ℝ} (hc : 0 ≤ c) (hU : ∀ (x : X), ∑ i : ι, ∑ k : K, U x i k * U x i k ≤ c) (hV : ∀ (x : X), ∑ i : ι, ∑ k : K, V x i k * V x i k ≤ c) :
                                            |∑ p : ι × K, (fun (x : X) => a x * U x p.1 p.2) ⬝ᵥ (M p.1).mulVec fun (y : X) => b y * V y p.1 p.2| ≤ c * √(a ⬝ᵥ a) * √(b ⬝ᵥ b)

                                            The core estimate of weak duality: a sum of bilinear forms of norm at most one, reweighted by dual vectors of cost at most c, is bounded by c times the product of the vector lengths.

                                            theorem QuantumQueryComplexity.advPM_le_of_dualPair {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_5} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) {c : ℝ} (hc : 0 ≤ c) (hP : P.IsCostLe c) :

                                            Weak duality: every feasible dual solution of cost at most c bounds the adversary bound by c.

                                            A feasible dual solution always exists #

                                            def QuantumQueryComplexity.diffCard {ι : Type u_1} [Fintype ι] (x y : ι → Bool) :

                                            The number of coordinates on which two inputs differ.

                                            Equations
                                            Instances For
                                              theorem QuantumQueryComplexity.diffCard_ne_zero {ι : Type u_1} [Fintype ι] {x y : ι → Bool} (h : x ≠ y) :
                                              theorem QuantumQueryComplexity.sum_ite_diff_const {ι : Type u_1} [Fintype ι] (x y : ι → Bool) (C : ℝ) :
                                              (∑ i : ι, if x i = y i then 0 else C) = ↑(diffCard x y) * C
                                              noncomputable def QuantumQueryComplexity.trivialDual {ι : Type u_1} [Fintype ι] [DecidableEq ι] (g : (ι → Bool) → Bool) :
                                              DualPair (ι → Bool) g

                                              A dual solution of finite (very lossy) cost, showing the dual program is always feasible: u x i is the standard basis vector of x, and the mass of v y i is spread over the coordinates where the inputs differ.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                theorem QuantumQueryComplexity.trivialDual_isCostLe {ι : Type u_1} [Fintype ι] [DecidableEq ι] (g : (ι → Bool) → Bool) :
                                                (trivialDual g).IsCostLe (↑(Fintype.card ι) + ↑(Fintype.card (ι → Bool)))

                                                The dual value #

                                                def QuantumQueryComplexity.dualCosts {ι : Type u_1} [Fintype ι] (g : (ι → Bool) → Bool) :

                                                The set of achievable dual costs (with dimensions normalised to Fin n).

                                                Equations
                                                Instances For
                                                  noncomputable def QuantumQueryComplexity.advDual {ι : Type u_1} [Fintype ι] (g : (ι → Bool) → Bool) :

                                                  The value of the dual program.

                                                  Equations
                                                  Instances For
                                                    theorem QuantumQueryComplexity.advDual_nonneg {ι : Type u_1} [Fintype ι] (g : (ι → Bool) → Bool) :
                                                    theorem QuantumQueryComplexity.advDual_le_of_dualPair {ι : Type u_1} [Fintype ι] {K : Type u_5} [Fintype K] {g : (ι → Bool) → Bool} (P : DualPair K g) {c : ℝ} (hc : 0 ≤ c) (hP : P.IsCostLe c) :

                                                    Any feasible dual solution bounds the dual value.

                                                    theorem QuantumQueryComplexity.advPM_le_advDual {ι : Type u_1} [Fintype ι] [DecidableEq ι] (g : (ι → Bool) → Bool) :

                                                    Weak duality.

                                                    theorem QuantumQueryComplexity.exists_dualPair_of_lt {ι : Type u_1} [Fintype ι] {g : (ι → Bool) → Bool} {c : ℝ} (h : advDual g < c) :
                                                    ∃ (n : ℕ) (P : DualPair (Fin n) g), P.IsCostLe c

                                                    Any value above the dual optimum is achieved by some feasible dual solution.

                                                    The b-sum form of the composed matrix #

                                                    The first rewriting lemma (composeE_apply_sum): the entry composeE e g Γf M x y can be written as a sum over all outer inputs b : α → Bool, with guards if g i (sliceE e y i) = b i making the b = tildeE e g y fiber automatic. This eliminates the non-factoring occurrence Γf x_tilde y_tilde before any sum/product interchange.

                                                    As in SourceCompositionHat the block decomposition is abstract; the cube statement is the instance at cubeBlocks.

                                                    theorem QuantumQueryComplexity.composeE_apply_sum {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [DecidableEq α] [Fintype Y] [DecidableEq Y] (e : Z ≃ (α → Y)) (g : α → Y → Bool) (Γf : Matrix (α → Bool) (α → Bool) ℝ) (M : α → Matrix Y Y ℝ) (x y : Z) :
                                                    composeE e g Γf M x y = ∑ b : α → Bool, Γf (tildeE e g x) b * ∏ i : α, if g i (sliceE e y i) = b i then hat (M i) (sliceE e x i) (sliceE e y i) else 0
                                                    theorem QuantumQueryComplexity.compose_apply_sum {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (g : α → (β → Bool) → Bool) (Γf : Matrix (α → Bool) (α → Bool) ℝ) (M : α → Matrix (β → Bool) (β → Bool) ℝ) (x y : α × β → Bool) :
                                                    compose g Γf M x y = ∑ b : α → Bool, Γf (tilde g x) b * ∏ i : α, if g i (slice y i) = b i then hat (M i) (slice x i) (slice y i) else 0

                                                    The outer auxiliary matrices Γf ⊙ Emat and their PSD structure #

                                                    For an assignment of eigenvalues lamv i (with |lamv i| ≤ R i), the matrix

                                                    Emat R lamv a b = ∏ i, if a i = b i then R i else lamv i

                                                    is positive semidefinite: it is the entrywise product over i : α of lifts of the 2×2 seeds [[R i, lamv i], [lamv i, R i]] along the coordinate maps a ↦ a i (mathlib's Matrix.PosSemidef.submatrix — BL Fact 2 — plus the Schur product theorem Matrix.PosSemidef.hadamard). Its diagonal is ∏ i, R i, so the Schur-multiplier bound gives ‖Γf ⊙ Emat R lamv‖ ≤ (∏ i, R i) * ‖Γf‖ — replacing the sign-flipping analysis of HLŠ Lemma 16.

                                                    At a "vertex" (lamv i = ε i * R i with ε i = ±1), Γf ⊙ Emat becomes a ±1-diagonal conjugate of (∏ R) • Γf (hadamard_Emat_vertex), which is the witness used in the ≥ direction.

                                                    theorem QuantumQueryComplexity.posSemidef_prod_lift {ι : Type u_2} {E : Type u_3} {κ : Type u_4} {F : ι → Matrix κ κ ℝ} (hF : ∀ (i : ι), (F i).PosSemidef) (e : ι → E → κ) (s : Finset ι) [Finite E] :
                                                    (Matrix.of fun (a b : E) => ∏ i ∈ s, F i (e i a) (e i b)).PosSemidef

                                                    Entrywise products of PSD matrices lifted along arbitrary maps are PSD (Finset induction from the Schur product theorem; BL Facts 2 and 3).

                                                    theorem QuantumQueryComplexity.posSemidef_prod_eval {α : Type u_1} {F : α → Matrix Bool Bool ℝ} (hF : ∀ (i : α), (F i).PosSemidef) (s : Finset α) [Finite α] :
                                                    (Matrix.of fun (a b : α → Bool) => ∏ i ∈ s, F i (a i) (b i)).PosSemidef

                                                    Entrywise products of PSD matrices lifted along coordinate evaluations are PSD.

                                                    noncomputable def QuantumQueryComplexity.Emat {α : Type u_1} [Fintype α] (R lamv : α → ℝ) :
                                                    Matrix (α → Bool) (α → Bool) ℝ

                                                    The outer auxiliary matrix of HLŠ Lemma 16 (denoted A_c there, with lamv i the eigenvalue selected in slot i).

                                                    Equations
                                                    Instances For
                                                      @[simp]
                                                      theorem QuantumQueryComplexity.Emat_apply {α : Type u_1} [Fintype α] (R lamv : α → ℝ) (a b : α → Bool) :
                                                      Emat R lamv a b = ∏ i : α, if a i = b i then R i else lamv i
                                                      theorem QuantumQueryComplexity.Emat_isHermitian {α : Type u_1} [Fintype α] (R lamv : α → ℝ) :
                                                      (Emat R lamv).IsHermitian
                                                      theorem QuantumQueryComplexity.Emat_posSemidef {α : Type u_1} [Fintype α] {R lamv : α → ℝ} (h : ∀ (i : α), |lamv i| ≤ R i) :
                                                      (Emat R lamv).PosSemidef
                                                      theorem QuantumQueryComplexity.Emat_diag {α : Type u_1} [Fintype α] (R lamv : α → ℝ) (a : α → Bool) :
                                                      Emat R lamv a a = ∏ i : α, R i
                                                      theorem QuantumQueryComplexity.norm_hadamard_Emat_le {α : Type u_1} [Fintype α] [DecidableEq α] (Γf : Matrix (α → Bool) (α → Bool) ℝ) {R lamv : α → ℝ} (hR : ∀ (i : α), 0 ≤ R i) (h : ∀ (i : α), |lamv i| ≤ R i) :
                                                      ‖Γf.hadamard (Emat R lamv)‖ ≤ (∏ i : α, R i) * ‖Γf‖

                                                      The Schur-multiplier estimate for the outer auxiliary matrix.

                                                      def QuantumQueryComplexity.chiSign {α : Type u_1} [Fintype α] (ε : α → ℝ) :
                                                      (α → Bool) → ℝ

                                                      The ±1 character vector attached to a sign assignment.

                                                      Equations
                                                      Instances For
                                                        theorem QuantumQueryComplexity.chiSign_mul_self {α : Type u_1} [Fintype α] {ε : α → ℝ} (hε : ∀ (i : α), ε i * ε i = 1) (a : α → Bool) :
                                                        chiSign ε a * chiSign ε a = 1
                                                        theorem QuantumQueryComplexity.Emat_vertex {α : Type u_1} [Fintype α] {R ε : α → ℝ} (hε : ∀ (i : α), ε i * ε i = 1) (a b : α → Bool) :
                                                        Emat R (fun (i : α) => ε i * R i) a b = (∏ i : α, R i) * (chiSign ε a * chiSign ε b)
                                                        theorem QuantumQueryComplexity.diagonal_chiSign_mul_self {α : Type u_1} [Fintype α] [DecidableEq α] {ε : α → ℝ} (hε : ∀ (i : α), ε i * ε i = 1) :
                                                        theorem QuantumQueryComplexity.chiSign_diagonal_mulVec_ne_zero {α : Type u_1} [Fintype α] [DecidableEq α] {ε : α → ℝ} (hε : ∀ (i : α), ε i * ε i = 1) {w : (α → Bool) → ℝ} (hw0 : w ≠ 0) :
                                                        theorem QuantumQueryComplexity.hadamard_Emat_vertex {α : Type u_1} [Fintype α] [DecidableEq α] (Γf : Matrix (α → Bool) (α → Bool) ℝ) {R ε : α → ℝ} (hε : ∀ (i : α), ε i * ε i = 1) :
                                                        Γf.hadamard (Emat R fun (i : α) => ε i * R i) = (∏ i : α, R i) • (Matrix.diagonal (chiSign ε) * Γf * Matrix.diagonal (chiSign ε))

                                                        At a sign vertex, Γf ⊙ Emat is a ±1-diagonal conjugate of (∏ R) • Γf.

                                                        The adversary bound on a promise domain #

                                                        advPM f is a single worst-case number attached to a total function on the cube ι → σ. Some bounds are genuinely instance-sensitive: the semilattice product costs O(√(n log|L_x|)) where L_x is generated by the letters of the input x at hand, and that cannot be said with a free x on only one side of an inequality about a total function.

                                                        The fix is to let the inputs be an arbitrary finite type X together with an observation map

                                                        read : X → ι → σ,

                                                        so that a query at i returns read x i. Every occurrence of x i = y i in the definitions becomes read x i = read y i, and nothing else changes: advPMOn, DualPairOn and weak duality are the same statements with the cube replaced by X. The total case is X = (ι → σ) with read x = x.

                                                        The point of the definitions is DualPair.restrictTo: a dual solution for a total function restricts to the promise at no cost, and the restricted cost is the maximum of the pointwise masses over the promise only. So a bound whose per-input analysis needs a hypothesis about that input — a critical budget, say — gives a promise bound as soon as the promise guarantees the hypothesis.

                                                        The primal bound #

                                                        def QuantumQueryComplexity.advDOn {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (i : ι) :

                                                        The difference matrix of a promise domain: 1 exactly when a query at i distinguishes the two promise inputs.

                                                        Equations
                                                        Instances For
                                                          @[simp]
                                                          theorem QuantumQueryComplexity.advDOn_apply {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (i : ι) (x y : X) :
                                                          advDOn read i x y = if read x i = read y i then 0 else 1
                                                          theorem QuantumQueryComplexity.advDOn_isHermitian {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (i : ι) :
                                                          theorem QuantumQueryComplexity.hadamard_advDOn_apply {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (Γ : Matrix X X ℝ) (i : ι) (x y : X) :
                                                          Γ.hadamard (advDOn read i) x y = if read x i = read y i then 0 else Γ x y
                                                          def QuantumQueryComplexity.IsAdvMatrixOn {X : Type u_3} {O : Type u_4} (f : X → O) (Γ : Matrix X X ℝ) :

                                                          An adversary matrix on a promise domain.

                                                          Equations
                                                          Instances For
                                                            theorem QuantumQueryComplexity.isAdvMatrixOn_zero {X : Type u_3} {O : Type u_4} (f : X → O) :
                                                            noncomputable def QuantumQueryComplexity.advPMOn {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} (read : X → ι → σ) (f : X → O) :

                                                            The adversary bound of a function on a promise domain.

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              theorem QuantumQueryComplexity.advPMOn_set_nonempty {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} (read : X → ι → σ) (f : X → O) :
                                                              {r : ℝ | ∃ (Γ : Matrix X X ℝ), IsAdvMatrixOn f Γ ∧ (∀ (i : ι), ‖Γ.hadamard (advDOn read i)‖ ≤ 1) ∧ r = ‖Γ‖}.Nonempty
                                                              theorem QuantumQueryComplexity.advPMOn_le {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} {c : ℝ} (hc : ∀ (Γ : Matrix X X ℝ), IsAdvMatrixOn f Γ → (∀ (i : ι), ‖Γ.hadamard (advDOn read i)‖ ≤ 1) → ‖Γ‖ ≤ c) :
                                                              advPMOn read f ≤ c

                                                              The dual #

                                                              structure QuantumQueryComplexity.DualPairOn {ι : Type u_5} [Fintype ι] {σ : Type u_6} [DecidableEq σ] {X : Type u_7} [Fintype X] {O : Type u_8} [DecidableEq O] (read : X → ι → σ) (K : Type u_9) [Fintype K] (f : X → O) :
                                                              Type (max (max u_5 u_7) u_9)

                                                              A feasible dual solution on a promise domain.

                                                              • u : X → ι → K → ℝ

                                                                The first vector family.

                                                              • v : X → ι → K → ℝ

                                                                The second vector family.

                                                              • constraint (x y : X) : (∑ i : ι, if read x i = read y i then 0 else ∑ k : K, self.u x i k * self.v y i k) = if f x = f y then 0 else 1

                                                                Feasibility, with the mask read through read.

                                                              Instances For
                                                                def QuantumQueryComplexity.DualPairOn.IsCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {read : X → ι → σ} {f : X → O} (P : DualPairOn read K f) (c : ℝ) :

                                                                The cost of a dual solution on a promise domain.

                                                                Equations
                                                                • P.IsCostLe c = ((∀ (x : X), ∑ i : ι, ∑ k : K, P.u x i k * P.u x i k ≤ c) ∧ ∀ (x : X), ∑ i : ι, ∑ k : K, P.v x i k * P.v x i k ≤ c)
                                                                Instances For
                                                                  theorem QuantumQueryComplexity.DualPairOn.IsCostLe.mono {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {read : X → ι → σ} {f : X → O} {P : DualPairOn read K f} {c d : ℝ} (h : P.IsCostLe c) (hcd : c ≤ d) :
                                                                  theorem QuantumQueryComplexity.advPMOn_le_of_dualPairOn {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {read : X → ι → σ} {f : X → O} (P : DualPairOn read K f) {c : ℝ} (hc : 0 ≤ c) (hP : P.IsCostLe c) :
                                                                  advPMOn read f ≤ c

                                                                  Weak duality on a promise domain. The same Gram-plus-Cauchy–Schwarz argument as advPM_le_of_dualPair; only the mask is read through read.

                                                                  Restricting a total dual solution to a promise #

                                                                  def QuantumQueryComplexity.DualPair.restrictTo {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) (read : X → ι → σ) :
                                                                  DualPairOn read K fun (x : X) => g (read x)

                                                                  A total dual solution restricted to a promise domain. The vectors are unchanged: the promise constraint at (x, y) is the total constraint at (read x, read y).

                                                                  Equations
                                                                  • P.restrictTo read = { u := fun (x : X) => P.u (read x), v := fun (y : X) => P.v (read y), constraint := ⋯ }
                                                                  Instances For
                                                                    theorem QuantumQueryComplexity.DualPair.restrictTo_isCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {g : (ι → σ) → O} {P : DualPair K g} {read : X → ι → σ} {c : ℝ} (hu : ∀ (x : X), ∑ i : ι, ∑ k : K, P.u (read x) i k * P.u (read x) i k ≤ c) (hv : ∀ (x : X), ∑ i : ι, ∑ k : K, P.v (read x) i k * P.v (read x) i k ≤ c) :
                                                                    (P.restrictTo read).IsCostLe c

                                                                    The restricted cost is the maximum of the pointwise masses over the promise only — which is the entire point of the construction.

                                                                    Gram encoding of the dual program, on a promise domain #

                                                                    The promise-domain mirror of SourceDualityGram: the input space is an abstract finite X read through read : X → ι → σ, the constraint mask is read x i = read y i, and the target is [f x ≠ f y]. Everything else — the convexification by passing to Gram matrices, the rank-one decomposition back to a DualPairOn — is the same change of variables.

                                                                    The total case is the instance X = ι → σ, read = id; it is kept as the separate SourceDualityGram because its statements (DualPair, advPM) are pinned by downstream consumers.

                                                                    @[reducible, inline]
                                                                    abbrev QuantumQueryComplexity.GramIdxOn (X : Type u_5) (ι : Type u_6) :
                                                                    Type (max u_6 u_5)

                                                                    Index type for the Gram matrix of a promise dual solution: (x, i, false) indexes the vector u x i and (x, i, true) indexes v x i.

                                                                    Equations
                                                                    Instances For

                                                                      The affine data of the promise dual program #

                                                                      def QuantumQueryComplexity.dualTargetOn {X : Type u_3} {O : Type u_4} [DecidableEq O] (f : X → O) :

                                                                      The right-hand side of the dual feasibility constraint on the promise domain: 1 on pairs with distinct values, 0 otherwise.

                                                                      Equations
                                                                      Instances For
                                                                        @[simp]
                                                                        theorem QuantumQueryComplexity.dualTargetOn_apply {X : Type u_3} {O : Type u_4} [DecidableEq O] (f : X → O) (x y : X) :
                                                                        dualTargetOn f x y = if f x = f y then 0 else 1
                                                                        theorem QuantumQueryComplexity.dualTargetOn_comm {X : Type u_3} {O : Type u_4} [DecidableEq O] (f : X → O) (x y : X) :
                                                                        def QuantumQueryComplexity.gramROn {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) :

                                                                        The left-hand side of the dual feasibility constraint, as a function of the Gram matrix, with the mask read through read.

                                                                        Equations
                                                                        Instances For
                                                                          @[simp]
                                                                          theorem QuantumQueryComplexity.gramROn_apply {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) (x y : X) :
                                                                          gramROn read G x y = ∑ i : ι, if read x i = read y i then 0 else G (x, i, false) (y, i, true)
                                                                          def QuantumQueryComplexity.gramCostOn {ι : Type u_1} [Fintype ι] {X : Type u_3} (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) (b : Bool) (x : X) :

                                                                          The dual objective, as a function of the Gram matrix.

                                                                          Equations
                                                                          Instances For

                                                                            Linearity #

                                                                            theorem QuantumQueryComplexity.gramROn_add {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (G H : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) :
                                                                            gramROn read (G + H) = gramROn read G + gramROn read H
                                                                            theorem QuantumQueryComplexity.gramROn_smul {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (c : ℝ) (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) :
                                                                            gramROn read (c • G) = c • gramROn read G
                                                                            theorem QuantumQueryComplexity.gramCostOn_add {ι : Type u_1} [Fintype ι] {X : Type u_3} (G H : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) (b : Bool) (x : X) :
                                                                            gramCostOn (G + H) b x = gramCostOn G b x + gramCostOn H b x
                                                                            theorem QuantumQueryComplexity.gramCostOn_smul {ι : Type u_1} [Fintype ι] {X : Type u_3} (c : ℝ) (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) (b : Bool) (x : X) :
                                                                            gramCostOn (c • G) b x = c * gramCostOn G b x
                                                                            theorem QuantumQueryComplexity.gramCostOn_nonneg {ι : Type u_1} [Fintype ι] {X : Type u_3} {G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ} (hG : G.PosSemidef) (b : Bool) (x : X) :
                                                                            0 ≤ gramCostOn G b x

                                                                            A positive semidefinite Gram matrix has nonnegative costs.

                                                                            Rank-one Gram matrices #

                                                                            theorem QuantumQueryComplexity.gramROn_vecMulVec {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (w : GramIdxOn X ι → ℝ) (x y : X) :
                                                                            gramROn read (Matrix.vecMulVec w w) x y = ∑ i : ι, if read x i = read y i then 0 else w (x, i, false) * w (y, i, true)
                                                                            @[simp]
                                                                            theorem QuantumQueryComplexity.gramCostOn_vecMulVec {ι : Type u_1} [Fintype ι] {X : Type u_3} (w : GramIdxOn X ι → ℝ) (b : Bool) (x : X) :
                                                                            gramCostOn (Matrix.vecMulVec w w) b x = ∑ i : ι, w (x, i, b) * w (x, i, b)
                                                                            theorem QuantumQueryComplexity.trace_vecMulVec_on {ι : Type u_1} [Fintype ι] {X : Type u_3} [Fintype X] (w : GramIdxOn X ι → ℝ) :
                                                                            (Matrix.vecMulVec w w).trace = ∑ z : GramIdxOn X ι, w z * w z

                                                                            From a Gram matrix to a dual solution #

                                                                            theorem QuantumQueryComplexity.exists_dualPairOn_of_gram {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] {O : Type u_4} [DecidableEq O] {read : X → ι → σ} {f : X → O} {G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ} (hG : G.PosSemidef) (hR : gramROn read G = dualTargetOn f) {c : ℝ} (hc : ∀ (b : Bool) (x : X), gramCostOn G b x ≤ c) :
                                                                            ∃ (m : ℕ) (P : DualPairOn read (Fin m) f), P.IsCostLe c

                                                                            Every positive semidefinite matrix satisfying the promise dual constraints is the Gram matrix of a feasible DualPairOn of the same cost.

                                                                            def QuantumQueryComplexity.DualPairOn.toTotal {ι : Type u_1} {σ : Type u_2} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] {O : Type u_3} {K : Type u_4} [DecidableEq O] [Fintype K] {g : (ι → σ) → O} (P : DualPairOn (fun (x : ι → σ) => x) K g) :

                                                                            A promise certificate for the identity read is a total-input certificate.

                                                                            Equations
                                                                            Instances For
                                                                              theorem QuantumQueryComplexity.DualPairOn.toTotal_isCostLe {ι : Type u_1} {σ : Type u_2} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] {O : Type u_3} {K : Type u_4} [DecidableEq O] [Fintype K] {g : (ι → σ) → O} {c : ℝ} {P : DualPairOn (fun (x : ι → σ) => x) K g} (h : P.IsCostLe c) :

                                                                              The conversion preserves both vector families and hence the cost bound.

                                                                              Gram encoding of the dual program #

                                                                              A feasible dual solution (DualPair) is a pair of vector families u x i, v y i; the dual constraints and the dual cost depend on those families only through their inner products, i.e. only through the Gram matrix of the whole family. This section makes that change of variables explicit, which is what convexifies the dual program: the set of feasible Gram matrices is the intersection of the (convex) positive semidefinite cone with affine constraints, whereas the set of feasible vector families is not convex.

                                                                              Indexing the combined family by GramIdx ι σ = (ι → σ) × ι × Bool — false tagging a u-vector and true a v-vector — the dictionary is

                                                                              Both directions of the translation are proved: gramOfDual builds the Gram matrix of a dual solution, and exists_dualPair_of_gram extracts a dual solution of dimension Fin m from any positive semidefinite G satisfying the constraints, via the rank-one decomposition Matrix.posSemidef_iff_eq_sum_vecMulVec.

                                                                              @[reducible, inline]
                                                                              abbrev QuantumQueryComplexity.GramIdx (ι : Type u_4) (σ : Type u_5) :
                                                                              Type (max u_4 u_5)

                                                                              Index type for the Gram matrix of a dual solution: (x, i, false) indexes the vector u x i and (x, i, true) indexes v x i.

                                                                              Equations
                                                                              Instances For

                                                                                The affine data of the dual program #

                                                                                def QuantumQueryComplexity.dualTarget {ι : Type u_1} {σ : Type u_2} {O : Type u_3} [DecidableEq O] (g : (ι → σ) → O) :
                                                                                Matrix (ι → σ) (ι → σ) ℝ

                                                                                The right-hand side of the dual feasibility constraint: dualTarget g x y = 1 if g x ≠ g y and 0 otherwise.

                                                                                Equations
                                                                                Instances For
                                                                                  @[simp]
                                                                                  theorem QuantumQueryComplexity.dualTarget_apply {ι : Type u_1} {σ : Type u_2} {O : Type u_3} [DecidableEq O] (g : (ι → σ) → O) (x y : ι → σ) :
                                                                                  dualTarget g x y = if g x = g y then 0 else 1
                                                                                  theorem QuantumQueryComplexity.dualTarget_comm {ι : Type u_1} {σ : Type u_2} {O : Type u_3} [DecidableEq O] (g : (ι → σ) → O) (x y : ι → σ) :
                                                                                  dualTarget g y x = dualTarget g x y
                                                                                  def QuantumQueryComplexity.gramR {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) :
                                                                                  Matrix (ι → σ) (ι → σ) ℝ

                                                                                  The left-hand side of the dual feasibility constraint, as a function of the Gram matrix.

                                                                                  Equations
                                                                                  Instances For
                                                                                    @[simp]
                                                                                    theorem QuantumQueryComplexity.gramR_apply {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) (x y : ι → σ) :
                                                                                    gramR G x y = ∑ i : ι, if x i = y i then 0 else G (x, i, false) (y, i, true)
                                                                                    def QuantumQueryComplexity.gramCost {ι : Type u_1} [Fintype ι] {σ : Type u_2} (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) (b : Bool) (x : ι → σ) :

                                                                                    The dual objective, as a function of the Gram matrix: gramCost G false x is ∑ i, ‖u x i‖² and gramCost G true x is ∑ i, ‖v x i‖².

                                                                                    Equations
                                                                                    Instances For

                                                                                      Linearity #

                                                                                      theorem QuantumQueryComplexity.gramR_add {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (G H : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) :
                                                                                      gramR (G + H) = gramR G + gramR H
                                                                                      theorem QuantumQueryComplexity.gramR_smul {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (c : ℝ) (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) :
                                                                                      gramR (c • G) = c • gramR G
                                                                                      theorem QuantumQueryComplexity.gramCost_add {ι : Type u_1} [Fintype ι] {σ : Type u_2} (G H : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) (b : Bool) (x : ι → σ) :
                                                                                      gramCost (G + H) b x = gramCost G b x + gramCost H b x
                                                                                      theorem QuantumQueryComplexity.gramCost_smul {ι : Type u_1} [Fintype ι] {σ : Type u_2} (c : ℝ) (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) (b : Bool) (x : ι → σ) :
                                                                                      gramCost (c • G) b x = c * gramCost G b x
                                                                                      theorem QuantumQueryComplexity.trace_eq_sum_gramCost {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) :
                                                                                      G.trace = ∑ x : ι → σ, gramCost G false x + ∑ x : ι → σ, gramCost G true x

                                                                                      The trace splits as the total cost of the two sides.

                                                                                      theorem QuantumQueryComplexity.gramCost_nonneg {ι : Type u_1} [Fintype ι] {σ : Type u_2} {G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ} (hG : G.PosSemidef) (b : Bool) (x : ι → σ) :
                                                                                      0 ≤ gramCost G b x

                                                                                      A positive semidefinite Gram matrix has nonnegative costs.

                                                                                      Rank-one Gram matrices #

                                                                                      theorem QuantumQueryComplexity.gramR_vecMulVec {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (w : GramIdx ι σ → ℝ) (x y : ι → σ) :
                                                                                      gramR (Matrix.vecMulVec w w) x y = ∑ i : ι, if x i = y i then 0 else w (x, i, false) * w (y, i, true)
                                                                                      @[simp]
                                                                                      theorem QuantumQueryComplexity.gramCost_vecMulVec {ι : Type u_1} [Fintype ι] {σ : Type u_2} (w : GramIdx ι σ → ℝ) (b : Bool) (x : ι → σ) :
                                                                                      gramCost (Matrix.vecMulVec w w) b x = ∑ i : ι, w (x, i, b) * w (x, i, b)
                                                                                      theorem QuantumQueryComplexity.trace_vecMulVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] (w : GramIdx ι σ → ℝ) :
                                                                                      (Matrix.vecMulVec w w).trace = ∑ z : GramIdx ι σ, w z * w z

                                                                                      From a dual solution to its Gram matrix #

                                                                                      def QuantumQueryComplexity.dualVec {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) :
                                                                                      Matrix (GramIdx ι σ) K ℝ

                                                                                      The two vector families of a dual solution, packed into a single matrix whose rows are indexed by GramIdx ι σ.

                                                                                      Equations
                                                                                      Instances For
                                                                                        @[simp]
                                                                                        theorem QuantumQueryComplexity.dualVec_false {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) (x : ι → σ) (i : ι) (k : K) :
                                                                                        dualVec P (x, i, false) k = P.u x i k
                                                                                        @[simp]
                                                                                        theorem QuantumQueryComplexity.dualVec_true {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) (x : ι → σ) (i : ι) (k : K) :
                                                                                        dualVec P (x, i, true) k = P.v x i k
                                                                                        def QuantumQueryComplexity.gramOfDual {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) :
                                                                                        Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ

                                                                                        The Gram matrix of a dual solution.

                                                                                        Equations
                                                                                        Instances For
                                                                                          theorem QuantumQueryComplexity.gramOfDual_apply {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) (z w : GramIdx ι σ) :
                                                                                          gramOfDual P z w = ∑ k : K, dualVec P z k * dualVec P w k
                                                                                          theorem QuantumQueryComplexity.gramOfDual_posSemidef {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) [Finite σ] :
                                                                                          theorem QuantumQueryComplexity.gramR_gramOfDual {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) :
                                                                                          theorem QuantumQueryComplexity.gramCost_gramOfDual_false {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) (x : ι → σ) :
                                                                                          gramCost (gramOfDual P) false x = ∑ i : ι, ∑ k : K, P.u x i k * P.u x i k
                                                                                          theorem QuantumQueryComplexity.gramCost_gramOfDual_true {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} (P : DualPair K g) (x : ι → σ) :
                                                                                          gramCost (gramOfDual P) true x = ∑ i : ι, ∑ k : K, P.v x i k * P.v x i k
                                                                                          theorem QuantumQueryComplexity.gramCost_gramOfDual_le {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {K : Type u_4} [Fintype K] {g : (ι → σ) → O} {P : DualPair K g} {c : ℝ} (h : P.IsCostLe c) (b : Bool) (x : ι → σ) :

                                                                                          From a Gram matrix back to a dual solution #

                                                                                          theorem QuantumQueryComplexity.exists_dualPair_of_gram {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {g : (ι → σ) → O} {G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ} (hG : G.PosSemidef) (hR : gramR G = dualTarget g) {c : ℝ} (hc : ∀ (b : Bool) (x : ι → σ), gramCost G b x ≤ c) [Finite σ] :
                                                                                          ∃ (m : ℕ) (P : DualPair (Fin m) g), P.IsCostLe c

                                                                                          Every positive semidefinite matrix satisfying the dual constraints is the Gram matrix of a feasible dual solution of the same cost. The dimension comes out as Fin m, which is the shape advDual normalises to.

                                                                                          Pulling a dual solution back along an embedding of coordinates #

                                                                                          A subproblem of a divide-and-conquer algorithm reads only a block of the input. Formally it is pullbackFun e f x = f (x ∘ e) for an injection e : κ → ι of the block into the full coordinate set.

                                                                                          A dual solution for f transports to one for pullbackFun e f at the same cost: place the j-th vector of the original solution at coordinate e j and zero elsewhere. Injectivity is what makes this work — each coordinate of ι receives at most one vector, so the ℓ² masses simply move rather than adding up, and the masked sum over ι restricts to the masked sum over κ.

                                                                                          This is how upstream Max/Staircase.lean's bound for maxFun on a κ-indexed input becomes a bound for "the maximum over a block" as a function of the whole array, with cost governed by the block size |κ| and not by |ι|.

                                                                                          def QuantumQueryComplexity.pullbackFun {ι : Type u_1} {κ : Type u_2} {σ : Type u_3} {O : Type u_4} (e : κ → ι) (f : (κ → σ) → O) :
                                                                                          (ι → σ) → O

                                                                                          Restricting a function to a block of coordinates.

                                                                                          Equations
                                                                                          Instances For
                                                                                            @[simp]
                                                                                            theorem QuantumQueryComplexity.pullbackFun_apply {ι : Type u_1} {κ : Type u_2} {σ : Type u_3} {O : Type u_4} (e : κ → ι) (f : (κ → σ) → O) (x : ι → σ) :
                                                                                            pullbackFun e f x = f fun (j : κ) => x (e j)

                                                                                            Spreading a κ-indexed family over ι #

                                                                                            noncomputable def QuantumQueryComplexity.spread {ι : Type u_1} {κ : Type u_2} [DecidableEq ι] [Fintype κ] (e : κ → ι) (F : κ → ℝ) (i : ι) :

                                                                                            The value placed at coordinate i by a κ-indexed family.

                                                                                            Equations
                                                                                            Instances For
                                                                                              theorem QuantumQueryComplexity.spread_eq_of_mem {ι : Type u_1} {κ : Type u_2} [DecidableEq ι] [Fintype κ] {e : κ → ι} (he : Function.Injective e) {i : ι} {j₀ : κ} (hj : e j₀ = i) (F : κ → ℝ) :
                                                                                              spread e F i = F j₀
                                                                                              theorem QuantumQueryComplexity.spread_eq_zero {ι : Type u_1} {κ : Type u_2} [DecidableEq ι] [Fintype κ] {e : κ → ι} {i : ι} (h : ∀ (j : κ), e j ≠ i) (F : κ → ℝ) :
                                                                                              spread e F i = 0
                                                                                              theorem QuantumQueryComplexity.spread_mul_spread {ι : Type u_1} {κ : Type u_2} [DecidableEq ι] [Fintype κ] {e : κ → ι} (he : Function.Injective e) (i : ι) (F G : κ → ℝ) :
                                                                                              spread e F i * spread e G i = spread e (fun (j : κ) => F j * G j) i

                                                                                              Injectivity makes spread multiplicative: at most one κ-index lands on any given coordinate.

                                                                                              theorem QuantumQueryComplexity.sum_spread {ι : Type u_1} {κ : Type u_2} [Fintype ι] [DecidableEq ι] [Fintype κ] {e : κ → ι} (F : κ → ℝ) :
                                                                                              ∑ i : ι, spread e F i = ∑ j : κ, F j

                                                                                              Summing a spread family over ι recovers the sum over κ.

                                                                                              noncomputable def QuantumQueryComplexity.DualPair.pullback {ι : Type u_1} {κ : Type u_2} [Fintype ι] [DecidableEq ι] [Fintype κ] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {e : κ → ι} {f : (κ → σ) → O} (he : Function.Injective e) (P : DualPair K f) :

                                                                                              A dual solution pulled back along an injection of coordinates.

                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For
                                                                                                theorem QuantumQueryComplexity.DualPair.pullback_isCostLe {ι : Type u_1} {κ : Type u_2} [Fintype ι] [DecidableEq ι] [Fintype κ] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {e : κ → ι} {f : (κ → σ) → O} {c : ℝ} (he : Function.Injective e) (P : DualPair K f) (hP : P.IsCostLe c) :

                                                                                                The pullback costs exactly what the original solution costs — the ℓ² mass moves from κ to the image of e without accumulating.

                                                                                                Freezing the coordinates outside a block #

                                                                                                The dual of padding. A function of n variables can be regarded as a function of N ≥ n variables in which the last N - n are held at fixed, known values; that is what "append N - n known identity matrices to the input" means, and a dual solution for the padded problem restricts to one for the original at unchanged cost.

                                                                                                Two conditions are needed, and between them they say that the adversary mask is transported exactly. hin says the embedded coordinates are read faithfully — two inputs agree at i precisely when the padded inputs agree at e i — and hout says the frozen coordinates never depend on the input, so they contribute nothing to the mask. Injectivity of e is what stops the ℓ² masses from accumulating, exactly as in pullback.

                                                                                                Unlike alphaMap, the alphabets on the two sides need not match: padding typically enlarges σ to Option σ in order to name the frozen letter.

                                                                                                noncomputable def QuantumQueryComplexity.DualPair.restrict {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] [DecidableEq κ] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {σ' : Type u_6} [DecidableEq σ'] {e : ι → κ} {Φ : (ι → σ) → κ → σ'} {F : (κ → σ') → O} (he : Function.Injective e) (hin : ∀ (x y : ι → σ) (i : ι), Φ x (e i) = Φ y (e i) ↔ x i = y i) (hout : ∀ (x y : ι → σ) (j : κ), (∀ (i : ι), e i ≠ j) → Φ x j = Φ y j) (P : DualPair K F) :
                                                                                                DualPair K fun (x : ι → σ) => F (Φ x)

                                                                                                A dual solution restricted along a padding.

                                                                                                Equations
                                                                                                Instances For
                                                                                                  theorem QuantumQueryComplexity.DualPair.restrict_isCostLe {ι : Type u_1} {κ : Type u_2} [Fintype ι] [Fintype κ] [DecidableEq κ] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {K : Type u_5} [Fintype K] {σ' : Type u_6} [DecidableEq σ'] {e : ι → κ} {Φ : (ι → σ) → κ → σ'} {F : (κ → σ') → O} {c : ℝ} (he : Function.Injective e) (hin : ∀ (x y : ι → σ) (i : ι), Φ x (e i) = Φ y (e i) ↔ x i = y i) (hout : ∀ (x y : ι → σ) (j : κ), (∀ (i : ι), e i ≠ j) → Φ x j = Φ y j) (P : DualPair K F) (hP : P.IsCostLe c) :
                                                                                                  (restrict he hin hout P).IsCostLe c

                                                                                                  The restriction costs no more than the padded solution: the ℓ² mass at the frozen coordinates is simply discarded.

                                                                                                  Recoding the alphabet #

                                                                                                  def QuantumQueryComplexity.alphaFun {ι : Type u_1} {σ : Type u_3} {O : Type u_4} {σ' : Type u_5} (m : σ → σ') (f : (ι → σ') → O) :
                                                                                                  (ι → σ) → O

                                                                                                  Recoding the input alphabet along a map m.

                                                                                                  Equations
                                                                                                  Instances For
                                                                                                    @[simp]
                                                                                                    theorem QuantumQueryComplexity.alphaFun_apply {ι : Type u_1} {σ : Type u_3} {O : Type u_4} {σ' : Type u_5} (m : σ → σ') (f : (ι → σ') → O) (x : ι → σ) :
                                                                                                    alphaFun m f x = f fun (i : ι) => m (x i)
                                                                                                    noncomputable def QuantumQueryComplexity.DualPair.alphaMap {ι : Type u_1} [Fintype ι] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {σ' : Type u_5} [DecidableEq σ'] {K : Type u_6} [Fintype K] {m : σ → σ'} {f : (ι → σ') → O} (hm : Function.Injective m) (P : DualPair K f) :

                                                                                                    A dual solution transports along an injective recoding of the alphabet, at unchanged cost.

                                                                                                    Injectivity is exactly what is needed and no more: it keeps the adversary mask x i ≠ y i in step with m (x i) ≠ m (y i), so the masked sums agree term by term. A non-injective recoding would merge inputs and let extra coordinates into the sum.

                                                                                                    The use here is order-reversing: v ↦ M - 1 - v is a bijection of Fin M, so a solution for a maximum becomes one for a minimum without any separate development.

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      theorem QuantumQueryComplexity.DualPair.alphaMap_isCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {σ' : Type u_5} [DecidableEq σ'] {K : Type u_6} [Fintype K] {m : σ → σ'} {f : (ι → σ') → O} {c : ℝ} (hm : Function.Injective m) (P : DualPair K f) (hP : P.IsCostLe c) :

                                                                                                      Transporting along an equality of functions #

                                                                                                      def QuantumQueryComplexity.DualPair.ofEq {ι : Type u_1} [Fintype ι] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {K : Type u_6} [Fintype K] {f g : (ι → σ) → O} (h : ∀ (x : ι → σ), f x = g x) (P : DualPair K f) :

                                                                                                      A dual solution for f is one for any function equal to f. The vector families are unchanged, so all costs are too.

                                                                                                      Equations
                                                                                                      Instances For
                                                                                                        theorem QuantumQueryComplexity.DualPair.ofEq_isCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {K : Type u_6} [Fintype K] {f g : (ι → σ) → O} {c : ℝ} (h : ∀ (x : ι → σ), f x = g x) {P : DualPair K f} (hP : P.IsCostLe c) :
                                                                                                        (ofEq h P).IsCostLe c

                                                                                                        Enlarging the dimension type #

                                                                                                        noncomputable def QuantumQueryComplexity.DualPair.embedDim {ι : Type u_1} [Fintype ι] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {K : Type u_6} {K' : Type u_7} [Fintype K] [Fintype K'] [DecidableEq K'] {m : K → K'} (hm : Function.Injective m) {f : (ι → σ) → O} (P : DualPair K f) :

                                                                                                        Padding a dual solution with zero coordinates, along an injection of dimension types. Costs are unchanged.

                                                                                                        This is what lets solutions built over different dimension types be fed to composeShared, which needs a single type for all subproblems.

                                                                                                        Equations
                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                        Instances For
                                                                                                          theorem QuantumQueryComplexity.DualPair.embedDim_isCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {K : Type u_6} {K' : Type u_7} [Fintype K] [Fintype K'] [DecidableEq K'] {m : K → K'} (hm : Function.Injective m) {f : (ι → σ) → O} {c : ℝ} (P : DualPair K f) (hP : P.IsCostLe c) :

                                                                                                          The eigen-computation for composed matrices (HLŠ Lemma 16, Items 1–2) #

                                                                                                          The crux of the composition theorem: for eigenvectors v i of the inner matrices M i (eigenvalues lamv i) and an eigenvector w of the outer auxiliary matrix Γf ⊙ Emat (‖M ·‖) lamv (eigenvalue μ), the tensor vector

                                                                                                          tensorVec g v w x = w (tilde g x) * ∏ i, v i (slice x i)

                                                                                                          is an eigenvector of compose g Γf M with eigenvalue μ (compose_mulVec_tensorVec).

                                                                                                          The two supporting identities:

                                                                                                          As in SourceCompositionHat everything is proved over an abstract block decomposition e : Z ≃ (α → Y); the cube statements are the cubeBlocks instance. This includes promise problems whose inner inputs form a subtype. Nothing in the spectral argument sees the difference: K1 uses only that the colouring is Bool-valued, and K2 is Fintype.prod_sum transported along e.

                                                                                                          An adversary matrix for a colouring of an arbitrary type #

                                                                                                          IsAdvMatrix is tied to a cube of inputs. The inner inputs of a composition range over an arbitrary finite type, so the same notion is needed there; at a cube the two are definitionally equal.

                                                                                                          def QuantumQueryComplexity.IsAdvCol {Y : Type u_1} (g : Y → Bool) (N : Matrix Y Y ℝ) :

                                                                                                          A symmetric matrix supported on pairs of differently-coloured points.

                                                                                                          Equations
                                                                                                          Instances For
                                                                                                            theorem QuantumQueryComplexity.IsAdvCol.isHermitian {Y : Type u_1} {g : Y → Bool} {N : Matrix Y Y ℝ} (h : IsAdvCol g N) :
                                                                                                            theorem QuantumQueryComplexity.IsAdvCol.apply_eq_zero {Y : Type u_1} {g : Y → Bool} {N : Matrix Y Y ℝ} (h : IsAdvCol g N) {u v : Y} (huv : g u = g v) :
                                                                                                            N u v = 0
                                                                                                            theorem QuantumQueryComplexity.IsAdvCol.exists_eigenvector_support {Y : Type u_1} [Fintype Y] {g : Y → Bool} {N : Matrix Y Y ℝ} (hN : IsAdvCol g N) {v : Y → ℝ} {θ : ℝ} (hv : N.mulVec v = θ • v) (hθ : θ ≠ 0) (hv0 : v ≠ 0) (a : Bool) :
                                                                                                            ∃ (u : Y), g u = a ∧ v u ≠ 0

                                                                                                            The bipartite-support lemma for a colouring of an arbitrary type: an eigenvector with nonzero eigenvalue of an adversary matrix for g has support in every colour class of g. (SourceBipartite proves this over an arbitrary index type already; only the IsAdvMatrix wrapper was cube-tied.)

                                                                                                            theorem QuantumQueryComplexity.IsAdvMatrix.isAdvCol {ι : Type u_1} {σ : Type u_2} {f : (ι → σ) → Bool} {Γ : Matrix (ι → σ) (ι → σ) ℝ} (h : IsAdvMatrix f Γ) :

                                                                                                            The spectral core over an abstract block decomposition #

                                                                                                            theorem QuantumQueryComplexity.hat_guarded_row_sumGen {Y : Type u_2} [Fintype Y] [DecidableEq Y] {g : Y → Bool} {N : Matrix Y Y ℝ} (hN : IsAdvCol g N) {v : Y → ℝ} {θ : ℝ} (hv : N.mulVec v = θ • v) (u₀ : Y) (b : Bool) :
                                                                                                            (∑ u : Y, if g u = b then hat N u₀ u * v u else 0) = (if g u₀ = b then ‖N‖ else θ) * v u₀

                                                                                                            K1: the guarded row sum of hat N against an eigenvector.

                                                                                                            theorem QuantumQueryComplexity.sum_prod_sliceE {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [Fintype Y] [Fintype Z] (e : Z ≃ (α → Y)) (F : α → Y → ℝ) :
                                                                                                            ∑ y : Z, ∏ i : α, F i (sliceE e y i) = ∏ i : α, ∑ u : Y, F i u

                                                                                                            K2: the sum/product interchange along slices.

                                                                                                            noncomputable def QuantumQueryComplexity.tensorVecE {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] (e : Z ≃ (α → Y)) (g : α → Y → Bool) (v : α → Y → ℝ) (w : (α → Bool) → ℝ) :
                                                                                                            Z → ℝ

                                                                                                            The tensor eigenvector of the composed matrix.

                                                                                                            Equations
                                                                                                            Instances For
                                                                                                              @[simp]
                                                                                                              theorem QuantumQueryComplexity.tensorVecE_apply {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] (e : Z ≃ (α → Y)) (g : α → Y → Bool) (v : α → Y → ℝ) (w : (α → Bool) → ℝ) (z : Z) :
                                                                                                              tensorVecE e g v w z = w (tildeE e g z) * ∏ i : α, v i (sliceE e z i)
                                                                                                              theorem QuantumQueryComplexity.composeE_mulVec_tensorVec' {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [DecidableEq α] [Fintype Y] [DecidableEq Y] [Fintype Z] (e : Z ≃ (α → Y)) {g : α → Y → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix Y Y ℝ} (hM : ∀ (i : α), IsAdvCol (g i) (M i)) {v : α → Y → ℝ} {lamv : α → ℝ} (hv : ∀ (i : α), (M i).mulVec (v i) = lamv i • v i) (w : (α → Bool) → ℝ) :
                                                                                                              (composeE e g Γf M).mulVec (tensorVecE e g v w) = tensorVecE e g v ((Γf.hadamard (Emat (fun (i : α) => ‖M i‖) lamv)).mulVec w)

                                                                                                              K3', the crux in general form: applying the composed matrix to a tensor vector amounts to applying the outer auxiliary matrix Γf ⊙ Emat to the outer factor. (HLŠ Lemma 16, Items 1–2, for an arbitrary outer vector.)

                                                                                                              theorem QuantumQueryComplexity.composeE_mulVec_tensorVec {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [DecidableEq α] [Fintype Y] [DecidableEq Y] [Fintype Z] (e : Z ≃ (α → Y)) {g : α → Y → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix Y Y ℝ} (hM : ∀ (i : α), IsAdvCol (g i) (M i)) {v : α → Y → ℝ} {lamv : α → ℝ} (hv : ∀ (i : α), (M i).mulVec (v i) = lamv i • v i) {w : (α → Bool) → ℝ} {μ : ℝ} (hw : (Γf.hadamard (Emat (fun (i : α) => ‖M i‖) lamv)).mulVec w = μ • w) :
                                                                                                              (composeE e g Γf M).mulVec (tensorVecE e g v w) = μ • tensorVecE e g v w

                                                                                                              K3: tensor vectors built from inner eigenvectors and an eigenvector of the outer auxiliary matrix are eigenvectors of the composed matrix, with the outer eigenvalue.

                                                                                                              The cube instance #

                                                                                                              theorem QuantumQueryComplexity.hat_guarded_row_sum {β : Type u_2} [Fintype β] [DecidableEq β] {g : (β → Bool) → Bool} {N : Matrix (β → Bool) (β → Bool) ℝ} (hN : IsAdvMatrix g N) {v : (β → Bool) → ℝ} {θ : ℝ} (hv : N.mulVec v = θ • v) (u₀ : β → Bool) (b : Bool) :
                                                                                                              (∑ u : β → Bool, if g u = b then hat N u₀ u * v u else 0) = (if g u₀ = b then ‖N‖ else θ) * v u₀
                                                                                                              theorem QuantumQueryComplexity.sum_prod_slice {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (F : α → (β → Bool) → ℝ) :
                                                                                                              ∑ y : α × β → Bool, ∏ i : α, F i (slice y i) = ∏ i : α, ∑ u : β → Bool, F i u
                                                                                                              noncomputable def QuantumQueryComplexity.tensorVec {α : Type u_1} {β : Type u_2} [Fintype α] (g : α → (β → Bool) → Bool) (v : α → (β → Bool) → ℝ) (w : (α → Bool) → ℝ) :
                                                                                                              (α × β → Bool) → ℝ

                                                                                                              The tensor eigenvector of the composed matrix.

                                                                                                              Equations
                                                                                                              Instances For
                                                                                                                @[simp]
                                                                                                                theorem QuantumQueryComplexity.tensorVec_apply {α : Type u_1} {β : Type u_2} [Fintype α] (g : α → (β → Bool) → Bool) (v : α → (β → Bool) → ℝ) (w : (α → Bool) → ℝ) (x : α × β → Bool) :
                                                                                                                tensorVec g v w x = w (tilde g x) * ∏ i : α, v i (slice x i)
                                                                                                                theorem QuantumQueryComplexity.compose_mulVec_tensorVec' {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {g : α → (β → Bool) → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix (β → Bool) (β → Bool) ℝ} (hM : ∀ (i : α), IsAdvMatrix (g i) (M i)) {v : α → (β → Bool) → ℝ} {lamv : α → ℝ} (hv : ∀ (i : α), (M i).mulVec (v i) = lamv i • v i) (w : (α → Bool) → ℝ) :
                                                                                                                (compose g Γf M).mulVec (tensorVec g v w) = tensorVec g v ((Γf.hadamard (Emat (fun (i : α) => ‖M i‖) lamv)).mulVec w)
                                                                                                                theorem QuantumQueryComplexity.compose_mulVec_tensorVec {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {g : α → (β → Bool) → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix (β → Bool) (β → Bool) ℝ} (hM : ∀ (i : α), IsAdvMatrix (g i) (M i)) {v : α → (β → Bool) → ℝ} {lamv : α → ℝ} (hv : ∀ (i : α), (M i).mulVec (v i) = lamv i • v i) {w : (α → Bool) → ℝ} {μ : ℝ} (hw : (Γf.hadamard (Emat (fun (i : α) => ‖M i‖) lamv)).mulVec w = μ • w) :
                                                                                                                (compose g Γf M).mulVec (tensorVec g v w) = μ • tensorVec g v w

                                                                                                                Positive semidefinite matrices of bounded trace #

                                                                                                                For a positive semidefinite matrix the spectral norm is at most the trace: the eigenvalues are nonnegative, so the largest is at most their sum.

                                                                                                                theorem QuantumQueryComplexity.sum_sq_single {n : Type u_1} [Fintype n] [DecidableEq n] (x : n) :
                                                                                                                ∑ y : n, Pi.single x 1 y * Pi.single x 1 y = 1

                                                                                                                The squared norm of a standard coordinate vector.

                                                                                                                theorem QuantumQueryComplexity.sum_weight_sq_single {n : Type u_1} [Fintype n] [DecidableEq n] (a : n → ℝ) (x : n) :
                                                                                                                ∑ y : n, a y * (Pi.single x 1 y * Pi.single x 1 y) = a x

                                                                                                                A diagonal quadratic form evaluated on a standard coordinate vector.

                                                                                                                theorem QuantumQueryComplexity.rankOne_lt_of_trace_bound {n : Type u_1} [Fintype n] (L : Matrix n n ℝ →ₗ[ℝ] ℝ) {T u : ℝ} (hT : 0 < T) (hbound : ∀ (w : n → ℝ), ∑ z : n, w z * w z ≤ T → L (Matrix.vecMulVec w w) < u) (w : n → ℝ) (hw : w ≠ 0) :
                                                                                                                L (Matrix.vecMulVec w w) < u / T * ∑ z : n, w z * w z

                                                                                                                A linear functional bounded on a trace ball has the corresponding homogeneous bound in every nonzero rank-one direction.

                                                                                                                The two convex sets of the separation argument, on a promise domain #

                                                                                                                The shared implementation for promise and total inputs: the ambient coordinate space is DualOmegaOn X → ℝ, the compact set is the image of the truncated positive semidefinite cone over GramIdxOn X ι, and the closed set is the box around the promise dual target. norm_le_trace_of_posSemidef and apply_eq_sum_single are generic and imported, not re-proved.

                                                                                                                @[reducible, inline]

                                                                                                                The coordinate index of the ambient space: a pair of promise inputs for each constraint, and an input with a side tag for each cost variable.

                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  def QuantumQueryComplexity.gramLOn {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) :

                                                                                                                  The affine data of the promise dual program, read off a Gram matrix.

                                                                                                                  Equations
                                                                                                                  Instances For
                                                                                                                    @[simp]
                                                                                                                    theorem QuantumQueryComplexity.gramLOn_inl {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) (x y : X) :
                                                                                                                    gramLOn read G (Sum.inl (x, y)) = gramROn read G x y
                                                                                                                    @[simp]
                                                                                                                    theorem QuantumQueryComplexity.gramLOn_inr {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) (x : X) (b : Bool) :
                                                                                                                    gramLOn read G (Sum.inr (x, b)) = gramCostOn G b x
                                                                                                                    def QuantumQueryComplexity.gramLOnₗ {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) :

                                                                                                                    gramLOn as a linear map.

                                                                                                                    Equations
                                                                                                                    Instances For
                                                                                                                      @[simp]
                                                                                                                      theorem QuantumQueryComplexity.gramLOnₗ_apply {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) :
                                                                                                                      (gramLOnₗ read) G = gramLOn read G
                                                                                                                      theorem QuantumQueryComplexity.continuous_matrixEntryOn {ι : Type u_1} {X : Type u_3} (z z' : GramIdxOn X ι) [Finite X] [Finite ι] :
                                                                                                                      Continuous fun (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) => G z z'
                                                                                                                      theorem QuantumQueryComplexity.continuous_matrixTraceOn {ι : Type u_1} [Fintype ι] {X : Type u_3} [Fintype X] :
                                                                                                                      Continuous fun (G : Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ) => G.trace
                                                                                                                      theorem QuantumQueryComplexity.continuous_gramLOn {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) [Finite X] :
                                                                                                                      def QuantumQueryComplexity.psdBallOn (X : Type u_4) (ι : Type u_5) [Fintype X] [Fintype ι] (T : ℝ) :
                                                                                                                      Set (Matrix (GramIdxOn X ι) (GramIdxOn X ι) ℝ)

                                                                                                                      Positive semidefinite matrices of trace at most T.

                                                                                                                      Equations
                                                                                                                      Instances For
                                                                                                                        theorem QuantumQueryComplexity.convex_psdBallOn {ι : Type u_1} [Fintype ι] {X : Type u_3} [Fintype X] (T : ℝ) :
                                                                                                                        theorem QuantumQueryComplexity.isClosed_psdBallOn {ι : Type u_1} [Fintype ι] {X : Type u_3} [Fintype X] (T : ℝ) :
                                                                                                                        theorem QuantumQueryComplexity.isCompact_psdBallOn {ι : Type u_1} [Fintype ι] {X : Type u_3} [Fintype X] (T : ℝ) :

                                                                                                                        The two sets #

                                                                                                                        def QuantumQueryComplexity.gramImageOn {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] (read : X → ι → σ) (T : ℝ) :

                                                                                                                        The image of the truncated positive semidefinite cone.

                                                                                                                        Equations
                                                                                                                        Instances For
                                                                                                                          theorem QuantumQueryComplexity.convex_gramImageOn {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] (read : X → ι → σ) (T : ℝ) :
                                                                                                                          theorem QuantumQueryComplexity.isCompact_gramImageOn {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] (read : X → ι → σ) (T : ℝ) :
                                                                                                                          theorem QuantumQueryComplexity.zero_mem_gramImageOn {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] {read : X → ι → σ} {T : ℝ} (hT : 0 ≤ T) :
                                                                                                                          0 ∈ gramImageOn read T
                                                                                                                          theorem QuantumQueryComplexity.mem_gramImageOn_vecMulVec {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] {read : X → ι → σ} {T : ℝ} (w : GramIdxOn X ι → ℝ) (hw : ∑ z : GramIdxOn X ι, w z * w z ≤ T) :
                                                                                                                          def QuantumQueryComplexity.dualBoxOn {X : Type u_3} (f : X → Bool) (c : ℝ) :

                                                                                                                          The target of the promise dual program: constraint block equal to dualTargetOn f, cost block in [0, c].

                                                                                                                          Equations
                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                          Instances For
                                                                                                                            def QuantumQueryComplexity.dualCornerOn {X : Type u_3} (f : X → Bool) (c : ℝ) :

                                                                                                                            The corner of the box.

                                                                                                                            Equations
                                                                                                                            Instances For
                                                                                                                              theorem QuantumQueryComplexity.dualCornerOn_mem {X : Type u_3} {f : X → Bool} {c : ℝ} (hc : 0 ≤ c) :

                                                                                                                              The two convex sets of the separation argument #

                                                                                                                              The dual program is separated from its target inside the finite-dimensional coordinate space DualOmega ι σ → ℝ, whose coordinates are indexed by a pair of inputs (the constraint gramR) or by an input together with a side tag (the two costs gramCost). The map assembling those coordinates from a Gram matrix is gramL.

                                                                                                                              Two sets live there:

                                                                                                                              Truncating the cone at a finite trace is what makes gramImage compact, and hence what lets geometric_hahn_banach_compact_closed apply without any closedness-of-image argument; the truncation is harmless because a dual solution of cost at most c has trace at most 2 c · card (ι → σ).

                                                                                                                              This section also records apply_eq_sum_single, which reads the coefficients of a continuous linear functional off its values on the standard basis.

                                                                                                                              @[reducible, inline]
                                                                                                                              abbrev QuantumQueryComplexity.DualOmega (ι : Type u_3) (σ : Type u_4) :
                                                                                                                              Type (max u_3 u_4)

                                                                                                                              The coordinate index of the ambient space of the separation argument: a pair of inputs for each constraint, and an input with a side tag for each cost variable.

                                                                                                                              Equations
                                                                                                                              Instances For
                                                                                                                                def QuantumQueryComplexity.gramL {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) :
                                                                                                                                DualOmega ι σ → ℝ

                                                                                                                                The affine data of the dual program, read off a Gram matrix.

                                                                                                                                Equations
                                                                                                                                Instances For
                                                                                                                                  @[simp]
                                                                                                                                  theorem QuantumQueryComplexity.gramL_inl {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) (x y : ι → σ) :
                                                                                                                                  gramL G (Sum.inl (x, y)) = gramR G x y
                                                                                                                                  @[simp]
                                                                                                                                  theorem QuantumQueryComplexity.gramL_inr {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) (x : ι → σ) (b : Bool) :
                                                                                                                                  gramL G (Sum.inr (x, b)) = gramCost G b x
                                                                                                                                  @[simp]
                                                                                                                                  theorem QuantumQueryComplexity.gramLₗ_apply {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) :
                                                                                                                                  theorem QuantumQueryComplexity.continuous_matrixEntry {ι : Type u_1} {σ : Type u_2} (z z' : GramIdx ι σ) [Finite ι] [Finite σ] :
                                                                                                                                  Continuous fun (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) => G z z'
                                                                                                                                  theorem QuantumQueryComplexity.continuous_matrixTrace {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] :
                                                                                                                                  Continuous fun (G : Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ) => G.trace
                                                                                                                                  def QuantumQueryComplexity.psdBall (ι : Type u_3) (σ : Type u_4) [Fintype ι] [DecidableEq ι] [Fintype σ] (T : ℝ) :
                                                                                                                                  Set (Matrix (GramIdx ι σ) (GramIdx ι σ) ℝ)

                                                                                                                                  Positive semidefinite matrices of trace at most T.

                                                                                                                                  Equations
                                                                                                                                  Instances For
                                                                                                                                    theorem QuantumQueryComplexity.convex_psdBall {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] (T : ℝ) :
                                                                                                                                    Convex ℝ (psdBall ι σ T)
                                                                                                                                    theorem QuantumQueryComplexity.isClosed_psdBall {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] (T : ℝ) :
                                                                                                                                    IsClosed (psdBall ι σ T)
                                                                                                                                    theorem QuantumQueryComplexity.isCompact_psdBall {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] (T : ℝ) :
                                                                                                                                    IsCompact (psdBall ι σ T)

                                                                                                                                    The two sets #

                                                                                                                                    def QuantumQueryComplexity.gramImage (ι : Type u_3) (σ : Type u_4) [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] (T : ℝ) :
                                                                                                                                    Set (DualOmega ι σ → ℝ)

                                                                                                                                    The image of the truncated positive semidefinite cone: the affine data achievable by dual solutions of total weight at most T.

                                                                                                                                    Equations
                                                                                                                                    Instances For
                                                                                                                                      theorem QuantumQueryComplexity.convex_gramImage {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] (T : ℝ) :
                                                                                                                                      Convex ℝ (gramImage ι σ T)
                                                                                                                                      theorem QuantumQueryComplexity.isCompact_gramImage {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] (T : ℝ) :
                                                                                                                                      theorem QuantumQueryComplexity.zero_mem_gramImage {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {T : ℝ} (hT : 0 ≤ T) :
                                                                                                                                      0 ∈ gramImage ι σ T
                                                                                                                                      theorem QuantumQueryComplexity.mem_gramImage_vecMulVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {T : ℝ} (w : GramIdx ι σ → ℝ) (hw : ∑ z : GramIdx ι σ, w z * w z ≤ T) :
                                                                                                                                      def QuantumQueryComplexity.dualBox {ι : Type u_1} {σ : Type u_2} (g : (ι → σ) → Bool) (c : ℝ) :
                                                                                                                                      Set (DualOmega ι σ → ℝ)

                                                                                                                                      The target of the dual program: constraint block equal to dualTarget g, cost block in [0, c].

                                                                                                                                      Equations
                                                                                                                                      Instances For
                                                                                                                                        theorem QuantumQueryComplexity.convex_dualBox {ι : Type u_1} {σ : Type u_2} (g : (ι → σ) → Bool) (c : ℝ) :
                                                                                                                                        theorem QuantumQueryComplexity.isClosed_dualBox {ι : Type u_1} {σ : Type u_2} (g : (ι → σ) → Bool) (c : ℝ) :
                                                                                                                                        def QuantumQueryComplexity.dualCorner {ι : Type u_1} {σ : Type u_2} (g : (ι → σ) → Bool) (c : ℝ) :
                                                                                                                                        DualOmega ι σ → ℝ

                                                                                                                                        The corner of the box: the dual target with every cost variable at c.

                                                                                                                                        Equations
                                                                                                                                        Instances For
                                                                                                                                          theorem QuantumQueryComplexity.dualCorner_mem {ι : Type u_1} {σ : Type u_2} {g : (ι → σ) → Bool} {c : ℝ} (hc : 0 ≤ c) :

                                                                                                                                          Reading off the coefficients of a functional #

                                                                                                                                          theorem QuantumQueryComplexity.apply_eq_sum_single {α : Type u_3} [Fintype α] [DecidableEq α] (φ : (α → ℝ) →L[ℝ] ℝ) (z : α → ℝ) :
                                                                                                                                          φ z = ∑ a : α, z a * φ (Pi.single a 1)

                                                                                                                                          A linear functional on a finite coordinate space is the pairing with its values on the standard basis.

                                                                                                                                          From a positive semidefinite certificate to an adversary matrix #

                                                                                                                                          This section contains the elementary half of strong duality: the construction that turns the multipliers produced by a separating hyperplane back into a feasible primal witness.

                                                                                                                                          The data is a symmetric matrix Γ, a strictly positive weight p on inputs, and the inequality

                                                                                                                                          |s ⬝ᵥ (Γ ⊙ advD i) *ᵥ t| ≤ ∑ₓ p x · s x ² + ∑ᵧ p y · t y ² (for every i),

                                                                                                                                          which says exactly that the block matrix [[diag p, (Γ ⊙ advD i)/2], [·, diag p]] is positive semidefinite. Rescaling by √p on both sides turns it into the adversary feasibility constraint: Γ' x y = Γ x y / (√(p x) √(p y)) satisfies ‖Γ' ⊙ advD i‖ ≤ 2. Masking off the pairs with equal g-value costs nothing in norm (l2_opNorm_hadamard_dualTarget_le, using that a two-valued mask is an average of the identity and a ±1 diagonal conjugation), and evaluating the resulting adversary matrix on the unit vector √p / ‖√p‖ returns the pairing ⟪Γ, dualTarget g⟫ / (2 ∑ p).

                                                                                                                                          The generic norm estimate is proved here. The total-input certificate theorem lt_advPM_of_certificate is derived from the promise construction below.

                                                                                                                                          Two auxiliary norm bounds #

                                                                                                                                          theorem QuantumQueryComplexity.l2_opNorm_le_two_of_quadratic {n : Type u_1} [Fintype n] [DecidableEq n] (M : Matrix n n ℝ) (h : ∀ (a b : n → ℝ), |a ⬝ᵥ M.mulVec b| ≤ a ⬝ᵥ a + b ⬝ᵥ b) :

                                                                                                                                          A bilinear form dominated by the sum of the squared lengths of its arguments comes from a matrix of norm at most 2. (Optimising the scaling a ↦ λ a, b ↦ λ⁻¹ b is what turns the arithmetic mean into the geometric one.)

                                                                                                                                          def QuantumQueryComplexity.boolSign {ι : Type u_1} {σ : Type u_2} (g : (ι → σ) → Bool) :
                                                                                                                                          (ι → σ) → ℝ

                                                                                                                                          The ±1 sign vector of a Boolean function.

                                                                                                                                          Equations
                                                                                                                                          Instances For
                                                                                                                                            theorem QuantumQueryComplexity.boolSign_eq_one_or {ι : Type u_1} {σ : Type u_2} (g : (ι → σ) → Bool) (x : ι → σ) :
                                                                                                                                            boolSign g x = 1 ∨ boolSign g x = -1
                                                                                                                                            theorem QuantumQueryComplexity.boolSign_mul {ι : Type u_1} {σ : Type u_2} (g : (ι → σ) → Bool) (x y : ι → σ) :
                                                                                                                                            boolSign g x * boolSign g y = 1 - 2 * dualTarget g x y

                                                                                                                                            The main construction #

                                                                                                                                            The primal witness API on a promise domain #

                                                                                                                                            SourcePromiseDefs supplies the upper eliminator advPMOn_le; this section supplies the introduction rules, so that a witness matrix certifies ‖Γ‖ ≤ advPMOn read f directly.

                                                                                                                                            There is one hypothesis here that the total case does not need. advPM is a supremum over feasible matrices, and boundedness of that set comes from the observation that a feasible matrix vanishes wherever no query separates the two inputs. On a promise domain two distinct inputs may look identical at every query, and then nothing constrains Γ there at all: the value set is unbounded and sSup degenerates. So every lemma below assumes

                                                                                                                                            hdet : ∀ x y, read x = read y → f x = f y,

                                                                                                                                            i.e. the observations determine the output. Injectivity of read implies this condition, as separates_of_injective records.

                                                                                                                                            theorem QuantumQueryComplexity.separates_of_injective {ι : Type u_1} {σ : Type u_2} {X : Type u_3} {O : Type u_4} {read : X → ι → σ} (hread : Function.Injective read) (f : X → O) (x y : X) :
                                                                                                                                            read x = read y → f x = f y

                                                                                                                                            An injective observation map determines the output.

                                                                                                                                            theorem QuantumQueryComplexity.abs_apply_le_one_of_feasibleOn {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} {Γ : Matrix X X ℝ} (hdet : ∀ (x y : X), read x = read y → f x = f y) (h1 : IsAdvMatrixOn f Γ) (h2 : ∀ (i : ι), ‖Γ.hadamard (advDOn read i)‖ ≤ 1) (x y : X) :
                                                                                                                                            |Γ x y| ≤ 1

                                                                                                                                            All entries of a feasible matrix are bounded by 1: entries with equal output vanish, and the rest are separated by some query.

                                                                                                                                            theorem QuantumQueryComplexity.norm_le_of_feasibleOn {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} {Γ : Matrix X X ℝ} (hdet : ∀ (x y : X), read x = read y → f x = f y) (h1 : IsAdvMatrixOn f Γ) (h2 : ∀ (i : ι), ‖Γ.hadamard (advDOn read i)‖ ≤ 1) :

                                                                                                                                            The a priori bound making the advPMOn value set bounded above.

                                                                                                                                            theorem QuantumQueryComplexity.bddAbove_advPMOn_set {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} (hdet : ∀ (x y : X), read x = read y → f x = f y) :
                                                                                                                                            BddAbove {r : ℝ | ∃ (Γ : Matrix X X ℝ), IsAdvMatrixOn f Γ ∧ (∀ (i : ι), ‖Γ.hadamard (advDOn read i)‖ ≤ 1) ∧ r = ‖Γ‖}
                                                                                                                                            theorem QuantumQueryComplexity.le_advPMOn {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} {Γ : Matrix X X ℝ} (hdet : ∀ (x y : X), read x = read y → f x = f y) (h1 : IsAdvMatrixOn f Γ) (h2 : ∀ (i : ι), ‖Γ.hadamard (advDOn read i)‖ ≤ 1) :
                                                                                                                                            ‖Γ‖ ≤ advPMOn read f

                                                                                                                                            Every feasible matrix certifies a lower bound on advPMOn.

                                                                                                                                            theorem QuantumQueryComplexity.advPMOn_nonneg {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} (hdet : ∀ (x y : X), read x = read y → f x = f y) :
                                                                                                                                            0 ≤ advPMOn read f
                                                                                                                                            theorem QuantumQueryComplexity.IsAdvMatrixOn.smul {X : Type u_3} {O : Type u_4} {f : X → O} {Γ : Matrix X X ℝ} (h : IsAdvMatrixOn f Γ) (c : ℝ) :
                                                                                                                                            theorem QuantumQueryComplexity.norm_div_le_advPMOn {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} {Γ : Matrix X X ℝ} (hdet : ∀ (x y : X), read x = read y → f x = f y) (h1 : IsAdvMatrixOn f Γ) {c : ℝ} (h2 : ∀ (i : ι), ‖Γ.hadamard (advDOn read i)‖ ≤ c) (hc : 0 < c) :
                                                                                                                                            ‖Γ‖ / c ≤ advPMOn read f

                                                                                                                                            The un-normalized witness lemma on a promise domain. Exhibit a matrix, bound its masked norms by c, and read off ‖Γ‖ / c.

                                                                                                                                            theorem QuantumQueryComplexity.exists_lt_of_lt_advPMOn {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} {c : ℝ} (h : c < advPMOn read f) :
                                                                                                                                            ∃ (Γ : Matrix X X ℝ), IsAdvMatrixOn f Γ ∧ (∀ (i : ι), ‖Γ.hadamard (advDOn read i)‖ ≤ 1) ∧ c < ‖Γ‖

                                                                                                                                            The ε-accessor, for arguments that need a witness beating a given value.

                                                                                                                                            The total case is a promise on the whole cube #

                                                                                                                                            A sanity check that the promise API really extends the total one: reading the identity on the full cube gives back advPM.

                                                                                                                                            @[simp]
                                                                                                                                            theorem QuantumQueryComplexity.advDOn_id {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] (i : ι) :
                                                                                                                                            advDOn (fun (x : ι → σ) => x) i = advD i
                                                                                                                                            theorem QuantumQueryComplexity.isAdvMatrixOn_id_iff {ι : Type u_1} {σ : Type u_2} {O : Type u_4} {g : (ι → σ) → O} {Γ : Matrix (ι → σ) (ι → σ) ℝ} :
                                                                                                                                            @[simp]
                                                                                                                                            theorem QuantumQueryComplexity.advPMOn_id {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_4} [Fintype σ] (g : (ι → σ) → O) :
                                                                                                                                            advPMOn (fun (x : ι → σ) => x) g = advPM g

                                                                                                                                            Spanning by tensor eigenvectors (HLŠ Lemma 16, Item 3) #

                                                                                                                                            The family of tensor vectors tensorVecE e g (v' · (c ·)) (ofLp (W c j)) — over all eigen-index assignments c : α → Y and all members j of an orthonormal basis W c of the outer space — spans the whole composed space.

                                                                                                                                            Route: pure tensors of orthonormal families are orthonormal (tensor_orthonormalE, via the sum_prod_sliceE interchange), hence linearly independent; their cardinality equals the dimension, so they span; and each pure tensor lies in the span of the family because tensorVecE is linear in its outer argument and W c is a basis.

                                                                                                                                            As in SourceCompositionHat the block decomposition is abstract: everything is proved for e : Z ≃ (α → Y) with Y an arbitrary finite type, and the cube statements are the cubeBlocks instance. The only cube-specific step was the dimension count Fintype.card ((α × β) → Bool) = Fintype.card (α → (β → Bool)), which is now just Fintype.card_congr e.symm.

                                                                                                                                            This section is the second (and last) WithLp/EuclideanSpace quarantine zone.

                                                                                                                                            theorem QuantumQueryComplexity.span_top_of_toLp {n : Type u_1} {κ : Type u_2} (T : κ → n → ℝ) (h : Submodule.span ℝ (Set.range fun (k : κ) => WithLp.toLp 2 (T k)) = ⊤) :

                                                                                                                                            S2: transporting a spanning statement from EuclideanSpace to the plain Pi module.

                                                                                                                                            Spanning over an abstract block decomposition #

                                                                                                                                            theorem QuantumQueryComplexity.tensor_orthonormalE {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [Fintype Y] [Fintype Z] (e : Z ≃ (α → Y)) {v' : α → Y → Y → ℝ} (hON : ∀ (i : α), Orthonormal ℝ fun (d : Y) => WithLp.toLp 2 (v' i d)) :
                                                                                                                                            Orthonormal ℝ fun (c : α → Y) => WithLp.toLp 2 fun (x : Z) => ∏ i : α, v' i (c i) (sliceE e x i)

                                                                                                                                            S1: pure tensors of orthonormal families are orthonormal.

                                                                                                                                            theorem QuantumQueryComplexity.span_tensorVecE_top {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [DecidableEq α] [Fintype Y] (e : Z ≃ (α → Y)) {g : α → Y → Bool} (v' : α → Y → Y → ℝ) (hON : ∀ (i : α), Orthonormal ℝ fun (d : Y) => WithLp.toLp 2 (v' i d)) (W : (α → Y) → OrthonormalBasis (α → Bool) ℝ (EuclideanSpace ℝ (α → Bool))) [Finite Z] :
                                                                                                                                            Submodule.span ℝ (Set.range fun (p : (α → Y) × (α → Bool)) => tensorVecE e g (fun (i : α) => v' i (p.1 i)) ((W p.1) p.2).ofLp) = ⊤

                                                                                                                                            S3: the tensor eigenvector family spans everything.

                                                                                                                                            The cube instance #

                                                                                                                                            theorem QuantumQueryComplexity.tensor_orthonormal {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {v' : α → (β → Bool) → (β → Bool) → ℝ} (hON : ∀ (i : α), Orthonormal ℝ fun (d : β → Bool) => WithLp.toLp 2 (v' i d)) :
                                                                                                                                            Orthonormal ℝ fun (c : α → β → Bool) => WithLp.toLp 2 fun (x : α × β → Bool) => ∏ i : α, v' i (c i) (slice x i)

                                                                                                                                            S1, cube form.

                                                                                                                                            theorem QuantumQueryComplexity.span_tensorVec_top {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {g : α → (β → Bool) → Bool} (v' : α → (β → Bool) → (β → Bool) → ℝ) (hON : ∀ (i : α), Orthonormal ℝ fun (d : β → Bool) => WithLp.toLp 2 (v' i d)) (W : (α → β → Bool) → OrthonormalBasis (α → Bool) ℝ (EuclideanSpace ℝ (α → Bool))) :
                                                                                                                                            Submodule.span ℝ (Set.range fun (p : (α → β → Bool) × (α → Bool)) => tensorVec g (fun (i : α) => v' i (p.1 i)) ((W p.1) p.2).ofLp) = ⊤

                                                                                                                                            S3, cube form.

                                                                                                                                            Post-composition lowers the promise adversary bound #

                                                                                                                                            An adversary matrix for g ∘ f is supported on pairs with g (f x) ≠ g (f y), hence on pairs with f x ≠ f y — so it is an adversary matrix for f, with the same feasibility. The suprema then compare directly:

                                                                                                                                            advPMOn read (g ∘ f) ≤ advPMOn read f.
                                                                                                                                            

                                                                                                                                            This is the promise mirror of the advPM_comp_le post-processing lemma, and it is what makes the bit encoding of a finite output type free on the adversary side: each output bit is a post-composition of f, so its promise adversary bound is at most that of f.

                                                                                                                                            theorem QuantumQueryComplexity.IsAdvMatrixOn.of_comp {X : Type u_3} {O : Type u_4} {O' : Type u_5} {f : X → O} {g : O → O'} {Γ : Matrix X X ℝ} (h : IsAdvMatrixOn (fun (x : X) => g (f x)) Γ) :

                                                                                                                                            An adversary matrix for a post-composition is one for the base function.

                                                                                                                                            theorem QuantumQueryComplexity.det_comp {ι : Type u_1} {σ : Type u_2} {X : Type u_3} {O : Type u_4} {O' : Type u_5} {read : X → ι → σ} {f : X → O} (hdet : ∀ (x y : X), read x = read y → f x = f y) (g : O → O') (x y : X) :
                                                                                                                                            read x = read y → g (f x) = g (f y)

                                                                                                                                            Determinacy transfers to any post-composition.

                                                                                                                                            theorem QuantumQueryComplexity.advPMOn_comp_le {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {O' : Type u_5} {read : X → ι → σ} {f : X → O} (hdet : ∀ (x y : X), read x = read y → f x = f y) (g : O → O') :
                                                                                                                                            (advPMOn read fun (x : X) => g (f x)) ≤ advPMOn read f

                                                                                                                                            Post-composition lowers the promise adversary bound.

                                                                                                                                            Relabelling the answers #

                                                                                                                                            An injective relabelling of the oracle's answers changes nothing: the masks advDOn only ask whether two promise inputs are distinguished at i.

                                                                                                                                            theorem QuantumQueryComplexity.advDOn_comp_injective {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} {σ' : Type u_6} [DecidableEq σ'] {φ : σ → σ'} (hφ : Function.Injective φ) (read : X → ι → σ) (i : ι) :
                                                                                                                                            advDOn (fun (x : X) (j : ι) => φ (read x j)) i = advDOn read i
                                                                                                                                            theorem QuantumQueryComplexity.advPMOn_comp_injective {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {σ' : Type u_6} [DecidableEq σ'] {φ : σ → σ'} (hφ : Function.Injective φ) (read : X → ι → σ) (f : X → O) :
                                                                                                                                            advPMOn (fun (x : X) (j : ι) => φ (read x j)) f = advPMOn read f

                                                                                                                                            The adversary bound is invariant under injective relabelling of the answers.

                                                                                                                                            The norm of a composed matrix (HLŠ Lemma 16 / BL Lemma 21) #

                                                                                                                                            ‖composeE e g Γf M‖ = ‖Γf‖ * ∏ i, ‖M i‖ for symmetric Γf and g-shaped inner matrices M i.

                                                                                                                                            As in SourceCompositionHat the block decomposition is abstract, and the cube statements norm_compose_le / le_norm_compose / norm_compose are the cubeBlocks instance. Two side conditions appear in the general form and are automatic at a cube: the ≤ direction is stated for a possibly empty composed type Z (the spanning-eigenvector bound wants Nonempty), and the ≥ direction needs Nonempty Y to select an inner eigenvalue of maximal modulus.

                                                                                                                                            theorem QuantumQueryComplexity.div_self_sq {a R : ℝ} (hR : 0 < R) (h : |a| = R) :
                                                                                                                                            a / R * (a / R) = 1
                                                                                                                                            theorem QuantumQueryComplexity.vertex_eigen {α : Type u_1} [Fintype α] [DecidableEq α] {Γf : Matrix (α → Bool) (α → Bool) ℝ} {R lam ε : α → ℝ} (hε : ∀ (i : α), ε i * ε i = 1) (hlam_eq : ∀ (i : α), ε i * R i = lam i) {θ : ℝ} {w : (α → Bool) → ℝ} (hw : Γf.mulVec w = θ • w) :
                                                                                                                                            (Γf.hadamard (Emat R lam)).mulVec ((Matrix.diagonal (chiSign ε)).mulVec w) = ((∏ i : α, R i) * θ) • (Matrix.diagonal (chiSign ε)).mulVec w

                                                                                                                                            The vertex eigen-computation: at a sign vertex, an eigenvector of Γf conjugated by the ±1 diagonal is an eigenvector of Γf ⊙ Emat R lam with eigenvalue (∏ R) * θ.

                                                                                                                                            The norm formula over an abstract block decomposition #

                                                                                                                                            theorem QuantumQueryComplexity.normE_compose_le {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [DecidableEq α] [Fintype Y] [DecidableEq Y] [Fintype Z] [DecidableEq Z] {g : α → Y → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix Y Y ℝ} (e : Z ≃ (α → Y)) (hΓf : Γf.IsHermitian) (hM : ∀ (i : α), IsAdvCol (g i) (M i)) :
                                                                                                                                            ‖composeE e g Γf M‖ ≤ ‖Γf‖ * ∏ i : α, ‖M i‖

                                                                                                                                            The ≤ direction of HLŠ Lemma 16.

                                                                                                                                            theorem QuantumQueryComplexity.le_normE_compose {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [DecidableEq α] [Fintype Y] [DecidableEq Y] [Fintype Z] [DecidableEq Z] {g : α → Y → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix Y Y ℝ} [Nonempty Y] (e : Z ≃ (α → Y)) (hΓf : Γf.IsHermitian) (hM : ∀ (i : α), IsAdvCol (g i) (M i)) :
                                                                                                                                            ‖Γf‖ * ∏ i : α, ‖M i‖ ≤ ‖composeE e g Γf M‖

                                                                                                                                            The ≥ direction of HLŠ Lemma 16.

                                                                                                                                            theorem QuantumQueryComplexity.normE_compose {α : Type u_1} {Y : Type u_2} {Z : Type u_3} [Fintype α] [DecidableEq α] [Fintype Y] [DecidableEq Y] [Fintype Z] [DecidableEq Z] {g : α → Y → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix Y Y ℝ} [Nonempty Y] (e : Z ≃ (α → Y)) (hΓf : Γf.IsHermitian) (hM : ∀ (i : α), IsAdvCol (g i) (M i)) :
                                                                                                                                            ‖composeE e g Γf M‖ = ‖Γf‖ * ∏ i : α, ‖M i‖

                                                                                                                                            HLŠ Lemma 16 / BL Lemma 21, over an abstract block decomposition.

                                                                                                                                            The cube instance #

                                                                                                                                            theorem QuantumQueryComplexity.norm_compose_le {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {g : α → (β → Bool) → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix (β → Bool) (β → Bool) ℝ} (hΓf : Γf.IsHermitian) (hM : ∀ (i : α), IsAdvMatrix (g i) (M i)) :
                                                                                                                                            ‖compose g Γf M‖ ≤ ‖Γf‖ * ∏ i : α, ‖M i‖

                                                                                                                                            The ≤ direction of HLŠ Lemma 16.

                                                                                                                                            theorem QuantumQueryComplexity.le_norm_compose {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {g : α → (β → Bool) → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix (β → Bool) (β → Bool) ℝ} (hΓf : Γf.IsHermitian) (hM : ∀ (i : α), IsAdvMatrix (g i) (M i)) :
                                                                                                                                            ‖Γf‖ * ∏ i : α, ‖M i‖ ≤ ‖compose g Γf M‖

                                                                                                                                            The ≥ direction of HLŠ Lemma 16.

                                                                                                                                            theorem QuantumQueryComplexity.norm_compose {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {g : α → (β → Bool) → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix (β → Bool) (β → Bool) ℝ} (hΓf : Γf.IsHermitian) (hM : ∀ (i : α), IsAdvMatrix (g i) (M i)) :
                                                                                                                                            ‖compose g Γf M‖ = ‖Γf‖ * ∏ i : α, ‖M i‖

                                                                                                                                            HLŠ Lemma 16 / BL Lemma 21: the norm of the composed matrix.

                                                                                                                                            From a certificate to an adversary matrix, on a promise domain #

                                                                                                                                            The promise mirror of SourceDualityWitness: the multipliers of the separating hyperplane become a feasible IsAdvMatrixOn witness, so the certificate forces c < advPMOn read f. The two generic norm lemmas (l2_opNorm_le_two_of_quadratic and the ±1 diagonal conjugation) are imported, not re-proved; the ±1 mask argument uses only that the output is two-valued, which holds verbatim for f : X → Bool.

                                                                                                                                            hdet (read-determinacy) enters exactly once, through le_advPMOn — the promise adversary bound is a supremum only over a bounded set when the promise is determined.

                                                                                                                                            def QuantumQueryComplexity.boolSignOn {X : Type u_1} (f : X → Bool) :
                                                                                                                                            X → ℝ

                                                                                                                                            The ±1 sign vector of a Boolean function on the promise domain.

                                                                                                                                            Equations
                                                                                                                                            Instances For
                                                                                                                                              theorem QuantumQueryComplexity.boolSignOn_eq_one_or {X : Type u_1} (f : X → Bool) (x : X) :
                                                                                                                                              boolSignOn f x = 1 ∨ boolSignOn f x = -1
                                                                                                                                              theorem QuantumQueryComplexity.boolSignOn_mul {X : Type u_1} (f : X → Bool) (x y : X) :
                                                                                                                                              boolSignOn f x * boolSignOn f y = 1 - 2 * dualTargetOn f x y

                                                                                                                                              Masking off the pairs with equal value does not increase the spectral norm: for a two-valued f the mask is an average of the identity and a ±1 diagonal conjugation.

                                                                                                                                              The main construction #

                                                                                                                                              theorem QuantumQueryComplexity.lt_advPMOn_of_certificate {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {read : X → ι → σ} {f : X → Bool} (hdet : ∀ (x y : X), read x = read y → f x = f y) {Γ : Matrix X X ℝ} {p : X → ℝ} {c : ℝ} (hsym : ∀ (x y : X), Γ y x = Γ x y) (hp : ∀ (x : X), 0 < p x) (hquad : ∀ (i : ι) (s t : X → ℝ), |s ⬝ᵥ (Γ.hadamard (advDOn read i)).mulVec t| ≤ ∑ x : X, p x * (s x * s x) + ∑ y : X, p y * (t y * t y)) (hobj : 2 * c * ∑ x : X, p x < ∑ x : X, ∑ y : X, Γ x y * dualTargetOn f x y) :
                                                                                                                                              c < advPMOn read f

                                                                                                                                              From a dual certificate to a primal witness, on a promise domain.

                                                                                                                                              Total-input specializations of the promise witness construction #

                                                                                                                                              theorem QuantumQueryComplexity.l2_opNorm_hadamard_dualTarget_le {ι : Type u_1} {σ : Type u_2} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] (g : (ι → σ) → Bool) (M : Matrix (ι → σ) (ι → σ) ℝ) :

                                                                                                                                              A Boolean output mask is contractive in the operator norm.

                                                                                                                                              theorem QuantumQueryComplexity.lt_advPM_of_certificate {ι : Type u_1} {σ : Type u_2} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] {g : (ι → σ) → Bool} {Γ : Matrix (ι → σ) (ι → σ) ℝ} {p : (ι → σ) → ℝ} {c : ℝ} (hsym : ∀ (x y : ι → σ), Γ y x = Γ x y) (hp : ∀ (x : ι → σ), 0 < p x) (hquad : ∀ (i : ι) (s t : (ι → σ) → ℝ), |s ⬝ᵥ (Γ.hadamard (advD i)).mulVec t| ≤ ∑ x : ι → σ, p x * (s x * s x) + ∑ y : ι → σ, p y * (t y * t y)) (hobj : 2 * c * ∑ x : ι → σ, p x < ∑ x : ι → σ, ∑ y : ι → σ, Γ x y * dualTarget g x y) :
                                                                                                                                              c < advPM g

                                                                                                                                              The total-input certificate construction is the identity-read promise case.

                                                                                                                                              The Hadamard-mask identity (HLŠ p. 20 / BL Eq. (8) + Claim 23) #

                                                                                                                                              Masking the composed matrix by a difference matrix produces another composed matrix: the outer matrix is masked by advD p and the inner matrix in slot p is masked by the inner difference matrix at q:

                                                                                                                                              composeE e g Γf M ⊙ advDOn (composeReadE e innerRead) (p, q) = composeE e g (Γf ⊙ advD p) (Function.update M p (M p ⊙ advDOn innerRead q))

                                                                                                                                              This is an exact entrywise identity: in every configuration where the ‖·‖ • 1 part of a hat matrix could differ between the two sides, either the outer factor (Γf ⊙ advD p) or a Kronecker delta vanishes first.

                                                                                                                                              The mask is a promise mask #

                                                                                                                                              The composed inputs form an arbitrary finite type Z ≃ (α → Y), and a query (p, q) reads coordinate q of the p-th block through the inner observation map innerRead : Y → β → σ (composeReadE). So the relevant difference matrix is advDOn, evaluated on the inner observations.

                                                                                                                                              Neither delicate step needs innerRead to be injective. In the "queries agree" branch the p-slot hat entry vanishes because the masked inner entry vanishes and the two blocks have different g-values, hence are distinct blocks; in the "queries differ" branch the blocks are distinct because a single congrArg turns differing reads into differing blocks.

                                                                                                                                              The original cube statement compose_hadamard_advD is recovered as the instance e := cubeBlocks α β with innerRead the identity, since advDOn (fun u => u) q is advD q definitionally.

                                                                                                                                              theorem QuantumQueryComplexity.IsAdvMatrix.hadamard_advD {ι : Type u_1} {f : (ι → Bool) → Bool} {Γ : Matrix (ι → Bool) (ι → Bool) ℝ} (h : IsAdvMatrix f Γ) (i : ι) :

                                                                                                                                              The mask identity over an abstract block decomposition #

                                                                                                                                              theorem QuantumQueryComplexity.IsAdvCol.hadamard_advDOn {β : Type u_2} {σ : Type u_3} {Y : Type u_4} [DecidableEq σ] {g : Y → Bool} {N : Matrix Y Y ℝ} (h : IsAdvCol g N) (innerRead : Y → β → σ) (q : β) :
                                                                                                                                              IsAdvCol g (N.hadamard (advDOn innerRead q))
                                                                                                                                              def QuantumQueryComplexity.composeReadE {α : Type u_1} {β : Type u_2} {σ : Type u_3} {Y : Type u_4} {Z : Type u_5} (e : Z ≃ (α → Y)) (innerRead : Y → β → σ) :
                                                                                                                                              Z → α × β → σ

                                                                                                                                              The observation map of a composed input: the query (p, q) reads coordinate q of the p-th block, through the inner observation map.

                                                                                                                                              Equations
                                                                                                                                              Instances For
                                                                                                                                                @[simp]
                                                                                                                                                theorem QuantumQueryComplexity.composeReadE_apply {α : Type u_1} {β : Type u_2} {σ : Type u_3} {Y : Type u_4} {Z : Type u_5} (e : Z ≃ (α → Y)) (innerRead : Y → β → σ) (z : Z) (pq : α × β) :
                                                                                                                                                composeReadE e innerRead z pq = innerRead (sliceE e z pq.1) pq.2
                                                                                                                                                theorem QuantumQueryComplexity.composeE_hadamard_advDOn {α : Type u_1} {β : Type u_2} {σ : Type u_3} {Y : Type u_4} {Z : Type u_5} [Fintype α] [DecidableEq α] [DecidableEq σ] [Fintype Y] [DecidableEq Y] (e : Z ≃ (α → Y)) (innerRead : Y → β → σ) (g : α → Y → Bool) (Γf : Matrix (α → Bool) (α → Bool) ℝ) (M : α → Matrix Y Y ℝ) (hM : ∀ (i : α), IsAdvCol (g i) (M i)) (p : α) (q : β) :
                                                                                                                                                (composeE e g Γf M).hadamard (advDOn (composeReadE e innerRead) (p, q)) = composeE e g (Γf.hadamard (advD p)) (Function.update M p ((M p).hadamard (advDOn innerRead q)))

                                                                                                                                                The mask identity.

                                                                                                                                                The cube instance #

                                                                                                                                                theorem QuantumQueryComplexity.compose_hadamard_advD {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (g : α → (β → Bool) → Bool) (Γf : Matrix (α → Bool) (α → Bool) ℝ) (M : α → Matrix (β → Bool) (β → Bool) ℝ) (hM : ∀ (i : α), IsAdvMatrix (g i) (M i)) (p : α) (q : β) :
                                                                                                                                                (compose g Γf M).hadamard (advD (p, q)) = compose g (Γf.hadamard (advD p)) (Function.update M p ((M p).hadamard (advD q)))

                                                                                                                                                The mask identity, cube form.

                                                                                                                                                Strong duality for the adversary bound, on a promise domain #

                                                                                                                                                The promise mirror of SourceDualityMain: for a read-determined Boolean promise problem, every value above advPMOn read f is achieved by a feasible DualPairOn:

                                                                                                                                                exists_dualPairOn_of_advPMOn_lt :
                                                                                                                                                  advPMOn read f < c → ∃ m (P : DualPairOn read (Fin m) f), P.IsCostLe c.
                                                                                                                                                

                                                                                                                                                The argument is the same single Hahn–Banach separation, run in the coordinate space DualOmegaOn X → ℝ with the truncation T = 2c·|X|. Determinacy (hdet) is a genuine hypothesis here: an undetermined pair (read x = read y, f x ≠ f y) makes the dual program infeasible while the primal supremum degenerates. In the proof it enters through le_advPMOn, and in the no-query case (ι empty), where it forces f constant so the zero dual is feasible; the X = ∅ case is vacuous and does not use it. The ±1 masking trick needs the output to be two-valued, which is the f : X → Bool hypothesis — exactly the scope the Boolean characterization needs.

                                                                                                                                                Combined with the promise-native lower bound and extraction (SourceQuantumUpperBound), this yields the promise-Boolean characterization; see SourceQuantumCharacterization.

                                                                                                                                                Rank-one test matrices concentrated on one query position #

                                                                                                                                                def QuantumQueryComplexity.concVecOn {ι : Type u_1} [DecidableEq ι] {X : Type u_3} (i₀ : ι) (s t : X → ℝ) :
                                                                                                                                                GramIdxOn X ι → ℝ

                                                                                                                                                The vector of Gram indices carrying s on the u-side and t on the v-side of the query position i₀, and zero elsewhere.

                                                                                                                                                Equations
                                                                                                                                                Instances For
                                                                                                                                                  theorem QuantumQueryComplexity.gramROn_concVecOn {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} (read : X → ι → σ) (i₀ : ι) (s t : X → ℝ) (x y : X) :
                                                                                                                                                  gramROn read (Matrix.vecMulVec (concVecOn i₀ s t) (concVecOn i₀ s t)) x y = if read x i₀ = read y i₀ then 0 else s x * t y
                                                                                                                                                  theorem QuantumQueryComplexity.gramCostOn_concVecOn_false {ι : Type u_1} [Fintype ι] [DecidableEq ι] {X : Type u_3} (i₀ : ι) (s t : X → ℝ) (x : X) :
                                                                                                                                                  gramCostOn (Matrix.vecMulVec (concVecOn i₀ s t) (concVecOn i₀ s t)) false x = s x * s x
                                                                                                                                                  theorem QuantumQueryComplexity.gramCostOn_concVecOn_true {ι : Type u_1} [Fintype ι] [DecidableEq ι] {X : Type u_3} (i₀ : ι) (s t : X → ℝ) (x : X) :
                                                                                                                                                  gramCostOn (Matrix.vecMulVec (concVecOn i₀ s t) (concVecOn i₀ s t)) true x = t x * t x
                                                                                                                                                  theorem QuantumQueryComplexity.sum_sq_concVecOn {ι : Type u_1} [Fintype ι] [DecidableEq ι] {X : Type u_3} [Fintype X] (i₀ : ι) (s t : X → ℝ) :
                                                                                                                                                  ∑ z : GramIdxOn X ι, concVecOn i₀ s t z * concVecOn i₀ s t z = ∑ x : X, s x * s x + ∑ x : X, t x * t x
                                                                                                                                                  theorem QuantumQueryComplexity.concVecOn_ne_zero_left {ι : Type u_1} [DecidableEq ι] {X : Type u_3} {i₀ : ι} {s t : X → ℝ} (hs : s ≠ 0) :
                                                                                                                                                  concVecOn i₀ s t ≠ 0
                                                                                                                                                  theorem QuantumQueryComplexity.concVecOn_ne_zero_right {ι : Type u_1} [DecidableEq ι] {X : Type u_3} {i₀ : ι} {s t : X → ℝ} (ht : t ≠ 0) :
                                                                                                                                                  concVecOn i₀ s t ≠ 0

                                                                                                                                                  Symmetrising a two-weight certificate #

                                                                                                                                                  theorem QuantumQueryComplexity.lt_advPMOn_of_certificate_two {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {read : X → ι → σ} {f : X → Bool} (hdet : ∀ (x y : X), read x = read y → f x = f y) {Ξ : Matrix X X ℝ} {p q : X → ℝ} {c : ℝ} (hp : ∀ (x : X), 0 < p x) (hq : ∀ (x : X), 0 < q x) (hquad : ∀ (i : ι) (s t : X → ℝ), |s ⬝ᵥ (Ξ.hadamard (advDOn read i)).mulVec t| ≤ ∑ x : X, p x * (s x * s x) + ∑ y : X, q y * (t y * t y)) (hobj : c * (∑ x : X, p x + ∑ x : X, q x) < ∑ x : X, ∑ y : X, Ξ x y * dualTargetOn f x y) :
                                                                                                                                                  c < advPMOn read f

                                                                                                                                                  The certificate with the two sides carrying different weights: averaging reduces to the symmetric case, because advDOn read i and dualTargetOn f are symmetric.

                                                                                                                                                  The separation argument #

                                                                                                                                                  theorem QuantumQueryComplexity.exists_dualPairOn_of_advPMOn_lt {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {read : X → ι → σ} {f : X → Bool} (hdet : ∀ (x y : X), read x = read y → f x = f y) {c : ℝ} (hc : advPMOn read f < c) :
                                                                                                                                                  ∃ (m : ℕ) (P : DualPairOn read (Fin m) f), P.IsCostLe c

                                                                                                                                                  Promise strong duality, existence form. For a read-determined Boolean promise problem, every value above the promise adversary bound is achieved by a feasible promise dual solution.

                                                                                                                                                  A nonconstant promise problem has advPMOn ≥ 1/2 #

                                                                                                                                                  The crude entrywise bound ‖M‖ ≤ ∑|M| on the elementary pair matrix loses a factor of two against the total case's exact norm_pairMatrix, which is all the characterization's constant bookkeeping needs.

                                                                                                                                                  The elementary promise adversary matrix supported on one symmetric pair.

                                                                                                                                                  Equations
                                                                                                                                                  Instances For
                                                                                                                                                    theorem QuantumQueryComplexity.pairMatrixOn_apply_self {X : Type u_3} [DecidableEq X] {x y : X} (hxy : x ≠ y) :
                                                                                                                                                    pairMatrixOn x y x y = 1
                                                                                                                                                    theorem QuantumQueryComplexity.sum_abs_pairMatrixOn {X : Type u_3} [Fintype X] [DecidableEq X] {x y : X} (hxy : x ≠ y) :
                                                                                                                                                    ∑ a : X, ∑ b : X, |pairMatrixOn x y a b| = 2
                                                                                                                                                    theorem QuantumQueryComplexity.half_le_advPMOn {ι : Type u_1} {σ : Type u_2} [DecidableEq σ] {X : Type u_3} [Fintype X] [DecidableEq X] {O : Type u_4} {read : X → ι → σ} {f : X → O} (hdet : ∀ (x y : X), read x = read y → f x = f y) {x y : X} (hf : f x ≠ f y) :
                                                                                                                                                    1 / 2 ≤ advPMOn read f

                                                                                                                                                    A nonconstant promise problem has advPMOn ≥ 1/2: half the elementary pair matrix is feasible.

                                                                                                                                                    The composition theorem for the negative-weight adversary bound #

                                                                                                                                                    Main result (advPM_mul_le_advPM_composeFun): for total Boolean functions f : (α → Bool) → Bool and g : (β → Bool) → Bool,

                                                                                                                                                    ADV±(f) * ADV±(g) ≤ ADV±(f ∘ gᵏ)

                                                                                                                                                    — the composition lower bound of Høyer–Lee–Špalek (quant-ph/0611054, Theorem 13, uniform unit-cost case) in the formulation of Belovs–Lee (arXiv:2004.06439, Theorem 1, ≥ direction). The iterated corollary advPM_pow_le_advPM_iterFun gives ADV±(f)^(d+1) ≤ ADV±(f^{∘(d+1)}).

                                                                                                                                                    Proof: for feasible witnesses Γf, Γg, the composed matrix Γh = compose (constFam g) Γf (fun _ => Γg) is an adversary matrix for f ∘ gᵏ with ‖Γh‖ ≥ ‖Γf‖ ‖Γg‖^k (Lemma 16, ≥) and ‖Γh ⊙ advD (p,q)‖ ≤ ‖Γg‖^(k-1) (mask identity + Lemma 16, ≤), so the un-normalized witness lemma yields advPM (f ∘ gᵏ) ≥ ‖Γf‖ ‖Γg‖; two supremum passes finish the proof.

                                                                                                                                                    def QuantumQueryComplexity.composeFunFam {α : Type u_1} {β : Type u_2} (f : (α → Bool) → Bool) (g : α → (β → Bool) → Bool) :
                                                                                                                                                    (α × β → Bool) → Bool

                                                                                                                                                    The composed function f ∘ gᵏ on inputs indexed by α × β.

                                                                                                                                                    Equations
                                                                                                                                                    Instances For
                                                                                                                                                      def QuantumQueryComplexity.composeFun {α : Type u_1} {β : Type u_2} (f : (α → Bool) → Bool) (g : (β → Bool) → Bool) :
                                                                                                                                                      (α × β → Bool) → Bool

                                                                                                                                                      The composed function f ∘ gᵏ on inputs indexed by α × β.

                                                                                                                                                      Equations
                                                                                                                                                      Instances For
                                                                                                                                                        theorem QuantumQueryComplexity.isAdvMatrix_compose {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] [DecidableEq β] {f : (α → Bool) → Bool} {g : α → (β → Bool) → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix (β → Bool) (β → Bool) ℝ} (hf : IsAdvMatrix f Γf) (hM : ∀ (i : α), IsAdvMatrix (g i) (M i)) :
                                                                                                                                                        theorem QuantumQueryComplexity.norm_compose_mask {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {g : (β → Bool) → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {Γg : Matrix (β → Bool) (β → Bool) ℝ} (hf : Γf.IsHermitian) (hg : IsAdvMatrix g Γg) (p : α) (q : β) :
                                                                                                                                                        ‖(compose (constFam g) Γf fun (x : α) => Γg).hadamard (advD (p, q))‖ ≤ ‖Γf.hadamard (advD p)‖ * (‖Γg.hadamard (advD q)‖ * ‖Γg‖ ^ (Fintype.card α - 1))

                                                                                                                                                        The masked norm bound for the composed witness (T1).

                                                                                                                                                        theorem QuantumQueryComplexity.advPM_mul_le_advPM_composeFun {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (f : (α → Bool) → Bool) (g : (β → Bool) → Bool) :

                                                                                                                                                        The composition theorem (HLŠ Theorem 13, uniform unit-cost case; BL Theorem 1, ≥ direction): ADV±(f) * ADV±(g) ≤ ADV±(f ∘ gᵏ).

                                                                                                                                                        The iterated corollary #

                                                                                                                                                        Index types for iterated composition: α, α × α, α × (α × α), …

                                                                                                                                                        Equations
                                                                                                                                                        Instances For
                                                                                                                                                          def QuantumQueryComplexity.iterFun {α : Type u_1} (f : (α → Bool) → Bool) (d : ℕ) :
                                                                                                                                                          (iterIdx α d → Bool) → Bool

                                                                                                                                                          Iterated composition f^{∘(d+1)}.

                                                                                                                                                          Equations
                                                                                                                                                          Instances For
                                                                                                                                                            theorem QuantumQueryComplexity.advPM_pow_le_advPM_iterFun {α : Type u_1} [Fintype α] [DecidableEq α] (f : (α → Bool) → Bool) (d : ℕ) :
                                                                                                                                                            advPM f ^ (d + 1) ≤ advPM (iterFun f d)

                                                                                                                                                            Iterated composition corollary: ADV±(f)^(d+1) ≤ ADV±(f^{∘(d+1)}).

                                                                                                                                                            Composition of dual solutions and the composition upper bound #

                                                                                                                                                            Dual solutions compose multiplicatively (Belovs–Lee, arXiv:2004.06439, Theorem 24; the construction is from LMRSS): tensoring an outer dual solution with an inner one,

                                                                                                                                                            u_{x,(p,q)} = ψ_{x_tilde,p} ⊗ u_{x·ₚ,q}, v_{x,(p,q)} = φ_{x_tilde,p} ⊗ v_{x·ₚ,q},

                                                                                                                                                            produces a feasible dual solution for f ∘ gᵏ of cost the product of the costs (DualPair.compose). This is exactly where the LMRSS constraints on pairs with g x = g y are used: they kill the blocks where the inner function values agree.

                                                                                                                                                            Consequently advDual (f ∘ gᵏ) ≤ advDual f * advDual g, and by weak duality

                                                                                                                                                            ADV±(f ∘ gᵏ) ≤ advDual f * advDual g (advPM_composeFun_le_advDual_mul)

                                                                                                                                                            unconditionally. Combined with the lower bound advPM_mul_le_advPM_composeFun this sandwiches the composed value. The perfect composition theorem ADV±(f ∘ gᵏ) = ADV±(f) · ADV±(g) follows by applying advPM_composeFun_eq_of_dual_eq to the strong-duality theorem advDual_eq_advPM in SourceDualityMain. The unconditional endpoint is advPM_composeFun_eq.

                                                                                                                                                            def QuantumQueryComplexity.DualPair.IsWeightedCostLe {ι : Type u_1} {K : Type u_2} [Fintype ι] [Fintype K] {σ : Type u_3} [DecidableEq σ] {O : Type u_4} [DecidableEq O] {f : (ι → σ) → O} (P : DualPair K f) (c : ι → ℝ) (V : ℝ) :

                                                                                                                                                            The c-weighted cost of a dual solution is bounded by V.

                                                                                                                                                            Stated for a general alphabet and output type: the weighted cost is what the outer solution of a composition must control, and in SourceComposeShared the outer function is a non-Boolean maximum.

                                                                                                                                                            Equations
                                                                                                                                                            • P.IsWeightedCostLe c V = ((∀ (x : ι → σ), ∑ i : ι, c i * ∑ k : K, P.u x i k * P.u x i k ≤ V) ∧ ∀ (x : ι → σ), ∑ i : ι, c i * ∑ k : K, P.v x i k * P.v x i k ≤ V)
                                                                                                                                                            Instances For
                                                                                                                                                              def QuantumQueryComplexity.DualPair.compose {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {f : (α → Bool) → Bool} {g : α → (β → Bool) → Bool} {K₁ : Type u_3} {K₂ : Type u_4} [Fintype K₁] [Fintype K₂] (Pf : DualPair K₁ f) (Pg : (i : α) → DualPair K₂ (g i)) :
                                                                                                                                                              DualPair (K₁ × K₂) (composeFunFam f g)

                                                                                                                                                              Composition of dual solutions (BL Theorem 24 construction).

                                                                                                                                                              Equations
                                                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                                                              Instances For
                                                                                                                                                                theorem QuantumQueryComplexity.sum_tensor_mass {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {K₁ : Type u_3} {K₂ : Type u_4} [Fintype K₁] [Fintype K₂] (u : α → K₁ → ℝ) (v : α → β → K₂ → ℝ) :
                                                                                                                                                                ∑ ℓ : α × β, ∑ k : K₁ × K₂, u ℓ.1 k.1 * v ℓ.1 ℓ.2 k.2 * (u ℓ.1 k.1 * v ℓ.1 ℓ.2 k.2) = ∑ p : α, (∑ k₁ : K₁, u p k₁ * u p k₁) * ∑ q : β, ∑ k₂ : K₂, v p q k₂ * v p q k₂

                                                                                                                                                                Squared mass of a block tensor factors into the two squared masses.

                                                                                                                                                                theorem QuantumQueryComplexity.sum_tensor_mass_le {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {K₁ : Type u_3} {K₂ : Type u_4} [Fintype K₁] [Fintype K₂] (u : α → K₁ → ℝ) (v : α → β → K₂ → ℝ) {c : α → ℝ} {V : ℝ} (hu : ∑ p : α, c p * ∑ k₁ : K₁, u p k₁ * u p k₁ ≤ V) (hv : ∀ (p : α), ∑ q : β, ∑ k₂ : K₂, v p q k₂ * v p q k₂ ≤ c p) :
                                                                                                                                                                ∑ ℓ : α × β, ∑ k : K₁ × K₂, u ℓ.1 k.1 * v ℓ.1 ℓ.2 k.2 * (u ℓ.1 k.1 * v ℓ.1 ℓ.2 k.2) ≤ V

                                                                                                                                                                Inner mass bounds give a weighted bound on the block tensor's mass.

                                                                                                                                                                theorem QuantumQueryComplexity.DualPair.compose_isWeightedCostLe {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {f : (α → Bool) → Bool} {g : α → (β → Bool) → Bool} {K₁ : Type u_3} {K₂ : Type u_4} [Fintype K₁] [Fintype K₂] {Pf : DualPair K₁ f} {Pg : (i : α) → DualPair K₂ (g i)} {c : α → ℝ} {V : ℝ} (hf : Pf.IsWeightedCostLe c V) (hg : ∀ (i : α), (Pg i).IsCostLe (c i)) :
                                                                                                                                                                (Pf.compose Pg).IsCostLe V

                                                                                                                                                                Weighted dual composition: a c-weighted outer bound composes with inner solutions of costs c i to an ordinary bound.

                                                                                                                                                                theorem QuantumQueryComplexity.DualPair.compose_isCostLe {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {f : (α → Bool) → Bool} {g : α → (β → Bool) → Bool} {K₁ : Type u_3} {K₂ : Type u_4} [Fintype K₁] [Fintype K₂] {Pf : DualPair K₁ f} {Pg : (i : α) → DualPair K₂ (g i)} {c₁ c₂ : ℝ} (hf : Pf.IsCostLe c₁) (hg : ∀ (i : α), (Pg i).IsCostLe c₂) (hc₂ : 0 ≤ c₂) :
                                                                                                                                                                (Pf.compose Pg).IsCostLe (c₁ * c₂)

                                                                                                                                                                The cost of a composed dual solution is the product of the costs.

                                                                                                                                                                theorem QuantumQueryComplexity.advDual_composeFun_le {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] (f : (α → Bool) → Bool) (g : (β → Bool) → Bool) :

                                                                                                                                                                The dual value is submultiplicative under composition.

                                                                                                                                                                theorem QuantumQueryComplexity.advPM_composeFun_le_advDual_mul {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (f : (α → Bool) → Bool) (g : (β → Bool) → Bool) :

                                                                                                                                                                The composition upper bound, unconditional: the adversary bound of a composed function is at most the product of the dual values.

                                                                                                                                                                theorem QuantumQueryComplexity.advPM_composeFun_sandwich {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (f : (α → Bool) → Bool) (g : (β → Bool) → Bool) :

                                                                                                                                                                The composed adversary bound is sandwiched between the product of the primal values and the product of the dual values.

                                                                                                                                                                theorem QuantumQueryComplexity.advPM_composeFun_eq_of_dual_eq {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (f : (α → Bool) → Bool) (g : (β → Bool) → Bool) (hf : advDual f = advPM f) (hg : advDual g = advPM g) :

                                                                                                                                                                Perfect composition from supplied duality equalities. The unconditional advPM_composeFun_eq below discharges these using advDual_eq_advPM.

                                                                                                                                                                Functions whose adversary bound is certified on both sides #

                                                                                                                                                                def QuantumQueryComplexity.HasAdvValue {ι : Type u_5} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) (c : ℝ) :

                                                                                                                                                                HasAdvValue f c records that the adversary bound of f equals c and that this value is certified by a dual solution — i.e. strong duality holds at f. This is exactly the hypothesis needed for perfect composition, and it is established for concrete functions by exhibiting a matching primal/dual pair.

                                                                                                                                                                Equations
                                                                                                                                                                Instances For
                                                                                                                                                                  theorem QuantumQueryComplexity.hasAdvValue_of_le {ι : Type u_5} [Fintype ι] [DecidableEq ι] {f : (ι → Bool) → Bool} {c : ℝ} (hprimal : c ≤ advPM f) (hdual : advDual f ≤ c) :

                                                                                                                                                                  Building a HasAdvValue from a primal lower bound and a dual upper bound: weak duality squeezes them together.

                                                                                                                                                                  theorem QuantumQueryComplexity.HasAdvValue.compose {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {f : (α → Bool) → Bool} {g : (β → Bool) → Bool} {a b : ℝ} (hf : HasAdvValue f a) (hg : HasAdvValue g b) :

                                                                                                                                                                  Certified values compose exactly. If strong duality holds at f and at g, then it holds at f ∘ gᵏ, with the product value.

                                                                                                                                                                  The weighted composition lower bound #

                                                                                                                                                                  The composition machinery now allows a different inner function in each block (compose g Γf M with g : α → (β → Bool) → Bool), which is what the cost/weighted version of the adversary composition theorem needs.

                                                                                                                                                                  advPM_composeFunFam_ge is the general weighted statement: if the outer witness Γf satisfies

                                                                                                                                                                  ‖Γf ⊙ D_p‖ · V ≤ ‖Γf‖ · ‖M p‖ for every outer coordinate p,

                                                                                                                                                                  — i.e. Γf certifies the value V for f with costs ‖M p‖ — and each inner witness M i is feasible, then ADV±(f ∘ (g_1, …, g_k)) ≥ V.

                                                                                                                                                                  This is HLŠ Theorem 13 (ADV±_α(h) ≥ ADV±_β(f) with β_i = ADV±(g_i)) in witness form: the cost vector enters as the norms ‖M p‖ of the inner witnesses, so no separate ADV±_α definition is needed.

                                                                                                                                                                  theorem QuantumQueryComplexity.advPM_composeFunFam_ge {α : Type u_1} {β : Type u_2} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] {f : (α → Bool) → Bool} {g : α → (β → Bool) → Bool} {Γf : Matrix (α → Bool) (α → Bool) ℝ} {M : α → Matrix (β → Bool) (β → Bool) ℝ} (hf : IsAdvMatrix f Γf) (hM : ∀ (i : α), IsAdvMatrix (g i) (M i)) (hMfeas : ∀ (i : α) (q : β), ‖(M i).hadamard (advD q)‖ ≤ 1) (hMpos : ∀ (i : α), 0 < ‖M i‖) {V : ℝ} (hVpos : 0 < V) (hΓfpos : 0 < ‖Γf‖) (hV : ∀ (p : α), ‖Γf.hadamard (advD p)‖ * V ≤ ‖Γf‖ * ‖M p‖) :

                                                                                                                                                                  The weighted composition lower bound.

                                                                                                                                                                  The two-bit AND and OR functions have adversary bound √2 #

                                                                                                                                                                  We compute ADV±(AND₂) = ADV±(OR₂) = √2 with a matching dual certificate, i.e. we establish HasAdvValue and2 (√2) and HasAdvValue or2 (√2). Strong duality is therefore available at these functions unconditionally, so the perfect composition theorem applies to them.

                                                                                                                                                                  The primal witness is the star matrix of HLŠ §6: the adversary matrix supported on the two edges joining 11 to its neighbours 01 and 10. Its spectral norm is √2 and each masked norm ‖Γ ⊙ D_i‖ is 1.

                                                                                                                                                                  The dual witness is one-dimensional (K = Unit), with weights α = 2^(-1/4) at 11, β = 2^(1/4) on the sensitive coordinate of each neighbour, and δ = 2^(1/4)/2 at 00; its cost is exactly √2.

                                                                                                                                                                  Enumeration of the four two-bit inputs #

                                                                                                                                                                  @[reducible, inline]

                                                                                                                                                                  The input 00.

                                                                                                                                                                  Equations
                                                                                                                                                                  Instances For
                                                                                                                                                                    @[reducible, inline]

                                                                                                                                                                    The input 01.

                                                                                                                                                                    Equations
                                                                                                                                                                    Instances For
                                                                                                                                                                      @[reducible, inline]

                                                                                                                                                                      The input 10.

                                                                                                                                                                      Equations
                                                                                                                                                                      Instances For
                                                                                                                                                                        @[reducible, inline]

                                                                                                                                                                        The input 11.

                                                                                                                                                                        Equations
                                                                                                                                                                        Instances For
                                                                                                                                                                          theorem QuantumQueryComplexity.sum_fin2Bool (f : (Fin 2 → Bool) → ℝ) :
                                                                                                                                                                          ∑ w : Fin 2 → Bool, f w = f i00 + f i01 + f i10 + f i11
                                                                                                                                                                          theorem QuantumQueryComplexity.dotProduct_fin2Bool (x y : (Fin 2 → Bool) → ℝ) :
                                                                                                                                                                          x ⬝ᵥ y = x i00 * y i00 + x i01 * y i01 + x i10 * y i10 + x i11 * y i11

                                                                                                                                                                          The two-bit AND function and its primal witness #

                                                                                                                                                                          The two-bit AND function.

                                                                                                                                                                          Equations
                                                                                                                                                                          Instances For
                                                                                                                                                                            noncomputable def QuantumQueryComplexity.and2Gamma :
                                                                                                                                                                            Matrix (Fin 2 → Bool) (Fin 2 → Bool) ℝ

                                                                                                                                                                            The star adversary matrix for AND₂, centred at 11.

                                                                                                                                                                            Equations
                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                            Instances For
                                                                                                                                                                              theorem QuantumQueryComplexity.and2Gamma_mulVec_apply (y : (Fin 2 → Bool) → ℝ) (w : Fin 2 → Bool) :
                                                                                                                                                                              and2Gamma.mulVec y w = ((if i01 = w then y i11 else 0) + if i11 = w then y i01 else 0) + ((if i10 = w then y i11 else 0) + if i11 = w then y i10 else 0)

                                                                                                                                                                              The dual witness #

                                                                                                                                                                              β = 2^(1/4).

                                                                                                                                                                              Equations
                                                                                                                                                                              Instances For
                                                                                                                                                                                noncomputable def QuantumQueryComplexity.and2DualVec (x : Fin 2 → Bool) (i : Fin 2) :

                                                                                                                                                                                The one-dimensional dual weights for AND₂.

                                                                                                                                                                                Equations
                                                                                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                                                                                Instances For

                                                                                                                                                                                  The dual solution for AND₂.

                                                                                                                                                                                  Equations
                                                                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                                                                  Instances For

                                                                                                                                                                                    ADV±(AND₂) = √2, with a matching dual certificate.

                                                                                                                                                                                    Invariance of the adversary bound under relabelling #

                                                                                                                                                                                    Negating the output, or negating a set of input bits, changes neither the primal nor the dual value. This transfers the AND₂ computation to OR₂.

                                                                                                                                                                                    theorem QuantumQueryComplexity.isAdvMatrix_not {ι : Type u_1} {f : (ι → Bool) → Bool} {Γ : Matrix (ι → Bool) (ι → Bool) ℝ} :
                                                                                                                                                                                    IsAdvMatrix (fun (x : ι → Bool) => !f x) Γ ↔ IsAdvMatrix f Γ
                                                                                                                                                                                    theorem QuantumQueryComplexity.advPM_not {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) :
                                                                                                                                                                                    (advPM fun (x : ι → Bool) => !f x) = advPM f
                                                                                                                                                                                    def QuantumQueryComplexity.DualPair.notFun {ι : Type u_1} [Fintype ι] {K : Type u_2} [Fintype K] {f : (ι → Bool) → Bool} (P : DualPair K f) :
                                                                                                                                                                                    DualPair K fun (x : ι → Bool) => !f x

                                                                                                                                                                                    Transport of a dual solution along output negation.

                                                                                                                                                                                    Equations
                                                                                                                                                                                    Instances For
                                                                                                                                                                                      theorem QuantumQueryComplexity.advDual_not {ι : Type u_1} [Fintype ι] (f : (ι → Bool) → Bool) :
                                                                                                                                                                                      (advDual fun (x : ι → Bool) => !f x) = advDual f
                                                                                                                                                                                      def QuantumQueryComplexity.flipAll {ι : Type u_1} :
                                                                                                                                                                                      (ι → Bool) ≃ (ι → Bool)

                                                                                                                                                                                      Negating every input bit.

                                                                                                                                                                                      Equations
                                                                                                                                                                                      Instances For
                                                                                                                                                                                        theorem QuantumQueryComplexity.flipAll_apply {ι : Type u_1} (x : ι → Bool) (i : ι) :
                                                                                                                                                                                        flipAll x i = !x i
                                                                                                                                                                                        theorem QuantumQueryComplexity.flipAll_coord_iff {ι : Type u_1} (x y : ι → Bool) (i : ι) :
                                                                                                                                                                                        flipAll x i = flipAll y i ↔ x i = y i
                                                                                                                                                                                        theorem QuantumQueryComplexity.isAdvMatrix_comp_flipAll {ι : Type u_1} {f : (ι → Bool) → Bool} {Γ : Matrix (ι → Bool) (ι → Bool) ℝ} (h : IsAdvMatrix f Γ) :
                                                                                                                                                                                        IsAdvMatrix (fun (x : ι → Bool) => f (flipAll x)) (Γ.submatrix ⇑flipAll ⇑flipAll)
                                                                                                                                                                                        theorem QuantumQueryComplexity.submatrix_flipAll_hadamard {ι : Type u_1} (Γ : Matrix (ι → Bool) (ι → Bool) ℝ) (i : ι) :
                                                                                                                                                                                        theorem QuantumQueryComplexity.advPM_comp_flipAll {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) :
                                                                                                                                                                                        (advPM fun (x : ι → Bool) => f (flipAll x)) = advPM f
                                                                                                                                                                                        def QuantumQueryComplexity.DualPair.compFlipAll {ι : Type u_1} [Fintype ι] {K : Type u_2} [Fintype K] {f : (ι → Bool) → Bool} (P : DualPair K f) :
                                                                                                                                                                                        DualPair K fun (x : ι → Bool) => f (flipAll x)

                                                                                                                                                                                        Transport of a dual solution along input negation.

                                                                                                                                                                                        Equations
                                                                                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                                                                                        Instances For
                                                                                                                                                                                          theorem QuantumQueryComplexity.advDual_comp_flipAll {ι : Type u_1} [Fintype ι] (f : (ι → Bool) → Bool) :
                                                                                                                                                                                          (advDual fun (x : ι → Bool) => f (flipAll x)) = advDual f
                                                                                                                                                                                          theorem QuantumQueryComplexity.HasAdvValue.not {ι : Type u_1} [Fintype ι] [DecidableEq ι] {f : (ι → Bool) → Bool} {c : ℝ} (h : HasAdvValue f c) :
                                                                                                                                                                                          HasAdvValue (fun (x : ι → Bool) => !f x) c
                                                                                                                                                                                          theorem QuantumQueryComplexity.HasAdvValue.compFlipAll {ι : Type u_1} [Fintype ι] [DecidableEq ι] {f : (ι → Bool) → Bool} {c : ℝ} (h : HasAdvValue f c) :
                                                                                                                                                                                          HasAdvValue (fun (x : ι → Bool) => f (flipAll x)) c

                                                                                                                                                                                          The two-bit OR function #

                                                                                                                                                                                          The two-bit OR function.

                                                                                                                                                                                          Equations
                                                                                                                                                                                          Instances For

                                                                                                                                                                                            ADV±(OR₂) = √2, with a matching dual certificate.

                                                                                                                                                                                            Strong duality for total-input adversary bounds #

                                                                                                                                                                                            The total-input existence theorem specializes exists_dualPairOn_of_advPMOn_lt at the identity read and transports the resulting certificate with DualPairOn.toTotal. The Hahn–Banach separation argument is proved once, in SourceDualityMainOn; the certificate and mask bounds are specialized in TotalDualitySpecialization.

                                                                                                                                                                                            The total-input Gram helpers below remain available for clients of that API. Weak duality then gives advDual g = advPM g for Boolean functions, followed by the exact block-composition corollaries.

                                                                                                                                                                                            Rank-one test matrices concentrated on one query position #

                                                                                                                                                                                            def QuantumQueryComplexity.concVec {ι : Type u_1} [DecidableEq ι] {σ : Type u_2} (i₀ : ι) (s t : (ι → σ) → ℝ) :
                                                                                                                                                                                            GramIdx ι σ → ℝ

                                                                                                                                                                                            The vector of Gram indices carrying s on the u-side and t on the v-side of the query position i₀, and zero elsewhere.

                                                                                                                                                                                            Equations
                                                                                                                                                                                            Instances For
                                                                                                                                                                                              theorem QuantumQueryComplexity.gramR_concVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] (i₀ : ι) (s t : (ι → σ) → ℝ) (x y : ι → σ) :
                                                                                                                                                                                              gramR (Matrix.vecMulVec (concVec i₀ s t) (concVec i₀ s t)) x y = if x i₀ = y i₀ then 0 else s x * t y
                                                                                                                                                                                              theorem QuantumQueryComplexity.gramCost_concVec_false {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} (i₀ : ι) (s t : (ι → σ) → ℝ) (x : ι → σ) :
                                                                                                                                                                                              gramCost (Matrix.vecMulVec (concVec i₀ s t) (concVec i₀ s t)) false x = s x * s x
                                                                                                                                                                                              theorem QuantumQueryComplexity.gramCost_concVec_true {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} (i₀ : ι) (s t : (ι → σ) → ℝ) (x : ι → σ) :
                                                                                                                                                                                              gramCost (Matrix.vecMulVec (concVec i₀ s t) (concVec i₀ s t)) true x = t x * t x
                                                                                                                                                                                              theorem QuantumQueryComplexity.sum_sq_concVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] (i₀ : ι) (s t : (ι → σ) → ℝ) :
                                                                                                                                                                                              ∑ z : GramIdx ι σ, concVec i₀ s t z * concVec i₀ s t z = ∑ x : ι → σ, s x * s x + ∑ x : ι → σ, t x * t x
                                                                                                                                                                                              theorem QuantumQueryComplexity.concVec_ne_zero_left {ι : Type u_1} [DecidableEq ι] {σ : Type u_2} {i₀ : ι} {s t : (ι → σ) → ℝ} (hs : s ≠ 0) :
                                                                                                                                                                                              concVec i₀ s t ≠ 0
                                                                                                                                                                                              theorem QuantumQueryComplexity.concVec_ne_zero_right {ι : Type u_1} [DecidableEq ι] {σ : Type u_2} {i₀ : ι} {s t : (ι → σ) → ℝ} (ht : t ≠ 0) :
                                                                                                                                                                                              concVec i₀ s t ≠ 0

                                                                                                                                                                                              Symmetrising a two-weight certificate #

                                                                                                                                                                                              theorem QuantumQueryComplexity.lt_advPM_of_certificate_two {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {g : (ι → σ) → Bool} {Ξ : Matrix (ι → σ) (ι → σ) ℝ} {p q : (ι → σ) → ℝ} {c : ℝ} (hp : ∀ (x : ι → σ), 0 < p x) (hq : ∀ (x : ι → σ), 0 < q x) (hquad : ∀ (i : ι) (s t : (ι → σ) → ℝ), |s ⬝ᵥ (Ξ.hadamard (advD i)).mulVec t| ≤ ∑ x : ι → σ, p x * (s x * s x) + ∑ y : ι → σ, q y * (t y * t y)) (hobj : c * (∑ x : ι → σ, p x + ∑ x : ι → σ, q x) < ∑ x : ι → σ, ∑ y : ι → σ, Ξ x y * dualTarget g x y) :
                                                                                                                                                                                              c < advPM g

                                                                                                                                                                                              The certificate of lt_advPM_of_certificate with the two sides carrying different weights: averaging Ξ with its transpose and the two weights with each other reduces to the symmetric case, because advD i and dualTarget g are symmetric.

                                                                                                                                                                                              The separation argument #

                                                                                                                                                                                              theorem QuantumQueryComplexity.exists_dualPair_of_advPM_lt {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {g : (ι → σ) → Bool} {c : ℝ} (hc : advPM g < c) :
                                                                                                                                                                                              ∃ (m : ℕ) (P : DualPair (Fin m) g), P.IsCostLe c

                                                                                                                                                                                              Strong duality, existence form. Above the adversary bound every value is achieved by a feasible dual solution.

                                                                                                                                                                                              Strong duality #

                                                                                                                                                                                              theorem QuantumQueryComplexity.advDual_eq_advPM {ι : Type u_3} [Fintype ι] [DecidableEq ι] (g : (ι → Bool) → Bool) :

                                                                                                                                                                                              Strong duality for the adversary bound. The LMRSS dual program has no gap: its value equals ADV±.

                                                                                                                                                                                              Consequences #

                                                                                                                                                                                              theorem QuantumQueryComplexity.advPM_composeFun_eq {α : Type u_3} {β : Type u_4} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (f : (α → Bool) → Bool) (g : (β → Bool) → Bool) :

                                                                                                                                                                                              Perfect composition, unconditionally: the adversary bound is exactly multiplicative under composition.

                                                                                                                                                                                              theorem QuantumQueryComplexity.hasAdvValue_advPM {α : Type u_3} [Fintype α] [DecidableEq α] (f : (α → Bool) → Bool) :

                                                                                                                                                                                              Every Boolean function carries a matching primal/dual pair of witnesses.

                                                                                                                                                                                              theorem QuantumQueryComplexity.advPM_iterFun_eq {α : Type u_3} [Fintype α] [DecidableEq α] (f : (α → Bool) → Bool) (d : ℕ) :
                                                                                                                                                                                              advPM (iterFun f d) = advPM f ^ (d + 1)

                                                                                                                                                                                              The iterated composition value is exact.

                                                                                                                                                                                              Star adversary matrices #

                                                                                                                                                                                              A star matrix with centre c and leaf set S is ∑ z ∈ S, pairMatrix z c: the symmetric matrix whose only nonzero entries are the unit weights joining c to each leaf. Its spectral norm is √|S| (norm_starMatrix), and masking it by a difference matrix restricts the leaf set to those leaves differing from the centre in that coordinate (starMatrix_hadamard_advD).

                                                                                                                                                                                              These are the optimal primal witnesses for OR and AND, and specialise to the two-bit case of SourceAndOr.

                                                                                                                                                                                              Generic sum manipulations #

                                                                                                                                                                                              theorem QuantumQueryComplexity.isHermitian_sum {ι : Type u_1} {σ : Type u_2} {α : Type u_3} {S : Finset α} {M : α → Matrix (ι → σ) (ι → σ) ℝ} (h : ∀ a ∈ S, (M a).IsHermitian) :
                                                                                                                                                                                              (∑ a ∈ S, M a).IsHermitian
                                                                                                                                                                                              theorem QuantumQueryComplexity.sum_mulVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] {α : Type u_3} (S : Finset α) (M : α → Matrix (ι → σ) (ι → σ) ℝ) (y : (ι → σ) → ℝ) :
                                                                                                                                                                                              (∑ a ∈ S, M a).mulVec y = ∑ a ∈ S, (M a).mulVec y
                                                                                                                                                                                              theorem QuantumQueryComplexity.sum_hadamard {ι : Type u_1} {σ : Type u_2} {α : Type u_3} (S : Finset α) (M : α → Matrix (ι → σ) (ι → σ) ℝ) (D : Matrix (ι → σ) (ι → σ) ℝ) :
                                                                                                                                                                                              (∑ a ∈ S, M a).hadamard D = ∑ a ∈ S, (M a).hadamard D
                                                                                                                                                                                              theorem QuantumQueryComplexity.sum_ite_const {α : Type u_3} [Fintype α] (p : α → Prop) [DecidablePred p] (C : ℝ) :
                                                                                                                                                                                              (∑ a : α, if p a then C else 0) = ↑(Finset.filter p Finset.univ).card * C

                                                                                                                                                                                              The star matrix #

                                                                                                                                                                                              noncomputable def QuantumQueryComplexity.starMatrix {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) :
                                                                                                                                                                                              Matrix (ι → σ) (ι → σ) ℝ

                                                                                                                                                                                              The star matrix with centre c and leaves S.

                                                                                                                                                                                              Equations
                                                                                                                                                                                              Instances For
                                                                                                                                                                                                theorem QuantumQueryComplexity.starMatrix_isHermitian {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) :
                                                                                                                                                                                                theorem QuantumQueryComplexity.starMatrix_mulVec_apply {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) (y : (ι → σ) → ℝ) (w : ι → σ) :
                                                                                                                                                                                                (starMatrix S c).mulVec y w = (if w ∈ S then y c else 0) + if c = w then ∑ z ∈ S, y z else 0
                                                                                                                                                                                                theorem QuantumQueryComplexity.starMatrix_bilinear {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {S : Finset (ι → σ)} {c : ι → σ} (x y : (ι → σ) → ℝ) :
                                                                                                                                                                                                x ⬝ᵥ (starMatrix S c).mulVec y = (∑ w ∈ S, x w) * y c + x c * ∑ z ∈ S, y z
                                                                                                                                                                                                theorem QuantumQueryComplexity.sum_sq_ge {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] {S : Finset (ι → σ)} {c : ι → σ} (hc : c ∉ S) (x : (ι → σ) → ℝ) :
                                                                                                                                                                                                ∑ w ∈ S, x w * x w + x c * x c ≤ x ⬝ᵥ x

                                                                                                                                                                                                Splitting off the centre and the leaves from a sum over all inputs.

                                                                                                                                                                                                theorem QuantumQueryComplexity.norm_starMatrix_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {S : Finset (ι → σ)} {c : ι → σ} (hc : c ∉ S) :
                                                                                                                                                                                                noncomputable def QuantumQueryComplexity.starVec {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) :
                                                                                                                                                                                                (ι → σ) → ℝ

                                                                                                                                                                                                The top eigenvector of a star matrix.

                                                                                                                                                                                                Equations
                                                                                                                                                                                                Instances For
                                                                                                                                                                                                  theorem QuantumQueryComplexity.sqrt_card_le_norm_starMatrix {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {S : Finset (ι → σ)} {c : ι → σ} (hc : c ∉ S) (hS : S.Nonempty) :
                                                                                                                                                                                                  theorem QuantumQueryComplexity.norm_starMatrix {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {S : Finset (ι → σ)} {c : ι → σ} (hc : c ∉ S) (hS : S.Nonempty) :
                                                                                                                                                                                                  theorem QuantumQueryComplexity.starMatrix_hadamard_advD {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) (i : ι) :
                                                                                                                                                                                                  (starMatrix S c).hadamard (advD i) = starMatrix ({z ∈ S | ¬z i = c i}) c

                                                                                                                                                                                                  Weighted star matrices #

                                                                                                                                                                                                  Giving the edges weights w replaces the leaf count |S| by the total squared weight ∑ w². This is what the cost version of the adversary bound needs: for OR_k with costs c, the weighted star with w = c certifies the value √(∑ cᵢ²) with masked norms cᵢ.

                                                                                                                                                                                                  noncomputable def QuantumQueryComplexity.wStarMatrix {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) (w : (ι → σ) → ℝ) :
                                                                                                                                                                                                  Matrix (ι → σ) (ι → σ) ℝ

                                                                                                                                                                                                  The star matrix with centre c, leaves S and edge weights w.

                                                                                                                                                                                                  Equations
                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                    def QuantumQueryComplexity.starWeight {ι : Type u_1} {σ : Type u_2} (S : Finset (ι → σ)) (w : (ι → σ) → ℝ) :

                                                                                                                                                                                                    The total squared weight of a star.

                                                                                                                                                                                                    Equations
                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                      theorem QuantumQueryComplexity.starWeight_nonneg {ι : Type u_1} {σ : Type u_2} (S : Finset (ι → σ)) (w : (ι → σ) → ℝ) :
                                                                                                                                                                                                      theorem QuantumQueryComplexity.wStarMatrix_isHermitian {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) (w : (ι → σ) → ℝ) :
                                                                                                                                                                                                      theorem QuantumQueryComplexity.wStarMatrix_mulVec_apply {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) (w y : (ι → σ) → ℝ) (v : ι → σ) :
                                                                                                                                                                                                      (wStarMatrix S c w).mulVec y v = (if v ∈ S then w v * y c else 0) + if c = v then ∑ z ∈ S, w z * y z else 0
                                                                                                                                                                                                      theorem QuantumQueryComplexity.wStarMatrix_bilinear {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {S : Finset (ι → σ)} {c : ι → σ} (w x y : (ι → σ) → ℝ) :
                                                                                                                                                                                                      x ⬝ᵥ (wStarMatrix S c w).mulVec y = (∑ z ∈ S, w z * x z) * y c + x c * ∑ z ∈ S, w z * y z
                                                                                                                                                                                                      theorem QuantumQueryComplexity.norm_wStarMatrix_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {S : Finset (ι → σ)} {c : ι → σ} (hc : c ∉ S) (w : (ι → σ) → ℝ) :
                                                                                                                                                                                                      noncomputable def QuantumQueryComplexity.wStarVec {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) (w : (ι → σ) → ℝ) :
                                                                                                                                                                                                      (ι → σ) → ℝ

                                                                                                                                                                                                      The top eigenvector of a weighted star matrix.

                                                                                                                                                                                                      Equations
                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                        theorem QuantumQueryComplexity.sqrt_starWeight_le_norm_wStarMatrix {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {S : Finset (ι → σ)} {c : ι → σ} (hc : c ∉ S) {w : (ι → σ) → ℝ} (hW : 0 < starWeight S w) :
                                                                                                                                                                                                        theorem QuantumQueryComplexity.norm_wStarMatrix {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {S : Finset (ι → σ)} {c : ι → σ} (hc : c ∉ S) {w : (ι → σ) → ℝ} (hW : 0 < starWeight S w) :
                                                                                                                                                                                                        theorem QuantumQueryComplexity.wStarMatrix_hadamard_advD {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (S : Finset (ι → σ)) (c : ι → σ) (w : (ι → σ) → ℝ) (i : ι) :
                                                                                                                                                                                                        (wStarMatrix S c w).hadamard (advD i) = wStarMatrix ({z ∈ S | ¬z i = c i}) c w

                                                                                                                                                                                                        ADV±(OR_n) = ADV±(AND_n) = √n #

                                                                                                                                                                                                        We compute the adversary bound of the n-bit OR and AND functions, with matching dual certificates, so strong duality holds at them and they compose perfectly.

                                                                                                                                                                                                        AND_n follows from OR_n by De Morgan, using the relabelling invariance lemmas of SourceAndOr.

                                                                                                                                                                                                        The n-bit OR function #

                                                                                                                                                                                                        The all-zero input.

                                                                                                                                                                                                        Equations
                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                          def QuantumQueryComplexity.unitVec {ι : Type u_1} [DecidableEq ι] (i : ι) :
                                                                                                                                                                                                          ι → Bool

                                                                                                                                                                                                          The input with a single true in position i.

                                                                                                                                                                                                          Equations
                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                            def QuantumQueryComplexity.orN {ι : Type u_1} [Fintype ι] (x : ι → Bool) :

                                                                                                                                                                                                            The n-bit OR function.

                                                                                                                                                                                                            Equations
                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                              def QuantumQueryComplexity.andN {ι : Type u_1} [Fintype ι] (x : ι → Bool) :

                                                                                                                                                                                                              The n-bit AND function.

                                                                                                                                                                                                              Equations
                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                @[simp]
                                                                                                                                                                                                                theorem QuantumQueryComplexity.unitVec_apply {ι : Type u_1} [DecidableEq ι] (i j : ι) :
                                                                                                                                                                                                                unitVec i j = decide (j = i)
                                                                                                                                                                                                                @[simp]
                                                                                                                                                                                                                noncomputable def QuantumQueryComplexity.unitSet {ι : Type u_1} [Fintype ι] [DecidableEq ι] :
                                                                                                                                                                                                                Finset (ι → Bool)

                                                                                                                                                                                                                The leaf set of the OR star matrix.

                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                  theorem QuantumQueryComplexity.mem_unitSet {ι : Type u_1} [Fintype ι] [DecidableEq ι] {z : ι → Bool} :
                                                                                                                                                                                                                  z ∈ unitSet ↔ ∃ (i : ι), unitVec i = z

                                                                                                                                                                                                                  The primal witness #

                                                                                                                                                                                                                  theorem QuantumQueryComplexity.unitSet_filter {ι : Type u_1} [Fintype ι] [DecidableEq ι] (j : ι) :
                                                                                                                                                                                                                  {z ∈ unitSet | ¬z j = zeroVec j} = {unitVec j}

                                                                                                                                                                                                                  The dual witness #

                                                                                                                                                                                                                  def QuantumQueryComplexity.supportCard {ι : Type u_1} [Fintype ι] (x : ι → Bool) :

                                                                                                                                                                                                                  The Hamming weight of an input.

                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                    theorem QuantumQueryComplexity.supportCard_pos {ι : Type u_1} [Fintype ι] {x : ι → Bool} (hx : x ≠ zeroVec) :
                                                                                                                                                                                                                    noncomputable def QuantumQueryComplexity.orNDelta (ι : Type u_2) [Fintype ι] :

                                                                                                                                                                                                                    δ = n^(-1/4).

                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                      δ² = 1/√n.

                                                                                                                                                                                                                      n δ² = √n.

                                                                                                                                                                                                                      noncomputable def QuantumQueryComplexity.orNDualVec {ι : Type u_1} [Fintype ι] (x : ι → Bool) (i : ι) :

                                                                                                                                                                                                                      The one-dimensional dual weights for OR_n.

                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                        noncomputable def QuantumQueryComplexity.orNDual {ι : Type u_1} [Fintype ι] [Nonempty ι] :

                                                                                                                                                                                                                        The dual solution for OR_n.

                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                          ADV±(OR_n) = √n, with a matching dual certificate.

                                                                                                                                                                                                                          The n-bit AND function #

                                                                                                                                                                                                                          theorem QuantumQueryComplexity.andN_eq {ι : Type u_1} [Fintype ι] :
                                                                                                                                                                                                                          andN = fun (x : ι → Bool) => !orN (flipAll x)

                                                                                                                                                                                                                          ADV±(AND_n) = √n, with a matching dual certificate.

                                                                                                                                                                                                                          The weighted OR witness and weighted OR-composition #

                                                                                                                                                                                                                          The weighted star centred at the all-zero input, with weight c i on the edge to the i-th unit input, is the optimal cost-c witness for OR_n: its norm is √(∑ cᵢ²) and its i-th masked norm is cᵢ (norm_orWStar, norm_orWStar_hadamard).

                                                                                                                                                                                                                          Feeding it into the weighted composition theorem gives the key inductive step for read-once formulas:

                                                                                                                                                                                                                          ADV±(OR_k ∘ (g₁, …, g_k)) ≥ √(∑ᵢ ADV±(gᵢ)²)

                                                                                                                                                                                                                          (sqrt_sum_sq_le_advPM_composeFunFam_orN), and the same for AND_k by De Morgan.

                                                                                                                                                                                                                          def QuantumQueryComplexity.wOf {ι : Type u_1} [Fintype ι] (c : ι → ℝ) (z : ι → Bool) :

                                                                                                                                                                                                                          The weight function attaching c i to the i-th unit input.

                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                            theorem QuantumQueryComplexity.wOf_unitVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] (c : ι → ℝ) (i : ι) :
                                                                                                                                                                                                                            wOf c (unitVec i) = c i
                                                                                                                                                                                                                            noncomputable def QuantumQueryComplexity.orWStar {ι : Type u_1} [Fintype ι] [DecidableEq ι] (c : ι → ℝ) :
                                                                                                                                                                                                                            Matrix (ι → Bool) (ι → Bool) ℝ

                                                                                                                                                                                                                            The weighted star witness for OR_n with costs c.

                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                              theorem QuantumQueryComplexity.starWeight_unitSet {ι : Type u_1} [Fintype ι] [DecidableEq ι] (c : ι → ℝ) :
                                                                                                                                                                                                                              starWeight unitSet (wOf c) = ∑ i : ι, c i * c i
                                                                                                                                                                                                                              theorem QuantumQueryComplexity.norm_orWStar {ι : Type u_1} [Fintype ι] [DecidableEq ι] {c : ι → ℝ} (hc : 0 < ∑ i : ι, c i * c i) :
                                                                                                                                                                                                                              ‖orWStar c‖ = √(∑ i : ι, c i * c i)
                                                                                                                                                                                                                              theorem QuantumQueryComplexity.norm_orWStar_hadamard {ι : Type u_1} [Fintype ι] [DecidableEq ι] (c : ι → ℝ) (j : ι) :
                                                                                                                                                                                                                              theorem QuantumQueryComplexity.sqrt_sum_sq_le_advPM_composeFunFam_orN {ι : Type u_1} [Fintype ι] [DecidableEq ι] {β : Type u_2} [Fintype β] [DecidableEq β] {g : ι → (β → Bool) → Bool} {M : ι → Matrix (β → Bool) (β → Bool) ℝ} (hM : ∀ (i : ι), IsAdvMatrix (g i) (M i)) (hMfeas : ∀ (i : ι) (q : β), ‖(M i).hadamard (advD q)‖ ≤ 1) (hMpos : ∀ (i : ι), 0 < ‖M i‖) [Nonempty ι] :
                                                                                                                                                                                                                              √(∑ i : ι, ‖M i‖ * ‖M i‖) ≤ advPM (composeFunFam orN g)

                                                                                                                                                                                                                              The weighted OR-composition lower bound. Composing OR_k with inner functions certified by witnesses M i gives at least √(∑ᵢ ‖M i‖²).

                                                                                                                                                                                                                              theorem QuantumQueryComplexity.composeFunFam_andN_eq {ι : Type u_1} [Fintype ι] {β : Type u_2} {g : ι → (β → Bool) → Bool} :
                                                                                                                                                                                                                              composeFunFam andN g = fun (x : ι × β → Bool) => !composeFunFam orN (fun (i : ι) (u : β → Bool) => !g i u) x

                                                                                                                                                                                                                              Composing AND is composing OR with negated inner functions, up to negating the output.

                                                                                                                                                                                                                              theorem QuantumQueryComplexity.sqrt_sum_sq_le_advPM_composeFunFam_andN {ι : Type u_1} [Fintype ι] [DecidableEq ι] {β : Type u_2} [Fintype β] [DecidableEq β] {g : ι → (β → Bool) → Bool} {M : ι → Matrix (β → Bool) (β → Bool) ℝ} (hM : ∀ (i : ι), IsAdvMatrix (g i) (M i)) (hMfeas : ∀ (i : ι) (q : β), ‖(M i).hadamard (advD q)‖ ≤ 1) (hMpos : ∀ (i : ι), 0 < ‖M i‖) [Nonempty ι] :
                                                                                                                                                                                                                              √(∑ i : ι, ‖M i‖ * ‖M i‖) ≤ advPM (composeFunFam andN g)

                                                                                                                                                                                                                              The same bound for AND_k, by De Morgan.

                                                                                                                                                                                                                              The weighted dual and weighted dual composition #

                                                                                                                                                                                                                              The cost side of the weighted composition theorem. Composing an outer dual solution with inner ones of costs c i gives a composed cost

                                                                                                                                                                                                                              ∑_p c_p ‖ψ_{x_tilde,p}‖²,

                                                                                                                                                                                                                              which is the c-weighted cost of the outer solution (DualPair.IsWeightedCostLe). So DualPair.compose_isWeightedCostLe turns a weighted outer bound into an ordinary bound on the composition.

                                                                                                                                                                                                                              For OR_n with costs c the optimal weighted dual is one-dimensional, with δₚ = √cₚ / √V at the all-zero input (where V = √(∑ cᵢ²)) and 1 / (∑_{p ∈ supp x} δₚ) on the support of each nonzero x; its c-weighted cost is exactly V (orWDual_isWeightedCostLe). Composing gives

                                                                                                                                                                                                                              advDual (OR_k ∘ (g₁, …, g_k)) ≤ √(∑ᵢ cᵢ²)

                                                                                                                                                                                                                              whenever the inner functions have dual solutions of cost cᵢ (advDual_composeFunFam_orN_le), matching the primal bound of SourceWeightedOr.

                                                                                                                                                                                                                              The weighted cost of a dual solution #

                                                                                                                                                                                                                              The weighted OR dual #

                                                                                                                                                                                                                              theorem QuantumQueryComplexity.sum_sq_le_sq_sum {ι : Type u_1} {S : Finset ι} {a : ι → ℝ} (ha : ∀ i ∈ S, 0 ≤ a i) :
                                                                                                                                                                                                                              ∑ i ∈ S, a i * a i ≤ (∑ i ∈ S, a i) * ∑ i ∈ S, a i
                                                                                                                                                                                                                              noncomputable def QuantumQueryComplexity.orWVal {ι : Type u_1} [Fintype ι] (c : ι → ℝ) :

                                                                                                                                                                                                                              The target value V = √(∑ cᵢ²).

                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                theorem QuantumQueryComplexity.orWVal_sq {ι : Type u_1} [Fintype ι] (c : ι → ℝ) :
                                                                                                                                                                                                                                orWVal c * orWVal c = ∑ i : ι, c i * c i
                                                                                                                                                                                                                                theorem QuantumQueryComplexity.orWVal_pos {ι : Type u_1} [Fintype ι] (c : ι → ℝ) [Nonempty ι] (hc : ∀ (i : ι), 0 < c i) :
                                                                                                                                                                                                                                0 < orWVal c
                                                                                                                                                                                                                                noncomputable def QuantumQueryComplexity.orWDelta {ι : Type u_1} [Fintype ι] (c : ι → ℝ) (p : ι) :

                                                                                                                                                                                                                                δₚ = √cₚ / √V.

                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                  noncomputable def QuantumQueryComplexity.orWSupp {ι : Type u_1} [Fintype ι] (c : ι → ℝ) (x : ι → Bool) :

                                                                                                                                                                                                                                  D x = ∑_{p ∈ supp x} δₚ.

                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                    noncomputable def QuantumQueryComplexity.orWSqrtSupp {ι : Type u_1} [Fintype ι] (c : ι → ℝ) (x : ι → Bool) :

                                                                                                                                                                                                                                    The support sum of square roots, ∑_{p ∈ supp x} √cₚ.

                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.orWDelta_pos {ι : Type u_1} [Fintype ι] {c : ι → ℝ} [Nonempty ι] (hc : ∀ (i : ι), 0 < c i) (p : ι) :
                                                                                                                                                                                                                                      0 < orWDelta c p
                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.exists_true_of_ne_zeroVec {ι : Type u_1} {x : ι → Bool} (hx : x ≠ zeroVec) :
                                                                                                                                                                                                                                      ∃ (p : ι), x p = true
                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.orWSqrtSupp_pos {ι : Type u_1} [Fintype ι] {c : ι → ℝ} (hc : ∀ (i : ι), 0 < c i) {x : ι → Bool} (hx : x ≠ zeroVec) :
                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.orWSupp_eq {ι : Type u_1} [Fintype ι] {c : ι → ℝ} (x : ι → Bool) :
                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.orWSupp_pos {ι : Type u_1} [Fintype ι] {c : ι → ℝ} [Nonempty ι] (hc : ∀ (i : ι), 0 < c i) {x : ι → Bool} (hx : x ≠ zeroVec) :
                                                                                                                                                                                                                                      0 < orWSupp c x
                                                                                                                                                                                                                                      noncomputable def QuantumQueryComplexity.orWDualVec {ι : Type u_1} [Fintype ι] (c : ι → ℝ) (x : ι → Bool) (p : ι) :

                                                                                                                                                                                                                                      The one-dimensional weighted dual weights for OR_n.

                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                        noncomputable def QuantumQueryComplexity.orWDual {ι : Type u_1} [Fintype ι] {c : ι → ℝ} [Nonempty ι] (hc : ∀ (i : ι), 0 < c i) :

                                                                                                                                                                                                                                        The weighted dual solution for OR_n.

                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                          theorem QuantumQueryComplexity.orWDual_isWeightedCostLe {ι : Type u_1} [Fintype ι] {c : ι → ℝ} [Nonempty ι] (hc : ∀ (i : ι), 0 < c i) :

                                                                                                                                                                                                                                          The weighted OR-composition upper bound #

                                                                                                                                                                                                                                          theorem QuantumQueryComplexity.advDual_composeFunFam_orN_le {ι : Type u_1} [Fintype ι] {β : Type u_2} [Fintype β] [Nonempty ι] {g : ι → (β → Bool) → Bool} {K₂ : Type u_3} [Fintype K₂] {Pg : (i : ι) → DualPair K₂ (g i)} {c : ι → ℝ} (hc : ∀ (i : ι), 0 < c i) (hg : ∀ (i : ι), (Pg i).IsCostLe (c i)) :
                                                                                                                                                                                                                                          advDual (composeFunFam orN g) ≤ √(∑ i : ι, c i * c i)

                                                                                                                                                                                                                                          The weighted OR-composition upper bound, matching the primal bound sqrt_sum_sq_le_advPM_composeFunFam_orN.

                                                                                                                                                                                                                                          Dual composition with shared inputs #

                                                                                                                                                                                                                                          The composition in SourceDualCompose gives each inner function its own block of variables (composeFunFam over α × β). Divide-and-conquer needs the opposite: finitely many subproblems g p, all reading the same input x, whose domains typically overlap. Write

                                                                                                                                                                                                                                          sharedFun h g x = h (fun p => g p x).

                                                                                                                                                                                                                                          Duals compose in this setting too, and the argument is shorter than the disjoint one. Tensoring the outer solution at p with the p-th inner solution,

                                                                                                                                                                                                                                          u x i = ⊕_p U_{g(x)} p ⊗ u^p x i, v y i = ⊕_p V_{g(y)} p ⊗ v^p y i,

                                                                                                                                                                                                                                          the masked sum factors as

                                                                                                                                                                                                                                          ∑_{i : x i ≠ y i} ⟨u x i, v y i⟩ = ∑_p ⟨U_{g x} p, V_{g y} p⟩ · [g p x ≠ g p y],

                                                                                                                                                                                                                                          which is exactly the outer constraint evaluated at the pair (g x, g y). No property of the inner functions' supports is used, so they may overlap freely.

                                                                                                                                                                                                                                          The cost telescopes the same way: the p-th block contributes ‖U_{g x} p‖² times the p-th inner cost, so an outer solution of weighted cost V with weights c and inner solutions of cost c p compose to cost V (DualPair.composeShared_isCostLe). That is the whole quantitative content of "solve subproblem p at cost c p, then optimise over p".

                                                                                                                                                                                                                                          def QuantumQueryComplexity.sharedFun {ι : Type u_1} {σ : Type u_2} {P : Type u_3} {V : Type u_4} {O : Type u_5} (h : (P → V) → O) (g : P → (ι → σ) → V) :
                                                                                                                                                                                                                                          (ι → σ) → O

                                                                                                                                                                                                                                          The composition of an outer function with subproblems that all read the same input.

                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                            @[simp]
                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.sharedFun_apply {ι : Type u_1} {σ : Type u_2} {P : Type u_3} {V : Type u_4} {O : Type u_5} (h : (P → V) → O) (g : P → (ι → σ) → V) (x : ι → σ) :
                                                                                                                                                                                                                                            sharedFun h g x = h fun (p : P) => g p x
                                                                                                                                                                                                                                            noncomputable def QuantumQueryComplexity.DualPair.composeShared {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {P : Type u_3} [Fintype P] {V : Type u_4} [DecidableEq V] {O : Type u_5} [DecidableEq O] {K : Type u_6} {K' : Type u_7} [Fintype K] [Fintype K'] {h : (P → V) → O} {g : P → (ι → σ) → V} (Q : DualPair K h) (R : (p : P) → DualPair K' (g p)) :
                                                                                                                                                                                                                                            DualPair (P × K × K') (sharedFun h g)

                                                                                                                                                                                                                                            Shared-input dual composition.

                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                              @[simp]
                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.DualPair.composeShared_u {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {P : Type u_3} [Fintype P] {V : Type u_4} [DecidableEq V] {O : Type u_5} [DecidableEq O] {K : Type u_6} {K' : Type u_7} [Fintype K] [Fintype K'] {h : (P → V) → O} {g : P → (ι → σ) → V} (Q : DualPair K h) (R : (p : P) → DualPair K' (g p)) (x : ι → σ) (i : ι) (c : P × K × K') :
                                                                                                                                                                                                                                              (Q.composeShared R).u x i c = Q.u (fun (p : P) => g p x) c.1 c.2.1 * (R c.1).u x i c.2.2
                                                                                                                                                                                                                                              @[simp]
                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.DualPair.composeShared_v {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {P : Type u_3} [Fintype P] {V : Type u_4} [DecidableEq V] {O : Type u_5} [DecidableEq O] {K : Type u_6} {K' : Type u_7} [Fintype K] [Fintype K'] {h : (P → V) → O} {g : P → (ι → σ) → V} (Q : DualPair K h) (R : (p : P) → DualPair K' (g p)) (y : ι → σ) (i : ι) (c : P × K × K') :
                                                                                                                                                                                                                                              (Q.composeShared R).v y i c = Q.v (fun (p : P) => g p y) c.1 c.2.1 * (R c.1).v y i c.2.2
                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.DualPair.composeShared_isCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {P : Type u_3} [Fintype P] {V : Type u_4} [DecidableEq V] {O : Type u_5} [DecidableEq O] {K : Type u_6} {K' : Type u_7} [Fintype K] [Fintype K'] {h : (P → V) → O} {g : P → (ι → σ) → V} {c : P → ℝ} {Vout : ℝ} (Q : DualPair K h) (R : (p : P) → DualPair K' (g p)) (hQ : Q.IsWeightedCostLe c Vout) (hR : ∀ (p : P), (R p).IsCostLe (c p)) :

                                                                                                                                                                                                                                              The cost of a shared composition. An outer solution of c-weighted cost V composed with inner solutions of cost c p has cost V.

                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.advPM_sharedFun_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {P : Type u_3} [Fintype P] {V : Type u_4} [DecidableEq V] {O : Type u_5} [DecidableEq O] [Fintype σ] {K : Type u_6} {K' : Type u_7} [Fintype K] [Fintype K'] {h : (P → V) → O} {g : P → (ι → σ) → V} {c : P → ℝ} {Vout : ℝ} (Q : DualPair K h) (R : (p : P) → DualPair K' (g p)) (hV : 0 ≤ Vout) (hQ : Q.IsWeightedCostLe c Vout) (hR : ∀ (p : P), (R p).IsCostLe (c p)) :
                                                                                                                                                                                                                                              advPM (sharedFun h g) ≤ Vout

                                                                                                                                                                                                                                              The adversary bound of a shared composition, from an outer weighted solution and inner solutions.

                                                                                                                                                                                                                                              The first-difference dual: ADV±(f) ≤ 2n for every f #

                                                                                                                                                                                                                                              Order the coordinates arbitrarily. For inputs x ≠ y there is exactly one coordinate at which they first differ, so

                                                                                                                                                                                                                                              ∑_{i : x i ≠ y i} [x agrees with y before i] = 1.

                                                                                                                                                                                                                                              Tensoring that indicator with a cheap factorization of the "different output" matrix, ⟨φ_a, ψ_b⟩ = [a ≠ b], turns it into a feasible dual solution: the count 1 is switched on precisely when f x ≠ f y, and the LMRSS equality constraints hold because the φψ factor already vanishes there. Each input puts mass ‖φ‖² = 2 on each of the n coordinates, so the cost is 2n.

                                                                                                                                                                                                                                              This is the dual attached to the trivial decision tree that reads every coordinate in order. Its point here is that the bound carries no alphabet dependence at all, so it complements upstream Max/Dyadic.lean, whose 2⌈log₂ m⌉√n degrades for very large alphabets.

                                                                                                                                                                                                                                              The same construction applied to an arbitrary decision tree gives ADV±(f) ≤ 2 D(f), and averaging duals (which is legitimate, since the constraint is linear in ⟨u, v⟩) gives ADV±(f) ≤ 2 R₀(f). Neither helps for maximum finding, where every coordinate must be read: D(MAX) = R₀(MAX) = n.

                                                                                                                                                                                                                                              An arbitrary ordering of the coordinates #

                                                                                                                                                                                                                                              noncomputable def QuantumQueryComplexity.idxRank {ι : Type u_1} [Fintype ι] (i : ι) :

                                                                                                                                                                                                                                              An arbitrary injective ranking of the finite index type; it supplies the "reading order" of the trivial decision tree.

                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                noncomputable def QuantumQueryComplexity.prefixOf {ι : Type u_1} [Fintype ι] {σ : Type u_2} (x : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                ι → Option σ

                                                                                                                                                                                                                                                What has been read about x before coordinate i is queried.

                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                  theorem QuantumQueryComplexity.prefixOf_eq_iff {ι : Type u_1} [Fintype ι] {σ : Type u_2} {x y : ι → σ} {i : ι} :
                                                                                                                                                                                                                                                  prefixOf x i = prefixOf y i ↔ ∀ (j : ι), idxRank j < idxRank i → x j = y j

                                                                                                                                                                                                                                                  Exactly one first difference #

                                                                                                                                                                                                                                                  noncomputable def QuantumQueryComplexity.firstDiffSet {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] (x y : ι → σ) :

                                                                                                                                                                                                                                                  The coordinates at which x and y differ for the first time.

                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.card_firstDiffSet {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {x y : ι → σ} (h : x ≠ y) :

                                                                                                                                                                                                                                                    Distinct inputs have exactly one first difference.

                                                                                                                                                                                                                                                    A cheap factorization of the "different output" matrix #

                                                                                                                                                                                                                                                    def QuantumQueryComplexity.phiVec {O : Type u_3} [DecidableEq O] (a : O) :
                                                                                                                                                                                                                                                    Option O → ℝ

                                                                                                                                                                                                                                                    φ a and ψ b pair to 1 exactly when a ≠ b, with squared norms 2.

                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                      def QuantumQueryComplexity.psiVec {O : Type u_3} [DecidableEq O] (b : O) :
                                                                                                                                                                                                                                                      Option O → ℝ

                                                                                                                                                                                                                                                      The partner of phiVec.

                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                        theorem QuantumQueryComplexity.sum_phiVec_mul_psiVec {O : Type u_3} [Fintype O] [DecidableEq O] (a b : O) :
                                                                                                                                                                                                                                                        ∑ t : Option O, phiVec a t * psiVec b t = if a = b then 0 else 1
                                                                                                                                                                                                                                                        theorem QuantumQueryComplexity.sum_phiVec_sq {O : Type u_3} [Fintype O] [DecidableEq O] (a : O) :
                                                                                                                                                                                                                                                        ∑ t : Option O, phiVec a t * phiVec a t = 2
                                                                                                                                                                                                                                                        theorem QuantumQueryComplexity.sum_psiVec_sq {O : Type u_3} [Fintype O] [DecidableEq O] (b : O) :
                                                                                                                                                                                                                                                        ∑ t : Option O, psiVec b t * psiVec b t = 2

                                                                                                                                                                                                                                                        The dual solution #

                                                                                                                                                                                                                                                        noncomputable def QuantumQueryComplexity.firstDiffDual {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] (f : (ι → σ) → O) :
                                                                                                                                                                                                                                                        DualPair ((ι → Option σ) × Option O) f

                                                                                                                                                                                                                                                        The dual solution of the trivial decision tree that reads every coordinate in the order given by idxRank.

                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                          theorem QuantumQueryComplexity.advPM_le_two_mul_card {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} (f : (ι → σ) → O) [Finite O] :
                                                                                                                                                                                                                                                          advPM f ≤ 2 * ↑(Fintype.card ι)

                                                                                                                                                                                                                                                          ADV±(f) ≤ 2n for every function on n variables, with no dependence on the input alphabet or the output type.

                                                                                                                                                                                                                                                          theorem QuantumQueryComplexity.sum_firstDiffDual_u_sq {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] (f : (ι → σ) → O) (x : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                          ∑ c : (ι → Option σ) × Option O, (firstDiffDual f).u x i c * (firstDiffDual f).u x i c = 2

                                                                                                                                                                                                                                                          Each input puts mass exactly ‖φ‖² = 2 on each coordinate.

                                                                                                                                                                                                                                                          theorem QuantumQueryComplexity.sum_firstDiffDual_v_sq {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] (f : (ι → σ) → O) (y : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                          ∑ c : (ι → Option σ) × Option O, (firstDiffDual f).v y i c * (firstDiffDual f).v y i c = 2
                                                                                                                                                                                                                                                          theorem QuantumQueryComplexity.firstDiffDual_isWeightedCostLe {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [Fintype σ] [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] (f : (ι → σ) → O) (c : ι → ℝ) :
                                                                                                                                                                                                                                                          (firstDiffDual f).IsWeightedCostLe c (2 * ∑ i : ι, c i)

                                                                                                                                                                                                                                                          The weighted cost of the first-difference dual: mass 2 on every coordinate, so the c-weighted cost is 2 ∑ c.

                                                                                                                                                                                                                                                          Averaging dual solutions #

                                                                                                                                                                                                                                                          The dual constraint is linear in ⟨u x i, v y i⟩, so a convex combination of solutions for the same function is again a solution: scale the z-th by √(p z) and take an orthogonal direct sum, and the pairing averages copies of the same number [f x ≠ f y].

                                                                                                                                                                                                                                                          What makes this worth doing is the cost. The averaged solution costs

                                                                                                                                                                                                                                                          ∑ z, p z · (cost of the z-th solution at that input)

                                                                                                                                                                                                                                                          per input — an average of costs, not a cost of averages. A family of solutions that is individually bad but good on average is therefore fine, which is exactly the situation for maximum finding: for a fixed scan order an increasing input sets a record at every step, but over a uniformly random order the probability of a record at step t is only 1/t.

                                                                                                                                                                                                                                                          noncomputable def QuantumQueryComplexity.DualPair.average {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] {f : (ι → σ) → O} (P : Z → DualPair K f) (p : Z → ℝ) (hp0 : ∀ (z : Z), 0 ≤ p z) (hp1 : ∑ z : Z, p z = 1) :
                                                                                                                                                                                                                                                          DualPair (Z × K) f

                                                                                                                                                                                                                                                          A convex combination of dual solutions for the same function.

                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.DualPair.sum_average_sq {ι : Type u_1} [Fintype ι] {σ : Type u_2} {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] (p : Z → ℝ) (hp0 : ∀ (z : Z), 0 ≤ p z) (U : Z → (ι → σ) → ι → K → ℝ) (x : ι → σ) :
                                                                                                                                                                                                                                                            ∑ i : ι, ∑ zk : Z × K, √(p zk.1) * U zk.1 x i zk.2 * (√(p zk.1) * U zk.1 x i zk.2) = ∑ z : Z, p z * ∑ i : ι, ∑ k : K, U z x i k * U z x i k
                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.DualPair.average_isCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] {f : (ι → σ) → O} (P : Z → DualPair K f) (p : Z → ℝ) (hp0 : ∀ (z : Z), 0 ≤ p z) (hp1 : ∑ z : Z, p z = 1) {c : ℝ} (hu : ∀ (x : ι → σ), ∑ z : Z, p z * ∑ i : ι, ∑ k : K, (P z).u x i k * (P z).u x i k ≤ c) (hv : ∀ (y : ι → σ), ∑ z : Z, p z * ∑ i : ι, ∑ k : K, (P z).v y i k * (P z).v y i k ≤ c) :
                                                                                                                                                                                                                                                            (average P p hp0 hp1).IsCostLe c

                                                                                                                                                                                                                                                            The averaged cost is the average of the costs, input by input.

                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.DualPair.average_isWeightedCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] {f : (ι → σ) → O} (P : Z → DualPair K f) (p : Z → ℝ) (hp0 : ∀ (z : Z), 0 ≤ p z) (hp1 : ∑ z : Z, p z = 1) {c : ι → ℝ} {V : ℝ} (hu : ∀ (x : ι → σ), ∑ z : Z, p z * ∑ i : ι, c i * ∑ k : K, (P z).u x i k * (P z).u x i k ≤ V) (hv : ∀ (y : ι → σ), ∑ z : Z, p z * ∑ i : ι, c i * ∑ k : K, (P z).v y i k * (P z).v y i k ≤ V) :
                                                                                                                                                                                                                                                            (average P p hp0 hp1).IsWeightedCostLe c V

                                                                                                                                                                                                                                                            The averaged weighted cost is the average of the weighted costs.

                                                                                                                                                                                                                                                            noncomputable def QuantumQueryComplexity.DualPair.averageUnif {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] {f : (ι → σ) → O} [Nonempty Z] (P : Z → DualPair K f) :
                                                                                                                                                                                                                                                            DualPair (Z × K) f

                                                                                                                                                                                                                                                            The uniform average over a nonempty finite family.

                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.DualPair.sum_averageUnif_u_sq {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] {f : (ι → σ) → O} [Nonempty Z] (P : Z → DualPair K f) (x : ι → σ) :
                                                                                                                                                                                                                                                              ∑ i : ι, ∑ zk : Z × K, (averageUnif P).u x i zk * (averageUnif P).u x i zk = (↑(Fintype.card Z))⁻¹ * ∑ z : Z, ∑ i : ι, ∑ k : K, (P z).u x i k * (P z).u x i k

                                                                                                                                                                                                                                                              The averaged ℓ² mass at a single input. Exposing this, rather than only the cost bound it implies, is what lets a dual solution be restricted to a promise domain: its cost there is the maximum of these over the promise only.

                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.DualPair.sum_averageUnif_v_sq {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] {f : (ι → σ) → O} [Nonempty Z] (P : Z → DualPair K f) (y : ι → σ) :
                                                                                                                                                                                                                                                              ∑ i : ι, ∑ zk : Z × K, (averageUnif P).v y i zk * (averageUnif P).v y i zk = (↑(Fintype.card Z))⁻¹ * ∑ z : Z, ∑ i : ι, ∑ k : K, (P z).v y i k * (P z).v y i k
                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.DualPair.averageUnif_isWeightedCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] {f : (ι → σ) → O} [Nonempty Z] (P : Z → DualPair K f) {c : ι → ℝ} {V : ℝ} (hu : ∀ (x : ι → σ), (↑(Fintype.card Z))⁻¹ * ∑ z : Z, ∑ i : ι, c i * ∑ k : K, (P z).u x i k * (P z).u x i k ≤ V) (hv : ∀ (y : ι → σ), (↑(Fintype.card Z))⁻¹ * ∑ z : Z, ∑ i : ι, c i * ∑ k : K, (P z).v y i k * (P z).v y i k ≤ V) :
                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.DualPair.averageUnif_isCostLe {ι : Type u_1} [Fintype ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [DecidableEq O] {Z : Type u_4} {K : Type u_5} [Fintype Z] [Fintype K] {f : (ι → σ) → O} [Nonempty Z] (P : Z → DualPair K f) {c : ℝ} (hu : ∀ (x : ι → σ), (↑(Fintype.card Z))⁻¹ * ∑ z : Z, ∑ i : ι, ∑ k : K, (P z).u x i k * (P z).u x i k ≤ c) (hv : ∀ (y : ι → σ), (↑(Fintype.card Z))⁻¹ * ∑ z : Z, ∑ i : ι, ∑ k : K, (P z).v y i k * (P z).v y i k ≤ c) :

                                                                                                                                                                                                                                                              Weighted scans: the decision-tree dual with black/red weights #

                                                                                                                                                                                                                                                              A scan orders the coordinates and records, for each input and coordinate, the branch taken there and its colour. This is the algebraic core of Beigi–Taghavi's generalized-decision-tree dual, with weights assigned to nodes.

                                                                                                                                                                                                                                                              The point of the reformulation used here is that a scan is SourceFirstDiff applied to the branch sequence instead of the raw input. A tree node is exactly a branch-prefix, so "two paths agree until their first different branch" is literally card_firstDiffSet, and no tree datatype is needed. Three conditions make the argument go through:

                                                                                                                                                                                                                                                              The colours are what the ordinary first-difference dual lacks. u pays 1 / W at the branch it takes, while v pays ∑ W over the other colours; choosing W per coordinate then trades the two costs off against each other. With constant weights this collapses back to ADV±(f) ≤ 2 D(f); with depth-dependent weights it is what removes the alphabet dependence from maximum finding.

                                                                                                                                                                                                                                                              structure QuantumQueryComplexity.Scan (ι : Type u_5) (σ : Type u_6) (O : Type u_7) (Q : Type u_8) [Fintype ι] :
                                                                                                                                                                                                                                                              Type (max (max (max u_5 u_6) u_7) u_8)

                                                                                                                                                                                                                                                              A scan of the coordinates: an order, and for each input the branch taken at each coordinate together with its colour.

                                                                                                                                                                                                                                                              • rank : ι → Fin (Fintype.card ι)

                                                                                                                                                                                                                                                                The order in which coordinates are scanned.

                                                                                                                                                                                                                                                              • rank_inj : Function.Injective self.rank

                                                                                                                                                                                                                                                                The order is a genuine ordering.

                                                                                                                                                                                                                                                              • br : (ι → σ) → ι → Q

                                                                                                                                                                                                                                                                The branch taken at each coordinate.

                                                                                                                                                                                                                                                              • col : (ι → σ) → ι → Bool

                                                                                                                                                                                                                                                                Its colour: false is black, true is red.

                                                                                                                                                                                                                                                              • out : (ι → σ) → O

                                                                                                                                                                                                                                                                The value computed.

                                                                                                                                                                                                                                                              • br_ne (x y : ι → σ) (i : ι) : (∀ (j : ι), self.rank j < self.rank i → self.br x j = self.br y j) → self.br x i ≠ self.br y i → x i ≠ y i

                                                                                                                                                                                                                                                                At the same node, a differing branch forces a differing symbol: the branches at a node partition the alphabet, so the branch is determined by the symbol read.

                                                                                                                                                                                                                                                              • out_eq (x y : ι → σ) : (∀ (i : ι), self.br x i = self.br y i) → self.out x = self.out y

                                                                                                                                                                                                                                                                Equal branch sequences force equal outputs.

                                                                                                                                                                                                                                                              • black_unique (x y : ι → σ) (i : ι) : self.col x i = false → self.col y i = false → (∀ (j : ι), self.rank j < self.rank i → self.br x j = self.br y j) → self.br x i = self.br y i

                                                                                                                                                                                                                                                                At most one branch at each node is black.

                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                def QuantumQueryComplexity.Scan.node {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} (S : Scan ι σ O Q) (x : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                                ι → Option Q

                                                                                                                                                                                                                                                                The node reached before scanning i: the branches taken so far.

                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                  theorem QuantumQueryComplexity.Scan.node_eq_iff {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} (S : Scan ι σ O Q) {x y : ι → σ} {i : ι} :
                                                                                                                                                                                                                                                                  S.node x i = S.node y i ↔ ∀ (j : ι), S.rank j < S.rank i → S.br x j = S.br y j

                                                                                                                                                                                                                                                                  Exactly one first divergence #

                                                                                                                                                                                                                                                                  noncomputable def QuantumQueryComplexity.Scan.divSet {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} [DecidableEq Q] (S : Scan ι σ O Q) (x y : ι → σ) :

                                                                                                                                                                                                                                                                  The coordinate at which two branch sequences first differ.

                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.Scan.card_divSet {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} [DecidableEq Q] (S : Scan ι σ O Q) {x y : ι → σ} (h : S.br x ≠ S.br y) :
                                                                                                                                                                                                                                                                    (S.divSet x y).card = 1
                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.Scan.card_divSet_of_out_ne {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} [DecidableEq Q] (S : Scan ι σ O Q) {x y : ι → σ} (h : S.out x ≠ S.out y) :
                                                                                                                                                                                                                                                                    (S.divSet x y).card = 1

                                                                                                                                                                                                                                                                    The dual solution attached to a weighted scan #

                                                                                                                                                                                                                                                                    u sits at the branch it takes, weighted 1/√W; v spreads over the other colours, weighted √W. At the first differing branch the two square roots cancel — this is where black_unique is used, since it rules out both sides taking a black branch at the same node, which would leave no common colour.

                                                                                                                                                                                                                                                                    The resulting costs are

                                                                                                                                                                                                                                                                    ∑ i, ‖u x i‖² ≤ 4 ∑ i, 1 / W i (col x i), ∑ i, ‖v y i‖² ≤ 4 ∑ i, (W i true + if col y i then W i false else 0),

                                                                                                                                                                                                                                                                    so the weights trade one side against the other. Constant weights give the first-difference dual back; the maximum scan will make them depend on depth.

                                                                                                                                                                                                                                                                    @[reducible, inline]
                                                                                                                                                                                                                                                                    abbrev QuantumQueryComplexity.ScanDim (ι : Type u_5) (O : Type u_6) (Q : Type u_7) :
                                                                                                                                                                                                                                                                    Type (max (max u_5 u_7) u_6 u_7)

                                                                                                                                                                                                                                                                    The dimension type: node, colour, branch gadget, output gadget.

                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                      def QuantumQueryComplexity.Scan.ndVec {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} [DecidableEq Q] (S : Scan ι σ O Q) (x : ι → σ) (i : ι) (p : ι → Option Q) :

                                                                                                                                                                                                                                                                      The node component of u and of v.

                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                        noncomputable def QuantumQueryComplexity.Scan.colU {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (x : ι → σ) (i : ι) (c : Bool) :

                                                                                                                                                                                                                                                                        The colour component of u: mass at the colour actually taken.

                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                          noncomputable def QuantumQueryComplexity.Scan.colV {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (y : ι → σ) (i : ι) (c : Bool) :

                                                                                                                                                                                                                                                                          The colour component of v: mass on every other colour.

                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.Scan.sum_ndVec {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (x y : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                                            ∑ p : ι → Option Q, S.ndVec x i p * S.ndVec y i p = if S.node x i = S.node y i then 1 else 0
                                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.Scan.sum_col {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) (x y : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                                            ∑ c : Bool, S.colU W x i c * S.colV W y i c = if (S.col y i || S.col x i) = true then 1 else 0
                                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.Scan.sum_ndVec_sq {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (x : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                                            ∑ p : ι → Option Q, S.ndVec x i p * S.ndVec x i p = 1
                                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.Scan.sum_colU_sq {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) (x : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                                            ∑ c : Bool, S.colU W x i c * S.colU W x i c = (W i (S.col x i))⁻¹
                                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.Scan.sum_colV_sq {ι : Type u_1} [Fintype ι] {σ : Type u_2} {O : Type u_3} {Q : Type u_4} (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) (y : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                                            ∑ c : Bool, S.colV W y i c * S.colV W y i c = W i true + if S.col y i = true then W i false else 0

                                                                                                                                                                                                                                                                            The dual solution #

                                                                                                                                                                                                                                                                            noncomputable def QuantumQueryComplexity.Scan.dual {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) :
                                                                                                                                                                                                                                                                            DualPair (ScanDim ι O Q) S.out

                                                                                                                                                                                                                                                                            The dual solution attached to a weighted scan.

                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.Scan.sum_dual_u_sq_coord {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) (x : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                                              ∑ k : ScanDim ι O Q, (S.dual W hW).u x i k * (S.dual W hW).u x i k = 4 * (W i (S.col x i))⁻¹

                                                                                                                                                                                                                                                                              The exact ℓ² mass of u at one coordinate: the reciprocal weight of the branch taken there.

                                                                                                                                                                                                                                                                              Stated per coordinate, not just summed, because a weighted cost inserts a different factor at each one.

                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.Scan.sum_dual_u_sq {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) (x : ι → σ) :
                                                                                                                                                                                                                                                                              ∑ i : ι, ∑ k : ScanDim ι O Q, (S.dual W hW).u x i k * (S.dual W hW).u x i k = 4 * ∑ i : ι, (W i (S.col x i))⁻¹

                                                                                                                                                                                                                                                                              The exact ℓ² mass of u at an input: the reciprocal weights of the branches taken.

                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.Scan.sum_dual_v_sq_coord {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) (y : ι → σ) (i : ι) :
                                                                                                                                                                                                                                                                              ∑ k : ScanDim ι O Q, (S.dual W hW).v y i k * (S.dual W hW).v y i k = 4 * (W i true + if S.col y i = true then W i false else 0)

                                                                                                                                                                                                                                                                              The exact ℓ² mass of v at one coordinate: the weights of the other colours.

                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.Scan.sum_dual_v_sq {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) (y : ι → σ) :
                                                                                                                                                                                                                                                                              ∑ i : ι, ∑ k : ScanDim ι O Q, (S.dual W hW).v y i k * (S.dual W hW).v y i k = 4 * ∑ i : ι, (W i true + if S.col y i = true then W i false else 0)

                                                                                                                                                                                                                                                                              The exact ℓ² mass of v at an input: the weights of the other colours.

                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.Scan.dual_isWeightedCostLe {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) {c : ι → ℝ} {V : ℝ} (hu : ∀ (x : ι → σ), 4 * ∑ i : ι, c i * (W i (S.col x i))⁻¹ ≤ V) (hv : ∀ (y : ι → σ), 4 * ∑ i : ι, c i * (W i true + if S.col y i = true then W i false else 0) ≤ V) :
                                                                                                                                                                                                                                                                              (S.dual W hW).IsWeightedCostLe c V

                                                                                                                                                                                                                                                                              The weighted cost of the scan dual. Each coordinate contributes its own factor c i, which is what a composition with subproblems of differing costs consumes.

                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.Scan.dual_isCostLe {ι : Type u_1} [Fintype ι] [DecidableEq ι] {σ : Type u_2} [DecidableEq σ] {O : Type u_3} [Fintype O] [DecidableEq O] {Q : Type u_4} [Fintype Q] [DecidableEq Q] (S : Scan ι σ O Q) (W : ι → Bool → ℝ) (hW : ∀ (i : ι) (c : Bool), 0 < W i c) {c : ℝ} (hu : ∀ (x : ι → σ), 4 * ∑ i : ι, (W i (S.col x i))⁻¹ ≤ c) (hv : ∀ (y : ι → σ), 4 * ∑ i : ι, (W i true + if S.col y i = true then W i false else 0) ≤ c) :
                                                                                                                                                                                                                                                                              (S.dual W hW).IsCostLe c

                                                                                                                                                                                                                                                                              The cost of the scan dual: u pays the reciprocal weight of the branch it takes, v pays the weights of the other colours.

                                                                                                                                                                                                                                                                              The maximum scan #

                                                                                                                                                                                                                                                                              Scan the coordinates in a fixed order, keeping the largest value seen. At each step the branch is black when the new value does not beat the running maximum, and is the red singleton {x i} when it does.

                                                                                                                                                                                                                                                                              The branch label is taken to be the running maximum after scanning i, runAfter. This is what makes the three Scan conditions nearly free, and it avoids induction entirely:

                                                                                                                                                                                                                                                                              A branch is red exactly when the step is a strict record. That is the event whose probability, over a uniformly random scan order, is at most 1/t — the estimate that will make the weighted cost O(√n).

                                                                                                                                                                                                                                                                              @[instance_reducible]

                                                                                                                                                                                                                                                                              WithBot α is definitionally Option α; mathlib carries no Fintype instance for it, and the scan needs one because the branch labels are running maxima.

                                                                                                                                                                                                                                                                              Equations

                                                                                                                                                                                                                                                                              The running join #

                                                                                                                                                                                                                                                                              Nothing about the running value of a scan needs a linear order: it is a supremum, so a SemilatticeSup suffices. Keeping this section general is what lets upstream Scan/Join.lean reuse it for products in a commutative idempotent semigroup, where two values may be incomparable.

                                                                                                                                                                                                                                                                              def QuantumQueryComplexity.beforeSet {ι : Type u_1} [Fintype ι] (rk : ι → Fin (Fintype.card ι)) (i : ι) :

                                                                                                                                                                                                                                                                              The coordinates scanned strictly before i.

                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                def QuantumQueryComplexity.runBefore {ι : Type u_1} [Fintype ι] {A : Type u_2} [SemilatticeSup A] (rk : ι → Fin (Fintype.card ι)) (x : ι → A) (i : ι) :

                                                                                                                                                                                                                                                                                The running maximum strictly before i (⊥ if nothing has been scanned).

                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                  def QuantumQueryComplexity.runAfter {ι : Type u_1} [Fintype ι] {A : Type u_2} [SemilatticeSup A] (rk : ι → Fin (Fintype.card ι)) (x : ι → A) (i : ι) :

                                                                                                                                                                                                                                                                                  The running maximum up to and including i.

                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.le_runBefore {ι : Type u_1} [Fintype ι] {A : Type u_2} [SemilatticeSup A] {rk : ι → Fin (Fintype.card ι)} {x : ι → A} {i j : ι} (h : rk j < rk i) :
                                                                                                                                                                                                                                                                                    ↑(x j) ≤ runBefore rk x i
                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.runBefore_le {ι : Type u_1} [Fintype ι] {A : Type u_2} [SemilatticeSup A] {rk : ι → Fin (Fintype.card ι)} {x : ι → A} {i : ι} {b : WithBot A} (h : ∀ (j : ι), rk j < rk i → ↑(x j) ≤ b) :
                                                                                                                                                                                                                                                                                    runBefore rk x i ≤ b
                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.le_runAfter {ι : Type u_1} [Fintype ι] {A : Type u_2} [SemilatticeSup A] (rk : ι → Fin (Fintype.card ι)) (x : ι → A) (i : ι) :
                                                                                                                                                                                                                                                                                    ↑(x i) ≤ runAfter rk x i
                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.runBefore_eq_sup_runAfter {ι : Type u_1} [Fintype ι] {A : Type u_2} [SemilatticeSup A] (rk : ι → Fin (Fintype.card ι)) (x : ι → A) (i : ι) :
                                                                                                                                                                                                                                                                                    runBefore rk x i = (beforeSet rk i).sup fun (j : ι) => runAfter rk x j

                                                                                                                                                                                                                                                                                    The running maximum before i is the sup of the branch labels before i. This is what replaces an induction on the scan order.

                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.runBefore_congr {ι : Type u_1} [Fintype ι] {A : Type u_2} [SemilatticeSup A] {rk : ι → Fin (Fintype.card ι)} {x y : ι → A} {i : ι} (h : ∀ (j : ι), rk j < rk i → runAfter rk x j = runAfter rk y j) :
                                                                                                                                                                                                                                                                                    runBefore rk x i = runBefore rk y i

                                                                                                                                                                                                                                                                                    Equal branch prefixes give equal running maxima.

                                                                                                                                                                                                                                                                                    The maximum scan #

                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.maxFun_eq_sup_runAfter {ι : Type u_1} [Fintype ι] [Nonempty ι] {A : Type u_2} [LinearOrder A] (rk : ι → Fin (Fintype.card ι)) (x : ι → A) :
                                                                                                                                                                                                                                                                                    ↑(maxFun x) = Finset.univ.sup fun (i : ι) => runAfter rk x i

                                                                                                                                                                                                                                                                                    maxFun is the sup of the branch labels.

                                                                                                                                                                                                                                                                                    The scan #

                                                                                                                                                                                                                                                                                    def QuantumQueryComplexity.isRecord {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] (rk : ι → Fin (Fintype.card ι)) (x : ι → A) (i : ι) :

                                                                                                                                                                                                                                                                                    Whether scanning i sets a strict record.

                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.runAfter_eq_of_not_record {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] {rk : ι → Fin (Fintype.card ι)} {x : ι → A} {i : ι} (h : isRecord rk x i = false) :
                                                                                                                                                                                                                                                                                      runAfter rk x i = runBefore rk x i
                                                                                                                                                                                                                                                                                      noncomputable def QuantumQueryComplexity.maxScanMap {ι : Type u_1} [Fintype ι] [Nonempty ι] {A : Type u_2} {σ : Type u_3} [LinearOrder A] (m : σ → A) (rk : ι → Fin (Fintype.card ι)) (hrk : Function.Injective rk) :
                                                                                                                                                                                                                                                                                      Scan ι σ A (WithBot A)

                                                                                                                                                                                                                                                                                      The maximum scan, for a given order of the coordinates and a given value map m : σ → A.

                                                                                                                                                                                                                                                                                      The letters read by the queries need not be the values being maximised: a query returns a whole letter x i : σ, and the quantity of interest is the largest m (x i). This costs the construction nothing, because the three Scan conditions only ever go in the direction "differing branch ⟹ differing letter", and m (x i) ≠ m (y i) certainly forces x i ≠ y i. A non-injective m is therefore fine — which matters, since the entries of distinct letter matrices routinely coincide.

                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                        noncomputable def QuantumQueryComplexity.maxScan {ι : Type u_1} [Fintype ι] [Nonempty ι] {A : Type u_2} [LinearOrder A] (rk : ι → Fin (Fintype.card ι)) (hrk : Function.Injective rk) :
                                                                                                                                                                                                                                                                                        Scan ι A A (WithBot A)

                                                                                                                                                                                                                                                                                        The maximum scan of the input itself: the value map is the identity.

                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                          The record lemma #

                                                                                                                                                                                                                                                                                          Over a uniformly random scan order, the probability that step t sets a strict record is at most 1 / (t + 1).

                                                                                                                                                                                                                                                                                          No bijection onto a quotient is needed. For each position s ≤ t let domSet x t s be the orders whose position-s coordinate strictly dominates all the others at positions ≤ t. Then

                                                                                                                                                                                                                                                                                          So (t + 1) disjoint sets of equal size fit inside all the orders, giving (t + 1) * |record event| ≤ n!. Ties are handled for free: if the maximum over the first t + 1 positions is attained twice, no order is counted, which only helps.

                                                                                                                                                                                                                                                                                          This is the one place where randomising the scan order earns its keep. For a fixed order an increasing input sets a record at every step.

                                                                                                                                                                                                                                                                                          @[reducible, inline]
                                                                                                                                                                                                                                                                                          abbrev QuantumQueryComplexity.Order (ι : Type u_3) [Fintype ι] :
                                                                                                                                                                                                                                                                                          Type u_3

                                                                                                                                                                                                                                                                                          A scan order: a bijection of the coordinates onto positions.

                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                            def QuantumQueryComplexity.domSet {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] (x : ι → A) (t s : Fin (Fintype.card ι)) :

                                                                                                                                                                                                                                                                                            The orders whose position-s coordinate strictly dominates every other coordinate at a position ≤ t.

                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.mem_domSet {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] {x : ι → A} {t s : Fin (Fintype.card ι)} {e : Order ι} :
                                                                                                                                                                                                                                                                                              e ∈ domSet x t s ↔ ∀ s' ≤ t, s' ≠ s → x ((Equiv.symm e) s') < x ((Equiv.symm e) s)
                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.domSet_disjoint {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] (x : ι → A) (t : Fin (Fintype.card ι)) {s₁ s₂ : Fin (Fintype.card ι)} (hne : s₁ ≠ s₂) (h1 : s₁ ≤ t) (h2 : s₂ ≤ t) :
                                                                                                                                                                                                                                                                                              Disjoint (domSet x t s₁) (domSet x t s₂)

                                                                                                                                                                                                                                                                                              A strict dominator is unique, so the sets are pairwise disjoint.

                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.card_domSet_eq {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] (x : ι → A) {t s : Fin (Fintype.card ι)} (hs : s ≤ t) :
                                                                                                                                                                                                                                                                                              (domSet x t s).card = (domSet x t t).card

                                                                                                                                                                                                                                                                                              Swapping positions s and t matches the two dominance events.

                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.card_domSet_mul_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] (x : ι → A) (t : Fin (Fintype.card ι)) :
                                                                                                                                                                                                                                                                                              (↑t + 1) * (domSet x t t).card ≤ Fintype.card (Order ι)

                                                                                                                                                                                                                                                                                              The record bound in counting form.

                                                                                                                                                                                                                                                                                              Identifying the record event #

                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.isRecord_eq_true_iff {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] (x : ι → A) (e : Order ι) (i : ι) :
                                                                                                                                                                                                                                                                                              isRecord (⇑e) x i = true ↔ ∀ (j : ι), e j < e i → x j < x i
                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.isRecord_iff_mem_domSet {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] (x : ι → A) (e : Order ι) (t : Fin (Fintype.card ι)) :
                                                                                                                                                                                                                                                                                              isRecord (⇑e) x ((Equiv.symm e) t) = true ↔ e ∈ domSet x t t

                                                                                                                                                                                                                                                                                              The record event is exactly the top dominance set.

                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.card_record_mul_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] (x : ι → A) (t : Fin (Fintype.card ι)) :
                                                                                                                                                                                                                                                                                              (↑t + 1) * {e : Order ι | isRecord (⇑e) x ((Equiv.symm e) t) = true}.card ≤ Fintype.card (Order ι)

                                                                                                                                                                                                                                                                                              The record lemma. At most a 1/(t+1) fraction of scan orders make step t a strict record.

                                                                                                                                                                                                                                                                                              ADV±(MAX) = O(√n), with no alphabet dependence #

                                                                                                                                                                                                                                                                                              Give the coordinate scanned at time t the weights

                                                                                                                                                                                                                                                                                              W(t, black) = √(t+1), W(t, red) = 1/√(t+1),

                                                                                                                                                                                                                                                                                              and average the resulting scan duals over all scan orders. A red branch is a strict record, which by the record lemma happens for at most a 1/(t+1) fraction of orders, so at each time the two contributions balance:

                                                                                                                                                                                                                                                                                              √(t+1) · (fraction of records) + 1/√(t+1) ≤ 2/√(t+1),

                                                                                                                                                                                                                                                                                              and ∑_{t<n} 1/√(t+1) ≤ 2√n. Both squared masses are therefore O(√n).

                                                                                                                                                                                                                                                                                              The bound is independent of the alphabet. This is what the threshold/staircase route could not achieve: there the pairing constraints force a γ₂ factorization of the greater-than matrix, costing Θ(log m). The scan never compares two alphabet symbols through an inner product — the comparison happens inside the branch structure, and the dual only ever tests branch labels for equality.

                                                                                                                                                                                                                                                                                              The elementary sum #

                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.sum_inv_sqrt_le (n : ℕ) :
                                                                                                                                                                                                                                                                                              ∑ t ∈ Finset.range n, (√(↑t + 1))⁻¹ ≤ 2 * √↑n

                                                                                                                                                                                                                                                                                              ∑_{t < n} 1/√(t+1) ≤ 2√n, by telescoping.

                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.sum_inv_sqrt_fin_le (n : ℕ) :
                                                                                                                                                                                                                                                                                              ∑ t : Fin n, (√(↑↑t + 1))⁻¹ ≤ 2 * √↑n

                                                                                                                                                                                                                                                                                              The weights #

                                                                                                                                                                                                                                                                                              noncomputable def QuantumQueryComplexity.scanWeight {ι : Type u_1} [Fintype ι] (e : Order ι) (i : ι) (c : Bool) :

                                                                                                                                                                                                                                                                                              Depth-dependent weights: black is √(t+1), red is 1/√(t+1).

                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.scanWeight_pos {ι : Type u_1} [Fintype ι] (e : Order ι) (i : ι) (c : Bool) :
                                                                                                                                                                                                                                                                                                0 < scanWeight e i c
                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.scanWeight_inv {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] (e : Order ι) (x : ι → A) (i : ι) :
                                                                                                                                                                                                                                                                                                (scanWeight e i (isRecord (⇑e) x i))⁻¹ = if isRecord (⇑e) x i = true then √(↑↑(e i) + 1) else (√(↑↑(e i) + 1))⁻¹

                                                                                                                                                                                                                                                                                                The u-side weight at a coordinate: √(t+1) on a record, 1/√(t+1) otherwise.

                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.scanWeight_v {ι : Type u_1} [Fintype ι] {A : Type u_2} [LinearOrder A] (e : Order ι) (x : ι → A) (i : ι) :
                                                                                                                                                                                                                                                                                                (scanWeight e i true + if isRecord (⇑e) x i = true then scanWeight e i false else 0) = (√(↑↑(e i) + 1))⁻¹ + if isRecord (⇑e) x i = true then √(↑↑(e i) + 1) else 0

                                                                                                                                                                                                                                                                                                The v-side weight at a coordinate.

                                                                                                                                                                                                                                                                                                Summing over the scan order #

                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.sum_over_times {ι : Type u_1} [Fintype ι] (e : Order ι) (F : Fin (Fintype.card ι) → ℝ) :
                                                                                                                                                                                                                                                                                                ∑ i : ι, F (e i) = ∑ t : Fin (Fintype.card ι), F t

                                                                                                                                                                                                                                                                                                Reindexing a sum over coordinates as a sum over times.

                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.sum_orders_u_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] (x : ι → A) (t : Fin (Fintype.card ι)) :
                                                                                                                                                                                                                                                                                                (∑ e : Order ι, if isRecord (⇑e) x ((Equiv.symm e) t) = true then √(↑↑t + 1) else (√(↑↑t + 1))⁻¹) ≤ ↑(Fintype.card (Order ι)) * (2 * (√(↑↑t + 1))⁻¹)

                                                                                                                                                                                                                                                                                                The key per-time estimate. Summed over all scan orders, the u-side cost at time t is at most 2 / √(t+1) times the number of orders.

                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.sum_orders_v_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Type u_2} [LinearOrder A] (x : ι → A) (t : Fin (Fintype.card ι)) :
                                                                                                                                                                                                                                                                                                ∑ e : Order ι, ((√(↑↑t + 1))⁻¹ + if isRecord (⇑e) x ((Equiv.symm e) t) = true then √(↑↑t + 1) else 0) ≤ ↑(Fintype.card (Order ι)) * (3 * (√(↑↑t + 1))⁻¹)

                                                                                                                                                                                                                                                                                                The v-side analogue: at most 3 / √(t+1) per order.

                                                                                                                                                                                                                                                                                                The theorem #

                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.exists_maxMap_dual_isCostLe {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {A : Type u_2} [Fintype A] [DecidableEq A] [LinearOrder A] {σ : Type u_3} [DecidableEq σ] (m : σ → A) :
                                                                                                                                                                                                                                                                                                ∃ (P : DualPair (Order ι × ScanDim ι A (WithBot A)) fun (x : ι → σ) => maxFun fun (j : ι) => m (x j)), P.IsCostLe (24 * √↑(Fintype.card ι))

                                                                                                                                                                                                                                                                                                ADV±(MAX) ≤ 24 √n, with no dependence on the alphabet, for the maximum of a value map applied to the letters.

                                                                                                                                                                                                                                                                                                Averaging the depth-weighted scan duals over all scan orders. A red branch is a strict record, which happens for at most a 1/(t+1) fraction of orders, so the two colour contributions balance at every time and the total is governed by ∑_t 1/√(t+1) ≤ 2√n.

                                                                                                                                                                                                                                                                                                Nothing about the bound sees m: neither its injectivity nor the size of the alphabet σ of letters plays any role.

                                                                                                                                                                                                                                                                                                The maximum of the input itself: the value map is the identity.

                                                                                                                                                                                                                                                                                                ADV±(MAX) ≤ 24 √n, with no dependence on the alphabet.

                                                                                                                                                                                                                                                                                                Bundled dual solutions #

                                                                                                                                                                                                                                                                                                A divide-and-conquer construction builds one dual solution out of many, and the dimension types of the pieces are all different: a maximum over a block of q positions carries Order and ScanDim types built from that block, a first-difference combination carries prefix and output gadgets, and a recursive call carries whatever its own subtree produced. Threading those types through a recursion requires a Sigma type and DualPair.embedDim to combine the different finite dimensions.

                                                                                                                                                                                                                                                                                                So we hide the dimension:

                                                                                                                                                                                                                                                                                                HasDual f c — some feasible dual solution for f has cost at most c; HasWeightedDual f c V — some solution has c-weighted cost at most V.

                                                                                                                                                                                                                                                                                                Every construction of SourcePullback, SourceFirstDiff, and SourceComposeShared is restated at this level, and the Sigma-plus-embedDim step happens exactly once, inside HasWeightedDual.composeShared. What is left are two combinators that say what divide-and-conquer actually does:

                                                                                                                                                                                                                                                                                                Dimension types are pinned to Type; every construction in this development produces one (Fin, Order, ScanDim, products, sums and sigmas of these).

                                                                                                                                                                                                                                                                                                The two predicates #

                                                                                                                                                                                                                                                                                                def QuantumQueryComplexity.HasDual {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] (f : (ι → σ) → O) (c : ℝ) :

                                                                                                                                                                                                                                                                                                f has a feasible dual solution of cost at most c.

                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                  def QuantumQueryComplexity.HasWeightedDual {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] (f : (ι → σ) → O) (c : ι → ℝ) (V : ℝ) :

                                                                                                                                                                                                                                                                                                  f has a feasible dual solution of c-weighted cost at most V.

                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasDual_of_dualPair {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {c : ℝ} {K : Type} [Fintype K] (P : DualPair K f) (h : P.IsCostLe c) :
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasWeightedDual_of_dualPair {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {K : Type} [Fintype K] {w : ι → ℝ} {V : ℝ} (P : DualPair K f) (h : P.IsWeightedCostLe w V) :
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.mono {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {c d : ℝ} (h : HasDual f c) (hcd : c ≤ d) :
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasWeightedDual.mono {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {w : ι → ℝ} {V V' : ℝ} (h : HasWeightedDual f w V) (hV : V ≤ V') :
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.nonneg {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {c : ℝ} [Nonempty σ] (h : HasDual f c) :
                                                                                                                                                                                                                                                                                                    0 ≤ c
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.advPM_le_of_hasDual {ι : Type} [Fintype ι] [DecidableEq ι] {σ : Type} [Fintype σ] [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {c : ℝ} (hc : 0 ≤ c) (h : HasDual f c) :

                                                                                                                                                                                                                                                                                                    Weak duality, bundled.

                                                                                                                                                                                                                                                                                                    Constant weights #

                                                                                                                                                                                                                                                                                                    The one quantitative fact linking the two predicates: an ordinary bound V is a constant-weight bound c₀ V. This is what lets a family of equally expensive subproblems be fed to an outer solution whose cost was measured without weights.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.DualPair.isWeightedCostLe_const {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {K : Type} [Fintype K] {P : DualPair K f} {V c₀ : ℝ} (hc₀ : 0 ≤ c₀) (h : P.IsCostLe V) :
                                                                                                                                                                                                                                                                                                    P.IsWeightedCostLe (fun (x : ι) => c₀) (c₀ * V)
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.weighted_const {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {c c₀ : ℝ} (hc₀ : 0 ≤ c₀) (h : HasDual f c) :
                                                                                                                                                                                                                                                                                                    HasWeightedDual f (fun (x : ι) => c₀) (c₀ * c)
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.DualPair.isCostLe_of_isWeightedCostLe_one {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {K : Type} [Fintype K] {P : DualPair K f} {V : ℝ} (h : P.IsWeightedCostLe (fun (x : ι) => 1) V) :

                                                                                                                                                                                                                                                                                                    Transport #

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.ofEq {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f g : (ι → σ) → O} {c : ℝ} (hfg : ∀ (x : ι → σ), f x = g x) (h : HasDual f c) :
                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.ofKer {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {c : ℝ} {O' : Type} [DecidableEq O'] {f' : (ι → σ) → O'} (hker : ∀ (x y : ι → σ), f x = f y ↔ f' x = f' y) (h : HasDual f c) :
                                                                                                                                                                                                                                                                                                    HasDual f' c

                                                                                                                                                                                                                                                                                                    A dual solution only sees which inputs share an output value.

                                                                                                                                                                                                                                                                                                    The feasibility constraint reads = if f x = f y then 0 else 1, so nothing but the partition of inputs into level sets enters. Two functions inducing the same partition therefore have the same dual solutions, at the same cost — even when their output types are different. This is what makes it harmless to recode an output into a finite type.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.pullback {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {c : ℝ} {κ : Type} [Fintype κ] {e : κ → ι} (he : Function.Injective e) {f : (κ → σ) → O} (h : HasDual f c) :

                                                                                                                                                                                                                                                                                                    A dual solution restricted to a block of coordinates: injectivity of the inclusion is what keeps the cost unchanged.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.restrict {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {c : ℝ} {κ σ' : Type} [Fintype κ] [DecidableEq σ'] {e : ι → κ} (he : Function.Injective e) {Φ : (ι → σ) → κ → σ'} (hin : ∀ (x y : ι → σ) (i : ι), Φ x (e i) = Φ y (e i) ↔ x i = y i) (hout : ∀ (x y : ι → σ) (j : κ), (∀ (i : ι), e i ≠ j) → Φ x j = Φ y j) {F : (κ → σ') → O} (h : HasDual F c) :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => F (Φ x)) c

                                                                                                                                                                                                                                                                                                    A dual solution restricted along a padding. A function of n letters is a function of N ≥ n letters whose last N - n are frozen at known values, and freezing costs nothing.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.alphaMap {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {c : ℝ} {σ' : Type} [DecidableEq σ'] {m : σ → σ'} (hm : Function.Injective m) {f : (ι → σ') → O} (h : HasDual f c) :

                                                                                                                                                                                                                                                                                                    Recoding the input alphabet along an injection.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasDual_const {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} (hf : ∀ (x y : ι → σ), f x = f y) :

                                                                                                                                                                                                                                                                                                    A function that never changes value costs nothing: both vector families are zero, and every dual constraint reads 0 = 0.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasWeightedDual_const {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {w : ι → ℝ} (hf : ∀ (x y : ι → σ), f x = f y) :

                                                                                                                                                                                                                                                                                                    The zero solution has weighted cost zero for every weight vector, whatever its sign.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasWeightedDual.ofKer {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {f : (ι → σ) → O} {O' : Type} [DecidableEq O'] {f' : (ι → σ) → O'} {w : ι → ℝ} {V : ℝ} (hker : ∀ (x y : ι → σ), f x = f y ↔ f' x = f' y) (h : HasWeightedDual f w V) :

                                                                                                                                                                                                                                                                                                    HasDual.ofKer for the weighted predicate: recoding the output changes neither the feasible solutions nor their cost.

                                                                                                                                                                                                                                                                                                    Composition with shared inputs #

                                                                                                                                                                                                                                                                                                    This is the only place where dimension types are unified. The subproblems' solutions live in types K p depending on p; the sigma type Σ p, K p holds them all, and DualPair.embedDim moves each into it by padding with zeros, at no cost.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasWeightedDual.composeShared {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {P V : Type} [Fintype P] [DecidableEq V] {h : (P → V) → O} {g : P → (ι → σ) → V} {c : P → ℝ} {Vout : ℝ} (hQ : HasWeightedDual h c Vout) (hg : ∀ (p : P), HasDual (g p) (c p)) :
                                                                                                                                                                                                                                                                                                    HasDual (sharedFun h g) Vout

                                                                                                                                                                                                                                                                                                    Shared-input composition, bundled. An outer solution of c-weighted cost Vout and subproblem solutions of costs c p compose to cost Vout.

                                                                                                                                                                                                                                                                                                    The two combinators #

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.combine {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {P V : Type} [Fintype P] [DecidableEq V] (h : (P → V) → O) {g : P → (ι → σ) → V} {c : P → ℝ} (hg : ∀ (p : P), HasDual (g p) (c p)) [Finite O] [Finite V] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => h fun (p : P) => g p x) (2 * ∑ p : P, c p)

                                                                                                                                                                                                                                                                                                    Feed finitely many subproblems to an arbitrary outer function.

                                                                                                                                                                                                                                                                                                    The first-difference dual is feasible for any outer function, so nothing about h is assumed: it may add two tropical path weights, take a maximum of level summaries, or assemble a whole matrix out of its entries. The price is a factor 2 on the total of the subproblem costs.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.max {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {P A : Type} [Fintype P] [Nonempty P] [DecidableEq A] [LinearOrder A] {g : P → (ι → σ) → A} {c₀ : ℝ} (hc₀ : 0 ≤ c₀) (hg : ∀ (p : P), HasDual (g p) c₀) [Finite A] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => maxFun fun (p : P) => g p x) (c₀ * (24 * √↑(Fintype.card P)))

                                                                                                                                                                                                                                                                                                    The maximum of equally expensive subproblems.

                                                                                                                                                                                                                                                                                                    24 √q is the alphabet-free cost of maximum finding on q coordinates (SourceScanFinal); with constant weights it turns q subproblems of cost c₀ into their maximum at cost 24 √q · c₀. The values compared may range over any finite linear order, and the bound does not see how large it is.

                                                                                                                                                                                                                                                                                                    Maximum of a value map over a block of coordinates #

                                                                                                                                                                                                                                                                                                    The base case of every divide-and-conquer over letters: a query returns a whole letter, and the quantity wanted is the largest value of some map on the letters read in a given block.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasDual_maxMap {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {A : Type} [Nonempty ι] [DecidableEq A] [LinearOrder A] (m : σ → A) [Finite A] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => maxFun fun (j : ι) => m (x j)) (24 * √↑(Fintype.card ι))

                                                                                                                                                                                                                                                                                                    The maximum of m over the letters, as a bundled dual.

                                                                                                                                                                                                                                                                                                    MAX itself, as a bundled dual: hasDual_maxMap at the identity value map, with the alphabet the finite linear order being maximized. The operational Θ(√n) endpoints extracted from these certificates live in upstream Quantum/MaxApplications.lean.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasDual_maxMap_block {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {κ A : Type} [Fintype κ] [Nonempty κ] [DecidableEq A] [LinearOrder A] {e : κ → ι} (he : Function.Injective e) (m : σ → A) [Finite A] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => maxFun fun (j : κ) => m (x (e j))) (24 * √↑(Fintype.card κ))

                                                                                                                                                                                                                                                                                                    The maximum of m over the letters in a block, at a cost governed by the size of the block.

                                                                                                                                                                                                                                                                                                    Infinite value types #

                                                                                                                                                                                                                                                                                                    The scan and the first-difference gadget both need finite branch and output types, while the values a divide-and-conquer computes naturally live somewhere infinite — tropical path weights are elements of ℝ ∪ {-∞}.

                                                                                                                                                                                                                                                                                                    Nothing is lost. The input space ι → σ is finite, so every function on it has finite range; restricting to that range changes neither the level sets nor, by HasDual.ofKer, the dual solutions. The three combinators are therefore restated with no finiteness assumption on the values at all, and it is these versions that a recursion over tropical matrices consumes.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.maxFun_strictMono {κ A B : Type} [Fintype κ] [Nonempty κ] [LinearOrder A] [LinearOrder B] {φ : A → B} (hφ : StrictMono φ) (G : κ → A) :
                                                                                                                                                                                                                                                                                                    (maxFun fun (j : κ) => φ (G j)) = φ (maxFun G)

                                                                                                                                                                                                                                                                                                    A strictly monotone map commutes with maxFun. Used to compare a maximum computed inside a finite subtype of values with the same maximum computed outside it.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.max' {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {Pi A : Type} [Fintype Pi] [Nonempty Pi] [DecidableEq A] [LinearOrder A] {g : Pi → (ι → σ) → A} {c₀ : ℝ} (hc₀ : 0 ≤ c₀) (hg : ∀ (p : Pi), HasDual (g p) c₀) [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => maxFun fun (p : Pi) => g p x) (c₀ * (24 * √↑(Fintype.card Pi)))

                                                                                                                                                                                                                                                                                                    The maximum of equally expensive subproblems, over any linear order of values.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.combine' {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {Pi V O' : Type} [Fintype Pi] [DecidableEq V] [DecidableEq O'] (h : (Pi → V) → O') {g : Pi → (ι → σ) → V} {c : Pi → ℝ} (hg : ∀ (p : Pi), HasDual (g p) (c p)) [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => h fun (p : Pi) => g p x) (2 * ∑ p : Pi, c p)

                                                                                                                                                                                                                                                                                                    An arbitrary outer function of finitely many subproblems, over any value and output types.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.postcomp {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {V O' : Type} [DecidableEq V] [DecidableEq O'] {f : (ι → σ) → V} {c : ℝ} (h : HasDual f c) (H : V → O') [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => H (f x)) (2 * c)

                                                                                                                                                                                                                                                                                                    Postcomposition is available within a factor two. combine' with a one-element index set: its outer function is arbitrary, so any recoding of the output — a coarsening included — costs at most twice the original. It is not free in general: a dual for f satisfies an equality constraint keyed to f's level sets, and merging two of them turns a required 1 into a required 0. Two is an upper bound obtained this way, not a lower bound on what a coarsening must cost — a particular recoding may well be cheaper, and an injective one is free (HasDual.ofKer). This is the priced form of the joint-output discipline.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.postcomp_of_determined {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {V O' : Type} [DecidableEq V] [DecidableEq O'] [Nonempty O'] {f : (ι → σ) → V} {g : (ι → σ) → O'} {c : ℝ} (h : HasDual f c) (hdet : ∀ (x y : ι → σ), f x = f y → g x = g y) [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual g (2 * c)

                                                                                                                                                                                                                                                                                                    A joint may be collapsed onto anything it determines, within the same factor two — with the collapsing map obtained from the determination rather than supplied. This is the form a transcript compiler needs: it builds a joint and reads off the answer that the joint determines.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasDual_two_mul_card {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] (f : (ι → σ) → O) [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual f (2 * ↑(Fintype.card ι))

                                                                                                                                                                                                                                                                                                    Every function of n letters costs 2n, whatever its output type. The first-difference dual with the output recoded into its finite range.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasDual_ofCoord {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] (i₀ : ι) (m : σ → O) [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => m (x i₀)) 2

                                                                                                                                                                                                                                                                                                    A function of a single letter costs 2. Both the letter alphabet and the output type are arbitrary.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.finsetSup_eq_maxFun {α A : Type} [LinearOrder A] [OrderBot A] (S : Finset α) (F : α → A) :
                                                                                                                                                                                                                                                                                                    S.sup F = maxFun fun (c : Option ↥S) => c.elim ⊥ fun (i : ↥S) => F ↑i

                                                                                                                                                                                                                                                                                                    A finite supremum, as a maximum over a nonempty index. Padding the index set with a none carrying ⊥ makes an empty supremum legal, so no nonemptiness hypothesis has to be threaded through a recursion.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.finsetSup {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {α A : Type} [DecidableEq A] [LinearOrder A] [OrderBot A] (S : Finset α) {g : α → (ι → σ) → A} {c₀ : ℝ} (hc₀ : 0 ≤ c₀) (hg : ∀ i ∈ S, HasDual (g i) c₀) [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => S.sup fun (i : α) => g i x) (c₀ * (24 * √(↑S.card + 1)))

                                                                                                                                                                                                                                                                                                    The supremum of a finite family of equally expensive subproblems.

                                                                                                                                                                                                                                                                                                    The workhorse of the divide-and-conquer: q candidates each solved at cost c₀ give their maximum at cost 24 √(q+1) · c₀. Stated for Finset.sup rather than maxFun, so that an empty candidate set — the maximum of nothing is ⊥ — is allowed and costs nothing extra.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.HasDual.combine₂ {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {V O' : Type} [DecidableEq V] [DecidableEq O'] (h : V → V → O') {g₀ g₁ : (ι → σ) → V} {c₀ c₁ : ℝ} (hg₀ : HasDual g₀ c₀) (hg₁ : HasDual g₁ c₁) [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => h (g₀ x) (g₁ x)) (2 * (c₀ + c₁))

                                                                                                                                                                                                                                                                                                    Two subproblems fed to an arbitrary binary outer function. This is how two tropical path weights are multiplied — h is (+) on ℝ ∪ {-∞} — and nothing about h is used.

                                                                                                                                                                                                                                                                                                    theorem QuantumQueryComplexity.hasDual_maxMap_block' {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {κ A : Type} [Fintype κ] [Nonempty κ] [DecidableEq A] [LinearOrder A] {e : κ → ι} (he : Function.Injective e) (m : σ → A) [Finite σ] :
                                                                                                                                                                                                                                                                                                    HasDual (fun (x : ι → σ) => maxFun fun (j : κ) => m (x (e j))) (24 * √↑(Fintype.card κ))

                                                                                                                                                                                                                                                                                                    The maximum of a value map over a block of letters, over any linear order of values. This is the base case of the tropical recursion: the largest (s,t) entry among the letters read in a block.

                                                                                                                                                                                                                                                                                                    Bundled dual solutions on a promise domain #

                                                                                                                                                                                                                                                                                                    SourceHasDual hides the dimension type of a dual solution for a total function; a divide-and-conquer recursion whose subproblems live on input-dependent promises needs the same service on DualPairOn. This section is that layer, plus the two structural moves every promise construction needs:

                                                                                                                                                                                                                                                                                                    Cost-0 solutions exist exactly for functions that are constant on the promise (hasDualOn_of_const): on such a promise the constraint's right-hand side is identically 0, so the zero vectors are feasible. That is the "value determined by the transcript" case of descriptor composition.

                                                                                                                                                                                                                                                                                                    Recoding the output #

                                                                                                                                                                                                                                                                                                    def QuantumQueryComplexity.DualPairOn.ofKer {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O O' : Type} [DecidableEq O] [DecidableEq O'] {K : Type} [Fintype K] {read : X → ι → σ} {f : X → O} {f' : X → O'} (P : DualPairOn read K f) (h : ∀ (x y : X), f x = f y ↔ f' x = f' y) :
                                                                                                                                                                                                                                                                                                    DualPairOn read K f'

                                                                                                                                                                                                                                                                                                    Output recoding. A dual solution for f is a dual solution for any f' with the same kernel on the promise — same vectors, same cost.

                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                    • P.ofKer h = { u := P.u, v := P.v, constraint := ⋯ }
                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                      @[simp]
                                                                                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.DualPairOn.ofKer_u {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O O' : Type} [DecidableEq O] [DecidableEq O'] {K : Type} [Fintype K] {read : X → ι → σ} {f : X → O} {f' : X → O'} (P : DualPairOn read K f) (h : ∀ (x y : X), f x = f y ↔ f' x = f' y) :
                                                                                                                                                                                                                                                                                                      (P.ofKer h).u = P.u
                                                                                                                                                                                                                                                                                                      @[simp]
                                                                                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.DualPairOn.ofKer_v {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O O' : Type} [DecidableEq O] [DecidableEq O'] {K : Type} [Fintype K] {read : X → ι → σ} {f : X → O} {f' : X → O'} (P : DualPairOn read K f) (h : ∀ (x y : X), f x = f y ↔ f' x = f' y) :
                                                                                                                                                                                                                                                                                                      (P.ofKer h).v = P.v
                                                                                                                                                                                                                                                                                                      theorem QuantumQueryComplexity.DualPairOn.ofKer_isCostLe {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O O' : Type} [DecidableEq O] [DecidableEq O'] {K : Type} [Fintype K] {read : X → ι → σ} {f : X → O} {f' : X → O'} {c : ℝ} {P : DualPairOn read K f} {h : ∀ (x y : X), f x = f y ↔ f' x = f' y} (hP : P.IsCostLe c) :
                                                                                                                                                                                                                                                                                                      (P.ofKer h).IsCostLe c
                                                                                                                                                                                                                                                                                                      def QuantumQueryComplexity.DualPairOn.comap {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {K : Type} [Fintype K] {read : X → ι → σ} {f : X → O} {Y : Type} [Fintype Y] (P : DualPairOn read K f) (e : Y → X) :
                                                                                                                                                                                                                                                                                                      DualPairOn (fun (y : Y) => read (e y)) K fun (y : Y) => f (e y)

                                                                                                                                                                                                                                                                                                      Pulling a promise solution back along a map of promises. Every sub-promise — in particular every fiber of a descriptor — inherits the ambient solution at the same cost, since the constraint at (y, y') is the constraint at (e y, e y').

                                                                                                                                                                                                                                                                                                      Equations
                                                                                                                                                                                                                                                                                                      • P.comap e = { u := fun (y : Y) => P.u (e y), v := fun (y : Y) => P.v (e y), constraint := ⋯ }
                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                        def QuantumQueryComplexity.DualPairOn.const {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] (read : X → ι → σ) (f : X → O) (hf : ∀ (x y : X), f x = f y) :

                                                                                                                                                                                                                                                                                                        The zero solution is feasible for a function that is constant on the promise.

                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                          theorem QuantumQueryComplexity.DualPairOn.const_isCostLe {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {read : X → ι → σ} {f : X → O} (hf : ∀ (x y : X), f x = f y) :
                                                                                                                                                                                                                                                                                                          (const read f hf).IsCostLe 0

                                                                                                                                                                                                                                                                                                          The bundled predicate #

                                                                                                                                                                                                                                                                                                          def QuantumQueryComplexity.HasDualOn {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] (read : X → ι → σ) (f : X → O) (c : ℝ) :

                                                                                                                                                                                                                                                                                                          f has a feasible dual solution of cost at most c on the promise domain read.

                                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.hasDualOn_of_dualPairOn {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {read : X → ι → σ} {f : X → O} {c : ℝ} {K : Type} [Fintype K] (P : DualPairOn read K f) (h : P.IsCostLe c) :
                                                                                                                                                                                                                                                                                                            HasDualOn read f c
                                                                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.HasDualOn.mono {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {read : X → ι → σ} {f : X → O} {c d : ℝ} (h : HasDualOn read f c) (hcd : c ≤ d) :
                                                                                                                                                                                                                                                                                                            HasDualOn read f d
                                                                                                                                                                                                                                                                                                            theorem QuantumQueryComplexity.advPMOn_le_of_hasDualOn {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] [DecidableEq X] {O : Type} [DecidableEq O] {read : X → ι → σ} {f : X → O} {c : ℝ} (hc : 0 ≤ c) (h : HasDualOn read f c) :
                                                                                                                                                                                                                                                                                                            advPMOn read f ≤ c

                                                                                                                                                                                                                                                                                                            Weak duality on a promise, bundled.

                                                                                                                                                                                                                                                                                                            Total solutions as promise solutions #

                                                                                                                                                                                                                                                                                                            A total function is the promise problem over read = id, and a DualPair is literally a DualPairOn there — the constraint's mask id x i = id y i is definitionally x i = y i.

                                                                                                                                                                                                                                                                                                            def QuantumQueryComplexity.DualPair.toOn {ι : Type} [Fintype ι] [DecidableEq ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] [Fintype σ] {g : (ι → σ) → O} {K : Type} [Fintype K] (P : DualPair K g) :

                                                                                                                                                                                                                                                                                                            A total dual solution, read as a promise solution over read = id.

                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                            • P.toOn = { u := P.u, v := P.v, constraint := ⋯ }
                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.DualPair.toOn_isCostLe {ι : Type} [Fintype ι] [DecidableEq ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {c : ℝ} [Fintype σ] {g : (ι → σ) → O} {K : Type} [Fintype K] (P : DualPair K g) (h : P.IsCostLe c) :
                                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.HasDual.hasDualOn {ι : Type} [Fintype ι] [DecidableEq ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {c : ℝ} [Fintype σ] {g : (ι → σ) → O} (h : HasDual g c) :

                                                                                                                                                                                                                                                                                                              A total bundled dual is a bundled promise dual over read = id.

                                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.HasDual.of_hasDualOn_id {ι : Type} [Fintype ι] [DecidableEq ι] {σ : Type} [DecidableEq σ] {O : Type} [DecidableEq O] {c : ℝ} [Fintype σ] {g : (ι → σ) → O} (h : HasDualOn id g c) :

                                                                                                                                                                                                                                                                                                              The converse of HasDual.hasDualOn. With both directions available the promise-side calculus — descriptor composition in particular — can be run inside a total development and handed back as a HasDual.

                                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.HasDualOn.ofKer {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O O' : Type} [DecidableEq O] [DecidableEq O'] {read : X → ι → σ} {f : X → O} {f' : X → O'} {c : ℝ} (h : HasDualOn read f c) (hker : ∀ (x y : X), f x = f y ↔ f' x = f' y) :
                                                                                                                                                                                                                                                                                                              HasDualOn read f' c

                                                                                                                                                                                                                                                                                                              Recoding the output of a bundled solution.

                                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.HasDualOn.ofEq {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {read : X → ι → σ} {f : X → O} {c : ℝ} (h : HasDualOn read f c) {g : X → O} (hg : ∀ (x : X), f x = g x) :
                                                                                                                                                                                                                                                                                                              HasDualOn read g c

                                                                                                                                                                                                                                                                                                              Replacing the function by a pointwise equal one.

                                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.HasDualOn.comap {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {read : X → ι → σ} {f : X → O} {c : ℝ} {Y : Type} [Fintype Y] (h : HasDualOn read f c) (e : Y → X) :
                                                                                                                                                                                                                                                                                                              HasDualOn (fun (y : Y) => read (e y)) (fun (y : Y) => f (e y)) c

                                                                                                                                                                                                                                                                                                              Restricting a bundled promise solution to a sub-promise, at the same cost.

                                                                                                                                                                                                                                                                                                              theorem QuantumQueryComplexity.hasDualOn_of_const {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] (read : X → ι → σ) {f : X → O} (hf : ∀ (x y : X), f x = f y) :
                                                                                                                                                                                                                                                                                                              HasDualOn read f 0

                                                                                                                                                                                                                                                                                                              A function constant on the promise costs nothing.

                                                                                                                                                                                                                                                                                                              Moving between query index types #

                                                                                                                                                                                                                                                                                                              noncomputable def QuantumQueryComplexity.DualPairOn.pullbackCoord {ι : Type} [Fintype ι] [DecidableEq ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {K : Type} [Fintype K] {read : X → ι → σ} {f : X → O} {ι' : Type} [Fintype ι'] {e : ι' → ι} (he : Function.Injective e) (P : DualPairOn (fun (x : X) (k : ι') => read x (e k)) K f) :
                                                                                                                                                                                                                                                                                                              DualPairOn read K f

                                                                                                                                                                                                                                                                                                              A solution that only queries a sub-family of coordinates. If the promise is observed through ι' ↪ ι — the arena of a divide-and-conquer node is such a sub-family of the word's positions — a solution written in arena coordinates becomes one in the ambient coordinates, at the same cost: the ℓ² mass moves to the image of the injection without accumulating (spread).

                                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.DualPairOn.pullbackCoord_isCostLe {ι : Type} [Fintype ι] [DecidableEq ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {K : Type} [Fintype K] {read : X → ι → σ} {f : X → O} {ι' : Type} [Fintype ι'] {e : ι' → ι} (he : Function.Injective e) (P : DualPairOn (fun (x : X) (k : ι') => read x (e k)) K f) {c : ℝ} (hP : P.IsCostLe c) :
                                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.HasDualOn.pullbackCoord {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {read : X → ι → σ} {f : X → O} {c : ℝ} {ι' : Type} [Fintype ι'] {e : ι' → ι} (he : Function.Injective e) (h : HasDualOn (fun (x : X) (k : ι') => read x (e k)) f c) :
                                                                                                                                                                                                                                                                                                                HasDualOn read f c

                                                                                                                                                                                                                                                                                                                Arena coordinates, bundled: a promise solution written in the coordinates of a sub-family costs the same in the ambient coordinates.

                                                                                                                                                                                                                                                                                                                Restricting a total solution #

                                                                                                                                                                                                                                                                                                                theorem QuantumQueryComplexity.HasDual.restrictToOn {ι : Type} [Fintype ι] {σ : Type} [DecidableEq σ] {X : Type} [Fintype X] {O : Type} [DecidableEq O] {c : ℝ} {g : (ι → σ) → O} (h : HasDual g c) (read : X → ι → σ) :
                                                                                                                                                                                                                                                                                                                HasDualOn read (fun (x : X) => g (read x)) c

                                                                                                                                                                                                                                                                                                                A total dual solution restricted to a promise domain, bundled: the vectors are unchanged, so the cost is inherited. This is how the windowed ED duals enter a promise-relativized recursion.