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.LinearAlgebra.Dimension.Torsion.Finite |
| 9 | public import Mathlib.LinearAlgebra.FreeModule.ModN |
| 10 | |
| 11 | import Mathlib.Algebra.Field.ZMod |
| 12 | import Mathlib.Algebra.Module.PID |
| 13 | import Mathlib.Algebra.Module.Torsion.Basic |
| 14 | import Mathlib.LinearAlgebra.Dimension.Constructions |
| 15 | import Mathlib.LinearAlgebra.Isomorphisms |
| 16 | import Mathlib.GroupTheory.Index |
| 17 | import Mathlib.GroupTheory.FiniteAbelian.Basic |
| 18 | import Mathlib.Data.ZMod.QuotientRing |
| 19 | import Mathlib.Data.DFinsupp.FiniteInfinite |
| 20 | |
| 21 | /-! |
| 22 | # Torsion, quotients and rank of modules over a product |
| 23 | |
| 24 | Module-theoretic facts about torsion submodules, quotients by a product submodule, and the free |
| 25 | rank of a product: transport of the range of a scalar multiple and of the torsion along a linear |
| 26 | equivalence, the splitting of a quotient of a binary product, and the free rank of a product with |
| 27 | a finite factor. |
| 28 | |
| 29 | ## Main results |
| 30 | |
| 31 | * `LinearEquiv.map_range_lsmul`, `LinearEquiv.map_torsionBy`: transport of the range of `a • ·` |
| 32 | and of the `a`-torsion along an `R`-linear equivalence. |
| 33 | * `Submodule.prodQuotEquiv`: `(M × N) ⧸ (P.prod Q) ≃ₗ (M ⧸ P) × (N ⧸ Q)`. |
| 34 | * `Submodule.prodSubtypeEquiv`: `↥(S.prod T) ≃ ↥S × ↥T`. |
| 35 | * `Submodule.range_lsmul_prod`, `Submodule.torsionBy_prod`, `Submodule.natCard_torsionBy_prod`: |
| 36 | the range of `a • ·` and the `a`-torsion of a binary product split over the factors. |
| 37 | * `Module.finrank_prod_finite`: `finrank ℤ (F × D) = finrank ℤ F` for a finite `D`. |
| 38 | * `ModN.natCard_modN`: `|H ⧸ nH| = n ^ rank H · |H[n]|` for a finitely generated abelian group. |
| 39 | -/ |
| 40 | |
| 41 | section |
| 42 | |
| 43 | open Module |
| 44 | |
| 45 | namespace Module |
| 46 | |
| 47 | /-- A finite `ℤ`-module has free rank zero. -/ |
| 48 | lemma finrank_int_zero_of_finite {D : Type*} [AddCommGroup D] [Finite D] : finrank ℤ D = 0 := by |
| 49 | have : Module.Finite ℤ D := Module.Finite.of_finite |
| 50 | rw [finrank_eq_zero_iff_isTorsion, ← isAddTorsion_iff_isTorsion_int] |
| 51 | exact isAddTorsion_of_finite |
| 52 | |
| 53 | /-- The free rank of `F × D` equals that of `F` when `D` is finite. -/ |
| 54 | public lemma finrank_prod_finite {F : Type*} [AddCommGroup F] [Module.Finite ℤ F] |
| 55 | {D : Type*} [AddCommGroup D] [Finite D] : |
| 56 | finrank ℤ (F × D) = finrank ℤ F := by |
| 57 | have hkerD : finrank ℤ (LinearMap.ker (LinearMap.fst ℤ F D)) = 0 := by |
| 58 | rw [LinearMap.ker_fst, ← (LinearEquiv.ofInjective (LinearMap.inr ℤ F D) |
| 59 | LinearMap.inr_injective).finrank_eq, finrank_int_zero_of_finite] |
| 60 | have key := Submodule.finrank_quotient_add_finrank (LinearMap.ker (LinearMap.fst ℤ F D)) |
| 61 | rw [hkerD, add_zero, |
| 62 | (LinearMap.quotKerEquivOfSurjective _ LinearMap.fst_surjective).finrank_eq] at key |
| 63 | exact key.symm |
| 64 | |
| 65 | end Module |
| 66 | |
| 67 | namespace LinearEquiv |
| 68 | |
| 69 | variable {R : Type*} [CommRing R] {H K : Type*} [AddCommGroup H] [Module R H] |
| 70 | [AddCommGroup K] [Module R K] |
| 71 | |
| 72 | /-- A linear equivalence carries the range of `a • ·` to the range of `a • ·`. -/ |
| 73 | public lemma map_range_lsmul (e : H ≃ₗ[R] K) (a : R) : |
| 74 | (LinearMap.range (LinearMap.lsmul R H a)).map (e : H →ₗ[R] K) = |
| 75 | LinearMap.range (LinearMap.lsmul R K a) := by |
| 76 | ext z |
| 77 | simp only [Submodule.mem_map, LinearMap.mem_range, LinearMap.lsmul_apply, LinearEquiv.coe_coe] |
| 78 | constructor |
| 79 | · rintro ⟨_, ⟨y, rfl⟩, rfl⟩ |
| 80 | exact ⟨e y, by rw [map_smul]⟩ |
| 81 | · rintro ⟨w, rfl⟩ |
| 82 | exact ⟨a • e.symm w, ⟨e.symm w, rfl⟩, by rw [map_smul, e.apply_symm_apply]⟩ |
| 83 | |
| 84 | /-- A linear equivalence carries `a`-torsion to `a`-torsion. -/ |
| 85 | public lemma map_torsionBy (e : H ≃ₗ[R] K) (a : R) : |
| 86 | (Submodule.torsionBy R H a).map (e : H →ₗ[R] K) = Submodule.torsionBy R K a := by |
| 87 | ext z |
| 88 | simp only [Submodule.mem_map, Submodule.mem_torsionBy_iff, LinearEquiv.coe_coe] |
| 89 | constructor |
| 90 | · rintro ⟨y, hy, rfl⟩ |
| 91 | rw [← map_smul, hy, map_zero] |
| 92 | · exact fun hz ↦ ⟨e.symm z, by rw [← map_smul, hz, map_zero], by simp⟩ |
| 93 | |
| 94 | end LinearEquiv |
| 95 | |
| 96 | namespace Submodule |
| 97 | |
| 98 | variable {R : Type*} [CommRing R] {M N : Type*} [AddCommGroup M] [Module R M] |
| 99 | [AddCommGroup N] [Module R N] (a : R) |
| 100 | |
| 101 | /-- The quotient of a binary product by a product submodule splits as a product of quotients. -/ |
| 102 | public def prodQuotEquiv (P : Submodule R M) (Q : Submodule R N) : |
| 103 | HasQuotient.Quotient (M × N) (P.prod Q) ≃ₗ[R] (M ⧸ P) × (N ⧸ Q) := by |
| 104 | refine LinearEquiv.ofLinearMap |
| 105 | ((P.prod Q).liftQ (LinearMap.prodMap P.mkQ Q.mkQ) ?_) |
| 106 | (LinearMap.coprod |
| 107 | (P.liftQ ((P.prod Q).mkQ.comp (LinearMap.inl R M N)) ?_) |
| 108 | (Q.liftQ ((P.prod Q).mkQ.comp (LinearMap.inr R M N)) ?_)) ?_ ?_ |
| 109 | · intro z hz |
| 110 | simpa [LinearMap.mem_ker, Prod.mk_eq_zero, Submodule.Quotient.mk_eq_zero, Submodule.mem_prod] |
| 111 | using hz |
| 112 | · intro x hx |
| 113 | simp [LinearMap.mem_ker, Submodule.Quotient.mk_eq_zero, Submodule.mem_prod, hx] |
| 114 | · intro y hy |
| 115 | simp [LinearMap.mem_ker, Submodule.Quotient.mk_eq_zero, Submodule.mem_prod, hy] |
| 116 | · apply LinearMap.ext |
| 117 | rintro ⟨a, b⟩ |
| 118 | induction a using Submodule.Quotient.induction_on with | H x => |
| 119 | induction b using Submodule.Quotient.induction_on with | H y => |
| 120 | simp [← Submodule.Quotient.mk_add] |
| 121 | · apply LinearMap.ext |
| 122 | intro z |
| 123 | induction z using Submodule.Quotient.induction_on with | H xy => |
| 124 | obtain ⟨x, y⟩ := xy |
| 125 | simp [← Submodule.Quotient.mk_add] |
| 126 | |
| 127 | /-- The subtype of a product submodule is the product of the subtypes. -/ |
| 128 | public def prodSubtypeEquiv (S : Submodule R M) (T : Submodule R N) : ↥(S.prod T) ≃ ↥S × ↥T where |
| 129 | toFun x := (⟨x.1.1, x.2.1⟩, ⟨x.1.2, x.2.2⟩) |
| 130 | invFun y := ⟨(y.1.1, y.2.1), y.1.2, y.2.2⟩ |
| 131 | left_inv _ := rfl |
| 132 | right_inv _ := rfl |
| 133 | |
| 134 | /-- `a • ·` has range the product of the ranges of the coordinate maps. -/ |
| 135 | public lemma range_lsmul_prod : |
| 136 | LinearMap.range (LinearMap.lsmul R (M × N) a) = |
| 137 | (LinearMap.range (LinearMap.lsmul R M a)).prod (LinearMap.range (LinearMap.lsmul R N a)) := by |
| 138 | have h : LinearMap.lsmul R (M × N) a = |
| 139 | LinearMap.prodMap (LinearMap.lsmul R M a) (LinearMap.lsmul R N a) := by |
| 140 | ext p <;> simp [LinearMap.lsmul_apply] |
| 141 | rw [h, LinearMap.range_prodMap] |
| 142 | |
| 143 | /-- The `a`-torsion of a product is the product of the `a`-torsions. -/ |
| 144 | public lemma torsionBy_prod : |
| 145 | Submodule.torsionBy R (M × N) a = |
| 146 | (Submodule.torsionBy R M a).prod (Submodule.torsionBy R N a) := by |
| 147 | ext ⟨x, y⟩ |
| 148 | simp [Submodule.mem_torsionBy_iff, Submodule.mem_prod, Prod.smul_mk, Prod.ext_iff] |
| 149 | |
| 150 | /-- `Nat.card` of the `a`-torsion of a product multiplies over the factors. -/ |
| 151 | public lemma natCard_torsionBy_prod : |
| 152 | Nat.card (Submodule.torsionBy R (M × N) a) = |
| 153 | Nat.card (Submodule.torsionBy R M a) * Nat.card (Submodule.torsionBy R N a) := by |
| 154 | rw [torsionBy_prod, ← Nat.card_prod] |
| 155 | exact Nat.card_congr (prodSubtypeEquiv _ _) |
| 156 | |
| 157 | end Submodule |
| 158 | |
| 159 | namespace ModN |
| 160 | |
| 161 | variable {H : Type*} [AddCommGroup H] {n : ℕ} |
| 162 | |
| 163 | /-- The `n`-torsion `H[n]` is the kernel of the map `x ↦ n • x`. -/ |
| 164 | lemma torsionBy_eq_ker : Submodule.torsionBy ℤ H n = LinearMap.ker (LinearMap.lsmul ℤ H n) := rfl |
| 165 | |
| 166 | public instance [NeZero n] [Module.Finite ℤ H] : Finite (Submodule.torsionBy ℤ H n) := |
| 167 | Module.finite_of_fg_torsion _ |
| 168 | (Submodule.torsionBy_isTorsion_nonZeroDivisor _ (by simp [NeZero.ne])) |
| 169 | |
| 170 | /-- For a finite abelian group `D`, `x ↦ n • x` has equally large kernel and cokernel: |
| 171 | `Nat.card (D ⧸ nD) = Nat.card D[n]`. -/ |
| 172 | lemma natCard_modN_of_finite (D : Type*) [AddCommGroup D] [Finite D] : |
| 173 | Nat.card (ModN D n) = Nat.card (Submodule.torsionBy ℤ D n) := by |
| 174 | set f := LinearMap.lsmul ℤ D (n : ℤ) |
| 175 | have hquot : Nat.card (D ⧸ LinearMap.ker f) = Nat.card (LinearMap.range f) := |
| 176 | Nat.card_congr f.quotKerEquivRange.toEquiv |
| 177 | have h1 : Nat.card D = Nat.card (D ⧸ LinearMap.ker f) * Nat.card (LinearMap.ker f) := |
| 178 | (LinearMap.ker f).toAddSubgroup.card_eq_card_quotient_mul_card_addSubgroup |
| 179 | have h2 : Nat.card D = Nat.card (ModN D n) * Nat.card (LinearMap.range f) := |
| 180 | (LinearMap.range f).toAddSubgroup.card_eq_card_quotient_mul_card_addSubgroup |
| 181 | rw [torsionBy_eq_ker] |
| 182 | have hpos : Nat.card (LinearMap.range f) ≠ 0 := Nat.card_ne_zero.2 ⟨⟨0, by simp⟩, inferInstance⟩ |
| 183 | refine Nat.eq_of_mul_eq_mul_left (Nat.pos_of_ne_zero hpos) ?_ |
| 184 | grind |
| 185 | |
| 186 | variable {K : Type*} [AddCommGroup K] |
| 187 | |
| 188 | /-- `Nat.card (H ⧸ nH)` is invariant under linear equivalences. -/ |
| 189 | lemma natCard_modN_congr (e : H ≃ₗ[ℤ] K) : Nat.card (ModN H n) = Nat.card (ModN K n) := |
| 190 | Nat.card_congr (Submodule.Quotient.equiv _ _ e (e.map_range_lsmul n)).toEquiv |
| 191 | |
| 192 | /-- `Nat.card H[n]` is invariant under linear equivalences. -/ |
| 193 | lemma natCard_torsionBy_congr (e : H ≃ₗ[ℤ] K) : |
| 194 | Nat.card (Submodule.torsionBy ℤ H n) = Nat.card (Submodule.torsionBy ℤ K n) := by |
| 195 | rw [← e.map_torsionBy] |
| 196 | exact Nat.card_congr (e.submoduleMap (Submodule.torsionBy ℤ H n)).toEquiv |
| 197 | |
| 198 | section Prod |
| 199 | |
| 200 | variable {M N : Type*} [AddCommGroup M] [AddCommGroup N] |
| 201 | |
| 202 | /-- `H ⧸ nH` for a product is the product of the factors' `H ⧸ nH`. -/ |
| 203 | lemma natCard_modN_prod : |
| 204 | Nat.card (ModN (M × N) n) = Nat.card (ModN M n) * Nat.card (ModN N n) := by |
| 205 | rw [← Nat.card_prod] |
| 206 | exact Nat.card_congr |
| 207 | (((Submodule.quotEquivOfEq _ _ (Submodule.range_lsmul_prod (n : ℤ))).toEquiv).trans |
| 208 | (Submodule.prodQuotEquiv _ _).toEquiv) |
| 209 | |
| 210 | end Prod |
| 211 | |
| 212 | /-- A torsion-free module has trivial `n`-torsion. -/ |
| 213 | lemma natCard_torsionBy_eq_one_of_noZeroSMul [NeZero n] (F : Type*) [AddCommGroup F] |
| 214 | [NoZeroSMulDivisors ℤ F] : Nat.card (Submodule.torsionBy ℤ F n) = 1 := by |
| 215 | rw [(isSMulRegular_iff_torsionBy_eq_bot F (n : ℤ)).1 |
| 216 | (smul_right_injective F (by simp [NeZero.ne]))] |
| 217 | exact Nat.card_unique |
| 218 | |
| 219 | /-- The identity for a free-times-finite decomposition. -/ |
| 220 | lemma natCard_modN_of_free_prod_finite [NeZero n] |
| 221 | {F : Type*} [AddCommGroup F] [Module.Free ℤ F] [Module.Finite ℤ F] [NoZeroSMulDivisors ℤ F] |
| 222 | {D : Type*} [AddCommGroup D] [Finite D] : |
| 223 | Nat.card (ModN (F × D) n) = |
| 224 | n ^ finrank ℤ F * Nat.card (Submodule.torsionBy ℤ (F × D) n) := by |
| 225 | rw [natCard_modN_prod, Submodule.natCard_torsionBy_prod, ModN.natCard_eq F n, |
| 226 | natCard_modN_of_finite D, natCard_torsionBy_eq_one_of_noZeroSMul F, one_mul] |
| 227 | |
| 228 | /-- For a finitely generated abelian group `H`, `|H ⧸ nH| = n ^ rank H · |H[n]|`. -/ |
| 229 | public theorem natCard_modN [NeZero n] [Module.Finite ℤ H] : |
| 230 | Nat.card (ModN H n) = n ^ finrank ℤ H * Nat.card (Submodule.torsionBy ℤ H n) := by |
| 231 | obtain ⟨m, ι, fι, p, hp, ee, ⟨iso⟩⟩ := Module.equiv_free_prod_directSum ℤ H |
| 232 | set D := DirectSum ι fun i ↦ ℤ ⧸ (ℤ ∙ p i ^ ee i) |
| 233 | have : ∀ i, NeZero (p i ^ ee i) := fun i ↦ ⟨pow_ne_zero _ (hp i).ne_zero⟩ |
| 234 | have : ∀ i, Finite (ℤ ⧸ (ℤ ∙ (p i ^ ee i))) := fun i ↦ |
| 235 | inferInstanceAs (Finite (ℤ ⧸ Ideal.span {p i ^ ee i})) |
| 236 | have : Finite D := Finite.of_equiv _ DFinsupp.equivFunOnFintype.symm |
| 237 | calc Nat.card (ModN H n) |
| 238 | = Nat.card (ModN ((Fin m →₀ ℤ) × D) n) := natCard_modN_congr iso |
| 239 | _ = n ^ finrank ℤ (Fin m →₀ ℤ) * |
| 240 | Nat.card (Submodule.torsionBy ℤ ((Fin m →₀ ℤ) × D) n) := |
| 241 | natCard_modN_of_free_prod_finite |
| 242 | _ = n ^ finrank ℤ H * Nat.card (Submodule.torsionBy ℤ H n) := by |
| 243 | rw [iso.finrank_eq.trans finrank_prod_finite, natCard_torsionBy_congr iso] |
| 244 | |
| 245 | end ModN |
| 246 | |
| 247 | end |