Riemann hypothesis: the Lean proof, cleaned up together
The 2026 Lean proof of the Riemann hypothesis and GRH, machine-checked by others, not refereed, no word from Clay; cleaned up together: more readable, faster to build, the theorems unchanged

| 1 | # Lean image |
| 2 | |
| 3 | `lean.Dockerfile` builds the image the riemann-hypothesis build check runs in. Tag: |
| 4 | |
| 5 | ``` |
| 6 | shoal-rh-lean:630d1e43 |
| 7 | ``` |
| 8 | |
| 9 | `scienceslack.json` refers to this exact name. |
| 10 | |
| 11 | ## Build |
| 12 | |
| 13 | On the machine whose runner will use it, with a checkout of the project's main as the context (not this folder, and |
| 14 | not a clone of upstream: the image is the build of our main): |
| 15 | |
| 16 | ```bash |
| 17 | git clone <the project's repository> /tmp/rh-main |
| 18 | sh /tmp/rh-main/docker/build.sh /tmp/rh-main # tag: the one scienceslack.json names |
| 19 | MIRRORS=cn CPUSET=64-127 sh /tmp/rh-main/docker/build.sh /tmp/rh-main # on the Beijing host, on those cores |
| 20 | ``` |
| 21 | |
| 22 | `build.sh` is one `docker build` with the classic builder and the host's network. `MIRRORS=cn` takes apt from Aliyun, the Lean release |
| 23 | and seven of the Lean packages (Mathlib among them) from SJTU's mirror; elan, Tau Ceti, plausible and LeanSearchClient still come from github.com, each |
| 24 | tried ten times. The build needs the network (GitHub, the Lean release, the Mathlib, Tau Ceti and project caches). Nothing is published: the runner that runs the check must have |
| 25 | the image locally. |
| 26 | |
| 27 | Built on the production host on 2026-12-02 (16 cores, `MIRRORS=cn`): image |
| 28 | `sha256:da30feeb683371b767e16bc1eccb85f55e8261b3fc17ccfcc2d6fe2feecc707a`, 5.3 GB, 19 minutes. Upstream's cache had |
| 29 | the project's build for `630d1e43`, so `lake build` of the four libraries took 11 s (26,379 jobs; `.lake/build` 2.2 GB). |
| 30 | On main, with the runner's flags: the per-push `build` (`"replay": "round"`: build, `sorry` scan, the theorems' axioms |
| 31 | as the commit's Lean reports them) 17 s at 4 CPUs, 0.9 GB; the full replay exports 4.7 GB in 4 minutes, nanoda takes |
| 32 | about 10 minutes, and Lean's kernel had run 90 minutes and held 62 GB without a verdict when the run was stopped (07:47): it runs once per maintainer round. |
| 33 | |
| 34 | ## What is in it |
| 35 | |
| 36 | - `/opt/elan`: elan with the upstream's toolchain installed and set as the default, so `lake` works offline. |
| 37 | - `/opt/proof`: the project's main (the context), with `.lake` fully built (dependencies, their oleans, and every library of `lakefile.toml`: Lib, New, Main and Challenge). `PROOF_BASE=/opt/proof`. `.lake/build` belongs to `nobody`, and everything under `/opt` is readable by `nobody`: the check compiles a commit as that user. |
| 38 | - On `PATH`: `lake` (with `lake comparator`), `lean`, `nanoda_bin`, `leanchecker`, `bwrap`; also `python3`, `git`, `curl`, `zstd` and a C toolchain. |
| 39 | |
| 40 | ## How the check uses it |
| 41 | |
| 42 | The check runs the image with `--network none`. It copies the pushed commit's tree to a writable directory, gives it `/opt/proof/.lake` (or links its `packages`), and runs `lake build`, `lake env lean scripts/PrintAxioms.lean` and `lake comparator --config comparator.json`. Lake then recompiles only what the commit changed. `lake exe cache get` cannot run there, which is why the image does it at build time. |
| 43 | |
| 44 | The project does not depend on Comparator, and the image builds none: since v4.35.0 Lean ships it as `lake comparator` |
| 45 | (sandboxed with bubblewrap), with its exporter and `nanoda_bin`, as the goldbach-spectral-bridge image uses them. The |
| 46 | standalone `leanprover/comparator` and `lean4export` are deprecated and have no tag for v4.37.0-rc1. The check runs |
| 47 | `lake comparator --config comparator.json`; the image puts the toolchain's `nanoda_bin` and `leanchecker` on `PATH`. |
| 48 | |
| 49 | The image fetches three caches, as upstream's `lake exe cache get` (`scripts/lake-cache-get.sh`) does: Mathlib's in the dependencies' layer, then Tau Ceti's (`scripts/tauceti-cache-get.py`) and the project's own (`scripts/ci-cache-get.py`; Python 3.11+ and curl 7.71+, which Ubuntu 24.04 has). The project's cache is what upstream's CI published for the `src` tree, `lakefile.toml`, `lake-manifest.json` and toolchain of its own commits: it matches while our main's `src` is byte for byte a commit of upstream's main (at the pin it is: upstream has a record for `630d1e43`), and no longer once we have merged our own changes. Then exit 3 (no record) is accepted and the full `lake build` that follows compiles what the caches did not supply, about 4 CPU-hours from nothing. |
| 50 | |
| 51 | ## Pins |
| 52 | |
| 53 | All pins are full hashes in `ARG`s at the top of `lean.Dockerfile`. The build checks the context's `lean-toolchain`, the toolchain file's SHA-256 and the Mathlib and Tau Ceti checkouts against them, and fails otherwise. |
| 54 | |
| 55 | | ARG | Value | Source | |
| 56 | | --- | --- | --- | |
| 57 | | `UPSTREAM_COMMIT` | `630d1e43b442cab27717c3ebf94d218dea608374` | leanprover-community/riemann-hypothesis, `upstream.json` | |
| 58 | | `TOOLCHAIN` | `leanprover/lean4:v4.37.0-rc1` | upstream `lean-toolchain` | |
| 59 | | `LEAN_SHA256` | `2e1bbb832870bb81b7131cb70b13aec2cc7ed9f22e2bdbb236b86076ae20382d` | the digest GitHub lists for `lean-4.37.0-rc1-linux.tar.zst` | |
| 60 | | `MATHLIB_COMMIT` | `31ce06eaadf4a200c0e1407c5f10953cf606b8f8` | upstream `lakefile.toml` / `lake-manifest.json` | |
| 61 | | `TAUCETI_COMMIT` | `2a9233e5be32675476ae438bef6f6dd4ba93eb64` | upstream `lakefile.toml` / `lake-manifest.json` | |
| 62 | |
| 63 | ## Rebuild when main moves |
| 64 | |
| 65 | The image is the build of one commit of main. Rebuild it, under a new tag, whenever main's `lean-toolchain` or `lake-manifest.json` changes (for example a new Lean release, or new Mathlib or Tau Ceti pins): set the pins it moves in `lean.Dockerfile`, build from a checkout of the new main as above, and change the tag in `scienceslack.json` in the same PR. The check refuses a commit whose `lean-toolchain` differs from the image's. Rebuilding after other changes to main is optional: it only makes the checks faster, since less has to be recompiled. |