Download data/lean/OAI/Computability/MaxCut/Gadgets/Polynomial.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 10.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/Gadgets/Polynomial.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MaxCut/Gadgets/Polynomial.lean
-
curl -L -o Polynomial.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/Gadgets/Polynomial.lean
10.7 kB
Lean 4 Β· 23
declarations fullstatements
| import Mathlib | |
| import OAI.Computability.MaxCut.Estimates.Degree | |
| namespace OAI | |
| noncomputable section | |
| namespace OptimalMaxCut.BooleanFourthMoment | |
| open scoped BigOperators | |
| open Finset MaxCutGames.Foundations.Hastad | |
| theorem sum_cube_succ {n : β} (F : Cube (Fin (n + 1)) β β) : | |
| β x, F x = β b : Bool, β y : Cube (Fin n), F (Fin.cons b y) := by | |
| rw [β (Fin.consEquiv (fun _ : Fin (n + 1) => Bool)).sum_comp] | |
| exact Fintype.sum_prod_type _ | |
| theorem expect_cube_succ {n : β} (F : Cube (Fin (n + 1)) β β) : | |
| (πΌ x, F x) = πΌ b : Bool, πΌ y : Cube (Fin n), F (Fin.cons b y) := by | |
| calc | |
| _ = πΌ p : Bool Γ Cube (Fin n), F (Fin.cons p.1 p.2) := | |
| (Fintype.expect_equiv (Fin.consEquiv (fun _ : Fin (n + 1) => Bool)) _ F (fun _ => rfl)).symm | |
| _ = _ := by rw [β Finset.univ_product_univ, Finset.expect_product] | |
| theorem expect_bool (F : Bool β β) : (πΌ b, F b) = (F false + F true) / 2 := by | |
| rw [Fintype.expect_eq_sum_div_card] | |
| simp [add_comm] | |
| noncomputable def polynomial {I : Type*} [Fintype I] [DecidableEq I] | |
| (c : Cube I β β) (x : Cube I) : β := β s, c s * walsh s x | |
| noncomputable def energy {I : Type*} [Fintype I] [DecidableEq I] | |
| (c : Cube I β β) : β := | |
| β s, (β i, if s i then (3 : β) else 1) * c s ^ 2 | |
| theorem energy_nonneg {I : Type*} [Fintype I] [DecidableEq I] (c : Cube I β β) : | |
| 0 β€ energy c := by | |
| apply Finset.sum_nonneg | |
| intro s _ | |
| apply mul_nonneg _ (sq_nonneg _) | |
| apply Finset.prod_nonneg | |
| intro i _ | |
| split_ifs <;> norm_num | |
| theorem walsh_cons {n : β} (s x : Cube (Fin n)) (a b : Bool) : | |
| walsh (Fin.cons a s) (Fin.cons b x) = (if a then bitSign b else 1) * walsh s x := by | |
| cases a <;> simp [walsh, Fin.prod_univ_succ, bitSign] | |
| theorem polynomial_cons {n : β} (c : Cube (Fin (n + 1)) β β) (x : Cube (Fin n)) (b : Bool) : | |
| polynomial c (Fin.cons b x) = polynomial (fun s => c (Fin.cons false s)) x + | |
| bitSign b * polynomial (fun s => c (Fin.cons true s)) x := by | |
| unfold polynomial | |
| rw [sum_cube_succ, Fintype.sum_bool] | |
| simp only [walsh_cons, Bool.false_eq_true, βreduceIte, one_mul] | |
| rw [Finset.mul_sum, add_comm] | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| ring | |
| theorem energy_cons {n : β} (c : Cube (Fin (n + 1)) β β) : | |
| energy c = energy (fun s => c (Fin.cons false s)) + | |
| 3 * energy (fun s => c (Fin.cons true s)) := by | |
| unfold energy | |
| rw [sum_cube_succ, Fintype.sum_bool] | |
| simp only [Fin.prod_univ_succ, Fin.cons_zero, Fin.cons_succ, Bool.false_eq_true, βreduceIte, | |
| one_mul, mul_assoc] | |
| rw [β Finset.mul_sum] | |
| ring | |
| theorem fourth_moment_cons {n : β} (c : Cube (Fin (n + 1)) β β) : | |
| (πΌ x, polynomial c x ^ 4) = | |
| (πΌ x, polynomial (fun s => c (Fin.cons false s)) x ^ 4) + | |
| 6 * (πΌ x, polynomial (fun s => c (Fin.cons false s)) x ^ 2 * | |
| polynomial (fun s => c (Fin.cons true s)) x ^ 2) + | |
| (πΌ x, polynomial (fun s => c (Fin.cons true s)) x ^ 4) := by | |
| rw [expect_cube_succ, Finset.expect_comm] | |
| simp_rw [expect_bool] | |
| simp only [polynomial_cons, bitSign, Bool.false_eq_true, βreduceIte, one_mul, neg_one_mul] | |
| simp_rw [show β a b : β, ((a + b) ^ 4 + (a + -b) ^ 4) / 2 = a ^ 4 + 6 * (a ^ 2 * b ^ 2) + b ^ 4 by | |
| intro a b; ring] | |
| rw [Finset.expect_add_distrib, Finset.expect_add_distrib, β Finset.mul_expect] | |
| theorem fourth_moment_bound (n : β) (c : Cube (Fin n) β β) : | |
| (πΌ x, polynomial c x ^ 4) β€ energy c ^ 2 := by | |
| induction n with | |
| | zero => simp [polynomial, energy, walsh]; exact le_of_eq (by ring) | |
| | succ n ih => | |
| let cβ : Cube (Fin n) β β := fun s => c (Fin.cons false s) | |
| let cβ : Cube (Fin n) β β := fun s => c (Fin.cons true s) | |
| have hβ := ih cβ | |
| have hβ := ih cβ | |
| have heβ := energy_nonneg cβ | |
| have heβ := energy_nonneg cβ | |
| have hmβ : 0 β€ πΌ x, polynomial cβ x ^ 4 := by positivity | |
| have hmβ : 0 β€ πΌ x, polynomial cβ x ^ 4 := by positivity | |
| have hc := Finset.expect_mul_sq_le_sq_mul_sq Finset.univ | |
| (fun x => polynomial cβ x ^ 2) (fun x => polynomial cβ x ^ 2) | |
| simp only [β pow_mul, Nat.reduceMul] at hc | |
| have hc' : (πΌ x, polynomial cβ x ^ 2 * polynomial cβ x ^ 2) ^ 2 β€ | |
| (energy cβ * energy cβ) ^ 2 := by | |
| calc _ β€ _ := hc | |
| _ β€ energy cβ ^ 2 * energy cβ ^ 2 := mul_le_mul hβ hβ hmβ (sq_nonneg _) | |
| _ = _ := by ring | |
| have hc'' : (πΌ x, polynomial cβ x ^ 2 * polynomial cβ x ^ 2) β€ energy cβ * energy cβ := | |
| (sq_le_sqβ (by positivity) (mul_nonneg heβ heβ)).mp hc' | |
| rw [fourth_moment_cons, energy_cons] | |
| change (πΌ x, polynomial cβ x ^ 4) + | |
| 6 * (πΌ x, polynomial cβ x ^ 2 * polynomial cβ x ^ 2) + | |
| (πΌ x, polynomial cβ x ^ 4) β€ (energy cβ + 3 * energy cβ) ^ 2 | |
| nlinarith [sq_nonneg (energy cβ)] | |
| theorem weight_eq_degree {I : Type*} [Fintype I] [DecidableEq I] (s : Cube I) : | |
| (β i, if s i then (3 : β) else 1) = 3 ^ Analytic.degree s := by | |
| simp [Finset.prod_ite, Analytic.degree] | |
| theorem energy_truncated {I : Type*} [Fintype I] [DecidableEq I] | |
| (K : β) (c : Cube I β β) (hc : β s, K < Analytic.degree s β c s = 0) : | |
| energy c β€ 3 ^ K * β s, c s ^ 2 := by | |
| unfold energy | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_le_sum | |
| intro s _ | |
| rw [weight_eq_degree] | |
| by_cases hs : Analytic.degree s β€ K | |
| Β· exact mul_le_mul_of_nonneg_right (pow_le_pow_rightβ (by norm_num) hs) (sq_nonneg _) | |
| Β· rw [hc s (lt_of_not_ge hs)]; simp | |
| theorem coefficient_polynomial {I : Type*} [Fintype I] [DecidableEq I] | |
| (c : Cube I β β) (a : Cube I) : coefficient (polynomial c) a = c a := by | |
| unfold coefficient polynomial | |
| simp only [Finset.sum_mul] | |
| rw [Finset.expect_sum_comm] | |
| simp_rw [mul_assoc, β Finset.mul_expect, walsh_orthogonality] | |
| simp | |
| theorem polynomial_second_moment {I : Type*} [Fintype I] [DecidableEq I] (c : Cube I β β) : | |
| (πΌ x, polynomial c x ^ 2) = β s, c s ^ 2 := by | |
| rw [β walsh_parseval] | |
| simp only [coefficient_polynomial] | |
| theorem degree_fourth_moment_bound {n K : β} (c : Cube (Fin n) β β) | |
| (hc : β s, K < Analytic.degree s β c s = 0) : | |
| (πΌ x, polynomial c x ^ 4) β€ (3 ^ K * (πΌ x, polynomial c x ^ 2)) ^ 2 := by | |
| rw [polynomial_second_moment] | |
| exact (fourth_moment_bound n c).trans | |
| ((sq_le_sqβ (energy_nonneg c) (by positivity)).mpr (energy_truncated K c hc)) | |
| theorem degree_third_moment_bound {n K : β} (c : Cube (Fin n) β β) | |
| (hc : β s, K < Analytic.degree s β c s = 0) {Ο : β} (hΟ : 0 β€ Ο) | |
| (hsmall : (πΌ x, polynomial c x ^ 2) β€ Ο ^ 2) : | |
| (πΌ x, |polynomial c x| ^ 3) β€ 3 ^ K * Ο * (πΌ x, polynomial c x ^ 2) := by | |
| have hsecond : 0 β€ πΌ x, polynomial c x ^ 2 := by positivity | |
| have hfourth := degree_fourth_moment_bound c hc | |
| have hCS := Finset.expect_mul_sq_le_sq_mul_sq Finset.univ | |
| (fun x => |polynomial c x|) (fun x => polynomial c x ^ 2) | |
| have hp (a : β) : |a| * a ^ 2 = |a| ^ 3 := by rw [β sq_abs]; ring | |
| simp_rw [hp, sq_abs, β pow_mul, Nat.reduceMul] at hCS | |
| have hbound : (πΌ x, |polynomial c x| ^ 3) ^ 2 β€ | |
| (3 ^ K * Ο * (πΌ x, polynomial c x ^ 2)) ^ 2 := by | |
| calc | |
| _ β€ (πΌ x, polynomial c x ^ 2) * (πΌ x, polynomial c x ^ 4) := hCS | |
| _ β€ (πΌ x, polynomial c x ^ 2) * (3 ^ K * (πΌ x, polynomial c x ^ 2)) ^ 2 := | |
| mul_le_mul_of_nonneg_left hfourth hsecond | |
| _ = (3 ^ K * (πΌ x, polynomial c x ^ 2)) ^ 2 * (πΌ x, polynomial c x ^ 2) := by ring | |
| _ β€ (3 ^ K * (πΌ x, polynomial c x ^ 2)) ^ 2 * Ο ^ 2 := | |
| mul_le_mul_of_nonneg_left hsmall (sq_nonneg _) | |
| _ = _ := by ring | |
| exact (sq_le_sqβ (by positivity) (by positivity)).mp hbound | |
| theorem walsh_flip {I : Type*} [Fintype I] [DecidableEq I] | |
| (s x : Cube I) (i : I) : | |
| walsh s (Function.update x i (!x i)) = (if s i then -1 else 1) * walsh s x := by | |
| classical | |
| have hp (j : I) : bitSign (s j && Function.update x i (!x i) j) = | |
| (if j = i then (if s i then (-1 : β) else 1) else 1) * bitSign (s j && x j) := by | |
| by_cases h : j = i | |
| Β· subst j; cases s i <;> cases x i <;> simp [bitSign] | |
| Β· simp [h] | |
| simp only [walsh, hp, Finset.prod_mul_distrib] | |
| simp | |
| noncomputable def discreteDiff {I : Type*} [Fintype I] [DecidableEq I] | |
| (f : Cube I β β) (i : I) (x : Cube I) : β := (f x - f (Function.update x i (!x i))) / 2 | |
| theorem polynomial_diff {I : Type*} [Fintype I] [DecidableEq I] | |
| (c : Cube I β β) (i : I) : | |
| discreteDiff (polynomial c) i = polynomial (fun s => if s i then c s else 0) := by | |
| funext x | |
| simp only [discreteDiff, polynomial, walsh_flip, β Finset.sum_sub_distrib, Finset.sum_div] | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| cases s i <;> simp | |
| theorem total_diff_second {I : Type*} [Fintype I] [DecidableEq I] | |
| (c : Cube I β β) : | |
| (β i, πΌ x, discreteDiff (polynomial c) i x ^ 2) = | |
| β s, (Analytic.degree s : β) * c s ^ 2 := by | |
| simp only [polynomial_diff, polynomial_second_moment] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| simp only [ite_pow, zero_pow (by omega : 2 β 0)] | |
| rw [β Finset.sum_filter] | |
| simp [Analytic.degree] | |
| theorem total_diff_second_truncated {I : Type*} [Fintype I] [DecidableEq I] | |
| (K : β) (c : Cube I β β) (hc : β s, K < Analytic.degree s β c s = 0) : | |
| (β i, πΌ x, discreteDiff (polynomial c) i x ^ 2) β€ | |
| K * (πΌ x, polynomial c x ^ 2) := by | |
| rw [total_diff_second, polynomial_second_moment, Finset.mul_sum] | |
| apply Finset.sum_le_sum | |
| intro s _ | |
| by_cases hs : Analytic.degree s β€ K | |
| Β· exact mul_le_mul_of_nonneg_right (by exact_mod_cast hs) (sq_nonneg _) | |
| Β· rw [hc s (lt_of_not_ge hs)]; simp | |
| theorem total_diff_third_truncated {n K : β} (c : Cube (Fin n) β β) | |
| (hc : β s, K < Analytic.degree s β c s = 0) {Ο : β} (hΟ : 0 β€ Ο) | |
| (hsmall : β i, (πΌ x, discreteDiff (polynomial c) i x ^ 2) β€ Ο ^ 2) : | |
| (β i, πΌ x, |discreteDiff (polynomial c) i x| ^ 3) β€ | |
| 3 ^ K * Ο * K * (πΌ x, polynomial c x ^ 2) := by | |
| calc | |
| _ β€ β i, 3 ^ K * Ο * (πΌ x, discreteDiff (polynomial c) i x ^ 2) := by | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| have hi := hsmall i | |
| rw [polynomial_diff] at hi β’ | |
| exact degree_third_moment_bound _ (fun s hs => by rw [hc s hs]; split_ifs <;> rfl) | |
| hΟ hi | |
| _ = 3 ^ K * Ο * (β i, πΌ x, discreteDiff (polynomial c) i x ^ 2) := by rw [Finset.mul_sum] | |
| _ β€ 3 ^ K * Ο * (K * (πΌ x, polynomial c x ^ 2)) := | |
| mul_le_mul_of_nonneg_left (total_diff_second_truncated K c hc) (by positivity) | |
| _ = _ := by ring | |
| end OptimalMaxCut.BooleanFourthMoment | |
| end | |
| end OAI | |
Outline
- theorem
sum_cube_succ11 - theorem
expect_cube_succ16 - theorem
expect_bool23 - def
polynomial27 - def
energy30 - theorem
energy_nonneg34 - theorem
walsh_cons43 - theorem
polynomial_cons47 - theorem
energy_cons59 - theorem
fourth_moment_cons69 - theorem
fourth_moment_bound82 - theorem
weight_eq_degree111 - theorem
energy_truncated115 - theorem
coefficient_polynomial127 - theorem
polynomial_second_moment135 - theorem
degree_fourth_moment_bound140 - theorem
degree_third_moment_bound147 - theorem
walsh_flip169 - def
discreteDiff181 - theorem
polynomial_diff184 - theorem
total_diff_second193 - theorem
total_diff_second_truncated205 - theorem
total_diff_third_truncated216