Hodge conjecture: the CM case in Lean, read and discussed
OpenAI's Lean proof of the Hodge conjecture for CM abelian varieties: rerun it, read its statement, and keep the open questions with their sources. The conjecture is open

| 1 | # Lean image |
| 2 | |
| 3 | The image the hodge-conjecture `build` check runs in. Tag, as `scienceslack.json` names it: |
| 4 | |
| 5 | ``` |
| 6 | shoal-hodge-lean:3344da59 |
| 7 | ``` |
| 8 | |
| 9 | Nothing is published: the runner that runs the check must have the image locally, so it is built on the runner's |
| 10 | machine. |
| 11 | |
| 12 | ## Build |
| 13 | |
| 14 | `build.sh` does it in three steps, each of which can be run again. The context is the tree of this project's `main`, |
| 15 | not this folder: the project is only part of openai/math's `lean/` (the import closure of the CM Hodge challenge, see |
| 16 | `upstream.json`) with this project's own `lakefile.toml` and `lake-manifest.json`, so cloning openai/math would not |
| 17 | reproduce it. |
| 18 | |
| 19 | ```bash |
| 20 | git clone <the project's repository> hodge-main # main at the commit the image is for |
| 21 | cd hodge-main |
| 22 | nohup sh docker/build.sh "$PWD" > ../hodge-image.log 2>&1 & |
| 23 | ``` |
| 24 | |
| 25 | | Step | What it does | How long | |
| 26 | | --- | --- | --- | |
| 27 | | `base` | `lean.Dockerfile` with `git archive` of the checkout as the context: Ubuntu 24.04, elan and the toolchain, each package of the manifest at its commit, Mathlib's oleans from its cache, Comparator, lean4export, landrun, nanoda_bin, the tree in `/opt/proof`. Tagged `shoal-hodge-lean:3344da59-base` | minutes | |
| 28 | | `compile` | `lake build` of every library `lakefile.toml` declares (`OAI`, `HodgeConjecture`, `ComparatorChallenges`: the project's own 33,429 files) in a container named `hodge-lean-build`, with no network and `LEAN_NUM_THREADS` set to the cores it has (Lake otherwise starts a `lean` per core of the host); the `.setup.json` files Lake writes per module and never reads again (about 1 MB each) are deleted as it goes; then the build becomes `nobody`'s, so the check builds a commit on top of it without copying it | hours (below) | |
| 29 | | `commit` | the finished container becomes `shoal-hodge-lean:3344da59`; `lake build --no-build` of the same libraries in the new image must find nothing left to build | minutes | |
| 30 | |
| 31 | `sh docker/build.sh <checkout> compile` after a stop (a reboot, a full disk, a kill) starts the same container again, |
| 32 | and Lake goes on from the modules it has: the compile is not a Dockerfile layer, where one failure would throw hours |
| 33 | away. Watch it with |
| 34 | |
| 35 | ```bash |
| 36 | docker exec hodge-lean-build sh -c 'find .lake/build/lib -name "*.olean" | wc -l' # of 33,429 |
| 37 | docker logs --tail 5 hodge-lean-build |
| 38 | ``` |
| 39 | |
| 40 | Settings, from the environment: `TAG`, `NAME` (the compile's container), `CPUSET` (the cores to use, e.g. `96-127`; |
| 41 | Lake starts one job per core it sees), `MEMORY` (a limit for the compile's container), and `MIRRORS=cn` on a host in |
| 42 | Beijing: the Ubuntu archive and Go from Aliyun, the Lean toolchain from SJTU's mirror of its releases, Go modules from |
| 43 | goproxy.cn, Rust and crates from rsproxy.cn, elan's release and the git fetches through gh-proxy.com. Every download |
| 44 | is still checked against a commit hash or a SHA-256 in `lean.Dockerfile`. From Beijing, connections to github.com |
| 45 | time out about every other time, so each repository is fetched as its one pinned commit (`clone-at`), through the |
| 46 | proxy and from github.com in turn, up to ten times. |
| 47 | |
| 48 | Upstream notes that a build this size may fail where Linux's `vm.max_map_count` is low (`UPSTREAM.md`). The |
| 49 | production host has 1,048,576 (the kernel's default is 65,530). |
| 50 | |
| 51 | ## What is in it |
| 52 | |
| 53 | - `/opt/elan`: elan with the project's toolchain (Lean v4.34.1) as the default, so `lake` works offline. |
| 54 | - `/opt/proof`: the project's tree at the checked-out commit, with `.lake` fully built: Mathlib and its dependencies |
| 55 | (`.lake/packages`, root's, read-only to the check's `nobody`) and the project's own build (`.lake/build`, |
| 56 | `nobody`'s). `PROOF_BASE=/opt/proof`. |
| 57 | - `/opt/comparator`, `/opt/lean4export`: Comparator and lean4export at their `v4.34.0` tags, built with the project's |
| 58 | toolchain. |
| 59 | - On `PATH`: `lake`, `lean`, `comparator`, `lean4export`, `landrun`, `nanoda_bin`; also `python3`, `git`, `curl`, |
| 60 | `zstd` and a C toolchain. |
| 61 | |
| 62 | Everything under `/opt` is readable by `nobody`: the check runs a commit's build as that user. |
| 63 | |
| 64 | ## How the check uses it |
| 65 | |
| 66 | The check runs the image with `--network none`. `checks/build.py` says what it does with a commit; Lake recompiles |
| 67 | only what the commit changed. `lake exe cache get` cannot run there, which is why the image holds Mathlib's oleans. |
| 68 | |
| 69 | Comparator is not a dependency of the project: Lean v4.34.1 does not ship `lake comparator` (v4.35.0 does), and the |
| 70 | project's `lakefile.toml` requires Mathlib alone. The image builds the standalone `leanprover/comparator` and |
| 71 | `lean4export`, each at its `v4.34.0` tag (the tags ask for v4.34.0; the image builds them with v4.34.1), and links |
| 72 | both into `/usr/local/bin`. `main.json` does not enable nanoda, so Comparator checks with the Lean kernel only; |
| 73 | `nanoda_bin` is there to run by hand. |
| 74 | |
| 75 | ## Pins |
| 76 | |
| 77 | All pins are in `ARG`s at the top of `lean.Dockerfile`. After each fetch the build checks `git rev-parse HEAD` (or the |
| 78 | file's SHA-256) against its pin and fails otherwise. |
| 79 | |
| 80 | | ARG | Value | Source | |
| 81 | | --- | --- | --- | |
| 82 | | `UPSTREAM_COMMIT` | `3344da59991ed94f9ba711217b29c1d760badfa6` | openai/math, `upstream.json` (the context's tree comes from it) | |
| 83 | | `ELAN_SHA256` | `f81c2e48…f589b` | elan 4.1.2's `elan-x86_64-unknown-linux-gnu.tar.gz`, as github.com serves it | |
| 84 | | `TOOLCHAIN`, `LEAN_SHA256` | `leanprover/lean4:v4.34.1`, `47bf4bbd…72e4e4` | upstream `lean/lean-toolchain`; the digest GitHub lists for the release's `lean-4.34.1-linux.tar.zst` | |
| 85 | | `MATHLIB_COMMIT` | `d13f23b723b8a846827a245b89c10fc7d3f11612` | upstream `lean/lake-manifest.json` and `lakefile.lean`; this project's `lakefile.toml` | |
| 86 | | `BATTERIES_COMMIT` | `f2effa3d803fda822b1f97b806c47cf2adfbcbc2` | upstream `lean/lake-manifest.json` (all nine packages of this project's manifest are at upstream's commits) | |
| 87 | | `AESOP_COMMIT` | `355695d523e41d0554926416cba2a2b3544fbbc9` | the same | |
| 88 | | `COMPARATOR_REV` | `d03acab154d269c06e60e4de7e4cc85deebff94b` | leanprover/comparator tag `v4.34.0` | |
| 89 | | `LEAN4EXPORT_REV` | `076e8e57707e813375e8f9da8bf989799ace9680` | leanprover/lean4export tag `v4.34.0`; Comparator's manifest at its tag | |
| 90 | | `LANDRUN_REV` | `811cfff51ceaf3d9843708aa6d22e9b84ccac8b4` (0.1.18) | as the navier-stokes and poincare-conjecture images | |
| 91 | | `NANODA_REV` | `079049d584b2aed2b0172218164082f4fc6eede2` (0.4.18) | as the navier-stokes and poincare-conjecture images | |
| 92 | | `GO_VERSION`, `GO_SHA256` | 1.24.13 | landrun's `go.mod` asks for Go 1.24; checksum from go.dev | |
| 93 | | `RUST_VERSION` | 1.100.1 | Rust stable on 2026-12-01; nanoda builds with `cargo build --locked` | |
| 94 | |
| 95 | ## Rebuild when main moves |
| 96 | |
| 97 | The image is the build of one commit of main. A check recompiles what differs between that commit and the pushed |
| 98 | one, so the further main moves from the image, the more every check recompiles: rebuild when a merged change touched |
| 99 | a file many others import (`build` then takes long for every pull request), and always when main's `lean-toolchain` |
| 100 | or `lake-manifest.json` changes (a new Lean release, a new Mathlib pin): the check refuses a commit whose |
| 101 | `lean-toolchain` differs from the image's. |
| 102 | |
| 103 | To rebuild after ordinary merges, keep the container's work: start from the current image instead of from nothing |
| 104 | (these two commands are written from `build.sh`'s steps and have not been run yet). |
| 105 | |
| 106 | ```bash |
| 107 | git -C hodge-main pull |
| 108 | docker run -d --name hodge-lean-rebuild --network none -v "$PWD/hodge-main":/src:ro shoal-hodge-lean:3344da59 bash -c \ |
| 109 | 'cd /src && git archive HEAD | tar -x -C /opt/proof && cd /opt/proof && lake build && chown -R nobody:nogroup .lake/build' |
| 110 | docker wait hodge-lean-rebuild && docker commit -c 'CMD ["/bin/bash"]' hodge-lean-rebuild shoal-hodge-lean:3344da59 |
| 111 | ``` |
| 112 | |
| 113 | (Files a merge deleted stay in `/opt/proof` this way; they are not built into anything a commit imports.) For a new |
| 114 | toolchain or Mathlib pin, set the pins they move in `lean.Dockerfile` (with a toolchain of v4.35.0 or later, drop |
| 115 | Comparator's build and use the toolchain's `lake comparator`, as the riemann-hypothesis image does), run `build.sh` |
| 116 | from a checkout of that commit under a new tag, and change the tag in `scienceslack.json` in the same pull request. |