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 Mathlib.Analysis.Calculus.ContDiff.Basic |
| 2 | import Mathlib.MeasureTheory.Measure.OpenPos |
| 3 | import Mathlib.MeasureTheory.Measure.Restrict |
| 4 | import Mathlib.Data.Set.UnionLift |
| 5 | |
| 6 | /-!+# Gluing local smooth representatives |
| 7 | |
| 8 | Almost-everywhere equality identifies continuous representatives on open |
| 9 | overlaps. A countable subcover then identifies the glued representative with |
| 10 | the original measurable function on the whole domain. |
| 11 | |
| 12 | Adapted from Chow--Liao--Qin, `Analysis/Sobolev/Euclidean/Embedding/ |
| 13 | IteratedSobolevEmbedding.lean`, revision |
| 14 | `1b535dd102b94cc42b107cca27059687888f08b3` (Apache-2.0). |
| 15 | -/ |
| 16 | |
| 17 | noncomputable section |
| 18 | |
| 19 | open Set MeasureTheory Topology |
| 20 | open scoped ContDiff |
| 21 | |
| 22 | namespace Poincare.Analysis.Elliptic |
| 23 | |
| 24 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 25 | [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] |
| 26 | {μ : Measure E} [μ.IsOpenPosMeasure] |
| 27 | |
| 28 | /-- Continuous local representatives of the same function agree on an open overlap. -/ |
| 29 | theorem eqOn_inter_of_ae_eq {s t : Set E} (hs : IsOpen s) (ht : IsOpen t) |
| 30 | {f g u : E → ℝ} (hf : ContinuousOn f s) (hg : ContinuousOn g t) |
| 31 | (hfu : f =ᵐ[μ.restrict s] u) (hgu : g =ᵐ[μ.restrict t] u) : |
| 32 | EqOn f g (s ∩ t) := by |
| 33 | apply MeasureTheory.Measure.eqOn_open_of_ae_eq (μ := μ) _ (hs.inter ht) |
| 34 | (hf.mono inter_subset_left) (hg.mono inter_subset_right) |
| 35 | have hf' : f =ᵐ[μ.restrict (s ∩ t)] u := |
| 36 | ae_restrict_of_ae_restrict_of_subset inter_subset_left hfu |
| 37 | have hg' : g =ᵐ[μ.restrict (s ∩ t)] u := |
| 38 | ae_restrict_of_ae_restrict_of_subset inter_subset_right hgu |
| 39 | exact hf'.trans hg'.symm |
| 40 | |
| 41 | /-- Smooth representatives on open neighborhoods glue to a representative on the domain. -/ |
| 42 | theorem exists_smooth_representative_of_local {O : Set E} {u : E → ℝ} |
| 43 | (hlocal : ∀ x ∈ O, ∃ V : Set E, IsOpen V ∧ x ∈ V ∧ V ⊆ O ∧ |
| 44 | ∃ f : E → ℝ, ContDiffOn ℝ ∞ f V ∧ f =ᵐ[μ.restrict V] u) : |
| 45 | ∃ U : E → ℝ, ContDiffOn ℝ ∞ U O ∧ U =ᵐ[μ.restrict O] u := by |
| 46 | classical |
| 47 | choose V hV hxV hVO f hf hfu using fun x : O => hlocal x x.property |
| 48 | have hcover : O ⊆ ⋃ x : O, V x := fun x hx => |
| 49 | mem_iUnion.mpr ⟨⟨x, hx⟩, hxV ⟨x, hx⟩⟩ |
| 50 | have hagree : ∀ (x y : O) (z : E), z ∈ V x → z ∈ V y → f x z = f y z := by |
| 51 | intro x y z hzx hzy |
| 52 | exact eqOn_inter_of_ae_eq (hV x) (hV y) (hf x).continuousOn |
| 53 | (hf y).continuousOn (hfu x) (hfu y) ⟨hzx, hzy⟩ |
| 54 | let g : O → ℝ := Set.iUnionLift V (fun x z => f x z) |
| 55 | (fun x y z hzx hzy => hagree x y z hzx hzy) O hcover |
| 56 | let U : E → ℝ := fun x => if hx : x ∈ O then g ⟨x, hx⟩ else 0 |
| 57 | have hU : ∀ x : O, EqOn U (f x) (V x) := by |
| 58 | intro x z hz |
| 59 | have hzO : z ∈ O := hVO x hz |
| 60 | have hglue : g ⟨z, hzO⟩ = f x z := Set.iUnionLift_of_mem |
| 61 | (S := V) (T := O) ⟨z, hzO⟩ hz |
| 62 | simpa only [U, dif_pos hzO] using hglue |
| 63 | refine ⟨U, ?_, ?_⟩ |
| 64 | · apply contDiffOn_of_locally_contDiffOn |
| 65 | intro x hx |
| 66 | refine ⟨V ⟨x, hx⟩, hV ⟨x, hx⟩, hxV ⟨x, hx⟩, ?_⟩ |
| 67 | exact ((hf ⟨x, hx⟩).mono inter_subset_right).congr |
| 68 | (fun y hy => hU ⟨x, hx⟩ hy.2) |
| 69 | · obtain ⟨T, hT, hTcover⟩ := TopologicalSpace.isOpen_iUnion_countable V hV |
| 70 | have hOcover : O ⊆ ⋃ x ∈ T, V x := by rwa [hTcover] |
| 71 | have hlocal_ae : ∀ x ∈ T, U =ᵐ[μ.restrict (V x)] u := by |
| 72 | intro x _ |
| 73 | apply Filter.EventuallyEq.trans _ (hfu x) |
| 74 | exact (ae_restrict_iff' (hV x).measurableSet).mpr |
| 75 | (Filter.Eventually.of_forall fun z hz => hU x hz) |
| 76 | exact ae_restrict_of_ae_restrict_of_subset hOcover |
| 77 | ((ae_eq_restrict_biUnion_iff V hT U u).mpr hlocal_ae) |
| 78 | |
| 79 | end Poincare.Analysis.Elliptic |