import PoincareLib.Geometry.RicciFlow.Tensor.TimeDerivative.Trace import PoincareLib.Geometry.Riemannian.Hessian.Tensor import PoincareLib.Geometry.Riemannian.ScalarOperators.GradientTime import PoincareLib.Geometry.Riemannian.Curvature.Bilinear /-! # Gradient energy under Ricci flow Tracing the tensor `df βŠ— df` gives its moving gradient norm. The inverse-metric variation contributes twice Ricci evaluated on the gradient; the two scalar differentials contribute twice the pairing with the gradient of the time derivative. This is the gradient-energy term in Morgan--Tian, Lemma 9.1. -/ set_option autoImplicit false set_option backward.isDefEq.respectTransparency false open Set Filter open scoped Manifold ContDiff Bundle Topology BigOperators universe u namespace PoincareMT variable {n : β„•} {M : Type u} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] private theorem differential_square_isSmooth {f : M β†’ ℝ} (hf : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ f) : IsSmoothCovariantTensor (k := 2) (fun x v ↦ mvfderiv (𝓑 n) f x (v 0) * mvfderiv (𝓑 n) f x (v 1)) := by constructor Β· intro x refine ⟨{ toFun := fun v ↦ mvfderiv (𝓑 n) f x (v 0) * mvfderiv (𝓑 n) f x (v 1) map_update_add' := ?_ map_update_smul' := ?_ }, fun _ ↦ rfl⟩ Β· intro _ v i a b fin_cases i <;> simp [map_add, add_mul, mul_add] Β· intro _ v i c a fin_cases i <;> simp [map_smul, mul_assoc, mul_left_comm] Β· intro U hU X hX exact ((differentialEvaluation_isSmooth hf).2 U hU (fun _ ↦ X 0) (fun _ ↦ hX 0)).mul ((differentialEvaluation_isSmooth hf).2 U hU (fun _ ↦ X 1) (fun _ ↦ hX 1)) private theorem ricci_gradient_eq_sum {g : RiemannianMetric n M} (D : LeviCivitaData g) (f : M β†’ ℝ) (x : M) : D.ricci x (D.gradient f x) (D.gradient f x) = βˆ‘ i, βˆ‘ j, D.ricci x (g.orthonormalBasis x i) (g.orthonormalBasis x j) * (mvfderiv (𝓑 n) f x (g.orthonormalBasis x i) * mvfderiv (𝓑 n) f x (g.orthonormalBasis x j)) := by classical let : Bundle.RiemannianBundle (TangentSpace (𝓑 n) : M β†’ Type _) := ⟨g.toRiemannianMetric⟩ let b := g.orthonormalBasis x let B := βˆ‘ k, D.curvatureTensor_bilinear_first_third x (b k) (b k) have hB (u v : TangentSpace (𝓑 n) x) : B u v = D.ricci x u v := by simp only [B, LinearMap.sum_apply, LeviCivitaData.curvatureTensor_bilinear_first_third_apply, LeviCivitaData.ricci, b] have hgrad : (βˆ‘ i, mvfderiv (𝓑 n) f x (b i) β€’ b i) = D.gradient f x := by have hinner (i) : inner ℝ (b i) (D.gradient f x) = mvfderiv (𝓑 n) f x (b i) := by change g.inner x (b i) (D.gradient f x) = _ rw [g.symm, D.inner_gradient] have h := b.sum_repr (D.gradient f x) simpa only [OrthonormalBasis.repr_apply_apply, hinner] using h rw [← hB, ← hgrad] simp only [map_sum, map_smul, LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul, Finset.mul_sum, hB] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring namespace RicciFlow variable {J : Set ℝ} /-- The variation of gradient energy for a smooth scalar with specified time derivative. -/ theorem hasDerivAt_gradient_normSq_of_time_derivative (F : RicciFlow n M J) {f : ℝ Γ— M β†’ ℝ} {df : M β†’ ℝ} {t : ℝ} (ht : t ∈ interior J) (hspace : βˆ€ s, ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ (fun y ↦ f (s, y))) (hreg : βˆ€ y, ContMDiffAt (π“˜(ℝ, ℝ).prod (𝓑 n)) π“˜(ℝ, ℝ) ∞ f (t, y)) (hdf : βˆ€ y, HasDerivAt (fun s ↦ f (s, y)) (df y) t) (x : M) : HasDerivAt (fun s ↦ (F.metric s).inner x ((F.connection s).gradient (fun y ↦ f (s, y)) x) ((F.connection s).gradient (fun y ↦ f (s, y)) x)) (2 * (F.connection t).ricci x ((F.connection t).gradient (fun y ↦ f (t, y)) x) ((F.connection t).gradient (fun y ↦ f (t, y)) x) + 2 * (F.metric t).inner x ((F.connection t).gradient (fun y ↦ f (t, y)) x) ((F.connection t).gradient df x)) t := by let T : ℝ β†’ CovariantTensorEvaluation n M 2 := fun s y v ↦ mvfderiv (𝓑 n) (fun z ↦ f (s, z)) y (v 0) * mvfderiv (𝓑 n) (fun z ↦ f (s, z)) y (v 1) let W : ℝ β†’ CovariantTensorEvaluation n M 2 := fun _ y v ↦ mvfderiv (𝓑 n) df y (v 0) * mvfderiv (𝓑 n) (fun z ↦ f (t, z)) y (v 1) + mvfderiv (𝓑 n) (fun z ↦ f (t, z)) y (v 0) * mvfderiv (𝓑 n) df y (v 1) have hW (v : Fin 2 β†’ TangentSpace (𝓑 n) x) : HasDerivAt (fun s ↦ T s x v) (W t x v) t := (Poincare.Manifold.hasDerivAt_mvfderiv_time (hreg x) hdf (v 0)).mul (Poincare.Manifold.hasDerivAt_mvfderiv_time (hreg x) hdf (v 1)) have h := F.hasDerivAt_tensorTrace (T := T) (W := W) ht x (fun s ↦ differential_square_isSmooth (hspace s)) hW (Fin.elim0) have htrace (s : ℝ) : (F.metric s).tensorTrace (T s) x Fin.elim0 = (F.metric s).inner x ((F.connection s).gradient (fun y ↦ f (s, y)) x) ((F.connection s).gradient (fun y ↦ f (s, y)) x) := by simpa only [RiemannianMetric.tensorTrace, T, Fin.cons_zero, Fin.cons_one, pow_two] using ((F.connection s).gradient_normSq_eq_sum_mvfderiv_sq (fun y ↦ f (s, y)) x).symm simp_rw [htrace] at h apply h.congr_deriv simp only [RiemannianMetric.tensorTrace, W, T, Fin.cons_zero, Fin.cons_one, Finset.sum_add_distrib] rw [(F.connection t).sum_mvfderiv_mul_eq_inner_gradient, (F.connection t).sum_mvfderiv_mul_eq_inner_gradient, ← ricci_gradient_eq_sum] rw [(F.metric t).symm x ((F.connection t).gradient df x)] ring /-- A jointly smooth potential on the flow's time strip has the moving gradient-energy derivative, with no regularity required outside that strip. -/ theorem hasDerivAt_gradient_normSq (F : RicciFlow n M J) {f : M Γ— ℝ β†’ ℝ} {t : ℝ} (ht : t ∈ interior J) (hf : ContMDiffOn ((𝓑 n).prod π“˜(ℝ, ℝ)) π“˜(ℝ, ℝ) ∞ f (univ Γ—Λ’ J)) (x : M) : HasDerivAt (fun s ↦ (F.metric s).inner x ((F.connection s).gradient (fun y ↦ f (y, s)) x) ((F.connection s).gradient (fun y ↦ f (y, s)) x)) (2 * (F.connection t).ricci x ((F.connection t).gradient (fun y ↦ f (y, t)) x) ((F.connection t).gradient (fun y ↦ f (y, t)) x) + 2 * (F.metric t).inner x ((F.connection t).gradient (fun y ↦ f (y, t)) x) ((F.connection t).gradient (fun y ↦ deriv (fun s ↦ f (y, s)) t) x)) t := by classical let f' : ℝ Γ— M β†’ ℝ := fun p ↦ if p.1 ∈ J then f (p.2, p.1) else 0 have hnear : J ∈ 𝓝 t := mem_interior_iff_mem_nhds.mp ht have hsmooth (y : M) : ContMDiffAt ((𝓑 n).prod π“˜(ℝ, ℝ)) π“˜(ℝ, ℝ) ∞ f (y, t) := hf.contMDiffAt (prod_mem_nhds Filter.univ_mem hnear) have hspace (s : ℝ) : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ (fun y ↦ f' (s, y)) := by by_cases hs : s ∈ J Β· have hslice : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ (fun y ↦ f (y, s)) := contMDiffOn_univ.mp (hf.comp (contMDiffOn_id.prodMk contMDiffOn_const) (fun y _ ↦ ⟨mem_univ y, hs⟩)) simpa only [f', if_pos hs] using hslice Β· simpa only [f', if_neg hs] using (contMDiff_const : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ (fun _ : M ↦ (0 : ℝ))) have hreg (y : M) : ContMDiffAt (π“˜(ℝ, ℝ).prod (𝓑 n)) π“˜(ℝ, ℝ) ∞ f' (t, y) := by have hswap : ContMDiffAt (π“˜(ℝ, ℝ).prod (𝓑 n)) π“˜(ℝ, ℝ) ∞ (fun p : ℝ Γ— M ↦ f (p.2, p.1)) (t, y) := (hsmooth y).comp_of_eq (contMDiffAt_snd.prodMk contMDiffAt_fst) rfl apply hswap.congr_of_eventuallyEq filter_upwards [continuousAt_fst.tendsto.eventually hnear] with p hp exact if_pos hp have hdf (y : M) : HasDerivAt (fun s ↦ f' (s, y)) (deriv (fun s ↦ f (y, s)) t) t := by have hs : ContMDiffAt π“˜(ℝ, ℝ) π“˜(ℝ, ℝ) ∞ (fun s ↦ f (y, s)) t := (hsmooth y).comp t (contMDiffAt_const.prodMk contMDiffAt_id) apply (hs.contDiffAt.differentiableAt (by simp)).hasDerivAt.congr_of_eventuallyEq filter_upwards [hnear] with s hs exact if_pos hs have h := F.hasDerivAt_gradient_normSq_of_time_derivative ht hspace hreg hdf x have hft : (fun y ↦ f' (t, y)) = (fun y ↦ f (y, t)) := by funext y exact if_pos (interior_subset ht) rw [hft] at h apply h.congr_of_eventuallyEq filter_upwards [hnear] with s hs simp only [f', if_pos hs] end RicciFlow end PoincareMT