Download data/lean/OAI/Analysis/AllenCahn/StrongMaximum.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 17 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/AllenCahn/StrongMaximum.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/AllenCahn/StrongMaximum.lean
-
curl -L -o StrongMaximum.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/AllenCahn/StrongMaximum.lean
17 kB
| import OAI.Analysis.AllenCahn.JetProducts | |
| namespace OAI | |
| noncomputable section | |
| namespace PositiveMaximum | |
| open Filter Set Topology | |
| open scoped NNReal | |
| open scoped SchwartzMap Laplacian ContDiff | |
| open FourierTransform | |
| abbrev Space (n : β) := EuclideanSpace β (Fin n) | |
| end PositiveMaximum | |
| end | |
| noncomputable section | |
| namespace PositiveMaximum | |
| open Filter Set Topology | |
| open scoped NNReal | |
| open scoped SchwartzMap Laplacian ContDiff | |
| open FourierTransform | |
| 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 | |
| private 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 compact_minimum_principle {n : β} {f : Space n β β} | |
| (hf : ContDiff β 2 f) {K : Set (Space n)} (hK : IsCompact K) | |
| (hboundary : β x β K, x β interior K β 0 β€ f x) | |
| (hineq : β x β interior K, Laplacian.laplacian f x β€ 2 * f x) : | |
| β x β K, 0 β€ f x := by | |
| intro x hx | |
| by_contra hn | |
| have hneg : f x < 0 := lt_of_not_ge hn | |
| obtain β¨y, hy, hminβ© := hK.exists_isMinOn β¨x, hxβ© hf.continuous.continuousOn | |
| have hyneg : f y < 0 := lt_of_le_of_lt (hmin hx) hneg | |
| have hyint : y β interior K := by | |
| by_contra hh | |
| exact (not_le_of_gt hyneg) (hboundary y hy hh) | |
| have hlap := laplacian_nonneg_of_local_min hf | |
| (hmin.isLocalMin (mem_interior_iff_mem_nhds.mp hyint)) | |
| have hle := hineq y hyint | |
| linarith | |
| private def gaussian {n : β} (a : β) (y : Space n) (x : Space n) : β := | |
| Real.exp (-a * βx - yβ ^ 2) | |
| private lemma gaussian_contDiff {n : β} (a : β) (y : Space n) : | |
| ContDiff β 2 (gaussian a y) := by | |
| exact ((contDiff_const.mul ((contDiff_norm_sq β).comp | |
| (contDiff_id.sub contDiff_const)))).exp | |
| private lemma fderiv_gaussian {n : β} (a : β) (y x e : Space n) : | |
| fderiv β (gaussian a y) x e = | |
| gaussian a y x * (-2 * a * inner β (x - y) e) := by | |
| have h := (((hasFDerivAt_id x).sub (hasFDerivAt_const y x)).norm_sq.const_mul (-a)).exp | |
| rw [show fderiv β (gaussian a y) x = _ from h.fderiv] | |
| simp [gaussian, inner_sub_left] | |
| ring | |
| private lemma second_coord_gaussian {n : β} (a : β) (y x : Space n) (i : Fin n) : | |
| coordDeriv (coordDeriv (gaussian a y) i) i x = | |
| gaussian a y x * (4 * a ^ 2 * (inner β (x - y) (basis n i)) ^ 2 - 2 * a) := by | |
| have hfun : coordDeriv (gaussian a y) i = fun z => | |
| gaussian a y z * (-2 * a * inner β (z - y) (basis n i)) := by | |
| funext z | |
| exact fderiv_gaussian a y z (basis n i) | |
| rw [hfun] | |
| unfold coordDeriv | |
| have hg := (gaussian_contDiff a y).differentiable (by norm_num) | |
| have hl : Differentiable β (fun z : Space n => inner β (z - y) (basis n i)) := | |
| (differentiable_id.sub (differentiable_const y)).inner β (differentiable_const _) | |
| rw [fderiv_fun_mul (hg x) ((hl.const_mul (-2 * a)) x)] | |
| simp only [add_apply, smul_apply, smul_eq_mul] | |
| rw [fderiv_gaussian] | |
| have hi : fderiv β (fun z : Space n => -2 * a * inner β (z - y) (basis n i)) x | |
| (basis n i) = -2 * a := by | |
| rw [fderiv_const_mul (hl x) (-2 * a)] | |
| simp only [smul_apply, smul_eq_mul] | |
| have hs : DifferentiableAt β (fun z : Space n => z - y) x := | |
| differentiableAt_id.sub (differentiableAt_const y) | |
| rw [fderiv_inner_apply β hs (differentiableAt_const (c := basis n i))] | |
| simp [basis, fderiv_fun_sub] | |
| rw [hi] | |
| ring | |
| private lemma laplacian_gaussian {n : β} (a : β) (y x : Space n) : | |
| Laplacian.laplacian (gaussian a y) x = | |
| gaussian a y x * (4 * a ^ 2 * βx - yβ ^ 2 - 2 * a * n) := by | |
| rw [laplacian_eq_sum_coordDeriv (gaussian_contDiff a y)] | |
| simp_rw [second_coord_gaussian] | |
| rw [β Finset.mul_sum, Finset.sum_sub_distrib, β Finset.mul_sum, | |
| (basis n).sum_sq_inner_left] | |
| simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] | |
| ring | |
| private def barrier {n : β} (a r : β) (y : Space n) (x : Space n) : β := | |
| gaussian a y x - Real.exp (-a * r ^ 2) | |
| private lemma barrier_contDiff {n : β} (a r : β) (y : Space n) : | |
| ContDiff β 2 (barrier a r y) := (gaussian_contDiff a y).sub contDiff_const | |
| private lemma laplacian_barrier {n : β} (a r : β) (y x : Space n) : | |
| Laplacian.laplacian (barrier a r y) x = | |
| gaussian a y x * (4 * a ^ 2 * βx - yβ ^ 2 - 2 * a * n) := by | |
| change Laplacian.laplacian ((gaussian a y) - (fun _ : Space n => Real.exp (-a * r ^ 2))) x = _ | |
| rw [(gaussian_contDiff a y).contDiffAt.laplacian_sub contDiff_const.contDiffAt, | |
| InnerProductSpace.laplacian_const] | |
| simpa using laplacian_gaussian a y x | |
| private lemma barrier_le_one {n : β} {a : β} (ha : 0 β€ a) (r : β) (y x : Space n) : | |
| barrier a r y x β€ 1 := by | |
| have he : gaussian a y x β€ 1 := by | |
| rw [gaussian, Real.exp_le_one_iff] | |
| exact mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr ha) (sq_nonneg _) | |
| have hh := Real.exp_pos (-a * r ^ 2) | |
| dsimp [barrier] | |
| linarith | |
| private lemma barrier_subsolution {n : β} {a r : β} (ha : 1 β€ a) (hr : 0 < r) | |
| (hscale : 2 * (n : β) + 2 β€ a * r ^ 2) (y x : Space n) | |
| (hx : r / 2 β€ βx - yβ) : | |
| 2 * barrier a r y x β€ Laplacian.laplacian (barrier a r y) x := by | |
| have han : 0 β€ a := le_trans (by norm_num) ha | |
| have hs : r ^ 2 β€ 4 * βx - yβ ^ 2 := by nlinarith [norm_nonneg (x - y)] | |
| have h1 := mul_le_mul_of_nonneg_left hscale han | |
| have h2 := mul_le_mul_of_nonneg_left hs (sq_nonneg a) | |
| have hcoeff : 0 β€ 4 * a ^ 2 * βx - yβ ^ 2 - 2 * a * n - 2 := by | |
| nlinarith | |
| have hp : 0 β€ gaussian a y x := le_of_lt (Real.exp_pos _) | |
| have hm := mul_nonneg hp hcoeff | |
| have he := Real.exp_pos (-a * r ^ 2) | |
| rw [laplacian_barrier] | |
| dsimp only [barrier] | |
| nlinarith | |
| private lemma laplacian_sub_const_mul {n : β} {w b : Space n β β} | |
| (hw : ContDiff β 2 w) (hb : ContDiff β 2 b) (Ξ΅ : β) (x : Space n) : | |
| Laplacian.laplacian (fun z => w z - Ξ΅ * b z) x = | |
| Laplacian.laplacian w x - Ξ΅ * Laplacian.laplacian b x := by | |
| change Laplacian.laplacian (w - Ξ΅ β’ b) x = _ | |
| have hs : ContDiff β 2 (Ξ΅ β’ b) := hb.const_smul Ξ΅ | |
| rw [hw.contDiffAt.laplacian_sub hs.contDiffAt, | |
| InnerProductSpace.laplacian_smul Ξ΅ hb.contDiffAt] | |
| rfl | |
| private lemma annulus_comparison {n : β} {w : Space n β β} | |
| (hw : ContDiff β 2 w) (hw0 : β x, 0 β€ w x) | |
| (hineq : β x, Laplacian.laplacian w x β€ 2 * w x) | |
| {a r Ξ΅ : β} (ha : 1 β€ a) (hr : 0 < r) (hΞ΅ : 0 β€ Ξ΅) | |
| (hscale : 2 * (n : β) + 2 β€ a * r ^ 2) (y : Space n) | |
| (hinner : β x, βx - yβ = r / 2 β Ξ΅ β€ w x) : | |
| β x, r / 2 β€ βx - yβ β βx - yβ β€ r β Ξ΅ * barrier a r y x β€ w x := by | |
| let K : Set (Space n) := {x | r / 2 β€ βx - yβ β§ βx - yβ β€ r} | |
| have hn : Continuous (fun x : Space n => βx - yβ) := | |
| (continuous_id.sub continuous_const).norm | |
| have hclosed : IsClosed K := | |
| (isClosed_le continuous_const hn).inter (isClosed_le hn continuous_const) | |
| have hK : IsCompact K := (isCompact_closedBall y r).of_isClosed_subset hclosed (by | |
| intro x hx | |
| simpa only [Metric.mem_closedBall, dist_eq_norm] using hx.2) | |
| have hF : ContDiff β 2 (fun x => w x - Ξ΅ * barrier a r y x) := | |
| hw.sub (contDiff_const.mul (barrier_contDiff a r y)) | |
| have hboundary : β x β K, x β interior K β 0 β€ w x - Ξ΅ * barrier a r y x := by | |
| intro x hx hxout | |
| by_cases hilow : βx - yβ = r / 2 | |
| Β· have hb := mul_le_mul_of_nonneg_left (barrier_le_one (le_trans (by norm_num) ha) r y x) hΞ΅ | |
| have hi := hinner x hilow | |
| linarith | |
| by_cases hihigh : βx - yβ = r | |
| Β· simpa [barrier, gaussian, hihigh] using hw0 x | |
| exfalso | |
| apply hxout | |
| rw [mem_interior_iff_mem_nhds] | |
| have ho : IsOpen {z : Space n | r / 2 < βz - yβ β§ βz - yβ < r} := | |
| (isOpen_lt continuous_const hn).inter (isOpen_lt hn continuous_const) | |
| have hxstrict : x β {z : Space n | r / 2 < βz - yβ β§ βz - yβ < r} := | |
| β¨lt_of_le_of_ne hx.1 (Ne.symm hilow), lt_of_le_of_ne hx.2 hihighβ© | |
| exact Filter.mem_of_superset (ho.mem_nhds hxstrict) (fun z hz => β¨hz.1.le, hz.2.leβ©) | |
| have hFineq : β x β interior K, | |
| Laplacian.laplacian (fun x => w x - Ξ΅ * barrier a r y x) x β€ | |
| 2 * (w x - Ξ΅ * barrier a r y x) := by | |
| intro x hx | |
| have hxb : x β K := interior_subset hx | |
| rw [laplacian_sub_const_mul hw (barrier_contDiff a r y)] | |
| have h1 := hineq x | |
| have h2 := mul_le_mul_of_nonneg_left (barrier_subsolution ha hr hscale y x hxb.1) hΞ΅ | |
| linarith | |
| have H := compact_minimum_principle hF hK hboundary hFineq | |
| intro x hxlo hxhi | |
| have hh := H x β¨hxlo, hxhiβ© | |
| linarith | |
| private lemma fderiv_barrier {n : β} (a r : β) (y x e : Space n) : | |
| fderiv β (barrier a r y) x e = | |
| gaussian a y x * (-2 * a * inner β (x - y) e) := by | |
| unfold barrier | |
| rw [fderiv_fun_sub ((gaussian_contDiff a y).differentiable (by norm_num) x) | |
| (differentiableAt_const _)] | |
| simpa using fderiv_gaussian a y x e | |
| private lemma nonneg_right_derivative {f : β β β} {d : β} | |
| (hd : HasDerivAt f d 0) (h0 : f 0 = 0) | |
| (hpos : βαΆ t in π[>] (0 : β), 0 β€ f t) : 0 β€ d := by | |
| apply ge_of_tendsto hd.tendsto_slope_zero_right | |
| filter_upwards [self_mem_nhdsWithin, hpos] with t ht hp | |
| simpa [h0] using mul_nonneg (inv_nonneg.mpr (le_of_lt ht)) hp | |
| private lemma no_tangent_zero {n : β} {w : Space n β β} | |
| (hw : ContDiff β 2 w) (hw0 : β x, 0 β€ w x) | |
| (hineq : β x, Laplacian.laplacian w x β€ 2 * w x) | |
| {r : β} (hr : 0 < r) (y z : Space n) (hz : βz - yβ = r) | |
| (hwz : w z = 0) (hball : β x, βx - yβ < r β 0 < w x) : False := by | |
| obtain β¨p, hp, hpminβ© := (isCompact_closedBall y (r / 2)).exists_isMinOn | |
| β¨y, by simp only [Metric.mem_closedBall, dist_self]; positivityβ© hw.continuous.continuousOn | |
| have hppos : 0 < w p := hball p (by | |
| have hnorm : βp - yβ β€ r / 2 := by simpa [Metric.mem_closedBall, dist_eq_norm] using hp | |
| linarith) | |
| let a : β := 1 + (2 * (n : β) + 2) / r ^ 2 | |
| have hr2 : 0 < r ^ 2 := sq_pos_of_pos hr | |
| have ha : 1 β€ a := by | |
| have hq : 0 β€ (2 * (n : β) + 2) / r ^ 2 := by positivity | |
| dsimp [a] | |
| linarith | |
| have hscale : 2 * (n : β) + 2 β€ a * r ^ 2 := by | |
| dsimp [a] | |
| field_simp | |
| nlinarith | |
| have hcomp := annulus_comparison hw hw0 hineq ha hr hppos.le hscale y | |
| (fun x hx => hpmin (by simp [Metric.mem_closedBall, dist_eq_norm, hx])) | |
| let F : Space n β β := fun x => w x - w p * barrier a r y x | |
| let e : Space n := y - z | |
| let f : β β β := fun t => F (z + t β’ e) | |
| have hF : ContDiff β 2 F := hw.sub (contDiff_const.mul (barrier_contDiff a r y)) | |
| have hdline : HasDerivAt (fun t : β => z + t β’ e) e 0 := by | |
| simpa using (hasDerivAt_const (0 : β) z).fun_add ((hasDerivAt_id (0 : β)).smul_const e) | |
| have hd : HasDerivAt f (fderiv β F z e) 0 := by | |
| simpa [f, Function.comp_def] using ((hF.differentiable (by norm_num) (z + (0 : β) β’ e)).hasFDerivAt.comp_hasDerivAt 0 hdline) | |
| have hf0 : f 0 = 0 := by simp [f, F, barrier, gaussian, hz, hwz] | |
| have hpos : βαΆ t in π[>] (0 : β), 0 β€ f t := by | |
| filter_upwards [self_mem_nhdsWithin, | |
| nhdsWithin_le_nhds (Iio_mem_nhds (show (0 : β) < 1 / 2 by norm_num))] with t ht ht2 | |
| change 0 < t at ht | |
| change t < 1 / 2 at ht2 | |
| have hnorm : βz + t β’ e - yβ = (1 - t) * r := by | |
| have heq : z + t β’ e - y = (1 - t) β’ (z - y) := by dsimp [e]; module | |
| rw [heq, norm_smul, Real.norm_eq_abs, abs_of_pos (by linarith : 0 < 1 - t), hz] | |
| have hlow : r / 2 β€ βz + t β’ e - yβ := by rw [hnorm]; nlinarith | |
| have hhigh : βz + t β’ e - yβ β€ r := by rw [hnorm]; nlinarith | |
| have hh := hcomp (z + t β’ e) hlow hhigh | |
| dsimp [f, F] | |
| linarith | |
| have hnonneg := nonneg_right_derivative hd hf0 hpos | |
| have hmin : IsLocalMin w z := Filter.Eventually.of_forall (fun x => by simpa [hwz] using hw0 x) | |
| have hwder := hmin.fderiv_eq_zero | |
| have hi : inner β (z - y) e = -r ^ 2 := by | |
| have heq : e = -(z - y) := by dsimp [e]; abel | |
| rw [heq, inner_neg_right, real_inner_self_eq_norm_sq, hz] | |
| have hcalc : fderiv β F z e = | |
| -(w p * gaussian a y z * (2 * a * r ^ 2)) := by | |
| dsimp only [F] | |
| rw [fderiv_fun_sub (hw.differentiable (by norm_num) z) | |
| (((barrier_contDiff a r y).differentiable (by norm_num)).const_mul _ z)] | |
| simp only [sub_apply, hwder, zero_apply] | |
| rw [fderiv_const_mul ((barrier_contDiff a r y).differentiable (by norm_num) z)] | |
| simp only [smul_apply, smul_eq_mul] | |
| rw [fderiv_barrier, hi] | |
| ring | |
| have hnegative : fderiv β F z e < 0 := by | |
| rw [hcalc] | |
| have hg : 0 < gaussian a y z := Real.exp_pos _ | |
| have hap : 0 < a := lt_of_lt_of_le (by norm_num) ha | |
| exact neg_neg_of_pos (mul_pos (mul_pos hppos hg) (mul_pos (mul_pos (by norm_num) hap) hr2)) | |
| exact not_le_of_gt hnegative hnonneg | |
| lemma nonnegative_supersolution_eq_zero {n : β} {w : Space n β β} | |
| (hw : ContDiff β 2 w) (hw0 : β x, 0 β€ w x) | |
| (hineq : β x, Laplacian.laplacian w x β€ 2 * w x) | |
| {z : Space n} (hwz : w z = 0) : β x, w x = 0 := by | |
| intro y | |
| by_contra hy | |
| have hypos : 0 < w y := lt_of_le_of_ne (hw0 y) (Ne.symm hy) | |
| let Z : Set (Space n) := {x | w x = 0} | |
| have hZ : IsClosed Z := isClosed_eq hw.continuous continuous_const | |
| obtain β¨p, hp, hdistβ© := hZ.exists_infDist_eq_dist β¨z, hwzβ© y | |
| have hne : y β p := by | |
| intro heq | |
| have hpzero : w p = 0 := hp | |
| rw [heq, hpzero] at hypos | |
| exact lt_irrefl _ hypos | |
| have hr : 0 < dist y p := dist_pos.mpr hne | |
| have hball : β x, βx - yβ < dist y p β 0 < w x := by | |
| intro x hx | |
| by_contra hnot | |
| have hwx : w x = 0 := le_antisymm (le_of_not_gt hnot) (hw0 x) | |
| have hd := Metric.infDist_le_dist_of_mem (x := y) (show x β Z from hwx) | |
| rw [hdist] at hd | |
| have he : dist y x = βx - yβ := by rw [dist_comm, dist_eq_norm] | |
| rw [he] at hd | |
| exact not_le_of_gt hx hd | |
| exact no_tangent_zero hw hw0 hineq hr y p (by rw [β dist_eq_norm, dist_comm]) hp hball | |
| end PositiveMaximum | |
| end | |
| end OAI | |