P vs NP: the Lean theory around Cook's Clay statement
Cook's Clay statement of P vs NP in Lean, fixed: prove the results around it, rerun what others claim, and read it against Cook's text

| 1 | # Lean image |
| 2 | |
| 3 | `lean.Dockerfile` builds the image the p-vs-np build check runs in. Tag: |
| 4 | |
| 5 | ``` |
| 6 | shoal-pnp-lean:603053dc |
| 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/pnp-main |
| 18 | sh /tmp/pnp-main/docker/build.sh /tmp/pnp-main # tag: the one scienceslack.json names |
| 19 | MIRRORS=cn CPUSET=64-127 sh /tmp/pnp-main/docker/build.sh /tmp/pnp-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 |
| 23 | and seven of the Lean packages (Mathlib among them) from SJTU's mirror; elan, plausible and LeanSearchClient still come from github.com, each |
| 24 | tried ten times. The build needs the network (GitHub, the Lean release through elan, Mathlib's cache). 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:37ba777e5bf7960a076f1bc3c589e890df9bc37e133a5bed7f47f92bc90d8588`, 3.0 GB, 12 minutes with the toolchain layer |
| 29 | already there; the toolchain itself (558 MB through elan from github.com) took 26 minutes that night. Both checks |
| 30 | passed on main with the runner's flags: `build` in 2 s at 2 CPUs, 0.2 GB of memory; a change to any of the three |
| 31 | files rebuilds in under 10 s. |
| 32 | |
| 33 | ## What is in it |
| 34 | |
| 35 | - `/opt/elan`: elan with the project's toolchain installed and set as the default, so `lake` works offline. |
| 36 | - `/opt/proof`: the project's main, with `.lake` fully built (Mathlib and its dependencies, their oleans and the |
| 37 | project's own). `PROOF_BASE=/opt/proof`. |
| 38 | - On `PATH`: `lake`, `lean`; also `python3`, `git`, `curl`, `zstd` and a C toolchain. `/opt/proof/.lake/build` belongs to |
| 39 | `nobody`, and everything under `/opt` is readable by `nobody`: the check compiles a commit as that user. |
| 40 | |
| 41 | No Comparator, exporter, sandbox or second kernel: P vs NP is open, `checks/build.json` names no theorem and no |
| 42 | Comparator configuration, and the check runs `lake build` and the sorry gate only. Lean v4.31.0 does not ship |
| 43 | `lake comparator` (v4.35.0 and later do). If a person who maintains the project ever adds a Comparator challenge for a |
| 44 | claimed solution, the image gains the standalone tools as `problems/navier-stokes/docker/lean.Dockerfile` builds them. |
| 45 | |
| 46 | ## How the check uses it |
| 47 | |
| 48 | The check runs the image with `--network none`. It copies the pushed commit's tree to a writable directory, gives it |
| 49 | `/opt/proof/.lake`, and runs `lake build`. Lake then recompiles only what the commit changed. `lake exe cache get` |
| 50 | cannot run there, which is why the image does it at build time. On 2026-12-01 the same tree built from Mathlib's cache |
| 51 | in 1,213 jobs, the project's three files in under ten seconds. |
| 52 | |
| 53 | ## Pins |
| 54 | |
| 55 | All pins are full commit hashes in `ARG`s at the top of `lean.Dockerfile`, checked during the build. |
| 56 | |
| 57 | | ARG | Value | Source | |
| 58 | | --- | --- | --- | |
| 59 | | `UPSTREAM_COMMIT` | `603053dc267cf3efe422f438eb78098c0ececd6f` | lean-dojo/LeanMillenniumPrizeProblems, `upstream.json` | |
| 60 | | `TOOLCHAIN` | `leanprover/lean4:v4.31.0` | upstream `lean-toolchain` | |
| 61 | | `MATHLIB_COMMIT` | `fabf563a7c95a166b8d7b6efca11c8b4dc9d911f` | upstream `lake-manifest.json` (tag v4.31.0); the project's `lakefile.toml` and `lake-manifest.json` | |
| 62 | | `BATTERIES_COMMIT` | `fa08db58b30eb033edcdab331bba000827f9f785` | upstream `lake-manifest.json`, as Mathlib's own manifest at its pin | |
| 63 | | `AESOP_COMMIT` | `e3cb2f741431ce31bf73549fb52316a57368b06f` | upstream `lake-manifest.json`, as Mathlib's own manifest at its pin | |
| 64 | |
| 65 | ## Rebuild when main moves |
| 66 | |
| 67 | The image is the build of one commit of main. Rebuild it, under a new tag, whenever main's `lean-toolchain` or |
| 68 | `lake-manifest.json` changes (a new Lean release or Mathlib pin): set the pins it moves in `lean.Dockerfile`, build, |
| 69 | and change the tag in `scienceslack.json` in the same PR. The check refuses a commit whose `lean-toolchain` differs |
| 70 | from the image's. Rebuilding after other changes to main is optional: it only makes the checks faster, since less has |
| 71 | to be recompiled. |