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 Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Formula |
| 9 | public import Mathlib.AlgebraicGeometry.EllipticCurve.Projective.Point |
| 10 | |
| 11 | /-! |
| 12 | # Weierstrass curve helpers for mathlib |
| 13 | |
| 14 | Negation on affine points when `a₁ = a₃ = 0`, two criteria for equivalence of nonsingular |
| 15 | projective representatives over a field, and the `j`-invariant of a curve with nonzero |
| 16 | discriminant over a field. |
| 17 | |
| 18 | ## Main results |
| 19 | |
| 20 | * `WeierstrassCurve.Affine.negY_of_a₁_a₃_eq_zero`: `negY x y = -y` when `a₁ = a₃ = 0`. |
| 21 | * `WeierstrassCurve.Projective.equiv_of_proportional`: `V 2 • U = U 2 • V` implies `U ≈ V`. |
| 22 | * `WeierstrassCurve.Projective.equiv_of_toAffine_eq`: equal affine points imply `U ≈ V`. |
| 23 | * `WeierstrassCurve.j_eq_iff`: `j = q ↔ c₄³ = Δ · q` for a curve with invertible discriminant. |
| 24 | * `WeierstrassCurve.isElliptic_of_Δ_ne_zero`: `Δ ≠ 0` over a field gives `IsElliptic`. |
| 25 | -/ |
| 26 | |
| 27 | public section |
| 28 | |
| 29 | namespace WeierstrassCurve.Affine |
| 30 | |
| 31 | variable {R : Type*} [CommRing R] |
| 32 | |
| 33 | /-- On a Weierstrass curve with `a₁ = a₃ = 0`, negation is `negY x y = -y`. -/ |
| 34 | @[grind =] |
| 35 | theorem negY_of_a₁_a₃_eq_zero (W : WeierstrassCurve R) (ha1 : W.a₁ = 0) (ha3 : W.a₃ = 0) |
| 36 | {x y : R} : W.toAffine.negY x y = -y := by simp [negY, ha1, ha3] |
| 37 | |
| 38 | end WeierstrassCurve.Affine |
| 39 | |
| 40 | namespace WeierstrassCurve.Projective |
| 41 | |
| 42 | variable {F : Type*} [Field F] {W : Projective F} {U V : Fin 3 → F} |
| 43 | |
| 44 | /-- Two nonsingular projective representatives over a field that are proportional with cross |
| 45 | scalars given by each other's `Z`-coordinate are equivalent: if `V 2 • U = U 2 • V`, then |
| 46 | `U ≈ V`. -/ |
| 47 | theorem equiv_of_proportional (hU : W.Nonsingular U) (hV : W.Nonsingular V) |
| 48 | (hprop : V 2 • U = U 2 • V) : U ≈ V := by |
| 49 | have hcU0 := congrFun hprop 0 |
| 50 | have hcU1 := congrFun hprop 1 |
| 51 | simp only [Pi.smul_apply, smul_eq_mul] at hcU0 hcU1 |
| 52 | by_cases hUz : U 2 = 0 |
| 53 | · -- `U z = 0`; deduce `V z = 0`, then both reduce to the point at infinity. |
| 54 | have hVz : V 2 = 0 := by |
| 55 | rw [nonsingular_of_Z_eq_zero hUz] at hU |
| 56 | grind [mul_eq_zero] |
| 57 | exact Setoid.trans (equiv_zero_of_Z_eq_zero hU hUz) |
| 58 | (Setoid.symm (equiv_zero_of_Z_eq_zero hV hVz)) |
| 59 | · -- `U z ≠ 0`; deduce `V z ≠ 0` and use `equiv_of_X_eq_of_Y_eq`. |
| 60 | have hVz : V 2 ≠ 0 := fun hVz ↦ by |
| 61 | rw [nonsingular_of_Z_eq_zero hVz] at hV |
| 62 | grind [mul_eq_zero] |
| 63 | exact equiv_of_X_eq_of_Y_eq hUz hVz (by grind) (by grind) |
| 64 | |
| 65 | /-- Two nonsingular projective representatives over a field with the same underlying affine point |
| 66 | are equivalent. See also `toAffine_of_equiv`. -/ |
| 67 | theorem equiv_of_toAffine_eq (hU : W.Nonsingular U) (hV : W.Nonsingular V) |
| 68 | (h : Point.toAffine W U = Point.toAffine W V) : U ≈ V := by |
| 69 | classical |
| 70 | have hUl : W.NonsingularLift ⟦U⟧ := (nonsingularLift_iff U).mpr hU |
| 71 | have hVl : W.NonsingularLift ⟦V⟧ := (nonsingularLift_iff V).mpr hV |
| 72 | have hmk : (⟨hUl⟩ : W.Point) = ⟨hVl⟩ := by |
| 73 | apply (Point.toAffineAddEquiv W).injective |
| 74 | rw [Point.toAffineAddEquiv_apply, Point.toAffineAddEquiv_apply, |
| 75 | Point.toAffineLift_eq, Point.toAffineLift_eq] |
| 76 | exact h |
| 77 | exact Quotient.exact (congrArg Point.point hmk) |
| 78 | |
| 79 | end WeierstrassCurve.Projective |
| 80 | |
| 81 | namespace WeierstrassCurve |
| 82 | |
| 83 | variable {F : Type*} [Field F] {W : WeierstrassCurve F} |
| 84 | |
| 85 | /-- For a Weierstrass curve with invertible discriminant, `j = q` iff `c₄³ = Δ · q`. -/ |
| 86 | theorem j_eq_iff [W.IsElliptic] {q : F} : W.j = q ↔ W.c₄ ^ 3 = W.Δ * q := by |
| 87 | rw [j, Units.inv_mul_eq_iff_eq_mul, coe_Δ'] |
| 88 | |
| 89 | /-- Over a field, a nonzero discriminant makes a Weierstrass curve an elliptic curve. -/ |
| 90 | theorem isElliptic_of_Δ_ne_zero (hΔ : W.Δ ≠ 0) : W.IsElliptic := ⟨isUnit_iff_ne_zero.mpr hΔ⟩ |
| 91 | |
| 92 | end WeierstrassCurve |