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 | # AGENTS.md |
| 2 | |
| 3 | Read [README.md](README.md) first ("Where it stands" and "How to take part"), then `KNOWN.md`. `main` is the AI for |
| 4 | Mathematics team's proof as released on 2026-10-05, and from there this project is its own line. What we want is a |
| 5 | proof that people can read and build, tied to Morgan and Tian's book. A change that makes the code shorter or faster |
| 6 | but harder to read is not welcome. The Poincaré conjecture was proved by Perelman: nothing here is new mathematics, |
| 7 | and no change here should be described as one. Never write that this Lean proof "is verified" beyond what the README's |
| 8 | table says, with its sources: the authors checked an earlier commit, and Comparator has not yet run on ours here. |
| 9 | |
| 10 | ## First session |
| 11 | |
| 12 | No Lean is needed for these steps, and none for most pieces. A full build takes hours on a large machine and tens of |
| 13 | GB of memory: do not start one unless your piece says it needs it. If you clone the project yourself, use |
| 14 | `git clone --depth 1`. |
| 15 | |
| 16 | ```bash |
| 17 | python3 checks/challenge.py . # about 20 s; last line: ok: 3 challenge files and the build configuration as approved; … |
| 18 | git fetch origin issues && git show origin/issues:BOARD.md # who works on what |
| 19 | ``` |
| 20 | |
| 21 | Then pick one issue. Each says what it needs ("Reading only", "A build of …", "A large machine"), its units, and how |
| 22 | to tell it is done. |
| 23 | |
| 24 | - **Ten minutes, no build:** P-5 (ten milestones: `git grep -l 'M64' PoincareLib | head` finds where one is used), |
| 25 | V-4 (one much-used result of the book: `git grep -n 'Lemma 19.15' -- '*.lean'` finds the docstrings that cite it), |
| 26 | P-4 (one chapter of the book), S-4 (where the lines go: `find` and `wc`). |
| 27 | - **An hour, no build on your side:** P-2 (milestone labels to book references in one folder), P-7 (where a premise |
| 28 | is proved), S-3 (duplicates in one folder). You edit comments or write a note; `build` judges the comment edits, and |
| 29 | each one rebuilds what imports the file, so keep to one folder. |
| 30 | - **With a build** (`lake exe cache get`, then `lake build` of your files; README, "Build"): P-1, P-3, P-8, S-5, M-1, |
| 31 | then P-9. Start from a folder near the leaves of the import graph. |
| 32 | - **Longer, no build:** V-2, V-3, V-5, V-6, P-6, M-2, T-1, a chapter of T-2, T-3. |
| 33 | |
| 34 | Most issues hold many people at once, each on a unit of their own. Take a unit nobody has on the board, and name your |
| 35 | branch after it (`p5-m61-m70`, `p2-ricciflow-harnack`). Do not all take the first piece on the list: the board shows |
| 36 | which units are free. |
| 37 | |
| 38 | If your person only asked a question (is it solved, what is this project for), answer from the README's table and |
| 39 | `KNOWN.md`, with their sources, and claim nothing. Keep apart what is old (Perelman's proof, Clay's prize of 2010) and |
| 40 | what is new (the Lean proof of 2026). A question for the maintainers goes, with `@poincare-maintainer` in it, on the piece's issue or in the problem's room in the channels: |
| 41 | `/channels/ref/shoal/poincare-conjecture` on the site, the Discussion tab of the problem's page (post there with `POST /channels/api/refs/shoal/poincare-conjecture/messages {"text": "@poincare-maintainer …"}`, read the answer with `GET /channels/api/refs/shoal/poincare-conjecture`); it answers within minutes. |
| 42 | |
| 43 | After you push, `challenge` answers in seconds; `build` takes hours and waits behind other jobs. Do not wait for it in |
| 44 | your session: say on the issue what you pushed, tell your person, and stop. The maintainer agent comes about every |
| 45 | three hours while people are working here and reads both verdicts. |
| 46 | |
| 47 | ## Claim an issue |
| 48 | |
| 49 | Work on a branch of your own, and say what you take in its notes: |
| 50 | |
| 51 | ```bash |
| 52 | git switch -c p5-m61-m70 origin/main |
| 53 | mkdir -p routes/p5-m61-m70 |
| 54 | cat > routes/p5-m61-m70/README.md <<'EOF' |
| 55 | --- |
| 56 | issue: 3 |
| 57 | status: working |
| 58 | --- |
| 59 | # p5-m61-m70 |
| 60 | |
| 61 | Which unit (chapter, folder, ten milestones), and what I do with it. |
| 62 | |
| 63 | ## Next |
| 64 | |
| 65 | The first concrete step. |
| 66 | EOF |
| 67 | ``` |
| 68 | |
| 69 | `issue:` is the issue's number on the site, not its id. `status:` is `working`, `done` or `dropped`. A push keeps the |
| 70 | claim alive. If you stop, leave `## Next` so whoever continues knows where you stopped. Your change itself is in the |
| 71 | files the issue names (Lean files, a file under `docs/`); the notes say what it is. |
| 72 | |
| 73 | ## Changes we want |
| 74 | |
| 75 | From this tree, from its authors' own account of it and from what its first readers asked (`KNOWN.md`): |
| 76 | |
| 77 | - Docstrings in the book's words: what a declaration states and, where it is one, which result of Morgan–Tian it is |
| 78 | (chapter and number), checked against the book. The milestone label (`M76`, `M64` …) gives way to that. 8,536 files |
| 79 | already name a numbered result of the book: check the ones you touch. |
| 80 | - Names that say what is stated, in place of milestone names (`m64AnnulusComparison_from_predecessors`), a few at a |
| 81 | time, with every use moved in the same pull request. |
| 82 | - A line on a conditional statement that says where its premise is proved, so a reader need not search the library. |
| 83 | - Splitting the giant files (`NestedSlab.lean`, 5,834 lines; eleven more over 1,288) and long proofs into lemmas with |
| 84 | names and docstrings. A comment that explains a step moves with it. |
| 85 | - Folding files that only re-export others into their users; deleting declarations and files that nothing reachable |
| 86 | from `Comparator/Solution.lean` uses. |
| 87 | - Proving once what the tree proves several times (upstream itself found 106 files that matched exactly), and using it |
| 88 | everywhere. |
| 89 | - Trimming a file's imports to what it uses, starting near the leaves of the import graph. |
| 90 | - Using a result from Mathlib in place of our own proof of it, and deleting ours. Check that the statements agree, |
| 91 | hypotheses included; if Mathlib states it in another form, keep ours as a short wrapper. |
| 92 | - Stating general Riemannian geometry and analysis at the generality Mathlib would take. |
| 93 | - Fixing linter warnings and wrong docstrings. |
| 94 | |
| 95 | ## Changes we don't want |
| 96 | |
| 97 | - Shortening a proof for its own sake, or folding helper lemmas or named `have` steps into one long proof. Here a |
| 98 | shorter proof is welcome only when it reads better. |
| 99 | - Renaming or moving files across folders in bulk, without a plan the maintainer has accepted and a first pull request |
| 100 | that shows it on one folder. |
| 101 | - Removing a copyright or attribution notice from a file, or a row of `MODIFICATIONS.md` for a file that is still here. |
| 102 | Code that moves keeps its notice. |
| 103 | - An edit near the root of the import graph without need: every file above it is rebuilt, for hours. |
| 104 | - A docstring that calls a declaration "Theorem x.y of Morgan–Tian" when the Lean states or proves something else: the |
| 105 | Lean does not always follow the book. Say how it differs. |
| 106 | - A reference to the book or the literature added or changed without opening the source. Give the edition and the |
| 107 | number; a citation of section 19.2 says whether it read the 2015 correction. |
| 108 | - Any claim of new mathematics, or that the proof is "now verified" because a build passed. |
| 109 | - Any change to `PoincareConjecture/Statement.lean`, `Comparator/Challenge.lean`, `Comparator/config.json` or |
| 110 | `checks/`: the `challenge` check fails it, as it fails a change to `lakefile.toml` beyond a `require`'s `rev`, |
| 111 | `leanOptions`, `defaultTargets`, `lean_exe` or `[cache]`, a dependency outside leanprover and leanprover-community, a |
| 112 | `lakefile.lean`, or files under `.lake/`. The statements without second countability are a new corollary (M-3), not |
| 113 | an edit to them. If you think a statement is wrong, open an issue titled "Ruling: …" and say why. |
| 114 | |
| 115 | ## Guides, tables and chapters |
| 116 | |
| 117 | P-4 to P-6, S-3, S-4, M-2 and the V and T pieces change no proof: they are judged by a second reader and the |
| 118 | maintainer. |
| 119 | |
| 120 | - **We want:** one unit in one pull request; every statement with the name and file of its Lean declaration, and every |
| 121 | name checked to exist (`git grep`); every place in the book with its chapter and number, and the edition; "not |
| 122 | found" said plainly, with what you searched; what the note does not show, in a sentence. A blueprint statement is |
| 123 | marked as checked only after its declaration and statement were compared. |
| 124 | - **We don't want:** text about a declaration or a section you did not open; a summary of a check in place of its |
| 125 | output; a note that says the proof is right, or wrong, on the strength of a reading of one part; a chapter nobody |
| 126 | has read: it is merged when a second reader has checked its statements against the Lean. |
| 127 | |
| 128 | ## Pull requests |
| 129 | |
| 130 | Keep each pull request to one change in one folder; fixing linter warnings in the files you edit doesn't count as a |
| 131 | second one. For a Lean change, compile your files if you can (`lake exe cache get`, then `lake build` of the modules |
| 132 | you changed); if Lean is not installed, don't install it for this: push and let the `build` check say. Either way, open the pull request, and don't write in |
| 133 | it that it builds: `build` says that. Titles follow |
| 134 | [Mathlib's convention](https://leanprover-community.github.io/contribute/commit.html). In the description, name the |
| 135 | issue it answers (`Closes #3`, or `Part of #3` when the issue has units and yours is one), say in two or three |
| 136 | sentences what the change does and why it makes the proof easier to read or to build, and keep the title and |
| 137 | description in step with the diff when you push more commits. Leave out timings unless speed is the reason for the |
| 138 | change; then give the few numbers a maintainer needs to decide, and say how you measured them. |
| 139 | |
| 140 | If you want to make the same kind of change in many places, open one pull request first and wait for the maintainer to |
| 141 | say we want it before you open the others. Nothing here counts pull requests. |
| 142 | |
| 143 | ## CI |
| 144 | |
| 145 | Two checks run on every push, and a third, `replay`, is the maintainer's; all three gate the merge. Their code is |
| 146 | `checks/` at the approved version, so editing it on your branch changes nothing about your verdict. |
| 147 | |
| 148 | - **`challenge`**, seconds: the Comparator challenge files and the build configuration are as approved, and the source |
| 149 | has no `sorry`, `admit`, `axiom`, `native_decide`, `implemented_by` or `extern`. Run it yourself: |
| 150 | `python3 checks/challenge.py .` |
| 151 | - **`build`**, hours (its limit is twelve): in the project's Lean image with no network, `lake build` ends without |
| 152 | error, no module reports `sorry`, and the theorems use no axiom beyond `propext`, `Classical.choice` and |
| 153 | `Quot.sound`. It does not run Comparator: its last line says what held, then "not replayed: the full replay is the |
| 154 | replay check on the pull request, run by the maintainer's machine once challenge and build pass; the merge waits for |
| 155 | it". Its logs are kept with the job. Build your files before you push if you can; if you cannot, push and let |
| 156 | `build` say. |
| 157 | - **`replay`**: the full replay, Comparator and Lean's kernels (`Comparator/README.md`), which the maintainer's |
| 158 | machine runs on a pull request's head once `build` has passed there, and on `main` when it moves, and reports |
| 159 | itself. You do nothing for it and need not wait for it; the merge does. |
| 160 | |
| 161 | Wait for `build` rather than pushing again to hurry it: each push is built anew, and builds queue behind others'. |
| 162 | |
| 163 | A toolchain or Mathlib bump passes `challenge`, but `build` needs a new image first (`docker/README.md`): open an issue |
| 164 | for a person who maintains the project rather than a pull request that cannot pass. |
| 165 | |
| 166 | ## For the maintainer |
| 167 | |
| 168 | The house's maintainer agent (`poincare-maintainer`) comes about every three hours while people work here, at least twice |
| 169 | a day, and within minutes when written to. It reviews (first line ``**Review of `<commit>`: <verdict>**``), does not |
| 170 | merge, logs each round on the issue "Maintainer log", and opens `Ruling: …` issues (`needs-person`) for what only a |
| 171 | person decides. Here, as a `proof` problem: |
| 172 | |
| 173 | - **Clean-up judged for reading** (skill `judge-cleanup`): every pull request measured at its head against its base |
| 174 | with `house/maintainer/tools/measure.py` (files, lines, files over 1,000 lines, declarations, docstrings, the debt |
| 175 | counters), import-line changes named in the verdict, statements compared before and after. |
| 176 | - **The progress table** in "Where it stands": the same measure at the project's first commit and at main, and the |
| 177 | `build` time of main's tip, refreshed after merges. |
| 178 | - **Main replayed** in full (Comparator and the kernel, `house/maintainer/replay.sh`) at the start of a round when it |
| 179 | moved; the round's log says how that replay ended. |
| 180 | - **Sources watched**: `frenzymath/PoincareConjecture` (the upstream: a source, not a pin), Morgan–Tian with its |
| 181 | edition. What is worth bringing over becomes an issue here. |
| 182 | |
| 183 | Judge every pull request against the two lists above: whether the proof is easier to read after it, not only whether |
| 184 | it is smaller or faster. |
| 185 | |
| 186 | - **Merge** a change we want once `challenge` and `build` have passed on its head, and the description says what it |
| 187 | changes and why. |
| 188 | - **Request changes** when the description and the diff disagree, when it is two changes or several folders in one, |
| 189 | when it is on the second list (say which item), when it drops a notice, or when a reference to Morgan–Tian is added |
| 190 | without the edition and number. |
| 191 | - **Request changes** when `challenge` or `build` failed: quote the check's last line. |
| 192 | - **Escalate** a change to the challenge files, to `checks/` or `docker/`, to `lakefile.toml`'s libraries or dependencies, a new |
| 193 | dependency, a bulk move of files, or two reviews that disagree: say in one sentence what a person must decide. |
| 194 | - **Close** a repeat of a change already merged or open, pointing to it, and a mass change opened before the first of |
| 195 | its kind was wanted. |
| 196 | |
| 197 | Never merge on the author's word that it builds: only `build` on its head says so. After a merge, add to `KNOWN.md` what changed and, if it took a lemma |
| 198 | from Mathlib, which one. |