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.Generalized.Gauge.MetricDerivative.Time |
| 2 | import PoincareLib.Geometry.RicciFlow.Generalized.Gauge.MetricDerivative.ProductRule |
| 3 | import PoincareLib.Geometry.RicciFlow.Generalized.Gauge.SectionTransport |
| 4 | import PoincareLib.Geometry.Spacetime.Horizontal.Connection |
| 5 | |
| 6 | /-! |
| 7 | # Metric differentiation under a moving gauge |
| 8 | |
| 9 | The horizontal metric defect and the transported connection identify the |
| 10 | derivative of the actual pullback metric. The two derivatives of the pulled |
| 11 | back sections cancel, leaving the negative spatial metric Lie derivative. |
| 12 | |
| 13 | The product-rule argument follows the inspected AxelWorkspace theorem |
| 14 | `MorganTianLib.hasDerivWithinAt_gaugePullbackValue_of_jointSmooth`, revision |
| 15 | `f1cdb30cabdc8781d2d3dec86d3d99ab1820f30e`. Here local section transport replaces |
| 16 | global diffeomorphisms, and normalized interval tangents treat endpoints. |
| 17 | |
| 18 | Source: Morgan--Tian, Definition 1.4, pp. 5--7, and Definitions 3.34--3.38, |
| 19 | Remark 3.37, pp. 59--61. |
| 20 | -/ |
| 21 | |
| 22 | set_option autoImplicit false |
| 23 | set_option backward.isDefEq.respectTransparency false |
| 24 | set_option synthInstance.maxHeartbeats 100000 |
| 25 | |
| 26 | open scoped Manifold ContDiff Bundle Topology |
| 27 | open Set Filter Bundle |
| 28 | |
| 29 | universe u v |
| 30 | |
| 31 | namespace PoincareMT |
| 32 | |
| 33 | variable {n : ℕ} {X : Type u} [TopologicalSpace X] {time : X → ℝ} |
| 34 | {I K : SpacetimeInterval} {F : GeneralizedFlowSpacetime n X time I} |
| 35 | {S : ∀ s : ℝ, SpacetimeSliceGeometry F s} |
| 36 | {T : SmoothSpacetimeInterval K} {C : Type v} [TopologicalSpace C] |
| 37 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) C] [IsManifold (𝓡 n) ∞ C] |
| 38 | {e : MovingSpacetimeGauge F T C} |
| 39 | |
| 40 | private theorem movingGaugeTimeVelocity_time |
| 41 | (e : MovingSpacetimeGauge F T C) (t : T.Point) (x : C) : |
| 42 | (show ℝ from mfderiv (spacetimeModel n) 𝓘(ℝ) F.timeFunction |
| 43 | (e.toSpacetime (t, x)) (movingGaugeTimeVelocity e t x)) = 1 := by |
| 44 | let : ChartedSpace (ModelProd (EuclideanHalfSpace 1) |
| 45 | (EuclideanSpace ℝ (Fin n))) F.Point := F.chartedSpace |
| 46 | let : IsManifold (spacetimeModel n) ∞ F.Point := F.isManifold |
| 47 | have hd := movingGauge_hasDerivWithinAt_comp e (f := F.timeFunction) t x |
| 48 | (F.time_smooth.mdifferentiableAt (by simp)) |
| 49 | have heq (s : ℝ) (hs : s ∈ K.domain) : |
| 50 | s = F.timeFunction (e.toSpacetime (T.realParam s, x)) := by |
| 51 | rw [e.time_eq, T.realParam_val hs] |
| 52 | have h := hd.congr heq (heq t.val t.property) |
| 53 | exact (uniqueDiffWithinAt_of_spacetimeInterval K t).eq_deriv K.domain h |
| 54 | (hasDerivWithinAt_id t.val K.domain) |
| 55 | |
| 56 | private theorem movingGauge_metric_derivative_on_sections |
| 57 | (D : LeafwiseLeviCivitaFamily F S) (G : MovingSpacetimeGaugeGeometry e) |
| 58 | (c : MetricLeviCivitaFamily G.metric) |
| 59 | (V W : HorizontalSection F) (O : Set F.Point) (hO : IsOpen O) |
| 60 | (hV : IsSmoothHorizontalSectionOn F V O) |
| 61 | (hW : IsSmoothHorizontalSectionOn F W O) |
| 62 | (t : T.Point) (x : C) (hp : e.toSpacetime (t, x) ∈ O) : |
| 63 | HasDerivWithinAt |
| 64 | (fun s => (G.metric s).inner x |
| 65 | (pullbackHorizontalSection G V t x) (pullbackHorizontalSection G W t x)) |
| 66 | (horizontalMetricLieDerivative F (e.toSpacetime (t, x)) |
| 67 | (V (e.toSpacetime (t, x))) (W (e.toSpacetime (t, x))) - |
| 68 | ordinaryMetricLieDerivative (G.metric t.val) (c t.val) (movingGaugeDrift G t) x |
| 69 | (pullbackHorizontalSection G V t x) (pullbackHorizontalSection G W t x)) |
| 70 | K.domain t.val := by |
| 71 | let : ChartedSpace (ModelProd (EuclideanHalfSpace 1) |
| 72 | (EuclideanSpace ℝ (Fin n))) F.Point := F.chartedSpace |
| 73 | let : IsManifold (spacetimeModel n) ∞ F.Point := F.isManifold |
| 74 | have hVd := (hV.contMDiffAt (hO.mem_nhds hp)).mdifferentiableAt (by simp) |
| 75 | have hWd := (hW.contMDiffAt (hO.mem_nhds hp)).mdifferentiableAt (by simp) |
| 76 | have hpair := (F.horizontalMetric.contMDiff _).mdifferentiableAt (by simp) |
| 77 | |>.clm_bundle_apply₂ (F₃ := ℝ) (E₃ := fun _ : F.Point => ℝ) hVd hWd |
| 78 | rw [mdifferentiableAt_totalSpace] at hpair |
| 79 | have hpair' : MDifferentiableAt (spacetimeModel n) 𝓘(ℝ) |
| 80 | (fun q => F.horizontalMetric.inner q (V q) (W q)) (e.toSpacetime (t, x)) := hpair.2 |
| 81 | have hpder := movingGauge_hasDerivWithinAt_comp e t x hpair' |
| 82 | have hunique := uniqueDiffWithinAt_of_spacetimeInterval K t |
| 83 | have ha := movingGauge_hasDerivWithinAt_pullbackSection e G V O hO hV t x hp |
| 84 | have hb := movingGauge_hasDerivWithinAt_pullbackSection e G W O hO hW t x hp |
| 85 | have hprod := movingMetric_hasDerivWithinAt_pair G.smooth t.property hunique x ha hb |
| 86 | have heq (s : ℝ) (hs : s ∈ K.domain) : |
| 87 | (G.metric s).inner x (pullbackHorizontalSection G V (T.realParam s) x) |
| 88 | (pullbackHorizontalSection G W (T.realParam s) x) = |
| 89 | F.horizontalMetric.inner (e.toSpacetime (T.realParam s, x)) |
| 90 | (V (e.toSpacetime (T.realParam s, x))) |
| 91 | (W (e.toSpacetime (T.realParam s, x))) := by |
| 92 | have hm := G.metric_eq (T.realParam s) x |
| 93 | (pullbackHorizontalSection G V (T.realParam s) x) |
| 94 | (pullbackHorizontalSection G W (T.realParam s) x) |
| 95 | rw [T.realParam_val hs] at hm |
| 96 | simpa only [pullbackHorizontalSection, ContinuousLinearEquiv.apply_symm_apply] using hm |
| 97 | have hpder' := hpder.congr heq (heq t.val t.property) |
| 98 | have heval := hunique.eq_deriv K.domain hpder' hprod |
| 99 | simp only [T.realParam_coe] at heval |
| 100 | have hdefect := rawHorizontalCovariantDerivative_metric_defect D hVd hWd |
| 101 | (movingGaugeTimeVelocity e t x) |
| 102 | rw [movingGaugeTimeVelocity_time e t x, one_mul] at hdefect |
| 103 | have htransport := movingGaugeSectionTransportFields D e G c |
| 104 | have hconnV := htransport.horizontal_derivative_eq V O hO hV t x hp 1 0 |
| 105 | have hconnW := htransport.horizontal_derivative_eq W O hO hW t x hp 1 0 |
| 106 | simp only [one_smul, map_zero, add_zero] at hconnV hconnW |
| 107 | change rawHorizontalCovariantDerivative D V (e.toSpacetime (t, x)) |
| 108 | (movingGaugeTimeVelocity e t x) = _ at hconnV |
| 109 | change rawHorizontalCovariantDerivative D W (e.toSpacetime (t, x)) |
| 110 | (movingGaugeTimeVelocity e t x) = _ at hconnW |
| 111 | rw [hconnV, hconnW] at hdefect |
| 112 | have hVval : V (e.toSpacetime (t, x)) = |
| 113 | G.spatialTangentEquiv t x (pullbackHorizontalSection G V t x) := by |
| 114 | simp only [pullbackHorizontalSection, ContinuousLinearEquiv.apply_symm_apply] |
| 115 | have hWval : W (e.toSpacetime (t, x)) = |
| 116 | G.spatialTangentEquiv t x (pullbackHorizontalSection G W t x) := by |
| 117 | simp only [pullbackHorizontalSection, ContinuousLinearEquiv.apply_symm_apply] |
| 118 | rw [hWval, ← G.metric_eq, hVval, ← G.metric_eq] at hdefect |
| 119 | rw [← hVval, ← hWval] at hdefect |
| 120 | simp only [map_sub, sub_apply] at hdefect |
| 121 | have hs := G.smooth.contDiffWithinAt_inner_time t.property x |
| 122 | (pullbackHorizontalSection G V t x) (pullbackHorizontalSection G W t x) |
| 123 | have hd := (hs.differentiableWithinAt (by simp)).hasDerivWithinAt |
| 124 | apply hd.congr_deriv |
| 125 | unfold ordinaryMetricLieDerivative |
| 126 | linarith |
| 127 | |
| 128 | /-- The exact metric-derivative field of `MovingGaugeCalculus`, for arbitrary |
| 129 | carrier universes, all spatial dimensions, and every included interval point. -/ |
| 130 | theorem movingGauge_metric_derivative |
| 131 | (D : LeafwiseLeviCivitaFamily F S) (G : MovingSpacetimeGaugeGeometry e) |
| 132 | (c : MetricLeviCivitaFamily G.metric) |
| 133 | (t : T.Point) (x : C) (u v : TangentSpace (𝓡 n) x) : |
| 134 | HasDerivWithinAt (fun s => (G.metric s).inner x u v) |
| 135 | (horizontalMetricLieDerivative F (e.toSpacetime (t, x)) |
| 136 | (G.spatialTangentEquiv t x u) (G.spatialTangentEquiv t x v) - |
| 137 | ordinaryMetricLieDerivative (G.metric t.val) (c t.val) |
| 138 | (movingGaugeDrift G t) x u v) K.domain t.val := by |
| 139 | let : ChartedSpace (ModelProd (EuclideanHalfSpace 1) |
| 140 | (EuclideanSpace ℝ (Fin n))) F.Point := F.chartedSpace |
| 141 | let : IsManifold (spacetimeModel n) ∞ F.Point := F.isManifold |
| 142 | let V := FiberBundle.extend (EuclideanSpace ℝ (Fin n)) (G.spatialTangentEquiv t x u) |
| 143 | let W := FiberBundle.extend (EuclideanSpace ℝ (Fin n)) (G.spatialTangentEquiv t x v) |
| 144 | obtain ⟨U, hU, hV⟩ := FiberBundle.exists_contMDiffOn_extend (k := ∞) |
| 145 | (spacetimeModel n) (EuclideanSpace ℝ (Fin n)) (G.spatialTangentEquiv t x u) |
| 146 | obtain ⟨U', hU', hW⟩ := FiberBundle.exists_contMDiffOn_extend (k := ∞) |
| 147 | (spacetimeModel n) (EuclideanSpace ℝ (Fin n)) (G.spatialTangentEquiv t x v) |
| 148 | obtain ⟨O, hOsub, hO, hp⟩ := mem_nhds_iff.mp (inter_mem hU hU') |
| 149 | have hd := movingGauge_metric_derivative_on_sections D G c V W O hO |
| 150 | (hV.mono fun _ h => (hOsub h).1) (hW.mono fun _ h => (hOsub h).2) t x hp |
| 151 | simpa only [V, W, pullbackHorizontalSection, FiberBundle.extend_apply_self, |
| 152 | ContinuousLinearEquiv.symm_apply_apply] using hd |
| 153 | |
| 154 | end PoincareMT |