Download data/lean/OAI/Computability/UniqueGames/Analysis/MatrixCharactersLemmas.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 35.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixCharactersLemmas.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixCharactersLemmas.lean
-
curl -L -o MatrixCharactersLemmas.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/Analysis/MatrixCharactersLemmas.lean
35.5 kB
| import Mathlib.Algebra.BigOperators.Expect | |
| import Mathlib.Algebra.Field.ZMod | |
| import Mathlib.Algebra.Group.AddChar | |
| import Mathlib.Basic.Complex.Basic | |
| import Mathlib.Basic.Real.Basic | |
| import Mathlib.LinearAlgebra.Dual.Lemmas | |
| import Mathlib.LinearAlgebra.Matrix.Trace | |
| import Mathlib.LinearAlgebra.Trace | |
| import OAI.Computability.UniqueGames.Analysis.ParityLemmas | |
| import OAI.Computability.UniqueGames.Reduction.BinaryLinear | |
| namespace OAI | |
| section | |
| /-! Trace characters on actual finite binary matrix spaces. -/ | |
| noncomputable section | |
| namespace UniqueGamesTheorem.Fourier.MatrixCharacters | |
| open scoped BigOperators Classical | |
| open UniqueGamesTheorem.Integration.BinaryLinear | |
| abbrev F2 := UniqueGamesTheorem.Integration.BinaryLinear.F2 | |
| /-- The binary trace pairing between oppositely oriented matrices. -/ | |
| def tracePair {n m : Nat} (X : Matrix (Fin n) (Fin m) F2) | |
| (S : Matrix (Fin m) (Fin n) F2) : F2 := Matrix.trace (X * S) | |
| theorem tracePair_eq_sum_entries {n m : Nat} (X : Matrix (Fin n) (Fin m) F2) | |
| (S : Matrix (Fin m) (Fin n) F2) : | |
| tracePair X S = β i, β j, X i j * S j i := rfl | |
| theorem tracePair_swap {n m : Nat} (X : Matrix (Fin n) (Fin m) F2) | |
| (S : Matrix (Fin m) (Fin n) F2) : tracePair X S = tracePair S X := | |
| Matrix.trace_mul_comm X S | |
| @[simp] theorem tracePair_zero_left {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) : | |
| tracePair (0 : Matrix (Fin n) (Fin m) F2) S = 0 := by simp [tracePair] | |
| @[simp] theorem tracePair_zero_right {n m : Nat} (X : Matrix (Fin n) (Fin m) F2) : | |
| tracePair X (0 : Matrix (Fin m) (Fin n) F2) = 0 := by simp [tracePair] | |
| theorem tracePair_add_left {n m : Nat} (X Y : Matrix (Fin n) (Fin m) F2) | |
| (S : Matrix (Fin m) (Fin n) F2) : | |
| tracePair (X + Y) S = tracePair X S + tracePair Y S := by | |
| simp [tracePair, Matrix.add_mul] | |
| theorem tracePair_add_right {n m : Nat} (X : Matrix (Fin n) (Fin m) F2) | |
| (S T : Matrix (Fin m) (Fin n) F2) : | |
| tracePair X (S + T) = tracePair X S + tracePair X T := by | |
| simp [tracePair, Matrix.mul_add] | |
| theorem tracePair_ext_right {n m : Nat} {S T : Matrix (Fin m) (Fin n) F2} | |
| (h : β X, tracePair X S = tracePair X T) : S = T := | |
| Matrix.ext_iff_trace_mul_left.mpr h | |
| theorem tracePair_ext_left {n m : Nat} {X Y : Matrix (Fin n) (Fin m) F2} | |
| (h : β S, tracePair X S = tracePair Y S) : X = Y := | |
| Matrix.ext_iff_trace_mul_right.mpr h | |
| /-- A nonzero matrix has trace pairing one with a dual matrix. -/ | |
| theorem exists_tracePair_eq_one {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) | |
| (hS : S β 0) : β X, tracePair X S = 1 := by | |
| by_contra h | |
| apply hS | |
| apply tracePair_ext_right | |
| intro X | |
| rw [tracePair_zero_right] | |
| rcases scalar_cases (tracePair X S) with hzero | hone | |
| Β· exact hzero | |
| Β· exact False.elim (h β¨X, honeβ©) | |
| /-- The unique nontrivial complex-valued character of the binary field. -/ | |
| def binarySign (a : F2) : β := if a = 0 then 1 else -1 | |
| @[simp] theorem binarySign_zero : binarySign 0 = 1 := by simp [binarySign] | |
| @[simp] theorem binarySign_one : binarySign 1 = -1 := by simp [binarySign] | |
| theorem binarySign_eq_neg_one_pow_val (a : F2) : | |
| binarySign a = (-1 : β) ^ a.val := by | |
| rcases scalar_cases a with rfl | rfl <;> | |
| simp [show (1 : F2).val = 1 by decide] | |
| theorem binarySign_add (a b : F2) : binarySign (a + b) = binarySign a * binarySign b := by | |
| have htwo : (1 : F2) + 1 = 0 := by decide | |
| rcases scalar_cases a with rfl | rfl <;> | |
| rcases scalar_cases b with rfl | rfl <;> simp [htwo] | |
| theorem binarySign_sum {ΞΉ : Type*} (s : Finset ΞΉ) (f : ΞΉ β F2) : | |
| binarySign (β i β s, f i) = β i β s, binarySign (f i) := by | |
| classical | |
| induction s using Finset.induction_on with | |
| | empty => simp | |
| | @insert a s ha ih => simp [ha, binarySign_add, ih] | |
| theorem binarySign_injective : Function.Injective binarySign := by | |
| intro a b h | |
| rcases scalar_cases a with rfl | rfl <;> | |
| rcases scalar_cases b with rfl | rfl | |
| Β· rfl | |
| Β· have hf : (1 : β) = -1 := by simpa using h | |
| exact False.elim (one_ne_zero ((CharZero.eq_neg_self_iff).mp hf)) | |
| Β· have hf : (1 : β) = -1 := by simpa using h.symm | |
| exact False.elim (one_ne_zero ((CharZero.eq_neg_self_iff).mp hf)) | |
| Β· rfl | |
| theorem binarySign_real (a : F2) : ((binarySign a).re : β) = binarySign a := by | |
| unfold binarySign | |
| split <;> simp | |
| @[simp] theorem binarySign_im (a : F2) : (binarySign a).im = 0 := by | |
| unfold binarySign | |
| split <;> simp | |
| @[simp] theorem binarySign_mul_self (a : F2) : binarySign a * binarySign a = 1 := by | |
| unfold binarySign | |
| split <;> simp | |
| section LinearFunctionals | |
| variable {E : Type*} [AddCommGroup E] [Module F2 E] | |
| /-- A binary linear functional determines a complex additive character. -/ | |
| def linearFunctionalCharacter (Ο : E ββ[F2] F2) : AddChar E β where | |
| toFun x := binarySign (Ο x) | |
| map_zero_eq_one' := by simp | |
| map_add_eq_mul' x y := by rw [map_add, binarySign_add] | |
| @[simp] theorem linearFunctionalCharacter_apply (Ο : E ββ[F2] F2) (x : E) : | |
| linearFunctionalCharacter Ο x = binarySign (Ο x) := rfl | |
| @[simp] theorem linearFunctionalCharacter_zero : | |
| linearFunctionalCharacter (0 : E ββ[F2] F2) = 0 := by | |
| ext x | |
| simp | |
| theorem linearFunctionalCharacter_injective : | |
| Function.Injective (linearFunctionalCharacter (E := E)) := by | |
| intro Ο Ο h | |
| ext x | |
| apply binarySign_injective | |
| exact congrArg (fun Ο : AddChar E β => Ο x) h | |
| theorem linearFunctionalCharacter_eq_zero_iff (Ο : E ββ[F2] F2) : | |
| linearFunctionalCharacter Ο = 0 β Ο = 0 := by | |
| rw [β linearFunctionalCharacter_zero, linearFunctionalCharacter_injective.eq_iff] | |
| theorem sum_linearFunctionalCharacter [Fintype E] (Ο : E ββ[F2] F2) : | |
| β x, linearFunctionalCharacter Ο x = | |
| if Ο = 0 then (Fintype.card E : β) else 0 := by | |
| rw [AddChar.sum_eq_ite] | |
| simp only [linearFunctionalCharacter_eq_zero_iff] | |
| theorem expect_linearFunctionalCharacter [Fintype E] (Ο : E ββ[F2] F2) : | |
| (πΌ x, linearFunctionalCharacter Ο x) = if Ο = 0 then 1 else 0 := by | |
| rw [Fintype.expect_eq_sum_div_card, sum_linearFunctionalCharacter] | |
| split_ifs <;> simp [Fintype.card_ne_zero] | |
| end LinearFunctionals | |
| def traceCharacter {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) : | |
| AddChar (Matrix (Fin n) (Fin m) F2) β where | |
| toFun X := binarySign (tracePair X S) | |
| map_zero_eq_one' := by simp | |
| map_add_eq_mul' X Y := by rw [tracePair_add_left, binarySign_add] | |
| @[simp] theorem traceCharacter_apply {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) | |
| (X : Matrix (Fin n) (Fin m) F2) : | |
| traceCharacter S X = binarySign (tracePair X S) := rfl | |
| theorem traceCharacter_eq_coordinate_sign {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) | |
| (X : Matrix (Fin n) (Fin m) F2) : | |
| traceCharacter S X = if (β i, β j, X i j * S j i) = 0 then 1 else -1 := rfl | |
| theorem traceCharacter_eq_trace_exponent {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) | |
| (X : Matrix (Fin n) (Fin m) F2) : | |
| traceCharacter S X = (-1 : β) ^ (Matrix.trace (X * S)).val := | |
| binarySign_eq_neg_one_pow_val _ | |
| theorem traceCharacter_eq_product_entries {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) | |
| (X : Matrix (Fin n) (Fin m) F2) : | |
| traceCharacter S X = β i, β j, binarySign (X i j * S j i) := by | |
| simp only [traceCharacter_apply, tracePair_eq_sum_entries, binarySign_sum] | |
| theorem traceCharacter_real {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) | |
| (X : Matrix (Fin n) (Fin m) F2) : | |
| ((traceCharacter S X).re : β) = traceCharacter S X := binarySign_real _ | |
| theorem traceCharacter_add {n m : Nat} (S T : Matrix (Fin m) (Fin n) F2) : | |
| traceCharacter (S + T) = traceCharacter S + traceCharacter T := by | |
| ext X | |
| simp only [traceCharacter_apply, tracePair_add_right, binarySign_add, AddChar.add_apply] | |
| @[simp] theorem traceCharacter_zero {n m : Nat} : | |
| traceCharacter (0 : Matrix (Fin m) (Fin n) F2) = 0 := by | |
| ext X | |
| simp | |
| theorem traceCharacter_injective {n m : Nat} : | |
| Function.Injective (traceCharacter (n := n) (m := m)) := by | |
| intro S T h | |
| apply tracePair_ext_right | |
| intro X | |
| apply binarySign_injective | |
| exact congrArg (fun Ο : AddChar (Matrix (Fin n) (Fin m) F2) β => Ο X) h | |
| theorem traceCharacter_eq_zero_iff {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) : | |
| traceCharacter S = 0 β S = 0 := by | |
| rw [β traceCharacter_zero, traceCharacter_injective.eq_iff] | |
| theorem sum_traceCharacter {n m : Nat} (S : Matrix (Fin m) (Fin n) F2) : | |
| β X, traceCharacter S X = | |
| if S = 0 then (Fintype.card (Matrix (Fin n) (Fin m) F2) : β) else 0 := by | |
| classical | |
| rw [AddChar.sum_eq_ite] | |
| simp only [traceCharacter_eq_zero_iff] | |
| section LinearMaps | |
| variable {E F : Type*} [AddCommGroup E] [Module F2 E] | |
| [AddCommGroup F] [Module F2 F] | |
| /-- The basis-independent trace pairing in the statement of Lemma 2.1. -/ | |
| def linearTracePair (X : E ββ[F2] F) (S : F ββ[F2] E) : F2 := | |
| LinearMap.trace F2 F (X.comp S) | |
| theorem linearTracePair_eq_matrix_tracePair {n m : Nat} | |
| (bE : Module.Basis (Fin m) F2 E) (bF : Module.Basis (Fin n) F2 F) | |
| (X : E ββ[F2] F) (S : F ββ[F2] E) : | |
| linearTracePair X S = | |
| tracePair (LinearMap.toMatrix bE bF X) (LinearMap.toMatrix bF bE S) := by | |
| change LinearMap.trace F2 F (X.comp S) = | |
| Matrix.trace (LinearMap.toMatrix bE bF X * LinearMap.toMatrix bF bE S) | |
| rw [LinearMap.trace_eq_matrix_trace F2 bF, LinearMap.toMatrix_comp bF bE bF] | |
| @[simp] theorem linearTracePair_zero_left (S : F ββ[F2] E) : | |
| linearTracePair (0 : E ββ[F2] F) S = 0 := by simp [linearTracePair] | |
| @[simp] theorem linearTracePair_zero_right (X : E ββ[F2] F) : | |
| linearTracePair X (0 : F ββ[F2] E) = 0 := by simp [linearTracePair] | |
| theorem linearTracePair_add_left (X Y : E ββ[F2] F) (S : F ββ[F2] E) : | |
| linearTracePair (X + Y) S = linearTracePair X S + linearTracePair Y S := by | |
| simp [linearTracePair, LinearMap.add_comp] | |
| theorem linearTracePair_add_right (X : E ββ[F2] F) (S T : F ββ[F2] E) : | |
| linearTracePair X (S + T) = linearTracePair X S + linearTracePair X T := by | |
| simp [linearTracePair, LinearMap.comp_add] | |
| /-- The trace character on actual linear maps, with no choice of basis. -/ | |
| def linearTraceCharacter (S : F ββ[F2] E) : AddChar (E ββ[F2] F) β where | |
| toFun X := binarySign (linearTracePair X S) | |
| map_zero_eq_one' := by simp | |
| map_add_eq_mul' X Y := by rw [linearTracePair_add_left, binarySign_add] | |
| @[simp] theorem linearTraceCharacter_apply (S : F ββ[F2] E) (X : E ββ[F2] F) : | |
| linearTraceCharacter S X = binarySign (linearTracePair X S) := rfl | |
| theorem linearTraceCharacter_real (S : F ββ[F2] E) (X : E ββ[F2] F) : | |
| ((linearTraceCharacter S X).re : β) = linearTraceCharacter S X := binarySign_real _ | |
| theorem linearTraceCharacter_add (S T : F ββ[F2] E) : | |
| linearTraceCharacter (S + T) = linearTraceCharacter S + linearTraceCharacter T := by | |
| ext X | |
| simp only [linearTraceCharacter_apply, linearTracePair_add_right, binarySign_add, | |
| AddChar.add_apply] | |
| @[simp] theorem linearTraceCharacter_zero : | |
| linearTraceCharacter (0 : F ββ[F2] E) = 0 := by | |
| ext X | |
| simp | |
| theorem linearTraceCharacter_eq_matrix_traceCharacter {n m : Nat} | |
| (bE : Module.Basis (Fin m) F2 E) (bF : Module.Basis (Fin n) F2 F) | |
| (S : F ββ[F2] E) (X : E ββ[F2] F) : | |
| linearTraceCharacter S X = | |
| traceCharacter (LinearMap.toMatrix bF bE S) (LinearMap.toMatrix bE bF X) := by | |
| simp only [linearTraceCharacter_apply, traceCharacter_apply, | |
| linearTracePair_eq_matrix_tracePair bE bF] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 F] | |
| theorem linearTracePair_swap (X : E ββ[F2] F) (S : F ββ[F2] E) : | |
| linearTracePair X S = linearTracePair S X := | |
| LinearMap.trace_comp_comm' S X | |
| theorem linearTraceCharacter_swap (S : F ββ[F2] E) (X : E ββ[F2] F) : | |
| linearTraceCharacter S X = linearTraceCharacter X S := by | |
| simp only [linearTraceCharacter_apply, linearTracePair_swap X S] | |
| /-- The actual trace pairing is nondegenerate in its dual-map argument. -/ | |
| theorem linearTracePair_ext_right {S T : F ββ[F2] E} | |
| (h : β X, linearTracePair X S = linearTracePair X T) : S = T := by | |
| classical | |
| let bE := Module.finBasis F2 E | |
| let bF := Module.finBasis F2 F | |
| apply (LinearMap.toMatrix bF bE).injective | |
| apply tracePair_ext_right | |
| intro X | |
| obtain β¨X', rflβ© := (LinearMap.toMatrix bE bF).surjective X | |
| exact (linearTracePair_eq_matrix_tracePair bE bF X' S).symm.trans | |
| ((h X').trans (linearTracePair_eq_matrix_tracePair bE bF X' T)) | |
| /-- Nondegeneracy also holds in the primal-map argument. -/ | |
| theorem linearTracePair_ext_left {X Y : E ββ[F2] F} | |
| (h : β S, linearTracePair X S = linearTracePair Y S) : X = Y := by | |
| classical | |
| let bE := Module.finBasis F2 E | |
| let bF := Module.finBasis F2 F | |
| apply (LinearMap.toMatrix bE bF).injective | |
| apply tracePair_ext_left | |
| intro S | |
| obtain β¨S', rflβ© := (LinearMap.toMatrix bF bE).surjective S | |
| exact (linearTracePair_eq_matrix_tracePair bE bF X S').symm.trans | |
| ((h S').trans (linearTracePair_eq_matrix_tracePair bE bF Y S')) | |
| theorem exists_linearTracePair_eq_one (S : F ββ[F2] E) (hS : S β 0) : | |
| β X, linearTracePair X S = 1 := by | |
| by_contra h | |
| apply hS | |
| apply linearTracePair_ext_right | |
| intro X | |
| rw [linearTracePair_zero_right] | |
| rcases scalar_cases (linearTracePair X S) with hzero | hone | |
| Β· exact hzero | |
| Β· exact False.elim (h β¨X, honeβ©) | |
| theorem linearTraceCharacter_injective : | |
| Function.Injective (linearTraceCharacter (E := E) (F := F)) := by | |
| intro S T h | |
| apply linearTracePair_ext_right | |
| intro X | |
| apply binarySign_injective | |
| exact congrArg (fun Ο : AddChar (E ββ[F2] F) β => Ο X) h | |
| theorem linearTraceCharacter_eq_zero_iff (S : F ββ[F2] E) : | |
| linearTraceCharacter S = 0 β S = 0 := by | |
| rw [β linearTraceCharacter_zero, linearTraceCharacter_injective.eq_iff] | |
| theorem sum_linearTraceCharacter [Fintype (E ββ[F2] F)] (S : F ββ[F2] E) : | |
| β X, linearTraceCharacter S X = | |
| if S = 0 then (Fintype.card (E ββ[F2] F) : β) else 0 := by | |
| classical | |
| rw [AddChar.sum_eq_ite] | |
| simp only [linearTraceCharacter_eq_zero_iff] | |
| end LinearMaps | |
| end UniqueGamesTheorem.Fourier.MatrixCharacters | |
| end | |
| end | |
| section | |
| /-! | |
| # Normalized Fourier analysis of finite binary linear-map spaces | |
| The coefficient normalization is uniform expectation on the primal space. The | |
| Parseval sum over frequencies is an unnormalized sum. The underlying complex | |
| Fourier system is the actual trace-character family on the finite additive group. | |
| Completeness is proved directly from character cancellation and finite sums. | |
| -/ | |
| noncomputable section | |
| namespace UniqueGamesTheorem.Fourier.MatrixFourier | |
| attribute [local instance] Classical.propDecidable | |
| open scoped BigOperators ComplexConjugate | |
| open Finset | |
| open UniqueGamesTheorem.Fourier.MatrixCharacters | |
| section FiniteGroup | |
| variable {G : Type*} [AddCommGroup G] [Fintype G] | |
| /-- Uniformly normalized complex Fourier coefficient. -/ | |
| def fourierCoeff (f : G β β) (Ο : AddChar G β) : β := | |
| πΌ x, f x * star (Ο x) | |
| theorem fourierCoeff_sum {J : Type*} (s : Finset J) (f : J β G β β) | |
| (Ο : AddChar G β) : | |
| fourierCoeff (β j β s, f j) Ο = β j β s, fourierCoeff (f j) Ο := by | |
| simp only [fourierCoeff, Finset.sum_apply, Finset.sum_mul] | |
| exact Finset.expect_sum_comm _ _ _ | |
| theorem fourierCoeff_smul (c : β) (f : G β β) (Ο : AddChar G β) : | |
| fourierCoeff (c β’ f) Ο = c * fourierCoeff f Ο := by | |
| simp only [fourierCoeff, Pi.smul_apply, smul_eq_mul, mul_assoc] | |
| exact Finset.mul_expect _ _ _ |>.symm | |
| omit [AddCommGroup G] in | |
| theorem star_expect (f : G β β) : | |
| star (πΌ x, f x) = πΌ x, star (f x) := by | |
| simp [Fintype.expect_eq_sum_div_card] | |
| theorem star_fourierCoeff (f : G β β) (Ο : AddChar G β) : | |
| star (fourierCoeff f Ο) = πΌ x, star (f x) * Ο x := by | |
| rw [fourierCoeff, star_expect] | |
| simp [star_mul, mul_comm] | |
| end FiniteGroup | |
| section LinearMaps | |
| 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)] | |
| /-- Real coefficient on the actual space of binary linear maps. -/ | |
| def linearCoeff (f : (E ββ[F2] F) β β) (S : F ββ[F2] E) : β := | |
| πΌ X, f X * (linearTraceCharacter S X).re | |
| theorem card_linearMap_reverse : | |
| Fintype.card (F ββ[F2] E) = Fintype.card (E ββ[F2] F) := by | |
| classical | |
| let bE := Module.finBasis F2 E | |
| let bF := Module.finBasis F2 F | |
| calc | |
| Fintype.card (F ββ[F2] E) = | |
| Fintype.card (Matrix (Fin (Module.finrank F2 E)) | |
| (Fin (Module.finrank F2 F)) F2) := | |
| Fintype.card_congr (LinearMap.toMatrix bF bE).toEquiv | |
| _ = Fintype.card (Matrix (Fin (Module.finrank F2 F)) | |
| (Fin (Module.finrank F2 E)) F2) := by | |
| exact Fintype.card_congr | |
| { toFun := Matrix.transpose | |
| invFun := Matrix.transpose | |
| left_inv := Matrix.transpose_transpose | |
| right_inv := Matrix.transpose_transpose } | |
| _ = Fintype.card (E ββ[F2] F) := | |
| (Fintype.card_congr (LinearMap.toMatrix bE bF).toEquiv).symm | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 F] | |
| [Fintype (E ββ[F2] F)] [Fintype (F ββ[F2] E)] in | |
| theorem linearTraceCharacter_star (S : F ββ[F2] E) (X : E ββ[F2] F) : | |
| star (linearTraceCharacter S X) = linearTraceCharacter S X := by | |
| calc | |
| _ = star (((linearTraceCharacter S X).re : β) : β) := | |
| congrArg star (linearTraceCharacter_real S X).symm | |
| _ = ((linearTraceCharacter S X).re : β) := by simp | |
| _ = linearTraceCharacter S X := linearTraceCharacter_real S X | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 F] | |
| [Fintype (E ββ[F2] F)] [Fintype (F ββ[F2] E)] in | |
| theorem linearMap_add_eq_zero_iff (X Y : E ββ[F2] F) : | |
| X + Y = 0 β X = Y := by | |
| have htwo : (1 + 1 : F2) = 0 := by decide | |
| have hself : Y + Y = 0 := by | |
| have h := congrArg (fun c : F2 => c β’ Y) htwo | |
| simpa only [add_smul, one_smul, zero_smul] using h | |
| have hneg : -Y = Y := neg_eq_iff_add_eq_zero.mpr hself | |
| rw [add_eq_zero_iff_eq_neg, hneg] | |
| /-- Exact trace-character orthogonality with the frequency sum unnormalized. -/ | |
| theorem linear_character_kernel (X Y : E ββ[F2] F) : | |
| β S : F ββ[F2] E, star (linearTraceCharacter S X) * linearTraceCharacter S Y = | |
| if X = Y then (Fintype.card (E ββ[F2] F) : β) else 0 := by | |
| classical | |
| calc | |
| _ = β S : F ββ[F2] E, linearTraceCharacter S (X + Y) := by | |
| apply Finset.sum_congr rfl | |
| intro S _ | |
| rw [linearTraceCharacter_star, AddChar.map_add_eq_mul] | |
| _ = β S : F ββ[F2] E, linearTraceCharacter (X + Y) S := by | |
| apply Finset.sum_congr rfl | |
| intro S _ | |
| exact linearTraceCharacter_swap S (X + Y) | |
| _ = if X + Y = 0 then (Fintype.card (F ββ[F2] E) : β) else 0 := | |
| sum_linearTraceCharacter (X + Y) | |
| _ = _ := by rw [linearMap_add_eq_zero_iff, card_linearMap_reverse] | |
| omit [Fintype (F ββ[F2] E)] in | |
| theorem linear_complexCoeff_character (S T : F ββ[F2] E) : | |
| fourierCoeff (linearTraceCharacter S : (E ββ[F2] F) β β) | |
| (linearTraceCharacter T) = if T = S then 1 else 0 := by | |
| classical | |
| simp only [fourierCoeff, linearTraceCharacter_star, β AddChar.add_apply, | |
| β linearTraceCharacter_add, Fintype.expect_eq_sum_div_card, | |
| sum_linearTraceCharacter, linearMap_add_eq_zero_iff] | |
| by_cases h : S = T | |
| Β· subst T | |
| simp | |
| Β· simp [h, Ne.symm h] | |
| /-- Fourier inversion obtained directly from the finite trace orthogonality sum. -/ | |
| theorem linear_complex_inversion (f : (E ββ[F2] F) β β) (Y : E ββ[F2] F) : | |
| β S : F ββ[F2] E, fourierCoeff f (linearTraceCharacter S) * | |
| linearTraceCharacter S Y = f Y := by | |
| classical | |
| simp only [fourierCoeff] | |
| simp_rw [Finset.expect_mul, mul_assoc] | |
| rw [β Finset.expect_sum_comm] | |
| simp_rw [β Finset.mul_sum, linear_character_kernel] | |
| rw [Finset.expect_eq_sum_div_card] | |
| simp [mul_ite] | |
| /-- Mixed Parseval with normalized primal expectation and unnormalized frequency sum. -/ | |
| theorem linear_complex_parseval (f g : (E ββ[F2] F) β β) : | |
| β S : F ββ[F2] E, star (fourierCoeff f (linearTraceCharacter S)) * | |
| fourierCoeff g (linearTraceCharacter S) = πΌ X, star (f X) * g X := by | |
| simp_rw [star_fourierCoeff, Finset.expect_mul] | |
| rw [β Finset.expect_sum_comm] | |
| apply Finset.expect_congr rfl | |
| intro X _ | |
| calc | |
| (β S : F ββ[F2] E, (star (f X) * linearTraceCharacter S X) * | |
| fourierCoeff g (linearTraceCharacter S)) = | |
| star (f X) * β S : F ββ[F2] E, | |
| fourierCoeff g (linearTraceCharacter S) * linearTraceCharacter S X := by | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro S _ | |
| ac_rfl | |
| _ = star (f X) * g X := by rw [linear_complex_inversion] | |
| theorem complex_ofReal_expect {J : Type*} [Fintype J] (f : J β β) : | |
| ((πΌ j, f j : β) : β) = πΌ j, (f j : β) := by | |
| simp only [Fintype.expect_eq_sum_div_card, Complex.ofReal_div, Complex.ofReal_natCast] | |
| congr 1 | |
| exact map_sum Complex.ofRealHom f Finset.univ | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 F] [Fintype (F ββ[F2] E)] in | |
| theorem linearCoeff_complex (f : (E ββ[F2] F) β β) (S : F ββ[F2] E) : | |
| (linearCoeff f S : β) = | |
| fourierCoeff (fun X => (f X : β)) (linearTraceCharacter S) := by | |
| rw [linearCoeff, complex_ofReal_expect, fourierCoeff] | |
| apply Finset.expect_congr rfl | |
| intro X _ | |
| rw [Complex.ofReal_mul, linearTraceCharacter_real, linearTraceCharacter_star] | |
| /-- Parseval for real functions and the real binary trace coefficients. -/ | |
| theorem linear_parseval_inner (f g : (E ββ[F2] F) β β) : | |
| β S : F ββ[F2] E, linearCoeff f S * linearCoeff g S = | |
| πΌ X, f X * g X := by | |
| apply Complex.ofReal_injective | |
| calc | |
| ((β S : F ββ[F2] E, linearCoeff f S * linearCoeff g S : β) : β) = | |
| β S : F ββ[F2] E, | |
| star (fourierCoeff (fun X => (f X : β)) (linearTraceCharacter S)) * | |
| fourierCoeff (fun X => (g X : β)) (linearTraceCharacter S) := by | |
| change Complex.ofRealHom (β S : F ββ[F2] E, linearCoeff f S * linearCoeff g S) = _ | |
| rw [map_sum] | |
| apply Finset.sum_congr rfl | |
| intro S _ | |
| rw [β linearCoeff_complex, β linearCoeff_complex] | |
| simp | |
| _ = πΌ X, star (f X : β) * (g X : β) := linear_complex_parseval _ _ | |
| _ = ((πΌ X, f X * g X : β) : β) := by | |
| rw [complex_ofReal_expect] | |
| simp | |
| theorem linear_parseval (f : (E ββ[F2] F) β β) : | |
| β S : F ββ[F2] E, linearCoeff f S ^ 2 = πΌ X, f X ^ 2 := by | |
| simpa only [pow_two] using linear_parseval_inner f f | |
| theorem linear_fourier_inversion (f : (E ββ[F2] F) β β) (X : E ββ[F2] F) : | |
| β S : F ββ[F2] E, linearCoeff f S * (linearTraceCharacter S X).re = f X := by | |
| apply Complex.ofReal_injective | |
| calc | |
| ((β S : F ββ[F2] E, linearCoeff f S * (linearTraceCharacter S X).re : β) : β) = | |
| β S : F ββ[F2] E, | |
| fourierCoeff (fun Y => (f Y : β)) (linearTraceCharacter S) * | |
| linearTraceCharacter S X := by | |
| change Complex.ofRealHom (β S : F ββ[F2] E, | |
| linearCoeff f S * (linearTraceCharacter S X).re) = _ | |
| rw [map_sum] | |
| apply Finset.sum_congr rfl | |
| intro S _ | |
| change ((linearCoeff f S * (linearTraceCharacter S X).re : β) : β) = _ | |
| rw [Complex.ofReal_mul, linearCoeff_complex, linearTraceCharacter_real] | |
| _ = (f X : β) := linear_complex_inversion _ X | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 F] [Fintype (F ββ[F2] E)] in | |
| theorem linearCoeff_sum {J : Type*} (s : Finset J) | |
| (f : J β (E ββ[F2] F) β β) (S : F ββ[F2] E) : | |
| linearCoeff (β j β s, f j) S = β j β s, linearCoeff (f j) S := by | |
| simp only [linearCoeff, Finset.sum_apply, Finset.sum_mul] | |
| exact Finset.expect_sum_comm _ _ _ | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 F] [Fintype (F ββ[F2] E)] in | |
| theorem linearCoeff_smul (c : β) (f : (E ββ[F2] F) β β) (S : F ββ[F2] E) : | |
| linearCoeff (c β’ f) S = c * linearCoeff f S := by | |
| simp only [linearCoeff, Pi.smul_apply, smul_eq_mul, mul_assoc] | |
| exact Finset.mul_expect _ _ _ |>.symm | |
| omit [Fintype (F ββ[F2] E)] in | |
| theorem linearCoeff_character (S T : F ββ[F2] E) : | |
| linearCoeff (fun X => (linearTraceCharacter S X).re) T = | |
| if T = S then 1 else 0 := by | |
| classical | |
| apply Complex.ofReal_injective | |
| rw [linearCoeff_complex] | |
| simp only [linearTraceCharacter_real, linear_complexCoeff_character] | |
| split_ifs <;> simp | |
| end LinearMaps | |
| end UniqueGamesTheorem.Fourier.MatrixFourier | |
| end | |
| end | |
| section | |
| /-! The degree-zero base case in the actual finite binary Fourier model. -/ | |
| noncomputable section | |
| namespace UniqueGamesTheorem.Appendix.DegreeZero | |
| open scoped BigOperators | |
| open UniqueGamesTheorem.Fourier.MatrixCharacters UniqueGamesTheorem.Fourier.MatrixFourier | |
| variable {E F : Type*} | |
| [AddCommGroup E] [Module F2 E] [AddCommGroup F] [Module F2 F] | |
| [FiniteDimensional F2 E] [FiniteDimensional F2 F] | |
| omit [FiniteDimensional F2 E] in | |
| theorem rank_pos_of_ne_zero (Y : F ββ[F2] E) (hY : Y β 0) : | |
| 0 < Module.finrank F2 Y.range := by | |
| apply Nat.pos_of_ne_zero | |
| intro hr | |
| have hb : Y.range = β₯ := Submodule.finrank_eq_zero.mp hr | |
| apply hY | |
| ext x | |
| have hx : Y x β Y.range := β¨x, rflβ© | |
| rw [hb] at hx | |
| exact hx | |
| variable [Fintype (E ββ[F2] F)] [Fintype (F ββ[F2] E)] | |
| theorem eq_constant_of_degree_zero (f : (E ββ[F2] F) β β) | |
| (hdegree : β Y : F ββ[F2] E, 0 < Module.finrank F2 Y.range β linearCoeff f Y = 0) | |
| (M : E ββ[F2] F) : f M = linearCoeff f 0 := by | |
| classical | |
| rw [β linear_fourier_inversion f M, Finset.sum_eq_single (0 : F ββ[F2] E)] | |
| Β· simp | |
| Β· intro Y _ hY | |
| rw [hdegree Y (rank_pos_of_ne_zero Y hY), zero_mul] | |
| Β· simp | |
| theorem fourth_moment_eq_energy_sq (f : (E ββ[F2] F) β β) | |
| (hdegree : β Y : F ββ[F2] E, 0 < Module.finrank F2 Y.range β linearCoeff f Y = 0) : | |
| (πΌ M, f M^4) = (πΌ M, f M^2)^2 := by | |
| simp only [eq_constant_of_degree_zero f hdegree, Fintype.expect_const] | |
| rw [β pow_mul] | |
| end UniqueGamesTheorem.Appendix.DegreeZero | |
| end | |
| end | |
| section | |
| /-! Actual binary matrix and linear-map parity used in Lemma 5.3. -/ | |
| noncomputable section | |
| namespace UniqueGamesTheorem.Fourier.MatrixParity | |
| open UniqueGamesTheorem.Integration.BinaryLinear | |
| open scoped Matrix BigOperators Classical | |
| /-- The rank-one shift `c Ο` paired against `S` evaluates the functional `Ο S` | |
| at `c`, exactly the parity appearing in the decoding condition. -/ | |
| theorem trace_rankOne {m n : Nat} (c : Vector n) (Ο : Vector m) | |
| (S : Matrix (Fin m) (Fin n) F2) : | |
| Matrix.trace (Matrix.vecMulVec c Ο * S) = Ο β¬α΅₯ (S *α΅₯ c) := by | |
| rw [Matrix.vecMulVec_mul, Matrix.trace_vecMulVec, dotProduct_comm, | |
| β Matrix.dotProduct_mulVec] | |
| /-- Coordinate form of the requirement `Ο β T β 0`. -/ | |
| def MatrixValid {m n : Nat} (Ο : Vector m) (S : Matrix (Fin m) (Fin n) F2) : Prop := | |
| Ο α΅₯* S β 0 | |
| theorem matrixValid_iff_exists {m n : Nat} (Ο : Vector m) | |
| (S : Matrix (Fin m) (Fin n) F2) : | |
| MatrixValid Ο S β β c : Vector n, Ο β¬α΅₯ (S *α΅₯ c) = 1 := by | |
| constructor | |
| Β· intro h | |
| have he : β i, (Ο α΅₯* S) i β 0 := by | |
| by_contra he | |
| apply h | |
| funext i | |
| by_contra hi | |
| exact he β¨i, hiβ© | |
| obtain β¨i, hiβ© := he | |
| have hone : (Ο α΅₯* S) i = 1 := (scalar_cases _).resolve_left hi | |
| exact β¨Pi.single i 1, by rw [Matrix.dotProduct_mulVec, dotProduct_single_one, hone]β© | |
| Β· rintro β¨c, hcβ© hzero | |
| rw [Matrix.dotProduct_mulVec, hzero] at hc | |
| simp at hc | |
| theorem exists_matrixValid {m n : Nat} (Ο : Vector m) (hΟ : Ο β 0) (hn : 0 < n) : | |
| β S : Matrix (Fin m) (Fin n) F2, MatrixValid Ο S := by | |
| classical | |
| have he : β i, Ο i β 0 := by | |
| by_contra he | |
| apply hΟ | |
| funext i | |
| by_contra hi | |
| exact he β¨i, hiβ© | |
| obtain β¨i, hiβ© := he | |
| have hone : Ο i = 1 := (scalar_cases _).resolve_left hi | |
| let j : Fin n := β¨0, hnβ© | |
| refine β¨Matrix.vecMulVec (Pi.single i 1) (Pi.single j 1), ?_β© | |
| unfold MatrixValid | |
| rw [Matrix.vecMul_vecMulVec, dotProduct_single_one, hone, one_smul] | |
| intro hz | |
| have := congrFun hz j | |
| simp at this | |
| /-- Abstract linear-map form of the nonzero-parity condition. -/ | |
| theorem comp_ne_zero_iff_exists {E C : Type*} | |
| [AddCommGroup E] [Module F2 E] [AddCommGroup C] [Module F2 C] | |
| (Ο : E ββ[F2] F2) (T : C ββ[F2] E) : | |
| Ο.comp T β 0 β β c, Ο (T c) = 1 := by | |
| constructor | |
| Β· intro h | |
| have he : β c, Ο (T c) β 0 := by | |
| by_contra he | |
| apply h | |
| ext c | |
| by_contra hc | |
| exact he β¨c, hcβ© | |
| obtain β¨c, hcβ© := he | |
| exact β¨c, (scalar_cases _).resolve_left hcβ© | |
| Β· rintro β¨c, hcβ© hz | |
| have hv := LinearMap.congr_fun hz c | |
| simp only [LinearMap.comp_apply, LinearMap.zero_apply, hc] at hv | |
| exact one_ne_zero hv | |
| section LinearMaps | |
| variable {E C : Type*} [AddCommGroup E] [Module F2 E] | |
| [AddCommGroup C] [Module F2 C] | |
| def Valid (Ο : E ββ[F2] F2) (S : C ββ[F2] E) : Prop := Ο.comp S β 0 | |
| theorem valid_iff_exists (Ο : E ββ[F2] F2) (S : C ββ[F2] E) : | |
| Valid Ο S β β c, Ο (S c) = 1 := comp_ne_zero_iff_exists Ο S | |
| /-- Any nonzero parity functional admits a parity-valid map out of a nontrivial | |
| binary vector space. This also proves the candidate family is nonempty. -/ | |
| theorem exists_valid [Nontrivial C] (Ο : E ββ[F2] F2) (hΟ : Ο β 0) : | |
| β S : C ββ[F2] E, Valid Ο S := by | |
| classical | |
| have he : β e, Ο e β 0 := by | |
| by_contra he | |
| apply hΟ | |
| ext e | |
| by_contra he' | |
| exact he β¨e, he'β© | |
| obtain β¨e, heβ© := he | |
| obtain β¨c, hcβ© := exists_ne (0 : C) | |
| obtain β¨Ο, hΟβ© := Module.Projective.exists_dual_eq_one F2 hc | |
| refine β¨Ο.smulRight e, (valid_iff_exists Ο _).mpr β¨c, ?_β©β© | |
| rw [LinearMap.smulRight_apply, hΟ, one_smul] | |
| exact (scalar_cases _).resolve_left he | |
| /-- Generic trace pairing of a rank-one color shift. -/ | |
| theorem trace_smulRight_comp [FiniteDimensional F2 C] | |
| (Ο : E ββ[F2] F2) (c : C) (S : C ββ[F2] E) : | |
| LinearMap.trace F2 C ((Ο.smulRight c).comp S) = Ο (S c) := by | |
| have heq : (Ο.smulRight c).comp S = (Ο.comp S).smulRight c := by | |
| ext x | |
| rfl | |
| rw [heq, LinearMap.trace_smulRight, LinearMap.comp_apply] | |
| /-- The exact number of binary linear maps, supplying the count in (5.20). | |
| Taking `E` to be the subspace `W` counts precisely maps whose image lies in `W`. -/ | |
| theorem card_linearMaps [FiniteDimensional F2 E] [FiniteDimensional F2 C] | |
| [Fintype (C ββ[F2] E)] : | |
| Fintype.card (C ββ[F2] E) = | |
| 2 ^ (Module.finrank F2 C * Module.finrank F2 E) := by | |
| classical | |
| let bC := Module.finBasis F2 C | |
| let bE := Module.finBasis F2 E | |
| rw [β Nat.card_eq_fintype_card, | |
| Nat.card_congr (LinearMap.toMatrix bC bE).toEquiv] | |
| change Nat.card (Fin (Module.finrank F2 E) β Fin (Module.finrank F2 C) β F2) = _ | |
| rw [Nat.card_fun, Nat.card_fun] | |
| simp [F2, Integration.BinaryLinear.F2, Nat.card_eq_fintype_card, β pow_mul, | |
| Nat.mul_comm] | |
| theorem card_linearMaps_le [FiniteDimensional F2 E] [FiniteDimensional F2 C] | |
| [Fintype (C ββ[F2] E)] (r s : Nat) | |
| (hE : Module.finrank F2 E β€ r) (hC : Module.finrank F2 C β€ s) : | |
| Fintype.card (C ββ[F2] E) β€ 2 ^ (r * s) := by | |
| rw [card_linearMaps] | |
| apply Nat.pow_le_pow_right (by decide : 0 < 2) | |
| calc | |
| Module.finrank F2 C * Module.finrank F2 E β€ s * r := Nat.mul_le_mul hC hE | |
| _ = r * s := Nat.mul_comm s r | |
| end LinearMaps | |
| section Folding | |
| variable {E C D : Type*} [AddCommGroup E] [Module F2 E] | |
| [AddCommGroup C] [Module F2 C] [Fintype C] | |
| [AddCommGroup D] [Module F2 D] | |
| /-- A folded map hits a fixed color at most once along its `C`-shift orbit. | |
| The injection models the inclusion of the subspace `C'` in the full color space. -/ | |
| theorem folded_indicator_sum_le_one (Ο : E ββ[F2] F2) | |
| (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) | |
| (X : E ββ[F2] C) (y : D) : | |
| (β c : C, if F (X + Ο.smulRight c) = y then (1 : β) else 0) β€ 1 := by | |
| classical | |
| let hits : Finset C := Finset.univ.filter fun c => F (X + Ο.smulRight c) = y | |
| have hcard : hits.card β€ 1 := by | |
| apply Finset.card_le_one.mpr | |
| intro a ha b hb | |
| have ha' : F (X + Ο.smulRight a) = y := (Finset.mem_filter.mp ha).2 | |
| have hb' : F (X + Ο.smulRight b) = y := (Finset.mem_filter.mp hb).2 | |
| apply inclusion_injective | |
| apply add_left_cancel (a := F X) | |
| simpa only [folded] using ha'.trans hb'.symm | |
| have hsum : (β c : C, if F (X + Ο.smulRight c) = y then (1 : β) else 0) = | |
| (hits.card : β) := by | |
| simp only [hits, Finset.sum_boole] | |
| rw [hsum] | |
| exact_mod_cast hcard | |
| /-- Equation (5.19)'s first bound, with the actual finite folded shift average. -/ | |
| theorem folded_indicator_average_le (Ο : E ββ[F2] F2) | |
| (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) | |
| (X : E ββ[F2] C) (y : D) : | |
| (β c : C, if F (X + Ο.smulRight c) = y then (1 : β) else 0) / | |
| Fintype.card C β€ 1 / (Fintype.card C : β) := by | |
| exact div_le_div_of_nonneg_right | |
| (folded_indicator_sum_le_one Ο inclusion inclusion_injective F folded X y) | |
| (Nat.cast_nonneg _) | |
| end Folding | |
| section ShiftCharacters | |
| open MatrixCharacters hiding F2 | |
| variable {E C : Type*} [AddCommGroup E] [Module F2 E] | |
| [AddCommGroup C] [Module F2 C] | |
| /-- The character of the color-shift group indexed by the functional `Ο S`. -/ | |
| def parityCharacter (Ο : E ββ[F2] F2) (S : C ββ[F2] E) : AddChar C β where | |
| toFun c := binarySign (Ο (S c)) | |
| map_zero_eq_one' := by simp | |
| map_add_eq_mul' c d := by simp only [map_add, binarySign_add] | |
| theorem parityCharacter_eq_zero_iff (Ο : E ββ[F2] F2) (S : C ββ[F2] E) : | |
| parityCharacter Ο S = 0 β Ο.comp S = 0 := by | |
| constructor | |
| Β· intro h | |
| ext c | |
| apply binarySign_injective | |
| have hc := congrArg (fun Ο : AddChar C β => Ο c) h | |
| simpa [parityCharacter] using hc | |
| Β· intro h | |
| ext c | |
| have hc := LinearMap.congr_fun h c | |
| simp only [LinearMap.comp_apply, LinearMap.zero_apply] at hc | |
| simp [parityCharacter, hc] | |
| /-- Unnormalized annihilator identity for exactly the `c Ο` shift subgroup. -/ | |
| theorem linearTrace_shift_sum [Fintype C] [FiniteDimensional F2 C] | |
| (Ο : E ββ[F2] F2) (S : C ββ[F2] E) : | |
| (β c : C, linearTraceCharacter S (Ο.smulRight c)) = | |
| if Ο.comp S = 0 then (Fintype.card C : β) else 0 := by | |
| classical | |
| simp only [linearTraceCharacter_apply, linearTracePair, trace_smulRight_comp] | |
| change (β c : C, parityCharacter Ο S c) = _ | |
| rw [AddChar.sum_eq_ite] | |
| simp only [parityCharacter_eq_zero_iff] | |
| /-- Averaging the Fourier character in the folding directions kills precisely | |
| the indices with nonzero `Ο S`, the multiplier used in Equation (5.19). -/ | |
| theorem linearTrace_shift_average [Fintype C] [FiniteDimensional F2 C] | |
| (Ο : E ββ[F2] F2) (S : C ββ[F2] E) : | |
| (β c : C, linearTraceCharacter S (Ο.smulRight c)) / (Fintype.card C : β) = | |
| if Ο.comp S = 0 then 1 else 0 := by | |
| classical | |
| rw [linearTrace_shift_sum] | |
| split <;> simp [Fintype.card_ne_zero] | |
| end ShiftCharacters | |
| end UniqueGamesTheorem.Fourier.MatrixParity | |
| end | |
| end | |
| end OAI | |