Getting Started
What you need, how to get the pinned environment, and how to run your first investigation, with and without Docker. The text says which commands have been checked in the reference environment.
This part is the reference. Part III explains why the laboratory works as it does; this part says how to use it. Each command below was run in the reference environment unless the text says otherwise. Where a command has not been verified in the current image, the text says so.
What you need
| For | You need |
|---|---|
| reading the records | nothing beyond a text editor |
| the independent computations | Python 3.11 or later, and the repository |
| the full investigations | Docker (Desktop or Engine) with about 40 GB of free disk to build, on linux/amd64 |
Get the repository
The book’s repository is private. These instructions assume a checkout at the repository root. A clean checkout matters: the records note whether any tracked file differed from the commit.
git status --short --untracked-files=no
Without Docker: the computations
pip install -e .
math-engine proof --list
This was checked on Linux with Python 3.13 on 2026-11-14. The list shows the eight investigations and, separately, the tutorial.
Each investigation’s independent computation then runs on its own, for example:
python -m math_engine.proofs.fermat_compute --divisor 641 --cofactor 6700417
python -m math_engine.proofs.kempe_compute --drop B3-Gout
Both were checked in the reference environment. The second exits with code 1 by design: it is Kempe’s failure control. Chapter 30 lists them all.
The investigations that need no Mathlib also run end to end outside the image,
with status checked_unpinned (a rehearsal, not evidence):
math-engine proof kempe --out out/proof-kempe
math-engine proof kempe --verify out/proof-kempe
These were checked in the reference environment. For the tutorial and the
wrong-theorem demonstration you also need a Lean 4.35.0 lean command, given
in MATH_PROOF_LEAN or MATH_PROOF_CORE_LEAN (Chapter 32).
With Docker: the pinned environment
Build the image (once; about 40 minutes the first time):
docker build -f docker/Dockerfile -t math-env --build-arg BOOK_COMMIT=$(git rev-parse HEAD) .
The recorded image was built on 2026-11-12 and 2026-11-13; every recorded run in
the book names the resulting image, sha256:74006085…. Building takes too long
to repeat routinely. The build steps, times and pins are in docker/README.md.
Confirm it:
docker run --rm math-env selftest
docker run --rm math-env info
Both were checked on Windows 11 with Docker Desktop on 2026-11-14. selftest
prints one line per tool, each starting ok. info prints the book commit the
image was built from and every tool’s version.
Your first investigation
$img = docker image inspect math-env --format '{{.Id}}'
docker run --rm --network none -e UV_OFFLINE=1 -e MATHENV_IMAGE_ID=$img `
-v "${PWD}:/source:ro" -v "${PWD}/out:/out" `
math-env uv run --offline math-engine proof fermat --out /out/proof-fermat
This is the form that produced the book’s recorded runs (for Fermat,
n1-fermat/kernel-runs/2026-11-13-approved/). In a Unix shell, use
img=$(docker image inspect …) and replace the backticks with backslashes. It
writes out/proof-fermat/ and ends with a status line that names the evidence
kind and whether a correspondence record applies. The Fermat run used here
ended kernel_checked_correspondence_approved.
-e UV_OFFLINE=1 is required. The image prepares a fresh copy of the book
before every command, and without it that step tries to reach the Python
package index, which --network none forbids.
Check the result (no Docker needed):
math-engine proof --verify out/proof-fermat
It prints evidence intact or a list of problems. Inside the image the same
check is:
math-env uv run --offline math-engine proof --verify /out/proof-fermat
That in-image form passed in the current reference run.
The shorter math-env proof NAME form is not available in the current
image. The image’s own proof command was added to its entry point
(docker/mathenv) in commit d4189ac, after the image the book’s runs use
(sha256:74006085…) was built. In that image, math-env proof fermat fails
with exec: proof: not found. It needs an image rebuilt from a later commit;
every command in this book uses the longer form.
Running the reference check yourself
python scripts/check_reference_commands.py local
python scripts/check_reference_commands.py docker
Each writes out/reference-check/<profile>/transcript.json with every command,
its exit code and the end of its output. The local profile passed 26 checks on
2026-11-14. The Docker profile has two recorded runs:
- run 1: 4 passed, 7 failed, every failure a command without
-e UV_OFFLINE=1; - run 2, with that fixed: 5 passed, 6 failed, every failure a command using the
math-env proofform, which the current image does not have (above); - run 3, with the long form throughout (commit
422571d): 11 passed, 0 failed. The short form, kept as an informational check (R-D12), failed as expected.
On the current image, every Docker command in this part has a passing record:
the image identifier, selftest, info, the tutorial, Fermat (ending
kernel_checked_correspondence_approved, 52 seconds), --verify in the image,
Kempe with and without MATHENV_IMAGE_ID, a --systems partial run of Simpson
(ending partial_run), and the runner’s tests inside the image (35 passed, 1
skipped). The short math-env proof NAME form still fails because the current
image predates that entry point.
Further Reading
For deeper study; not sources for the chapter’s claims.
- Leonardo de Moura, Sebastian Ullrich. “The Lean 4 Theorem Prover and Programming Language.” In Automated Deduction — CADE 28, Lecture Notes in Computer Science 12699 (Springer, 2021), 625–635. DOI. Why read it: The primary paper for Lean 4, the proof assistant used in the book’s main environment, covering its design and its trusted kernel.
- The mathlib Community. “The Lean Mathematical Library.” In Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (ACM, 2020), 367–381. DOI. Why read it: Describes Mathlib, the library on which the book’s Lean proofs depend, including its organisation and its role in formalized mathematics.
- The Rocq Prover. The Rocq Prover Reference Manual (Rocq 9.0, 2026). link. Why read it: The authoritative reference for Rocq syntax, tactics and libraries, the second kernel used in the book’s investigations.
Next in Part IV: Chapter 30, every investigation at a glance.