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
test(routes): 在两份隔离的预演输入上运行项目检查
Browse filesChecks
build Program · lake build and Comparator
Details
challenge Program · challenge files and build config
Details
+12 −0 routes/s1-comparator-rehearsal-shumo/README.md added View file
| @@ -0,0 +1,12 @@ | ||
| 1 | +--- | |
| 2 | +issue: 117 | |
| 3 | +status: working | |
| 4 | +--- | |
| 5 | + | |
| 6 | +# S 单调性的独立算力预演 | |
| 7 | + | |
| 8 | +输入是 `92ae985` 与 PR #41 的 `2d88081` 的合并树。可独立移植的六文件补丁为 `4e8cffe44918ef94091eac5575ed24164878c264`。`run.sbatch` 以这份树自己的 `checks/` 执行全部检查。反例在临时副本中只替换同名解答,作业保留 Comparator 的拒绝退出码。 | |
| 9 | + | |
| 10 | +## Next | |
| 11 | + | |
| 12 | +在本目录分别提交 `sbatch run.sbatch positive` 和 `sbatch run.sbatch negative`,把两份日志归档到正式路线。[正式路线](https://shoal.club/shoal/goldbach-spectral-bridge/tree/s1-comparator-shumo/routes/s1-comparator-shumo) | |
+76 −0 routes/s1-comparator-rehearsal-shumo/run.sbatch added View file
| @@ -0,0 +1,76 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | +#SBATCH --job-name=s1-comparator | |
| 3 | +#SBATCH --partition=lean | |
| 4 | +#SBATCH --time=02:00:00 | |
| 5 | +#SBATCH --cpus-per-task=4 | |
| 6 | +#SBATCH --mem=20G | |
| 7 | +set -euo pipefail | |
| 8 | +mode=$1 | |
| 9 | +case "$mode" in positive|negative) ;; *) exit 2 ;; esac | |
| 10 | +work=$(mktemp -d) | |
| 11 | +trap 'rm -rf -- "$work"' EXIT | |
| 12 | +mkdir "$work/exam" | |
| 13 | +cd "$SS_INPUT" | |
| 14 | +tar --exclude=.git --exclude=.lake -cf - . | tar -xf - -C "$work/exam" | |
| 15 | +cd "$work/exam" | |
| 16 | +export PROOF_APPROVED=$PWD | |
| 17 | +export SS_INPUT=$PWD | |
| 18 | +if [[ $mode == negative ]]; then | |
| 19 | + cp -a "$PWD" "$work/control" | |
| 20 | + export SS_INPUT=$work/control | |
| 21 | +fi | |
| 22 | +python3 - "$mode" "$SS_INPUT" <<'PY' | |
| 23 | +from pathlib import Path | |
| 24 | +import hashlib | |
| 25 | +import json | |
| 26 | +import re | |
| 27 | +import sys | |
| 28 | + | |
| 29 | +mode, tree = sys.argv[1], Path(sys.argv[2]) | |
| 30 | +audit = Path("verification/independent-audit/comparator-project/TexAuditComparator") | |
| 31 | +solution = tree / audit / "Solution.lean" | |
| 32 | +original = solution.read_bytes() | |
| 33 | +match = re.compile(rb"(?m)^theorem s_monotone :(?P<type>\n[^\n]+) := by$") | |
| 34 | +def spec(path): | |
| 35 | + (t,) = match.findall(path.read_bytes()) | |
| 36 | + return t | |
| 37 | +target = spec(Path("Open.lean")) | |
| 38 | +assert target == spec(audit / "Challenge.lean") == spec(solution) | |
| 39 | +cfg = json.loads(Path("comparator.json").read_bytes()) | |
| 40 | +assert cfg["enable_nanoda"] and cfg["theorem_names"].count("TexComparator.s_monotone") == 1 | |
| 41 | +print("target=TexComparator.s_monotone", "total=" + str(len(cfg["theorem_names"])), | |
| 42 | + "type_bytes=" + str(len(target)), "type_sha256=" + hashlib.sha256(target).hexdigest()) | |
| 43 | +if mode == "negative": | |
| 44 | + good = b"theorem s_monotone :" + target + b" := by\n exact ConditionalGoldbach.hypothesisS_mono\n" | |
| 45 | + bad = b"theorem s_monotone : True := by\n trivial\n" | |
| 46 | + assert original.count(good) == 1 | |
| 47 | + solution.write_bytes(original.replace(good, bad)) | |
| 48 | + assert (tree / audit / "Challenge.lean").read_bytes() == (audit / "Challenge.lean").read_bytes() | |
| 49 | + print(bad.decode().strip()) | |
| 50 | +print("Challenge.lean sha256=" + hashlib.sha256((tree / audit / "Challenge.lean").read_bytes()).hexdigest()) | |
| 51 | +PY | |
| 52 | +bash checks/challenge.sbatch | |
| 53 | +echo "challenge exit=0" | |
| 54 | +rc=0 | |
| 55 | +bash checks/build.sbatch > "$work/build.txt" 2>&1 || rc=$? | |
| 56 | +cat "$work/build.txt" | |
| 57 | +echo "build exit=$rc" | |
| 58 | +log=logs/comparator-0.log | |
| 59 | +if [[ ! -f $log ]]; then | |
| 60 | + echo "Comparator log missing; the run stopped before Comparator" >&2 | |
| 61 | + exit 2 | |
| 62 | +fi | |
| 63 | +cat "$log" | |
| 64 | +if [[ $mode == positive ]]; then | |
| 65 | + [[ $rc == 0 ]] | |
| 66 | + grep -Fq 'nanoda kernel accepts the solution' "$log" | |
| 67 | + grep -Fq 'Lean default kernel accepts the solution' "$log" | |
| 68 | + grep -Fq 'Your solution is okay!' "$log" | |
| 69 | + echo "positive: TexComparator.s_monotone included; both kernels accepted; build exit=0" | |
| 70 | +else | |
| 71 | + [[ $rc == 1 ]] || exit 2 | |
| 72 | + grep -Fq "Challenge and solution theorem statement do not match: 'TexComparator.s_monotone'" "$log" || exit 2 | |
| 73 | + grep -Fq -- '--inadvisably-no-sandbox ended with exit 1' "$work/build.txt" || exit 2 | |
| 74 | + echo "negative: TexComparator.s_monotone : True compiled; Comparator exit=1; build exit=1" | |
| 75 | + exit "$rc" | |
| 76 | +fi | |
