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 for the hodge-conjecture `build` check (checks/build.py): everything before the compile. |
| 2 | # |
| 3 | # docker/build.sh builds this file with the tree of the project's main as the context (shoal-hodge-lean:3344da59-base), |
| 4 | # then compiles the project's own 33,429 files in a container of it and commits that container as |
| 5 | # shoal-hodge-lean:3344da59 (docker/README.md). A compile of hours does not belong in a layer that one failure throws |
| 6 | # away. |
| 7 | # |
| 8 | # The context is the project's main, not this folder: the project is the import closure of the CM Hodge challenge and |
| 9 | # solution inside lean/ of openai/math at 3344da59 (upstream.json), with this project's own lakefile.toml and |
| 10 | # lake-manifest.json, which require Mathlib alone. Cloning openai/math would bring its lakefile.lean and the 59 |
| 11 | # packages of its manifest, of which the proof imports Mathlib alone. The check runs with --network none: nothing is |
| 12 | # downloaded at check time. |
| 13 | # |
| 14 | # Every pin is a full commit hash or a checksum in an ARG below, and each download is checked against it. |
| 15 | |
| 16 | FROM ubuntu:24.04 |
| 17 | |
| 18 | # --- Where the downloads come from ------------------------------------------ |
| 19 | |
| 20 | # The defaults are each project's own servers. From Beijing (docker/build.sh with MIRRORS=cn): the Ubuntu archive by |
| 21 | # plain http from Aliyun (ca-certificates is not installed yet at the first apt step), the Lean toolchain from SJTU's |
| 22 | # mirror of its releases, Go from Aliyun, Go modules from goproxy.cn, Rust and its crates from rsproxy.cn, the git |
| 23 | # fetches through gh-proxy.com. |
| 24 | # raw.githubusercontent.com is not used: Beijing cannot reach it. |
| 25 | ARG APT_MIRROR= |
| 26 | ARG LEAN_DL=https://github.com/leanprover/lean4/releases/download |
| 27 | ARG GO_DL=https://go.dev/dl |
| 28 | ARG GOPROXY=https://proxy.golang.org,direct |
| 29 | ARG RUST_DIST=https://static.rust-lang.org |
| 30 | ARG CARGO_MIRROR= |
| 31 | # A proxy in front of github.com for the git fetches (docker/clone-at) and elan's release, e.g. |
| 32 | # https://gh-proxy.com/https://github.com |
| 33 | ARG GITHUB_MIRROR= |
| 34 | |
| 35 | # --- Pins ------------------------------------------------------------------- |
| 36 | |
| 37 | # openai/math, whose lean/ folder the project starts from, and its lean-toolchain at that commit, with the SHA-256 |
| 38 | # GitHub lists for the release's lean-4.34.1-linux.tar.zst. |
| 39 | ARG UPSTREAM_COMMIT=3344da59991ed94f9ba711217b29c1d760badfa6 |
| 40 | ARG TOOLCHAIN=leanprover/lean4:v4.34.1 |
| 41 | ARG LEAN_SHA256=47bf4bbd78f70c2e9670598ab7124d92b6efb7330ff33e5fbb4030f6fd72e4e4 |
| 42 | # From the project's lake-manifest.json (openai/math's pins at that commit). Every package is cloned at the manifest's |
| 43 | # commit; these three are also checked here. |
| 44 | ARG MATHLIB_COMMIT=d13f23b723b8a846827a245b89c10fc7d3f11612 |
| 45 | ARG BATTERIES_COMMIT=f2effa3d803fda822b1f97b806c47cf2adfbcbc2 |
| 46 | ARG AESOP_COMMIT=355695d523e41d0554926416cba2a2b3544fbbc9 |
| 47 | |
| 48 | # Comparator and its exporter, built here and not as packages of the project. Lean v4.34.1 does not ship |
| 49 | # `lake comparator` (v4.35.0 and later do), so the standalone tools are used, at their v4.34.0 tags. |
| 50 | ARG COMPARATOR_REV=d03acab154d269c06e60e4de7e4cc85deebff94b |
| 51 | ARG LEAN4EXPORT_REV=076e8e57707e813375e8f9da8bf989799ace9680 |
| 52 | |
| 53 | # Comparator's sandbox (landrun 0.1.18) and the second kernel (nanoda_lib 0.4.18), as the navier-stokes and |
| 54 | # poincare-conjecture images pin them. |
| 55 | ARG LANDRUN_REV=811cfff51ceaf3d9843708aa6d22e9b84ccac8b4 |
| 56 | ARG NANODA_REV=079049d584b2aed2b0172218164082f4fc6eede2 |
| 57 | |
| 58 | # Build tools for landrun (go.mod asks for Go 1.24) and nanoda (Rust), used here and removed. |
| 59 | ARG GO_VERSION=1.24.13 |
| 60 | ARG GO_SHA256=1fc94b57134d51669c72173ad5d49fd62afb0f1db9bf3f798fd98ee423f8d730 |
| 61 | ARG RUST_VERSION=1.100.1 |
| 62 | |
| 63 | # --- System packages -------------------------------------------------------- |
| 64 | |
| 65 | # python3 runs the check; curl and zstd are what Lake and Mathlib's cache tool use. |
| 66 | ENV DEBIAN_FRONTEND=noninteractive |
| 67 | RUN if [ -n "$APT_MIRROR" ]; then sed -i "s#http://archive.ubuntu.com/ubuntu#$APT_MIRROR#; s#http://security.ubuntu.com/ubuntu#$APT_MIRROR#" /etc/apt/sources.list.d/ubuntu.sources; fi \ |
| 68 | && apt-get update && apt-get install -y --no-install-recommends \ |
| 69 | ca-certificates curl git python3 build-essential zstd \ |
| 70 | && rm -rf /var/lib/apt/lists/* |
| 71 | |
| 72 | # The check runs the commit's build as `nobody`; let git (and Lake, which calls git in each package) read every |
| 73 | # repository in the image. clone-at fetches one pinned commit of a repository, with retries (docker/clone-at). |
| 74 | COPY docker/clone-at /usr/local/bin/clone-at |
| 75 | RUN git config --system --add safe.directory '*' && chmod 755 /usr/local/bin/clone-at |
| 76 | |
| 77 | # --- Lean ------------------------------------------------------------------- |
| 78 | |
| 79 | # elan 4.1.2 from its GitHub release, checksum-verified. The toolchain as its release tarball, likewise, unpacked where elan keeps a |
| 80 | # toolchain of that name: `elan toolchain install` takes it from releases.lean-lang.org, which redirects to GitHub's |
| 81 | # release, and from Beijing that download stalls (12-02: 1.7 MB in two minutes); LEAN_DL lets a mirror serve the file. |
| 82 | ENV ELAN_HOME=/opt/elan |
| 83 | ENV PATH=/usr/local/bin:/opt/elan/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin |
| 84 | ARG ELAN_SHA256=f81c2e48c1588d4612cd2c8851947898a45ac8d72748a07dff3a5694f1cf589b |
| 85 | RUN curl -sSfL --retry 8 --retry-all-errors --connect-timeout 20 --speed-limit 1000 --speed-time 30 \ |
| 86 | "${GITHUB_MIRROR:-https://github.com}/leanprover/elan/releases/download/v4.1.2/elan-x86_64-unknown-linux-gnu.tar.gz" -o /tmp/elan.tgz \ |
| 87 | && echo "${ELAN_SHA256} /tmp/elan.tgz" | sha256sum -c - \ |
| 88 | && tar -xzf /tmp/elan.tgz -C /tmp && /tmp/elan-init -y --no-modify-path --default-toolchain none && rm /tmp/elan-init /tmp/elan.tgz |
| 89 | RUN v="${TOOLCHAIN#*:v}" && dir="/opt/elan/toolchains/$(echo "${TOOLCHAIN}" | sed 's#/#--#; s#:#---#')" \ |
| 90 | && curl -sSfL --retry 8 --retry-all-errors --connect-timeout 20 "${LEAN_DL}/v$v/lean-$v-linux.tar.zst" -o /tmp/lean.tar.zst \ |
| 91 | && echo "${LEAN_SHA256} /tmp/lean.tar.zst" | sha256sum -c - \ |
| 92 | && mkdir -p "$dir" && tar --zstd -xf /tmp/lean.tar.zst -C "$dir" --strip-components 1 && rm /tmp/lean.tar.zst \ |
| 93 | && elan default "${TOOLCHAIN}" && chmod -R a+rX /opt/elan \ |
| 94 | && lean --version | grep -q "version $v" |
| 95 | |
| 96 | # --- The dependencies ------------------------------------------------------- |
| 97 | |
| 98 | # From the three files that name them, so that a change elsewhere in main does not fetch Mathlib's cache (5 GB) again. |
| 99 | # Each package of the manifest is fetched at its commit first (Lake does not try a clone again when the connection |
| 100 | # fails, and clones every package's whole history), then Mathlib's oleans: a few of the cache's downloads fail now and then, and each try fetches only what is |
| 101 | # still missing. Mathlib's download store (~/.cache/mathlib) is unpacked into .lake by then and removed in the same |
| 102 | # layer; so is the chmod: the cache unpacks its files 0600, and the check reads them as nobody. |
| 103 | WORKDIR /opt/proof |
| 104 | COPY lakefile.toml lake-manifest.json lean-toolchain /opt/proof/ |
| 105 | RUN test "$(cat lean-toolchain)" = "${TOOLCHAIN}" \ |
| 106 | && python3 -c 'import json; [print(p["url"], ".lake/packages/" + p["name"], p["rev"]) for p in json.load(open("lake-manifest.json"))["packages"]]' \ |
| 107 | | while read -r url dir rev; do clone-at "$url" "$dir" "$rev" || exit 1; done \ |
| 108 | && test "$(git -C .lake/packages/mathlib rev-parse HEAD)" = "${MATHLIB_COMMIT}" \ |
| 109 | && test "$(git -C .lake/packages/batteries rev-parse HEAD)" = "${BATTERIES_COMMIT}" \ |
| 110 | && test "$(git -C .lake/packages/aesop rev-parse HEAD)" = "${AESOP_COMMIT}" \ |
| 111 | && (lake exe cache get || lake exe cache get || lake exe cache get) \ |
| 112 | && test "$(git -C .lake/packages/mathlib rev-parse HEAD)" = "${MATHLIB_COMMIT}" \ |
| 113 | && rm -rf /root/.cache/mathlib \ |
| 114 | && chmod -R a+rX /opt/proof |
| 115 | |
| 116 | # --- Comparator and lean4export --------------------------------------------- |
| 117 | |
| 118 | # Each built on its own with the project's toolchain (their v4.34.0 tags ask for leanprover/lean4:v4.34.0), and |
| 119 | # linked onto PATH. Comparator has lean4export as its package: cloned at the same commit, so Lake fetches nothing. |
| 120 | RUN clone-at https://github.com/leanprover/lean4export /opt/lean4export "${LEAN4EXPORT_REV}" \ |
| 121 | && echo "${TOOLCHAIN}" > /opt/lean4export/lean-toolchain \ |
| 122 | && (cd /opt/lean4export && lake build lean4export) \ |
| 123 | && ln -s /opt/lean4export/.lake/build/bin/lean4export /usr/local/bin/lean4export \ |
| 124 | && chmod -R a+rX /opt/lean4export |
| 125 | RUN clone-at https://github.com/leanprover/comparator /opt/comparator "${COMPARATOR_REV}" \ |
| 126 | && clone-at https://github.com/leanprover/lean4export /opt/comparator/.lake/packages/lean4export "${LEAN4EXPORT_REV}" \ |
| 127 | && echo "${TOOLCHAIN}" > /opt/comparator/lean-toolchain \ |
| 128 | && (cd /opt/comparator && lake build comparator) \ |
| 129 | && test "$(git -C /opt/comparator/.lake/packages/lean4export rev-parse HEAD)" = "${LEAN4EXPORT_REV}" \ |
| 130 | && ln -s /opt/comparator/.lake/build/bin/comparator /usr/local/bin/comparator \ |
| 131 | && chmod -R a+rX /opt/comparator |
| 132 | |
| 133 | # --- landrun ---------------------------------------------------------------- |
| 134 | |
| 135 | # The Go tarball, checksum-verified. |
| 136 | RUN curl -sSfL --retry 8 --retry-all-errors --connect-timeout 20 "${GO_DL}/go${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tgz \ |
| 137 | && echo "${GO_SHA256} /tmp/go.tgz" | sha256sum -c - \ |
| 138 | && tar -C /tmp -xzf /tmp/go.tgz \ |
| 139 | && clone-at https://github.com/Zouuup/landrun /tmp/landrun "${LANDRUN_REV}" \ |
| 140 | && cd /tmp/landrun \ |
| 141 | && GOPROXY="${GOPROXY}" GOTOOLCHAIN=local GOPATH=/tmp/gopath GOCACHE=/tmp/gocache /tmp/go/bin/go build -o /usr/local/bin/landrun ./cmd/landrun \ |
| 142 | && cd / && rm -rf /tmp/go /tmp/go.tgz /tmp/landrun /tmp/gopath /tmp/gocache |
| 143 | |
| 144 | # --- nanoda_bin ------------------------------------------------------------- |
| 145 | |
| 146 | # main.json has enable_nanoda false, so Comparator does not call it; it is in the image so the second kernel can be |
| 147 | # run on the export by hand, as upstream's ComparatorChallenges README describes. |
| 148 | RUN export RUSTUP_HOME=/tmp/rustup CARGO_HOME=/tmp/cargo RUSTUP_DIST_SERVER="${RUST_DIST}" RUSTUP_UPDATE_ROOT="${RUST_DIST}/rustup" \ |
| 149 | && curl -sSfL --retry 8 --retry-all-errors --connect-timeout 20 "${RUST_DIST}/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" -o /tmp/rustup-init && chmod +x /tmp/rustup-init \ |
| 150 | && /tmp/rustup-init -y --no-modify-path --profile minimal --default-toolchain "${RUST_VERSION}" \ |
| 151 | && if [ -n "$CARGO_MIRROR" ]; then printf '[source.crates-io]\nreplace-with = "mirror"\n[source.mirror]\nregistry = "%s"\n' "$CARGO_MIRROR" > /tmp/cargo/config.toml; fi \ |
| 152 | && clone-at https://github.com/ammkrn/nanoda_lib /tmp/nanoda "${NANODA_REV}" \ |
| 153 | && cd /tmp/nanoda \ |
| 154 | && /tmp/cargo/bin/cargo build --release --locked --bin nanoda_bin \ |
| 155 | && install -m 0755 target/release/nanoda_bin /usr/local/bin/nanoda_bin \ |
| 156 | && cd / && rm -rf /tmp/rustup /tmp/cargo /tmp/nanoda /tmp/rustup-init |
| 157 | |
| 158 | # Every tool must be on PATH. |
| 159 | RUN for t in lean4export comparator landrun nanoda_bin lake lean python3 git which; do \ |
| 160 | command -v "$t" >/dev/null || { echo "missing: $t"; exit 1; }; \ |
| 161 | done |
| 162 | |
| 163 | # --- The project ------------------------------------------------------------ |
| 164 | |
| 165 | # The context is the tree of the project's main as git holds it (docker/build.sh sends `git archive`): it goes in |
| 166 | # whole, as the check's commits will be, readable by all as git archives it. docker/build.sh compiles it next, in a |
| 167 | # container. (No chmod -R here: in a layer of its own it would copy every file of Mathlib's build.) |
| 168 | COPY . /opt/proof |
| 169 | RUN test ! -e .git && test -d .lake/packages/mathlib \ |
| 170 | && test -f lakefile.toml && test ! -e lakefile.lean \ |
| 171 | && grep -q "${MATHLIB_COMMIT}" lake-manifest.json \ |
| 172 | && grep -q "${UPSTREAM_COMMIT}" docker/lean.Dockerfile |
| 173 | |
| 174 | ENV PROOF_BASE=/opt/proof |
| 175 | CMD ["/bin/bash"] |