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 | # The Goldbach maintainer's workspace: the image the `lean` check runs in and the maintainer's look runs commands in. |
| 2 | # |
| 3 | # Build (about an hour the first time; the Mathlib cache is ~5 GB): |
| 4 | # docker build -f docker/lean-check.Dockerfile -t shoal-goldbach-lean:4.35-c55db645 docker/ |
| 5 | # |
| 6 | # It pins the Li–Liu development and prebuilds it, Fu's workspace for ¬R and GRH, and the kernels V-2 names (Lean |
| 7 | # 4.35.0's toolchain ships leanchecker, lean4lean, nanoda_bin and con-leche). At check time checks/lean_verify.py |
| 8 | # compiles the approved Challenge as root and the route's Solution as nobody against these builds, which is why every |
| 9 | # file under /opt is world-readable, and judges the two with lake comparator. No network is used at check time. The |
| 10 | # build downloads from the Ubuntu archive (or APT_MIRROR), github.com (elan, the git clones), releases.lean-lang.org |
| 11 | # (the toolchain), cache.mathlib.org (twice ~5 GB) and PyPI (or PIP_INDEX_URL); not from raw.githubusercontent.com, |
| 12 | # which the Beijing site cannot reach (12-01). |
| 13 | |
| 14 | FROM ubuntu:24.04 |
| 15 | |
| 16 | # On the Beijing site: --build-arg APT_MIRROR=http://mirrors.aliyun.com/ubuntu (http: ca-certificates is not installed |
| 17 | # yet, and https fails its certificate check) --build-arg PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple |
| 18 | ARG APT_MIRROR= |
| 19 | ARG PIP_INDEX_URL=https://pypi.org/simple |
| 20 | ENV DEBIAN_FRONTEND=noninteractive |
| 21 | 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 \ |
| 22 | && apt-get update && apt-get install -y --no-install-recommends \ |
| 23 | ca-certificates curl git python3 python3-venv build-essential zstd ripgrep bubblewrap \ |
| 24 | && rm -rf /var/lib/apt/lists/* |
| 25 | |
| 26 | ENV ELAN_HOME=/opt/elan |
| 27 | ENV PATH=/opt/elan/bin:${PATH} |
| 28 | RUN curl -sSfL https://github.com/leanprover/elan/releases/download/v4.1.2/elan-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C /tmp \ |
| 29 | && /tmp/elan-init -y --no-modify-path --default-toolchain none && rm /tmp/elan-init |
| 30 | RUN elan toolchain install leanprover/lean4:v4.35.0 \ |
| 31 | && elan default leanprover/lean4:v4.35.0 |
| 32 | |
| 33 | WORKDIR /opt |
| 34 | RUN git clone https://github.com/subfish-zhou/conditional-goldbach-lean.git goldbach \ |
| 35 | && git -C goldbach checkout c55db645f3b4aed00374fe4aa1fcee2428c88c4b |
| 36 | |
| 37 | WORKDIR /opt/goldbach/formalization |
| 38 | # (chmod in the same layer: Mathlib's cache unpacks its files 0600, which nobody cannot read; cache get again: a few of |
| 39 | # its 9,031 downloads fail now and then, and each try fetches only what is still missing) |
| 40 | RUN (lake exe cache get || lake exe cache get || lake exe cache get) \ |
| 41 | && test "$(git -C .lake/packages/mathlib rev-parse --short=8 HEAD)" = 56a00585 \ |
| 42 | && lake build && chmod -R a+rX /opt/goldbach |
| 43 | |
| 44 | # Fu's workspace pins both the conditional theorem and grh-compact. The not-r and grh-bridge targets are checked on its |
| 45 | # LEAN_PATH, so its copy of Zhou's development needs PrimePairs too (grh-bridge's Challenge imports it). |
| 46 | # UnconditionalAudit itself does not build: GRH's Lib and PrimeNumberTheoremAnd both declare `nabla`; Fu's replay joins |
| 47 | # their exports instead (verification/join-grh.py). |
| 48 | # (retried: from Beijing a clone from github.com broke off once in TLS, 12-01) |
| 49 | RUN for i in 1 2 3 4 5; do git clone https://github.com/RaymondVoldemortFu/li-liu-spectral-hypotheses-lean /opt/fu && break; \ |
| 50 | rm -rf /opt/fu; sleep 10; done \ |
| 51 | && git -C /opt/fu checkout 56090686f4dcc16147ea74548d52184b2cfa89cb |
| 52 | WORKDIR /opt/fu/WithGRH435 |
| 53 | RUN (lake exe cache get || lake exe cache get || lake exe cache get) \ |
| 54 | && lake build +Main +OriginalStatements +SingleScaleCriterion +ConditionalGoldbach.Proofs.PrimePairs \ |
| 55 | && chmod -R a+rX /opt/fu |
| 56 | |
| 57 | # The maintainer's numerics (C-3..C-5 interval certificates, reruns of authors' scripts), in a venv of its own so the |
| 58 | # system python3 the checks call stays as it is: python3-sci has them. |
| 59 | # (a wrapper, not a link: Python started through a link to a venv's python does not find the venv) |
| 60 | RUN python3 -m venv /opt/py && /opt/py/bin/pip install --no-cache-dir python-flint mpmath sympy numpy scipy \ |
| 61 | && printf '#!/bin/sh\nexec /opt/py/bin/python3 "$@"\n' > /usr/local/bin/python3-sci && chmod 755 /usr/local/bin/python3-sci \ |
| 62 | && python3-sci -c "import flint, mpmath, sympy, numpy, scipy" |
| 63 | # numpy's and scipy's OpenBLAS each start a thread per host CPU: on a 128-core host that is past a look's 128 processes, |
| 64 | # and `import scipy.linalg` dies (SIGSEGV, reproduced on a2 with --pids-limit below its 63 threads) |
| 65 | ENV OPENBLAS_NUM_THREADS=4 OMP_NUM_THREADS=4 |
| 66 | |
| 67 | ENV GOLDBACH_LEAN_PROJECT=/opt/goldbach/formalization |
| 68 | WORKDIR /opt/goldbach/formalization |
| 69 | CMD ["/bin/bash"] |
