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.Surgery.StandardCap.Existence.Analysis.Basic.ParameterSpatialDerivatives |
| 2 | import Mathlib.Topology.Piecewise |
| 3 | |
| 4 | /-! |
| 5 | # Continuity and spatial jets of a time-slice gluing |
| 6 | |
| 7 | Whole-slice agreement joins continuous fields and all actual spatial |
| 8 | derivatives. The assembled field remains smooth away from the joining |
| 9 | time. This is the coefficient preparation for Morgan-Tian Theorem 12.5, |
| 10 | pp. 296-297; see terminal-flow-joining.md. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set Filter |
| 16 | open scoped ContDiff Topology |
| 17 | |
| 18 | /-- Continuous fields on adjacent included half-slabs join continuously |
| 19 | when their whole common slice agrees (Theorem 12.5, pp. 296-297). -/ |
| 20 | theorem continuousOn_time_ite |
| 21 | {E V : Type*} [TopologicalSpace E] [TopologicalSpace V] |
| 22 | {f g : ℝ × E → V} {a b c : ℝ} |
| 23 | (hf : ContinuousOn f (Ioc a c ×ˢ univ)) |
| 24 | (hg : ContinuousOn g (Ico c b ×ˢ univ)) |
| 25 | (hfg : ∀ x, f (c, x) = g (c, x)) : |
| 26 | ContinuousOn (fun p : ℝ × E => if p.1 < c then f p else g p) (Ioo a b ×ˢ univ) := by |
| 27 | apply ContinuousOn.if |
| 28 | · intro p hp |
| 29 | have heq : p.1 = c := frontier_lt_subset_eq continuous_fst continuous_const hp.2 |
| 30 | simpa only [← heq] using hfg p.2 |
| 31 | · apply hf.mono |
| 32 | intro p hp |
| 33 | have hle : p.1 ≤ c := closure_lt_subset_le continuous_fst continuous_const hp.2 |
| 34 | exact ⟨⟨hp.1.1.1, hle⟩, hp.1.2⟩ |
| 35 | · apply hg.mono |
| 36 | intro p hp |
| 37 | have hle : c ≤ p.1 := by |
| 38 | have hclosed : IsClosed {q : ℝ × E | ¬q.1 < c} := by |
| 39 | simpa only [not_lt] using isClosed_le continuous_const continuous_fst |
| 40 | have hp' := hp.2 |
| 41 | rw [hclosed.closure_eq] at hp' |
| 42 | exact not_lt.mp hp' |
| 43 | exact ⟨⟨hle, hp.1.1.2⟩, hp.1.2⟩ |
| 44 | |
| 45 | /-- A time-only branch chooses an entire spatial slice, so its ordinary |
| 46 | spatial derivatives are exactly the selected derivatives |
| 47 | (Theorem 12.5, pp. 296-297). -/ |
| 48 | theorem iteratedFDeriv_time_ite |
| 49 | {E V : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 50 | [NormedAddCommGroup V] [NormedSpace ℝ V] |
| 51 | (f g : ℝ × E → V) (c : ℝ) (j : ℕ) (p : ℝ × E) : |
| 52 | iteratedFDeriv ℝ j (fun x => if p.1 < c then f (p.1, x) else g (p.1, x)) p.2 = |
| 53 | if p.1 < c then iteratedFDeriv ℝ j (fun x => f (p.1, x)) p.2 |
| 54 | else iteratedFDeriv ℝ j (fun x => g (p.1, x)) p.2 := by |
| 55 | by_cases ht : p.1 < c <;> simp only [ht, if_true, if_false] |
| 56 | |
| 57 | /-- Whole-slice agreement of smooth half-families makes every actual |
| 58 | spatial jet continuous across their join (Theorem 12.5, pp. 296-297). -/ |
| 59 | theorem continuousOn_spatialJet_time_ite |
| 60 | {E V : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 61 | [NormedAddCommGroup V] [NormedSpace ℝ V] |
| 62 | {f g : ℝ × E → V} {a b c : ℝ} |
| 63 | (hf : ContDiffOn ℝ ∞ f (Ioc a c ×ˢ univ)) |
| 64 | (hg : ContDiffOn ℝ ∞ g (Ico c b ×ˢ univ)) |
| 65 | (hfg : ∀ x, f (c, x) = g (c, x)) (j : ℕ) : |
| 66 | ContinuousOn |
| 67 | (fun p : ℝ × E => iteratedFDeriv ℝ j |
| 68 | (fun x => if p.1 < c then f (p.1, x) else g (p.1, x)) p.2) |
| 69 | (Ioo a b ×ˢ univ) := by |
| 70 | have h := continuousOn_time_ite |
| 71 | (hf.iteratedFDeriv_snd_of_isOpen isOpen_univ j).continuousOn |
| 72 | (hg.iteratedFDeriv_snd_of_isOpen isOpen_univ j).continuousOn |
| 73 | (fun x => congrArg (fun u => iteratedFDeriv ℝ j u x) (funext hfg)) |
| 74 | apply h.congr |
| 75 | intro p _hp |
| 76 | exact iteratedFDeriv_time_ite f g c j p |
| 77 | |
| 78 | /-- Smooth adjacent half-families give ordinary smoothness of their |
| 79 | assembled field off the joining slice (Theorem 12.5, pp. 296-297). -/ |
| 80 | theorem contDiffOn_time_ite_off_time |
| 81 | {E V : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 82 | [NormedAddCommGroup V] [NormedSpace ℝ V] |
| 83 | {f g : ℝ × E → V} {a b c : ℝ} |
| 84 | (hf : ContDiffOn ℝ ∞ f (Ioc a c ×ˢ univ)) |
| 85 | (hg : ContDiffOn ℝ ∞ g (Ico c b ×ˢ univ)) : |
| 86 | ContDiffOn ℝ ∞ (fun p : ℝ × E => if p.1 < c then f p else g p) |
| 87 | ((Ioo a b \ {c}) ×ˢ univ) := by |
| 88 | intro p hp |
| 89 | by_cases ht : p.1 < c |
| 90 | · have hreg := (hf.mono (prod_mono Ioo_subset_Ioc_self (Subset.refl univ))).contDiffAt |
| 91 | ((isOpen_Ioo.prod isOpen_univ).mem_nhds ⟨⟨hp.1.1.1, ht⟩, hp.2⟩) |
| 92 | apply ContDiffAt.contDiffWithinAt |
| 93 | apply hreg.congr_of_eventuallyEq |
| 94 | filter_upwards [(isOpen_Iio.preimage continuous_fst).mem_nhds ht] with q hq |
| 95 | exact if_pos hq |
| 96 | · have hgt : c < p.1 := lt_of_le_of_ne (not_lt.mp ht) (Ne.symm hp.1.2) |
| 97 | have hreg := (hg.mono (prod_mono Ioo_subset_Ico_self (Subset.refl univ))).contDiffAt |
| 98 | ((isOpen_Ioo.prod isOpen_univ).mem_nhds ⟨⟨hgt, hp.1.1.2⟩, hp.2⟩) |
| 99 | apply ContDiffAt.contDiffWithinAt |
| 100 | apply hreg.congr_of_eventuallyEq |
| 101 | filter_upwards [(isOpen_Ioi.preimage continuous_fst).mem_nhds hgt] with q hq |
| 102 | exact if_neg (not_lt.mpr hq.le) |