import Mathlib import OAI.Geometry.CAT0Fillings.Gradient.ClosedLinear import OAI.Geometry.CAT0Fillings.Gradient.Multiplier import OAI.Geometry.CAT0Fillings.Calculus.ClosedChain namespace OAI section open Set Filter MeasureTheory open scoped Topology ENNReal NNReal namespace CAT0Fillings.ChartGeometry variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [CompactSpace X] [Nonempty X] {k : β„•} {T : Functional X (k+1)} {hT : IsMetricCurrent T} (q : ChartGeometry hT) lemma sobolev_tendsto {P : β„• β†’ q.Sobolev} {Q : q.Sobolev} (hv : Tendsto (fun j => q.inclusion (P j)) atTop (𝓝 (q.inclusion Q))) (hg : Tendsto (fun j => q.closedGradient (P j)) atTop (𝓝 (q.closedGradient Q))) : Tendsto P atTop (𝓝 Q) := by apply tendsto_subtype_rng.mpr exact ((WithLp.prodContinuousLinearEquiv 2 ℝ (Lp ℝ 2 (MassMeasure.currentMassMeasure hT)) (Lp (Euc (k+1)) 2 q.atlasMeasure)).symm.continuous.tendsto (q.inclusion Q,q.closedGradient Q)).comp (hv.prodMk_nhds hg) lemma closed_chain_in_closed {F F' : ℝ β†’ ℝ} {J : ℝβ‰₯0} (hF : LipschitzWith J F) (hdF : βˆ€ t, HasDerivAt F (F' t) t) (hcF : Continuous F') {C : ℝ} (hC : 0 ≀ C) (hbF : βˆ€ t, |F' t| ≀ C) (P : q.Sobolev) {S : Set q.Sobolev} (hS : IsClosed S) (hmem : βˆ€ (u : X β†’ ℝ) (K : ℝβ‰₯0) (hu : LipschitzWith K u), q.lipSobolev (hF.comp hu) ∈ S) : βˆƒ Q : q.Sobolev, Q ∈ S ∧ (q.inclusion Q : X β†’ ℝ) =ᡐ[MassMeasure.currentMassMeasure hT] (fun x => F ((q.inclusion P) x)) ∧ (q.closedGradient Q : (β„• Γ— Euc (k+1)) β†’ Euc (k+1)) =ᡐ[q.atlasMeasure] (fun w => F' ((q.inclusion P) (q.atlasParam w)) β€’ (q.closedGradient P) w) := by obtain ⟨u,K,hu,hl⟩ := q.exists_lipschitz_approximants P have hv := (q.valueProjection.continuous.tendsto (P : q.GraphAmbient)).comp hl have hg := (q.gradientProjection.continuous.tendsto (P : q.GraphAmbient)).comp hl change Tendsto (fun j => value (hu j)) atTop (𝓝 (q.inclusion P)) at hv change Tendsto (fun j => q.gradient (hu j)) atTop (𝓝 (q.closedGradient P)) at hg obtain ⟨s,hs,hae⟩ := (tendstoInMeasure_of_tendsto_Lp hv).exists_seq_tendsto_ae have hnames : βˆ€α΅ x βˆ‚MassMeasure.currentMassMeasure hT, βˆ€ j, (value (hT := hT) (hu (s j))) x = u (s j) x := by apply ae_all_iff.mpr intro j exact ((Foundations.boundedLip_of_lipschitz (hu (s j))).memLp 2).coeFn_toLp have hae' : βˆ€α΅ x βˆ‚MassMeasure.currentMassMeasure hT, Tendsto (fun j => u (s j) x) atTop (𝓝 ((q.inclusion P) x)) := by filter_upwards [hae,hnames] with x hx he simpa only [he] using hx let b (j : β„•) (w : β„• Γ— Euc (k+1)) := F' (u (s j) (q.atlasParam w)) let c (w : β„• Γ— Euc (k+1)) := F' ((q.inclusion P) (q.atlasParam w)) have hb (j : β„•) : AEStronglyMeasurable (b j) q.atlasMeasure := (hcF.measurable.comp ((hu (s j)).continuous.measurable.comp q.measurable_atlasParam)).aestronglyMeasurable have hc : AEStronglyMeasurable c q.atlasMeasure := hcF.comp_aestronglyMeasurable ((Lp.aestronglyMeasurable (q.inclusion P)).comp_measurePreserving q.atlas_preserving) have hbC (j : β„•) : βˆ€α΅ w βˆ‚q.atlasMeasure, |b j w| ≀ C := Eventually.of_forall fun point => hbF (u (s j) (q.atlasParam point)) have hcC : βˆ€α΅ w βˆ‚q.atlasMeasure, |c w| ≀ C := Eventually.of_forall fun point => hbF ((q.inclusion P) (q.atlasParam point)) have hbc : βˆ€α΅ w βˆ‚q.atlasMeasure, Tendsto (fun j => b j w) atTop (𝓝 (c w)) := by have ha : βˆ€α΅ w βˆ‚q.atlasMeasure, Tendsto (fun j => u (s j) (q.atlasParam w)) atTop (𝓝 ((q.inclusion P) (q.atlasParam w))) := by apply ae_of_ae_map (ΞΌ := q.atlasMeasure) (p := fun x => Tendsto (fun j => u (s j) x) atTop (𝓝 ((q.inclusion P) x))) q.measurable_atlasParam.aemeasurable rwa [q.map_atlasMeasure] filter_upwards [ha] with w hw exact (hcF.tendsto _).comp hw have hgl := ClosedCalculus.mulLp_tendsto hb hc hC hbC hcC hbc (hg.comp hs.tendsto_atTop) have he (j : β„•) : ClosedCalculus.mulLp (hb j) (hbC j) (q.gradient (hu (s j))) = q.gradient (hF.comp (hu (s j))) := by apply Lp.ext exact (ClosedCalculus.mulLp_ae (hb j) (hbC j) _).trans (q.gradient_chain_ae (hu (s j)) hF hdF).symm simp only [Function.comp_apply,he] at hgl have hvl := (q.continuous_composeValue hF).tendsto (q.inclusion P) |>.comp (hv.comp hs.tendsto_atTop) simp only [Function.comp_def,q.composeValue_value] at hvl obtain ⟨Q,hQ,hG⟩ := q.closedGradient_closed (q.composeValue hF (q.inclusion P)) (ClosedCalculus.mulLp hc hcC (q.closedGradient P)) (fun j => q.lipSobolev (hF.comp (hu (s j)))) hvl hgl refine ⟨Q,?_,?_,?_⟩ Β· apply hS.mem_of_tendsto (q.sobolev_tendsto (P := fun j => q.lipSobolev (hF.comp (hu (s j)))) (by simpa only [q.inclusion_lipSobolev,hQ] using hvl) (by simpa only [q.closedGradient_lipSobolev,hG] using hgl)) exact Eventually.of_forall fun j => hmem _ _ (hu (s j)) Β· rw [hQ] exact q.composeValue_ae hF (q.inclusion P) Β· rw [hG] exact ClosedCalculus.mulLp_ae hc hcC _ end CAT0Fillings.ChartGeometry end section open Set Filter MeasureTheory open scoped Topology ENNReal NNReal namespace CAT0Fillings.ChartGeometry variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [CompactSpace X] [Nonempty X] {k : β„•} {T : Functional X (k+1)} {hT : IsMetricCurrent T} (q : ChartGeometry hT) lemma closed_chain_uniform_in_closed {F D : ℝ β†’ ℝ} {J : ℝβ‰₯0} (hF : LipschitzWith J F) (hD : Measurable D) {C : ℝ} (hC : 0 ≀ C) (hbD : βˆ€ t, |D t| ≀ C) (Fj Dj : β„• β†’ ℝ β†’ ℝ) (K : β„• β†’ ℝβ‰₯0) (hFj : βˆ€ j, LipschitzWith (K j) (Fj j)) (hdj : βˆ€ j t, HasDerivAt (Fj j) (Dj j t) t) (hcj : βˆ€ j, Continuous (Dj j)) (hbj : βˆ€ j t, |Dj j t| ≀ C) (hdlim : βˆ€ t, Tendsto (fun j => Dj j t) atTop (𝓝 (D t))) (a : β„• β†’ ℝ) (ha : Tendsto a atTop (𝓝 0)) (he : βˆ€ j t, |Fj j t-F t| ≀ a j) (P : q.Sobolev) {S : Set q.Sobolev} (hclosed : IsClosed S) (hmem : βˆ€ j (u : X β†’ ℝ) (K : ℝβ‰₯0) (hu : LipschitzWith K u), q.lipSobolev ((hFj j).comp hu) ∈ S) : βˆƒ Q : q.Sobolev, Q ∈ S ∧ (q.inclusion Q : X β†’ ℝ) =ᡐ[MassMeasure.currentMassMeasure hT] (fun x => F ((q.inclusion P) x)) ∧ (q.closedGradient Q : (β„• Γ— Euc (k+1)) β†’ Euc (k+1)) =ᡐ[q.atlasMeasure] (fun w => D ((q.inclusion P) (q.atlasParam w)) β€’ (q.closedGradient P) w) := by choose Q hQS hQ hG using (fun j => q.closed_chain_in_closed (hFj j) (hdj j) (hcj j) hC (hbj j) P hclosed (hmem j)) let b (j : β„•) (w : β„• Γ— Euc (k+1)) := Dj j ((q.inclusion P) (q.atlasParam w)) let c (w : β„• Γ— Euc (k+1)) := D ((q.inclusion P) (q.atlasParam w)) have hpm := (Lp.aestronglyMeasurable (q.inclusion P)).comp_measurePreserving q.atlas_preserving have hb (j : β„•) : AEStronglyMeasurable (b j) q.atlasMeasure := (hcj j).comp_aestronglyMeasurable hpm have hc : AEStronglyMeasurable c q.atlasMeasure := (hD.comp_aemeasurable hpm.aemeasurable).aestronglyMeasurable have hbC (j : β„•) : βˆ€α΅ w βˆ‚q.atlasMeasure, |b j w| ≀ C := Eventually.of_forall fun _ => hbj j _ have hcC : βˆ€α΅ w βˆ‚q.atlasMeasure, |c w| ≀ C := Eventually.of_forall fun _ => hbD _ have hgl := ClosedCalculus.mulLp_tendsto hb hc hC hbC hcC (Eventually.of_forall fun point => hdlim ((q.inclusion P) (q.atlasParam point))) (tendsto_const_nhds (x := q.closedGradient P)) have heG (j : β„•) : ClosedCalculus.mulLp (hb j) (hbC j) (q.closedGradient P) = q.closedGradient (Q j) := by apply Lp.ext exact (ClosedCalculus.mulLp_ae (hb j) (hbC j) _).trans (hG j).symm simp only [heG] at hgl let V := q.composeValue hF (q.inclusion P) have hv : Tendsto (fun j => q.inclusion (Q j)) atTop (𝓝 V) := by apply tendsto_iff_norm_sub_tendsto_zero.mpr apply squeeze_zero (fun _ => norm_nonneg _) (g := fun j => a j*β€–value (hT := hT) (LipschitzWith.const (1:ℝ))β€–) Β· intro j apply Lp.norm_le_mul_norm_of_ae_le_mul filter_upwards [Lp.coeFn_sub (q.inclusion (Q j)) V,hQ j,q.composeValue_ae hF (q.inclusion P), ((Foundations.boundedLip_of_lipschitz (LipschitzWith.const (1:ℝ))).memLp (ΞΌ := MassMeasure.currentMassMeasure hT) 2).coeFn_toLp] with x hs hq hv h1 change (value (hT := hT) (LipschitzWith.const (1:ℝ)) : X β†’ ℝ) x = 1 at h1 rw [hs,Pi.sub_apply,hq,hv,h1,Real.norm_eq_abs,norm_one,mul_one] exact he j _ Β· simpa only [zero_mul] using ha.mul_const β€–value (hT := hT) (LipschitzWith.const (1:ℝ))β€– obtain ⟨R,hR,hRG⟩ := q.closedGradient_closed V (ClosedCalculus.mulLp hc hcC (q.closedGradient P)) Q hv hgl refine ⟨R,?_,?_,?_⟩ Β· apply hclosed.mem_of_tendsto (q.sobolev_tendsto (P := Q) (by simpa only [hR] using hv) (by simpa only [hRG] using hgl)) exact Eventually.of_forall hQS Β· rw [hR] exact q.composeValue_ae hF (q.inclusion P) Β· rw [hRG] exact ClosedCalculus.mulLp_ae hc hcC _ end CAT0Fillings.ChartGeometry end end OAI