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.Spacetime.Realization.Interval.Maps |
| 2 | import PoincareLib.Geometry.Spacetime.Basic |
| 3 | |
| 4 | /-! |
| 5 | # The actual partial homeomorphisms of adapted boxes |
| 6 | -/ |
| 7 | |
| 8 | set_option autoImplicit false |
| 9 | |
| 10 | open Set |
| 11 | open scoped Manifold ContDiff Topology |
| 12 | |
| 13 | open PoincareMT |
| 14 | |
| 15 | namespace Poincare.Spacetime.Realization |
| 16 | |
| 17 | variable {n : ℕ} {X : Type*} [TopologicalSpace X] |
| 18 | {time : X → ℝ} {I : SpacetimeInterval} |
| 19 | |
| 20 | abbrev boxDomain (b : AdaptedMetricBox n X time I) := |
| 21 | (smoothInterval b.interval).Point × b.spatial |
| 22 | |
| 23 | theorem boxDomain_nonempty (b : AdaptedMetricBox n X time I) : Nonempty (boxDomain b) := by |
| 24 | obtain ⟨t, ht⟩ := b.interval.nontrivial.nonempty |
| 25 | obtain ⟨x, hx⟩ := b.spatial_nonempty |
| 26 | exact ⟨(⟨t, ht⟩, ⟨x, hx⟩)⟩ |
| 27 | |
| 28 | noncomputable def boxHomeomorph (b : AdaptedMetricBox n X time I) : |
| 29 | OpenPartialHomeomorph (boxDomain b) X := by |
| 30 | letI := boxDomain_nonempty b |
| 31 | exact b.openEmbedding.toOpenPartialHomeomorph b.toSpacetime |
| 32 | |
| 33 | theorem boxHomeomorph_apply (b : AdaptedMetricBox n X time I) (p : boxDomain b) : |
| 34 | boxHomeomorph b p = b.toSpacetime p := rfl |
| 35 | |
| 36 | theorem boxHomeomorph_source (b : AdaptedMetricBox n X time I) : |
| 37 | (boxHomeomorph b).source = univ := rfl |
| 38 | |
| 39 | theorem boxHomeomorph_target (b : AdaptedMetricBox n X time I) : |
| 40 | (boxHomeomorph b).target = range b.toSpacetime := by |
| 41 | simp [boxHomeomorph] |
| 42 | |
| 43 | theorem boxHomeomorph_left_inv (b : AdaptedMetricBox n X time I) (p : boxDomain b) : |
| 44 | (boxHomeomorph b).symm (b.toSpacetime p) = p := |
| 45 | (boxHomeomorph b).left_inv (mem_univ p) |
| 46 | |
| 47 | theorem boxHomeomorph_right_inv (b : AdaptedMetricBox n X time I) |
| 48 | {p : X} (hp : p ∈ (boxHomeomorph b).target) : |
| 49 | b.toSpacetime ((boxHomeomorph b).symm p) = p := |
| 50 | (boxHomeomorph b).right_inv hp |
| 51 | |
| 52 | theorem boxHomeomorph_inverse_time (b : AdaptedMetricBox n X time I) |
| 53 | {p : X} (hp : p ∈ (boxHomeomorph b).target) : |
| 54 | ((boxHomeomorph b).symm p).1.val = time p := by |
| 55 | rw [← b.time_toSpacetime, boxHomeomorph_right_inv b hp] |
| 56 | |
| 57 | /-- The supplied coordinate change is the actual transition on a neighborhood. -/ |
| 58 | theorem box_transition_eventually_eq (b c : AdaptedMetricBox n X time I) |
| 59 | (p : boxDomain b) {y : EuclideanSpace ℝ (Fin n)} |
| 60 | (T : AdaptedMetricTransition b c p.1.val p.2.val y) : |
| 61 | ∀ᶠ q in 𝓝 p, |
| 62 | ((boxHomeomorph c).symm (b.toSpacetime q)).1.val = q.1.val ∧ |
| 63 | ((boxHomeomorph c).symm (b.toSpacetime q)).2.val = T.coordinateChange q.2.val := by |
| 64 | obtain ⟨U, hU, hTU⟩ := T.interval_relatively_open |
| 65 | have htU : p.1.val ∈ U := by |
| 66 | have ht := T.time_mem |
| 67 | rw [hTU] at ht |
| 68 | exact ht.2 |
| 69 | filter_upwards [ |
| 70 | (hU.preimage (continuous_subtype_val.comp continuous_fst)).mem_nhds htU, |
| 71 | (T.coordinateChange.open_source.preimage |
| 72 | (continuous_subtype_val.comp continuous_snd)).mem_nhds T.source_mem] with q hqt hqx |
| 73 | have ht : q.1.val ∈ T.interval.domain := by |
| 74 | rw [hTU] |
| 75 | exact ⟨b.interval_subset q.1.property, hqt⟩ |
| 76 | have heq := T.box_eq q.1.val ht q.2.val hqx |
| 77 | change b.toSpacetime q = c.toSpacetime |
| 78 | (⟨q.1.val, T.interval_subset_right ht⟩, |
| 79 | ⟨T.coordinateChange q.2.val, T.target_subset (T.coordinateChange.map_source hqx)⟩) |
| 80 | at heq |
| 81 | rw [heq, boxHomeomorph_left_inv] |
| 82 | exact ⟨rfl, rfl⟩ |
| 83 | |
| 84 | theorem box_transition_data (A : AdaptedMetricAtlas n X) (b c : A.box_index) |
| 85 | (p : boxDomain (A.box b)) |
| 86 | (hp : (A.box b).toSpacetime p ∈ (boxHomeomorph (A.box c)).target) : |
| 87 | Nonempty (AdaptedMetricTransition (A.box b) (A.box c) p.1.val p.2.val |
| 88 | ((boxHomeomorph (A.box c)).symm ((A.box b).toSpacetime p)).2.val) := by |
| 89 | let q := (boxHomeomorph (A.box c)).symm ((A.box b).toSpacetime p) |
| 90 | have ht : q.1.val = p.1.val := |
| 91 | (boxHomeomorph_inverse_time (A.box c) hp).trans ((A.box b).time_toSpacetime p) |
| 92 | have hc : p.1.val ∈ (A.box c).interval.domain := ht ▸ q.1.property |
| 93 | apply A.transitions b c p.1.val p.1.property hc p.2 q.2 |
| 94 | have hq : (⟨p.1.val, hc⟩, q.2) = q := by |
| 95 | apply Prod.ext |
| 96 | · exact Subtype.ext ht.symm |
| 97 | · rfl |
| 98 | rw [hq] |
| 99 | exact (boxHomeomorph_right_inv (A.box c) hp).symm |
| 100 | |
| 101 | end Poincare.Spacetime.Realization |