Download data/lean/OAI/Computability/UniqueGames/Analysis/MatrixParityRow.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 13.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixParityRow.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixParityRow.lean
-
curl -L -o MatrixParityRow.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixParityRow.lean
13.6 kB
| import Mathlib.Algebra.Order.BigOperators.Expect | |
| import Mathlib.Basic.Complex.BigOperators | |
| import Mathlib.Tactic.Linarith | |
| import OAI.Computability.UniqueGames.Analysis.MatrixCharactersLemmas | |
| import OAI.Computability.UniqueGames.Analysis.MatrixRestrictions | |
| namespace OAI | |
| section | |
| /-! Fourier expansion of actual affine restrictions and parity extraction. -/ | |
| noncomputable section | |
| namespace UniqueGamesTheorem.Fourier.MatrixParityRow | |
| open MatrixCharacters MatrixFourier MatrixParity | |
| open scoped BigOperators Classical | |
| variable {E C V : Type*} [AddCommGroup E] [Module F2 E] | |
| [AddCommGroup C] [Module F2 C] [AddCommGroup V] [Module F2 V] | |
| theorem traceCharacter_comp (Q : E ββ[F2] V) (A : V ββ[F2] C) | |
| (T : C ββ[F2] E) : | |
| linearTraceCharacter T (A.comp Q) = linearTraceCharacter (Q.comp T) A := by | |
| simp only [linearTraceCharacter_apply, linearTracePair, LinearMap.comp_assoc] | |
| theorem traceCharacter_re_add (T : C ββ[F2] E) (X Y : E ββ[F2] C) : | |
| (linearTraceCharacter T (X + Y)).re = | |
| (linearTraceCharacter T X).re * (linearTraceCharacter T Y).re := by | |
| rw [AddChar.map_add_eq_mul, Complex.mul_re] | |
| simp [linearTraceCharacter_apply, binarySign_im] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 C] [FiniteDimensional F2 V] | |
| [Fintype (E ββ[F2] C)] [Fintype (C ββ[F2] E)] [Fintype (V ββ[F2] C)] | |
| omit [FiniteDimensional F2 E] [Fintype (E ββ[F2] C)] [Fintype (C ββ[F2] E)] in | |
| /-- Characters restricted to the row vanish unless the dual map lands in the | |
| kernel of `Q`. For `Q = W.mkQ` this is precisely `range T β€ W`. -/ | |
| theorem row_character_average (Q : E ββ[F2] V) (T : C ββ[F2] E) : | |
| (πΌ A : V ββ[F2] C, (linearTraceCharacter T (A.comp Q)).re) = | |
| if Q.comp T = 0 then 1 else 0 := by | |
| have hcomplex : (πΌ A : V ββ[F2] C, | |
| linearTraceCharacter T (A.comp Q)) = if Q.comp T = 0 then 1 else 0 := by | |
| simp only [traceCharacter_comp, Fintype.expect_eq_sum_div_card, | |
| sum_linearTraceCharacter] | |
| split <;> simp [Fintype.card_ne_zero] | |
| have h := congrArg Complex.re hcomplex | |
| simpa only [Complex.re_expect, apply_ite, Complex.one_re, Complex.zero_re] using h | |
| omit [FiniteDimensional F2 E] [Fintype (E ββ[F2] C)] in | |
| /-- Averaging a finite trace-character expansion on an actual affine row. -/ | |
| theorem row_spectral_average (Q : E ββ[F2] V) (Xβ : E ββ[F2] C) | |
| (a : (C ββ[F2] E) β β) : | |
| (πΌ A : V ββ[F2] C, β T : C ββ[F2] E, | |
| a T * (linearTraceCharacter T (Xβ + A.comp Q)).re) = | |
| β T : C ββ[F2] E, if Q.comp T = 0 then | |
| a T * (linearTraceCharacter T Xβ).re else 0 := by | |
| rw [Finset.expect_sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro T _ | |
| simp only [traceCharacter_re_add, β mul_assoc] | |
| rw [β Finset.mul_expect, row_character_average] | |
| split <;> simp | |
| /-- Equation (5.18), with the primal row parametrized by actual quotient maps. -/ | |
| theorem row_fourier_average (Q : E ββ[F2] V) (Xβ : E ββ[F2] C) | |
| (g : (E ββ[F2] C) β β) : | |
| (πΌ A : V ββ[F2] C, g (Xβ + A.comp Q)) = | |
| β T : C ββ[F2] E, if Q.comp T = 0 then | |
| linearCoeff g T * (linearTraceCharacter T Xβ).re else 0 := by | |
| rw [β row_spectral_average] | |
| apply Finset.expect_congr rfl | |
| intro A _ | |
| exact (linear_fourier_inversion g _).symm | |
| omit [FiniteDimensional F2 E] [Fintype (E ββ[F2] C)] [Fintype (C ββ[F2] E)] in | |
| theorem shift_character_average [Fintype C] (Ο : E ββ[F2] F2) | |
| (T : C ββ[F2] E) : | |
| (πΌ c : C, (linearTraceCharacter T (Ο.smulRight c)).re) = | |
| if Ο.comp T = 0 then 1 else 0 := by | |
| have hc := linearTrace_shift_average Ο T | |
| rw [β Fintype.expect_eq_sum_div_card] at hc | |
| have hr := congrArg Complex.re hc | |
| simpa only [Complex.re_expect, apply_ite, Complex.one_re, Complex.zero_re] using hr | |
| /-- The folding average is the Fourier projection onto parity-zero frequencies. -/ | |
| theorem shift_fourier_average [Fintype C] (Ο : E ββ[F2] F2) | |
| (X : E ββ[F2] C) (g : (E ββ[F2] C) β β) : | |
| (πΌ c : C, g (X + Ο.smulRight c)) = | |
| β T : C ββ[F2] E, (if Ο.comp T = 0 then linearCoeff g T else 0) * | |
| (linearTraceCharacter T X).re := by | |
| calc | |
| _ = πΌ c : C, β T : C ββ[F2] E, | |
| linearCoeff g T * (linearTraceCharacter T (X + Ο.smulRight c)).re := by | |
| apply Finset.expect_congr rfl | |
| intro c _ | |
| exact (linear_fourier_inversion g _).symm | |
| _ = _ := by | |
| rw [Finset.expect_sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro T _ | |
| simp only [traceCharacter_re_add, β mul_assoc] | |
| rw [β Finset.mul_expect, shift_character_average] | |
| split <;> simp | |
| /-- The parity-zero row subtotal equals the row average of the folded average. -/ | |
| theorem row_shift_fourier_average [Fintype C] (Q : E ββ[F2] V) | |
| (Ο : E ββ[F2] F2) (Xβ : E ββ[F2] C) (g : (E ββ[F2] C) β β) : | |
| (πΌ A : V ββ[F2] C, πΌ c : C, g (Xβ + A.comp Q + Ο.smulRight c)) = | |
| β T : C ββ[F2] E, if Q.comp T = 0 β§ Ο.comp T = 0 then | |
| linearCoeff g T * (linearTraceCharacter T Xβ).re else 0 := by | |
| simp only [shift_fourier_average] | |
| rw [row_spectral_average] | |
| apply Finset.sum_congr rfl | |
| intro T _ | |
| split_ifs <;> simp_all | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 C] | |
| [Fintype (E ββ[F2] C)] [Fintype (C ββ[F2] E)] in | |
| theorem signed_coefficient_le_abs (a : β) (T : C ββ[F2] E) | |
| (X : E ββ[F2] C) : a * (linearTraceCharacter T X).re β€ |a| := by | |
| rcases Integration.BinaryLinear.scalar_cases (linearTracePair X T) with h | h | |
| Β· simpa [linearTraceCharacter_apply, h] using le_abs_self a | |
| Β· simpa [linearTraceCharacter_apply, h] using neg_le_abs a | |
| /-- Actual coefficient extraction from a dense affine row and a uniformly small | |
| folding average. The row frequency count is an explicit finite cardinal bound; | |
| the quotient/subspace specialization supplies it by counting maps into `W`. -/ | |
| theorem coefficient_of_dense_row [Fintype C] (Q : E ββ[F2] V) | |
| (Ο : E ββ[F2] F2) (Xβ : E ββ[F2] C) (g : (E ββ[F2] C) β β) | |
| (Ο : β) (N : Nat) (Ο_pos : 0 < Ο) (N_pos : 0 < N) | |
| (row_count : (Finset.univ.filter fun T : C ββ[F2] E => Q.comp T = 0).card β€ N) | |
| (dense : Ο < πΌ A : V ββ[F2] C, g (Xβ + A.comp Q)) | |
| (shift_bound : β X, (πΌ c : C, g (X + Ο.smulRight c)) β€ Ο / 2) : | |
| β T : C ββ[F2] E, Q.comp T = 0 β§ Ο.comp T β 0 β§ | |
| Ο / (2 * (N : β)) < |linearCoeff g T| := by | |
| classical | |
| let row : Finset (C ββ[F2] E) := Finset.univ.filter fun T => Q.comp T = 0 | |
| let term (T : C ββ[F2] E) := linearCoeff g T * (linearTraceCharacter T Xβ).re | |
| let Ξ² : β := (Ο / 2) / (N : β) | |
| have hN : (0 : β) < (N : β) := Nat.cast_pos.mpr N_pos | |
| have hΞ² : 0 β€ Ξ² := le_of_lt (div_pos (div_pos Ο_pos zero_lt_two) hN) | |
| have hbudget : (N : β) * Ξ² = Ο / 2 := by | |
| dsimp [Ξ²] | |
| rw [mul_comm, div_mul_cancelβ _ (ne_of_gt hN)] | |
| have htotal : Ο < β T : C ββ[F2] E, | |
| if Q.comp T = 0 then term T else 0 := by | |
| rw [row_fourier_average] at dense | |
| apply lt_of_lt_of_eq dense | |
| apply Finset.sum_congr rfl | |
| intro frequency _ | |
| exact ite_congr rfl (fun _ => rfl) (fun _ => rfl) | |
| have hzero : (β T : C ββ[F2] E, | |
| if Q.comp T = 0 β§ Ο.comp T = 0 then term T else 0) β€ Ο / 2 := by | |
| change (β T : C ββ[F2] E, if Q.comp T = 0 β§ Ο.comp T = 0 then | |
| linearCoeff g T * (linearTraceCharacter T Xβ).re else 0) β€ _ | |
| rw [β row_shift_fourier_average] | |
| apply Finset.expect_le Finset.univ_nonempty | |
| intro A _ | |
| exact shift_bound (Xβ + A.comp Q) | |
| have hsplit : (β T : C ββ[F2] E, if Q.comp T = 0 then term T else 0) = | |
| (β T : C ββ[F2] E, if Q.comp T = 0 β§ Ο.comp T = 0 then term T else 0) + | |
| β T β row, if Ο.comp T = 0 then 0 else term T := by | |
| simp only [row, Finset.sum_filter] | |
| rw [β Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro T _ | |
| split_ifs <;> simp_all | |
| have hnonzero : Ο / 2 < β T β row, if Ο.comp T = 0 then 0 else term T := by | |
| linarith | |
| by_contra hnone | |
| have hsmall : β T β row, (if Ο.comp T = 0 then 0 else term T) β€ Ξ² := by | |
| intro T hT | |
| split_ifs with hΟ | |
| Β· exact hΞ² | |
| Β· have hQ : Q.comp T = 0 := (Finset.mem_filter.mp hT).2 | |
| have hc : |linearCoeff g T| β€ Ξ² := by | |
| by_contra hc | |
| apply hnone | |
| refine β¨T, hQ, hΟ, ?_β© | |
| have hlarge : Ξ² < |linearCoeff g T| := lt_of_not_ge hc | |
| simpa only [Ξ², div_div] using hlarge | |
| exact (signed_coefficient_le_abs (linearCoeff g T) T Xβ).trans hc | |
| have hsum := Finset.sum_le_sum hsmall | |
| have hcard : (row.card : β) β€ (N : β) := by exact_mod_cast row_count | |
| have hcount := mul_le_mul_of_nonneg_right hcard hΞ² | |
| have hsum' : (β T β row, if Ο.comp T = 0 then 0 else term T) β€ | |
| (row.card : β) * Ξ² := by | |
| simpa only [Finset.sum_const, nsmul_eq_mul] using hsum | |
| linarith | |
| /-- Dense-row extraction for a genuinely folded color map. The zero-parity | |
| subtotal bound follows from folding, rather than being supplied as a hypothesis. -/ | |
| theorem coefficient_of_folded_dense_row [Fintype C] | |
| {D : Type*} [AddCommGroup D] [Module F2 D] | |
| (Q : E ββ[F2] V) (Ο : E ββ[F2] F2) (Xβ : E ββ[F2] C) | |
| (inclusion : C ββ[F2] D) (inclusion_injective : Function.Injective inclusion) | |
| (F : (E ββ[F2] C) β D) | |
| (folded : β X c, F (X + Ο.smulRight c) = F X + inclusion c) | |
| (y : D) (Ο : β) (N : Nat) (Ο_pos : 0 < Ο) (N_pos : 0 < N) | |
| (color_bound : 1 / (Fintype.card C : β) β€ Ο / 2) | |
| (row_count : (Finset.univ.filter fun T : C ββ[F2] E => Q.comp T = 0).card β€ N) | |
| (dense : Ο < πΌ A : V ββ[F2] C, if F (Xβ + A.comp Q) = y then (1 : β) else 0) : | |
| β T : C ββ[F2] E, Q.comp T = 0 β§ Ο.comp T β 0 β§ | |
| Ο / (2 * (N : β)) < |linearCoeff (fun X => if F X = y then 1 else 0) T| := by | |
| apply coefficient_of_dense_row Q Ο Xβ (fun X => if F X = y then 1 else 0) | |
| Ο N Ο_pos N_pos row_count dense | |
| intro X | |
| rw [Fintype.expect_eq_sum_div_card] | |
| exact (folded_indicator_average_le Ο inclusion inclusion_injective F folded X y).trans | |
| color_bound | |
| lemma color_card_bound [Fintype C] (r s : Nat) (Ο : β) | |
| (hΟ : Ο = 2 / (2 : β) ^ (s - r)) | |
| (hdim : s - r β€ Module.finrank F2 C) : | |
| 1 / (Fintype.card C : β) β€ Ο / 2 := by | |
| have hcard : Fintype.card C = 2 ^ Module.finrank F2 C := by | |
| simpa [F2, ZMod.card] using Module.card_fintype (Module.finBasis F2 C) | |
| have hleNat : 2 ^ (s - r) β€ Fintype.card C := by | |
| rw [hcard] | |
| exact Nat.pow_le_pow_right (by decide : 0 < 2) hdim | |
| have hle : (2 : β) ^ (s - r) β€ (Fintype.card C : β) := by | |
| exact_mod_cast hleNat | |
| calc | |
| 1 / (Fintype.card C : β) β€ 1 / (2 : β) ^ (s - r) := | |
| one_div_le_one_div_of_le (pow_pos zero_lt_two _) hle | |
| _ = Ο / 2 := by rw [hΟ]; ring | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 C] | |
| [Fintype (E ββ[F2] C)] [Fintype (C ββ[F2] E)] in | |
| lemma fixed_row_folded {R D : Type*} | |
| [AddCommGroup R] [Module F2 R] [AddCommGroup D] [Module F2 D] | |
| (Ο : E ββ[F2] F2) (questionInclusion : C ββ[F2] R) | |
| (colorInclusion : C ββ[F2] D) | |
| (FU : (E ββ[F2] R) β D) (Z : E ββ[F2] R) | |
| (folded : β Y c, FU (Y + Ο.smulRight (questionInclusion c)) = FU Y + colorInclusion c) : | |
| β X c, FU (Z + questionInclusion.comp (X + Ο.smulRight c)) = | |
| FU (Z + questionInclusion.comp X) + colorInclusion c := by | |
| intro X c | |
| have hshift : questionInclusion.comp (Ο.smulRight c) = Ο.smulRight (questionInclusion c) := by | |
| ext e | |
| simp [LinearMap.smulRight_apply] | |
| rw [LinearMap.comp_add, hshift, β add_assoc, folded] | |
| /-- Lemma 5.3 on an actual quotient-parametrized dense row. The density parameter | |
| is stated as a ratio of natural powers, avoiding truncated negative exponents. -/ | |
| theorem lemma53_quotient [Fintype C] | |
| {D : Type*} [AddCommGroup D] [Module F2 D] | |
| (W : Submodule F2 E) | |
| [Fintype ((E β§Έ W) ββ[F2] C)] [Fintype (C ββ[F2] W)] | |
| (Ο : E ββ[F2] F2) (Xβ : E ββ[F2] C) | |
| (inclusion : C ββ[F2] D) (inclusion_injective : Function.Injective inclusion) | |
| (F : (E ββ[F2] C) β D) | |
| (folded : β X c, F (X + Ο.smulRight c) = F X + inclusion c) | |
| (y : D) (r s : Nat) (Ο : β) | |
| (hΟ : Ο = 2 / (2 : β) ^ (s - r)) | |
| (hW : Module.finrank F2 W β€ r) | |
| (hC : Module.finrank F2 C β€ s) | |
| (hdim : s - r β€ Module.finrank F2 C) | |
| (dense : Ο < πΌ A : (E β§Έ W) ββ[F2] C, | |
| if F (Xβ + A.comp W.mkQ) = y then (1 : β) else 0) : | |
| β T : C ββ[F2] E, Ο.comp T β 0 β§ | |
| Ο / (2 * ((2 ^ (r * s) : Nat) : β)) < | |
| |linearCoeff (fun X => if F X = y then 1 else 0) T| := by | |
| have hΟpos : 0 < Ο := by | |
| rw [hΟ] | |
| exact div_pos zero_lt_two (pow_pos zero_lt_two _) | |
| have hcount : (Finset.univ.filter fun T : C ββ[F2] E => W.mkQ.comp T = 0).card β€ | |
| 2 ^ (r * s) := by | |
| rw [β Finset.filter_congr_decidable Finset.univ | |
| (fun frequency : C ββ[F2] E => W.mkQ.comp frequency = 0) | |
| (fun frequency => Classical.propDecidable (W.mkQ.comp frequency = 0)), | |
| MatrixRestrictions.quotientKernel_filter_card W] | |
| exact MatrixParity.card_linearMaps_le (E := W) (C := C) r s hW hC | |
| obtain β¨T, _, hΟ, hΞ²β© := coefficient_of_folded_dense_row W.mkQ Ο Xβ | |
| inclusion inclusion_injective F folded y Ο (2 ^ (r * s)) hΟpos | |
| (Nat.two_pow_pos _) (color_card_bound r s Ο hΟ hdim) hcount dense | |
| exact β¨T, hΟ, hΞ²β© | |
| end UniqueGamesTheorem.Fourier.MatrixParityRow | |
| end | |
| end | |
| end OAI | |