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.CurveShortening.Connection.Pullback |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Mul |
| 3 | |
| 4 | /-! |
| 5 | # Germ congruence and the scalar pullback product rule |
| 6 | |
| 7 | These rules apply to the actual selected-frame derivative in MT2007 |
| 8 | Lemma 19.6, pp. 441-442, and correction Lemma 0.1, p. 3. Germ congruence |
| 9 | does not infer differentiability. The scalar rule has derivative witnesses. |
| 10 | See `references/ricci-flow/mapher/curve-evolution/derivations/2026-09-19-pullback-algebra.md`. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option maxSynthPendingDepth 3 |
| 15 | set_option backward.isDefEq.respectTransparency false |
| 16 | |
| 17 | open scoped Manifold ContDiff Bundle Topology |
| 18 | open Filter |
| 19 | |
| 20 | universe u |
| 21 | |
| 22 | namespace PoincareMT.M62 |
| 23 | |
| 24 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 25 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 26 | |
| 27 | /-- Parameter-germ equality preserves the actual frozen pullback derivative. |
| 28 | Correction connection calculus, pp. 2-3; this asserts no derivative witness. -/ |
| 29 | theorem pullback_congr {g : RiemannianMetric n M} |
| 30 | (D : LeviCivitaData g) {γ : ℝ → M} |
| 31 | {Y Z : (r : ℝ) → TangentSpace (𝓡 n) (γ r)} {x : ℝ} |
| 32 | (h : ∀ᶠ r in 𝓝 x, Y r = Z r) : |
| 33 | rampHorizontalCovariantDerivative D γ Y x = |
| 34 | rampHorizontalCovariantDerivative D γ Z x := by |
| 35 | let e := trivializationAt (EuclideanSpace ℝ (Fin n)) (TangentSpace (𝓡 n)) (γ x) |
| 36 | have hx : Y x = Z x := h.self_of_nhds |
| 37 | have heq : (fun r ↦ (e ⟨γ r, Y r⟩).2) =ᶠ[𝓝 x] |
| 38 | (fun r ↦ (e ⟨γ r, Z r⟩).2) := by |
| 39 | filter_upwards [h] with r hr |
| 40 | rw [hr] |
| 41 | change e.symmL ℝ (γ x) (deriv (fun r ↦ (e ⟨γ r, Y r⟩).2) x) + |
| 42 | D.connection (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) (Y x)) |
| 43 | (γ x) (curveVelocity γ x) = _ |
| 44 | rw [heq.deriv_eq, hx] |
| 45 | rfl |
| 46 | |
| 47 | /-- The scalar Leibniz rule for the actual pullback connection. |
| 48 | MT2007 Lemma 19.6, pp. 441-442; correction Lemma 0.1, p. 3. -/ |
| 49 | theorem pullback_smul {g : RiemannianMetric n M} |
| 50 | (D : LeviCivitaData g) {γ : ℝ → M} |
| 51 | {Y : (r : ℝ) → TangentSpace (𝓡 n) (γ r)} {f : ℝ → ℝ} |
| 52 | {x f' : ℝ} (hf : HasDerivAt f f' x) |
| 53 | (hY : MDifferentiableAt (𝓘(ℝ, ℝ)) ((𝓡 n).prod (𝓡 n)) |
| 54 | (fun r ↦ (⟨γ r, Y r⟩ : TangentBundle (𝓡 n) M)) x) : |
| 55 | rampHorizontalCovariantDerivative D γ (fun r ↦ f r • Y r) x = |
| 56 | f' • Y x + f x • rampHorizontalCovariantDerivative D γ Y x := by |
| 57 | let e := trivializationAt (EuclideanSpace ℝ (Fin n)) (TangentSpace (𝓡 n)) (γ x) |
| 58 | have hp : γ x ∈ e.baseSet := FiberBundle.mem_baseSet_trivializationAt' (γ x) |
| 59 | let y : ℝ → EuclideanSpace ℝ (Fin n) := fun r ↦ (e ⟨γ r, Y r⟩).2 |
| 60 | rw [mdifferentiableAt_totalSpace] at hY |
| 61 | have hy : DifferentiableAt ℝ y x := hY.2.differentiableAt |
| 62 | have hnear : ∀ᶠ r in 𝓝 x, γ r ∈ e.baseSet := |
| 63 | hY.1.continuousAt (e.open_baseSet.mem_nhds hp) |
| 64 | have heq : (fun r ↦ (e ⟨γ r, f r • Y r⟩).2) =ᶠ[𝓝 x] |
| 65 | (fun r ↦ f r • y r) := by |
| 66 | filter_upwards [hnear] with r hr |
| 67 | change (e ⟨γ r, f r • Y r⟩).2 = f r • (e ⟨γ r, Y r⟩).2 |
| 68 | rw [← e.continuousLinearMapAt_apply_of_mem ℝ hr, |
| 69 | ← e.continuousLinearMapAt_apply_of_mem ℝ hr, map_smul] |
| 70 | have hd : deriv (fun r ↦ (e ⟨γ r, f r • Y r⟩).2) x = |
| 71 | f' • y x + f x • deriv y x := by |
| 72 | rw [heq.deriv_eq, deriv_fun_smul hf.differentiableAt hy, hf.deriv, add_comm] |
| 73 | have hrep : e.symmL ℝ (γ x) (y x) = Y x := by |
| 74 | change e.symmL ℝ (γ x) (e ⟨γ x, Y x⟩).2 = Y x |
| 75 | rw [← e.continuousLinearMapAt_apply_of_mem ℝ hp] |
| 76 | exact e.symmL_continuousLinearMapAt hp _ |
| 77 | let A := PoincareMT.ReducedLengthMinimum.Variation.Geometry.frozenConnectionEndomorphism D (γ x) (curveVelocity γ x) |
| 78 | change e.symmL ℝ (γ x) (deriv (fun r ↦ (e ⟨γ r, f r • Y r⟩).2) x) + |
| 79 | A (f x • Y x) = |
| 80 | f' • Y x + f x • (e.symmL ℝ (γ x) (deriv y x) + A (Y x)) |
| 81 | rw [hd, map_add, map_smul, map_smul, map_smul, hrep, smul_add, add_assoc] |
| 82 | |
| 83 | end PoincareMT.M62 |