goldbach-spectral-bridge
Li and Liu's GRH + S ⇒ Goldbach in Lean, checked against the paper by Comparator: clean it up together, and settle S
| 1 | # Lean image for the goldbach-spectral-bridge `build` check (checks/build.py). |
| 2 | # |
| 3 | # Build with a checkout of the project's main as the context, not this folder: |
| 4 | # git clone <the project's repository> /tmp/goldbach-main |
| 5 | # git -C /tmp/goldbach-main checkout <main's commit> |
| 6 | # docker build -f docker/lean.Dockerfile -t shoal-goldbach-lean:c55db645 /tmp/goldbach-main |
| 7 | # |
| 8 | # The project is the folder formalization/ of subfish-zhou/conditional-goldbach-lean at c55db645, without the |
| 9 | # generated reports (upstream.json), with this project's lakefile.toml on top: it adds the upstream's own Comparator |
| 10 | # project (verification/independent-audit/comparator-project/TexAuditComparator) and the open statements (Open.lean) |
| 11 | # as libraries of the one package. Cloning upstream would give neither, so the image is built from the project's own |
| 12 | # tree: COPY puts it in /opt/proof. The check runs with --network none: it copies a commit's tree to a scratch |
| 13 | # directory, gives it /opt/proof/.lake, and runs lake build and `lake comparator --config comparator.json`. Nothing is |
| 14 | # downloaded at check time. |
| 15 | # |
| 16 | # Every pin is a full commit hash in an ARG below, checked once the dependencies are fetched. |
| 17 | |
| 18 | FROM ubuntu:24.04 |
| 19 | |
| 20 | # --- Pins ------------------------------------------------------------------- |
| 21 | |
| 22 | # subfish-zhou/conditional-goldbach-lean, and its formalization/lean-toolchain at that commit. |
| 23 | ARG UPSTREAM_COMMIT=c55db645f3b4aed00374fe4aa1fcee2428c88c4b |
| 24 | ARG TOOLCHAIN=leanprover/lean4:v4.35.0 |
| 25 | # From lake-manifest.json at that commit. |
| 26 | ARG MATHLIB_COMMIT=56a005855ea17e0b0958f73ec801ae140b0a1679 |
| 27 | ARG GOLDBACH_COMMIT=24490c2ab7787238f816d771c9176411dcbda503 |
| 28 | ARG LEANARCHITECT_COMMIT=9f3bb53916b9d6fa05b7777389e1844f82b1c9a6 |
| 29 | |
| 30 | # Comparator: Lean v4.35.0 ships it as `lake comparator` (sandboxed with bubblewrap), with its exporter, nanoda_bin and |
| 31 | # leanchecker beside it; the upstream's own audit ran exactly that (verification/independent-audit/comparator-manifest.json). |
| 32 | |
| 33 | # --- System packages -------------------------------------------------------- |
| 34 | |
| 35 | # python3 and curl are what Mathlib's cache tool uses; bubblewrap is the sandbox `lake comparator` runs in. |
| 36 | ENV DEBIAN_FRONTEND=noninteractive |
| 37 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 38 | ca-certificates curl git python3 build-essential zstd bubblewrap \ |
| 39 | && rm -rf /var/lib/apt/lists/* |
| 40 | |
| 41 | # The check may run as another user than the one that built; let git (and Lake, which calls git in each package) |
| 42 | # read every repository in the image. |
| 43 | RUN git config --system --add safe.directory '*' |
| 44 | |
| 45 | # --- Lean ------------------------------------------------------------------- |
| 46 | |
| 47 | ENV ELAN_HOME=/opt/elan |
| 48 | ENV PATH=/usr/local/bin:/opt/elan/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin |
| 49 | RUN curl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh \ |
| 50 | | sh -s -- -y --no-modify-path --default-toolchain none |
| 51 | RUN elan toolchain install "${TOOLCHAIN}" \ |
| 52 | && elan default "${TOOLCHAIN}" |
| 53 | |
| 54 | # --- The project ------------------------------------------------------------ |
| 55 | |
| 56 | # The context is a checkout of the project's main: its tree goes in whole, as the check's commits will be. |
| 57 | COPY . /opt/proof |
| 58 | WORKDIR /opt/proof |
| 59 | RUN rm -rf .git .lake \ |
| 60 | && test "$(cat lean-toolchain)" = "${TOOLCHAIN}" \ |
| 61 | && grep -q "${UPSTREAM_COMMIT}" docker/lean.Dockerfile |
| 62 | |
| 63 | # Mathlib's cache, then the dependencies at their pins, then a full build of the default targets (the library, the |
| 64 | # Comparator project and the open statements), so a pull request's build recompiles only what it changed. |
| 65 | RUN lake exe cache get \ |
| 66 | && test "$(git -C .lake/packages/mathlib rev-parse HEAD)" = "${MATHLIB_COMMIT}" \ |
| 67 | && test "$(git -C .lake/packages/goldbach rev-parse HEAD)" = "${GOLDBACH_COMMIT}" \ |
| 68 | && test "$(git -C .lake/packages/LeanArchitect rev-parse HEAD)" = "${LEANARCHITECT_COMMIT}" \ |
| 69 | && rm -rf /root/.cache/mathlib |
| 70 | RUN lake build |
| 71 | |
| 72 | # --- Comparator's second kernel --------------------------------------------- |
| 73 | |
| 74 | RUN ln -s "$(elan which --toolchain "${TOOLCHAIN}" nanoda_bin)" /usr/local/bin/nanoda_bin \ |
| 75 | && ln -s "$(elan which --toolchain "${TOOLCHAIN}" leanchecker)" /usr/local/bin/leanchecker \ |
| 76 | && lake comparator --help >/dev/null |
| 77 | |
| 78 | RUN for t in bwrap nanoda_bin leanchecker lake lean; do \ |
| 79 | command -v "$t" >/dev/null || { echo "missing: $t"; exit 1; }; \ |
| 80 | done |
| 81 | |
| 82 | ENV PROOF_BASE=/opt/proof |
| 83 | WORKDIR /opt/proof |
| 84 | CMD ["/bin/bash"] |
