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.Point |
| 9 | public import Mathlib.AlgebraicGeometry.EllipticCurve.VariableChange |
| 10 | |
| 11 | /-! |
| 12 | # The Mordell-Weil isomorphism of an admissible change of variables |
| 13 | |
| 14 | For an admissible linear change of variables `C = ⟨u, r, s, t⟩` over `ℚ`, the substitution |
| 15 | `(X, Y) ↦ (u²X + r, u³Y + u²sX + t)` (mathlib's `WeierstrassCurve.VariableChange` action `C • W`) |
| 16 | is a group isomorphism `W.toAffine.Point ≃+ (C • W).toAffine.Point` on Mordell-Weil groups. |
| 17 | |
| 18 | ## Main results |
| 19 | |
| 20 | * `WeierstrassCurve.VariableChange.pointAddEquiv`: the change of variables as a group |
| 21 | isomorphism. |
| 22 | -/ |
| 23 | |
| 24 | section |
| 25 | |
| 26 | namespace WeierstrassCurve |
| 27 | open Affine |
| 28 | |
| 29 | variable {x y x₁ x₂ y₁ y₂ : ℚ} |
| 30 | |
| 31 | namespace VariableChange |
| 32 | |
| 33 | variable (C : VariableChange ℚ) |
| 34 | |
| 35 | /-- The `x`-coordinate on `C • W` of the point with `x`-coordinate `x` on `W`: `u⁻²(x - r)`. -/ |
| 36 | def mapX (x : ℚ) : ℚ := (C.u : ℚ)⁻¹ ^ 2 * (x - C.r) |
| 37 | |
| 38 | /-- The `y`-coordinate on `C • W` of the point `(x, y)` on `W`: `u⁻³(y - s(x - r) - t)`. -/ |
| 39 | def mapY (x y : ℚ) : ℚ := (C.u : ℚ)⁻¹ ^ 3 * (y - C.s * (x - C.r) - C.t) |
| 40 | |
| 41 | /-- The slope on `C • W` of a line of slope `ℓ` on `W`: `u⁻¹(ℓ - s)`. -/ |
| 42 | def mapSlope (ℓ : ℚ) : ℚ := (C.u : ℚ)⁻¹ * (ℓ - C.s) |
| 43 | |
| 44 | /-- The `x`-coordinate on `W` of the point with `x`-coordinate `X` on `C • W`: `u²X + r`. -/ |
| 45 | def invX (X : ℚ) : ℚ := (C.u : ℚ) ^ 2 * X + C.r |
| 46 | |
| 47 | /-- The `y`-coordinate on `W` of the point `(X, Y)` on `C • W`: `u³Y + u²sX + t`. -/ |
| 48 | def invY (X Y : ℚ) : ℚ := (C.u : ℚ) ^ 3 * Y + (C.u : ℚ) ^ 2 * C.s * X + C.t |
| 49 | |
| 50 | variable {C} |
| 51 | |
| 52 | @[local grind .] lemma u_ne_zero : (C.u : ℚ) ≠ 0 := C.u.ne_zero |
| 53 | |
| 54 | @[grind =] lemma mapX_invX : C.mapX (C.invX x) = x := by grind [mapX, invX] |
| 55 | |
| 56 | @[grind =] lemma mapY_invY : C.mapY (C.invX x) (C.invY x y) = y := by grind [mapY, invX, invY] |
| 57 | |
| 58 | @[grind =] lemma invX_mapX : C.invX (C.mapX x) = x := by grind [mapX, invX] |
| 59 | |
| 60 | @[grind =] lemma invY_mapY : C.invY (C.mapX x) (C.mapY x y) = y := by grind [mapX, mapY, invY] |
| 61 | |
| 62 | @[grind inj] lemma mapX_injective : C.mapX.Injective := by grind [Function.Injective, mapX] |
| 63 | |
| 64 | @[grind inj] theorem mapY_injective : (C.mapY x).Injective := by grind [Function.Injective, mapY] |
| 65 | |
| 66 | end VariableChange |
| 67 | |
| 68 | open VariableChange |
| 69 | |
| 70 | variable {W : WeierstrassCurve ℚ} {C : VariableChange ℚ} |
| 71 | |
| 72 | /-- A point `(x, y)` lies on `W` iff its image lies on `C • W`. -/ |
| 73 | theorem equation_variableChange_iff : |
| 74 | W.toAffine.Equation x y ↔ (C • W).toAffine.Equation (C.mapX x) (C.mapY x y) := by |
| 75 | have hu : (C.u : ℚ) ≠ 0 := u_ne_zero |
| 76 | rw [equation_iff, equation_iff, mapX, mapY, variableChange_a₁, variableChange_a₂, |
| 77 | variableChange_a₃, variableChange_a₄, variableChange_a₆] |
| 78 | grind [Units.val_inv_eq_inv_val] |
| 79 | |
| 80 | /-- Nonsingularity transfers forward along the change of variables. -/ |
| 81 | theorem nonsingular_variableChange_iff : |
| 82 | W.toAffine.Nonsingular x y ↔ (C • W).toAffine.Nonsingular (C.mapX x) (C.mapY x y) := by |
| 83 | have hu : (C.u : ℚ) ≠ 0 := u_ne_zero |
| 84 | rw [nonsingular_iff', nonsingular_iff', ← equation_variableChange_iff, mapX, mapY, |
| 85 | variableChange_a₁, variableChange_a₂, variableChange_a₃, variableChange_a₄] |
| 86 | grind [Units.val_inv_eq_inv_val] |
| 87 | |
| 88 | /-! ### Transfer of the addition-law ingredients -/ |
| 89 | |
| 90 | @[grind =] |
| 91 | theorem variableChange_negY : |
| 92 | (C • W).toAffine.negY (C.mapX x) (C.mapY x y) = C.mapY x (W.toAffine.negY x y) := by |
| 93 | simp only [negY, mapX, mapY, variableChange_a₁, variableChange_a₃] |
| 94 | grind [Units.val_inv_eq_inv_val] |
| 95 | |
| 96 | @[grind =] |
| 97 | theorem variableChange_addX {ℓ : ℚ} : |
| 98 | (C • W).toAffine.addX (C.mapX x₁) (C.mapX x₂) (C.mapSlope ℓ) |
| 99 | = C.mapX (W.toAffine.addX x₁ x₂ ℓ) := by |
| 100 | simp only [addX, mapX, mapSlope, variableChange_a₁, variableChange_a₂, Units.val_inv_eq_inv_val] |
| 101 | grind |
| 102 | |
| 103 | @[grind =] |
| 104 | theorem variableChange_addY {ℓ : ℚ} : |
| 105 | (C • W).toAffine.addY (C.mapX x₁) (C.mapX x₂) (C.mapY x₁ y₁) (C.mapSlope ℓ) |
| 106 | = C.mapY (W.toAffine.addX x₁ x₂ ℓ) (W.toAffine.addY x₁ x₂ y₁ ℓ) := by |
| 107 | simp only [addY, negAddY, addX, negY, mapX, mapY, mapSlope, variableChange_a₁, variableChange_a₂, |
| 108 | variableChange_a₃, Units.val_inv_eq_inv_val] |
| 109 | grind |
| 110 | |
| 111 | theorem variableChange_slope (h₁ : W.toAffine.Equation x₁ y₁) |
| 112 | (h₂ : W.toAffine.Equation x₂ y₂) (hxy : ¬(x₁ = x₂ ∧ y₁ = W.toAffine.negY x₂ y₂)) : |
| 113 | (C • W).toAffine.slope (C.mapX x₁) (C.mapX x₂) (C.mapY x₁ y₁) (C.mapY x₂ y₂) |
| 114 | = C.mapSlope (W.toAffine.slope x₁ x₂ y₁ y₂) := by |
| 115 | obtain rfl | hx := eq_or_ne x₁ x₂ |
| 116 | · have hy : y₁ ≠ W.toAffine.negY x₁ y₂ := fun h ↦ hxy ⟨rfl, h⟩ |
| 117 | obtain rfl : y₁ = y₂ := Y_eq_of_Y_ne h₁ h₂ rfl hy |
| 118 | have hy' : C.mapY x₁ y₁ ≠ (C • W).toAffine.negY (C.mapX x₁) (C.mapY x₁ y₁) := by grind |
| 119 | have hs : C.mapSlope |
| 120 | ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - W.toAffine.negY x₁ y₁)) |
| 121 | = ((C.u : ℚ)⁻¹ |
| 122 | * ((3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) |
| 123 | - C.s * (y₁ - W.toAffine.negY x₁ y₁))) / (y₁ - W.toAffine.negY x₁ y₁) := by |
| 124 | rw [mapSlope]; field_simp [u_ne_zero] |
| 125 | rw [slope_of_Y_ne rfl hy', slope_of_Y_ne rfl hy, hs, div_eq_div_iff (by grind) (by grind)] |
| 126 | simp only [negY, mapX, mapY, variableChange_a₁, variableChange_a₂, variableChange_a₃, |
| 127 | variableChange_a₄, Units.val_inv_eq_inv_val] |
| 128 | ring |
| 129 | · have hs : C.mapSlope ((y₁ - y₂) / (x₁ - x₂)) |
| 130 | = ((C.u : ℚ)⁻¹ * (y₁ - y₂ - C.s * (x₁ - x₂))) / (x₁ - x₂) := by |
| 131 | rw [mapSlope]; field_simp [u_ne_zero] |
| 132 | rw [slope_of_X_ne (by grind), slope_of_X_ne hx, hs, div_eq_div_iff (by grind) (by grind)] |
| 133 | grind [mapX, mapY] |
| 134 | |
| 135 | /-! ### The group isomorphism -/ |
| 136 | |
| 137 | namespace VariableChange |
| 138 | |
| 139 | /-- An admissible change of variables `C` induces a group isomorphism between the Mordell-Weil |
| 140 | groups of `W` and `C • W`, sending `(x, y)` to `(u⁻²(x - r), u⁻³(y - s(x - r) - t))`. -/ |
| 141 | public def pointAddEquiv (C : VariableChange ℚ) : W.toAffine.Point ≃+ (C • W).toAffine.Point := |
| 142 | AddEquiv.mk' |
| 143 | { toFun := fun |
| 144 | | .zero => .zero |
| 145 | | .some x y h => .some (C.mapX x) (C.mapY x y) (nonsingular_variableChange_iff.mp h) |
| 146 | invFun := fun |
| 147 | | .zero => .zero |
| 148 | | .some X Y h => .some (C.invX X) (C.invY X Y) |
| 149 | (nonsingular_variableChange_iff.mpr (by rwa [mapX_invX, mapY_invY])) |
| 150 | left_inv := by grind |
| 151 | right_inv := by grind } |
| 152 | (by |
| 153 | rintro P Q |
| 154 | rcases P with _ | ⟨x₁, y₁, hp₁⟩ <;> rcases Q with _ | ⟨x₂, y₂, hp₂⟩ |
| 155 | any_goals rfl |
| 156 | simp only [Equiv.coe_fn_mk] |
| 157 | grind [Point.add_some, variableChange_slope hp₁.1 hp₂.1, Point.zero_def, Point.add_of_Y_eq]) |
| 158 | |
| 159 | end VariableChange |
| 160 | |
| 161 | end WeierstrassCurve |
| 162 | |
| 163 | end |