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.RicciFlow.ReducedGeometry.ReducedLength.Variation.Differential.SmoothSquareFirstVariation |
| 2 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Action.SmoothSquareAction |
| 3 | |
| 4 | /-! |
| 5 | # The actual differential of a smooth comparison action |
| 6 | |
| 7 | Restriction to affine parameter lines reduces the Frechet derivative to |
| 8 | the reviewed first variation, with both endpoint momenta retained. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | set_option maxSynthPendingDepth 3 |
| 13 | set_option maxHeartbeats 800000 |
| 14 | |
| 15 | open scoped Manifold ContDiff Bundle Topology |
| 16 | open Filter |
| 17 | |
| 18 | universe u |
| 19 | |
| 20 | namespace PoincareMT.ReducedLength |
| 21 | |
| 22 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 23 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 24 | {J : Set ℝ} {F : RicciFlow n M J} {T τmax : ℝ} {p : M} |
| 25 | {E : Type} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] |
| 26 | |
| 27 | set_option backward.isDefEq.respectTransparency false in |
| 28 | theorem fderiv_smoothSquareFamily_action [ConnectedSpace M] |
| 29 | (hM04 : RicciFlowCurvatureTheory.{u}) (hL : LGeodesicTheory F T τmax) |
| 30 | (hτmax : 0 < τmax) (hwindow : Set.Icc (T - τmax) T ⊆ J) |
| 31 | (A : LExponentialFamily F T τmax p) (Z : TangentSpace (𝓡 n) p) |
| 32 | (b : ℝ) (hb : 0 < b) (hmax : b < τmax) |
| 33 | (f : E × ℝ → M) (U : Set (E × ℝ)) (hU : IsOpen U) |
| 34 | (hf : ContMDiffOn (𝓘(ℝ, E × ℝ)) (𝓡 n) ∞ f U) |
| 35 | (x0 v : E) (hsegment : ∀ s ∈ Set.Icc 0 (Real.sqrt b), (x0, s) ∈ U) |
| 36 | (hcenter : ∀ s ∈ Set.Icc 0 (Real.sqrt b), f (x0, s) = A.squareFamily Z s) : |
| 37 | fderiv ℝ (fun x ↦ backwardLLength F T 0 b (fun t ↦ f (x, Real.sqrt t))) x0 v = |
| 38 | (F.metric (T - b)).inner (A.squareFamily Z (Real.sqrt b)) |
| 39 | (curveVelocity (A.squareFamily Z) (Real.sqrt b)) |
| 40 | (curveVelocity (fun r ↦ f (x0 + r • v, Real.sqrt b)) 0) - |
| 41 | (F.metric T).inner p ((2 : ℝ) • Z) |
| 42 | (curveVelocity (fun r ↦ f (x0 + r • v, 0)) 0) := by |
| 43 | let B : E → ℝ := fun x ↦ backwardLLength F T 0 b (fun t ↦ f (x, Real.sqrt t)) |
| 44 | have hsmooth : ContDiffAt ℝ ∞ B x0 := by |
| 45 | have h := contDiffAt_smoothSquareFamily_action F hM04 T τmax hτmax hwindow |
| 46 | f U hU hf (x0, b) ⟨hb, hmax⟩ (fun r hr ↦ hsegment _ |
| 47 | ⟨mul_nonneg (Real.sqrt_nonneg b) hr.1, |
| 48 | mul_le_of_le_one_right (Real.sqrt_nonneg b) hr.2⟩) |
| 49 | exact h.comp x0 (contDiffAt_id.prodMk contDiffAt_const) |
| 50 | have hline : HasDerivAt (fun r : ℝ ↦ x0 + r • v) v 0 := by |
| 51 | simpa only [id_eq, one_smul] using ((hasDerivAt_id (0 : ℝ)).smul_const v).const_add x0 |
| 52 | have hactual : HasDerivAt (fun r : ℝ ↦ B (x0 + r • v)) (fderiv ℝ B x0 v) 0 := by |
| 53 | have hB : DifferentiableAt ℝ B (x0 + (0 : ℝ) • v) := by |
| 54 | simpa only [zero_smul, add_zero] using hsmooth.differentiableAt (by simp) |
| 55 | simpa only [Function.comp_def, zero_smul, add_zero] using |
| 56 | hB.hasFDerivAt.comp_hasDerivAt (0 : ℝ) hline |
| 57 | let k : ℝ × ℝ → E × ℝ := fun z ↦ (x0 + z.2 • v, z.1) |
| 58 | let U' := k ⁻¹' U |
| 59 | have hk : ContDiff ℝ ∞ k := |
| 60 | (contDiff_const.add (contDiff_snd.smul contDiff_const)).prodMk contDiff_fst |
| 61 | have hU' : IsOpen U' := hU.preimage hk.continuous |
| 62 | have hf' : ContMDiffOn ((𝓘(ℝ, ℝ)).prod (𝓘(ℝ, ℝ))) (𝓡 n) ∞ (f ∘ k) U' := by |
| 63 | convert! hf.comp hk.contMDiff.contMDiffOn (fun _ hz ↦ hz) using 1 <;> |
| 64 | simp only [modelWithCornersSelf_prod, chartedSpaceSelf_prod] |
| 65 | have hnear : ∀ᶠ r in 𝓝 (0 : ℝ), ∀ s ∈ Set.Icc 0 (Real.sqrt b), (s, r) ∈ U' := by |
| 66 | apply isCompact_Icc.eventually_forall_of_forall_eventually |
| 67 | intro s hs |
| 68 | have hmem : (s, (0 : ℝ)) ∈ U' := by |
| 69 | simpa only [U', Set.mem_preimage, k, zero_smul, add_zero] using hsegment s hs |
| 70 | exact continuous_swap.continuousAt.preimage_mem_nhds (hU'.mem_nhds hmem) |
| 71 | obtain ⟨ρ, hρ, hρsub⟩ := Metric.mem_nhds_iff.mp hnear |
| 72 | have hbox : Set.Icc 0 (Real.sqrt b) ×ˢ Set.Ioo (-ρ) ρ ⊆ U' := by |
| 73 | intro z hz |
| 74 | apply hρsub (show z.2 ∈ Metric.ball (0 : ℝ) ρ from ?_) z.1 hz.1 |
| 75 | simpa only [Metric.mem_ball, Real.dist_eq, sub_zero, abs_lt, Set.mem_Ioo] using hz.2 |
| 76 | have hc : ∀ s ∈ Set.Icc 0 (Real.sqrt b), (f ∘ k) (s, 0) = A.squareFamily Z s := by |
| 77 | intro s hs |
| 78 | simpa only [Function.comp_apply, k, zero_smul, add_zero] using hcenter s hs |
| 79 | have hfirst := hasDerivAt_smoothSquareFamily_action hM04 hL hτmax hwindow |
| 80 | A Z b hb hmax (f ∘ k) U' hU' hf' ρ hρ hbox hc |
| 81 | exact hactual.unique hfirst |
| 82 | |
| 83 | end PoincareMT.ReducedLength |