Download data/lean/OAI/Computability/MaxCut/PCP/MatrixParity.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.34 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/PCP/MatrixParity.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MaxCut/PCP/MatrixParity.lean
-
curl -L -o MatrixParity.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/PCP/MatrixParity.lean
9.34 kB
| import Mathlib | |
| import OAI.Computability.MaxCut.Games.MatrixCharacters | |
| namespace OAI | |
| /-! Actual binary matrix and linear-map parity used in Lemma 5.3. -/ | |
| noncomputable section | |
| namespace MaxCutGames.Fourier.MatrixParity | |
| open MaxCutGames.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 | |
| 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 MaxCutGames.Fourier.MatrixParity | |
| end | |
| end OAI | |