Download data/lean/OAI/Computability/MaxCut/Analysis/CubePerm.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.64 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/Analysis/CubePerm.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MaxCut/Analysis/CubePerm.lean
-
curl -L -o CubePerm.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/Analysis/CubePerm.lean
6.64 kB
| import Mathlib | |
| import OAI.Computability.MaxCut.Estimates.Clip | |
| namespace OAI | |
| noncomputable section | |
| namespace OptimalMaxCut.LongCode | |
| open scoped BigOperators | |
| open Finset MaxCutGames.Foundations.Hastad OptimalMaxCut.Analytic | |
| noncomputable def cubePerm {n : β} (Ο : Equiv.Perm (Fin n)) : Equiv.Perm (Cube (Fin n)) where | |
| toFun x := fun i => x (Ο i) | |
| invFun x := fun i => x (Ο.symm i) | |
| left_inv x := by funext i; simp | |
| right_inv x := by funext i; simp | |
| @[simp] theorem cubePerm_apply {n : β} (Ο : Equiv.Perm (Fin n)) (x : Cube (Fin n)) (i : Fin n) : | |
| cubePerm Ο x i = x (Ο i) := rfl | |
| theorem degree_cubePerm {n : β} (Ο : Equiv.Perm (Fin n)) (s : Cube (Fin n)) : | |
| degree (cubePerm Ο s) = degree s := by | |
| unfold degree | |
| simp only [card_eq_sum_ones, sum_filter] | |
| exact Fintype.sum_equiv Ο _ _ (fun _ => rfl) | |
| theorem walsh_cubePerm {n : β} (Ο : Equiv.Perm (Fin n)) (s x : Cube (Fin n)) : | |
| walsh (cubePerm Ο s) (cubePerm Ο x) = walsh s x := by | |
| unfold walsh | |
| exact Fintype.prod_equiv Ο _ _ (fun _ => rfl) | |
| noncomputable def reindex {n : β} (Ο : Equiv.Perm (Fin n)) (f : Cube (Fin n) β β) | |
| (x : Cube (Fin n)) : β := f (cubePerm Ο x) | |
| theorem coefficient_reindex {n : β} (Ο : Equiv.Perm (Fin n)) (f : Cube (Fin n) β β) | |
| (s : Cube (Fin n)) : coefficient (reindex Ο f) s = coefficient f (cubePerm Ο s) := by | |
| unfold coefficient reindex | |
| apply Fintype.expect_equiv (cubePerm Ο) | |
| intro x | |
| rw [walsh_cubePerm] | |
| theorem mean_reindex {n : β} (Ο : Equiv.Perm (Fin n)) (f : Cube (Fin n) β β) : | |
| (πΌ x, reindex Ο f x) = πΌ x, f x := | |
| Fintype.expect_equiv (cubePerm Ο) _ _ (fun _ => rfl) | |
| theorem cutoffInfluence_reindex {n : β} (Ο : Equiv.Perm (Fin n)) (f : Cube (Fin n) β β) | |
| (K : β) (i : Fin n) : | |
| cutoffInfluence K i (reindex Ο f) = cutoffInfluence K (Ο.symm i) f := by | |
| classical | |
| unfold cutoffInfluence | |
| simp only [sum_filter, coefficient_reindex] | |
| apply Fintype.sum_equiv (cubePerm Ο) | |
| intro s | |
| simp [degree_cubePerm] | |
| theorem cutoffInfluence_nonneg {n : β} (K : β) (i : Fin n) (f : Cube (Fin n) β β) : | |
| 0 β€ cutoffInfluence K i f := | |
| sum_nonneg (fun _ _ => sq_nonneg _) | |
| namespace Game | |
| variable {X Y E : Type*} [Fintype X] [Fintype Y] [Fintype E] {q : β} | |
| /-- A real weighted averaging of all pulled-back odd long codes at a right | |
| question. The graph/test itself uses only rational probabilities. -/ | |
| noncomputable def averageCode (G : Game X Y E q) (f : X β Cube (Fin q) β β) | |
| (y : Y) (z : Cube (Fin q)) : β := | |
| (G.edgeLaw y).avg (fun e => reindex (G.permutation e) (f (G.source e)) z) | |
| theorem averageCode_bounded (G : Game X Y E q) (f : X β Cube (Fin q) β β) | |
| (hf : β x z, f x z β Set.Icc (-1 : β) 1) (y : Y) (z : Cube (Fin q)) : | |
| G.averageCode f y z β Set.Icc (-1 : β) 1 := | |
| (G.edgeLaw y).avg_mem (fun e => hf (G.source e) _) | |
| theorem averageCode_mean (G : Game X Y E q) (f : X β Cube (Fin q) β β) | |
| (hf : β x, (πΌ z, f x z) = 0) (y : Y) : (πΌ z, G.averageCode f y z) = 0 := by | |
| unfold averageCode | |
| rw [Law.avg_expect] | |
| simp_rw [mean_reindex, hf] | |
| exact Law.avg_const _ _ | |
| theorem averageCode_influence (G : Game X Y E q) (f : X β Cube (Fin q) β β) | |
| (K : β) (y : Y) (i : Fin q) : | |
| cutoffInfluence K i (G.averageCode f y) β€ (G.edgeLaw y).avg (fun e => | |
| cutoffInfluence K ((G.permutation e).symm i) (f (G.source e))) := by | |
| apply (Law.cutoffInfluence_avg (G.edgeLaw y) _ K i).trans_eq | |
| simp_rw [cutoffInfluence_reindex] | |
| /-- Low-degree Fourier influence decodes an actual labeling. There is no | |
| assumed decoder or hardness assertion in this inequality. -/ | |
| theorem decoding_bound (G : Game X Y E q) (hq : 0 < q) (K : β) | |
| (f : X β Cube (Fin q) β β) (hf : β x z, f x z β Set.Icc (-1 : β) 1) | |
| (Ξ΄ : β) (hsound : G.Sound Ξ΄) (ly : Y β Fin q) : | |
| G.rightLaw.avg (fun y => (G.edgeLaw y).avg (fun e => | |
| cutoffInfluence K ((G.permutation e).symm (ly y)) (f (G.source e)))) β€ (K : β) * Ξ΄ := by | |
| classical | |
| let : Nonempty (Fin q) := β¨β¨0, hqβ©β© | |
| let P (x : X) (i : Fin q) : β := cutoffInfluence K i (f x) | |
| let score (x : X) (i : Fin q) : β := G.rightLaw.avg (fun y => | |
| (G.edgeLaw y).avg (fun e => if G.source e = x then | |
| (if G.permutation e i = ly y then 1 else 0) else 0)) | |
| have hP (x : X) (i : Fin q) : 0 β€ P x i := cutoffInfluence_nonneg _ _ _ | |
| have hPsum (x : X) : (β i, P x i) β€ (K : β) := sum_cutoffInfluences K (f x) (hf x) | |
| have hscore (x : X) (i : Fin q) : 0 β€ score x i := by | |
| apply Law.avg_nonneg | |
| intro y | |
| apply Law.avg_nonneg | |
| intro e | |
| split_ifs <;> norm_num | |
| have hmax (x : X) : β i : Fin q, β j, score x j β€ score x i := by | |
| obtain β¨i, _, hiβ© := exists_max_image univ (score x) univ_nonempty | |
| exact β¨i, fun j => hi j (mem_univ _)β© | |
| choose lx hlx using hmax | |
| have hweighted (x : X) : (β i, P x i * score x i) β€ (K : β) * score x (lx x) := by | |
| calc | |
| _ β€ β i, P x i * score x (lx x) := | |
| sum_le_sum (fun i _ => mul_le_mul_of_nonneg_left (hlx x i) (hP x i)) | |
| _ = (β i, P x i) * score x (lx x) := (sum_mul _ _ _).symm | |
| _ β€ _ := mul_le_mul_of_nonneg_right (hPsum x) (hscore x (lx x)) | |
| have htotal : (β x, score x (lx x)) = G.satisfied lx ly := by | |
| dsimp [score, satisfied] | |
| simp_rw [β Law.avg_sum] | |
| congr 1 | |
| funext y | |
| congr 1 | |
| funext e | |
| simp | |
| have hinfluence : (β x, β i, P x i * score x i) = | |
| G.rightLaw.avg (fun y => (G.edgeLaw y).avg (fun e => | |
| P (G.source e) ((G.permutation e).symm (ly y)))) := by | |
| calc | |
| _ = β x, β i, G.rightLaw.avg (fun y => (G.edgeLaw y).avg (fun e => | |
| P x i * (if G.source e = x then (if G.permutation e i = ly y then 1 else 0) else 0))) := by | |
| simp only [Law.avg_smul, score] | |
| _ = G.rightLaw.avg (fun y => (G.edgeLaw y).avg (fun e => | |
| β x, β i, P x i * (if G.source e = x then (if G.permutation e i = ly y then 1 else 0) else 0))) := by | |
| simp_rw [Law.avg_sum] | |
| _ = _ := by | |
| congr 1 | |
| funext y | |
| congr 1 | |
| funext e | |
| simp only [β Equiv.eq_symm_apply, mul_ite, mul_one, mul_zero] | |
| simp | |
| change G.rightLaw.avg (fun y => (G.edgeLaw y).avg (fun e => | |
| P (G.source e) ((G.permutation e).symm (ly y)))) β€ _ | |
| rw [β hinfluence] | |
| calc | |
| _ β€ β x, (K : β) * score x (lx x) := sum_le_sum (fun x _ => hweighted x) | |
| _ = (K : β) * G.satisfied lx ly := by rw [β mul_sum, htotal] | |
| _ β€ (K : β) * Ξ΄ := mul_le_mul_of_nonneg_left (hsound lx ly) (Nat.cast_nonneg _) | |
| end Game | |
| end OptimalMaxCut.LongCode | |
| end | |
| end OAI | |