Download data/lean/OAI/Combinatorics/IndependentSets/Reduction/Cube.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.19 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/IndependentSets/Reduction/Cube.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/IndependentSets/Reduction/Cube.lean
-
curl -L -o Cube.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/IndependentSets/Reduction/Cube.lean
9.19 kB
| import Mathlib | |
| namespace OAI | |
| namespace LargeIndependentSets.BooleanJunta | |
| open scoped BigOperators | |
| def Cube : β β Type | |
| | 0 => Unit | |
| | n+1 => Bool Γ Cube n | |
| instance cubeFintype : (n : β) β Fintype (Cube n) | |
| | 0 => inferInstanceAs (Fintype Unit) | |
| | n+1 => by | |
| letI := cubeFintype n | |
| exact inferInstanceAs (Fintype (Bool Γ Cube n)) | |
| instance cubeNonempty : (n : β) β Nonempty (Cube n) | |
| | 0 => inferInstanceAs (Nonempty Unit) | |
| | n+1 => @instNonemptyProd Bool (Cube n) _ (cubeNonempty n) | |
| noncomputable def mean {n : β} (f : Cube n β β) : β := πΌ x, f x | |
| lemma mean_zero (f : Cube 0 β β) : mean f = f () := by | |
| change (πΌ x : Unit, f x) = f () | |
| simp [Finset.expect_eq_sum_div_card] | |
| lemma mean_succ {n : β} (f : Cube (n+1) β β) : | |
| mean f = (mean (fun x => f (false,x)) + mean (fun x => f (true,x))) / 2 := by | |
| change (πΌ x : Bool Γ Cube n, f x) = _ | |
| rw [show (Finset.univ : Finset (Bool Γ Cube n)) = Finset.univ ΓΛ’ Finset.univ from rfl, | |
| Finset.expect_product] | |
| simp [Finset.expect_eq_sum_div_card, mean, add_comm] | |
| lemma mean_add {n : β} (f g : Cube n β β) : | |
| mean (fun x => f x + g x) = mean f + mean g := Finset.expect_add_distrib _ _ _ | |
| lemma mean_sub {n : β} (f g : Cube n β β) : | |
| mean (fun x => f x - g x) = mean f - mean g := Finset.expect_sub_distrib _ _ _ | |
| lemma mean_mul {n : β} (a : β) (f : Cube n β β) : | |
| mean (fun x => a * f x) = a * mean f := (Finset.mul_expect _ _ _).symm | |
| lemma mean_nonneg {n : β} {f : Cube n β β} (hf : β x, 0 β€ f x) : 0 β€ mean f := | |
| Finset.expect_nonneg (fun x _ => hf x) | |
| lemma mean_mono {n : β} {f g : Cube n β β} (h : β x, f x β€ g x) : mean f β€ mean g := | |
| Finset.expect_le_expect (fun x _ => h x) | |
| lemma mean_cauchy {n : β} (f g : Cube n β β) : | |
| (mean (fun x => f x * g x))^2 β€ mean (fun x => f x^2) * mean (fun x => g x^2) := | |
| Finset.expect_mul_sq_le_sq_mul_sq _ _ _ | |
| noncomputable def evenPart {n : β} (f : Cube (n+1) β β) (x : Cube n) := | |
| (f (false,x) + f (true,x)) / 2 | |
| noncomputable def oddPart {n : β} (f : Cube (n+1) β β) (x : Cube n) := | |
| (f (false,x) - f (true,x)) / 2 | |
| noncomputable def noise (Ο : β) : {n : β} β (Cube n β β) β Cube n β β | |
| | 0, f, x => f x | |
| | _+1, f, (b,x) => noise Ο (evenPart f) x + (if b then -Ο else Ο) * noise Ο (oddPart f) x | |
| lemma mean_square_split {n : β} (f : Cube (n+1) β β) : | |
| mean (fun x => f x^2) = mean (fun x => evenPart f x^2) + mean (fun x => oddPart f x^2) := by | |
| rw [mean_succ, β mean_add] | |
| rw [β mean_add, div_eq_mul_inv, mul_comm _ (2β»ΒΉ), β mean_mul] | |
| congr 1 | |
| funext x | |
| dsimp [evenPart, oddPart] | |
| ring | |
| lemma mean_noise_fourth {n : β} (Ο : β) (f : Cube (n+1) β β) : | |
| mean (fun x => noise Ο f x ^ 4) = | |
| mean (fun x => noise Ο (evenPart f) x ^ 4) + | |
| 6 * Ο^2 * mean (fun x => (noise Ο (evenPart f) x)^2 * (noise Ο (oddPart f) x)^2) + | |
| Ο^4 * mean (fun x => noise Ο (oddPart f) x ^ 4) := by | |
| rw [mean_succ, β mean_add, div_eq_mul_inv, mul_comm _ (2β»ΒΉ), β mean_mul, β mean_mul, β mean_add, | |
| β mean_mul, β mean_add] | |
| congr 1 | |
| funext x | |
| dsimp [noise] | |
| ring | |
| theorem hypercontractive_two_four {n : β} (f : Cube n β β) : | |
| mean (fun x => noise (1/2) f x ^ 4) β€ (mean (fun x => f x^2))^2 := by | |
| induction n with | |
| | zero => | |
| simp only [mean_zero, noise] | |
| nlinarith | |
| | succ n ih => | |
| let a := evenPart f | |
| let b := oddPart f | |
| let A := mean (fun x => a x^2) | |
| let B := mean (fun x => b x^2) | |
| let C := mean (fun x => noise (1/2) a x^4) | |
| let D := mean (fun x => noise (1/2) b x^4) | |
| let E := mean (fun x => (noise (1/2) a x)^2 * (noise (1/2) b x)^2) | |
| have hA : 0 β€ A := mean_nonneg (fun x => sq_nonneg _) | |
| have hB : 0 β€ B := mean_nonneg (fun x => sq_nonneg _) | |
| have hC : 0 β€ C := mean_nonneg (fun x => by positivity) | |
| have hD : 0 β€ D := mean_nonneg (fun x => by positivity) | |
| have hE : 0 β€ E := mean_nonneg (fun x => mul_nonneg (sq_nonneg _) (sq_nonneg _)) | |
| have hCA : C β€ A^2 := ih a | |
| have hDB : D β€ B^2 := ih b | |
| have hEC : E^2 β€ C*D := by | |
| have hc := mean_cauchy (fun x => (noise (1/2) a x)^2) (fun x => (noise (1/2) b x)^2) | |
| have hpow (x : β) : (x^2)^2 = x^4 := by ring | |
| simp only [hpow] at hc | |
| exact hc | |
| have hmul : C*D β€ A^2*B^2 := mul_le_mul hCA hDB hD (sq_nonneg A) | |
| have hEAB : E β€ A*B := by | |
| nlinarith [hEC.trans hmul, mul_nonneg hA hB] | |
| rw [mean_noise_fourth, mean_square_split] | |
| change C + 6*(1/2:β)^2*E + (1/2:β)^4*D β€ (A+B)^2 | |
| nlinarith [mul_nonneg hA hB] | |
| lemma evenPart_noise {n : β} (Ο : β) (f : Cube (n+1) β β) : | |
| evenPart (noise Ο f) = noise Ο (evenPart f) := by | |
| funext x | |
| dsimp [evenPart, noise] | |
| ring | |
| lemma oddPart_noise {n : β} (Ο : β) (f : Cube (n+1) β β) : | |
| oddPart (noise Ο f) = fun x => Ο * noise Ο (oddPart f) x := by | |
| funext x | |
| dsimp [oddPart, noise] | |
| ring | |
| lemma mean_product_split {n : β} (f g : Cube (n+1) β β) : | |
| mean (fun x => f x * g x) = | |
| mean (fun x => evenPart f x * evenPart g x) + | |
| mean (fun x => oddPart f x * oddPart g x) := by | |
| rw [mean_succ, β mean_add, div_eq_mul_inv, mul_comm _ (2β»ΒΉ), β mean_mul, | |
| β mean_add] | |
| congr 1 | |
| funext x | |
| dsimp [evenPart, oddPart] | |
| ring | |
| lemma noise_selfadjoint {n : β} (Ο : β) (f g : Cube n β β) : | |
| mean (fun x => f x * noise Ο g x) = mean (fun x => noise Ο f x * g x) := by | |
| induction n with | |
| | zero => simp only [mean_zero, noise] | |
| | succ n ih => | |
| rw [mean_product_split, mean_product_split, evenPart_noise, oddPart_noise, | |
| evenPart_noise, oddPart_noise, ih] | |
| have hβ : mean (fun x => oddPart f x * (Ο * noise Ο (oddPart g) x)) = | |
| Ο * mean (fun x => oddPart f x * noise Ο (oddPart g) x) := by | |
| rw [β mean_mul] | |
| congr 1; funext x; ring | |
| have hβ : mean (fun x => Ο * noise Ο (oddPart f) x * oddPart g x) = | |
| Ο * mean (fun x => noise Ο (oddPart f) x * oddPart g x) := by | |
| rw [β mean_mul] | |
| congr 1; funext x; ring | |
| rw [hβ, hβ, ih] | |
| lemma mean_holder_four {n : β} (g h : Cube n β β) : | |
| (mean (fun x => g x * h x))^4 β€ | |
| (mean (fun x => |g x|))^2 * mean (fun x => g x^2) * mean (fun x => h x^4) := by | |
| let G := mean (fun x => |g x|) | |
| let U := mean (fun x => |g x| * |h x|) | |
| let V := mean (fun x => |g x| * h x^2) | |
| have hG : 0 β€ G := mean_nonneg (fun x => abs_nonneg _) | |
| have hU : 0 β€ U := mean_nonneg (fun x => mul_nonneg (abs_nonneg _) (abs_nonneg _)) | |
| have hV : 0 β€ V := mean_nonneg (fun x => mul_nonneg (abs_nonneg _) (sq_nonneg _)) | |
| have huv : U^2 β€ G*V := by | |
| have hc := mean_cauchy (fun x => Real.sqrt |g x|) (fun x => Real.sqrt |g x| * |h x|) | |
| have heβ : (fun x => Real.sqrt |g x| * (Real.sqrt |g x| * |h x|)) = | |
| (fun x => |g x| * |h x|) := by | |
| funext x | |
| rw [β mul_assoc, Real.mul_self_sqrt (abs_nonneg _)] | |
| have heβ : (fun x => (Real.sqrt |g x|)^2) = (fun x => |g x|) := by | |
| funext x; exact Real.sq_sqrt (abs_nonneg _) | |
| have heβ : (fun x => (Real.sqrt |g x| * |h x|)^2) = (fun x => |g x| * h x^2) := by | |
| funext x | |
| rw [mul_pow, Real.sq_sqrt (abs_nonneg _), sq_abs] | |
| simpa only [heβ, heβ, heβ] using hc | |
| have hv : V^2 β€ mean (fun x => g x^2) * mean (fun x => h x^4) := by | |
| have hc := mean_cauchy (fun x => |g x|) (fun x => h x^2) | |
| have hpow (x : β) : (x^2)^2 = x^4 := by ring | |
| simp only [sq_abs, hpow] at hc | |
| exact hc | |
| have habs : |mean (fun x => g x * h x)| β€ U := by | |
| have hh := Finset.abs_expect_le Finset.univ (fun x => g x*h x) | |
| simp only [abs_mul] at hh | |
| exact hh | |
| have hs : (mean (fun x => g x * h x))^2 β€ U^2 := by | |
| have ha := abs_nonneg (mean (fun x => g x*h x)) | |
| nlinarith [sq_abs (mean (fun x => g x*h x))] | |
| have hsq : (mean (fun x => g x * h x))^4 β€ (G*V)^2 := by | |
| nlinarith [hs.trans huv, sq_nonneg (mean (fun x => g x*h x))] | |
| have hm := mul_le_mul_of_nonneg_left hv (sq_nonneg G) | |
| nlinarith | |
| theorem noise_small_l1 {n : β} (g : Cube n β β) (hg : β x, |g x| β€ 1) : | |
| (mean (fun x => noise (1/2) g x^2))^2 β€ (mean (fun x => |g x|))^3 := by | |
| let u := noise (1/2) g | |
| let A := mean (fun x => u x^2) | |
| let I := mean (fun x => |g x|) | |
| have hA : 0 β€ A := mean_nonneg (fun x => sq_nonneg _) | |
| have hI : 0 β€ I := mean_nonneg (fun x => abs_nonneg _) | |
| have hgs : mean (fun x => g x^2) β€ I := by | |
| apply mean_mono | |
| intro x | |
| nlinarith [hg x, abs_nonneg (g x), sq_abs (g x)] | |
| have he : mean (fun x => g x * noise (1/2) u x) = A := by | |
| rw [noise_selfadjoint] | |
| congr 1; funext x; simp only [u, pow_two] | |
| have h := mean_holder_four g (noise (1/2) u) | |
| rw [he] at h | |
| have hh := hypercontractive_two_four u | |
| have hp : 0 β€ I^2 * mean (fun x => g x^2) := | |
| mul_nonneg (sq_nonneg _) (mean_nonneg (fun x => sq_nonneg _)) | |
| have hβ := mul_le_mul_of_nonneg_left hh hp | |
| have hβ := mul_le_mul_of_nonneg_left hgs (sq_nonneg I) | |
| have hβ := mul_le_mul_of_nonneg_right hβ (sq_nonneg A) | |
| change A^2 β€ I^3 | |
| change _ β€ _ * A^2 at hβ | |
| nlinarith [h.trans hβ] | |
| end LargeIndependentSets.BooleanJunta | |
| end OAI | |