Poincaré conjecture: the Lean proof, cleaned up together
The 2026 Lean proof of the Poincaré conjecture after Morgan and Tian, 3 million lines, cleaned up together: smaller, faster to build, more readable, the theorems unchanged

| 1 | import PoincareLib.Geometry.CurveShortening.Comparison.Compatibility.SourceNames |
| 2 | import PoincareLib.Geometry.CurveShortening.Ramp.Approximation.Raw.LoopLength |
| 3 | import PoincareLib.Geometry.CurveShortening.Ramp.Approximation.Sampled.PolygonLength |
| 4 | import PoincareLib.Geometry.Riemannian.Measure.HausdorffDensity.ChartComparison |
| 5 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Coordinates.TangentChartPhase |
| 6 | import PoincareLib.Geometry.Riemannian.LoopSpace.Length.PeriodicSpeed |
| 7 | import PoincareLib.Geometry.CurveShortening.Comparison.PolygonApproximation.Compact.ProductCover |
| 8 | import Mathlib.Topology.MetricSpace.Pseudo.Lemmas |
| 9 | import Mathlib.Analysis.Calculus.MeanValue |
| 10 | |
| 11 | /-! |
| 12 | # Uniform length of sampled intrinsic chords |
| 13 | |
| 14 | Actual coordinate first jets on a compact parameter-time domain give |
| 15 | one short-arc deficit estimate. Summing the genuine cells proves the |
| 16 | reverse length comparison in MT2007 Claim 19.19, p. 450. See the exact |
| 17 | uniform sampled chord-length derivation, 2026-09-23. |
| 18 | |
| 19 | Morgan--Tian context: Section 19.4, Definition 19.18 and Claims 19.19-19.22, printed pp. |
| 20 | 450-453. |
| 21 | -/ |
| 22 | |
| 23 | set_option autoImplicit false |
| 24 | |
| 25 | noncomputable section |
| 26 | |
| 27 | open Set Filter Metric Bundle MeasureTheory |
| 28 | open scoped Manifold ContDiff Topology BigOperators intervalIntegral NNReal ENNReal |
| 29 | |
| 30 | universe u |
| 31 | |
| 32 | namespace PoincareMT |
| 33 | |
| 34 | open Proofs.M58 |
| 35 | |
| 36 | /-- The actual sampled intrinsic chord sum approaches length uniformly for a compact C1 |
| 37 | parameter family. This is the arbitrary-compact parameter form of the closed M63 chord |
| 38 | estimate. Source: Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. |
| 39 | 450-453; project construction in |
| 40 | `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 41 | theorem m64_exists_uniform_sampled_chord_length |
| 42 | {M : Type u} [TopologicalSpace M] [T2Space M] |
| 43 | [ChartedSpace LoopAmbient M] [IsManifold (𝓡 3) ∞ M] |
| 44 | (g : RiemannianMetric 3 M) |
| 45 | (hcompact : IsCompact (univ : Set M)) |
| 46 | {Z : Type*} [TopologicalSpace Z] [CompactSpace Z] |
| 47 | (Gamma : Z → C1FreeLoopSpace (M := M)) |
| 48 | (hGamma : Continuous Gamma) |
| 49 | {zeta : ℝ} (hzeta : 0 < zeta) : |
| 50 | ∃ N0 : ℕ, 0 < N0 ∧ ∀ N : ℕ, N0 ≤ N → ∀ z : Z, |
| 51 | let chord := ∑ j : Fin N, |
| 52 | (g.edist |
| 53 | (periodicFreeLoop (Gamma z) (m63CellLeft N j)) |
| 54 | (periodicFreeLoop (Gamma z) (m63CellLeft N (finRotate N j)))).toReal |
| 55 | 0 ≤ freeLoopLength g (Gamma z) - chord ∧ |
| 56 | freeLoopLength g (Gamma z) - chord < zeta := by |
| 57 | classical |
| 58 | let : CompactSpace M := isCompact_univ_iff.mp hcompact |
| 59 | let : RiemannianBundle (TangentSpace (𝓡 3) : M → Type _) := |
| 60 | ⟨g.toRiemannianMetric⟩ |
| 61 | let : IsContinuousRiemannianBundle LoopAmbient (TangentSpace (𝓡 3) : M → Type _) := |
| 62 | ⟨⟨g.inner, g.contMDiff.continuous, fun _ _ _ => rfl⟩⟩ |
| 63 | let : EMetricSpace M := EMetricSpace.ofRiemannianMetric (𝓡 3) M |
| 64 | let Y := Z × Icc (0 : ℝ) curvePeriod |
| 65 | let gamma : Z → ℝ → M := fun z => periodicFreeLoop (Gamma z) |
| 66 | let speed : Z → ℝ → ℝ := fun z t => |
| 67 | g.tangentNorm (gamma z t) (curveVelocity (gamma z) t) |
| 68 | have hP : 0 < curvePeriod := Real.two_pi_pos |
| 69 | have hgamma (z : Z) : ContMDiff 𝓘(ℝ, ℝ) (𝓡 3) 1 (gamma z) := |
| 70 | contMDiff_periodicFreeLoop (Gamma z) |
| 71 | have hperiod (z : Z) : Function.Periodic (gamma z) curvePeriod := |
| 72 | periodic_periodicFreeLoop (Gamma z) |
| 73 | have hspeed (z : Z) : Continuous (speed z) := |
| 74 | continuous_freeLoopSpeed g (Gamma z) |
| 75 | have hspeed0 (z : Z) (t : ℝ) : 0 ≤ speed z t := Real.sqrt_nonneg _ |
| 76 | have hjet : Continuous (fun w : Y => m63AngularFirstJet (gamma w.1) w.2) := |
| 77 | m63AngularFirstJet_continuous.comp |
| 78 | ((hGamma.comp continuous_fst).prodMk |
| 79 | (continuous_subtype_val.comp continuous_snd)) |
| 80 | have hvalue : Continuous (fun w : Y => gamma w.1 w.2) := |
| 81 | (FiberBundle.continuous_proj LoopAmbient (TangentSpace (𝓡 3))).comp hjet |
| 82 | have hspeedJoint : Continuous (fun w : Y => speed w.1 w.2) := |
| 83 | (hjet.inner_bundle hjet).sqrt |
| 84 | obtain ⟨S0, hS0⟩ := (isCompact_range hspeedJoint).bddAbove |
| 85 | let S : ℝ := max S0 0 |
| 86 | let L : ℝ := S + 1 |
| 87 | have hS : 0 ≤ S := le_max_right _ _ |
| 88 | have hL : 0 < L := by dsimp only [L]; positivity |
| 89 | have hSL : S ≤ L := le_add_of_nonneg_right zero_le_one |
| 90 | have hspeedBound (w : Y) : speed w.1 w.2 ≤ S := |
| 91 | (hS0 (mem_range_self w)).trans (le_max_left _ _) |
| 92 | let sigma : ℝ := min 1 (zeta / (16 * curvePeriod * L)) |
| 93 | have hsigma : 0 < sigma := lt_min zero_lt_one (div_pos hzeta (by positivity)) |
| 94 | have hsigma1 : sigma ≤ 1 := min_le_left _ _ |
| 95 | let K : ℝ≥0 := ⟨1 + sigma, by positivity⟩ |
| 96 | have hK : 1 < K := by change 1 < 1 + sigma; linarith only [hsigma] |
| 97 | have hK0 : 0 ≤ (K : ℝ) := K.2 |
| 98 | have hK2 : (K : ℝ) ≤ 2 := by change 1 + sigma ≤ 2; linarith only [hsigma1] |
| 99 | let d : ℝ := sigma * L |
| 100 | have hd : 0 < d := mul_pos hsigma hL |
| 101 | have htotal : 7 * sigma * L * curvePeriod < zeta := by |
| 102 | have h := (le_div_iff₀ (show 0 < 16 * curvePeriod * L by positivity)).mp |
| 103 | (min_le_right (1 : ℝ) (zeta / (16 * curvePeriod * L))) |
| 104 | change sigma * (16 * curvePeriod * L) ≤ zeta at h |
| 105 | nlinarith only [h, hzeta] |
| 106 | let q : M → (LoopAmbient ≃L[ℝ] LoopAmbient) → Z → ℝ → LoopAmbient := |
| 107 | fun p A z t => A ((chartAt LoopAmbient p) (gamma z t)) |
| 108 | let bvec : M → (LoopAmbient ≃L[ℝ] LoopAmbient) → Z → ℝ → LoopAmbient := |
| 109 | fun p A z t => A (mfderiv (𝓡 3) (𝓡 3) (chartAt LoopAmbient p) |
| 110 | (gamma z t) (curveVelocity (gamma z) t)) |
| 111 | have hder (p : M) (A : LoopAmbient ≃L[ℝ] LoopAmbient) |
| 112 | (z : Z) (t : ℝ) (ht : gamma z t ∈ (chartAt LoopAmbient p).source) : |
| 113 | HasDerivAt (q p A z) (bvec p A z t) t := by |
| 114 | have hc := (mdifferentiable_chart (I := 𝓡 3) p).mdifferentiableAt ht |
| 115 | have hg := (hgamma z t).mdifferentiableAt one_ne_zero |
| 116 | have hdiff := mdifferentiableAt_iff_differentiableAt.mp (hc.comp t hg) |
| 117 | have heq : deriv ((chartAt LoopAmbient p) ∘ gamma z) t = |
| 118 | mfderiv (𝓡 3) (𝓡 3) (chartAt LoopAmbient p) (gamma z t) |
| 119 | (curveVelocity (gamma z) t) := by |
| 120 | simpa +instances only [mfderiv_eq_fderiv, fderiv_apply_one_eq_deriv, curveVelocity] |
| 121 | using! mfderiv_comp_apply t hc hg (1 : ℝ) |
| 122 | have hh := hdiff.hasDerivAt |
| 123 | rw [heq] at hh |
| 124 | simpa +instances only [q, bvec, Function.comp_def] using! |
| 125 | A.toContinuousLinearMap.hasFDerivAt.comp_hasDerivAt t hh |
| 126 | -- Each cover member retains one chart, one frozen metric and actual velocity oscillation. |
| 127 | have hlocal (w : Y) : |
| 128 | ∃ p : M, ∃ A : LoopAmbient ≃L[ℝ] LoopAmbient, ∃ V : Set Y, |
| 129 | IsOpen V ∧ w ∈ V ∧ |
| 130 | (∀ v ∈ V, gamma v.1 v.2 ∈ (chartAt LoopAmbient p).source ∧ |
| 131 | speed v.1 v.2 ≤ (K : ℝ) * ‖bvec p A v.1 v.2‖) ∧ |
| 132 | (∀ v ∈ V, ∀ v' ∈ V, |
| 133 | ENNReal.ofReal ‖q p A v.1 v.2 - q p A v'.1 v'.2‖ ≤ |
| 134 | (K : ℝ≥0∞) * g.edist (gamma v.1 v.2) (gamma v'.1 v'.2)) ∧ |
| 135 | (∀ v ∈ V, ∀ v' ∈ V, ‖bvec p A v.1 v.2 - bvec p A v'.1 v'.2‖ ≤ d) := by |
| 136 | let p : M := gamma w.1 w.2 |
| 137 | let c := chartAt LoopAmbient p |
| 138 | let x0 := c p |
| 139 | have hp : p ∈ c.source := mem_chart_source LoopAmbient p |
| 140 | have hx0 : x0 ∈ c.target := c.map_source hp |
| 141 | have hc : ContMDiffOn (𝓡 3) (𝓡 3) ∞ c c.source := contMDiffOn_chart |
| 142 | have hci : ContMDiffOn (𝓡 3) (𝓡 3) ∞ c.symm c.target := contMDiffOn_chart_symm |
| 143 | have hcinj : Function.Injective (mfderiv (𝓡 3) (𝓡 3) c.symm x0) := |
| 144 | ((mdifferentiable_chart (I := 𝓡 3) p).symm.mfderiv_bijective hx0).1 |
| 145 | obtain ⟨A, hA, _hdet⟩ := g.exists_frozenPullbackEquiv hcinj |
| 146 | have hnear := g.eventually_pullbackNorm_comparison |
| 147 | (hci.contMDiffAt (c.open_target.mem_nhds hx0)) A hA hK |
| 148 | obtain ⟨U, hUopen, hxU, _hUsource, hdist⟩ := |
| 149 | g.exists_open_distortion_of_tangentNorm_comparison c.symm hci hc hx0 A hK hnear |
| 150 | obtain ⟨U1, hU1sub, hU1open, hxU1⟩ := _root_.mem_nhds_iff.mp hnear |
| 151 | let T : Set M := c.source ∩ c ⁻¹' (U ∩ U1) |
| 152 | have hTopen : IsOpen T := c.isOpen_inter_preimage (hUopen.inter hU1open) |
| 153 | have hpT : p ∈ T := ⟨hp, hxU, hxU1⟩ |
| 154 | have hsourceOpen : IsOpen {v : Y | gamma v.1 v.2 ∈ c.source} := |
| 155 | c.open_source.preimage hvalue |
| 156 | have hphase := (Proofs.M09.tangentChartPhase_continuousOn p).comp |
| 157 | hjet.continuousOn (show MapsTo (fun v : Y => m63AngularFirstJet (gamma v.1) v.2) |
| 158 | {v : Y | gamma v.1 v.2 ∈ c.source} |
| 159 | {v : TangentBundle (𝓡 3) M | v.proj ∈ c.source} from fun _ hv => hv) |
| 160 | have hb : ContinuousOn (fun v : Y => bvec p A v.1 v.2) |
| 161 | {v : Y | gamma v.1 v.2 ∈ c.source} := |
| 162 | A.continuous.comp_continuousOn hphase.snd |
| 163 | have hbAt : ContinuousAt (fun v : Y => bvec p A v.1 v.2) w := |
| 164 | hb.continuousAt (hsourceOpen.mem_nhds hp) |
| 165 | have hnb : ∀ᶠ v : Y in 𝓝 w, |
| 166 | ‖bvec p A v.1 v.2 - bvec p A w.1 w.2‖ < d / 2 := by |
| 167 | simpa only [dist_eq_norm] using Metric.tendsto_nhds.mp hbAt (d / 2) (half_pos hd) |
| 168 | obtain ⟨V, hVsub, hVopen, hwV⟩ := _root_.mem_nhds_iff.mp |
| 169 | (inter_mem (hvalue.continuousAt.preimage_mem_nhds (hTopen.mem_nhds hpT)) hnb) |
| 170 | have hVT {v : Y} (hv : v ∈ V) : gamma v.1 v.2 ∈ T := (hVsub hv).1 |
| 171 | refine ⟨p, A, V, hVopen, hwV, ?_, ?_, ?_⟩ |
| 172 | · intro v hv |
| 173 | have hvT := hVT hv |
| 174 | refine ⟨hvT.1, ?_⟩ |
| 175 | have hback : mfderiv (𝓡 3) (𝓡 3) c.symm (c (gamma v.1 v.2)) |
| 176 | (mfderiv (𝓡 3) (𝓡 3) c (gamma v.1 v.2) (curveVelocity (gamma v.1) v.2)) = |
| 177 | curveVelocity (gamma v.1) v.2 := by |
| 178 | exact congrArg |
| 179 | (fun L : TangentSpace (𝓡 3) (gamma v.1 v.2) →L[ℝ] |
| 180 | TangentSpace (𝓡 3) (gamma v.1 v.2) => L (curveVelocity (gamma v.1) v.2)) |
| 181 | ((mdifferentiable_chart (I := 𝓡 3) p).symm_comp_deriv hvT.1) |
| 182 | have htangent := (hU1sub hvT.2.2 |
| 183 | (mfderiv (𝓡 3) (𝓡 3) c (gamma v.1 v.2) (curveVelocity (gamma v.1) v.2))).2 |
| 184 | rw [hback, c.left_inv hvT.1] at htangent |
| 185 | exact htangent |
| 186 | · intro v hv v' hv' |
| 187 | have h := (hdist _ (hVT hv).2.1 _ (hVT hv').2.1).2 |
| 188 | simpa only [c.left_inv (hVT hv).1, c.left_inv (hVT hv').1, |
| 189 | edist_dist, dist_eq_norm] using h |
| 190 | · intro v hv v' hv' |
| 191 | have h1 : ‖bvec p A v.1 v.2 - bvec p A w.1 w.2‖ < d / 2 := (hVsub hv).2 |
| 192 | have h2 : ‖bvec p A v'.1 v'.2 - bvec p A w.1 w.2‖ < d / 2 := (hVsub hv').2 |
| 193 | have htri := norm_sub_le_norm_sub_add_norm_sub |
| 194 | (bvec p A v.1 v.2) (bvec p A w.1 w.2) (bvec p A v'.1 v'.2) |
| 195 | rw [norm_sub_rev (bvec p A w.1 w.2)] at htri |
| 196 | linarith only [htri, h1, h2] |
| 197 | choose p A V hVopen hVself hVspeed hVdist hVosc using hlocal |
| 198 | obtain ⟨delta, hdelta, hcover⟩ := m64_compact_product_cover_vertical_radius |
| 199 | (V := fun w : Y => V w) hVopen hVself |
| 200 | have hshort (z : Z) {s t : ℝ} |
| 201 | (hs : 0 ≤ s) (hst : s ≤ t) (ht : t ≤ curvePeriod) (hell : t - s < delta) : |
| 202 | let I := ∫ u in s..t, speed z u |
| 203 | let D := (g.edist (gamma z s) (gamma z t)).toReal |
| 204 | 0 ≤ I - D ∧ I - D ≤ 7 * sigma * L * (t - s) := by |
| 205 | let ws : Y := (z, ⟨s, hs, hst.trans ht⟩) |
| 206 | obtain ⟨w, hw⟩ := hcover ws |
| 207 | have hcell (u : ℝ) (hu : u ∈ Icc s t) : |
| 208 | (z, (⟨u, hs.trans hu.1, hu.2.trans ht⟩ : Icc (0 : ℝ) curvePeriod)) ∈ V w := by |
| 209 | have hdiff : |u - s| < delta := by |
| 210 | rw [abs_of_nonneg (sub_nonneg.mpr hu.1)] |
| 211 | exact (sub_le_sub_right hu.2 s).trans_lt hell |
| 212 | apply hw |
| 213 | change |u - s| < delta |
| 214 | exact hdiff |
| 215 | let Q : ℝ → LoopAmbient := q (p w) (A w) z |
| 216 | let B : ℝ → LoopAmbient := bvec (p w) (A w) z |
| 217 | have hQ (u : ℝ) (hu : u ∈ Icc s t) : HasDerivAt Q (B u) u := |
| 218 | hder (p w) (A w) z u (hVspeed w _ (hcell u hu)).1 |
| 219 | have hB (u : ℝ) (hu : u ∈ Icc s t) : ‖B u - B s‖ ≤ d := by |
| 220 | simpa +instances only [B] using! |
| 221 | hVosc w _ (hcell u hu) _ (hcell s ⟨le_rfl, hst⟩) |
| 222 | have hrem : ‖Q t - Q s - (t - s) • B s‖ ≤ d * (t - s) := by |
| 223 | have hmean := norm_image_sub_le_of_norm_deriv_le_segment' |
| 224 | (a := s) (b := t) (f := fun u => Q u - (u - s) • B s) |
| 225 | (f' := fun u => B u - B s) (C := d) |
| 226 | (fun u hu => by |
| 227 | have hh := (hQ u hu).sub (((hasDerivAt_id u).sub_const s).smul_const (B s)) |
| 228 | simpa +instances only [one_smul, Pi.sub_apply, id_eq] using! hh.hasDerivWithinAt) |
| 229 | (fun u hu => hB u (Ico_subset_Icc_self hu)) t ⟨hst, le_rfl⟩ |
| 230 | have heq : (Q t - (t - s) • B s) - (Q s - (s - s) • B s) = |
| 231 | Q t - Q s - (t - s) • B s := by simp only [sub_self, zero_smul, sub_zero]; abel |
| 232 | rwa [heq] at hmean |
| 233 | let I : ℝ := ∫ u in s..t, speed z u |
| 234 | let D : ℝ := (g.edist (gamma z s) (gamma z t)).toReal |
| 235 | have hI0 : 0 ≤ I := intervalIntegral.integral_nonneg hst (fun u _ => hspeed0 z u) |
| 236 | have hD0 : 0 ≤ D := ENNReal.toReal_nonneg |
| 237 | have hpath : g.edist (gamma z s) (gamma z t) ≤ ENNReal.ofReal I := by |
| 238 | have h := g.edist_le_pathELength_of_mem_Icc (hgamma z).contMDiffOn |
| 239 | (show t ∈ Icc s t from ⟨hst, le_rfl⟩) |
| 240 | rw [M04.pathELength_eq_ofReal_integral_pathSpeed g (hgamma z) hst] at h |
| 241 | exact h |
| 242 | have hfinite : g.edist (gamma z s) (gamma z t) ≠ ⊤ := |
| 243 | ne_top_of_le_ne_top ENNReal.ofReal_ne_top hpath |
| 244 | have hDI : D ≤ I := by |
| 245 | have h := ENNReal.toReal_mono ENNReal.ofReal_ne_top hpath |
| 246 | simpa only [ENNReal.toReal_ofReal hI0] using h |
| 247 | have hIS : I ≤ S * (t - s) := by |
| 248 | have h := intervalIntegral.integral_mono_on (μ := volume) hst |
| 249 | ((hspeed z).intervalIntegrable s t) (continuous_const.intervalIntegrable s t) |
| 250 | (fun u hu => hspeedBound (z, ⟨u, hs.trans hu.1, hu.2.trans ht⟩)) |
| 251 | simpa only [intervalIntegral.integral_const, smul_eq_mul, mul_comm] using h |
| 252 | have hcoord : ‖Q t - Q s‖ ≤ (K : ℝ) * D := by |
| 253 | have h := hVdist w _ (hcell t ⟨hst, le_rfl⟩) _ (hcell s ⟨le_rfl, hst⟩) |
| 254 | have hedist : g.edist (gamma z t) (gamma z s) = g.edist (gamma z s) (gamma z t) := |
| 255 | Manifold.riemannianEDist_comm |
| 256 | rw [hedist] at h |
| 257 | have hr := ENNReal.toReal_mono (ENNReal.mul_ne_top ENNReal.coe_ne_top hfinite) h |
| 258 | simpa only [ENNReal.toReal_ofReal (norm_nonneg _), ENNReal.toReal_mul, |
| 259 | ENNReal.coe_toReal] using hr |
| 260 | have hB0 : (t - s) * ‖B s‖ ≤ (K : ℝ) * D + d * (t - s) := by |
| 261 | have htri := norm_add_le (Q t - Q s) ((t - s) • B s - (Q t - Q s)) |
| 262 | have heq : (Q t - Q s) + ((t - s) • B s - (Q t - Q s)) = |
| 263 | (t - s) • B s := by abel |
| 264 | rw [heq, norm_smul, Real.norm_eq_abs, |
| 265 | abs_of_nonneg (sub_nonneg.mpr hst)] at htri |
| 266 | have herr : ‖(t - s) • B s - (Q t - Q s)‖ ≤ d * (t - s) := by |
| 267 | calc |
| 268 | _ = ‖Q t - Q s - (t - s) • B s‖ := norm_sub_rev _ _ |
| 269 | _ ≤ _ := hrem |
| 270 | exact htri.trans (add_le_add hcoord herr) |
| 271 | have hvK (u : ℝ) (hu : u ∈ Icc s t) : speed z u ≤ (K : ℝ) * (‖B s‖ + d) := by |
| 272 | have hn := norm_add_le (B u - B s) (B s) |
| 273 | rw [sub_add_cancel] at hn |
| 274 | have hb : ‖B u‖ ≤ ‖B s‖ + d := by linarith only [hn, hB u hu] |
| 275 | exact (hVspeed w _ (hcell u hu)).2.trans (mul_le_mul_of_nonneg_left hb hK0) |
| 276 | have hIK : I ≤ (K : ℝ) * (‖B s‖ + d) * (t - s) := by |
| 277 | have h := intervalIntegral.integral_mono_on (μ := volume) hst |
| 278 | ((hspeed z).intervalIntegrable s t) (continuous_const.intervalIntegrable s t) hvK |
| 279 | simpa only [intervalIntegral.integral_const, smul_eq_mul, mul_comm] using h |
| 280 | have hdeficit : I - D ≤ ((K : ℝ) ^ 2 - 1) * D + 2 * (K : ℝ) * d * (t - s) := by |
| 281 | have h := mul_le_mul_of_nonneg_left hB0 hK0 |
| 282 | nlinarith only [hIK, h] |
| 283 | have hKsq : (K : ℝ) ^ 2 - 1 ≤ 3 * sigma := by |
| 284 | have hsq := mul_le_mul_of_nonneg_left hsigma1 hsigma.le |
| 285 | change (1 + sigma) ^ 2 - 1 ≤ 3 * sigma |
| 286 | nlinarith only [hsq] |
| 287 | have hfirst : ((K : ℝ) ^ 2 - 1) * D ≤ 3 * sigma * S * (t - s) := by |
| 288 | calc |
| 289 | _ ≤ (3 * sigma) * D := mul_le_mul_of_nonneg_right hKsq hD0 |
| 290 | _ ≤ (3 * sigma) * (S * (t - s)) := |
| 291 | mul_le_mul_of_nonneg_left (hDI.trans hIS) (by positivity) |
| 292 | _ = _ := by ring |
| 293 | have hsecond : 2 * (K : ℝ) * d * (t - s) ≤ 4 * sigma * L * (t - s) := by |
| 294 | have h := mul_le_mul_of_nonneg_right hK2 (mul_nonneg hd.le (sub_nonneg.mpr hst)) |
| 295 | dsimp only [d] at h ⊢ |
| 296 | nlinarith only [h] |
| 297 | refine ⟨sub_nonneg.mpr hDI, hdeficit.trans ?_⟩ |
| 298 | have hSL' := mul_le_mul_of_nonneg_left hSL |
| 299 | (show 0 ≤ 3 * sigma * (t - s) by positivity) |
| 300 | nlinarith only [hfirst, hsecond, hSL'] |
| 301 | obtain ⟨N0, hN0⟩ := exists_nat_gt (max 1 (curvePeriod / delta)) |
| 302 | have hN0pos : 0 < N0 := by |
| 303 | have h : (0 : ℝ) < N0 := zero_lt_one.trans ((le_max_left _ _).trans_lt hN0) |
| 304 | exact_mod_cast h |
| 305 | refine ⟨N0, hN0pos, ?_⟩ |
| 306 | intro N hN z |
| 307 | have hNpos : 0 < N := hN0pos.trans_le hN |
| 308 | have hell : 0 < m63CellLength N := m63CellLength_pos hNpos |
| 309 | have hmesh : m63CellLength N < delta := by |
| 310 | change curvePeriod / (N : ℝ) < delta |
| 311 | have h0 := (div_lt_iff₀ hdelta).mp ((le_max_right _ _).trans_lt hN0) |
| 312 | have hcast : (N0 : ℝ) ≤ N := by exact_mod_cast hN |
| 313 | apply (div_lt_iff₀ (show (0 : ℝ) < N by exact_mod_cast hNpos)).mpr |
| 314 | exact h0.trans_le (by nlinarith only [mul_le_mul_of_nonneg_right hcast hdelta.le]) |
| 315 | have hcell (j : Fin N) : |
| 316 | 0 ≤ (∫ u in m63CellLeft N j..m63CellLeft N j + m63CellLength N, speed z u) - |
| 317 | (g.edist (gamma z (m63CellLeft N j)) |
| 318 | (gamma z (m63CellLeft N (finRotate N j)))).toReal ∧ |
| 319 | (∫ u in m63CellLeft N j..m63CellLeft N j + m63CellLength N, speed z u) - |
| 320 | (g.edist (gamma z (m63CellLeft N j)) |
| 321 | (gamma z (m63CellLeft N (finRotate N j)))).toReal ≤ |
| 322 | 7 * sigma * L * m63CellLength N := by |
| 323 | have hs : 0 ≤ m63CellLeft N j := mul_nonneg (Nat.cast_nonneg _) hell.le |
| 324 | have horder : m63CellLeft N j ≤ m63CellLeft N j + m63CellLength N := |
| 325 | le_add_of_nonneg_right hell.le |
| 326 | have hright : m63CellLeft N j + m63CellLength N ≤ curvePeriod := by |
| 327 | have hcast : (j.val : ℝ) + 1 ≤ N := by exact_mod_cast Nat.succ_le_of_lt j.isLt |
| 328 | calc |
| 329 | _ = ((j.val : ℝ) + 1) * m63CellLength N := by dsimp only [m63CellLeft]; ring |
| 330 | _ ≤ (N : ℝ) * m63CellLength N := mul_le_mul_of_nonneg_right hcast hell.le |
| 331 | _ = curvePeriod := m63_count_mul_cellLength hNpos |
| 332 | have hh := hshort z hs horder hright (by simpa only [add_sub_cancel_left] using hmesh) |
| 333 | rw [m63PeriodicLoop_cell_finish (hperiod z) hNpos j] |
| 334 | simpa only [add_sub_cancel_left] using hh |
| 335 | have hsum : (∑ j : Fin N, |
| 336 | ∫ u in m63CellLeft N j..m63CellLeft N j + m63CellLength N, speed z u) = |
| 337 | freeLoopLength g (Gamma z) := by |
| 338 | have htel := intervalIntegral.sum_integral_adjacent_intervals |
| 339 | (a := fun k : ℕ => (k : ℝ) * m63CellLength N) (n := N) (μ := volume) |
| 340 | (fun _ _ => (hspeed z).intervalIntegrable _ _) |
| 341 | rw [← Fin.sum_univ_eq_sum_range] at htel |
| 342 | simpa only [m63CellLeft, Nat.cast_add, Nat.cast_one, add_mul, one_mul, |
| 343 | Nat.cast_zero, zero_mul, m63_count_mul_cellLength hNpos, curvePeriod, |
| 344 | freeLoopLength, rampPeriod, speed, gamma] using htel |
| 345 | have hsumLength : (∑ _j : Fin N, m63CellLength N) = curvePeriod := by |
| 346 | simpa only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, |
| 347 | curvePeriod] |
| 348 | using m63_count_mul_cellLength hNpos |
| 349 | have hnon := Finset.sum_nonneg (fun j (_hj : j ∈ (Finset.univ : Finset (Fin N))) => |
| 350 | (hcell j).1) |
| 351 | have hle := Finset.sum_le_sum (fun j (_hj : j ∈ (Finset.univ : Finset (Fin N))) => |
| 352 | (hcell j).2) |
| 353 | rw [Finset.sum_sub_distrib, hsum] at hnon hle |
| 354 | rw [← Finset.mul_sum, hsumLength] at hle |
| 355 | exact ⟨hnon, hle.trans_lt htotal⟩ |
| 356 | |
| 357 | end PoincareMT |