Download data/lean/OAI/Computability/UniqueGames/Analysis/MatrixEnergy.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 31.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixEnergy.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixEnergy.lean
-
curl -L -o MatrixEnergy.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixEnergy.lean
31.7 kB
| import Mathlib.Algebra.Order.BigOperators.Expect | |
| import Mathlib.Basic.Real.Basic | |
| import Mathlib.Tactic.FieldSimp | |
| import Mathlib.Tactic.Linarith | |
| import Mathlib.Tactic.Ring | |
| import OAI.Computability.UniqueGames.Analysis.MatrixCharactersLemmas | |
| import OAI.Computability.UniqueGames.Analysis.MatrixRestrictions | |
| import OAI.Computability.UniqueGames.Analysis.MatrixSubspaceCount | |
| namespace OAI | |
| section | |
| namespace UniqueGamesTheorem.Fourier.MatrixEnergy | |
| open scoped BigOperators | |
| variable {Q : Type*} {I : Q β Type*} [Fintype Q] [β q, Fintype (I q)] | |
| /-- Squared coefficient energy, averaged using the supplied question weights. -/ | |
| noncomputable def energy (weight : Q β β) (a : (q : Q) β I q β β) : β := | |
| β q, weight q * β i, a q i ^ 2 | |
| /-- Squared energy retained by a coordinate projection. -/ | |
| noncomputable def cutoffEnergy (weight : Q β β) (keep : (q : Q) β I q β Prop) | |
| (a : (q : Q) β I q β β) : β := by | |
| classical | |
| exact β q, weight q * β i, if keep q i then a q i ^ 2 else 0 | |
| /-- Diagonal spectral quadratic form. -/ | |
| noncomputable def spectralEnergy (weight : Q β β) (eigen a : (q : Q) β I q β β) : β := | |
| β q, weight q * β i, eigen q i * a q i ^ 2 | |
| theorem energy_nonneg (weight : Q β β) (a : (q : Q) β I q β β) | |
| (hw : β q, 0 β€ weight q) : 0 β€ energy weight a := by | |
| exact Finset.sum_nonneg (fun q _ => mul_nonneg (hw q) | |
| (Finset.sum_nonneg (fun i _ => sq_nonneg (a q i)))) | |
| theorem cutoffEnergy_nonneg (weight : Q β β) (keep : (q : Q) β I q β Prop) | |
| (a : (q : Q) β I q β β) (hw : β q, 0 β€ weight q) : | |
| 0 β€ cutoffEnergy weight keep a := by | |
| classical | |
| unfold cutoffEnergy | |
| apply Finset.sum_nonneg | |
| intro q _ | |
| apply mul_nonneg (hw q) | |
| apply Finset.sum_nonneg | |
| intro i _ | |
| split_ifs | |
| Β· exact sq_nonneg _ | |
| Β· exact le_rfl | |
| /-- The projection onto any set of coefficient indices is a contraction in | |
| the weighted squared norm. -/ | |
| theorem cutoffEnergy_le_energy (weight : Q β β) (keep : (q : Q) β I q β Prop) | |
| (a : (q : Q) β I q β β) (hw : β q, 0 β€ weight q) : | |
| cutoffEnergy weight keep a β€ energy weight a := by | |
| classical | |
| apply Finset.sum_le_sum | |
| intro q _ | |
| apply mul_le_mul_of_nonneg_left _ (hw q) | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| split_ifs <;> nlinarith [sq_nonneg (a q i)] | |
| /-- Retained and discarded coefficient coordinates are orthogonal: their | |
| energies add exactly to the original energy. -/ | |
| theorem energy_split (weight : Q β β) (keep : (q : Q) β I q β Prop) (a : (q : Q) β I q β β) : | |
| energy weight a = cutoffEnergy weight keep a + | |
| cutoffEnergy weight (fun q i => Β¬ keep q i) a := by | |
| classical | |
| unfold energy cutoffEnergy | |
| rw [β Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| rw [β mul_add, β Finset.sum_add_distrib] | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| by_cases h : keep q i <;> simp [h] | |
| /-- A spectral multiplier bounded by one on retained indices and by `Ξ·` | |
| elsewhere contributes at most retained energy plus `Ξ·` times total energy. -/ | |
| theorem spectralEnergy_le_cutoff_add | |
| (weight : Q β β) (keep : (q : Q) β I q β Prop) (eigen a : (q : Q) β I q β β) (Ξ· : β) | |
| (hw : β q, 0 β€ weight q) (hΞ· : 0 β€ Ξ·) | |
| (hone : β q i, eigen q i β€ 1) | |
| (hhigh : β q i, Β¬ keep q i β eigen q i β€ Ξ·) : | |
| spectralEnergy weight eigen a β€ cutoffEnergy weight keep a + Ξ· * energy weight a := by | |
| classical | |
| have hpoint (q : Q) (i : I q) : | |
| eigen q i * a q i ^ 2 β€ (if keep q i then a q i ^ 2 else 0) + Ξ· * a q i ^ 2 := by | |
| by_cases hk : keep q i | |
| Β· have h := mul_le_mul_of_nonneg_right (hone q i) (sq_nonneg (a q i)) | |
| have hn := mul_nonneg hΞ· (sq_nonneg (a q i)) | |
| simp only [hk, ite_true] | |
| nlinarith | |
| Β· simpa only [hk, ite_false, zero_add] using | |
| mul_le_mul_of_nonneg_right (hhigh q i hk) (sq_nonneg (a q i)) | |
| calc | |
| spectralEnergy weight eigen a | |
| β€ β q, weight q * β i, | |
| ((if keep q i then a q i ^ 2 else 0) + Ξ· * a q i ^ 2) := by | |
| apply Finset.sum_le_sum | |
| intro q _ | |
| exact mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun i _ => hpoint q i)) (hw q) | |
| _ = cutoffEnergy weight keep a + Ξ· * energy weight a := by | |
| simp only [cutoffEnergy, energy, Finset.sum_add_distrib, β Finset.mul_sum, mul_add] | |
| congr 1 | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| ring | |
| /-- Unit total energy and spectral value above `Ξ΄` force retained energy above | |
| `Ξ΄/2` when all discarded multipliers are at most `Ξ΄/2`. -/ | |
| theorem cutoffEnergy_gt_half | |
| (weight : Q β β) (keep : (q : Q) β I q β Prop) (eigen a : (q : Q) β I q β β) (Ξ΄ : β) | |
| (hw : β q, 0 β€ weight q) (hΞ΄ : 0 β€ Ξ΄) | |
| (hone : β q i, eigen q i β€ 1) | |
| (hhigh : β q i, Β¬ keep q i β eigen q i β€ Ξ΄ / 2) | |
| (htotal : energy weight a = 1) (hvalue : Ξ΄ < spectralEnergy weight eigen a) : | |
| Ξ΄ / 2 < cutoffEnergy weight keep a := by | |
| have h := spectralEnergy_le_cutoff_add weight keep eigen a (Ξ΄ / 2) | |
| hw (by linarith) hone hhigh | |
| rw [htotal] at h | |
| linarith | |
| /-- The elementary square bound, summed over the retained coefficients. The | |
| discarded term on the right uses the full coefficient difference, giving the | |
| contraction needed for equation (5.11) without introducing square roots. -/ | |
| theorem cutoffEnergy_le_twice_difference_add | |
| (weight : Q β β) (keep : (q : Q) β I q β Prop) (H G : (q : Q) β I q β β) | |
| (hw : β q, 0 β€ weight q) : | |
| cutoffEnergy weight keep H β€ | |
| 2 * energy weight (fun q i => H q i - G q i) + 2 * cutoffEnergy weight keep G := by | |
| classical | |
| have hpoint (q : Q) (i : I q) : | |
| (if keep q i then H q i ^ 2 else 0) β€ | |
| 2 * (H q i - G q i) ^ 2 + 2 * (if keep q i then G q i ^ 2 else 0) := by | |
| by_cases hk : keep q i | |
| Β· simp only [hk, ite_true] | |
| nlinarith [sq_nonneg (H q i - 2 * G q i)] | |
| Β· simp only [hk, ite_false, mul_zero, add_zero] | |
| nlinarith [sq_nonneg (H q i - G q i)] | |
| calc | |
| cutoffEnergy weight keep H β€ | |
| β q, weight q * β i, | |
| (2 * (H q i - G q i) ^ 2 + 2 * (if keep q i then G q i ^ 2 else 0)) := by | |
| apply Finset.sum_le_sum | |
| intro q _ | |
| exact mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun i _ => hpoint q i)) (hw q) | |
| _ = 2 * energy weight (fun q i => H q i - G q i) + | |
| 2 * cutoffEnergy weight keep G := by | |
| simp only [energy, cutoffEnergy, Finset.sum_add_distrib, β Finset.mul_sum, mul_add] | |
| congr 1 <;> rw [Finset.mul_sum] <;> | |
| apply Finset.sum_congr rfl <;> intro q _ <;> ring | |
| theorem deleted_energy_gt_eighth | |
| (weight : Q β β) (keep : (q : Q) β I q β Prop) (H G : (q : Q) β I q β β) (Ξ΄ : β) | |
| (hw : β q, 0 β€ weight q) | |
| (hlarge : Ξ΄ / 2 < cutoffEnergy weight keep H) | |
| (hsmall : cutoffEnergy weight keep G β€ Ξ΄ / 8) : | |
| Ξ΄ / 8 < energy weight (fun q i => H q i - G q i) := by | |
| have h := cutoffEnergy_le_twice_difference_add weight keep H G hw | |
| linarith | |
| /-- Squared Boolean functions equal their values under a finite weighted sum. -/ | |
| theorem boolean_energy_eq_mass (weight : Q β β) (H : (q : Q) β I q β β) | |
| (hbool : β q i, H q i = 0 β¨ H q i = 1) : | |
| energy weight H = β q, weight q * β i, H q i := by | |
| unfold energy | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| rcases hbool q i with h | h <;> simp [h] | |
| /-- A finite union bound for fractional removed mass dominated by indicator | |
| events. Both the event choice and the removed value may depend on the outcome. -/ | |
| theorem weighted_union_bound {Ξ© J : Type*} [Fintype Ξ©] [Fintype J] | |
| (weight value : Ξ© β β) (event : J β Ξ© β Prop) | |
| [β j, DecidablePred (event j)] | |
| (hw : β Ο, 0 β€ weight Ο) (hvalue : β Ο, value Ο β€ 1) | |
| (hcover : β Ο, 0 < value Ο β β j, event j Ο) : | |
| (β Ο, weight Ο * value Ο) β€ | |
| β j, β Ο, weight Ο * (if event j Ο then (1 : β) else 0) := by | |
| classical | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_le_sum | |
| intro Ο _ | |
| rw [β Finset.mul_sum] | |
| apply mul_le_mul_of_nonneg_left _ (hw Ο) | |
| by_cases hp : 0 < value Ο | |
| Β· obtain β¨j, hjβ© := hcover Ο hp | |
| have hs : (if event j Ο then (1 : β) else 0) β€ | |
| β k, if event k Ο then (1 : β) else 0 := by | |
| apply Finset.single_le_sum (s := Finset.univ) | |
| (f := fun k : J => if event k Ο then (1 : β) else 0) (a := j) | |
| Β· intro k _; split_ifs <;> norm_num | |
| Β· exact Finset.mem_univ j | |
| exact le_trans (hvalue Ο) (by simpa [hj] using hs) | |
| Β· exact le_trans (le_of_not_gt hp) (Finset.sum_nonneg (by intro j _; split_ifs <;> norm_num)) | |
| /-- Finite real pigeonhole principle for the one fixed color/subspace choice. -/ | |
| theorem exists_fixed_event {J : Type*} [Fintype J] (mass : J β β) | |
| (threshold budget : β) | |
| (hcount : (Fintype.card J : β) * threshold β€ budget) | |
| (hmass : budget < β j, mass j) : β j, threshold < mass j := by | |
| classical | |
| by_contra h | |
| push Not at h | |
| have hs : (β j, mass j) β€ (Fintype.card J : β) * threshold := by | |
| calc | |
| (β j, mass j) β€ β _j : J, threshold := Finset.sum_le_sum (fun j _ => h j) | |
| _ = _ := by simp | |
| linarith | |
| /-- The explicit denominator in (5.13), for any supplied event-count bound. -/ | |
| theorem exists_fixed_event_scaled {J : Type*} [Fintype J] | |
| (mass : J β β) (N : β) (Ξ΄ : β) | |
| (hN : 0 < N) (hΞ΄ : 0 β€ Ξ΄) (hcard : Fintype.card J β€ N) | |
| (hmass : Ξ΄ / 8 < β j, mass j) : | |
| β j, Ξ΄ / (8 * (N : β)) < mass j := by | |
| have hNreal : (0 : β) < N := by exact_mod_cast hN | |
| have hcardreal : (Fintype.card J : β) β€ N := by exact_mod_cast hcard | |
| have hthreshold : 0 β€ Ξ΄ / (8 * (N : β)) := | |
| div_nonneg hΞ΄ (mul_nonneg (by norm_num) hNreal.le) | |
| have hcancel : (N : β) * (Ξ΄ / (8 * (N : β))) = Ξ΄ / 8 := by | |
| field_simp [ne_of_gt hNreal] | |
| apply exists_fixed_event mass (Ξ΄ / (8 * (N : β))) (Ξ΄ / 8) _ hmass | |
| rw [β hcancel] | |
| exact mul_le_mul_of_nonneg_right hcardreal hthreshold | |
| section LinearMaps | |
| open MatrixCharacters MatrixFourier | |
| variable {E F : Type*} | |
| variable [AddCommGroup E] [Module F2 E] [AddCommGroup F] [Module F2 F] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 F] | |
| variable [Fintype (E ββ[F2] F)] [Fintype (F ββ[F2] E)] | |
| /-- The actual rank of a Fourier index restricted to the alphabet subspace. -/ | |
| noncomputable def linearRankOn (C : Submodule F2 F) (S : F ββ[F2] E) : β := | |
| Module.finrank F2 (LinearMap.range (S.comp C.subtype)) | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 F] | |
| [Fintype (E ββ[F2] F)] [Fintype (F ββ[F2] E)] in | |
| theorem linearRankOn_top (S : F ββ[F2] E) : | |
| linearRankOn (β€ : Submodule F2 F) S = | |
| Module.finrank F2 (LinearMap.range S) := by | |
| have hrange : LinearMap.range (S.comp (β€ : Submodule F2 F).subtype) = | |
| LinearMap.range S := by | |
| ext x | |
| constructor | |
| Β· rintro β¨v, hvβ© | |
| exact β¨v.1, hvβ© | |
| Β· rintro β¨v, hvβ© | |
| exact β¨β¨v, by simpβ©, hvβ© | |
| exact congrArg (fun P : Submodule F2 E => Module.finrank F2 P) hrange | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 F] | |
| [Fintype (E ββ[F2] F)] [Fintype (F ββ[F2] E)] in | |
| /-- Restricting to the image of a symbol embedding has the same image rank | |
| as composition with that embedding, even when it is not injective. -/ | |
| theorem linearRankOn_range {V : Type*} [AddCommGroup V] [Module F2 V] | |
| (S : F ββ[F2] E) (ΞΉ : V ββ[F2] F) : | |
| linearRankOn (LinearMap.range ΞΉ) S = | |
| Module.finrank F2 (LinearMap.range (S.comp ΞΉ)) := by | |
| have hrange : LinearMap.range (S.comp (LinearMap.range ΞΉ).subtype) = | |
| LinearMap.range (S.comp ΞΉ) := by | |
| ext x | |
| constructor | |
| Β· rintro β¨v, hvβ© | |
| obtain β¨u, huβ© := v.property | |
| refine β¨u, ?_β© | |
| change S (ΞΉ u) = x | |
| rw [hu] | |
| exact hv | |
| Β· rintro β¨u, huβ© | |
| exact β¨β¨ΞΉ u, β¨u, rflβ©β©, huβ© | |
| exact congrArg (fun P : Submodule F2 E => Module.finrank F2 P) hrange | |
| /-- Projection onto trace characters whose index has bounded rank on `C`. -/ | |
| noncomputable def rankProjection (C : Submodule F2 F) (r : β) | |
| (f : (E ββ[F2] F) β β) : (E ββ[F2] F) β β := by | |
| classical | |
| exact β S : F ββ[F2] E, | |
| (if linearRankOn C S β€ r then linearCoeff f S else 0) β’ | |
| (fun X => (linearTraceCharacter S X).re) | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 F] [Fintype (F ββ[F2] E)] in | |
| theorem linearCoeff_sub (f g : (E ββ[F2] F) β β) (S : F ββ[F2] E) : | |
| linearCoeff (fun X => f X - g X) S = linearCoeff f S - linearCoeff g S := by | |
| simp only [linearCoeff, sub_mul, Finset.expect_sub_distrib] | |
| /-- The genuine function-space projection acts by the claimed coefficient mask. -/ | |
| theorem linearCoeff_rankProjection (C : Submodule F2 F) (r : β) | |
| (f : (E ββ[F2] F) β β) (S : F ββ[F2] E) : | |
| linearCoeff (rankProjection C r f) S = | |
| if linearRankOn C S β€ r then linearCoeff f S else 0 := by | |
| classical | |
| unfold rankProjection | |
| rw [linearCoeff_sum] | |
| simp only [linearCoeff_smul, linearCoeff_character, mul_ite, mul_one, mul_zero] | |
| simp | |
| /-- Squared norm of the actual projection equals the retained coefficient mass. -/ | |
| theorem rankProjection_parseval (C : Submodule F2 F) (r : β) | |
| (f : (E ββ[F2] F) β β) : | |
| (πΌ X, rankProjection C r f X ^ 2) = | |
| β S : F ββ[F2] E, if linearRankOn C S β€ r then linearCoeff f S ^ 2 else 0 := by | |
| classical | |
| rw [β linear_parseval] | |
| apply Finset.sum_congr rfl | |
| intro S _ | |
| rw [linearCoeff_rankProjection] | |
| split_ifs <;> simp | |
| /-- Contraction for the actual rank projection with the uniform function norm. -/ | |
| theorem rankProjection_contraction (C : Submodule F2 F) (r : β) | |
| (f : (E ββ[F2] F) β β) : | |
| (πΌ X, rankProjection C r f X ^ 2) β€ πΌ X, f X ^ 2 := by | |
| classical | |
| rw [rankProjection_parseval, β linear_parseval] | |
| apply Finset.sum_le_sum | |
| intro S _ | |
| split_ifs | |
| Β· exact le_rfl | |
| Β· exact sq_nonneg _ | |
| /-- The projected part is orthogonal to the discarded part in the actual | |
| uniform function inner product. -/ | |
| theorem rankProjection_orthogonal (C : Submodule F2 F) (r : β) | |
| (f : (E ββ[F2] F) β β) : | |
| (πΌ X, rankProjection C r f X * (f X - rankProjection C r f X)) = 0 := by | |
| classical | |
| rw [β linear_parseval_inner] | |
| apply Finset.sum_eq_zero | |
| intro S _ | |
| rw [linearCoeff_sub, linearCoeff_rankProjection] | |
| split_ifs <;> simp | |
| theorem linear_energy_parseval (weight : Q β β) (f : Q β (E ββ[F2] F) β β) : | |
| energy weight (fun q S => linearCoeff (f q) S) = | |
| β q, weight q * (πΌ X, f q X ^ 2) := by | |
| simp only [energy, linear_parseval] | |
| theorem linear_difference_energy_parseval (weight : Q β β) | |
| (H G : Q β (E ββ[F2] F) β β) : | |
| energy weight (fun q S => linearCoeff (H q) S - linearCoeff (G q) S) = | |
| β q, weight q * (πΌ X, (H q X - G q X) ^ 2) := by | |
| simp only [β linearCoeff_sub, linear_energy_parseval] | |
| /-- Equation (5.11) now for actual functions on a binary linear-map space, | |
| using the actual restriction rank and trace Fourier coefficients. -/ | |
| theorem linear_deleted_energy_gt_eighth | |
| (weight : Q β β) (C : Submodule F2 F) (r : β) | |
| (H G : Q β (E ββ[F2] F) β β) (Ξ΄ : β) | |
| (hw : β q, 0 β€ weight q) | |
| (hlarge : Ξ΄ / 2 < cutoffEnergy weight (fun _ S => linearRankOn C S β€ r) | |
| (fun q S => linearCoeff (H q) S)) | |
| (hsmall : cutoffEnergy weight (fun _ S => linearRankOn C S β€ r) | |
| (fun q S => linearCoeff (G q) S) β€ Ξ΄ / 8) : | |
| Ξ΄ / 8 < β q, weight q * (πΌ X, (H q X - G q X) ^ 2) := by | |
| rw [β linear_difference_energy_parseval] | |
| exact deleted_energy_gt_eighth weight (fun _ S => linearRankOn C S β€ r) | |
| (fun q S => linearCoeff (H q) S) (fun q S => linearCoeff (G q) S) | |
| Ξ΄ hw hlarge hsmall | |
| /-- Color indicator of one actual labeling. -/ | |
| noncomputable def colorIndicator {X Y : Type*} (label : X β Y) (y : Y) : X β β := by | |
| classical | |
| exact fun x => if label x = y then 1 else 0 | |
| theorem colorIndicator_partition {X Y : Type*} [Fintype Y] | |
| (label : X β Y) (x : X) : β y, colorIndicator label y x ^ 2 = 1 := by | |
| classical | |
| simp [colorIndicator, eq_comm] | |
| /-- Parseval for all color indicators sums to exactly one, with the correct | |
| uniform primal normalization and counting measure on Fourier indices. -/ | |
| theorem colorIndicator_parseval {Y : Type*} [Fintype Y] | |
| (label : (E ββ[F2] F) β Y) : | |
| (β y, β S : F ββ[F2] E, linearCoeff (colorIndicator label y) S ^ 2) = 1 := by | |
| simp_rw [linear_parseval] | |
| rw [β Finset.expect_sum_comm] | |
| simp_rw [colorIndicator_partition] | |
| exact Fintype.expect_const 1 | |
| /-- Fourier coefficient array for a family of labelings, including color as | |
| part of the component index. -/ | |
| noncomputable def labelingCoeff {Y : Type*} | |
| (label : Q β (E ββ[F2] F) β Y) (qy : Q Γ Y) (S : F ββ[F2] E) : β := | |
| linearCoeff (colorIndicator (label qy.1) qy.2) S | |
| theorem labelingCoeff_energy_one {Y : Type*} [Fintype Y] | |
| (weight : Q β β) (label : Q β (E ββ[F2] F) β Y) | |
| (hnorm : β q, weight q = 1) : | |
| energy (fun qy : Q Γ Y => weight qy.1) (labelingCoeff label) = 1 := by | |
| classical | |
| calc | |
| energy (fun qy : Q Γ Y => weight qy.1) (labelingCoeff label) = | |
| β q, weight q * (β y, β S : F ββ[F2] E, | |
| linearCoeff (colorIndicator (label q) y) S ^ 2) := by | |
| simp only [energy, labelingCoeff, Fintype.sum_prod_type, Finset.mul_sum] | |
| _ = β q, weight q := by simp only [colorIndicator_parseval, mul_one] | |
| _ = 1 := hnorm | |
| /-- The low-rank Fourier-energy conclusion (5.5), for genuine binary linear | |
| maps and genuine labeling coefficients. The spectral premise can be obtained | |
| from the noise diagonalization; the bound is on actual restriction rank. -/ | |
| theorem labeling_lowRank_energy {Y : Type*} [Fintype Y] | |
| (weight : Q β β) (label : Q β (E ββ[F2] F) β Y) | |
| (C : Submodule F2 F) (r : β) (eigen : Q β (F ββ[F2] E) β β) (Ξ΄ : β) | |
| (hw : β q, 0 β€ weight q) (hnorm : β q, weight q = 1) (hΞ΄ : 0 β€ Ξ΄) | |
| (hone : β q S, eigen q S β€ 1) | |
| (hhigh : β q S, r < linearRankOn C S β eigen q S β€ Ξ΄ / 2) | |
| (hvalue : Ξ΄ < spectralEnergy (fun qy : Q Γ Y => weight qy.1) | |
| (fun qy S => eigen qy.1 S) (labelingCoeff label)) : | |
| Ξ΄ / 2 < cutoffEnergy (fun qy : Q Γ Y => weight qy.1) | |
| (fun _ S => linearRankOn C S β€ r) (labelingCoeff label) := by | |
| apply cutoffEnergy_gt_half _ _ _ _ Ξ΄ | |
| Β· intro qy; exact hw qy.1 | |
| Β· exact hΞ΄ | |
| Β· intro qy S; exact hone qy.1 S | |
| Β· intro qy S hS; exact hhigh qy.1 S (Nat.lt_of_not_ge hS) | |
| Β· exact labelingCoeff_energy_one weight label hnorm | |
| Β· exact hvalue | |
| end LinearMaps | |
| section DependentLinearMaps | |
| open MatrixCharacters MatrixFourier | |
| variable {J : Type*} [Fintype J] {E : J β Type*} {F : Type*} | |
| [β j, AddCommGroup (E j)] [β j, Module F2 (E j)] | |
| [AddCommGroup F] [Module F2 F] | |
| [β j, FiniteDimensional F2 (E j)] [FiniteDimensional F2 F] | |
| [β j, Fintype (E j ββ[F2] F)] [β j, Fintype (F ββ[F2] E j)] | |
| theorem dependent_linear_energy_parseval | |
| (weight : J β β) (H : (j : J) β (E j ββ[F2] F) β β) : | |
| energy weight (fun j S => linearCoeff (H j) S) = | |
| β j, weight j * (πΌ X, H j X ^ 2) := by | |
| unfold energy | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| rw [linear_parseval] | |
| omit [β j, FiniteDimensional F2 (E j)] [FiniteDimensional F2 F] in | |
| theorem dependent_remainder_cutoff_le_eighth | |
| (weight : J β β) (C : Submodule F2 F) (r : β) | |
| (G : (j : J) β (E j ββ[F2] F) β β) (ΞΊ Ξ΄ : β) | |
| (hw : β j, 0 β€ weight j) (hΞΊ : 0 β€ ΞΊ) (hΞΊΞ΄ : ΞΊ β€ Ξ΄ / 8) | |
| (hlevel : β j, (β S : F ββ[F2] E j, | |
| if linearRankOn C S β€ r then linearCoeff (G j) S ^ 2 else 0) β€ | |
| ΞΊ * (πΌ X, G j X ^ 2)) | |
| (hmass : (β j, weight j * (πΌ X, G j X ^ 2)) β€ 1) : | |
| cutoffEnergy weight (fun _ S => linearRankOn C S β€ r) | |
| (fun j S => linearCoeff (G j) S) β€ Ξ΄ / 8 := by | |
| classical | |
| have hs : cutoffEnergy weight (fun _ S => linearRankOn C S β€ r) | |
| (fun j S => linearCoeff (G j) S) β€ | |
| ΞΊ * (β j, weight j * (πΌ X, G j X ^ 2)) := by | |
| calc | |
| _ β€ β j, weight j * (ΞΊ * (πΌ X, G j X ^ 2)) := by | |
| apply Finset.sum_le_sum | |
| intro j _ | |
| apply mul_le_mul_of_nonneg_left _ (hw j) | |
| simpa using hlevel j | |
| _ = _ := by | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| ring | |
| have hm := mul_le_mul_of_nonneg_left hmass hΞΊ | |
| linarith | |
| /-- The actual removed probability energy in Section 5.3, allowing the map | |
| domain to depend on the complete question and color index. -/ | |
| theorem dependent_deleted_energy_from_level | |
| (weight : J β β) (C : Submodule F2 F) (r : β) | |
| (H G : (j : J) β (E j ββ[F2] F) β β) (ΞΊ Ξ΄ : β) | |
| (hw : β j, 0 β€ weight j) (hΞΊ : 0 β€ ΞΊ) (hΞΊΞ΄ : ΞΊ β€ Ξ΄ / 8) | |
| (hlarge : Ξ΄ / 2 < cutoffEnergy weight (fun _ S => linearRankOn C S β€ r) | |
| (fun j S => linearCoeff (H j) S)) | |
| (hlevel : β j, (β S : F ββ[F2] E j, | |
| if linearRankOn C S β€ r then linearCoeff (G j) S ^ 2 else 0) β€ | |
| ΞΊ * (πΌ X, G j X ^ 2)) | |
| (hmass : (β j, weight j * (πΌ X, G j X ^ 2)) β€ 1) : | |
| Ξ΄ / 8 < β j, weight j * (πΌ X, (H j X - G j X) ^ 2) := by | |
| have hsmall := dependent_remainder_cutoff_le_eighth weight C r G ΞΊ Ξ΄ | |
| hw hΞΊ hΞΊΞ΄ hlevel hmass | |
| have h := deleted_energy_gt_eighth weight (fun _ S => linearRankOn C S β€ r) | |
| (fun j S => linearCoeff (H j) S) (fun j S => linearCoeff (G j) S) | |
| Ξ΄ hw hlarge hsmall | |
| simpa only [β linearCoeff_sub, energy, linear_parseval, Pi.sub_apply] using h | |
| end DependentLinearMaps | |
| /-- Real value of a Boolean indicator. -/ | |
| def boolReal (b : Bool) : β := if b then 1 else 0 | |
| @[simp] theorem boolReal_sq (b : Bool) : boolReal b ^ 2 = boolReal b := by | |
| cases b <;> norm_num [boolReal] | |
| theorem boolReal_le_one (b : Bool) : boolReal b β€ 1 := by | |
| cases b <;> norm_num [boolReal] | |
| /-- Boolean indicator of one color of a labeling. -/ | |
| noncomputable def labelBool {X Y : Type*} (label : X β Y) (y : Y) : X β Bool := by | |
| classical | |
| exact fun x => decide (label x = y) | |
| theorem labelBool_real {X Y : Type*} (label : X β Y) (y : Y) (x : X) : | |
| boolReal (labelBool label y x) = colorIndicator label y x := by | |
| classical | |
| simp [boolReal, labelBool, colorIndicator] | |
| /-- Deletion's actual Boolean removed function is exactly the difference of | |
| the original and remainder indicators. -/ | |
| theorem removed_boolReal {X Row Witness : Type*} | |
| (S : Deletion.RestrictionSystem X Row Witness) (H : X β Bool) (p d : β) (x : X) : | |
| boolReal (Deletion.removed S H p d x) = | |
| boolReal (H x) - boolReal (Deletion.remainder S H p d x) := by | |
| classical | |
| by_cases hd : Deletion.DeletedSet S H p d x | |
| Β· simp [Deletion.removed, Deletion.remainder, hd, boolReal] | |
| Β· simp [Deletion.removed, Deletion.remainder, hd, boolReal] | |
| theorem removed_difference_sq {X Row Witness : Type*} | |
| (S : Deletion.RestrictionSystem X Row Witness) (H : X β Bool) (p d : β) (x : X) : | |
| (boolReal (H x) - boolReal (Deletion.remainder S H p d x)) ^ 2 = | |
| boolReal (Deletion.removed S H p d x) := by | |
| rw [β removed_boolReal, boolReal_sq] | |
| section QuestionProbabilities | |
| variable {Ξ© : Q β Type*} [β q, Fintype (Ξ© q)] | |
| variable {Y A : Type*} [Fintype Y] [Fintype A] | |
| /-- An event probability: first sample the question with the supplied weights, | |
| then sample uniformly in its own finite space. -/ | |
| noncomputable def questionEventMass | |
| (weight : Q β β) (B : (q : Q) β Ξ© q β Prop) : β := by | |
| classical | |
| exact β q, weight q * (πΌ X, if B q X then (1 : β) else 0) | |
| theorem dependent_removed_union_bound | |
| (weight : Q β β) (d : (q : Q) β Y β Ξ© q β β) | |
| (B : (q : Q) β Y β A β Ξ© q β Prop) | |
| (hw : β q, 0 β€ weight q) | |
| (hd : β q y X, d q y X β€ 1) | |
| (hc : β q y X, 0 < d q y X β β a, B q y a X) : | |
| (β q, weight q * β y, πΌ X, d q y X) β€ | |
| β ya : Y Γ A, questionEventMass weight (fun q X => B q ya.1 ya.2 X) := by | |
| classical | |
| have hp (q : Q) (y : Y) (X : Ξ© q) : | |
| d q y X β€ β a, if B q y a X then (1 : β) else 0 := by | |
| by_cases hpos : 0 < d q y X | |
| Β· obtain β¨a, haβ© := hc q y X hpos | |
| have hi := Finset.single_le_sum (s := Finset.univ) | |
| (f := fun b : A => if B q y b X then (1 : β) else 0) | |
| (fun b _ => by split_ifs <;> norm_num) (Finset.mem_univ a) | |
| exact le_trans (hd q y X) (by simpa [ha] using hi) | |
| Β· exact le_trans (le_of_not_gt hpos) | |
| (Finset.sum_nonneg (by intro a _; split_ifs <;> norm_num)) | |
| calc | |
| _ β€ β q, weight q * β y, πΌ X, | |
| β a, if B q y a X then (1 : β) else 0 := by | |
| apply Finset.sum_le_sum | |
| intro q _ | |
| apply mul_le_mul_of_nonneg_left _ (hw q) | |
| apply Finset.sum_le_sum | |
| intro y _ | |
| exact Finset.expect_le_expect (fun X _ => hp q y X) | |
| _ = _ := by | |
| simp only [questionEventMass, Finset.expect_sum_comm, | |
| Finset.mul_sum, Fintype.sum_prod_type] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| exact Finset.sum_comm | |
| /-- One target is fixed before sampling the question and its map. -/ | |
| theorem fixed_target_of_removed_mass | |
| (weight : Q β β) (d : (q : Q) β Y β Ξ© q β β) | |
| (B : (q : Q) β Y β A β Ξ© q β Prop) | |
| (hw : β q, 0 β€ weight q) (hd : β q y X, d q y X β€ 1) | |
| (hc : β q y X, 0 < d q y X β β a, B q y a X) | |
| (Ξ΄ : β) (N : β) (hΞ΄ : 0 β€ Ξ΄) (hN : 0 < N) | |
| (hcount : Fintype.card (Y Γ A) β€ N) | |
| (hremoved : Ξ΄ / 8 < β q, weight q * β y, πΌ X, d q y X) : | |
| β y a, Ξ΄ / (8 * (N : β)) < | |
| questionEventMass weight (fun q X => B q y a X) := by | |
| have hu := dependent_removed_union_bound weight d B hw hd hc | |
| obtain β¨β¨y, aβ©, hyaβ© := exists_fixed_event_scaled | |
| (fun ya : Y Γ A => questionEventMass weight (fun q X => B q ya.1 ya.2 X)) | |
| N Ξ΄ hN hΞ΄ hcount (lt_of_lt_of_le hremoved hu) | |
| exact β¨y, a, hyaβ© | |
| /-- A Boolean subpartition has total squared mass at most one. Colors are | |
| summed with counting measure, not averaged. -/ | |
| theorem boolean_subpartition_energy_le_one [β q, Nonempty (Ξ© q)] | |
| (weight : Q β β) (label : (q : Q) β Ξ© q β Y) | |
| (G : (q : Q) β Y β Ξ© q β Bool) | |
| (hw : β q, 0 β€ weight q) (hnorm : β q, weight q = 1) | |
| (hG : β q y X, G q y X = true β label q X = y) : | |
| (β q, weight q * β y, πΌ X, boolReal (G q y X) ^ 2) β€ 1 := by | |
| classical | |
| have hp (q : Q) (X : Ξ© q) : | |
| (β y, boolReal (G q y X) ^ 2) β€ 1 := by | |
| calc | |
| _ β€ β y, colorIndicator (label q) y X ^ 2 := by | |
| apply Finset.sum_le_sum | |
| intro y _ | |
| by_cases hg : G q y X = true | |
| Β· have hl := hG q y X hg | |
| simp [hg, boolReal, colorIndicator, hl] | |
| Β· simpa [boolReal, hg] using sq_nonneg (colorIndicator (label q) y X) | |
| _ = 1 := colorIndicator_partition (label q) X | |
| have hq (q : Q) : (β y, πΌ X, boolReal (G q y X) ^ 2) β€ 1 := by | |
| rw [β Finset.expect_sum_comm] | |
| calc | |
| _ β€ πΌ _X : Ξ© q, (1 : β) := Finset.expect_le_expect (fun X _ => hp q X) | |
| _ = 1 := Fintype.expect_const 1 | |
| calc | |
| _ β€ β q, weight q * 1 := | |
| Finset.sum_le_sum (fun q _ => mul_le_mul_of_nonneg_left (hq q) (hw q)) | |
| _ = 1 := by simpa using hnorm | |
| /-- The actual whole-row remainder of labeling indicators satisfies the mass | |
| bound needed in the deleted-energy argument, with no remaining mass hypothesis. -/ | |
| theorem remainder_subpartition_energy_le_one [β q, Nonempty (Ξ© q)] | |
| {Row Witness : Q β Type*} | |
| (S : (q : Q) β Deletion.RestrictionSystem (Ξ© q) (Row q) (Witness q)) | |
| (weight : Q β β) (label : (q : Q) β Ξ© q β Y) (p d : β) | |
| (hw : β q, 0 β€ weight q) (hnorm : β q, weight q = 1) : | |
| (β q, weight q * β y, πΌ X, | |
| boolReal (Deletion.remainder (S q) (labelBool (label q) y) p d X) ^ 2) β€ 1 := by | |
| apply boolean_subpartition_energy_le_one weight label _ hw hnorm | |
| intro q y X hG | |
| have h := Deletion.remainder_le_original (S q) (labelBool (label q) y) p d X hG | |
| simpa [labelBool] using h | |
| end QuestionProbabilities | |
| section ActualBadRows | |
| open MatrixCharacters | |
| variable {C : Type*} [AddCommGroup C] [Module F2 C] | |
| [FiniteDimensional F2 C] [Fintype C] | |
| {E : Q β Type*} [β q, AddCommGroup (E q)] [β q, Module F2 (E q)] | |
| [β q, Finite (E q)] [β q, Fintype (E q ββ[F2] C)] | |
| /-- Equation (5.13) for the actual whole-row deletion system. Only the color | |
| and target subspace are selected. Neither the question, row value, nor witness | |
| vanishing subspace is part of the counted target. -/ | |
| theorem fixed_badRow_target_of_removed_mass | |
| (weight : Q β β) (H : (q : Q) β C β (E q ββ[F2] C) β Bool) | |
| (r p d : β) (Ξ΄ : β) | |
| (hw : β q, 0 β€ weight q) (hΞ΄ : 0 β€ Ξ΄) | |
| (hremoved : Ξ΄ / 8 < β q, weight q * β y, πΌ X, | |
| boolReal (Deletion.removed (MatrixRestrictions.system r) (H q y) p d X)) : | |
| β (y : C) (C' : Submodule F2 C), Module.finrank F2 (C β§Έ C') β€ r β§ | |
| Ξ΄ / (8 * (Nat.card C : β) * (2 : β) ^ | |
| (Module.finrank F2 C * Module.finrank F2 C)) < | |
| questionEventMass weight (fun q (X : E q ββ[F2] C) => | |
| Deletion.BadRow (MatrixRestrictions.system r) (H q y) p d | |
| β¨C', C'.mkQ.comp Xβ©) := by | |
| classical | |
| let : Finite (C ββ[F2] C) := Finite.of_injective | |
| (fun f : C ββ[F2] C => (f : C β C)) DFunLike.coe_injective | |
| let : Finite (Submodule F2 C) := Finite.of_surjective | |
| (fun f : C ββ[F2] C => LinearMap.range f) | |
| MatrixSubspaceCount.endomorphism_range_surjective | |
| let A := {C' : Submodule F2 C // Module.finrank F2 (C β§Έ C') β€ r} | |
| let : Fintype A := Fintype.ofFinite A | |
| let N := Nat.card C * 2 ^ (Module.finrank F2 C * Module.finrank F2 C) | |
| let value (q : Q) (y : C) (X : E q ββ[F2] C) : β := | |
| boolReal (Deletion.removed (MatrixRestrictions.system r) (H q y) p d X) | |
| let event (q : Q) (y : C) (a : A) (X : E q ββ[F2] C) : Prop := | |
| Deletion.BadRow (MatrixRestrictions.system r) (H q y) p d | |
| β¨a.val, a.val.mkQ.comp Xβ© | |
| have hcover (q : Q) (y : C) (X : E q ββ[F2] C) (hpos : 0 < value q y X) : | |
| β a : A, event q y a X := by | |
| have ht : Deletion.removed (MatrixRestrictions.system r) (H q y) p d X = true := by | |
| by_contra hn | |
| simp [value, boolReal, hn] at hpos | |
| have hdel : Deletion.DeletedSet (MatrixRestrictions.system r) (H q y) p d X := by | |
| by_contra hn | |
| simp [Deletion.removed, hn] at ht | |
| obtain β¨C', hcodim, hbadβ© := | |
| (MatrixRestrictions.deletedSet_iff_exists_admissible_target (H q y) r p d X).mp hdel | |
| exact β¨β¨C', hcodimβ©, hbadβ© | |
| have hcount : Fintype.card (C Γ A) β€ N := by | |
| simpa only [A, N, Nat.card_eq_fintype_card] using | |
| (MatrixSubspaceCount.card_color_admissible_subspaces_le | |
| (fun C' : Submodule F2 C => Module.finrank F2 (C β§Έ C') β€ r)) | |
| have hN : 0 < N := by | |
| simpa only [N, Nat.card_eq_fintype_card] using | |
| (Nat.mul_pos (Fintype.card_pos : 0 < Fintype.card C) | |
| (pow_pos (by norm_num : 0 < (2 : β)) (Module.finrank F2 C * Module.finrank F2 C))) | |
| obtain β¨y, a, haβ© := fixed_target_of_removed_mass weight value event hw | |
| (fun _ _ _ => boolReal_le_one _) hcover Ξ΄ N hΞ΄ hN hcount hremoved | |
| refine β¨y, a.val, a.property, ?_β© | |
| simpa only [N, event, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat, mul_assoc] using ha | |
| end ActualBadRows | |
| end UniqueGamesTheorem.Fourier.MatrixEnergy | |
| end | |
| end OAI | |