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

| 1 | /- |
| 2 | Copyright (c) 2026 Bhavik Mehta. All rights reserved. |
| 3 | Released under the GNU General Public License version 3.0 as described in the file LICENSE. |
| 4 | Authors: Bhavik Mehta |
| 5 | -/ |
| 6 | module |
| 7 | |
| 8 | public import ECCompute.Theory.Descent.Character |
| 9 | import ECCompute.Theory.Descent.PointArith |
| 10 | import ECCompute.Theory.Descent.ReductionMap |
| 11 | import ECCompute.Theory.Descent.ReductionHom |
| 12 | import ECCompute.Theory.Descent.FiniteCharacter |
| 13 | |
| 14 | /-! |
| 15 | # The descent character: additivity |
| 16 | |
| 17 | This file assembles the additivity of the descent character `λ_{p,θ}` defined in |
| 18 | `ECCompute.Descent.Character`. Additivity is obtained by factoring `λ` through the reduction map |
| 19 | `redP : E(ℚ) → E(𝔽ₚ)` and the finite-field descent character `εpFinite`, both of which are |
| 20 | additive homomorphisms (see `ECCompute.Descent.ReductionHom` and |
| 21 | `ECCompute.Descent.FiniteCharacter`). |
| 22 | |
| 23 | ## Main declarations |
| 24 | |
| 25 | * `ECCompute.lambdaHom`: `λ` packaged as an `AddMonoidHom`. |
| 26 | -/ |
| 27 | |
| 28 | open WeierstrassCurve |
| 29 | |
| 30 | namespace ECCompute |
| 31 | |
| 32 | variable {a₂ a₄ a₆ : ℤ} {p : ℕ} {θ : ZMod p} |
| 33 | |
| 34 | /-! ### Reducing `λ` on an affine point to `ψ_p` of the reduced coordinate -/ |
| 35 | |
| 36 | /-- Reduction of `λ` on an affine point with `p ∤ x.den` to `ψ_p` of the reduced coordinate: |
| 37 | `ψ_p(f'(θ))` when `xbar p x = θ`, and `ψ_p(xbar p x - θ)` otherwise. -/ |
| 38 | theorem lambda_some_of_den_ne [Fact p.Prime] {x y : ℚ} |
| 39 | (h : (curveQ a₂ a₄ a₆).toAffine.Nonsingular x y) (hd : (x.den : ZMod p) ≠ 0) : |
| 40 | lambda θ (.some x y h) |
| 41 | = if xbar p x = θ then psi p (fderiv (R := ZMod p) a₂ a₄ θ) else psi p (xbar p x - θ) := by |
| 42 | obtain ⟨w, hxden, _⟩ := den_isSquare h.1 |
| 43 | have hw : (w : ZMod p) ≠ 0 := by intro h0; apply hd; rw [hxden]; grind |
| 44 | have hnum : (x.num : ZMod p) = xbar p x * x.den := by |
| 45 | rw [xbar, Rat.cast_def, div_mul_cancel₀ _ hd] |
| 46 | have halpha : x.num - θ * x.den = (w : ZMod p) ^ 2 * (xbar p x - θ) := by rw [hnum, hxden]; grind |
| 47 | grind [lambda, psi_mul_sq Fact.out] |
| 48 | |
| 49 | /-- When `p ∣ x.den` the point reduces to `O` of `E/𝔽ₚ`, where `λ` vanishes. -/ |
| 50 | theorem lambda_some_of_den_zero {x y : ℚ} |
| 51 | (h : (curveQ a₂ a₄ a₆).toAffine.Nonsingular x y) (hd : (x.den : ZMod p) = 0) : |
| 52 | lambda θ (.some x y h) = 0 := by simp only [lambda, ite_eq_left hd] |
| 53 | |
| 54 | /-! ### Additivity via the reduction factorization |
| 55 | |
| 56 | Additivity of `λ_{p,θ}` factors it as `λ = εpFinite ∘ redP`, with `redP : E(ℚ) → E(𝔽ₚ)` |
| 57 | (`ECCompute.Descent.ReductionHom`) and `εpFinite : E(𝔽ₚ) → ZMod 2` |
| 58 | (`ECCompute.Descent.FiniteCharacter`) both `AddMonoidHom`s. See `lambda_map_add`. -/ |
| 59 | |
| 60 | /-- The descent character `λ_{p,θ}` presented as the composition `εpFinite θ ∘ redP`, packaged |
| 61 | as an `AddMonoidHom E(ℚ) → ZMod 2`. See `lambda_map_add`. -/ |
| 62 | noncomputable def redCharHom [Fact p.Prime] (h : DescentHyp a₂ a₄ a₆ p θ) |
| 63 | (hΔ : ((curve a₂ a₄ a₆).Δ : ZMod p) ≠ 0) : |
| 64 | (curveQ a₂ a₄ a₆).toAffine.Point →+ ZMod 2 := |
| 65 | (εpHom h).comp (redHom hΔ) |
| 66 | |
| 67 | /-- On each point, `λ_{p,θ}` agrees with the reduction composition `εpFinite θ ∘ redP`. -/ |
| 68 | theorem lambda_eq_εp_red [Fact p.Prime] (h : DescentHyp a₂ a₄ a₆ p θ) |
| 69 | (hΔ : ((curve a₂ a₄ a₆).Δ : ZMod p) ≠ 0) (P : (curveQ a₂ a₄ a₆).toAffine.Point) : |
| 70 | lambda θ P = redCharHom h hΔ P := by |
| 71 | cases P with |
| 72 | | zero => rw [← Affine.Point.zero_def, lambda_zero, map_zero] |
| 73 | | some x y hns => |
| 74 | rw [redCharHom, AddMonoidHom.comp_apply, redHom_apply] |
| 75 | by_cases hd : (x.den : ZMod p) = 0 |
| 76 | · grind [lambda_some_of_den_zero, redP_of_den_zero] |
| 77 | · grind [lambda_some_of_den_ne, redP_of_den_ne, εpHom_apply, εpFinite_some, xbar] |
| 78 | |
| 79 | /-- The descent character `λ_{p,θ}` is additive, i.e. a homomorphism `(E(ℚ), +) → (ZMod 2, +)`. -/ |
| 80 | theorem lambda_map_add (h : DescentHyp a₂ a₄ a₆ p θ) |
| 81 | (P Q : (curveQ a₂ a₄ a₆).toAffine.Point) : |
| 82 | lambda θ (P + Q) = lambda θ P + lambda θ Q := by |
| 83 | have : Fact p.Prime := ⟨h.prime⟩ |
| 84 | have hΔ : ((curve a₂ a₄ a₆).Δ : ZMod p) ≠ 0 := by |
| 85 | grind [Rat.num_intCast, map_curveQ, map_Δ, eq_intCast] |
| 86 | grind [lambda_eq_εp_red h hΔ] |
| 87 | |
| 88 | /-- The descent character `λ_{p,θ}` as an `AddMonoidHom E(ℚ) → ZMod 2`. -/ |
| 89 | @[expose, simps] |
| 90 | public noncomputable def lambdaHom (h : DescentHyp a₂ a₄ a₆ p θ) : |
| 91 | (curveQ a₂ a₄ a₆).toAffine.Point →+ ZMod 2 where |
| 92 | toFun := lambda θ |
| 93 | map_zero' := lambda_zero |
| 94 | map_add' := by exact lambda_map_add h |
| 95 | |
| 96 | end ECCompute |