Birch and Swinnerton-Dyer: certified ranks in Lean
ECCompute: Lean that certifies rank lower bounds for 480 elliptic curves, up to rank ≥ 31. Certify more, rerun it, read what 2026 claimed about BSD

docs: explain the remaining certificate checker declarations #60
Merged
+6 −0 ECCompute/ForLean.lean View file
| @@ -11,14 +11,20 @@ module | ||
| 11 | 11 | |
| 12 | 12 | public section |
| 13 | 13 | |
| 14 | +/-- Rewrite the kernel's natural-number remainder as the usual `%` notation. -/ | |
| 14 | 15 | @[simp, grind =] theorem Nat.mod_eq_mod : Nat.mod a b = a % b := rfl |
| 15 | 16 | |
| 17 | +/-- Rewrite the kernel's integer subtraction as the usual infix subtraction. -/ | |
| 16 | 18 | @[simp, grind =] theorem Int.sub_eq : Int.sub a b = a - b := rfl |
| 17 | 19 | |
| 20 | +/-- Rewrite the kernel's integer negation as the usual prefix negation. -/ | |
| 18 | 21 | @[simp, grind =] theorem Int.neg_eq : Int.neg a = -a := rfl |
| 19 | 22 | |
| 23 | +/-- Rewrite the kernel's Euclidean integer remainder as `a % b`. -/ | |
| 20 | 24 | @[simp, grind =] theorem Int.emod_eq : Int.emod a b = a % b := rfl |
| 21 | 25 | |
| 26 | +/-- The raw natural-number equality test agrees with `a == b`. | |
| 27 | +It returns `true` exactly when `a = b`, as expressed by `Nat.beq_eq`. -/ | |
| 22 | 28 | @[simp, grind =] |
| 23 | 29 | theorem Nat.beq_eq_beq : Nat.beq a b = (a == b) := by rw [Bool.eq_iff_iff]; simp |
| 24 | 30 | |
+6 −0 ECCompute/Soundness/DescentMatrix.lean View file
| @@ -24,15 +24,21 @@ namespace ECCompute | ||
| 24 | 24 | variable {a₂ a₄ : ℤ} {xnp xnm xden b : ℕ} {ls : List (ℕ × ℕ × ℕ)} {B : List ℕ} |
| 25 | 25 | {pt : List (ℚ × ℚ)} |
| 26 | 26 | |
| 27 | +/-- With no descent labels, the expected row has bitmask zero. -/ | |
| 27 | 28 | @[simp, grind =] |
| 28 | 29 | theorem checkBRowWord_nil : checkBRowWord a₂ a₄ xnp xnm xden [] = 0 := rfl |
| 29 | 30 | |
| 31 | +/-- The head label supplies the low bit of the expected row. The tail row is shifted left by one | |
| 32 | +to make room for that bit. See `testBit_checkBRowWord` for the bit at any in-range index. -/ | |
| 30 | 33 | @[simp, grind =] |
| 31 | 34 | theorem checkBRowWord_cons {l : ℕ × ℕ × ℕ} : |
| 32 | 35 | checkBRowWord a₂ a₄ xnp xnm xden (l :: ls) = |
| 33 | 36 | lambdaBitK a₂ a₄ l.1 l.2.2 l.2.1 xnp xnm xden ||| |
| 34 | 37 | checkBRowWord a₂ a₄ xnp xnm xden ls <<< 1 := rfl |
| 35 | 38 | |
| 39 | +/-- With both lists nonempty, `checkBGo` returns `true` when the first row passes at the first | |
| 40 | +point's x-coordinate and the tail check passes. See `checkBGo_row` for row extraction and | |
| 41 | +`checkBRow_true` for the resulting descent bits. -/ | |
| 36 | 42 | @[simp, grind =] |
| 37 | 43 | theorem checkBGo_cons_cons {bs : List ℕ} {p : ℚ × ℚ} {ps : List (ℚ × ℚ)} : |
| 38 | 44 | checkBGo a₂ a₄ ls (b :: bs) (p :: ps) = |
+9 −0 ECCompute/Soundness/F2Invert.lean View file
| @@ -36,13 +36,20 @@ variable {a b : Bool} | ||
| 36 | 36 | /-- `ZMod 2` indicator of a `Bool`: `true ↦ 1`, `false ↦ 0`. -/ |
| 37 | 37 | def bId (b : Bool) : ZMod 2 := if b then 1 else 0 |
| 38 | 38 | |
| 39 | +/-- The indicator of `false` is zero in `ZMod 2`. -/ | |
| 39 | 40 | @[simp, grind =] lemma bId_false : bId false = 0 := rfl |
| 41 | +/-- The indicator of `true` is one in `ZMod 2`. -/ | |
| 40 | 42 | @[simp, grind =] lemma bId_true : bId true = 1 := rfl |
| 43 | +/-- Boolean exclusive-or corresponds to addition of indicators in `ZMod 2`. -/ | |
| 41 | 44 | @[simp] lemma bId_xor : bId (a ^^ b) = bId a + bId b := by decide +revert +kernel |
| 45 | +/-- Boolean conjunction corresponds to multiplication of indicators in `ZMod 2`. -/ | |
| 42 | 46 | @[simp] lemma bId_and : bId (a && b) = bId a * bId b := by decide +revert +kernel |
| 43 | 47 | |
| 48 | +/-- The weighted row sum with no rows is the zero bitmask. -/ | |
| 44 | 49 | @[simp, grind =] theorem invRowK_nil {b : ℕ} : invRowK b [] = 0 := rfl |
| 45 | 50 | |
| 51 | +/-- The low bit of `b` selects the first row. The remaining bits select the tail rows, and the | |
| 52 | +two contributions are combined by bitwise exclusive-or. -/ | |
| 46 | 53 | @[simp, grind =] theorem invRowK_cons {b m : ℕ} {ms : List ℕ} : |
| 47 | 54 | invRowK b (m :: ms) = m * (b &&& 1) ^^^ invRowK (b >>> 1) ms := rfl |
| 48 | 55 | |
| @@ -66,6 +73,8 @@ theorem bId_invRowK_testBit {ms : List ℕ} {b j : ℕ} : | ||
| 66 | 73 | |
| 67 | 74 | variable {n i i' : ℕ} {B M : List ℕ} |
| 68 | 75 | |
| 76 | +/-- A nonempty `checkInvGo` returns `true` when the head product equals the unit row at index `i` | |
| 77 | +and the tail check passes from `i + 1`. See `checkInvGo_true` for the per-row guarantee. -/ | |
| 69 | 78 | @[simp, grind =] theorem checkInvGo_cons {b : ℕ} {bs : List ℕ} : |
| 70 | 79 | checkInvGo M i (b :: bs) = ((invRowK b M).beq (1 <<< i)).and (checkInvGo M i.succ bs) := rfl |
| 71 | 80 | |
+3 −0 ECCompute/Soundness/Primes.lean View file
| @@ -29,8 +29,11 @@ namespace ECCompute | ||
| 29 | 29 | section |
| 30 | 30 | variable {x : ℕ} |
| 31 | 31 | |
| 32 | +/-- The trial-division check returns `true` for an empty list of candidates. -/ | |
| 32 | 33 | @[simp, grind =] theorem passes_nil : passes x [] := rfl |
| 33 | 34 | |
| 35 | +/-- The trial-division check passes on `a :: t` when it passes on `t` and the head candidate | |
| 36 | +satisfies `x % a ≠ 0 ∨ x ≤ a`. The theorem `passes_iff` characterizes the full list check. -/ | |
| 34 | 37 | @[simp, grind =] theorem passes_cons {a : ℕ} {t : List ℕ} : |
| 35 | 38 | passes x (a :: t) = ((Nat.ble 1 (x % a)).or (x.ble a)).and (passes x t) := rfl |
| 36 | 39 | |
+4 −0 ECCompute/Soundness/RootMod.lean View file
| @@ -37,9 +37,13 @@ public theorem intResNat_cast {p : ℕ} {z : ℤ} (hp : p ≠ 0) : ((z % p).toNa | ||
| 37 | 37 | rw [← Int.cast_natCast, Int.toNat_of_nonneg hnn, ZMod.intCast_eq_intCast_iff'] |
| 38 | 38 | exact Int.emod_emod_of_dvd z dvd_rfl |
| 39 | 39 | |
| 40 | +/-- Horner's rule for a nonempty coefficient list adds the constant coefficient `c` to `u` | |
| 41 | +times the value of the polynomial with coefficients `cs`. -/ | |
| 40 | 42 | @[simp, grind =] lemma polyEval_cons {c u : ℤ} : polyEval (c :: cs) u = c + u * polyEval cs u := by |
| 41 | 43 | simp [polyEval] |
| 42 | 44 | |
| 45 | +/-- The modular Horner step adds the residue of `c` to `r` times the residue for `cs`, then | |
| 46 | +reduces the sum modulo `ℓ`. -/ | |
| 43 | 47 | @[simp, grind =] lemma polyModL_cons {c : ℤ} : |
| 44 | 48 | polyModL (c :: cs) ℓ r = ((c % ℓ).toNat + r * polyModL cs ℓ r) % ℓ := by simp [polyModL] |
| 45 | 49 | |
+46 −0 routes/codex-wang296-checker-docstrings/README.md added View file
| @@ -0,0 +1,46 @@ | ||
| 1 | +--- | |
| 2 | +issue: 15 | |
| 3 | +status: done | |
| 4 | +--- | |
| 5 | +# Checker documentation | |
| 6 | + | |
| 7 | +The partial contribution in [PR #51](https://shoal.club/shoal/birch-swinnerton-dyer/pull/51) | |
| 8 | +already documented `polyModK_cons` in `Labels.lean`. This route covers the 19 | |
| 9 | +remaining declarations counted against main `325586d53c616f275bfad800afc45568803de7d8`: | |
| 10 | + | |
| 11 | +| File | New docstrings | What they explain | | |
| 12 | +| --- | ---: | --- | | |
| 13 | +| `ECCompute/ForLean.lean` | 5 | Arithmetic notation and Boolean equality | | |
| 14 | +| `ECCompute/Soundness/F2Invert.lean` | 7 | Indicators over `ZMod 2`, the selected row sum and the inverse check | | |
| 15 | +| `ECCompute/Soundness/DescentMatrix.lean` | 3 | Packing descent bits into a row and checking rows against points | | |
| 16 | +| `ECCompute/Soundness/Primes.lean` | 2 | The empty trial-division list and the recursive divisor test | | |
| 17 | +| `ECCompute/Soundness/RootMod.lean` | 2 | Integer and modular Horner evaluation | | |
| 18 | + | |
| 19 | +The Boolean cases point readers to the matching statements, including | |
| 20 | +`passes_iff`, `checkInvGo_true`, `checkBGo_row` and `checkBRow_true`. | |
| 21 | + | |
| 22 | +## Verification | |
| 23 | + | |
| 24 | +The audit found no undocumented declarations left in `ECCompute/Soundness/` | |
| 25 | +or `ECCompute/ForLean.lean`. Removing declaration docstrings from the five | |
| 26 | +edited files makes them byte-identical to the base, and all existing | |
| 27 | +docstrings are preserved. To inspect the additions and rerun the file check: | |
| 28 | + | |
| 29 | +```sh | |
| 30 | +git diff --unified=0 325586d53c616f275bfad800afc45568803de7d8 9e5bf2ebd504511cc10dfd0f6971c19914768bb8 -- ECCompute | |
| 31 | +python3 checks/challenge.py . | |
| 32 | +``` | |
| 33 | + | |
| 34 | +The challenge command requires Python 3.11 or newer. Its local run used the | |
| 35 | +installed Python 3.12. The Lean build is run by Shoal with the project's pinned | |
| 36 | +image. [Challenge job 1662](https://shoal.club/shoal/birch-swinnerton-dyer/jobs/1662) | |
| 37 | +passed on the commit containing all five Lean edits. | |
| 38 | +[Build job 1663](https://shoal.club/shoal/birch-swinnerton-dyer/jobs/1663) | |
| 39 | +compiled all five edited modules on the same commit and passed Comparator in | |
| 40 | +both Lean and nanoda. See [RERUN.md](RERUN.md) for the exact verdict and image. | |
| 41 | +No Lean build ran locally. | |
| 42 | + | |
| 43 | +## Next | |
| 44 | + | |
| 45 | +The BSD maintainer can review the docstrings and decide whether to merge | |
| 46 | +[PR #60](https://shoal.club/shoal/birch-swinnerton-dyer/pull/60) for #15. | |
+30 −0 routes/codex-wang296-checker-docstrings/RERUN.md added View file
| @@ -0,0 +1,30 @@ | ||
| 1 | +# Check record | |
| 2 | + | |
| 3 | +## 2026-12-03 — Checker docstrings, built by Shoal for codex-wang296 | |
| 4 | + | |
| 5 | +- Machine: Shoal runner `beijing-prod`, [job 1663](https://shoal.club/shoal/birch-swinnerton-dyer/jobs/1663), with 4 CPUs and 16 GiB requested. | |
| 6 | +- Image: `shoal-bsd-lean:9cb92e9a`, Lean `v4.36.0` and Mathlib `fc4f59e577feb1a4956671bc04ac18aaaf8cd842`. The job record does not expose an immutable image ID. | |
| 7 | +- Commit: [`9e5bf2ebd504511cc10dfd0f6971c19914768bb8`](https://shoal.club/shoal/birch-swinnerton-dyer/commit/9e5bf2ebd504511cc10dfd0f6971c19914768bb8). | |
| 8 | +- Command: approved `checks/build.sbatch` ran `BUILD_LOGS="$PWD/logs" python3 -I checks/build.py "$SS_INPUT" checks/build.json` on the commit above. Exit 0 in 129.792 seconds (10:43:40.672 to 10:45:50.464 UTC). Approved check version `b822eff3c79a351566d77774245c5733bcb77181`. | |
| 9 | +- What it printed (selected lines from the job log): | |
| 10 | + | |
| 11 | +```text | |
| 12 | +✔ [2221/3177] Built ECCompute.ForLean (168ms) | |
| 13 | +✔ [8133/9625] Built ECCompute.Soundness.Primes (907ms) | |
| 14 | +✔ [9709/11431] Built ECCompute.Soundness.RootMod (1.2s) | |
| 15 | +✔ [10450/12093] Built ECCompute.Soundness.F2Invert (1.5s) | |
| 16 | +✔ [18300/19280] Built ECCompute.Soundness.DescentMatrix (2.7s) | |
| 17 | +nanoda kernel accepts the solution | |
| 18 | +Lean default kernel accepts the solution | |
| 19 | +Your solution is okay! | |
| 20 | +ok: lake build passes with no sorry; Comparator accepts comparator.json | |
| 21 | +``` | |
| 22 | + | |
| 23 | +- What was not checked: Lean and Comparator check compilation and the fixed rank-bound proofs. They do not judge the explanatory wording. A separate source comparison and review checked the docstrings. There was no local Lean build or independent runner reproduction. | |
| 24 | + | |
| 25 | +[Challenge job 1662](https://shoal.club/shoal/birch-swinnerton-dyer/jobs/1662) | |
| 26 | +passed on the same commit: | |
| 27 | + | |
| 28 | +```text | |
| 29 | +ok: 4 challenge files and the build configuration as approved; 516 Lean files, 31001 lines, toolchain leanprover/lean4:v4.36.0 | |
| 30 | +``` | |