math / data /lean /OAI /Computability /UniqueGames /Decoding /AdviceFibersLemmas.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
48.6 kB
import Mathlib.Algebra.BigOperators.Field import Mathlib.Algebra.Order.BigOperators.Expect import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring import OAI.Computability.UniqueGames.Analysis.MatrixEnergy import OAI.Computability.UniqueGames.Analysis.MatrixNoiseLemmas import OAI.Computability.UniqueGames.Analysis.MatrixParityRow import OAI.Computability.UniqueGames.Analysis.MatrixRestrictions import OAI.Computability.UniqueGames.Gadgets.AdaptivePathsLemmas namespace OAI section /-! # Exact visible row advice and private matrix coordinates Every nonempty fiber of `M ↦ A ∘ M` is an affine copy of `Hom(E, ker A)`, whether or not `A` is surjective. Choosing one base matrix for each attainable row gives a product decomposition of the complete matrix space. Uniform sampling therefore makes visible row advice and the hidden kernel-valued matrix independent. -/ noncomputable section open scoped BigOperators open UniqueGamesTheorem.Integration.BinaryLinear namespace UniqueGamesTheorem.Decoder.AdviceFibers variable {E K R : Type*} [AddCommGroup E] [Module F2 E] [AddCommGroup K] [Module F2 K] [AddCommGroup R] [Module F2 R] /-- Actual matrices with the specified observed row advice. -/ abbrev RowFiber (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R) := {M : E β†’β‚—[F2] K // A.comp M = S} /-- Hidden coordinates relative to one base matrix in the same row fiber. -/ def kernelDifference (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) (M : RowFiber A S) : E β†’β‚—[F2] A.ker := (M.val - Mβ‚€).codRestrict A.ker (by intro x change A (M.val x - Mβ‚€ x) = 0 rw [map_sub] have hM := LinearMap.congr_fun M.property x have hbase := LinearMap.congr_fun hβ‚€ x change A (M.val x) = S x at hM change A (Mβ‚€ x) = S x at hbase rw [hM, hbase, sub_self]) @[simp] theorem kernelDifference_apply (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) (M : RowFiber A S) (x : E) : (kernelDifference A S Mβ‚€ hβ‚€ M x : K) = M.val x - Mβ‚€ x := rfl /-- Reassemble an actual matrix from its fixed visible base and private part. -/ def assemble (A : K β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (N : E β†’β‚—[F2] A.ker) : E β†’β‚—[F2] K := Mβ‚€ + A.ker.subtype.comp N @[simp] theorem assemble_apply (A : K β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (N : E β†’β‚—[F2] A.ker) (x : E) : assemble A Mβ‚€ N x = Mβ‚€ x + (N x : K) := rfl /-- Observed advice is completely unchanged by the private coordinates. -/ theorem observed_assemble (A : K β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (N : E β†’β‚—[F2] A.ker) : A.comp (assemble A Mβ‚€ N) = A.comp Mβ‚€ := by ext x have hN : A (N x : K) = 0 := (N x).property simp only [LinearMap.comp_apply, assemble_apply, map_add, hN, add_zero] /-- The exact row-fiber bijection; no rank or surjectivity premise is needed. -/ def rowFiberEquiv (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) : (E β†’β‚—[F2] A.ker) ≃ RowFiber A S where toFun N := ⟨assemble A Mβ‚€ N, (observed_assemble A Mβ‚€ N).trans hβ‚€βŸ© invFun := kernelDifference A S Mβ‚€ hβ‚€ left_inv N := by apply LinearMap.ext intro x apply Subtype.ext change Mβ‚€ x + (N x : K) - Mβ‚€ x = (N x : K) exact add_sub_cancel_left _ _ right_inv M := by apply Subtype.ext ext x change Mβ‚€ x + (M.val x - Mβ‚€ x) = M.val x simpa only [← add_sub_assoc] using add_sub_cancel_left (Mβ‚€ x) (M.val x) @[simp] theorem rowFiberEquiv_coe (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) (N : E β†’β‚—[F2] A.ker) : (rowFiberEquiv A S Mβ‚€ hβ‚€ N).val = assemble A Mβ‚€ N := rfl @[simp] theorem rowFiberEquiv_symm (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) (M : RowFiber A S) : (rowFiberEquiv A S Mβ‚€ hβ‚€).symm M = kernelDifference A S Mβ‚€ hβ‚€ M := rfl /-- Affine target intercepts are retained in the private coordinates. -/ theorem assemble_affine_target (A : K β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K) (N : E β†’β‚—[F2] A.ker) (z : E) (u : K) : assemble A Mβ‚€ N z + u = (N z : K) + (Mβ‚€ z + u) := by rw [assemble_apply] ac_rfl section UniformFiber variable (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R) [Fintype (E β†’β‚—[F2] A.ker)] theorem rowFiber_card (Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) : Nat.card (RowFiber A S) = Fintype.card (E β†’β‚—[F2] A.ker) := by rw [Nat.card_congr (rowFiberEquiv A S Mβ‚€ hβ‚€).symm, Nat.card_eq_fintype_card] /-- Uniform private matrices push forward to uniform matrices in the fiber. -/ theorem rowFiber_expect (Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) [Fintype (RowFiber A S)] (f : (E β†’β‚—[F2] K) β†’ ℝ) : (𝔼 M : RowFiber A S, f M.val) = 𝔼 N : E β†’β‚—[F2] A.ker, f (assemble A Mβ‚€ N) := by exact (Fintype.expect_equiv (rowFiberEquiv A S Mβ‚€ hβ‚€) (fun N => f (assemble A Mβ‚€ N)) (fun M => f M.val) (fun _ => rfl)).symm end UniformFiber /-- Only attainable rows are observation values. -/ abbrev ObservedRow (A : K β†’β‚—[F2] R) := {S : E β†’β‚—[F2] R // βˆƒ M : E β†’β‚—[F2] K, A.comp M = S} def observe (A : K β†’β‚—[F2] R) (M : E β†’β‚—[F2] K) : ObservedRow (E := E) A := ⟨A.comp M, M, rfl⟩ /-- A canonical base depends only on observed advice, never on the hidden matrix. -/ def observedBase (A : K β†’β‚—[F2] R) (S : ObservedRow (E := E) A) : E β†’β‚—[F2] K := Classical.choose S.property theorem observedBase_property (A : K β†’β‚—[F2] R) (S : ObservedRow (E := E) A) : A.comp (observedBase A S) = S.val := Classical.choose_spec S.property def hiddenCoordinate (A : K β†’β‚—[F2] R) (M : E β†’β‚—[F2] K) : E β†’β‚—[F2] A.ker := (rowFiberEquiv A (observe A M).val (observedBase A (observe A M)) (observedBase_property A (observe A M))).symm ⟨M, rfl⟩ theorem observe_assemble_base (A : K β†’β‚—[F2] R) (S : ObservedRow (E := E) A) (N : E β†’β‚—[F2] A.ker) : observe A (assemble A (observedBase A S) N) = S := by apply Subtype.ext exact (observed_assemble A (observedBase A S) N).trans (observedBase_property A S) /-- Full matrix space is a product of attainable visible rows and private kernel-valued maps. A section of `A` is not required. -/ def observationEquiv (A : K β†’β‚—[F2] R) : (E β†’β‚—[F2] K) ≃ ObservedRow (E := E) A Γ— (E β†’β‚—[F2] A.ker) where toFun M := (observe A M, hiddenCoordinate A M) invFun p := assemble A (observedBase A p.1) p.2 left_inv M := by exact congrArg Subtype.val ((rowFiberEquiv A (observe A M).val (observedBase A (observe A M)) (observedBase_property A (observe A M))).apply_symm_apply ⟨M, rfl⟩) right_inv p := by apply Prod.ext Β· exact observe_assemble_base A p.1 p.2 Β· apply LinearMap.ext intro x apply Subtype.ext change assemble A (observedBase A p.1) p.2 x - observedBase A (observe A (assemble A (observedBase A p.1) p.2)) x = (p.2 x : K) rw [observe_assemble_base, assemble_apply] exact add_sub_cancel_left _ _ @[simp] theorem observationEquiv_apply (A : K β†’β‚—[F2] R) (M : E β†’β‚—[F2] K) : observationEquiv A M = (observe A M, hiddenCoordinate A M) := rfl section UniformObservation variable (A : K β†’β‚—[F2] R) [Fintype (E β†’β‚—[F2] K)] [Fintype (E β†’β‚—[F2] A.ker)] [Fintype (ObservedRow (E := E) A)] /-- The joint law is exactly the uniform product law. -/ theorem observation_expect (f : ObservedRow (E := E) A β†’ (E β†’β‚—[F2] A.ker) β†’ ℝ) : (𝔼 M : E β†’β‚—[F2] K, f (observe A M) (hiddenCoordinate A M)) = 𝔼 S : ObservedRow (E := E) A, 𝔼 N : E β†’β‚—[F2] A.ker, f S N := by rw [Fintype.expect_equiv (observationEquiv A) (fun M => f (observe A M) (hiddenCoordinate A M)) (fun p => f p.1 p.2) (fun _ => rfl)] rw [← Finset.univ_product_univ, Finset.expect_product] /-- Exact factorization of every product of visible and private observables. -/ theorem observed_hidden_independent (f : ObservedRow (E := E) A β†’ ℝ) (g : (E β†’β‚—[F2] A.ker) β†’ ℝ) : (𝔼 M : E β†’β‚—[F2] K, f (observe A M) * g (hiddenCoordinate A M)) = (𝔼 S : ObservedRow (E := E) A, f S) * (𝔼 N : E β†’β‚—[F2] A.ker, g N) := by rw [observation_expect A (fun S N => f S * g N)] simp_rw [← Finset.mul_expect] exact (Finset.expect_mul _ _ _).symm end UniformObservation end UniqueGamesTheorem.Decoder.AdviceFibers end end section /-! # Finite latent samplers and their actual spectral law This bridge counts all sampler outcomes, including repeated vectors and the zero vector. Uniform sampler detection is exactly the complement of the matrix operator's annihilation multiplier. -/ noncomputable section open scoped BigOperators Classical open UniqueGamesTheorem.Fourier.MatrixCharacters open UniqueGamesTheorem.Fourier.MatrixNoise namespace UniqueGamesTheorem.Decoder.NoiseSampler section FiniteLaw variable {Noise V : Type*} [Fintype Noise] [Fintype V] /-- The real pushforward of the uniform law on sampler outcomes. -/ def samplerLaw (noise : Noise β†’ V) (v : V) : ℝ := by classical exact βˆ‘ n, if noise n = v then (Fintype.card Noise : ℝ)⁻¹ else 0 omit [Fintype V] in theorem samplerLaw_nonneg (noise : Noise β†’ V) (v : V) : 0 ≀ samplerLaw noise v := by classical unfold samplerLaw apply Finset.sum_nonneg intro n _ split_ifs <;> positivity omit [Fintype V] in /-- Literal counting formula; multiple sampler outcomes mapping to the same vector retain their multiplicity. -/ theorem samplerLaw_eq_count (noise : Noise β†’ V) (v : V) : samplerLaw noise v = ((Finset.univ.filter fun n => noise n = v).card : ℝ) / Fintype.card Noise := by classical unfold samplerLaw rw [← Finset.sum_filter] simp [div_eq_mul_inv] theorem samplerLaw_sum (noise : Noise β†’ V) (f : V β†’ ℝ) : (βˆ‘ v, samplerLaw noise v * f v) = (Fintype.card Noise : ℝ)⁻¹ * βˆ‘ n, f (noise n) := by classical unfold samplerLaw simp_rw [Finset.sum_mul, ite_mul, zero_mul] rw [Finset.sum_comm] simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] exact (Finset.mul_sum _ _ _).symm /-- Exact pushforward expectation, with the uniform normalization explicit. -/ theorem sample_expect_eq (noise : Noise β†’ V) (f : V β†’ ℝ) : (𝔼 n, f (noise n)) = βˆ‘ v, samplerLaw noise v * f v := by rw [samplerLaw_sum, Fintype.expect_eq_sum_div_card, div_eq_mul_inv, mul_comm] theorem samplerLaw_normalized [Nonempty Noise] (noise : Noise β†’ V) : βˆ‘ v, samplerLaw noise v = 1 := by have h := sample_expect_eq noise (fun _ => 1) simpa using h.symm theorem rat_expect_cast (f : Noise β†’ β„š) : ((𝔼 n, f n : β„š) : ℝ) = 𝔼 n, (f n : ℝ) := by simp only [Finset.expect_eq_sum_div_card, Rat.cast_div, Rat.cast_sum, Rat.cast_natCast] omit [Fintype V] in theorem samplerLaw_eq_rat_count (noise : Noise β†’ V) (v : V) : samplerLaw noise v = ((((Finset.univ.filter fun n => noise n = v).card : β„š) / (Fintype.card Noise : β„š) : β„š) : ℝ) := by rw [samplerLaw_eq_count] simp only [Rat.cast_div, Rat.cast_natCast] end FiniteLaw section ActualMultiplier variable {Noise V E : Type*} [Fintype Noise] [Fintype V] [AddCommGroup V] [Module F2 V] [AddCommGroup E] [Module F2 E] /-- The actual matrix multiplier is precisely the sampler's kernel event. -/ theorem sample_kernel_eq_eigenvalue (noise : Noise β†’ V) (S : V β†’β‚—[F2] E) : (𝔼 n, if S (noise n) = 0 then (1 : ℝ) else 0) = linearNoiseEigenvalue (samplerLaw noise) S := by classical exact sample_expect_eq noise (fun v => if S v = 0 then 1 else 0) /-- Detection plus annihilation is one for the same unconditional sampler. -/ theorem detection_add_eigenvalue [Nonempty Noise] (noise : Noise β†’ V) (S : V β†’β‚—[F2] E) : (𝔼 n, if S (noise n) β‰  0 then (1 : ℝ) else 0) + linearNoiseEigenvalue (samplerLaw noise) S = 1 := by classical rw [← sample_kernel_eq_eigenvalue, ← Finset.expect_add_distrib] calc _ = 𝔼 _n : Noise, (1 : ℝ) := by apply Finset.expect_congr rfl intro n _ by_cases h : S (noise n) = 0 <;> simp [h] _ = 1 := Fintype.expect_const 1 /-- The constant-detection input becomes the `7/8` multiplier bound. -/ theorem detection_eigenvalue_le [Nonempty Noise] (noise : Noise β†’ V) (S : V β†’β‚—[F2] E) (hdetect : (1 : ℝ) / 8 ≀ 𝔼 n, if S (noise n) β‰  0 then (1 : ℝ) else 0) : linearNoiseEigenvalue (samplerLaw noise) S ≀ 7 / 8 := by have h := detection_add_eigenvalue noise S linarith /-- A generic detection level bounds the annihilation multiplier. -/ theorem detection_eigenvalue_le_complement [Nonempty Noise] (noise : Noise β†’ V) (S : V β†’β‚—[F2] E) (d : ℝ) (hdetect : d ≀ 𝔼 n, if S (noise n) β‰  0 then (1 : ℝ) else 0) : linearNoiseEigenvalue (samplerLaw noise) S ≀ 1 - d := by have h := detection_add_eigenvalue noise S linarith /-- The gadget may keep its finite probabilities rational throughout. -/ theorem rational_detection_eigenvalue_le [Nonempty Noise] (noise : Noise β†’ V) (S : V β†’β‚—[F2] E) (hdetect : (1 : β„š) / 8 ≀ 𝔼 n, if S (noise n) β‰  0 then (1 : β„š) else 0) : linearNoiseEigenvalue (samplerLaw noise) S ≀ 7 / 8 := by apply detection_eigenvalue_le noise S have hcast := (Rat.cast_le (K := ℝ)).mpr hdetect rw [rat_expect_cast] at hcast simpa only [Rat.cast_div, Rat.cast_ofNat, Rat.cast_one, Rat.cast_zero, apply_ite] using hcast end ActualMultiplier end UniqueGamesTheorem.Decoder.NoiseSampler end end section noncomputable section open scoped BigOperators Classical open UniqueGamesTheorem.Fourier open MatrixCharacters MatrixFourier MatrixNoise MatrixEnergy namespace UniqueGamesTheorem.Decoder.PositiveMultiplier section FiniteSpectra variable {J : Type*} [Fintype J] {I : J β†’ Type*} [βˆ€ j, Fintype (I j)] /-- A `7/8` bound outside the retained set forces at least `0.92` retained mass when acceptance is at least `0.99`. The statement keeps the exact rational constants, rather than assuming a low-rank mass premise. -/ theorem retained_mass_of_acceptance (w : J β†’ ℝ) (a lam : (j : J) β†’ I j β†’ ℝ) (keep : (j : J) β†’ I j β†’ Prop) (hw : βˆ€ j, 0 ≀ w j) (htotal : energy w a = 1) (hone : βˆ€ j i, lam j i ≀ 1) (hhigh : βˆ€ j i, Β¬ keep j i β†’ lam j i ≀ 7 / 8) (haccept : (99 : ℝ) / 100 ≀ spectralEnergy w lam a) : (23 : ℝ) / 25 ≀ cutoffEnergy w keep a := by classical have hp (j : J) (i : I j) : lam j i * a j i ^ 2 ≀ (7 / 8 : ℝ) * a j i ^ 2 + (1 / 8 : ℝ) * (if keep j i then a j i ^ 2 else 0) := by by_cases hk : keep j i Β· have h := mul_le_mul_of_nonneg_right (hone j i) (sq_nonneg (a j i)) simp only [ite_eq_left hk] at * nlinarith Β· have h := mul_le_mul_of_nonneg_right (hhigh j i hk) (sq_nonneg (a j i)) simpa only [ite_eq_right hk, mul_zero, add_zero] using h have hb : spectralEnergy w lam a ≀ (7 / 8 : ℝ) * energy w a + (1 / 8 : ℝ) * cutoffEnergy w keep a := by calc _ ≀ βˆ‘ j, w j * βˆ‘ i, ((7 / 8 : ℝ) * a j i ^ 2 + (1 / 8 : ℝ) * (if keep j i then a j i ^ 2 else 0)) := by exact Finset.sum_le_sum (fun j _ => mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun i _ => hp j i)) (hw j)) _ = _ := by simp only [energy, cutoffEnergy, Finset.sum_add_distrib, Finset.mul_sum, mul_add] congr 1 <;> (apply Finset.sum_congr rfl intro j _ apply Finset.sum_congr rfl intro i _ ring) rw [htotal] at hb linarith theorem positive_multiplier_comparison (w : J β†’ ℝ) (a lam Ο„ : (j : J) β†’ I j β†’ ℝ) (keep : (j : J) β†’ I j β†’ Prop) (t : ℝ) (hw : βˆ€ j, 0 ≀ w j) (htotal : energy w a = 1) (ht : 0 ≀ t) (hone : βˆ€ j i, lam j i ≀ 1) (hhigh : βˆ€ j i, Β¬ keep j i β†’ lam j i ≀ 7 / 8) (hΟ„ : βˆ€ j i, 0 ≀ Ο„ j i) (hlow : βˆ€ j i, keep j i β†’ t ≀ Ο„ j i) (haccept : (99 : ℝ) / 100 ≀ spectralEnergy w lam a) : (9 : ℝ) / 10 * t ≀ spectralEnergy w Ο„ a := by classical have hmass := retained_mass_of_acceptance w a lam keep hw htotal hone hhigh haccept have hp (j : J) (i : I j) : t * (if keep j i then a j i ^ 2 else 0) ≀ Ο„ j i * a j i ^ 2 := by by_cases hk : keep j i Β· simpa only [ite_eq_left hk] using mul_le_mul_of_nonneg_right (hlow j i hk) (sq_nonneg (a j i)) Β· simpa only [ite_eq_right hk, mul_zero] using mul_nonneg (hΟ„ j i) (sq_nonneg (a j i)) have hb : t * cutoffEnergy w keep a ≀ spectralEnergy w Ο„ a := by unfold cutoffEnergy spectralEnergy rw [Finset.mul_sum] apply Finset.sum_le_sum intro j _ calc t * (w j * βˆ‘ i, if keep j i then a j i ^ 2 else 0) = w j * (βˆ‘ i, t * (if keep j i then a j i ^ 2 else 0)) := by rw [← Finset.mul_sum] ring _ ≀ _ := mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun i _ => hp j i)) (hw j) have hm := mul_le_mul_of_nonneg_left hmass ht nlinarith /-- A finite probability law with mean at least `14.4 Ξ·` assigns mass at least `10 Ξ·` to acceptances at least `4 Ξ·`. -/ theorem good_fiber_mass {Q : Type*} [Fintype Q] (ΞΌ p : Q β†’ ℝ) (Ξ· : ℝ) (hΞΌ : βˆ€ q, 0 ≀ ΞΌ q) (hΞΌsum : βˆ‘ q, ΞΌ q = 1) (hΞ· : 0 ≀ Ξ·) (hp : βˆ€ q, p q ≀ 1) (hmean : (72 : ℝ) / 5 * Ξ· ≀ βˆ‘ q, ΞΌ q * p q) : 10 * Ξ· ≀ βˆ‘ q, ΞΌ q * if 4 * Ξ· ≀ p q then 1 else 0 := by classical have hbound : (βˆ‘ q, ΞΌ q * p q) ≀ 4 * Ξ· + βˆ‘ q, ΞΌ q * if 4 * Ξ· ≀ p q then 1 else 0 := by calc _ ≀ βˆ‘ q, ΞΌ q * (4 * Ξ· + if 4 * Ξ· ≀ p q then 1 else 0) := by apply Finset.sum_le_sum intro q _ apply mul_le_mul_of_nonneg_left _ (hΞΌ q) split_ifs with hq Β· linarith [hp q] Β· linarith _ = _ := by simp only [mul_add, Finset.sum_add_distrib, ← Finset.sum_mul, hΞΌsum, one_mul] linarith end FiniteSpectra section ActualMatrixTest variable {Q C E V : Type*} [Fintype Q] [Fintype C] [AddCommGroup E] [Module F2 E] [FiniteDimensional F2 E] [AddCommGroup V] [Module F2 V] [FiniteDimensional F2 V] [Fintype V] [Fintype (E β†’β‚—[F2] F2)] [Fintype (E β†’β‚—[F2] V)] [Fintype (V β†’β‚—[F2] E)] /-- The actual equality test, including zero perturbation factors. -/ def equalityAcceptance (Ξ½ : V β†’ ℝ) (label : (E β†’β‚—[F2] V) β†’ C) : ℝ := by classical exact 𝔼 X, βˆ‘ v, Ξ½ v * (𝔼 l : E β†’β‚—[F2] F2, if label X = label (X + l.smulRight v) then (1 : ℝ) else 0) omit [FiniteDimensional F2 E] [FiniteDimensional F2 V] [Fintype V] [Fintype (E β†’β‚—[F2] F2)] [Fintype (E β†’β‚—[F2] V)] [Fintype (V β†’β‚—[F2] E)] in theorem color_pair_sum (label : (E β†’β‚—[F2] V) β†’ C) (X Y : E β†’β‚—[F2] V) : (βˆ‘ c, colorIndicator label c X * colorIndicator label c Y) = if label X = label Y then (1 : ℝ) else 0 := by classical simp [colorIndicator, eq_comm] /-- Equality acceptance has the actual positive Fourier multiplier. Color indicators give the same equality expansion as output characters, with no extra factor depending on the output alphabet. -/ theorem equalityAcceptance_fourier (Ξ½ : V β†’ ℝ) (label : (E β†’β‚—[F2] V) β†’ C) : equalityAcceptance Ξ½ label = βˆ‘ c, βˆ‘ S : V β†’β‚—[F2] E, linearNoiseEigenvalue Ξ½ S * linearCoeff (colorIndicator label c) S ^ 2 := by classical simp_rw [← linearRealNoiseOperator_energy] rw [← Finset.expect_sum_comm] unfold equalityAcceptance linearRealNoiseOperator apply Finset.expect_congr rfl intro X _ simp_rw [Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro v _ calc Ξ½ v * (𝔼 l : E β†’β‚—[F2] F2, if label X = label (X + l.smulRight v) then (1 : ℝ) else 0) = Ξ½ v * (𝔼 l : E β†’β‚—[F2] F2, βˆ‘ c, colorIndicator label c X * colorIndicator label c (X + l.smulRight v)) := by simp only [color_pair_sum] _ = _ := by rw [Finset.expect_sum_comm, Finset.mul_sum] apply Finset.sum_congr rfl intro c _ rw [← Finset.mul_expect] ring /-- Spectral comparison applied to a genuine family of matrix labelings. The two explicit probability laws may be the latent gadget law and uniform sampling in the distinguished subspace, respectively. -/ theorem matrix_test_comparison (ΞΌ : Q β†’ ℝ) (Ξ½ ρ : V β†’ ℝ) (label : Q β†’ (E β†’β‚—[F2] V) β†’ C) (keep : (V β†’β‚—[F2] E) β†’ Prop) (t : ℝ) (hΞΌ : βˆ€ q, 0 ≀ ΞΌ q) (hΞΌsum : βˆ‘ q, ΞΌ q = 1) (hΞ½ : βˆ€ v, 0 ≀ Ξ½ v) (hΞ½sum : βˆ‘ v, Ξ½ v = 1) (hρ : βˆ€ v, 0 ≀ ρ v) (ht : 0 ≀ t) (hhigh : βˆ€ S : V β†’β‚—[F2] E, Β¬ keep S β†’ linearNoiseEigenvalue Ξ½ S ≀ 7 / 8) (hlow : βˆ€ S : V β†’β‚—[F2] E, keep S β†’ t ≀ linearNoiseEigenvalue ρ S) (haccept : (99 : ℝ) / 100 ≀ βˆ‘ q, ΞΌ q * equalityAcceptance Ξ½ (label q)) : (9 : ℝ) / 10 * t ≀ βˆ‘ q, ΞΌ q * equalityAcceptance ρ (label q) := by have hs (law : V β†’ ℝ) : spectralEnergy (fun qc : Q Γ— C => ΞΌ qc.1) (fun _ S => linearNoiseEigenvalue law S) (labelingCoeff label) = βˆ‘ q, ΞΌ q * equalityAcceptance law (label q) := by simp only [spectralEnergy, labelingCoeff, Fintype.sum_prod_type, equalityAcceptance_fourier, Finset.mul_sum] rw [← hs] at haccept ⊒ apply positive_multiplier_comparison (fun qc : Q Γ— C => ΞΌ qc.1) (labelingCoeff label) (fun _ S => linearNoiseEigenvalue Ξ½ S) (fun _ S => linearNoiseEigenvalue ρ S) (fun _ S => keep S) t Β· exact fun qc => hΞΌ qc.1 Β· exact labelingCoeff_energy_one ΞΌ label hΞΌsum Β· exact ht Β· exact fun _ S => linearNoiseEigenvalue_le_one Ξ½ S hΞ½ hΞ½sum Β· exact fun _ S hS => hhigh S hS Β· exact fun _ S => linearNoiseEigenvalue_nonneg ρ S hρ Β· exact fun _ S hS => hlow S hS Β· exact haccept end ActualMatrixTest section UniformSubspace variable {K V E : Type*} [AddCommGroup K] [Module F2 K] [FiniteDimensional F2 K] [Fintype K] [AddCommGroup V] [Module F2 V] [Fintype V] [AddCommGroup E] [Module F2 E] /-- Pushforward of uniform sampling in `K`. For a subspace inclusion this is uniform sampling in that subspace; the definition also permits a linear map with nontrivial fibers without accidentally conditioning on nonzero vectors. -/ def subspaceLaw (ΞΉ : K β†’β‚—[F2] V) (v : V) : ℝ := by classical exact βˆ‘ k, if ΞΉ k = v then (Fintype.card K : ℝ)⁻¹ else 0 omit [FiniteDimensional F2 K] [Fintype V] in theorem subspaceLaw_nonneg (ΞΉ : K β†’β‚—[F2] V) (v : V) : 0 ≀ subspaceLaw ΞΉ v := by classical unfold subspaceLaw apply Finset.sum_nonneg intro k _ split_ifs <;> positivity omit [FiniteDimensional F2 K] in theorem subspaceLaw_sum (ΞΉ : K β†’β‚—[F2] V) (f : V β†’ ℝ) : (βˆ‘ v, subspaceLaw ΞΉ v * f v) = (Fintype.card K : ℝ)⁻¹ * βˆ‘ k, f (ΞΉ k) := by classical unfold subspaceLaw simp_rw [Finset.sum_mul, ite_mul, zero_mul] rw [Finset.sum_comm] simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] exact (Finset.mul_sum _ _ _).symm omit [FiniteDimensional F2 K] in theorem subspaceLaw_normalized (ΞΉ : K β†’β‚—[F2] V) : βˆ‘ v, subspaceLaw ΞΉ v = 1 := by have h := subspaceLaw_sum ΞΉ (fun _ => 1) simpa [Fintype.card_ne_zero] using h theorem subspaceLaw_eigenvalue (ΞΉ : K β†’β‚—[F2] V) (S : V β†’β‚—[F2] E) : linearNoiseEigenvalue (subspaceLaw ΞΉ) S = ((2 : ℝ) ^ Module.finrank F2 (S.comp ΞΉ).range)⁻¹ := by classical let k := (Finset.univ.filter fun x : K => S (ΞΉ x) = 0).card have hs : (βˆ‘ x : K, if S (ΞΉ x) = 0 then (1 : ℝ) else 0) = (k : ℝ) := by rw [← Finset.sum_filter] simp [k] have hc : (k : ℝ) * (2 : ℝ) ^ Module.finrank F2 (S.comp ΞΉ).range = (Fintype.card K : ℝ) := by have h := congrArg (fun n : β„• => (n : ℝ)) (UniqueGamesTheorem.Gadget.LinearKernelCount.zero_event_finset_count_mul_pow_rank (S.comp ΞΉ)) simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat, LinearMap.comp_apply] using h have hn : (Fintype.card K : ℝ) β‰  0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero have hp : (2 : ℝ) ^ Module.finrank F2 (S.comp ΞΉ).range β‰  0 := pow_ne_zero _ two_ne_zero unfold linearNoiseEigenvalue rw [subspaceLaw_sum, hs] apply mul_right_cancelβ‚€ hp calc ((Fintype.card K : ℝ)⁻¹ * (k : ℝ)) * (2 : ℝ) ^ Module.finrank F2 (S.comp ΞΉ).range = (Fintype.card K : ℝ)⁻¹ * ((k : ℝ) * (2 : ℝ) ^ Module.finrank F2 (S.comp ΞΉ).range) := mul_assoc _ _ _ _ = (Fintype.card K : ℝ)⁻¹ * (Fintype.card K : ℝ) := by rw [hc] _ = 1 := inv_mul_cancelβ‚€ hn _ = ((2 : ℝ) ^ Module.finrank F2 (S.comp ΞΉ).range)⁻¹ * (2 : ℝ) ^ Module.finrank F2 (S.comp ΞΉ).range := (inv_mul_cancelβ‚€ hp).symm theorem subspaceLaw_eigenvalue_lower (ΞΉ : K β†’β‚—[F2] V) (S : V β†’β‚—[F2] E) (r : β„•) (hr : Module.finrank F2 (S.comp ΞΉ).range < r) : ((2 : ℝ) ^ r)⁻¹ ≀ linearNoiseEigenvalue (subspaceLaw ΞΉ) S := by rw [subspaceLaw_eigenvalue, ← one_div, ← one_div] apply one_div_le_one_div_of_le (pow_pos (by norm_num) _) exact pow_le_pow_rightβ‚€ (by norm_num) (Nat.le_of_lt hr) end UniformSubspace section ManuscriptComparison variable {Q C K E V : Type*} [Fintype Q] [Fintype C] [AddCommGroup K] [Module F2 K] [FiniteDimensional F2 K] [Fintype K] [AddCommGroup E] [Module F2 E] [FiniteDimensional F2 E] [AddCommGroup V] [Module F2 V] [FiniteDimensional F2 V] [Fintype V] [Fintype (E β†’β‚—[F2] F2)] [Fintype (E β†’β‚—[F2] V)] [Fintype (V β†’β‚—[F2] E)] theorem matrix_spectral_comparison (ΞΌ : Q β†’ ℝ) (Ξ½ : V β†’ ℝ) (ΞΉ : K β†’β‚—[F2] V) (label : Q β†’ (E β†’β‚—[F2] V) β†’ C) (r : β„•) (hΞΌ : βˆ€ q, 0 ≀ ΞΌ q) (hΞΌsum : βˆ‘ q, ΞΌ q = 1) (hΞ½ : βˆ€ v, 0 ≀ Ξ½ v) (hΞ½sum : βˆ‘ v, Ξ½ v = 1) (hdetect : βˆ€ S : V β†’β‚—[F2] E, r ≀ Module.finrank F2 (S.comp ΞΉ).range β†’ linearNoiseEigenvalue Ξ½ S ≀ 7 / 8) (haccept : (99 : ℝ) / 100 ≀ βˆ‘ q, ΞΌ q * equalityAcceptance Ξ½ (label q)) : (9 : ℝ) / 10 * ((2 : ℝ) ^ r)⁻¹ ≀ βˆ‘ q, ΞΌ q * equalityAcceptance (subspaceLaw ΞΉ) (label q) := by apply matrix_test_comparison ΞΌ Ξ½ (subspaceLaw ΞΉ) label (fun S => Module.finrank F2 (S.comp ΞΉ).range < r) ((2 : ℝ) ^ r)⁻¹ hΞΌ hΞΌsum hΞ½ hΞ½sum (subspaceLaw_nonneg ΞΉ) Β· positivity Β· intro S hS exact hdetect S (Nat.le_of_not_gt hS) Β· intro S hS exact subspaceLaw_eigenvalue_lower ΞΉ S r hS Β· exact haccept end ManuscriptComparison end UniqueGamesTheorem.Decoder.PositiveMultiplier end end section noncomputable section namespace UniqueGamesTheorem.Decoder.PrivateFourier open UniqueGamesTheorem.Fourier.MatrixCharacters open UniqueGamesTheorem.Fourier.MatrixFourier open UniqueGamesTheorem.Fourier.MatrixParity open UniqueGamesTheorem.Fourier.MatrixParityRow open scoped BigOperators Classical section Signs /-- A real-valued binary character, with the uniform Fourier normalization. -/ def sign (a : F2) : ℝ := (binarySign a).re @[simp] theorem sign_zero : sign 0 = 1 := by simp [sign] @[simp] theorem sign_one : sign 1 = -1 := by simp [sign] theorem sign_sq (a : F2) : sign a ^ 2 = 1 := by rcases Integration.BinaryLinear.scalar_cases a with rfl | rfl <;> simp @[simp] theorem sign_abs (a : F2) : |sign a| = 1 := by rcases Integration.BinaryLinear.scalar_cases a with rfl | rfl <;> simp theorem sign_add (a b : F2) : sign (a + b) = sign a * sign b := by simp [sign, binarySign_add, Complex.mul_re] theorem sign_add_one (a : F2) : sign (a + 1) = -sign a := by rw [sign_add, sign_one] ring end Signs section CharacterAverages variable {H K : Type*} [AddCommGroup H] [Module F2 H] [AddCommGroup K] [Module F2 K] theorem binary_neg_eq_self (x : K) : -x = x := by have htwo : (1 + 1 : F2) = 0 := by decide have hh := congrArg (fun a : F2 => a β€’ x) htwo exact neg_eq_iff_add_eq_zero.mpr (by simpa only [add_smul, one_smul, zero_smul] using hh) theorem binary_add_eq_zero_iff (x y : K) : x + y = 0 ↔ x = y := by rw [add_eq_zero_iff_eq_neg, binary_neg_eq_self] theorem average_sign_dual [Fintype (K β†’β‚—[F2] F2)] (x : K) : (𝔼 Οƒ : K β†’β‚—[F2] F2, sign (Οƒ x)) = if x = 0 then 1 else 0 := by have h := congrArg Complex.re (UniqueGamesTheorem.Fourier.MatrixNoise.average_evaluationCharacter x) simpa only [Complex.re_expect, apply_ite, Complex.one_re, Complex.zero_re, sign] using h theorem average_sign_primal [Fintype H] (Οƒ : H β†’β‚—[F2] F2) : (𝔼 h : H, sign (Οƒ h)) = if Οƒ = 0 then 1 else 0 := by have h := congrArg Complex.re (expect_linearFunctionalCharacter Οƒ) simpa only [Complex.re_expect, apply_ite, Complex.one_re, Complex.zero_re, linearFunctionalCharacter_apply, sign] using h /-- Exact character expansion of equality in the actual output space. -/ theorem average_sign_equality [Fintype (K β†’β‚—[F2] F2)] (x y : K) : (𝔼 Οƒ : K β†’β‚—[F2] F2, sign (Οƒ x) * sign (Οƒ y)) = if x = y then 1 else 0 := by simp_rw [← sign_add, ← map_add] rw [average_sign_dual, binary_add_eq_zero_iff] /-- The ambient uniform character has trivial restriction to `H` with exactly the reciprocal cardinality of `H`. No conditioning on the private character is substituted for the real experiment. -/ theorem trivial_restriction_probability [Fintype H] [Fintype (K β†’β‚—[F2] F2)] (ΞΉ : H β†’β‚—[F2] K) (hΞΉ : Function.Injective ΞΉ) : (𝔼 Οƒ : K β†’β‚—[F2] F2, if Οƒ.comp ΞΉ = 0 then (1 : ℝ) else 0) = 1 / (Fintype.card H : ℝ) := by calc _ = 𝔼 Οƒ : K β†’β‚—[F2] F2, 𝔼 h : H, sign (Οƒ (ΞΉ h)) := by apply Finset.expect_congr rfl intro Οƒ _ exact (average_sign_primal (Οƒ.comp ΞΉ)).symm _ = 𝔼 h : H, 𝔼 Οƒ : K β†’β‚—[F2] F2, sign (Οƒ (ΞΉ h)) := Finset.expect_comm _ _ _ _ = 𝔼 h : H, if h = 0 then (1 : ℝ) else 0 := by apply Finset.expect_congr rfl intro h _ rw [average_sign_dual] have heq : ΞΉ h = 0 ↔ h = 0 := by rw [← map_zero ΞΉ] exact hΞΉ.eq_iff rw [heq] _ = _ := by simp theorem trivial_restriction_probability_pow [Fintype H] [FiniteDimensional F2 H] [Fintype (K β†’β‚—[F2] F2)] (ΞΉ : H β†’β‚—[F2] K) (hΞΉ : Function.Injective ΞΉ) : (𝔼 Οƒ : K β†’β‚—[F2] F2, if Οƒ.comp ΞΉ = 0 then (1 : ℝ) else 0) = 1 / (2 : ℝ) ^ Module.finrank F2 H := by rw [trivial_restriction_probability ΞΉ hΞΉ] have hc : Fintype.card H = 2 ^ Module.finrank F2 H := by simpa [F2, Integration.BinaryLinear.F2, ZMod.card] using Module.card_fintype (Module.finBasis F2 H) rw [hc] norm_cast end CharacterAverages section ActualFourier variable {E H K : Type*} variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] variable [AddCommGroup K] [Module F2 K] variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] variable [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] /-- The private sign function, formed from the table on one visible row fiber. -/ def tableSign (F : (E β†’β‚—[F2] H) β†’ K) (Οƒ : K β†’β‚—[F2] F2) (N : E β†’β‚—[F2] H) : ℝ := sign (Οƒ (F N)) /-- The actual probability assigned to a reverse-map frequency. -/ def frequencyWeight (f : (E β†’β‚—[F2] H) β†’ ℝ) (Ξ¦ : H β†’β‚—[F2] E) : ℝ := linearCoeff f Ξ¦ ^ 2 omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [Fintype (H β†’β‚—[F2] E)] in theorem frequencyWeight_nonneg (f : (E β†’β‚—[F2] H) β†’ ℝ) (Ξ¦ : H β†’β‚—[F2] E) : 0 ≀ frequencyWeight f Ξ¦ := sq_nonneg _ /-- Squared Fourier coefficients of the private sign form a probability law. -/ theorem tableSign_frequencyWeight_sum (F : (E β†’β‚—[F2] H) β†’ K) (Οƒ : K β†’β‚—[F2] F2) : βˆ‘ Ξ¦ : H β†’β‚—[F2] E, frequencyWeight (tableSign F Οƒ) Ξ¦ = 1 := by simp only [frequencyWeight, linear_parseval, tableSign, sign_sq] exact Fintype.expect_const 1 omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] in theorem tableSign_antifold (F : (E β†’β‚—[F2] H) β†’ K) (ΞΉ : H β†’β‚—[F2] K) (Ο„ : E β†’β‚—[F2] F2) (Οƒ : K β†’β‚—[F2] F2) (h : H) (folded : βˆ€ N, F (N + Ο„.smulRight h) = F N + ΞΉ h) (hΟƒ : Οƒ (ΞΉ h) = 1) : βˆ€ N, tableSign F Οƒ (N + Ο„.smulRight h) = -tableSign F Οƒ N := by intro N simp only [tableSign, folded, map_add, hΟƒ, sign_add_one] omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [Fintype (H β†’β‚—[F2] E)] in /-- Translation of the input multiplies a coefficient by its character. -/ theorem linearCoeff_translate (f : (E β†’β‚—[F2] H) β†’ ℝ) (D : E β†’β‚—[F2] H) (Ξ¦ : H β†’β‚—[F2] E) : linearCoeff (fun N => f (N + D)) Ξ¦ = linearCoeff f Ξ¦ * (linearTraceCharacter Ξ¦ D).re := by have hself : D + D = 0 := (linearMap_add_eq_zero_iff D D).2 rfl have hchange := Fintype.expect_equiv (Equiv.addRight D) (fun N => f (N + D) * (linearTraceCharacter Ξ¦ N).re) (fun N => f N * (linearTraceCharacter Ξ¦ (N + D)).re) (fun N => by simp only [Equiv.coe_addRight, add_assoc, hself, add_zero]) unfold linearCoeff rw [hchange] simp only [traceCharacter_re_add, ← mul_assoc] exact (Finset.expect_mul _ _ _).symm omit [FiniteDimensional F2 E] [Fintype (H β†’β‚—[F2] E)] in /-- Anti-folding forces every positive-mass frequency to return first bit one. -/ theorem positive_frequency_first_bit (f : (E β†’β‚—[F2] H) β†’ ℝ) (Ο„ : E β†’β‚—[F2] F2) (h : H) (Ξ¦ : H β†’β‚—[F2] E) (folded : βˆ€ N, f (N + Ο„.smulRight h) = -f N) (positive : 0 < frequencyWeight f Ξ¦) : Ο„ (Ξ¦ h) = 1 := by have hcoeff : linearCoeff f Ξ¦ β‰  0 := by intro hz simp [frequencyWeight, hz] at positive have heq := linearCoeff_translate f (Ο„.smulRight h) Ξ¦ have hneg : linearCoeff (fun N => f (N + Ο„.smulRight h)) Ξ¦ = -linearCoeff f Ξ¦ := by simp only [linearCoeff, folded, neg_mul] simp [Fintype.expect_eq_sum_div_card] rw [hneg] at heq have hchar : (linearTraceCharacter Ξ¦ (Ο„.smulRight h)).re = sign (Ο„ (Ξ¦ h)) := by simp only [linearTraceCharacter_apply, linearTracePair, trace_smulRight_comp, sign] rw [hchar] at heq rcases Integration.BinaryLinear.scalar_cases (Ο„ (Ξ¦ h)) with hz | hone Β· rw [hz, sign_zero, mul_one] at heq exact False.elim (hcoeff (by linarith)) Β· exact hone end ActualFourier section AffineSlice variable {E H V : Type*} variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] variable [AddCommGroup V] [Module F2 V] variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] [FiniteDimensional F2 V] variable [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] variable [Fintype (V β†’β‚—[F2] H)] /-- Frequencies in the affine target's annihilator coset. With `q = Q.mkQ`, this is exactly `ΞΈ + Hom(H,Q)` in the ambient reverse-map space. -/ def frequencyCoset (q : E β†’β‚—[F2] V) (ΞΈ : H β†’β‚—[F2] E) : Finset (H β†’β‚—[F2] E) := Finset.univ.filter fun Ξ¦ => q.comp (Ξ¦ + ΞΈ) = 0 /-- Correlation on a genuine affine slice. `Nβ‚€` is retained: its phase cannot be discarded when the witness has a nonzero affine intercept. -/ def sliceCorrelation (q : E β†’β‚—[F2] V) (Nβ‚€ : E β†’β‚—[F2] H) (f : (E β†’β‚—[F2] H) β†’ ℝ) (ΞΈ : H β†’β‚—[F2] E) : ℝ := 𝔼 A : V β†’β‚—[F2] H, f (Nβ‚€ + A.comp q) * (linearTraceCharacter ΞΈ (Nβ‚€ + A.comp q)).re omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] in theorem traceCharacter_re_mul (Ξ¦ ΞΈ : H β†’β‚—[F2] E) (N : E β†’β‚—[F2] H) : (linearTraceCharacter Ξ¦ N).re * (linearTraceCharacter ΞΈ N).re = (linearTraceCharacter (Ξ¦ + ΞΈ) N).re := by rw [linearTraceCharacter_add, AddChar.add_apply, Complex.mul_re] simp [linearTraceCharacter_apply] /-- The exact Fourier coset expansion of the affine conditional correlation. -/ theorem sliceCorrelation_eq_coset (q : E β†’β‚—[F2] V) (Nβ‚€ : E β†’β‚—[F2] H) (f : (E β†’β‚—[F2] H) β†’ ℝ) (ΞΈ : H β†’β‚—[F2] E) : sliceCorrelation q Nβ‚€ f ΞΈ = βˆ‘ Ξ¦ ∈ frequencyCoset q ΞΈ, linearCoeff f Ξ¦ * (linearTraceCharacter (Ξ¦ + ΞΈ) Nβ‚€).re := by unfold sliceCorrelation calc _ = 𝔼 A : V β†’β‚—[F2] H, βˆ‘ Ξ¦ : H β†’β‚—[F2] E, linearCoeff f Ξ¦ * (linearTraceCharacter (Ξ¦ + ΞΈ) (Nβ‚€ + A.comp q)).re := by apply Finset.expect_congr rfl intro A _ rw [← linear_fourier_inversion f (Nβ‚€ + A.comp q), Finset.sum_mul] apply Finset.sum_congr rfl intro Ξ¦ _ rw [mul_assoc, traceCharacter_re_mul] _ = βˆ‘ Ξ¦ : H β†’β‚—[F2] E, if q.comp (Ξ¦ + ΞΈ) = 0 then linearCoeff f Ξ¦ * (linearTraceCharacter (Ξ¦ + ΞΈ) Nβ‚€).re else 0 := by rw [Finset.expect_sum_comm] apply Finset.sum_congr rfl intro Ξ¦ _ simp only [traceCharacter_re_add, ← mul_assoc] rw [← Finset.mul_expect, row_character_average] split <;> simp _ = _ := by simp [frequencyCoset, Finset.sum_filter] /-- Cauchy--Schwarz bounds an affine correlation by the actual Fourier mass in its target coset; no spectral mass is assumed. -/ theorem sliceCorrelation_sq_le_coset_mass (q : E β†’β‚—[F2] V) (Nβ‚€ : E β†’β‚—[F2] H) (f : (E β†’β‚—[F2] H) β†’ ℝ) (ΞΈ : H β†’β‚—[F2] E) : sliceCorrelation q Nβ‚€ f ΞΈ ^ 2 ≀ (frequencyCoset q ΞΈ).card * βˆ‘ Ξ¦ ∈ frequencyCoset q ΞΈ, frequencyWeight f Ξ¦ := by rw [sliceCorrelation_eq_coset] have hcs := Finset.sum_mul_sq_le_sq_mul_sq (frequencyCoset q ΞΈ) (linearCoeff f) (fun Ξ¦ => (linearTraceCharacter (Ξ¦ + ΞΈ) Nβ‚€).re) have hs : βˆ€ Ξ¦ : H β†’β‚—[F2] E, (linearTraceCharacter (Ξ¦ + ΞΈ) Nβ‚€).re ^ 2 = 1 := by intro Ξ¦ exact sign_sq _ simpa only [hs, Finset.sum_const, nsmul_eq_mul, mul_one, one_mul, frequencyWeight, mul_comm] using hcs end AffineSlice section AffineEquality variable {E H K V : Type*} variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] variable [AddCommGroup K] [Module F2 K] [AddCommGroup V] [Module F2 V] variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] [FiniteDimensional F2 V] variable [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] variable [Fintype (V β†’β‚—[F2] H)] [Fintype (K β†’β‚—[F2] F2)] omit [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] in /-- The pure-tensor target character is literally evaluation at `z`. -/ theorem target_character (Οƒ : H β†’β‚—[F2] F2) (z : E) (N : E β†’β‚—[F2] H) : (linearTraceCharacter (Οƒ.smulRight z) N).re = sign (Οƒ (N z)) := by simp only [linearTraceCharacter_apply, sign] congr 2 rw [linearTracePair_swap] exact trace_smulRight_comp Οƒ z N omit [FiniteDimensional F2 V] [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] in /-- Affine target equality expands into the correlations with the intercept phase `sign (Οƒ b)`. In the projected experiment `b = Mβ‚€ z + u`. -/ theorem affine_equality_character_expansion (q : E β†’β‚—[F2] V) (Nβ‚€ : E β†’β‚—[F2] H) (F : (E β†’β‚—[F2] H) β†’ K) (ΞΉ : H β†’β‚—[F2] K) (z : E) (b : K) : (𝔼 A : V β†’β‚—[F2] H, if F (Nβ‚€ + A.comp q) = b + ΞΉ ((Nβ‚€ + A.comp q) z) then (1 : ℝ) else 0) = 𝔼 Οƒ : K β†’β‚—[F2] F2, sign (Οƒ b) * sliceCorrelation q Nβ‚€ (tableSign F Οƒ) ((Οƒ.comp ΞΉ).smulRight z) := by calc _ = 𝔼 A : V β†’β‚—[F2] H, 𝔼 Οƒ : K β†’β‚—[F2] F2, sign (Οƒ (F (Nβ‚€ + A.comp q))) * sign (Οƒ (b + ΞΉ ((Nβ‚€ + A.comp q) z))) := by apply Finset.expect_congr rfl intro A _ exact (average_sign_equality _ _).symm _ = 𝔼 Οƒ : K β†’β‚—[F2] F2, 𝔼 A : V β†’β‚—[F2] H, sign (Οƒ (F (Nβ‚€ + A.comp q))) * sign (Οƒ (b + ΞΉ ((Nβ‚€ + A.comp q) z))) := Finset.expect_comm _ _ _ _ = _ := by apply Finset.expect_congr rfl intro Οƒ _ unfold sliceCorrelation rw [Finset.mul_expect] apply Finset.expect_congr rfl intro A _ simp only [map_add, sign_add, target_character, tableSign, LinearMap.comp_apply] ring omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [FiniteDimensional F2 V] [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] [Fintype (K β†’β‚—[F2] F2)] in /-- Every slice correlation has absolute value at most one. -/ theorem sliceCorrelation_tableSign_abs_le_one (q : E β†’β‚—[F2] V) (Nβ‚€ : E β†’β‚—[F2] H) (F : (E β†’β‚—[F2] H) β†’ K) (Οƒ : K β†’β‚—[F2] F2) (ΞΈ : H β†’β‚—[F2] E) : |sliceCorrelation q Nβ‚€ (tableSign F Οƒ) ΞΈ| ≀ 1 := by unfold sliceCorrelation calc _ ≀ 𝔼 A : V β†’β‚—[F2] H, |tableSign F Οƒ (Nβ‚€ + A.comp q) * (linearTraceCharacter ΞΈ (Nβ‚€ + A.comp q)).re| := Finset.abs_expect_le _ _ _ = 1 := by have hp (N : E β†’β‚—[F2] H) : |(linearTraceCharacter ΞΈ N).re| = 1 := sign_abs _ simp only [abs_mul, tableSign, sign_abs, hp, mul_one] exact Fintype.expect_const 1 omit [FiniteDimensional F2 V] [Fintype (E β†’β‚—[F2] H)] [Fintype (H β†’β‚—[F2] E)] in /-- Dropping the unit intercept phase can only increase the average absolute correlation; the hypothesis is the actual affine-slice agreement probability. -/ theorem agreement_le_average_abs_correlation (q : E β†’β‚—[F2] V) (Nβ‚€ : E β†’β‚—[F2] H) (F : (E β†’β‚—[F2] H) β†’ K) (ΞΉ : H β†’β‚—[F2] K) (z : E) (b : K) : (𝔼 A : V β†’β‚—[F2] H, if F (Nβ‚€ + A.comp q) = b + ΞΉ ((Nβ‚€ + A.comp q) z) then (1 : ℝ) else 0) ≀ 𝔼 Οƒ : K β†’β‚—[F2] F2, |sliceCorrelation q Nβ‚€ (tableSign F Οƒ) ((Οƒ.comp ΞΉ).smulRight z)| := by rw [affine_equality_character_expansion] apply Finset.expect_le_expect intro Οƒ _ calc _ ≀ |sign (Οƒ b) * sliceCorrelation q Nβ‚€ (tableSign F Οƒ) ((Οƒ.comp ΞΉ).smulRight z)| := le_abs_self _ _ = _ := by rw [abs_mul, sign_abs, one_mul] end AffineEquality section CosetCardinality variable {E H : Type*} variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] variable [Fintype (H β†’β‚—[F2] E)] /-- The exact number of frequencies in the affine coset. Translation does not alter the annihilator cardinality, including when the target is nonzero. -/ theorem frequencyCoset_card (Q : Submodule F2 E) [Fintype (H β†’β‚—[F2] Q)] (ΞΈ : H β†’β‚—[F2] E) : (frequencyCoset Q.mkQ ΞΈ).card = 2 ^ (Module.finrank F2 H * Module.finrank F2 Q) := by classical rw [frequencyCoset, ← Fintype.card_subtype] calc Fintype.card {Ξ¦ : H β†’β‚—[F2] E // Q.mkQ.comp (Ξ¦ + ΞΈ) = 0} = Fintype.card {Ξ¦ : H β†’β‚—[F2] E // Q.mkQ.comp Ξ¦ = 0} := Fintype.card_congr (Equiv.subtypeEquiv (Equiv.addRight ΞΈ) (fun _ => Iff.rfl)) _ = Fintype.card (H β†’β‚—[F2] Q) := UniqueGamesTheorem.Fourier.MatrixRestrictions.quotientKernel_card Q _ = _ := card_linearMaps theorem frequencyCoset_card_le (Q : Submodule F2 E) [Fintype (H β†’β‚—[F2] Q)] (ΞΈ : H β†’β‚—[F2] E) (β„“ r : β„•) (hH : Module.finrank F2 H ≀ β„“) (hQ : Module.finrank F2 Q ≀ r) : (frequencyCoset Q.mkQ ΞΈ).card ≀ 2 ^ (β„“ * r) := by rw [frequencyCoset_card] exact Nat.pow_le_pow_right (by decide : 0 < 2) (Nat.mul_le_mul hH hQ) end CosetCardinality section Averaging variable {SigmaChar : Type*} [Fintype SigmaChar] [Nonempty SigmaChar] omit [Nonempty SigmaChar] in /-- Discarding a set of characters costs at most its actual uniform mass. -/ theorem remove_bad_characters (C : SigmaChar β†’ ℝ) (good : SigmaChar β†’ Prop) (a b : ℝ) (hC : βˆ€ Οƒ, |C Οƒ| ≀ 1) (hcorrelation : a ≀ 𝔼 Οƒ, |C Οƒ|) (hbad : (𝔼 Οƒ, if good Οƒ then (0 : ℝ) else 1) ≀ b) : a - b ≀ 𝔼 Οƒ, if good Οƒ then |C Οƒ| else 0 := by classical have hp : (𝔼 Οƒ, |C Οƒ|) ≀ (𝔼 Οƒ, if good Οƒ then |C Οƒ| else 0) + (𝔼 Οƒ, if good Οƒ then (0 : ℝ) else 1) := by rw [← Finset.expect_add_distrib] apply Finset.expect_le_expect intro Οƒ _ by_cases hg : good Οƒ Β· simp [hg] Β· simpa [hg] using hC Οƒ linarith /-- The second Cauchy--Schwarz step in private decoding. The first step is `sliceCorrelation_sq_le_coset_mass`; the mass is the actual sampled Fourier mass and `good` selects nontrivial output characters. -/ theorem average_coset_mass_lower (C mass : SigmaChar β†’ ℝ) (good : SigmaChar β†’ Prop) (N c : ℝ) (hN : 0 < N) (hc : 0 ≀ c) (hcorrelation : c ≀ 𝔼 Οƒ, if good Οƒ then |C Οƒ| else 0) (hpoint : βˆ€ Οƒ, good Οƒ β†’ C Οƒ ^ 2 ≀ N * mass Οƒ) : c ^ 2 / N ≀ 𝔼 Οƒ, if good Οƒ then mass Οƒ else 0 := by classical let d : SigmaChar β†’ ℝ := fun Οƒ => if good Οƒ then |C Οƒ| else 0 have hj := Finset.expect_mul_sq_le_sq_mul_sq Finset.univ d (fun _ => (1 : ℝ)) simp only [mul_one, one_pow, Fintype.expect_const] at hj have hp : (𝔼 Οƒ, d Οƒ ^ 2) ≀ N * (𝔼 Οƒ, if good Οƒ then mass Οƒ else 0) := by rw [Finset.mul_expect] apply Finset.expect_le_expect intro Οƒ _ by_cases hg : good Οƒ Β· simpa [d, hg, sq_abs] using hpoint Οƒ hg Β· simp [d, hg] have hs : c ^ 2 ≀ (𝔼 Οƒ, d Οƒ) ^ 2 := by have hd : c ≀ 𝔼 Οƒ, d Οƒ := hcorrelation nlinarith apply (div_le_iffβ‚€ hN).2 nlinarith end Averaging section Contraction variable {E H : Type*} [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] /-- A frequency in the target coset contracts into `z + Q`. -/ theorem contraction_mem_target_coset (Q : Submodule F2 E) (Οƒ : H β†’β‚—[F2] F2) (z : E) (Ξ¦ : H β†’β‚—[F2] E) (h : H) (hΟƒ : Οƒ h = 1) (hcoset : Q.mkQ.comp (Ξ¦ + Οƒ.smulRight z) = 0) : Ξ¦ h - z ∈ Q := by have hq := LinearMap.congr_fun hcoset h simp only [LinearMap.comp_apply, LinearMap.add_apply, LinearMap.smulRight_apply, hΟƒ, one_smul, LinearMap.zero_apply] at hq have hmem : Ξ¦ h + z ∈ Q := by change Q.mkQ (Ξ¦ h + z) = 0 at hq exact (Submodule.Quotient.mk_eq_zero Q).mp hq have hz : -z = z := by have htwo : (1 + 1 : F2) = 0 := by decide have hzz : z + z = 0 := by have hh := congrArg (fun a : F2 => a β€’ z) htwo simpa only [add_smul, one_smul, zero_smul] using hh exact neg_eq_iff_add_eq_zero.mpr hzz simpa only [sub_eq_add_neg, hz] using hmem end Contraction section IndependentSampling variable {U O Ξ© : Type*} [Fintype Ξ©] /-- If the returned projected answer has a preimage in the candidate set, the uniform, independently sampled candidate finds a preimage with this probability. -/ theorem uniform_preimage_probability (s : Finset U) (Ο€ : U β†’ O) (b : O) (preimage : βˆƒ u ∈ s, Ο€ u = b) : 1 / (s.card : ℝ) ≀ 𝔼 u ∈ s, if Ο€ u = b then (1 : ℝ) else 0 := by classical obtain ⟨u, hu, hΟ€βŸ© := preimage have hsum : (1 : ℝ) ≀ βˆ‘ v ∈ s, if Ο€ v = b then (1 : ℝ) else 0 := by have hnonneg : βˆ€ v ∈ s, (0 : ℝ) ≀ if Ο€ v = b then 1 else 0 := by intro v _ split <;> norm_num have h := Finset.single_le_sum hnonneg hu simpa only [hΟ€, ite_true] using h rw [Finset.expect_eq_sum_div_card] exact div_le_div_of_nonneg_right hsum (Nat.cast_nonneg _) /-- An explicit product sampling law: the left strategy samples uniformly from `s`, independently of the right strategy's private sample. Only positive-mass good samples need a preimage; no private Fourier information is passed left. -/ theorem independent_agreement_lower (s : Finset U) (Ο€ : U β†’ O) (answer : Ξ© β†’ O) (weight : Ξ© β†’ ℝ) (good : Ξ© β†’ Prop) (hweight : βˆ€ Ο‰, 0 ≀ weight Ο‰) (preimage : βˆ€ Ο‰, good Ο‰ β†’ 0 < weight Ο‰ β†’ βˆƒ u ∈ s, Ο€ u = answer Ο‰) : (βˆ‘ Ο‰, if good Ο‰ then weight Ο‰ else 0) / (s.card : ℝ) ≀ βˆ‘ Ο‰, weight Ο‰ * (𝔼 u ∈ s, if Ο€ u = answer Ο‰ then (1 : ℝ) else 0) := by classical rw [Finset.sum_div] apply Finset.sum_le_sum intro Ο‰ _ have havg : 0 ≀ 𝔼 u ∈ s, if Ο€ u = answer Ο‰ then (1 : ℝ) else 0 := Finset.expect_nonneg fun _ _ => by positivity by_cases hg : good Ο‰ Β· simp only [hg, ite_true] by_cases hw : 0 < weight Ο‰ Β· have hb := uniform_preimage_probability s Ο€ (answer Ο‰) (preimage Ο‰ hg hw) have := mul_le_mul_of_nonneg_left hb (hweight Ο‰) simpa only [div_eq_mul_inv, one_mul] using this Β· have hz : weight Ο‰ = 0 := le_antisymm (le_of_not_gt hw) (hweight Ο‰) simp [hz] Β· simp only [hg, ite_false, zero_div] exact mul_nonneg (hweight Ο‰) havg end IndependentSampling end UniqueGamesTheorem.Decoder.PrivateFourier end end end OAI
import Mathlib.Algebra.BigOperators.Field
import Mathlib.Algebra.Order.BigOperators.Expect
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
import OAI.Computability.UniqueGames.Analysis.MatrixEnergy
import OAI.Computability.UniqueGames.Analysis.MatrixNoiseLemmas
import OAI.Computability.UniqueGames.Analysis.MatrixParityRow
import OAI.Computability.UniqueGames.Analysis.MatrixRestrictions
import OAI.Computability.UniqueGames.Gadgets.AdaptivePathsLemmas
namespace OAI
section
/-!
# Exact visible row advice and private matrix coordinates
Every nonempty fiber of `M ↦ A ∘ M` is an affine copy of
`Hom(E, ker A)`, whether or not `A` is surjective. Choosing one base matrix
for each attainable row gives a product decomposition of the complete matrix
space. Uniform sampling therefore makes visible row advice and the hidden
kernel-valued matrix independent.
-/
noncomputable section
open scoped BigOperators
open UniqueGamesTheorem.Integration.BinaryLinear
namespace UniqueGamesTheorem.Decoder.AdviceFibers
variable {E K R : Type*}
[AddCommGroup E] [Module F2 E]
[AddCommGroup K] [Module F2 K]
[AddCommGroup R] [Module F2 R]
/-- Actual matrices with the specified observed row advice. -/
abbrev RowFiber (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R) :=
{M : E β†’β‚—[F2] K // A.comp M = S}
/-- Hidden coordinates relative to one base matrix in the same row fiber. -/
def kernelDifference (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R)
(Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) (M : RowFiber A S) :
E β†’β‚—[F2] A.ker :=
(M.val - Mβ‚€).codRestrict A.ker (by
intro x
change A (M.val x - Mβ‚€ x) = 0
rw [map_sub]
have hM := LinearMap.congr_fun M.property x
have hbase := LinearMap.congr_fun hβ‚€ x
change A (M.val x) = S x at hM
change A (Mβ‚€ x) = S x at hbase
rw [hM, hbase, sub_self])
@[simp] theorem kernelDifference_apply (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R)
(Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) (M : RowFiber A S) (x : E) :
(kernelDifference A S Mβ‚€ hβ‚€ M x : K) = M.val x - Mβ‚€ x := rfl
/-- Reassemble an actual matrix from its fixed visible base and private part. -/
def assemble (A : K β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K)
(N : E β†’β‚—[F2] A.ker) : E β†’β‚—[F2] K :=
Mβ‚€ + A.ker.subtype.comp N
@[simp] theorem assemble_apply (A : K β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K)
(N : E β†’β‚—[F2] A.ker) (x : E) :
assemble A Mβ‚€ N x = Mβ‚€ x + (N x : K) := rfl
/-- Observed advice is completely unchanged by the private coordinates. -/
theorem observed_assemble (A : K β†’β‚—[F2] R) (Mβ‚€ : E β†’β‚—[F2] K)
(N : E β†’β‚—[F2] A.ker) : A.comp (assemble A Mβ‚€ N) = A.comp Mβ‚€ := by
ext x
have hN : A (N x : K) = 0 := (N x).property
simp only [LinearMap.comp_apply, assemble_apply, map_add, hN, add_zero]
/-- The exact row-fiber bijection; no rank or surjectivity premise is needed. -/
def rowFiberEquiv (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R)
(Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) :
(E β†’β‚—[F2] A.ker) ≃ RowFiber A S where
toFun N := ⟨assemble A Mβ‚€ N, (observed_assemble A Mβ‚€ N).trans hβ‚€βŸ©
invFun := kernelDifference A S Mβ‚€ hβ‚€
left_inv N := by
apply LinearMap.ext
intro x
apply Subtype.ext
change Mβ‚€ x + (N x : K) - Mβ‚€ x = (N x : K)
exact add_sub_cancel_left _ _
right_inv M := by
apply Subtype.ext
ext x
change Mβ‚€ x + (M.val x - Mβ‚€ x) = M.val x
simpa only [← add_sub_assoc] using add_sub_cancel_left (Mβ‚€ x) (M.val x)
@[simp] theorem rowFiberEquiv_coe (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R)
(Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) (N : E β†’β‚—[F2] A.ker) :
(rowFiberEquiv A S Mβ‚€ hβ‚€ N).val = assemble A Mβ‚€ N := rfl
@[simp] theorem rowFiberEquiv_symm (A : K β†’β‚—[F2] R) (S : E β†’β‚—[F2] R)
(Mβ‚€ : E β†’β‚—[F2] K) (hβ‚€ : A.comp Mβ‚€ = S) (M : RowFiber A S) :
(rowFiberEquiv A S Mβ‚€ hβ‚€).symm M = kernelDifference A S Mβ‚€ hβ‚€ M := rfl
/-- Affine target intercepts are retained in the private coordinates. -/