import PoincareLib.Geometry.Riemannian.ScalarOperators.Gradient.Flow.Expansion /-! # Nondecreasing tangent lengths under normalized gradient transport The normalization derivative vanishes when paired with a level tangent. The actual smooth-flow variation equation thus differentiates its squared length into twice the tangential Hessian divided by the gradient norm square. -/ noncomputable section set_option autoImplicit false set_option backward.isDefEq.respectTransparency false open Set Filter open Poincare.Geometry.Riemannian.Convexity open scoped Manifold ContDiff Bundle Topology namespace PoincareMT.LeviCivitaData variable {n : β„•} {M : Type*} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] {g : RiemannianMetric n M} /-- The exact tangential metric pairing for the positive normalized gradient field on a smooth manifold. -/ theorem inner_connection_normalizedGradient_of_tangent (D : LeviCivitaData g) {f : M β†’ ℝ} {x : M} (hf : ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ f x) (hregular : g.inner x (D.gradient f x) (D.gradient f x) β‰  0) (v : TangentSpace (𝓑 n) x) (hv : mvfderiv (𝓑 n) f x v = 0) : g.inner x (D.connection (D.normalizedGradient f) x v) v = D.hessian f x v v / g.inner x (D.gradient f x) (D.gradient f x) := by let : Bundle.RiemannianBundle (TangentSpace (𝓑 n) : M β†’ Type _) := ⟨g.toRiemannianMetric⟩ have hgrad := (D.contMDiffAt_gradient hf).mdifferentiableAt (by simp) have hpair : MDifferentiableAt (𝓑 n) π“˜(ℝ, ℝ) (fun y ↦ g.inner y (D.gradient f y) (D.gradient f y)) x := hgrad.inner_bundle hgrad have hinv : MDifferentiableAt (𝓑 n) π“˜(ℝ, ℝ) (fun y ↦ (g.inner y (D.gradient f y) (D.gradient f y))⁻¹) x := (differentiableAt_inv hregular).mdifferentiableAt.comp x hpair unfold normalizedGradient rw [inner_connection_smul_gradient_of_tangent D hf hinv v hv] ring /-- Convexity makes the actual tangential normalized-gradient metric variation nonnegative. -/ theorem inner_connection_normalizedGradient_nonneg (D : LeviCivitaData g) {f : M β†’ ℝ} {x : M} (hf : ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ f x) (hregular : 0 < g.inner x (D.gradient f x) (D.gradient f x)) (v : TangentSpace (𝓑 n) x) (hv : mvfderiv (𝓑 n) f x v = 0) (hhess : 0 ≀ D.hessian f x v v) : 0 ≀ g.inner x (D.connection (D.normalizedGradient f) x v) v := by rw [D.inner_connection_normalizedGradient_of_tangent hf hregular.ne' v hv] exact div_nonneg hhess hregular.le end PoincareMT.LeviCivitaData namespace PoincareMT.LeviCivitaData variable {n : β„•} {g : RiemannianMetric n (EuclideanSpace ℝ (Fin n))} /-- Exact squared-length variation of an actual normalized-gradient flow at a transported level tangent in model coordinates. -/ theorem hasDerivAt_normalizedGradient_flow_squared_length (D : LeviCivitaData g) {f : EuclideanSpace ℝ (Fin n) β†’ ℝ} {q : ℝ Γ— EuclideanSpace ℝ (Fin n) β†’ EuclideanSpace ℝ (Fin n)} {t : ℝ} {x : EuclideanSpace ℝ (Fin n)} (hq : ContDiffAt ℝ ∞ q (t, x)) (hf : ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ f (q (t, x))) (hregular : g.inner (q (t, x)) (D.gradient f (q (t, x))) (D.gradient f (q (t, x))) β‰  0) (htime : βˆ€αΆ  y in 𝓝 x, HasDerivAt (fun s ↦ q (s, y)) (D.normalizedGradient f (q (t, y))) t) (v : EuclideanSpace ℝ (Fin n)) (htangent : mvfderiv (𝓑 n) f (q (t, x)) (fderiv ℝ (fun y ↦ q (t, y)) x v) = 0) : let w := fderiv ℝ (fun y ↦ q (t, y)) x v HasDerivAt (fun s ↦ g.inner (q (s, x)) (fderiv ℝ (fun y ↦ q (s, y)) x v) (fderiv ℝ (fun y ↦ q (s, y)) x v)) (2 * D.hessian f (q (t, x)) w w / g.inner (q (t, x)) (D.gradient f (q (t, x))) (D.gradient f (q (t, x)))) t := by have hfield : DifferentiableAt ℝ (D.normalizedGradient f) (q (t, x)) := by have heq : D.normalizedGradient f = fun z ↦ -normalizedNegGradient D f z := by funext z simp only [normalizedGradient, normalizedNegGradient, neg_smul, neg_neg] rw [heq] exact (differentiableAt_normalizedNegGradient D hf hregular).neg have h := hasDerivAt_flow_squared_length D hq hfield htime v dsimp only at h ⊒ rw [D.inner_connection_normalizedGradient_of_tangent hf hregular _ htangent] at h convert! h using 1 ring private theorem comp_normalizedGradient_eq_add (D : LeviCivitaData g) {f : EuclideanSpace ℝ (Fin n) β†’ ℝ} {Ξ³ : ℝ β†’ EuclideanSpace ℝ (Fin n)} {a b : ℝ} (hf : βˆ€ t ∈ Icc a b, ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ f (Ξ³ t)) (hregular : βˆ€ t ∈ Icc a b, g.inner (Ξ³ t) (D.gradient f (Ξ³ t)) (D.gradient f (Ξ³ t)) β‰  0) (hΞ³ : βˆ€ t ∈ Icc a b, HasDerivAt Ξ³ (D.normalizedGradient f (Ξ³ t)) t) : βˆ€ t ∈ Icc a b, f (Ξ³ t) = f (Ξ³ a) + (t - a) := by have hd (t : ℝ) (ht : t ∈ Icc a b) : HasDerivAt (f ∘ Ξ³) 1 t := by have hcomp := ((contMDiffAt_iff_contDiffAt.mp (hf t ht)).differentiableAt (by simp)).hasFDerivAt.comp_hasDerivAt t (hΞ³ t ht) have he : mvfderiv (𝓑 n) f (Ξ³ t) (D.normalizedGradient f (Ξ³ t)) = 1 := by simp only [normalizedGradient, map_smul, smul_eq_mul, ← D.inner_gradient] exact inv_mul_cancelβ‚€ (hregular t ht) have he' : fderiv ℝ f (Ξ³ t) (D.normalizedGradient f (Ξ³ t)) = 1 := by simp [mvfderiv, mfderiv_eq_fderiv, NormedSpace.fromTangentSpace] at he convert! he using 1 exact hcomp.congr_deriv he' have hl (t : ℝ) : HasDerivAt (fun s ↦ f (Ξ³ a) + (s - a)) 1 t := by simpa using ((hasDerivAt_id t).sub_const a).const_add (f (Ξ³ a)) exact eq_of_has_deriv_right_eq (fun t ht ↦ (hd t ⟨ht.1, ht.2.le⟩).hasDerivWithinAt) (fun t _ ↦ (hl t).hasDerivWithinAt) (fun t ht ↦ (hd t ht).continuousAt.continuousWithinAt) (fun t _ ↦ (hl t).continuousAt.continuousWithinAt) (by simp) /-- A genuine positive normalized-gradient flow preserves the differential of its defining function. -/ theorem normalizedGradient_flow_preserves_level_differential (D : LeviCivitaData g) {f : EuclideanSpace ℝ (Fin n) β†’ ℝ} {q : ℝ Γ— EuclideanSpace ℝ (Fin n) β†’ EuclideanSpace ℝ (Fin n)} {a b : ℝ} {x : EuclideanSpace ℝ (Fin n)} (hq : βˆ€ t ∈ Icc a b, ContDiffAt ℝ ∞ q (t, x)) (hf : βˆ€αΆ  y in 𝓝 x, βˆ€ t ∈ Icc a b, ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ f (q (t, y))) (hregular : βˆ€αΆ  y in 𝓝 x, βˆ€ t ∈ Icc a b, g.inner (q (t, y)) (D.gradient f (q (t, y))) (D.gradient f (q (t, y))) β‰  0) (htime : βˆ€αΆ  y in 𝓝 x, βˆ€ t ∈ Icc a b, HasDerivAt (fun s ↦ q (s, y)) (D.normalizedGradient f (q (t, y))) t) (v : EuclideanSpace ℝ (Fin n)) (t : ℝ) (ht : t ∈ Icc a b) : mvfderiv (𝓑 n) f (q (t, x)) (fderiv ℝ (fun y ↦ q (t, y)) x v) = mvfderiv (𝓑 n) f (q (a, x)) (fderiv ℝ (fun y ↦ q (a, y)) x v) := by have ha : a ∈ Icc a b := ⟨le_rfl, ht.1.trans ht.2⟩ have he : (fun y ↦ f (q (t, y))) =αΆ [𝓝 x] fun y ↦ f (q (a, y)) + (t - a) := by filter_upwards [hf, hregular, htime] with y hy hr hytime exact comp_normalizedGradient_eq_add D hy hr hytime t ht have hqd (s : ℝ) (hs : s ∈ Icc a b) : DifferentiableAt ℝ (fun y ↦ q (s, y)) x := ((hq s hs).differentiableAt (by simp)).comp x (differentiableAt_const s |>.prodMk differentiableAt_id) have hfd (s : ℝ) (hs : s ∈ Icc a b) : DifferentiableAt ℝ f (q (s, x)) := (contMDiffAt_iff_contDiffAt.mp (hf.self_of_nhds s hs)).differentiableAt (by simp) have hleft := (hfd t ht).hasFDerivAt.comp x (hqd t ht).hasFDerivAt have hright := ((hfd a ha).hasFDerivAt.comp x (hqd a ha).hasFDerivAt).add_const (t - a) have hd := congrArg (fun A ↦ A v) (hleft.unique (hright.congr_of_eventuallyEq he)) simp [mvfderiv, mfderiv_eq_fderiv, NormedSpace.fromTangentSpace] convert! hd using 1 /-- The actual induced quadratic metric on level tangents is nondecreasing along any smooth normalized-gradient flow with nonnegative tangential Hessian. -/ theorem normalizedGradient_flow_squared_length_monotone (D : LeviCivitaData g) {f : EuclideanSpace ℝ (Fin n) β†’ ℝ} {q : ℝ Γ— EuclideanSpace ℝ (Fin n) β†’ EuclideanSpace ℝ (Fin n)} {a b : ℝ} {x : EuclideanSpace ℝ (Fin n)} (hq : βˆ€ t ∈ Icc a b, ContDiffAt ℝ ∞ q (t, x)) (hf : βˆ€αΆ  y in 𝓝 x, βˆ€ t ∈ Icc a b, ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ f (q (t, y))) (hregular : βˆ€αΆ  y in 𝓝 x, βˆ€ t ∈ Icc a b, 0 < g.inner (q (t, y)) (D.gradient f (q (t, y))) (D.gradient f (q (t, y)))) (htime : βˆ€αΆ  y in 𝓝 x, βˆ€ t ∈ Icc a b, HasDerivAt (fun s ↦ q (s, y)) (D.normalizedGradient f (q (t, y))) t) (v : EuclideanSpace ℝ (Fin n)) (hinitial : mvfderiv (𝓑 n) f (q (a, x)) (fderiv ℝ (fun y ↦ q (a, y)) x v) = 0) (hhess : βˆ€ t ∈ Icc a b, βˆ€ w, mvfderiv (𝓑 n) f (q (t, x)) w = 0 β†’ 0 ≀ D.hessian f (q (t, x)) w w) : MonotoneOn (fun t ↦ g.inner (q (t, x)) (fderiv ℝ (fun y ↦ q (t, y)) x v) (fderiv ℝ (fun y ↦ q (t, y)) x v)) (Icc a b) := by have htan (t : ℝ) (ht : t ∈ Icc a b) : mvfderiv (𝓑 n) f (q (t, x)) (fderiv ℝ (fun y ↦ q (t, y)) x v) = 0 := (D.normalizedGradient_flow_preserves_level_differential hq hf (hregular.mono fun y hy s hs ↦ (hy s hs).ne') htime v t ht).trans hinitial have hd (t : ℝ) (ht : t ∈ Icc a b) := D.hasDerivAt_normalizedGradient_flow_squared_length (hq t ht) (hf.self_of_nhds t ht) (hregular.self_of_nhds t ht).ne' (htime.mono fun y hy ↦ hy t ht) v (htan t ht) apply monotoneOn_of_deriv_nonneg (convex_Icc _ _) (fun t ht ↦ (hd t ht).continuousAt.continuousWithinAt) (fun t ht ↦ (hd t (interior_subset ht)).differentiableAt.differentiableWithinAt) intro t ht rw [(hd t (interior_subset ht)).deriv] exact div_nonneg (mul_nonneg (by norm_num) (hhess t (interior_subset ht) _ (htan t (interior_subset ht)))) (hregular.self_of_nhds t (interior_subset ht)).le /-- A local normalized-gradient flow exists on a regular region with nonnegative tangential Hessian and expands the induced level metric. -/ theorem exists_local_normalizedGradient_flow_with_nondecreasing_metric (D : LeviCivitaData g) {f : EuclideanSpace ℝ (Fin n) β†’ ℝ} {U : Set (EuclideanSpace ℝ (Fin n))} (hU : IsOpen U) (hf : ContDiffOn ℝ ∞ f U) (hregular : βˆ€ y ∈ U, 0 < g.inner y (D.gradient f y) (D.gradient f y)) (hhess : βˆ€ y ∈ U, βˆ€ v : EuclideanSpace ℝ (Fin n), mvfderiv (𝓑 n) f y v = 0 β†’ 0 ≀ D.hessian f y v v) {x : EuclideanSpace ℝ (Fin n)} (hx : x ∈ U) : βˆƒ (V : Set (EuclideanSpace ℝ (Fin n))) (Ξ΄ : ℝ) (Ξ¦ : ℝ Γ— EuclideanSpace ℝ (Fin n) β†’ EuclideanSpace ℝ (Fin n)), IsOpen V ∧ x ∈ V ∧ V βŠ† U ∧ 0 < Ξ΄ ∧ ContDiffOn ℝ ∞ Ξ¦ (Ioo (-Ξ΄) Ξ΄ Γ—Λ’ V) ∧ (βˆ€ y ∈ V, Ξ¦ (0, y) = y) ∧ (βˆ€ y ∈ V, βˆ€ t ∈ Ioo (-Ξ΄) Ξ΄, Ξ¦ (t, y) ∈ U ∧ HasDerivAt (fun s => Ξ¦ (s, y)) (D.normalizedGradient f (Ξ¦ (t, y))) t) ∧ βˆ€ y ∈ V, βˆ€ t ∈ Ico 0 Ξ΄, f (Ξ¦ (t, y)) = f y + t ∧ βˆ€ v : EuclideanSpace ℝ (Fin n), mvfderiv (𝓑 n) f y v = 0 β†’ g.inner y v v ≀ g.inner (Ξ¦ (t, y)) (fderiv ℝ (fun z => Ξ¦ (t, z)) y v) (fderiv ℝ (fun z => Ξ¦ (t, z)) y v) := by obtain ⟨V, Ξ΄, q, hV, hxV, hVU, hΞ΄, hq, hinit, hflow⟩ := exists_smooth_normalizedNegGradient_flow D hU hf (fun y hy => (hregular y hy).ne') hx let Ξ¦ : ℝ Γ— EuclideanSpace ℝ (Fin n) β†’ EuclideanSpace ℝ (Fin n) := fun p => q (-p.1, p.2) have hneg (t : ℝ) (ht : t ∈ Ioo (-Ξ΄) Ξ΄) : -t ∈ Ioo (-Ξ΄) Ξ΄ := by constructor <;> linarith [ht.1, ht.2] have hΞ¦ : ContDiffOn ℝ ∞ Ξ¦ (Ioo (-Ξ΄) Ξ΄ Γ—Λ’ V) := hq.comp (contDiff_fst.neg.prodMk contDiff_snd).contDiffOn (fun p hp => ⟨hneg p.1 hp.1, hp.2⟩) have hΞ¦0 (y : EuclideanSpace ℝ (Fin n)) (hy : y ∈ V) : Ξ¦ (0, y) = y := by simpa only [Ξ¦, neg_zero] using hinit y hy have hΞ¦flow (y : EuclideanSpace ℝ (Fin n)) (hy : y ∈ V) (t : ℝ) (ht : t ∈ Ioo (-Ξ΄) Ξ΄) : Ξ¦ (t, y) ∈ U ∧ HasDerivAt (fun s => Ξ¦ (s, y)) (D.normalizedGradient f (Ξ¦ (t, y))) t := by refine ⟨(hflow y hy (-t) (hneg t ht)).1, ?_⟩ have hd := (hflow y hy (-t) (hneg t ht)).2.scomp t ((hasDerivAt_id t).neg) simpa only [Ξ¦, Function.comp_def, normalizedGradient, normalizedNegGradient, neg_smul, one_smul, neg_neg] using hd refine ⟨V, Ξ΄, Ξ¦, hV, hxV, hVU, hΞ΄, hΞ¦, hΞ¦0, hΞ¦flow, ?_⟩ intro y hy t ht have hsub : Icc (0 : ℝ) t βŠ† Ioo (-Ξ΄) Ξ΄ := fun s hs => ⟨by linarith [hs.1], hs.2.trans_lt ht.2⟩ have hqs (s : ℝ) (hs : s ∈ Icc (0 : ℝ) t) : ContDiffAt ℝ ∞ Ξ¦ (s, y) := hΞ¦.contDiffAt ((isOpen_Ioo.prod hV).mem_nhds ⟨hsub hs, hy⟩) have hfs : βˆ€αΆ  z in 𝓝 y, βˆ€ s ∈ Icc (0 : ℝ) t, ContMDiffAt (𝓑 n) π“˜(ℝ, ℝ) ∞ f (Ξ¦ (s, z)) := by filter_upwards [hV.mem_nhds hy] with z hz s hs exact contMDiffAt_iff_contDiffAt.mpr (hf.contDiffAt (hU.mem_nhds (hΞ¦flow z hz s (hsub hs)).1)) have hrs : βˆ€αΆ  z in 𝓝 y, βˆ€ s ∈ Icc (0 : ℝ) t, 0 < g.inner (Ξ¦ (s, z)) (D.gradient f (Ξ¦ (s, z))) (D.gradient f (Ξ¦ (s, z))) := by filter_upwards [hV.mem_nhds hy] with z hz s hs exact hregular _ (hΞ¦flow z hz s (hsub hs)).1 have hts : βˆ€αΆ  z in 𝓝 y, βˆ€ s ∈ Icc (0 : ℝ) t, HasDerivAt (fun r => Ξ¦ (r, z)) (D.normalizedGradient f (Ξ¦ (s, z))) s := by filter_upwards [hV.mem_nhds hy] with z hz s hs exact (hΞ¦flow z hz s (hsub hs)).2 constructor Β· have he := comp_normalizedGradient_eq_add D hfs.self_of_nhds (fun s hs => (hrs.self_of_nhds s hs).ne') hts.self_of_nhds t ⟨ht.1, le_rfl⟩ simpa only [hΞ¦0 y hy, sub_zero] using he Β· intro v hv have he : (fun z => Ξ¦ (0, z)) =αΆ [𝓝 y] id := by filter_upwards [hV.mem_nhds hy] with z hz exact hΞ¦0 z hz have hzero : fderiv ℝ (fun z => Ξ¦ (0, z)) y v = v := by rw [he.fderiv_eq, fderiv_id, ContinuousLinearMap.id_apply] have hm := D.normalizedGradient_flow_squared_length_monotone hqs hfs hrs hts v (by rw [hzero, hΞ¦0 y hy]; exact hv) (fun s hs w hw => hhess _ (hΞ¦flow y hy s (hsub hs)).1 w hw) have hb := hm ⟨le_rfl, ht.1⟩ ⟨ht.1, le_rfl⟩ ht.1 dsimp only at hb rw [hzero, hΞ¦0 y hy] at hb exact hb end PoincareMT.LeviCivitaData