import PoincareLib.Geometry.RicciFlow.Curvature.Estimates.ScalarTrace import PoincareLib.Geometry.RicciFlow.Curvature.Calculus.Tensors.TensorMetricTrace import PoincareLib.Geometry.RicciFlow.Curvature.Calculus.Identities.SecondBianchi import PoincareLib.Geometry.Riemannian.ScalarOperators import Mathlib.Logic.Equiv.Fin.Basic /-! Adapted from Mapher06/Poincare-MorganTian, `PoincareMT/Proofs/M04/ScalarContractions.lean`, revision `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. See the curvature import record under `references/ricci-flow/mapher/curvature/`. -/ /-! # Spatial contractions for scalar evolution Derivative slots remain fixed while tensor slots are permuted or traced. -/ set_option autoImplicit false open scoped Manifold ContDiff Bundle open Topology Filter universe u namespace PoincareMT.RicciFlowAnalysis variable {n : โ„•} {M : Type u} [TopologicalSpace M] [ChartedSpace (EuclideanSpace โ„ (Fin n)) M] [IsManifold (๐“ก n) โˆž M] private theorem append_one_tuple {ฮฑ : Type*} (v : Fin 1 โ†’ ฮฑ) (a b : ฮฑ) : Fin.append v ![a, b] = ![v 0, a, b] := by funext i fin_cases i <;> rfl private theorem append_two_tuple {ฮฑ : Type*} (v : Fin 2 โ†’ ฮฑ) (a b : ฮฑ) : Fin.append v ![a, b] = ![v 0, v 1, a, b] := by funext i fin_cases i <;> rfl private theorem append_three_tuple {ฮฑ : Type*} (v : Fin 3 โ†’ ฮฑ) (a b : ฮฑ) : Fin.append v ![a, b] = ![v 0, v 1, v 2, a, b] := by funext i fin_cases i <;> rfl def tensorPermute {k : โ„•} (T : CovariantTensorEvaluation n M k) (s : Equiv.Perm (Fin k)) : CovariantTensorEvaluation n M k := fun x v โ†ฆ T x (v โˆ˜ s) theorem isSmoothCovariantTensor_tensorPermute {k : โ„•} {T : CovariantTensorEvaluation n M k} (hT : IsSmoothCovariantTensor T) (s : Equiv.Perm (Fin k)) : IsSmoothCovariantTensor (tensorPermute T s) := by constructor ยท intro x obtain โŸจL, hLโŸฉ := hT.1 x exact โŸจL.domDomCongr s, fun v โ†ฆ hL (v โˆ˜ s)โŸฉ ยท intro U hU V hV exact hT.2 U hU (fun i โ†ฆ V (s i)) (fun i โ†ฆ hV (s i)) set_option backward.isDefEq.respectTransparency false in theorem covariantTensorDerivative_tensorPermute {g : RiemannianMetric n M} (D : LeviCivitaData g) {k : โ„•} {T : CovariantTensorEvaluation n M k} (_hT : IsSmoothCovariantTensor T) (s : Equiv.Perm (Fin k)) (x : M) (a : TangentSpace (๐“ก n) x) (v : Fin k โ†’ TangentSpace (๐“ก n) x) : D.covariantTensorDerivative (tensorPermute T s) x (Fin.cons a v) = D.covariantTensorDerivative T x (Fin.cons a (v โˆ˜ s)) := by classical simp only [LeviCivitaData.covariantTensorDerivative, tensorPermute, Fin.cons_zero, Fin.cons_succ] congr 1 refine Fintype.sum_equiv s.symm _ _ ?_ intro i simp only [Function.comp_def, s.apply_symm_apply] apply congrArg (T x) change (Function.update v i (D.connection (FiberBundle.extend _ (v i)) x a)) โˆ˜ s = _ exact Function.update_comp_equiv _ _ _ _ private def liftTensorPermutation {k : โ„•} (s : Equiv.Perm (Fin k)) : Equiv.Perm (Fin (k + 1)) := (finSuccEquiv k).trans ((Equiv.optionCongr s).trans (finSuccEquiv k).symm) private theorem cons_comp_lift {ฮฑ : Type*} {k : โ„•} (s : Equiv.Perm (Fin k)) (a : ฮฑ) (v : Fin k โ†’ ฮฑ) : Fin.cons a v โˆ˜ liftTensorPermutation s = Fin.cons a (v โˆ˜ s) := by funext i cases i using Fin.cases <;> simp [liftTensorPermutation, Function.comp_def] set_option backward.isDefEq.respectTransparency false in theorem secondCovariantTensorDerivative_tensorPermute {g : RiemannianMetric n M} (D : LeviCivitaData g) {k : โ„•} {T : CovariantTensorEvaluation n M k} (hT : IsSmoothCovariantTensor T) (s : Equiv.Perm (Fin k)) (x : M) (a b : TangentSpace (๐“ก n) x) (v : Fin k โ†’ TangentSpace (๐“ก n) x) : D.iteratedCovariantTensorDerivative (tensorPermute T s) 2 x (Fin.cons a (Fin.cons b v)) = D.iteratedCovariantTensorDerivative T 2 x (Fin.cons a (Fin.cons b (v โˆ˜ s))) := by have he : D.covariantTensorDerivative (tensorPermute T s) = tensorPermute (D.covariantTensorDerivative T) (liftTensorPermutation s) := by funext y w conv_lhs => rw [โ† Fin.cons_self_tail w] rw [covariantTensorDerivative_tensorPermute D hT] change _ = D.covariantTensorDerivative T y (w โˆ˜ liftTensorPermutation s) conv_rhs => rw [โ† Fin.cons_self_tail w] rw [cons_comp_lift] simp only [LeviCivitaData.iteratedCovariantTensorDerivative, he] rw [covariantTensorDerivative_tensorPermute D (isSmoothCovariantTensor_covariantTensorDerivative D hT), cons_comp_lift] private def scalarTensor (f : M โ†’ โ„) : CovariantTensorEvaluation n M 0 := fun x _ โ†ฆ f x private theorem derivative_scalarTensor {g : RiemannianMetric n M} (D : LeviCivitaData g) (f : M โ†’ โ„) (x : M) (v : Fin 1 โ†’ TangentSpace (๐“ก n) x) : D.covariantTensorDerivative (scalarTensor f) x v = mvfderiv (๐“ก n) f x (v 0) := by simp [LeviCivitaData.covariantTensorDerivative, scalarTensor] private theorem second_derivative_scalarTensor {g : RiemannianMetric n M} (D : LeviCivitaData g) (f : M โ†’ โ„) (x : M) (v : Fin 2 โ†’ TangentSpace (๐“ก n) x) : D.covariantTensorDerivative (D.covariantTensorDerivative (scalarTensor f)) x v = D.hessian f x (v 0) (v 1) := by rw [LeviCivitaData.covariantTensorDerivative] simp only [derivative_scalarTensor, Fin.sum_univ_succ, Fin.sum_univ_zero, Function.update_self, LeviCivitaData.hessian, LeviCivitaData.hessianOnFields, FiberBundle.extend_apply_self, add_zero] rfl private theorem tensorTraceLast_ricci {g : RiemannianMetric n M} (D : LeviCivitaData g) : tensorTraceLast g D.ricciEvaluation = scalarTensor D.scalarCurvature := by funext x v have hv : v = Fin.elim0 := funext fun i โ†ฆ Fin.elim0 i rw [hv] simp [tensorTraceLast, scalarTensor, LeviCivitaData.ricciEvaluation, LeviCivitaData.scalarCurvature] theorem ricci_covariantDerivative_symm {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a b c : TangentSpace (๐“ก n) x) : D.covariantTensorDerivative D.ricciEvaluation x ![a, b, c] = D.covariantTensorDerivative D.ricciEvaluation x ![a, c, b] := by classical let s := Equiv.swap (0 : Fin 2) 1 have he : tensorPermute D.ricciEvaluation s = D.ricciEvaluation := by funext y w change D.ricci y (w (s 0)) (w (s 1)) = D.ricci y (w 0) (w 1) simp only [s, Equiv.swap_apply_left, Equiv.swap_apply_right] exact ricci_symm D y _ _ have hv : ![b, c] โˆ˜ s = ![c, b] := by funext i fin_cases i <;> simp [s] have hp := covariantTensorDerivative_tensorPermute D (isSmoothCovariantTensor_ricciEvaluation D) s x a ![b, c] rw [he, hv] at hp exact hp theorem ricci_secondCovariantDerivative_symm {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a b c d : TangentSpace (๐“ก n) x) : D.iteratedCovariantTensorDerivative D.ricciEvaluation 2 x ![a, b, c, d] = D.iteratedCovariantTensorDerivative D.ricciEvaluation 2 x ![a, b, d, c] := by classical let s := Equiv.swap (0 : Fin 2) 1 have he : tensorPermute D.ricciEvaluation s = D.ricciEvaluation := by funext y w change D.ricci y (w (s 0)) (w (s 1)) = D.ricci y (w 0) (w 1) simp only [s, Equiv.swap_apply_left, Equiv.swap_apply_right] exact ricci_symm D y _ _ have hv : ![c, d] โˆ˜ s = ![d, c] := by funext i fin_cases i <;> simp [s] have hp := secondCovariantTensorDerivative_tensorPermute D (isSmoothCovariantTensor_ricciEvaluation D) s x a b ![c, d] rw [he, hv] at hp exact hp theorem ricci_covariantDerivative_metric_trace {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a : TangentSpace (๐“ก n) x) : (โˆ‘ i, D.covariantTensorDerivative D.ricciEvaluation x ![a, g.orthonormalBasis x i, g.orthonormalBasis x i]) = mvfderiv (๐“ก n) D.scalarCurvature x a := by have ht := covariantTensorDerivative_tensorTraceLast D (isSmoothCovariantTensor_ricciEvaluation D) x ![a] rw [tensorTraceLast_ricci, derivative_scalarTensor] at ht simpa only [tensorTraceLast, append_one_tuple, Matrix.cons_val_zero] using ht.symm set_option maxHeartbeats 1000000 in -- Commuting the second derivative with the Ricci trace needs extra elaboration. set_option backward.isDefEq.respectTransparency false in theorem ricci_secondCovariantDerivative_metric_trace {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a b : TangentSpace (๐“ก n) x) : (โˆ‘ i, D.iteratedCovariantTensorDerivative D.ricciEvaluation 2 x ![a, b, g.orthonormalBasis x i, g.orthonormalBasis x i]) = D.hessian D.scalarCurvature x a b := by have he : D.covariantTensorDerivative (tensorTraceLast g D.ricciEvaluation) = tensorTraceLast g (D.covariantTensorDerivative D.ricciEvaluation) := by funext y w exact covariantTensorDerivative_tensorTraceLast D (isSmoothCovariantTensor_ricciEvaluation D) y w have ht := covariantTensorDerivative_tensorTraceLast D (isSmoothCovariantTensor_covariantTensorDerivative D (isSmoothCovariantTensor_ricciEvaluation D)) x ![a, b] rw [โ† he, tensorTraceLast_ricci, second_derivative_scalarTensor] at ht simpa only [tensorTraceLast, append_two_tuple, Matrix.cons_val_zero, Matrix.cons_val_one, LeviCivitaData.iteratedCovariantTensorDerivative] using ht.symm set_option backward.isDefEq.respectTransparency false in private theorem derivative_tensor_neg {g : RiemannianMetric n M} (D : LeviCivitaData g) {k : โ„•} (T : CovariantTensorEvaluation n M k) (x : M) (v : Fin (k + 1) โ†’ TangentSpace (๐“ก n) x) : D.covariantTensorDerivative (fun y w โ†ฆ -T y w) x v = -D.covariantTensorDerivative T x v := by simp only [LeviCivitaData.covariantTensorDerivative, mvfderiv_fun_neg, neg_apply, Finset.sum_neg_distrib] ring private theorem riemann_derivative_swap_first {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a b c d e : TangentSpace (๐“ก n) x) : D.covariantTensorDerivative D.riemannEvaluation x ![a, b, c, d, e] = -D.covariantTensorDerivative D.riemannEvaluation x ![a, c, b, d, e] := by classical let s := Equiv.swap (0 : Fin 4) 1 have he : tensorPermute D.riemannEvaluation s = fun y w โ†ฆ -D.riemannEvaluation y w := by funext y w change D.curvatureTensor y (w (s 0)) (w (s 1)) (w (s 2)) (w (s 3)) = _ have hs : s 0 = 1 โˆง s 1 = 0 โˆง s 2 = 2 โˆง s 3 = 3 := by decide rw [hs.1, hs.2.1, hs.2.2.1, hs.2.2.2] exact curvatureTensor_swap_first D y (w 0) (w 1) (w 2) (w 3) have hv : ![b, c, d, e] โˆ˜ s = ![c, b, d, e] := by funext i fin_cases i <;> simp [s, Equiv.swap_apply_def] have hp := covariantTensorDerivative_tensorPermute D (isSmoothCovariantTensor_riemannEvaluation D) s x a ![b, c, d, e] rw [he, derivative_tensor_neg, hv] at hp change -D.covariantTensorDerivative D.riemannEvaluation x ![a, b, c, d, e] = D.covariantTensorDerivative D.riemannEvaluation x ![a, c, b, d, e] at hp linarith only [hp] private theorem riemann_derivative_swap_last {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a b c d e : TangentSpace (๐“ก n) x) : D.covariantTensorDerivative D.riemannEvaluation x ![a, b, c, d, e] = -D.covariantTensorDerivative D.riemannEvaluation x ![a, b, c, e, d] := by classical let s := Equiv.swap (2 : Fin 4) 3 have he : tensorPermute D.riemannEvaluation s = fun y w โ†ฆ -D.riemannEvaluation y w := by funext y w change D.curvatureTensor y (w (s 0)) (w (s 1)) (w (s 2)) (w (s 3)) = _ have hs : s 0 = 0 โˆง s 1 = 1 โˆง s 2 = 3 โˆง s 3 = 2 := by decide rw [hs.1, hs.2.1, hs.2.2.1, hs.2.2.2] exact curvatureTensor_swap_last D y (w 0) (w 1) (w 3) (w 2) have hv : ![b, c, d, e] โˆ˜ s = ![b, c, e, d] := by funext i fin_cases i <;> simp [s, Equiv.swap_apply_def] have hp := covariantTensorDerivative_tensorPermute D (isSmoothCovariantTensor_riemannEvaluation D) s x a ![b, c, d, e] rw [he, derivative_tensor_neg, hv] at hp change -D.covariantTensorDerivative D.riemannEvaluation x ![a, b, c, d, e] = D.covariantTensorDerivative D.riemannEvaluation x ![a, b, c, e, d] at hp linarith only [hp] theorem ricci_covariantDerivative_curvature_trace {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a b c : TangentSpace (๐“ก n) x) : D.covariantTensorDerivative D.ricciEvaluation x ![a, b, c] = โˆ‘ i, D.covariantTensorDerivative D.riemannEvaluation x ![a, b, g.orthonormalBasis x i, c, g.orthonormalBasis x i] := by classical let s := Equiv.swap (1 : Fin 4) 2 have he : tensorTraceLast g (tensorPermute D.riemannEvaluation s) = D.ricciEvaluation := by funext y w simp [tensorTraceLast, tensorPermute, append_two_tuple, s, Equiv.swap_apply_def, LeviCivitaData.riemannEvaluation, LeviCivitaData.ricciEvaluation, LeviCivitaData.ricci] have hv (d e : TangentSpace (๐“ก n) x) : ![b, c, d, e] โˆ˜ s = ![b, d, c, e] := by funext i fin_cases i <;> simp [s, Equiv.swap_apply_def] have hterm (i) : D.covariantTensorDerivative (tensorPermute D.riemannEvaluation s) x ![a, b, c, g.orthonormalBasis x i, g.orthonormalBasis x i] = D.covariantTensorDerivative D.riemannEvaluation x ![a, b, g.orthonormalBasis x i, c, g.orthonormalBasis x i] := by have hp := covariantTensorDerivative_tensorPermute D (isSmoothCovariantTensor_riemannEvaluation D) s x a ![b, c, g.orthonormalBasis x i, g.orthonormalBasis x i] rw [hv] at hp exact hp have ht := covariantTensorDerivative_tensorTraceLast D (isSmoothCovariantTensor_tensorPermute (isSmoothCovariantTensor_riemannEvaluation D) s) x ![a, b, c] rw [he] at ht simpa only [tensorTraceLast, append_three_tuple, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, Matrix.head_cons, Matrix.tail_cons, hterm] using ht set_option maxHeartbeats 1200000 in -- The Bianchi contraction and finite trace sums need extra elaboration. theorem ricci_covariantDerivative_contracted {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a : TangentSpace (๐“ก n) x) : (โˆ‘ i, D.covariantTensorDerivative D.ricciEvaluation x ![g.orthonormalBasis x i, g.orthonormalBasis x i, a]) = (1 / 2 : โ„) * mvfderiv (๐“ก n) D.scalarCurvature x a := by classical let e := g.orthonormalBasis x let Q := D.covariantTensorDerivative D.riemannEvaluation x let K := D.covariantTensorDerivative D.ricciEvaluation x have h0 : (โˆ‘ i, โˆ‘ j, (Q ![a, e i, e j, e i, e j] + Q ![e i, e j, a, e i, e j] + Q ![e j, a, e i, e i, e j])) = 0 := by have he (i j) : Q ![a, e i, e j, e i, e j] + Q ![e i, e j, a, e i, e j] + Q ![e j, a, e i, e i, e j] = 0 := riemann_second_bianchi D x a (e i) (e j) (e i) (e j) simp only [he, Finset.sum_const_zero] have h1 : (โˆ‘ i, โˆ‘ j, Q ![a, e i, e j, e i, e j]) = mvfderiv (๐“ก n) D.scalarCurvature x a := by calc _ = โˆ‘ i, K ![a, e i, e i] := by apply Finset.sum_congr rfl intro i _ exact (ricci_covariantDerivative_curvature_trace D x a (e i) (e i)).symm _ = _ := ricci_covariantDerivative_metric_trace D x a have h2 : (โˆ‘ i, โˆ‘ j, Q ![e i, e j, a, e i, e j]) = -(โˆ‘ i, K ![e i, e i, a]) := by rw [โ† Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro i _ calc _ = -(โˆ‘ j, Q ![e i, a, e j, e i, e j]) := by rw [โ† Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro j _ exact riemann_derivative_swap_first D x (e i) (e j) a (e i) (e j) _ = -K ![e i, a, e i] := by rw [โ† ricci_covariantDerivative_curvature_trace D x (e i) a (e i)] _ = _ := congrArg Neg.neg (ricci_covariantDerivative_symm D x (e i) a (e i)) have h3 : (โˆ‘ i, โˆ‘ j, Q ![e j, a, e i, e i, e j]) = -(โˆ‘ i, K ![e i, e i, a]) := by rw [Finset.sum_comm, โ† Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro j _ calc _ = -(โˆ‘ i, Q ![e j, a, e i, e j, e i]) := by rw [โ† Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro i _ exact riemann_derivative_swap_last D x (e j) a (e i) (e i) (e j) _ = -K ![e j, a, e j] := by rw [โ† ricci_covariantDerivative_curvature_trace D x (e j) a (e j)] _ = _ := congrArg Neg.neg (ricci_covariantDerivative_symm D x (e j) a (e j)) simp only [Finset.sum_add_distrib, h1, h2, h3] at h0 change (โˆ‘ i, K ![e i, e i, a]) = _ linarith only [h0] set_option maxHeartbeats 1500000 in -- Differentiating the contracted identity and permuting slots needs extra elaboration. set_option backward.isDefEq.respectTransparency false in theorem ricci_secondCovariantDerivative_contracted {g : RiemannianMetric n M} (D : LeviCivitaData g) (x : M) (a b : TangentSpace (๐“ก n) x) : (โˆ‘ i, D.iteratedCovariantTensorDerivative D.ricciEvaluation 2 x ![a, g.orthonormalBasis x i, g.orthonormalBasis x i, b]) = (1 / 2 : โ„) * D.hessian D.scalarCurvature x a b := by classical let K := D.covariantTensorDerivative D.ricciEvaluation have hK : IsSmoothCovariantTensor K := isSmoothCovariantTensor_covariantTensorDerivative D (isSmoothCovariantTensor_ricciEvaluation D) let s := (Equiv.swap (1 : Fin 3) 2).trans (Equiv.swap (0 : Fin 3) 1) let P := tensorPermute K s let S0 := scalarTensor (n := n) D.scalarCurvature let S1 := D.covariantTensorDerivative S0 have hS0 : IsSmoothCovariantTensor S0 := by dsimp only [S0] rw [โ† tensorTraceLast_ricci D] exact isSmoothCovariantTensor_tensorTraceLast g (isSmoothCovariantTensor_ricciEvaluation D) have hS1 : IsSmoothCovariantTensor S1 := isSmoothCovariantTensor_covariantTensorDerivative D hS0 have he : tensorTraceLast g P = fun y v โ†ฆ (1 / 2 : โ„) * S1 y v := by funext y v have hv (c : TangentSpace (๐“ก n) y) : Fin.append v ![c, c] โˆ˜ s = ![c, c, v 0] := by funext i fin_cases i <;> simp [s, Equiv.swap_apply_def, append_one_tuple] change (โˆ‘ i, K y (Fin.append v ![g.orthonormalBasis y i, g.orthonormalBasis y i] โˆ˜ s)) = (1 / 2 : โ„) * D.covariantTensorDerivative (scalarTensor D.scalarCurvature) y v simp only [hv, derivative_scalarTensor] exact ricci_covariantDerivative_contracted D y (v 0) let E := EuclideanSpace โ„ (Fin n) let e := trivializationAt E (TangentSpace (๐“ก n) : M โ†’ Type _) x let B := FiberBundle.extend E b have hx : x โˆˆ e.baseSet := FiberBundle.mem_baseSet_trivializationAt' x have hB : ContMDiffOn (๐“ก n) ((๐“ก n).prod ๐“˜(โ„, E)) โˆž (T% B) e.baseSet := contMDiffOn_extend_baseSet b have hW (i : Fin 1) : ContMDiffOn (๐“ก n) ((๐“ก n).prod ๐“˜(โ„, E)) โˆž (T% (![B] i)) e.baseSet := by fin_cases i exact hB have hf : MDifferentiableAt (๐“ก n) ๐“˜(โ„, โ„) (fun y โ†ฆ S1 y ![B y]) x := by have hs := hS1.2 e.baseSet e.open_baseSet ![B] hW have hp (y : M) : (fun i โ†ฆ ![B] i y) = ![B y] := by funext i fin_cases i rfl simp only [hp] at hs exact (hs.contMDiffAt (e.open_baseSet.mem_nhds hx)).mdifferentiableAt (by simp) have hRaw (T : CovariantTensorEvaluation n M 1) : D.covariantTensorDerivative T x ![a, b] = mvfderiv (๐“ก n) (fun y โ†ฆ T y ![B y]) x a - T x ![D.connection B x a] := by have htail (y : M) : (fun i : Fin 1 โ†ฆ FiberBundle.extend (EuclideanSpace โ„ (Fin n)) (![a, b] i.succ) y) = ![B y] := by funext i fin_cases i rfl have hfun : (fun y โ†ฆ T y (fun i : Fin 1 โ†ฆ FiberBundle.extend (EuclideanSpace โ„ (Fin n)) (![a, b] i.succ) y)) = (fun y โ†ฆ T y ![B y]) := by funext y exact congrArg (T y) (htail y) have hu (z : TangentSpace (๐“ก n) x) : Function.update (fun j : Fin 1 โ†ฆ ![a, b] j.succ) 0 z = ![z] := by funext i fin_cases i simp simp only [LeviCivitaData.covariantTensorDerivative, Fin.sum_univ_succ, Fin.sum_univ_zero, Matrix.cons_val_zero, hu, add_zero] rw [hfun] rfl have hscale : D.covariantTensorDerivative (fun y v โ†ฆ (1 / 2 : โ„) * S1 y v) x ![a, b] = (1 / 2 : โ„) * D.covariantTensorDerivative S1 x ![a, b] := by rw [hRaw, hRaw] have hd : mvfderiv (๐“ก n) (fun y โ†ฆ (1 / 2 : โ„) * S1 y ![B y]) x a = (1 / 2 : โ„) * mvfderiv (๐“ก n) (fun y โ†ฆ S1 y ![B y]) x a := by erw [mvfderiv_fun_mul (mdifferentiableAt_const (c := (1 / 2 : โ„))) hf] simp only [mvfderiv_const, add_apply, smul_apply, smul_eq_mul, zero_apply, mul_zero, add_zero] rw [hd] ring have hL : D.covariantTensorDerivative (tensorTraceLast g P) x ![a, b] = (1 / 2 : โ„) * D.hessian D.scalarCurvature x a b := by rw [he, hscale] change (1 / 2 : โ„) * D.covariantTensorDerivative (D.covariantTensorDerivative (scalarTensor D.scalarCurvature)) x ![a, b] = _ rw [second_derivative_scalarTensor] rfl have hv (c d : TangentSpace (๐“ก n) x) : ![b, c, d] โˆ˜ s = ![c, d, b] := by funext i fin_cases i <;> simp [s, Equiv.swap_apply_def] have hterm (c : TangentSpace (๐“ก n) x) : D.covariantTensorDerivative (tensorPermute K s) x ![a, b, c, c] = D.covariantTensorDerivative K x ![a, c, c, b] := by have hp := covariantTensorDerivative_tensorPermute D hK s x a ![b, c, c] rw [hv] at hp exact hp have ht := covariantTensorDerivative_tensorTraceLast D (isSmoothCovariantTensor_tensorPermute hK s) x ![a, b] rw [hL] at ht simp only [tensorTraceLast, append_two_tuple, Matrix.cons_val_zero, Matrix.cons_val_one] at ht simpa only [hterm, K, LeviCivitaData.iteratedCovariantTensorDerivative] using ht.symm end PoincareMT.RicciFlowAnalysis