Download data/lean/OAI/Analysis/AllenCahn/Differences.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 16.2 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/AllenCahn/Differences.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/AllenCahn/Differences.lean
-
curl -L -o Differences.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/AllenCahn/Differences.lean
16.2 kB
| import OAI.Analysis.AllenCahn.RegularityModel | |
| namespace OAI | |
| noncomputable section | |
| namespace RegularitySupport.DeGiorgi | |
| open Filter Set Topology | |
| open scoped NNReal | |
| open scoped SchwartzMap Laplacian ContDiff | |
| open FourierTransform | |
| open Filter Topology | |
| open scoped ContDiff | |
| open MeasureTheory | |
| open scoped ENNReal | |
| lemma laplacian_poisson_at_max {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) (A Ξ΅ : β) {x y : Space n} | |
| (hxy : y β x) (hsmall : βy - xβ < 1) | |
| (hm : β a b : Space n, | |
| f b - f a - poissonPenalty A βb - aβ - Ξ΅ * (βaβ ^ 2 + βbβ ^ 2) β€ | |
| f y - f x - poissonPenalty A βy - xβ - Ξ΅ * (βxβ ^ 2 + βyβ ^ 2)) : | |
| Laplacian.laplacian f y - Laplacian.laplacian f x β€ -8 * A + 4 * n * Ξ΅ := by | |
| let r := βy - xβ | |
| have hr : 0 < r := norm_pos_iff.mpr (sub_ne_zero.mpr hxy) | |
| let e : Space n := rβ»ΒΉ β’ (y - x) | |
| have he : βeβ = 1 := by simp [e, norm_smul, r, hr.ne'] | |
| have her : r β’ e = y - x := by dsimp [e]; rw [smul_smul, mul_inv_cancelβ hr.ne', one_smul] | |
| let J := reflect e | |
| let a : Space n := (-2 : β) β’ e | |
| let g : Space n β β := fun z => r + inner β a z | |
| have hg : ContDiff β 2 g := contDiff_const.add (innerSL β a).contDiff | |
| have hg0 : g 0 = r := by simp [g] | |
| have hdistance : β z : Space n, y + J z - (x + z) = g z β’ e := by | |
| intro z | |
| have hai : inner β a z = (-2 : β) * inner β e z := by | |
| dsimp only [a] | |
| rw [real_inner_smul_left] | |
| change y + reflect e z - (x + z) = (r + inner β a z) β’ e | |
| rw [reflect_apply he, hai, add_smul, her, neg_mul, neg_smul] | |
| abel | |
| have hnear : βαΆ z in π (0 : Space n), 0 < g z β§ g z < 1 := | |
| ((hg.continuous.isOpen_preimage _ isOpen_Ioo).mem_nhds (by simpa [hg0] using And.intro hr hsmall)) | |
| let F : Space n β β := fun z => f (y + J z) - f (x + z) - | |
| A * (2 * g z - (g z) ^ 2) - Ξ΅ * (βx + zβ ^ 2 + βy + J zβ ^ 2) | |
| have hfy : ContDiff β 2 (fun z => f (y + J z)) := | |
| hf.comp (contDiff_const.add J.contDiff) | |
| have hfx : ContDiff β 2 (fun z => f (x + z)) := hf.comp (contDiff_const.add contDiff_id) | |
| have hnx : ContDiff β 2 (fun z : Space n => βx + zβ ^ 2) := | |
| (contDiff_const.add contDiff_id).norm_sq β | |
| have hny : ContDiff β 2 (fun z : Space n => βy + J zβ ^ 2) := | |
| (contDiff_const.add J.contDiff).norm_sq β | |
| have hp : ContDiff β 2 (fun z => A * (2 * g z - (g z) ^ 2)) := by fun_prop | |
| have hq : ContDiff β 2 (fun z => Ξ΅ * (βx + zβ ^ 2 + βy + J zβ ^ 2)) := by fun_prop | |
| have hF : ContDiff β 2 F := ((hfy.sub hfx).sub hp).sub hq | |
| have hmax : IsLocalMax F 0 := by | |
| filter_upwards [hnear] with z hz | |
| have hnorm : βy + J z - (x + z)β = g z := by | |
| rw [hdistance, norm_smul, he, mul_one, Real.norm_eq_abs, abs_of_pos hz.1] | |
| have hh := hm (x + z) (y + J z) | |
| rw [hnorm, poissonPenalty_of_le A hz.2.le, poissonPenalty_of_le A hsmall.le] at hh | |
| simpa [F, hg0, r] using hh | |
| have hl := laplacian_nonpos_of_local_max hF hmax | |
| have hly : Laplacian.laplacian (fun z => f (y + J z)) 0 = Laplacian.laplacian f y := by | |
| have ht : ContDiff β 2 (fun u => f (y + u)) := hf.comp (contDiff_const.add contDiff_id) | |
| simpa only [map_zero, laplacian_translate hf, add_zero] using laplacian_comp_isometry ht J 0 | |
| have hns : ContDiff β 2 (fun z : Space n => βzβ ^ 2) := contDiff_id.norm_sq β | |
| have hlny : Laplacian.laplacian (fun z => βy + J zβ ^ 2) 0 = 2 * n := by | |
| have ht : ContDiff β 2 (fun u : Space n => βy + uβ ^ 2) := | |
| (contDiff_const.add contDiff_id).norm_sq β | |
| simpa only [map_zero, laplacian_translate hns, laplacian_norm_sq] using | |
| laplacian_comp_isometry ht J 0 | |
| have hal : βaβ ^ 2 = 4 := by simp [a, norm_smul, he]; norm_num | |
| have hlg : Laplacian.laplacian g 0 = 0 := laplacian_affine a r 0 | |
| have hlgs : Laplacian.laplacian (fun z => g z ^ 2) 0 = 8 := by | |
| rw [show (fun z => g z ^ 2) = (fun z => (r + inner β a z) ^ 2) from rfl, | |
| laplacian_affine_sq, hal] | |
| norm_num | |
| have hg2 : ContDiff β 2 (fun z => 2 * g z) := contDiff_const.mul hg | |
| dsimp only [F] at hl | |
| rw [laplacian_fun_sub ((hfy.sub hfx).sub hp) hq, | |
| laplacian_fun_sub (hfy.sub hfx) hp, laplacian_fun_sub hfy hfx, | |
| hly, laplacian_translate hf, | |
| laplacian_fun_const_mul (hg2.sub (hg.pow 2)), | |
| laplacian_fun_sub hg2 (hg.pow 2), | |
| laplacian_fun_const_mul hg, hlg, hlgs, | |
| laplacian_fun_const_mul (hnx.add hny), laplacian_fun_add hnx hny, | |
| laplacian_translate hns, laplacian_norm_sq, hlny] at hl | |
| simp only [add_zero] at hl | |
| linarith | |
| lemma bounded_poisson_lipschitz {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) {M C : β} (hM : 0 β€ M) (hC : 0 β€ C) | |
| (hbound : β x, |f x| β€ M) (hlap : β x, |Laplacian.laplacian f x| β€ C) : | |
| β x y, |f y - f x| β€ 2 * (2 * M + C + 1) * βy - xβ := by | |
| let A := 2 * M + C + 1 | |
| have hA : 0 < A := by dsimp [A]; positivity | |
| have hlarge : 2 * M < A := by dsimp [A]; linarith | |
| have honeway : β x y, f y - f x β€ 2 * A * βy - xβ := by | |
| intro xβ yβ | |
| by_contra hbad | |
| have hbad' : 2 * A * βyβ - xββ < f yβ - f xβ := lt_of_not_ge hbad | |
| let Ξ΄ := f yβ - f xβ - poissonPenalty A βyβ - xββ | |
| have hΞ΄ : 0 < Ξ΄ := by | |
| dsimp [Ξ΄] | |
| have hh := poissonPenalty_le_linear hA.le (norm_nonneg (yβ - xβ)) | |
| linarith | |
| let S := βxββ ^ 2 + βyββ ^ 2 | |
| have hS : 0 β€ S := by dsimp [S]; positivity | |
| let Ξ΅ := min (Ξ΄ / (2 * (S + 1))) (1 / (n + 1 : β)) | |
| have hΞ΅ : 0 < Ξ΅ := lt_min (by positivity) (by positivity) | |
| have hΞ΅S : Ξ΅ * (S + 1) β€ Ξ΄ / 2 := by | |
| have hh := min_le_left (Ξ΄ / (2 * (S + 1))) (1 / (n + 1 : β)) | |
| have hh' := (le_div_iffβ (show 0 < 2 * (S + 1) by positivity)).mp hh | |
| change Ξ΅ * (2 * (S + 1)) β€ Ξ΄ at hh' | |
| linarith | |
| have hΞ΅n : (n : β) * Ξ΅ β€ 1 := by | |
| have hh := min_le_right (Ξ΄ / (2 * (S + 1))) (1 / (n + 1 : β)) | |
| have hh' := (le_div_iffβ (show 0 < (n : β) + 1 by positivity)).mp hh | |
| change Ξ΅ * ((n : β) + 1) β€ 1 at hh' | |
| nlinarith | |
| have hposβ : 0 < f yβ - f xβ - poissonPenalty A βyβ - xββ - | |
| Ξ΅ * (βxββ ^ 2 + βyββ ^ 2) := by | |
| change 0 < Ξ΄ - Ξ΅ * S | |
| nlinarith | |
| obtain β¨x, y, hmβ© := poisson_maximum hf.continuous hM hbound hA.le hΞ΅ | |
| have hp : 0 < f y - f x - poissonPenalty A βy - xβ - Ξ΅ * (βxβ ^ 2 + βyβ ^ 2) := | |
| hposβ.trans_le (hm xβ yβ) | |
| have hpen : 0 β€ Ξ΅ * (βxβ ^ 2 + βyβ ^ 2) := by positivity | |
| have hxy : y β x := by | |
| rintro rfl | |
| simp only [sub_self, norm_zero, poissonPenalty, sub_zero, max_eq_left zero_le_one, | |
| one_pow, sub_self, mul_zero] at hp | |
| linarith | |
| have hs : βy - xβ < 1 := by | |
| by_contra h | |
| rw [poissonPenalty_of_ge A (le_of_not_gt h)] at hp | |
| have hbβ := (abs_le.mp (hbound x)).1 | |
| have hbβ := (abs_le.mp (hbound y)).2 | |
| linarith | |
| have hl := laplacian_poisson_at_max hf A Ξ΅ hxy hs hm | |
| have hbβ := (abs_le.mp (hlap y)).1 | |
| have hbβ := (abs_le.mp (hlap x)).2 | |
| dsimp [A] at hl | |
| linarith | |
| intro x y | |
| apply abs_le.mpr | |
| constructor | |
| Β· have h := honeway y x | |
| rw [norm_sub_rev x y] at h | |
| linarith | |
| Β· exact honeway x y | |
| def difference {n : β} (h : Space n) (f : Space n β β) : Space n β β := | |
| fun x => f (x + h) - f x | |
| def iterDifference {n : β} : List (Space n) β (Space n β β) β Space n β β | |
| | [], f => f | |
| | h :: l, f => difference h (iterDifference l f) | |
| def differenceScale {n : β} (l : List (Space n)) : β := (l.map (fun h => βhβ)).prod | |
| def DifferenceBound {n : β} (k : β) (f : Space n β β) (M : β) : Prop := | |
| β l : List (Space n), l.length β€ k β β x, |iterDifference l f x| β€ M * differenceScale l | |
| lemma differenceScale_nonneg {n : β} (l : List (Space n)) : 0 β€ differenceScale l := by | |
| apply List.prod_nonneg | |
| intro a ha | |
| obtain β¨h, _, rflβ© := List.mem_map.mp ha | |
| exact norm_nonneg h | |
| lemma difference_comm {n : β} (h k : Space n) (f : Space n β β) : | |
| difference h (difference k f) = difference k (difference h f) := by | |
| funext x | |
| simp only [difference] | |
| rw [show x + h + k = x + k + h by abel] | |
| ring | |
| lemma iterDifference_difference {n : β} (l : List (Space n)) (h : Space n) (f : Space n β β) : | |
| iterDifference l (difference h f) = difference h (iterDifference l f) := by | |
| induction l with | |
| | nil => rfl | |
| | cons a l ih => simp only [iterDifference, ih, difference_comm a h] | |
| lemma iterDifference_add {n : β} (l : List (Space n)) (f g : Space n β β) : | |
| iterDifference l (fun x => f x + g x) = fun x => iterDifference l f x + iterDifference l g x := by | |
| induction l with | |
| | nil => rfl | |
| | cons h l ih => | |
| funext x | |
| simp only [iterDifference, ih, difference] | |
| ring | |
| lemma iterDifference_sub {n : β} (l : List (Space n)) (f g : Space n β β) : | |
| iterDifference l (fun x => f x - g x) = fun x => iterDifference l f x - iterDifference l g x := by | |
| induction l with | |
| | nil => rfl | |
| | cons h l ih => | |
| funext x | |
| simp only [iterDifference, ih, difference] | |
| ring | |
| lemma iterDifference_const_mul {n : β} (l : List (Space n)) (c : β) (f : Space n β β) : | |
| iterDifference l (fun x => c * f x) = fun x => c * iterDifference l f x := by | |
| induction l with | |
| | nil => rfl | |
| | cons h l ih => | |
| funext x | |
| simp only [iterDifference, ih, difference] | |
| ring | |
| lemma iterDifference_translate {n : β} (l : List (Space n)) (h : Space n) (f : Space n β β) : | |
| iterDifference l (fun x => f (x + h)) = fun x => iterDifference l f (x + h) := by | |
| induction l with | |
| | nil => rfl | |
| | cons a l ih => | |
| funext x | |
| simp only [iterDifference, ih, difference] | |
| rw [show x + a + h = x + h + a by abel] | |
| lemma DifferenceBound.mono {n k j : β} {f : Space n β β} {M : β} | |
| (hf : DifferenceBound k f M) (hj : j β€ k) : DifferenceBound j f M := | |
| fun l hl => hf l (hl.trans hj) | |
| lemma DifferenceBound.translate {n k : β} {f : Space n β β} {M : β} | |
| (hf : DifferenceBound k f M) (h : Space n) : DifferenceBound k (fun x => f (x + h)) M := by | |
| intro l hl x | |
| rw [iterDifference_translate] | |
| exact hf l hl (x + h) | |
| lemma DifferenceBound.normalized_difference {n k : β} {f : Space n β β} {M : β} | |
| (hf : DifferenceBound (k + 1) f M) {h : Space n} (hh : h β 0) : | |
| DifferenceBound k (fun x => βhββ»ΒΉ * difference h f x) M := by | |
| intro l hl x | |
| rw [iterDifference_const_mul, iterDifference_difference, abs_mul, | |
| abs_of_nonneg (inv_nonneg.mpr (norm_nonneg h))] | |
| have hb := hf (h :: l) (by simpa using Nat.add_le_add_right hl 1) x | |
| change |difference h (iterDifference l f) x| β€ M * (βhβ * differenceScale l) at hb | |
| have hn : 0 < βhβ := norm_pos_iff.mpr hh | |
| have hz := mul_le_mul_of_nonneg_left hb (inv_nonneg.mpr hn.le) | |
| calc | |
| βhββ»ΒΉ * |difference h (iterDifference l f) x| β€ βhββ»ΒΉ * (M * (βhβ * differenceScale l)) := hz | |
| _ = M * differenceScale l := by field_simp | |
| lemma DifferenceBound.sub {n k : β} {f g : Space n β β} {M N : β} | |
| (hf : DifferenceBound k f M) (hg : DifferenceBound k g N) : | |
| DifferenceBound k (fun x => f x - g x) (M + N) := by | |
| intro l hl x | |
| rw [iterDifference_sub] | |
| calc | |
| |iterDifference l f x - iterDifference l g x| β€ |iterDifference l f x| + |iterDifference l g x| := abs_sub _ _ | |
| _ β€ M * differenceScale l + N * differenceScale l := add_le_add (hf l hl x) (hg l hl x) | |
| _ = (M + N) * differenceScale l := by ring | |
| lemma DifferenceBound.mul {n k : β} {f g : Space n β β} {M N : β} | |
| (hM : 0 β€ M) (hN : 0 β€ N) (hf : DifferenceBound k f M) (hg : DifferenceBound k g N) : | |
| DifferenceBound k (fun x => f x * g x) ((2 : β) ^ k * M * N) := by | |
| induction k generalizing f g with | |
| | zero => | |
| intro l hl x | |
| have he : l = [] := List.length_eq_zero_iff.mp (Nat.eq_zero_of_le_zero hl) | |
| subst l | |
| have hfb := hf [] (by simp) x | |
| have hgb := hg [] (by simp) x | |
| simpa [iterDifference, differenceScale, abs_mul] using | |
| mul_le_mul hfb hgb (abs_nonneg _) (by simpa [differenceScale] using hM) | |
| | succ k ih => | |
| intro l hl x | |
| cases l with | |
| | nil => | |
| have hb := mul_le_mul (hf [] (by simp) x) (hg [] (by simp) x) (abs_nonneg _) | |
| (show 0 β€ M * differenceScale ([] : List (Space n)) by simpa [differenceScale] using hM) | |
| have hp : 1 β€ (2 : β) ^ (k + 1) := one_le_powβ (by norm_num) | |
| simp only [iterDifference, differenceScale, List.map_nil, List.prod_nil, mul_one, abs_mul] at hb β’ | |
| calc | |
| |f x| * |g x| β€ M * N := hb | |
| _ β€ 2 ^ (k + 1) * M * N := by nlinarith [mul_nonneg hM hN] | |
| | cons h l => | |
| by_cases hh : h = 0 | |
| Β· subst h | |
| simp [iterDifference, difference, differenceScale] | |
| have hl' : l.length β€ k := Nat.le_of_succ_le_succ hl | |
| let F : Space n β β := fun x => βhββ»ΒΉ * difference h f x | |
| let G : Space n β β := fun x => βhββ»ΒΉ * difference h g x | |
| have hF : DifferenceBound k F M := hf.normalized_difference hh | |
| have hG : DifferenceBound k G N := hg.normalized_difference hh | |
| have hf' : DifferenceBound k f M := hf.mono (Nat.le_succ k) | |
| have hg' : DifferenceBound k (fun x => g (x + h)) N := | |
| (hg.mono (Nat.le_succ k)).translate h | |
| have htβ := ih hF hg' l hl' x | |
| have htβ := ih hf' hG l hl' x | |
| have he : difference h (fun x => f x * g x) = | |
| fun x => βhβ * (F x * g (x + h) + f x * G x) := by | |
| funext x | |
| dsimp [difference, F, G] | |
| field_simp | |
| ring | |
| have ht : iterDifference (h :: l) (fun x => f x * g x) x = | |
| βhβ * (iterDifference l (fun x => F x * g (x + h)) x + | |
| iterDifference l (fun x => f x * G x) x) := by | |
| change difference h (iterDifference l (fun x => f x * g x)) x = _ | |
| rw [β iterDifference_difference, he, iterDifference_const_mul, iterDifference_add] | |
| rw [ht, abs_mul, abs_of_nonneg (norm_nonneg h)] | |
| have hab := (abs_add_le _ _).trans (add_le_add htβ htβ) | |
| have hmult := mul_le_mul_of_nonneg_left hab (norm_nonneg h) | |
| calc | |
| _ β€ βhβ * (2 ^ k * M * N * differenceScale l + 2 ^ k * M * N * differenceScale l) := hmult | |
| _ = 2 ^ (k + 1) * M * N * differenceScale (h :: l) := by | |
| simp only [differenceScale, List.map_cons, List.prod_cons, pow_succ] | |
| ring | |
| lemma iterDifference_contDiff {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) (l : List (Space n)) : ContDiff β 2 (iterDifference l f) := by | |
| induction l with | |
| | nil => exact hf | |
| | cons h l ih => exact (ih.comp (contDiff_id.add contDiff_const)).sub ih | |
| lemma laplacian_difference {n : β} {f : Space n β β} (hf : ContDiff β 2 f) | |
| (h x : Space n) : Laplacian.laplacian (difference h f) x = difference h (Laplacian.laplacian f) x := by | |
| have hc : ContDiff β 2 (fun x => f (x + h)) := hf.comp (contDiff_id.add contDiff_const) | |
| rw [show difference h f = (fun x => f (x + h)) - f by rfl, | |
| hc.contDiffAt.laplacian_sub hf.contDiffAt] | |
| change Laplacian.laplacian (fun z => f (z + h)) x - Laplacian.laplacian f x = _ | |
| rw [show (fun z => f (z + h)) = (fun z => f (h + z)) by funext z; rw [add_comm], | |
| laplacian_translate hf] | |
| simp [difference, add_comm] | |
| lemma laplacian_iterDifference {n : β} {f : Space n β β} (hf : ContDiff β 2 f) | |
| (l : List (Space n)) : Laplacian.laplacian (iterDifference l f) = iterDifference l (Laplacian.laplacian f) := by | |
| induction l with | |
| | nil => rfl | |
| | cons h l ih => | |
| funext x | |
| rw [iterDifference, laplacian_difference (iterDifference_contDiff hf l), ih] | |
| rfl | |
| lemma iterDifference_eq_zero_of_scale_eq_zero {n : β} (l : List (Space n)) | |
| (hl : differenceScale l = 0) (f : Space n β β) : iterDifference l f = 0 := by | |
| induction l with | |
| | nil => simp [differenceScale] at hl | |
| | cons h l ih => | |
| have hp : βhβ * differenceScale l = 0 := hl | |
| rcases mul_eq_zero.mp hp with hh | hl | |
| Β· have hz : h = 0 := norm_eq_zero.mp hh | |
| subst h | |
| ext x | |
| simp [iterDifference, difference] | |
| Β· rw [iterDifference, ih hl] | |
| ext x | |
| simp [difference] | |
| end RegularitySupport.DeGiorgi | |
| end | |
| end OAI | |