import Mathlib import OAI.Geometry.CubicTorus.Estimates.DifferenceStep namespace OAI section section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus lemma differential_integral_restrict {ψ : Plane → ℝ} {S : Set Plane} (hs : tsupport ψ⊆S) (F : Plane → Plane) : (∫ y in S, fderiv ℝ ψ y (F y))=(∫ y, fderiv ℝ ψ y (F y)) := by apply setIntegral_eq_integral_of_forall_compl_eq_zero intro y hy rw [fderiv_of_notMem_tsupport ℝ (fun hy' ↦ hy (hs hy')),zero_apply] theorem WeakCMCGraph.linearized_equation {g : Plane → ℝ} {K : ℝ≥0} (hg : LipschitzWith K g) (hK : (K:ℝ)≤1) {H R : ℝ} (hR : 0] 0) := (differenceStep_tendsto hδ).comp hφ.tendsto_atTop have hQ (i : ℕ) : (Q i : Plane → Plane)=ᵐ[volume.restrict (Metric.ball (0 : Plane) (R/4))] vectorDifference G v (t i) := (vectorDifference_memLp hGc hGb (R/4) (t i) v).coeFn_toLp have hweak : ∀ V : Lp Plane 2 (volume.restrict (Metric.ball (0 : Plane) (R/4))), Tendsto (fun i ↦ ⟪Q i,V⟫) atTop (𝓝 ⟪u,V⟫) := hw have hty (i : ℕ) : ‖t i • v‖≤t i := by rw [norm_smul,Real.norm_eq_abs,abs_of_pos (ht i).1] exact mul_le_of_le_one_right (ht i).1.le hv have hGy (y : Plane) (hy : y∈Metric.ball (0 : Plane) (R/4)) : G y=gradient g y := by apply hGeq have hh : ‖y‖] 0) := (differenceStep_tendsto hδ).comp hφ.tendsto_atTop have hQ (i : ℕ) : (Q i : Plane → Plane)=ᵐ[volume.restrict (Metric.ball (0 : Plane) (R/4))] vectorDifference G v (t i) := (vectorDifference_memLp hGc hGb (R/4) (t i) v).coeFn_toLp have hweak : ∀ V : Lp Plane 2 (volume.restrict (Metric.ball (0 : Plane) (R/4))), Tendsto (fun i ↦ ⟪Q i,V⟫) atTop (𝓝 ⟪u,V⟫) := hwk have hty (i : ℕ) : ‖t i • v‖≤t i := by rw [norm_smul,Real.norm_eq_abs,abs_of_pos (ht i).1] exact mul_le_of_le_one_right (ht i).1.le hv have hGy (y : Plane) (hy : y∈Metric.ball (0 : Plane) (R/4)) : G y=gradient g y := by apply hGeq have hh : ‖y‖.mono_set Metric.ball_subset_closedBall rw [← integral_add hAi hSi] at he rw [← he] apply setIntegral_congr_fun measurableSet_ball intro y hy dsimp only rw [hGy y hy] simp only [map_sub] ring end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus lemma C1_gradient_continuous {f : Plane → ℝ} (hf : ContDiff ℝ 1 f) : Continuous (gradient f) := (InnerProductSpace.toDual ℝ Plane).symm.continuous.comp (hf.continuous_fderiv (by simp)) lemma plane_gradient_support {f : Plane → ℝ} : tsupport (gradient f)⊆tsupport f := by exact (tsupport_comp_subset (g := (InnerProductSpace.toDual ℝ Plane).symm) (by simp) _).trans (tsupport_fderiv_subset ℝ) lemma plane_gradient_compact {f : Plane → ℝ} (hf : HasCompactSupport f) : HasCompactSupport (gradient f) := (hf.fderiv ℝ).comp_left (map_zero (InnerProductSpace.toDual ℝ Plane).symm) lemma compact_C1_gradient_memLp {f : Plane → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : MemLp (gradient f) 2 := (C1_gradient_continuous hf).memLp_of_hasCompactSupport (plane_gradient_compact hc) lemma compact_test_poincare (R : ℝ) : ∃ C : ℝ, 0≤C ∧ ∀ f : Plane → ℝ, ∀ hf : ContDiff ℝ 1 f, ∀ hc : HasCompactSupport f, tsupport f⊆Metric.ball 0 R → ‖(hf.continuous.memLp_of_hasCompactSupport hc : MemLp f 2).toLp f‖≤ C*‖(compact_C1_gradient_memLp hf hc).toLp (gradient f)‖ := by let A : ℝ≥0 := eLpNormLESNormFDerivOfEqInnerConst (volume : Measure Plane) 1 let B : ℝ≥0∞ := volume (Metric.ball (0 : Plane) R)^(1/2:ℝ) have hB : B≠⊤ := ENNReal.rpow_ne_top_of_nonneg (by norm_num) measure_ball_lt_top.ne refine ⟨(A:ℝ)*B.toReal,by positivity,?_⟩ intro f hf hc hs have hd := hf.continuous_fderiv (by simp : (1 : WithTop ℕ∞)≠0) have hm : MemLp (fderiv ℝ f) 2 := hd.memLp_of_hasCompactSupport (hc.fderiv ℝ) have hsub : Function.support (fderiv ℝ f)⊆Metric.ball 0 R := (subset_tsupport (fderiv ℝ f)).trans ((tsupport_fderiv_subset ℝ).trans hs) have hgns := eLpNorm_le_eLpNorm_fderiv_of_eq_inner (volume : Measure Plane) hf hc (p := 1) (p' := 2) (by norm_num) (by simp [Plane]) (by norm_num [Plane]) have hcomp := eLpNorm_le_eLpNorm_mul_rpow_measure_univ (μ := volume.restrict (Metric.ball 0 R)) (f := fderiv ℝ f) (p := 1) (q := 2) (by norm_num) hd.aestronglyMeasurable.restrict rw [eLpNorm_restrict_eq_of_support_subset (μ := volume) (p := 1) (f := fderiv ℝ f) hd.aestronglyMeasurable hsub, eLpNorm_restrict_eq_of_support_subset (μ := volume) (p := 2) (f := fderiv ℝ f) hd.aestronglyMeasurable hsub,Measure.restrict_apply_univ] at hcomp norm_num only [ENNReal.toReal_one,ENNReal.toReal_ofNat,div_one] at hcomp have hcomp' : eLpNorm (fderiv ℝ f) 1 volume≤eLpNorm (fderiv ℝ f) 2 volume*B := by exact hcomp have he : eLpNorm f 2 volume ≤ (A:ℝ≥0∞)*(eLpNorm (fderiv ℝ f) 2 volume*B) := hgns.trans (mul_le_mul_right hcomp' _) have hgn : eLpNorm (gradient f) 2 volume=eLpNorm (fderiv ℝ f) 2 volume := eLpNorm_congr_norm_ae (C1_gradient_continuous hf).aestronglyMeasurable hd.aestronglyMeasurable (ae_of_all _ (plane_gradient_norm f)) rw [Lp.norm_toLp,Lp.norm_toLp,hgn] have hh := ENNReal.toReal_mono (ENNReal.mul_ne_top ENNReal.coe_ne_top (ENNReal.mul_ne_top hm.ne hB)) he simpa only [ENNReal.toReal_mul,ENNReal.coe_toReal,mul_assoc,mul_comm,mul_left_comm] using hh end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus def PlaneWeakGradient (S : Set Plane) (u : Plane → ℝ) (G : Plane → Plane) : Prop := ∀ (v : Plane) (ψ : Plane → ℝ), ContDiff ℝ (⊤ : ℕ∞) ψ → HasCompactSupport ψ → tsupport ψ⊆S → (∫ y, ⟪G y,v⟫*ψ y)= -(∫ y,u y*fderiv ℝ ψ y v) lemma PlaneWeakGradient.congr {S : Set Plane} {u u' : Plane → ℝ} {G G' : Plane → Plane} (h : PlaneWeakGradient S u G) (hu : u'=ᵐ[volume] u) (hG : G'=ᵐ[volume] G) : PlaneWeakGradient S u' G' := by intro v ψ hψ hc hs have ha : (∫ y,⟪G' y,v⟫*ψ y)=(∫ y,⟪G y,v⟫*ψ y) := integral_congr_ae (hG.mono fun _ he ↦ by dsimp only; rw [he]) have hb : (∫ y,u' y*fderiv ℝ ψ y v)=(∫ y,u y*fderiv ℝ ψ y v) := integral_congr_ae (hu.mono fun _ he ↦ by dsimp only; rw [he]) rw [ha,hb] exact h v ψ hψ hc hs lemma compact_C1_weak_gradient {f : Plane → ℝ} (hf : ContDiff ℝ 1 f) (_hc : HasCompactSupport f) (S : Set Plane) : PlaneWeakGradient S f (gradient f) := by intro v ψ hψ hc _hs have hi₁ : Integrable (fun y ↦ fderiv ℝ f y v*ψ y) := (((hf.continuous_fderiv (by simp)).clm_apply continuous_const).mul hψ.continuous).integrable_of_hasCompactSupport hc.mul_left have hi₂ : Integrable (fun y ↦ f y*fderiv ℝ ψ y v) := (hf.continuous.mul ((hψ.continuous_fderiv (by simp)).clm_apply continuous_const)).integrable_of_hasCompactSupport (hc.fderiv_apply ℝ v).mul_left have hi₃ : Integrable (fun y ↦ f y*ψ y) := (hf.continuous.mul hψ.continuous).integrable_of_hasCompactSupport hc.mul_left have hh := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hi₁ hi₂ hi₃ (fun _ _ ↦ (hf.differentiable (by simp)).differentiableAt) (fun _ _ ↦ (hψ.differentiable (by simp)).differentiableAt) simpa only [inner_gradient_left,neg_neg] using congrArg Neg.neg hh.symm lemma L2_pair_scalar_test {u : Lp ℝ 2 (volume : Measure Plane)} {φ : Plane → ℝ} (hφ : MemLp φ 2 volume) : ⟪u,hφ.toLp φ⟫=(∫ y,u y*φ y) := by rw [L2.inner_def] apply integral_congr_ae filter_upwards [hφ.coeFn_toLp] with y hy simp only [hy,RCLike.inner_apply,conj_trivial] ring lemma L2_pair_vector_test {G : Lp Plane 2 (volume : Measure Plane)} {φ : Plane → ℝ} (hφ : Continuous φ) (hc : HasCompactSupport φ) (v : Plane) : let hm : MemLp (fun y ↦ φ y • v) 2 volume := (hφ.smul continuous_const).memLp_of_hasCompactSupport hc.smul_right ⟪G,hm.toLp (fun y ↦ φ y • v)⟫=(∫ y,⟪G y,v⟫*φ y) := by dsimp only rw [L2.inner_def] apply integral_congr_ae filter_upwards [((hφ.smul continuous_const).memLp_of_hasCompactSupport hc.smul_right : MemLp (fun y ↦ φ y • v) 2 volume).coeFn_toLp] with y hy simp only [Pi.smul_def'] at hy rw [hy,inner_smul_right,mul_comm] lemma PlaneWeakGradient.L2_limit {S : Set Plane} {u : ℕ → Lp ℝ 2 (volume : Measure Plane)} {G : ℕ → Lp Plane 2 (volume : Measure Plane)} {u₀ : Lp ℝ 2 (volume : Measure Plane)} {G₀ : Lp Plane 2 (volume : Measure Plane)} (hu : Tendsto u atTop (𝓝 u₀)) (hG : Tendsto G atTop (𝓝 G₀)) (hweak : ∀ i,PlaneWeakGradient S (u i) (G i)) : PlaneWeakGradient S u₀ G₀ := by intro v ψ hψ hc hs let a : Plane → Plane := fun y ↦ ψ y • v have ha : MemLp a 2 volume := (hψ.continuous.smul continuous_const).memLp_of_hasCompactSupport hc.smul_right let A := ha.toLp a let b : Plane → ℝ := fun y ↦ fderiv ℝ ψ y v have hb : MemLp b 2 volume := ((hψ.continuous_fderiv (by simp)).clm_apply continuous_const).memLp_of_hasCompactSupport (hc.fderiv_apply ℝ v) let B := hb.toLp b have he (i : ℕ) : ⟪G i,A⟫= -⟪u i,B⟫ := by rw [L2_pair_vector_test hψ.continuous hc v,L2_pair_scalar_test hb] exact hweak i v ψ hψ hc hs have hleft := hG.inner (𝕜 := ℝ) (tendsto_const_nhds (x := A)) have hright := (hu.inner (𝕜 := ℝ) (tendsto_const_nhds (x := B))).neg have hh := tendsto_nhds_unique (hleft.congr' (Eventually.of_forall he)) hright rw [L2_pair_vector_test hψ.continuous hc v,L2_pair_scalar_test hb] at hh exact hh end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus lemma continuous_local_scalar_product {f η : Plane → ℝ} {S : Set Plane} (hS : IsOpen S) (hf : ContinuousOn f S) (hη : Continuous η) (hs : tsupport η⊆S) : Continuous (fun y ↦ f y*η y) := by rw [continuous_iff_continuousAt] intro y by_cases hy : y∈tsupport η · exact ((hf y (hs hy)).continuousAt (hS.mem_nhds (hs hy))).mul hη.continuousAt · apply (continuousAt_const (y := (0:ℝ))).congr_of_eventuallyEq filter_upwards [notMem_tsupport_iff_eventuallyEq.mp hy] with z hz simp [hz] lemma C1_local_integration_by_parts {g ψ : Plane → ℝ} {S : Set Plane} (hS : IsOpen S) (hg : Continuous g) (hgc : ContDiffOn ℝ 1 g S) (hψ : ContDiff ℝ 1 ψ) (hc : HasCompactSupport ψ) (hs : tsupport ψ⊆S) (v : Plane) : (∫ y, fderiv ℝ g y v*ψ y)= -(∫ y,g y*fderiv ℝ ψ y v) := by have hdf : ContinuousOn (fun y ↦ fderiv ℝ g y v) S := (hgc.continuousOn_fderiv_of_isOpen hS (by simp)).clm_apply continuousOn_const have hi₁ : Integrable (fun y ↦ fderiv ℝ g y v*ψ y) := (continuous_local_scalar_product hS hdf hψ.continuous hs).integrable_of_hasCompactSupport hc.mul_left have hi₂ : Integrable (fun y ↦ g y*fderiv ℝ ψ y v) := (hg.mul ((hψ.continuous_fderiv (by simp)).clm_apply continuous_const)).integrable_of_hasCompactSupport (hc.fderiv_apply ℝ v).mul_left have hi₃ : Integrable (fun y ↦ g y*ψ y) := (hg.mul hψ.continuous).integrable_of_hasCompactSupport hc.mul_left have hh := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hi₁ hi₂ hi₃ (fun y hy ↦ ((hgc y (hs hy)).contDiffAt (hS.mem_nhds (hs hy))).differentiableAt (by simp)) (fun _ _ ↦ (hψ.differentiable (by simp)).differentiableAt) simpa only [neg_neg] using congrArg Neg.neg hh.symm lemma C1_mixed_test_identity {g ψ : Plane → ℝ} {S : Set Plane} (hS : IsOpen S) (hg : Continuous g) (hgc : ContDiffOn ℝ 1 g S) (hψ : ContDiff ℝ (⊤ : ℕ∞) ψ) (hc : HasCompactSupport ψ) (hs : tsupport ψ⊆S) (v w : Plane) : (∫ y, ⟪gradient g y,w⟫*fderiv ℝ ψ y v)= (∫ y, ⟪gradient g y,v⟫*fderiv ℝ ψ y w) := by have hv : ContDiff ℝ (⊤ : ℕ∞) (fun y ↦ fderiv ℝ ψ y v) := (hψ.fderiv_right (by simp)).clm_apply contDiff_const have hw : ContDiff ℝ (⊤ : ℕ∞) (fun y ↦ fderiv ℝ ψ y w) := (hψ.fderiv_right (by simp)).clm_apply contDiff_const simp only [inner_gradient_left] rw [C1_local_integration_by_parts hS hg hgc (hv.of_le (by simp)) (hc.fderiv_apply ℝ v) ((tsupport_fderiv_apply_subset (f := ψ) ℝ v).trans hs) w, C1_local_integration_by_parts hS hg hgc (hw.of_le (by simp)) (hc.fderiv_apply ℝ w) ((tsupport_fderiv_apply_subset (f := ψ) ℝ w).trans hs) v] congr 1 apply integral_congr_ae filter_upwards [] with y congr 1 rw [fderiv_fderiv_apply hψ,fderiv_fderiv_apply hψ] exact (hψ.contDiffAt.isSymmSndFDerivAt (by simp only [minSmoothness_of_isRCLikeNormedField]; exact WithTop.coe_le_coe.mpr le_top)) w v end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus lemma indicator_inner_test_integral {S : Set Plane} (hS : MeasurableSet S) (U : Plane → Plane) (v : Plane) (ψ : Plane → ℝ) : (∫ y,⟪S.indicator U y,v⟫*ψ y)=(∫ y in S,⟪U y,v⟫*ψ y) := by rw [← integral_indicator hS] apply integral_congr_ae filter_upwards [] with y by_cases hy : y∈S <;> simp [hy] lemma indicator_differential_integral {S : Set Plane} (hS : MeasurableSet S) (U : Plane → Plane) (A : Plane → Plane →L[ℝ] Plane) (ψ : Plane → ℝ) : (∫ y,fderiv ℝ ψ y (A y (S.indicator U y)))= (∫ y in S,fderiv ℝ ψ y (A y (U y))) := by rw [← integral_indicator hS] apply integral_congr_ae filter_upwards [] with y by_cases hy : y∈S <;> simp [hy] theorem WeakCMCGraph.scalar_linearized_equation {g : Plane → ℝ} {K : ℝ≥0} (hg : LipschitzWith K g) (hK : (K:ℝ)≤1) {H R : ℝ} (hR : 0