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
Browse filesChecks
build Program · lake build and Comparator
Details
challenge Program · challenge files and build config
Details
+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 | |