# Lean image `lean.Dockerfile` builds the image the p-vs-np build check runs in. Tag: ``` shoal-pnp-lean:603053dc ``` `scienceslack.json` refers to this exact name. ## Build On the machine whose runner will use it, with a checkout of the project's main as the context (not this folder, and not a clone of upstream: the image is the build of our main): ```bash git clone /tmp/pnp-main sh /tmp/pnp-main/docker/build.sh /tmp/pnp-main # tag: the one scienceslack.json names MIRRORS=cn CPUSET=64-127 sh /tmp/pnp-main/docker/build.sh /tmp/pnp-main # on the Beijing host, on those cores ``` `build.sh` is one `docker build` with the classic builder and the host's network. `MIRRORS=cn` takes apt from Aliyun and seven of the Lean packages (Mathlib among them) from SJTU's mirror; elan, plausible and LeanSearchClient still come from github.com, each 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 the image locally. Built on the production host on 2026-12-02 (16 cores, `MIRRORS=cn`): image `sha256:37ba777e5bf7960a076f1bc3c589e890df9bc37e133a5bed7f47f92bc90d8588`, 3.0 GB, 12 minutes with the toolchain layer already there; the toolchain itself (558 MB through elan from github.com) took 26 minutes that night. Both checks 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 files rebuilds in under 10 s. ## What is in it - `/opt/elan`: elan with the project's toolchain installed and set as the default, so `lake` works offline. - `/opt/proof`: the project's main, with `.lake` fully built (Mathlib and its dependencies, their oleans and the project's own). `PROOF_BASE=/opt/proof`. - On `PATH`: `lake`, `lean`; also `python3`, `git`, `curl`, `zstd` and a C toolchain. `/opt/proof/.lake/build` belongs to `nobody`, and everything under `/opt` is readable by `nobody`: the check compiles a commit as that user. No Comparator, exporter, sandbox or second kernel: P vs NP is open, `checks/build.json` names no theorem and no Comparator configuration, and the check runs `lake build` and the sorry gate only. Lean v4.31.0 does not ship `lake comparator` (v4.35.0 and later do). If a person who maintains the project ever adds a Comparator challenge for a claimed solution, the image gains the standalone tools as `problems/navier-stokes/docker/lean.Dockerfile` builds them. ## How the check uses it The check runs the image with `--network none`. It copies the pushed commit's tree to a writable directory, gives it `/opt/proof/.lake`, and runs `lake build`. 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. On 2026-12-01 the same tree built from Mathlib's cache in 1,213 jobs, the project's three files in under ten seconds. ## Pins All pins are full commit hashes in `ARG`s at the top of `lean.Dockerfile`, checked during the build. | ARG | Value | Source | | --- | --- | --- | | `UPSTREAM_COMMIT` | `603053dc267cf3efe422f438eb78098c0ececd6f` | lean-dojo/LeanMillenniumPrizeProblems, `upstream.json` | | `TOOLCHAIN` | `leanprover/lean4:v4.31.0` | upstream `lean-toolchain` | | `MATHLIB_COMMIT` | `fabf563a7c95a166b8d7b6efca11c8b4dc9d911f` | upstream `lake-manifest.json` (tag v4.31.0); the project's `lakefile.toml` and `lake-manifest.json` | | `BATTERIES_COMMIT` | `fa08db58b30eb033edcdab331bba000827f9f785` | upstream `lake-manifest.json`, as Mathlib's own manifest at its pin | | `AESOP_COMMIT` | `e3cb2f741431ce31bf73549fb52316a57368b06f` | upstream `lake-manifest.json`, as Mathlib's own manifest at its pin | ## Rebuild when main moves 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 (a new Lean release or Mathlib pin): set the pins it moves in `lean.Dockerfile`, build, 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.