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

Lean image
The image the build check runs in. Tag, as scienceslack.json names it:
shoal-poincare-lean:62db01af
Nothing is published: the runner that runs the check must have the image locally, so build it on the runner's machine.
Build
Compiling the project's 23,554 Lean files (3.06 million lines) takes hours, so it is not a Dockerfile layer, which a
failure would throw away. build.sh does it in three steps:
cd problems/poincare-conjecture
CPUSET=64-95 sh docker/build.sh base # shoal-poincare-lean:62db01af-base, from lean.Dockerfile: about 26 minutes
CPUSET=64-95 sh docker/build.sh start # the long step, detached, in the container poincare-lean-build
docker logs --tail 3 poincare-lean-build # watch it: "✔ [n/N] Built PoincareLib.… (12s)"; the last line is "long step done"
sh docker/build.sh commit # once it has exited 0: shoal-poincare-lean:62db01af, and the container is removed
On the production host (12-02, cores 64-95, other builds beside it): the base 26 minutes; the long step 1 h 46 m at 32
cores, about 40 GB of memory; commit 11 minutes. The image is 35 GB on disk, 7.9 GB compressed; the project's build
in it 14 GB (oleans 11.7 GB), owned by nobody.
CPUSET is the cores to use (docker's --cpuset-cpus; leave it out to use them all), MEMORY the long step's limit
(256g unless set), NAME the container's name. Run start under nothing else: the container is detached and outlives
the shell.
If the long step stops (a kill, a reboot, a full disk): docker start poincare-lean-build goes on from the modules
already compiled; docker logs --tail 20 poincare-lean-build says why it stopped. commit refuses a container that
has not exited 0.
baseneeds the network: the Ubuntu archive, GitHub (elan, the clone, the dependencies, landrun, nanoda), releases.lean-lang.org, Mathlib's cache, the Go and Rust downloads. The defaults are mirrors that answer from mainland China (APT_MIRROR,GO_DIST,GOPROXY,RUST_DIST,CRATES_INDEXinlean.Dockerfile); elsewhere pass the official addresses with--build-arg. The clone is tried up to five times andlake exe cache getup to three, and the layer fails unless Lake then finds nothing of Mathlib left to compile.startruns with--network none:lake build(the default targetsPoincareConjectureandPoincareLib), thenlake build Challenge Solution @Comparator/comparator @lean4export/lean4exportasComparator/README.mdsays: all four librarieslakefile.tomldeclares. It linkscomparatorandlean4exportinto/usr/local/bin, deletes thesetup.jsonLake wrote for each module (1.5 MB each, never read again: about 35 GB of a 51 GB build), opens/optto every user (chmod -R a+rX) and gives the project's own build,/opt/proof/.lake/build, tonobody.commitsets what a Dockerfile's last lines would:ENV PROOF_BASE=/opt/proof,WORKDIR /opt/proof,CMD ["/bin/bash"].
What is in it
/opt/elan: elan 4.1.2 with Lean v4.33.1 as the default toolchain, solakeworks offline. The toolchain shipsleanchecker; it does not shipleanexportornanoda_bin(v4.35 and later do)./opt/proof: the upstream at its pinned commit with.lakefully built: the dependencies with Mathlib's oleans from its cache (.lake/packages, root's, read-only to the check'snobody), and the project's own build (.lake/build, owned bynobody).PROOF_BASE=/opt/proof.- On
PATH:lake,lean,leanchecker,comparator,lean4export,landrun0.1.18,nanoda_bin0.4.18; alsopython33.12,git,which,curl,zstdand a C toolchain.
How the check uses it
The check runs the image with --network none, as root, and compiles a commit's Lean as nobody
(scripts/lean-ci/README.md). The project's build is too big to copy for each job: a job is meant to compile on top
of /opt/proof/.lake/build inside its own container, so it writes only the modules the commit changed and the ones
that import them, and the container's end throws them away. The image itself never changes. lake exe cache get
cannot run there, which is why the image does it.
Lake starts one lean for every core it sees, and a container's --cpus is a share of time, not a number of cores:
the check has to give the commit's lake build a LEAN_NUM_THREADS equal to the CPUs the job asked for.
Pins
All pins are full commit hashes in ARGs at the top of lean.Dockerfile. After each clone the build checks
git rev-parse HEAD against its pin and fails otherwise.
| ARG | Value | Source |
|---|---|---|
UPSTREAM_COMMIT |
62db01af9388dc1d9b56b66d6674f4c09b2318a2 |
frenzymath/PoincareConjecture, upstream.json |
TOOLCHAIN |
leanprover/lean4:v4.33.1 |
upstream lean-toolchain |
MATHLIB_COMMIT |
0df444a360eaa60ab8c11dca51a86af692955474 |
upstream lakefile.toml / lake-manifest.json |
COMPARATOR_REV |
3927ad383f208ae977c340a91c48ac9b497d2097 |
upstream lakefile.toml / lake-manifest.json |
LEAN4EXPORT_REV |
15f6055e299ad5b89345e533cc2192f4cc00f659 |
upstream lakefile.toml / lake-manifest.json |
LANDRUN_REV |
811cfff51ceaf3d9843708aa6d22e9b84ccac8b4 (0.1.18) |
PoincareConjecture Comparator/README.md |
NANODA_REV |
079049d584b2aed2b0172218164082f4fc6eede2 (0.4.18) |
PoincareConjecture Comparator/README.md |
GO_VERSION, GO_SHA256 |
1.24.13 | landrun's go.mod asks for Go 1.24; the mirror's tarball has go.dev's checksum |
RUST_VERSION |
1.100.1 | Rust stable on 2026-12-01; nanoda builds with cargo build --locked |
ELAN_URL |
elan 4.1.2's GitHub release | the install script lives on raw.githubusercontent.com, closed from mainland China |
Rebuild when main moves
The image is the build of one commit. Rebuild it, under a new tag, whenever main's lean-toolchain or
lake-manifest.json changes (a new Lean release, or new Mathlib, Comparator or lean4export pins): set
UPSTREAM_COMMIT (and the other pins it moves) in lean.Dockerfile and TAG in build.sh, build, give the tag the
new commit's first eight hex digits, and change the tag in scienceslack.json in the same pull request. The check
refuses a commit whose lean-toolchain differs from the image's.
Rebuilding after other changes to main is optional but pays quickly here: a check recompiles everything that differs
from the image's commit, so once main has moved in a file that thousands of others import, every later pull request
recompiles those thousands again. The clone in lean.Dockerfile is upstream's; to build main as it is on the site
instead, point UPSTREAM_REPO and UPSTREAM_COMMIT at the project's own repository and commit.