Download data/lean/OAI/Analysis/AllenCahn/Basic.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 15.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/AllenCahn/Basic.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/AllenCahn/Basic.lean
-
curl -L -o Basic.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/AllenCahn/Basic.lean
15.8 kB
| import Mathlib | |
| namespace OAI | |
| noncomputable section | |
| namespace DeGiorgi | |
| open MeasureTheory | |
| open scoped ENNReal | |
| abbrev Space (n : β) := EuclideanSpace β (Fin n) | |
| def potential (t : β) : β := (1 - t ^ 2) ^ 2 / 4 | |
| def profile (s : β) : β := Real.tanh (s / Real.sqrt 2) | |
| def surfaceTension : β := 2 * Real.sqrt 2 / 3 | |
| def AllenCahn {n : β} (v : Space n β β) : Prop := | |
| β x, Laplacian.laplacian v x = v x ^ 3 - v x | |
| def SecondVariation {n : β} (v Ο : Space n β β) : β := | |
| β« x, (βgradient Ο xβ ^ 2 + (3 * v x ^ 2 - 1) * Ο x ^ 2) | |
| def Stable {n : β} (v : Space n β β) : Prop := | |
| β Ο : Space n β β, ContDiff β 1 Ο β HasCompactSupport Ο β | |
| 0 β€ SecondVariation v Ο | |
| def Energy {n : β} (v : Space n β β) (Ξ© : Set (Space n)) : β := | |
| β« x in Ξ©, (βgradient v xβ ^ 2 / 2 + potential (v x)) | |
| def unitBallVolume (m : β) : β := | |
| volume.real (Metric.ball (0 : Space m) 1) | |
| def density {n : β} (v : Space n β β) (R : β) (y : Space n) : β := | |
| Energy v (Metric.ball y R) / (surfaceTension * unitBallVolume (n - 1) * R ^ (n - 1)) | |
| def densityAtInfinity {n : β} (v : Space n β β) : ββ₯0β := | |
| β¨ R : { R : β // 0 < R }, ENNReal.ofReal (density v R.val 0) | |
| def Classified {n : β} (v : Space n β β) : Prop := | |
| (β x, v x = 1) β¨ (β x, v x = -1) β¨ | |
| β (a : Space n) (b : β), βaβ = 1 β§ β x, v x = profile (inner β a x - b) | |
| def StableRigiditySeven : Prop := | |
| β v : Space 7 β β, ContDiff β 2 v β | |
| (β x, v x β Set.Icc (-1 : β) 1) β AllenCahn v β Stable v β Classified v | |
| def MonotoneRigidityEight : Prop := | |
| β u : Space 8 β β, ContDiff β 2 u β | |
| (β x, u x β Set.Ioo (-1 : β) 1) β AllenCahn u β | |
| (β x, 0 < fderiv β u x (EuclideanSpace.single (7 : Fin 8) 1)) β | |
| β (e : Space 8) (c : β), βeβ = 1 β§ 0 < e 7 β§ | |
| β x, u x = profile (inner β e x - c) | |
| def FiniteDensityRigidity : Prop := | |
| β (n : β), 4 β€ n β n β€ 7 β | |
| β v : Space n β β, ContDiff β 2 v β | |
| (β x, v x β Set.Icc (-1 : β) 1) β AllenCahn v β Stable v β | |
| densityAtInfinity v < β€ β Classified v | |
| end DeGiorgi | |
| end | |
| noncomputable section | |
| namespace DeGiorgi | |
| open MeasureTheory | |
| open scoped ENNReal | |
| open Filter Topology | |
| lemma second_deriv_nonneg_of_local_min {f : β β β} {x : β} | |
| (hf : ContinuousAt f x) (hm : IsLocalMin f x) : 0 β€ deriv (deriv f) x := by | |
| by_contra h | |
| have hn : deriv (deriv f) x < 0 := lt_of_not_ge h | |
| have hmax := isLocalMax_of_deriv_deriv_neg hn hm.deriv_eq_zero hf | |
| have he : f =αΆ [π x] fun _ => f x := by | |
| filter_upwards [hm, hmax] with y hy hz using le_antisymm hz hy | |
| have hz := he.deriv.deriv_eq | |
| have hz0 : deriv (deriv f) x = 0 := by | |
| calc deriv (deriv f) x = deriv (deriv (fun _ : β => f x)) x := hz | |
| _ = 0 := by simp | |
| linarith | |
| def basis (n : β) := EuclideanSpace.basisFun (Fin n) β | |
| def coordDeriv {n : β} (f : Space n β β) (i : Fin n) (x : Space n) : β := | |
| fderiv β f x (basis n i) | |
| lemma coordDeriv_contDiff {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) (i : Fin n) : ContDiff β 1 (coordDeriv f i) := by | |
| exact (hf.fderiv_right (m := 1) (by norm_num)).clm_apply contDiff_const | |
| lemma laplacian_eq_sum_coordDeriv {n : β} {f : Space n β β} (hf : ContDiff β 2 f) | |
| (x : Space n) : | |
| Laplacian.laplacian f x = β i : Fin n, coordDeriv (coordDeriv f i) i x := by | |
| rw [InnerProductSpace.laplacian_eq_iteratedFDeriv_orthonormalBasis f (basis n)] | |
| apply Finset.sum_congr rfl | |
| intro i hi | |
| rw [iteratedFDeriv_two_apply] | |
| change _ = fderiv β (fun y => fderiv β f y (basis n i)) x (basis n i) | |
| simp [fderiv_clm_apply | |
| ((hf.fderiv_right (m := 1) (by norm_num)).differentiable (by norm_num) x) | |
| (differentiableAt_const (c := basis n i))] | |
| lemma deriv_line {n : β} {f : Space n β β} (hf : Differentiable β f) | |
| (x e : Space n) (t : β) : | |
| deriv (fun s : β => f (x + s β’ e)) t = fderiv β f (x + t β’ e) e := by | |
| have hd : HasDerivAt (fun s : β => x + s β’ e) e t := by | |
| simpa using (hasDerivAt_const t x).fun_add ((hasDerivAt_id t).smul_const e) | |
| exact ((hf _).hasFDerivAt.comp_hasDerivAt t hd).deriv | |
| lemma laplacian_nonneg_of_local_min {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) {x : Space n} (hm : IsLocalMin f x) : | |
| 0 β€ Laplacian.laplacian f x := by | |
| rw [laplacian_eq_sum_coordDeriv hf] | |
| apply Finset.sum_nonneg | |
| intro i _ | |
| let g : β β β := fun s => f (x + s β’ basis n i) | |
| have hg : ContinuousAt g 0 := hf.continuous.continuousAt.comp | |
| (continuous_const.add (continuous_id.smul continuous_const)).continuousAt | |
| have hmin : IsLocalMin g 0 := by | |
| have ht : Tendsto (fun s : β => x + s β’ basis n i) (π 0) (π x) := by | |
| have hc : Continuous (fun s : β => x + s β’ basis n i) := | |
| continuous_const.add (continuous_id.smul continuous_const) | |
| simpa only [ContinuousAt, zero_smul, add_zero] using hc.continuousAt (x := 0) | |
| change βαΆ s in π (0 : β), g 0 β€ g s | |
| simpa [g] using ht.eventually hm | |
| have hder : deriv g = fun s => coordDeriv f i (x + s β’ basis n i) := by | |
| funext s | |
| exact deriv_line (hf.differentiable (by norm_num)) x (basis n i) s | |
| have hh := second_deriv_nonneg_of_local_min hg hmin | |
| rw [hder, deriv_line ((coordDeriv_contDiff hf i).differentiable (by norm_num))] at hh | |
| simpa [coordDeriv] using hh | |
| lemma laplacian_nonpos_of_local_max {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) {x : Space n} (hm : IsLocalMax f x) : | |
| Laplacian.laplacian f x β€ 0 := by | |
| have h := laplacian_nonneg_of_local_min hf.neg hm.neg | |
| change 0 β€ Laplacian.laplacian (-f) x at h | |
| rw [InnerProductSpace.laplacian_neg] at h | |
| simpa using h | |
| lemma coordDeriv_translate {n : β} {f : Space n β β} | |
| (hf : Differentiable β f) (a : Space n) (i : Fin n) (x : Space n) : | |
| coordDeriv (fun z => f (a + z)) i x = coordDeriv f i (a + x) := by | |
| dsimp [coordDeriv] | |
| have hd : HasFDerivAt (fun z => f (a + z)) (fderiv β f (a + x)) x := by | |
| simpa only [Function.comp_def, zero_add, ContinuousLinearMap.comp_id, id_eq] using (hf (a + x)).hasFDerivAt.comp x | |
| ((hasFDerivAt_const a x).fun_add (hasFDerivAt_id x)) | |
| rw [hd.fderiv] | |
| lemma laplacian_translate {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) (a x : Space n) : | |
| Laplacian.laplacian (fun z => f (a + z)) x = Laplacian.laplacian f (a + x) := by | |
| have hs : ContDiff β 2 (fun z => f (a + z)) := | |
| hf.comp (contDiff_const.add contDiff_id) | |
| rw [laplacian_eq_sum_coordDeriv hs, | |
| laplacian_eq_sum_coordDeriv hf] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| have hfun : coordDeriv (fun z => f (a + z)) i = fun z => coordDeriv f i (a + z) := | |
| funext (coordDeriv_translate (hf.differentiable (by norm_num)) a i) | |
| rw [hfun, coordDeriv_translate ((coordDeriv_contDiff hf i).differentiable (by norm_num))] | |
| lemma laplacian_norm_sq {n : β} (x : Space n) : | |
| Laplacian.laplacian (fun z : Space n => βzβ ^ 2) x = 2 * n := by | |
| have hs : ContDiff β 2 (fun z : Space n => βzβ ^ 2) := contDiff_id.norm_sq β | |
| rw [laplacian_eq_sum_coordDeriv hs] | |
| have hfirst (i : Fin n) : coordDeriv (fun z : Space n => βzβ ^ 2) i = | |
| fun z => 2 * inner β z (basis n i) := by | |
| funext z | |
| simp [coordDeriv] | |
| simp_rw [hfirst] | |
| have hsecond (i : Fin n) : coordDeriv (fun z => 2 * inner β z (basis n i)) i x = 2 := by | |
| dsimp [coordDeriv] | |
| have hd : HasFDerivAt (fun z : Space n => 2 * inner β z (basis n i)) | |
| ((2 : β) β’ innerSL β (basis n i)) x := by | |
| simpa [real_inner_comm] using | |
| ((innerSL β (basis n i)).hasFDerivAt (x := x)).const_mul 2 | |
| rw [hd.fderiv] | |
| simp [basis] | |
| simp_rw [hsecond] | |
| simp [mul_comm] | |
| lemma hasFDerivAt_norm_nonzero {n : β} {x : Space n} (hx : x β 0) : | |
| HasFDerivAt (fun z : Space n => βzβ) (βxββ»ΒΉ β’ innerSL β x) x := by | |
| have h := (hasStrictFDerivAt_norm_sq x).hasFDerivAt.sqrt | |
| (pow_ne_zero 2 (norm_ne_zero_iff.mpr hx)) | |
| simp only [Real.sqrt_sq (norm_nonneg _)] at h | |
| have he : (1 / (2 * βxβ) : β) * 2 = βxββ»ΒΉ := by field_simp | |
| rw [β Nat.cast_smul_eq_nsmul β 2, smul_smul, Nat.cast_ofNat, he] at h | |
| exact h | |
| lemma two_point_maximum {n : β} {f : Space n β β} (hf : Continuous f) | |
| {M L Ξ΅ : β} (hM : 0 β€ M) (hbound : β x, |f x| β€ M) | |
| (hL : 0 β€ L) (hΞ΅ : 0 < Ξ΅) : | |
| β x y : Space n, β a b : Space n, | |
| f b - f a - L * βb - aβ - Ξ΅ * (βaβ ^ 2 + βbβ ^ 2) β€ | |
| f y - f x - L * βy - xβ - Ξ΅ * (βxβ ^ 2 + βyβ ^ 2) := by | |
| let H : Space n Γ Space n β β := fun z => | |
| f z.2 - f z.1 - L * βz.2 - z.1β - Ξ΅ * (βz.1β ^ 2 + βz.2β ^ 2) | |
| have hc : Continuous H := by fun_prop | |
| let R := Real.sqrt (2 * M / Ξ΅ + 1) | |
| have hR : 0 β€ R := Real.sqrt_nonneg _ | |
| have hR2 : R ^ 2 = 2 * M / Ξ΅ + 1 := Real.sq_sqrt (by positivity) | |
| have hevent : βαΆ z in cocompact (Space n Γ Space n), H z β€ H (0, 0) := by | |
| filter_upwards [((isCompact_closedBall (0 : Space n) R).prod | |
| (isCompact_closedBall (0 : Space n) R)).compl_mem_cocompact] with z hz | |
| have hz' : R < βz.1β β¨ R < βz.2β := by | |
| simpa only [Set.mem_compl_iff, Set.mem_prod, Metric.mem_closedBall, dist_zero_right, | |
| not_and_or, not_le] using hz | |
| have hsq : R ^ 2 < βz.1β ^ 2 + βz.2β ^ 2 := by | |
| rcases hz' with hz' | hz' | |
| Β· nlinarith [sq_nonneg βz.2β, norm_nonneg z.1] | |
| Β· nlinarith [sq_nonneg βz.1β, norm_nonneg z.2] | |
| have heq : Ξ΅ * (2 * M / Ξ΅ + 1) = 2 * M + Ξ΅ := by field_simp | |
| have hh := mul_lt_mul_of_pos_left hsq hΞ΅ | |
| have hb1 := (abs_le.mp (hbound z.1)).1 | |
| have hb2 := (abs_le.mp (hbound z.2)).2 | |
| have hcost := mul_nonneg hL (norm_nonneg (z.2 - z.1)) | |
| dsimp [H] | |
| simp only [sub_self, norm_zero, mul_zero, zero_pow two_ne_zero, add_zero] | |
| rw [hR2, heq] at hh | |
| linarith | |
| obtain β¨β¨x, yβ©, hmaxβ© := hc.exists_forall_ge' (0, 0) hevent | |
| exact β¨x, y, fun a b => hmax (a, b)β© | |
| lemma gradient_at_two_point_max_y {n : β} {f : Space n β β} | |
| (hf : Differentiable β f) (L Ξ΅ : β) {x y : Space n} (hxy : y β x) | |
| (hm : β b : Space n, | |
| f b - f x - L * βb - xβ - Ξ΅ * (βxβ ^ 2 + βbβ ^ 2) β€ | |
| f y - f x - L * βy - xβ - Ξ΅ * (βxβ ^ 2 + βyβ ^ 2)) : | |
| gradient f y = (L / βy - xβ) β’ (y - x) + (2 * Ξ΅) β’ y := by | |
| have hn : HasFDerivAt (fun b : Space n => βb - xβ) | |
| (βy - xββ»ΒΉ β’ innerSL β (y - x)) y := by | |
| simpa only [Function.comp_def, ContinuousLinearMap.comp_id, id_eq] using | |
| (hasFDerivAt_norm_nonzero (sub_ne_zero.mpr hxy)).comp y | |
| ((hasFDerivAt_id y).sub_const x) | |
| have hq : HasFDerivAt (fun b : Space n => βxβ ^ 2 + βbβ ^ 2) | |
| ((2 : β) β’ innerSL β y) y := by | |
| have hh := (hasStrictFDerivAt_norm_sq y).hasFDerivAt.const_add (βxβ ^ 2) | |
| rw [β Nat.cast_smul_eq_nsmul β 2, Nat.cast_ofNat] at hh | |
| exact hh | |
| have hd := (((hf y).hasFDerivAt.sub_const (f x)).fun_sub | |
| (hn.const_mul L)).fun_sub (hq.const_mul Ξ΅) | |
| have hz := (show IsLocalMax | |
| (fun b => f b - f x - L * βb - xβ - Ξ΅ * (βxβ ^ 2 + βbβ ^ 2)) y from | |
| Filter.Eventually.of_forall hm).hasFDerivAt_eq_zero hd | |
| apply (InnerProductSpace.toDual β (Space n)).injective | |
| ext z | |
| have he := congrArg (fun A : Space n βL[β] β => A z) hz | |
| simp only [sub_apply, smul_apply, smul_eq_mul, zero_apply] at he | |
| change (fderiv β f y) z - L * (βy - xββ»ΒΉ * inner β (y - x) z) - | |
| Ξ΅ * (2 * inner β y z) = 0 at he | |
| simp only [toDual_gradient, map_add, map_smul, add_apply, smul_apply, | |
| InnerProductSpace.toDual_apply_apply, smul_eq_mul] | |
| rw [div_eq_mul_inv] | |
| linarith | |
| lemma laplacian_fun_sub {n : β} {f g : Space n β β} | |
| (hf : ContDiff β 2 f) (hg : ContDiff β 2 g) (x : Space n) : | |
| Laplacian.laplacian (fun z => f z - g z) x = | |
| Laplacian.laplacian f x - Laplacian.laplacian g x := by | |
| change Laplacian.laplacian (f - g) x = _ | |
| exact hf.contDiffAt.laplacian_sub hg.contDiffAt | |
| lemma laplacian_fun_add {n : β} {f g : Space n β β} | |
| (hf : ContDiff β 2 f) (hg : ContDiff β 2 g) (x : Space n) : | |
| Laplacian.laplacian (fun z => f z + g z) x = | |
| Laplacian.laplacian f x + Laplacian.laplacian g x := by | |
| change Laplacian.laplacian (f + g) x = _ | |
| exact hf.contDiffAt.laplacian_add hg.contDiffAt | |
| lemma laplacian_fun_const_mul {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) (c : β) (x : Space n) : | |
| Laplacian.laplacian (fun z => c * f z) x = c * Laplacian.laplacian f x := by | |
| change Laplacian.laplacian (c β’ f) x = _ | |
| exact InnerProductSpace.laplacian_smul c hf.contDiffAt | |
| lemma laplacian_at_two_point_max {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) (L Ξ΅ : β) {x y : Space n} | |
| (hm : β a b : Space n, | |
| f b - f a - L * βb - aβ - Ξ΅ * (βaβ ^ 2 + βbβ ^ 2) β€ | |
| f y - f x - L * βy - xβ - Ξ΅ * (βxβ ^ 2 + βyβ ^ 2)) : | |
| Laplacian.laplacian f y - Laplacian.laplacian f x β€ 4 * n * Ξ΅ := by | |
| let F : Space n β β := fun z => | |
| f (y + z) - f (x + z) - L * βy - xβ - Ξ΅ * (βx + zβ ^ 2 + βy + zβ ^ 2) | |
| have hF : ContDiff β 2 F := by | |
| dsimp [F] | |
| exact (((hf.comp (contDiff_const.add contDiff_id)).sub | |
| (hf.comp (contDiff_const.add contDiff_id))).sub contDiff_const).sub | |
| ((((contDiff_const.add contDiff_id).norm_sq β).add | |
| ((contDiff_const.add contDiff_id).norm_sq β)).const_smul Ξ΅) | |
| have hmF : IsLocalMax F 0 := Filter.Eventually.of_forall (fun z => by | |
| simpa [F, add_sub_add_right_eq_sub] using hm (x + z) (y + z)) | |
| have hl := laplacian_nonpos_of_local_max hF hmF | |
| have hj : Laplacian.laplacian F 0 = | |
| Laplacian.laplacian f y - Laplacian.laplacian f x - Ξ΅ * (2 * n + 2 * n) := by | |
| have hfx : ContDiff β 2 (fun z => f (x + z)) := hf.comp (contDiff_const.add contDiff_id) | |
| have hfy : ContDiff β 2 (fun z => f (y + 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 + zβ ^ 2) := | |
| (contDiff_const.add contDiff_id).norm_sq β | |
| have hA : ContDiff β 2 (fun z => f (y + z) - f (x + z) - L * βy - xβ) := | |
| (hfy.sub hfx).sub contDiff_const | |
| have hB : ContDiff β 2 (fun z => Ξ΅ * (βx + zβ ^ 2 + βy + zβ ^ 2)) := | |
| contDiff_const.mul (hnx.add hny) | |
| have hC : ContDiff β 2 (fun _ : Space n => L * βy - xβ) := contDiff_const | |
| dsimp only [F] | |
| rw [laplacian_fun_sub hA hB, | |
| laplacian_fun_sub (hfy.sub hfx) hC, | |
| laplacian_fun_sub hfy hfx, | |
| laplacian_fun_const_mul (hnx.add hny) Ξ΅, | |
| laplacian_fun_add hnx hny] | |
| simp only [laplacian_translate hf, add_zero, InnerProductSpace.laplacian_const, | |
| Pi.zero_apply, sub_zero] | |
| have hns : ContDiff β 2 (fun z : Space n => βzβ ^ 2) := contDiff_id.norm_sq β | |
| rw [laplacian_translate hns, laplacian_translate hns] | |
| simp [laplacian_norm_sq] | |
| rw [hj] at hl | |
| linarith | |
| lemma sq_norm_error {n : β} {u p : Space n} {L E : β} | |
| (hL : 0 β€ L) (hE : 0 β€ E) (hp : βpβ = L) (hu : βu - pβ β€ E) : | |
| |βuβ ^ 2 - L ^ 2| β€ E * (2 * L + E) := by | |
| have h1 : |βuβ - L| β€ E := by rw [β hp]; exact (abs_norm_sub_norm_le u p).trans hu | |
| have h2 : βuβ + L β€ 2 * L + E := by have := (abs_le.mp h1).2; linarith | |
| calc | |
| |βuβ ^ 2 - L ^ 2| = |βuβ - L| * (βuβ + L) := by | |
| rw [β abs_of_nonneg (add_nonneg (norm_nonneg u) hL), β abs_mul] | |
| congr 1 | |
| ring | |
| _ β€ E * (2 * L + E) := mul_le_mul h1 h2 (add_nonneg (norm_nonneg u) hL) hE | |
| end DeGiorgi | |
| end | |
| end OAI | |