import PoincareLib.Analysis.Parabolic.CompactMaximum import Mathlib.Analysis.Calculus.Deriv.Inv import Mathlib.Analysis.Calculus.Deriv.Pow /-! Adapted from Mapher `PoincareMT/Proofs/M15/Mathlib/CompactCubicComparison.lean` at `0c5d5c4e1ecbc12703b1994e226df1b15d2e8d39`. See the source mapping in `references/ricci-flow/mapher/noncollapse/import.json`. -/ /-! # Compact comparison for a cubic norm reaction Morgan-Tian Proposition 4.11, pp. 67-68, as used in Theorem 8.10, pp. 176-177. A reciprocal barrier for the squared norm reduces the cubic reaction to the existing compact linear maximum principle. See `references/ricci-flow/mapher/noncollapse/derivations/2026-09-21-compact-curvature.md`. -/ set_option autoImplicit false open Set Filter open scoped Topology namespace Poincare.Parabolic /-- A compact nonnegative norm with a cubic squared-energy reaction at spatial maxima stays below two on a uniform short interval. Source: Proposition 4.11, pp. 67-68; all derivatives are within the closed interval. -/ theorem norm_le_two_of_sq_deriv_le_cube_at_max {A : Type*} [TopologicalSpace A] [CompactSpace A] {N D : A → ℝ → ℝ} {C b : ℝ} (hC : 0 < C) (hb : 0 ≤ b) (hbC : b ≤ 1 / (2 * C)) (hN : ContinuousOn (Function.uncurry N) (univ ×ˢ Icc 0 b)) (hnonneg : ∀ q t, t ∈ Icc 0 b → 0 ≤ N q t) (hderiv : ∀ q t, t ∈ Ioc 0 b → HasDerivWithinAt (fun s => N q s ^ 2) (D q t) (Icc 0 b) t) (hmax : ∀ q t, t ∈ Ioc 0 b → (∀ p, N p t ≤ N q t) → D q t ≤ C * N q t ^ 3) (hinit : ∀ q, N q 0 ≤ 1) : ∀ q t, t ∈ Icc 0 b → N q t ≤ 2 := by let p : ℝ → ℝ := fun t => 1 / (1 - C * t) have hden (t : ℝ) (ht : t ∈ Icc 0 b) : 1 / 2 ≤ 1 - C * t := by have hbt := mul_le_mul_of_nonneg_left ht.2 hC.le have hbC' := (le_div_iff₀ (mul_pos (by norm_num : (0 : ℝ) < 2) hC)).mp hbC linarith have hdenpos (t : ℝ) (ht : t ∈ Icc 0 b) : 0 < 1 - C * t := lt_of_lt_of_le (by norm_num) (hden t ht) have hppos (t : ℝ) (ht : t ∈ Icc 0 b) : 0 < p t := one_div_pos.mpr (hdenpos t ht) have hptwo (t : ℝ) (ht : t ∈ Icc 0 b) : p t ≤ 2 := by apply (div_le_iff₀ (hdenpos t ht)).mpr linarith [hden t ht] have hpc : ContinuousOn (fun q : A × ℝ => p q.2) (univ ×ˢ Icc 0 b) := continuousOn_const.div (continuous_const.sub (continuous_const.mul continuous_snd)).continuousOn (fun q hq => (hdenpos q.2 hq.2).ne') have hpd (t : ℝ) (ht : t ∈ Icc 0 b) : HasDerivAt (fun s => p s ^ 2) (2 * C * p t ^ 3) t := by have hd : HasDerivAt p (C / (1 - C * t)^2) t := by simpa only [p, one_div, id_eq, mul_one, neg_neg] using! (((hasDerivAt_id t).const_mul C).const_sub 1).inv (hdenpos t ht).ne' convert! hd.pow 2 using 1 dsimp [p] field_simp [(hdenpos t ht).ne'] obtain ⟨K, hK⟩ := ((isCompact_univ : IsCompact (univ : Set A)).prod isCompact_Icc).bddAbove_image hN have hKpos : 0 < max K 1 := zero_lt_one.trans_le (le_max_right _ _) have hbound (q : A) (t : ℝ) (ht : t ∈ Icc 0 b) : N q t ≤ max K 1 := (hK (mem_image_of_mem (Function.uncurry N) (show (q, t) ∈ univ ×ˢ Icc 0 b from ⟨mem_univ q, ht⟩))).trans (le_max_left _ _) have hF := nonpos_of_deriv_le_mul_at_max (F := fun q t => N q t ^ 2 - p t ^ 2) (F' := fun q t => D q t - 2 * C * p t ^ 3) (a := 0) (b := b) (K := 3 * C * max K 1) (by simpa only [Function.uncurry, Pi.sub_apply, Pi.pow_apply] using! (hN.pow 2).sub (hpc.pow 2)) (fun q t ht => (hderiv q t ht).sub (hpd t ⟨ht.1.le, ht.2⟩).hasDerivWithinAt) (fun q t ht hpos hspace => by have ht' : t ∈ Icc 0 b := ⟨ht.1.le, ht.2⟩ have hNq := hnonneg q t ht' have hp := (hppos t ht').le have hpN : p t ≤ N q t := by nlinarith have hNmax (z : A) : N z t ≤ N q t := by have hz := hspace z nlinarith [hnonneg z t ht'] have hD := hmax q t ht hNmax have hNK := hbound q t ht' have hpK := hpN.trans hNK have hquad : N q t ^ 2 + N q t * p t + p t ^ 2 ≤ 3 * max K 1 * (N q t + p t) := by nlinarith [mul_le_mul_of_nonneg_right hNK hNq, mul_le_mul_of_nonneg_right hNK hp, mul_le_mul_of_nonneg_right hpK hp, mul_nonneg hKpos.le hNq, mul_nonneg hKpos.le hp] have hpoly : N q t ^ 3 - p t ^ 3 ≤ 3 * max K 1 * (N q t ^ 2 - p t ^ 2) := by calc _ = (N q t - p t) * (N q t ^ 2 + N q t * p t + p t ^ 2) := by ring _ ≤ (N q t - p t) * (3 * max K 1 * (N q t + p t)) := mul_le_mul_of_nonneg_left hquad (sub_nonneg.mpr hpN) _ = _ := by ring nlinarith [mul_le_mul_of_nonneg_left hpoly hC.le, mul_nonneg hC.le (pow_nonneg hp 3)]) (fun q => by have hq := pow_le_pow_left₀ (hnonneg q 0 ⟨le_rfl, hb⟩) (hinit q) 2 simpa only [p, mul_zero, sub_zero, div_one, one_pow, sub_nonpos] using hq) intro q t ht have h := hF q t ht have hp := pow_le_pow_left₀ (hppos t ht).le (hptwo t ht) 2 nlinarith end Poincare.Parabolic