Download data/lean/OAI/Analysis/AllenCahn/PoissonMaximum.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 15.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/AllenCahn/PoissonMaximum.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/AllenCahn/PoissonMaximum.lean
-
curl -L -o PoissonMaximum.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/AllenCahn/PoissonMaximum.lean
15.7 kB
| import Mathlib | |
| namespace OAI | |
| noncomputable section | |
| namespace PoissonSupport.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 PoissonSupport.DeGiorgi | |
| end | |
| noncomputable section | |
| namespace PoissonSupport.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 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_comp_isometry {n : โ} {f : Space n โ โ} | |
| (hf : ContDiff โ 2 f) (J : Space n โโแตข[โ] Space n) (x : Space n) : | |
| Laplacian.laplacian (fun z => f (J z)) x = Laplacian.laplacian f (J x) := by | |
| rw [InnerProductSpace.laplacian_eq_iteratedFDeriv_orthonormalBasis _ (basis n), | |
| InnerProductSpace.laplacian_eq_iteratedFDeriv_orthonormalBasis _ ((basis n).map J)] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| change iteratedFDeriv โ 2 (f โ J.toContinuousLinearMap) x _ = _ | |
| rw [J.toContinuousLinearMap.iteratedFDeriv_comp_right hf x (by norm_num)] | |
| simp only [ContinuousMultilinearMap.compContinuousLinearMap_apply, | |
| OrthonormalBasis.map_apply] | |
| congr 1 | |
| ext j | |
| fin_cases j <;> simp | |
| def reflect {n : โ} (e : Space n) : Space n โโแตข[โ] Space n := | |
| (Submodule.span โ {e})แฎ.reflection | |
| lemma reflect_apply {n : โ} {e : Space n} (he : โeโ = 1) (z : Space n) : | |
| reflect e z = z - (2 * inner โ e z) โข e := by | |
| simp only [reflect, Submodule.reflection_orthogonal_apply, | |
| Submodule.reflection_singleton_apply, he] | |
| norm_num only [RCLike.ofReal_real_eq_id, id_eq, one_pow, div_one] | |
| rw [neg_sub, โ smul_assoc] | |
| simp only [two_smul, two_mul] | |
| def poissonPenalty (A t : โ) : โ := A * (1 - (max (1 - t) 0) ^ 2) | |
| lemma poissonPenalty_of_le (A : โ) {t : โ} (ht : t โค 1) : | |
| poissonPenalty A t = A * (2 * t - t ^ 2) := by | |
| rw [poissonPenalty, max_eq_left (by linarith)] | |
| ring | |
| lemma poissonPenalty_of_ge (A : โ) {t : โ} (ht : 1 โค t) : | |
| poissonPenalty A t = A := by | |
| simp [poissonPenalty, max_eq_right (show 1 - t โค 0 by linarith)] | |
| lemma poissonPenalty_nonneg {A t : โ} (hA : 0 โค A) (ht : 0 โค t) : | |
| 0 โค poissonPenalty A t := by | |
| by_cases h : t โค 1 | |
| ยท rw [poissonPenalty_of_le A h] | |
| apply mul_nonneg hA | |
| nlinarith | |
| ยท rw [poissonPenalty_of_ge A (le_of_not_ge h)] | |
| exact hA | |
| lemma poissonPenalty_le_linear {A t : โ} (hA : 0 โค A) (ht : 0 โค t) : | |
| poissonPenalty A t โค 2 * A * t := by | |
| by_cases h : t โค 1 | |
| ยท rw [poissonPenalty_of_le A h] | |
| nlinarith [mul_nonneg hA (sq_nonneg t)] | |
| ยท rw [poissonPenalty_of_ge A (le_of_not_ge h)] | |
| nlinarith | |
| lemma poisson_maximum {n : โ} {f : Space n โ โ} (hf : Continuous f) | |
| {M A ฮต : โ} (hM : 0 โค M) (hbound : โ x, |f x| โค M) | |
| (hA : 0 โค A) (hฮต : 0 < ฮต) : | |
| โ x y : Space n, โ 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) := by | |
| let H : Space n ร Space n โ โ := fun z => | |
| f z.2 - f z.1 - poissonPenalty A โz.2 - z.1โ - ฮต * (โz.1โ ^ 2 + โz.2โ ^ 2) | |
| have hc : Continuous H := by dsimp [H, poissonPenalty]; 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 := poissonPenalty_nonneg hA (norm_nonneg (z.2 - z.1)) | |
| dsimp [H] | |
| simp only [sub_self, norm_zero, poissonPenalty, sub_zero, max_eq_left zero_le_one, | |
| one_pow, mul_zero, zero_pow two_ne_zero, add_zero] | |
| rw [hR2, heq] at hh | |
| dsimp [poissonPenalty] at hcost | |
| linarith | |
| obtain โจโจx, yโฉ, hmaxโฉ := hc.exists_forall_ge' (0, 0) hevent | |
| exact โจx, y, fun a b => hmax (a, b)โฉ | |
| lemma coordDeriv_affine {n : โ} (a : Space n) (c : โ) (i : Fin n) (x : Space n) : | |
| coordDeriv (fun z => c + inner โ a z) i x = inner โ a (basis n i) := by | |
| have hd : HasFDerivAt (fun z => c + inner โ a z) (innerSL โ a) x := | |
| (innerSL โ a).hasFDerivAt.const_add c | |
| simp [coordDeriv, hd.fderiv] | |
| lemma laplacian_affine {n : โ} (a : Space n) (c : โ) (x : Space n) : | |
| Laplacian.laplacian (fun z => c + inner โ a z) x = 0 := by | |
| have hc : ContDiff โ 2 (fun z : Space n => c + inner โ a z) := contDiff_const.add ((innerSL โ a).contDiff) | |
| rw [laplacian_eq_sum_coordDeriv hc] | |
| have he (i : Fin n) : coordDeriv (fun z : Space n => c + inner โ a z) i = | |
| fun _ => inner โ a (basis n i) := funext (coordDeriv_affine a c i) | |
| simp_rw [he] | |
| simp [coordDeriv] | |
| lemma laplacian_affine_sq {n : โ} (a : Space n) (c : โ) (x : Space n) : | |
| Laplacian.laplacian (fun z => (c + inner โ a z) ^ 2) x = 2 * โaโ ^ 2 := by | |
| have hc : ContDiff โ 2 (fun z : Space n => (c + inner โ a z) ^ 2) := | |
| (contDiff_const.add ((innerSL โ a).contDiff)).pow 2 | |
| rw [laplacian_eq_sum_coordDeriv hc] | |
| have hfirst (i : Fin n) : coordDeriv (fun z : Space n => (c + inner โ a z) ^ 2) i = | |
| fun z => 2 * (c + inner โ a z) * inner โ a (basis n i) := by | |
| funext z | |
| have hd := ((innerSL โ a).hasFDerivAt (x := z)).const_add c | |
| have hd2 := hd.pow 2 | |
| dsimp only [coordDeriv] | |
| change (fderiv โ (fun z => (c + (innerSL โ a) z) ^ 2) z) _ = _ | |
| rw [hd2.fderiv] | |
| simp only [smul_apply, smul_eq_mul, Nat.cast_ofNat, Nat.reduceSub, pow_one, innerSL_apply_apply, nsmul_eq_mul] | |
| simp_rw [hfirst] | |
| have hsecond (i : Fin n) : coordDeriv | |
| (fun z => 2 * (c + inner โ a z) * inner โ a (basis n i)) i x = | |
| 2 * (inner โ a (basis n i)) ^ 2 := by | |
| have hd := ((((innerSL โ a).hasFDerivAt (x := x)).const_add c).const_mul 2).mul_const | |
| (inner โ a (basis n i)) | |
| dsimp only [coordDeriv] | |
| change (fderiv โ (fun z => 2 * (c + (innerSL โ a) z) * inner โ a ((basis n) i)) x) _ = _ | |
| rw [hd.fderiv] | |
| simp [pow_two, mul_left_comm] | |
| simp_rw [hsecond] | |
| rw [โ Finset.mul_sum] | |
| congr 1 | |
| have hb := (basis n).sum_inner_mul_inner a a | |
| simpa only [real_inner_comm, โ pow_two, real_inner_self_eq_norm_sq] using hb | |
| end PoissonSupport.DeGiorgi | |
| end | |
| end OAI | |