Lean / Reader
Lean reader

BealFrey.lean

210 lines27 declarationsno sorry
  1. import Mathlib.Tactic.Ring
  2. import Mathlib.Tactic.Linarith
  3. import Mathlib.Data.ZMod.Basic
  4. /-!
  5. # Round 14: the Frey curve of `{3,4,p}` and its conductor at 2 and 3
  6. For a primitive solution of `A³ + B⁴ = Cᵖ`, `A³ + Cᵖ = B⁴` or `B⁴ + Cᵖ = A³` put `a = B²` and `b = A` (first order)
  7. or `b = -A` (other two), so that `a² + b³ = s·Cᵖ` with `s = 1, 1, -1`. The Frey curve is
  8. `E_{a,b} : Y² = X³ + 3bX - 2a`, i.e. `a₁ = a₂ = a₃ = 0`, `a₄ = 3b`, `a₆ = -2a`.
  9. This file checks the algebra behind the computation of the Serre level `N = 2^{f₂} 3^{f₃}`:
  10. * the invariants `c₄ = -144b`, `c₆ = 1728a`, `Δ = -1728(a² + b³)`;
  11. * `2 ∤ C`: `v₂(Δ) = 6`; Tate's algorithm stops at type II (`f₂ = 6`) for `B` odd or `b ≡ 3 (mod 4)`, and at type III
  12. (`f₂ = 5`) for `B` even, `b ≡ 1 (mod 4)`;
  13. * `3 ∤ C`: `v₃(Δ) = 3`; the singular point is `(-a, 0)`, and `f₃ = 2` or `3` according to `9 ∣ a(a² + 3b + 2)`;
  14. * `2 ∣ C`: Kraus' condition `c₆' ≡ -1 (mod 4)` for `(c₄', c₆') = (c₄/2⁴, c₆/2⁶)`, so `E` is multiplicative at 2;
  15. * `3 ∣ C`: `B ≡ ±1 (mod 9)` and `81 ∤ c₄`, so the model is minimal and the reduction is of type `Iₙ*`;
  16. * the Ramanujan bound used for level lowering: `p ∣ (ℓ+1)² - a_ℓ²` forces `p ≤ (√ℓ + 1)²`.
  17. Modularity, Ribet's level lowering, Mazur's isogeny theorem, Tate's algorithm itself, Ogg's formula and the
  18. computation of the newforms are cited, not formalized.
  19. -/
  20. namespace BealFrey
  21. /-! ### Weierstrass invariants (standard formulas) -/
  22. def b2 (a₁ a₂ : ℤ) : ℤ := a₁ ^ 2 + 4 * a₂
  23. def b4 (a₁ a₃ a₄ : ℤ) : ℤ := a₁ * a₃ + 2 * a₄
  24. def b6 (a₃ a₆ : ℤ) : ℤ := a₃ ^ 2 + 4 * a₆
  25. def b8 (a₁ a₂ a₃ a₄ a₆ : ℤ) : ℤ := a₁ ^ 2 * a₆ + 4 * a₂ * a₆ - a₁ * a₃ * a₄ + a₂ * a₃ ^ 2 - a₄ ^ 2
  26. def c4 (a₁ a₂ a₃ a₄ : ℤ) : ℤ := b2 a₁ a₂ ^ 2 - 24 * b4 a₁ a₃ a₄
  27. def c6 (a₁ a₂ a₃ a₄ a₆ : ℤ) : ℤ :=
  28. -b2 a₁ a₂ ^ 3 + 36 * b2 a₁ a₂ * b4 a₁ a₃ a₄ - 216 * b6 a₃ a₆
  29. def disc (a₁ a₂ a₃ a₄ a₆ : ℤ) : ℤ :=
  30. -b2 a₁ a₂ ^ 2 * b8 a₁ a₂ a₃ a₄ a₆ - 8 * b4 a₁ a₃ a₄ ^ 3 - 27 * b6 a₃ a₆ ^ 2
  31. + 9 * b2 a₁ a₂ * b4 a₁ a₃ a₄ * b6 a₃ a₆
  32. /-- `c₄(E_{a,b}) = -144b`. -/
  33. theorem frey_c4 (b : ℤ) : c4 0 0 0 (3 * b) = -144 * b := by
  34. simp only [c4, b2, b4]; ring
  35. /-- `c₆(E_{a,b}) = 1728a`. -/
  36. theorem frey_c6 (a b : ℤ) : c6 0 0 0 (3 * b) (-2 * a) = 1728 * a := by
  37. simp only [c6, b2, b4, b6]; ring
  38. /-- `Δ(E_{a,b}) = -1728(a² + b³) = -1728·s·Cᵖ`. -/
  39. theorem frey_disc (a b : ℤ) : disc 0 0 0 (3 * b) (-2 * a) = -1728 * (a ^ 2 + b ^ 3) := by
  40. simp only [disc, b2, b4, b6, b8]; ring
  41. /-- The invariants satisfy `c₄³ - c₆² = 1728Δ`, and `j = c₄³/Δ = 1728b³/(a² + b³)`. -/
  42. theorem frey_c4c6_disc (a b : ℤ) :
  43. (-144 * b) ^ 3 - (1728 * a) ^ 2 = 1728 * (-1728 * (a ^ 2 + b ^ 3)) ∧
  44. (-144 * b) ^ 3 = 1728 * b ^ 3 * (-1728) := by
  45. constructor <;> ring
  46. /-! ### The prime 2, `2 ∤ C` (so `a² + b³` is odd and `B`, `b` have opposite parity) -/
  47. /-- `v₂(Δ) = 6` when `c = a² + b³` is odd; the model is then minimal at 2 (`v₂(Δ) < 12`). -/
  48. theorem disc_val2 (c : ℤ) (hc : ¬ (2 : ℤ) ∣ c) : (64 : ℤ) ∣ -1728 * c ∧ ¬ (128 : ℤ) ∣ -1728 * c := by
  49. refine ⟨⟨-27 * c, by ring⟩, ?_⟩
  50. omega
  51. /-- `B = 2k + 1` odd, `b = 2m` even: the singular point mod 2 is `(0,0)`, `2 ∣ a₄`, `2 ∣ a₆`, `b₂ = 0`, and
  52. `4 ∤ a₆ = -2B²`: type II, `f₂ = v₂(Δ) = 6`. -/
  53. theorem tate2_B_odd (k m : ℤ) :
  54. (2 : ℤ) ∣ 3 * (2 * m) ∧ (2 : ℤ) ∣ -2 * (2 * k + 1) ^ 2 ∧ ¬ (4 : ℤ) ∣ -2 * (2 * k + 1) ^ 2 := by
  55. refine ⟨⟨3 * m, by ring⟩, ⟨-(2 * k + 1) ^ 2, by ring⟩, ?_⟩
  56. have e : -2 * (2 * k + 1) ^ 2 = 4 * (-2 * k ^ 2 - 2 * k - 1) + 2 := by ring
  57. rw [e]
  58. generalize -2 * k ^ 2 - 2 * k - 1 = w
  59. omega
  60. /-- `b` odd: the singular point of `E mod 2` is `(1, 0)`; the shift `X = x + 1` gives
  61. `a₂ = 3`, `a₄ = 3(1 + b)`, `a₆ = 1 + 3b - 2a` (and `b₂ = 12`, so the reduction is additive). -/
  62. theorem tate2_shift (a b x : ℤ) :
  63. (x + 1) ^ 3 + 3 * b * (x + 1) - 2 * a = x ^ 3 + 3 * x ^ 2 + 3 * (1 + b) * x + (1 + 3 * b - 2 * a) := by
  64. ring
  65. /-- `B = 2k` even, `b = 4m + 3`: after the shift `2 ∣ a₄`, `2 ∣ a₆` and `4 ∤ a₆`: type II, `f₂ = 6`. -/
  66. theorem tate2_b3 (k m : ℤ) :
  67. (2 : ℤ) ∣ 3 * (1 + (4 * m + 3)) ∧ (2 : ℤ) ∣ 1 + 3 * (4 * m + 3) - 2 * (2 * k) ^ 2 ∧
  68. ¬ (4 : ℤ) ∣ 1 + 3 * (4 * m + 3) - 2 * (2 * k) ^ 2 := by
  69. refine ⟨⟨6 * m + 6, by ring⟩, ⟨6 * m + 5 - 4 * k ^ 2, by ring⟩, ?_⟩
  70. have e : 1 + 3 * (4 * m + 3) - 2 * (2 * k) ^ 2 = 4 * (2 + 3 * m - 2 * k ^ 2) + 2 := by ring
  71. rw [e]
  72. generalize 2 + 3 * m - 2 * k ^ 2 = w
  73. omega
  74. /-- `B = 2k` even, `b = 4m + 1`: `4 ∣ a₆`, and `b₈ = 4a₂a₆ - a₄² = 12a₆ - 9(1 + b)²` is `≡ 4 (mod 8)`:
  75. type III, `f₂ = v₂(Δ) - 1 = 5`. -/
  76. theorem tate2_b1 (k m : ℤ) :
  77. (4 : ℤ) ∣ 1 + 3 * (4 * m + 1) - 2 * (2 * k) ^ 2 ∧
  78. ¬ (8 : ℤ) ∣ 12 * (1 + 3 * (4 * m + 1) - 2 * (2 * k) ^ 2) - 9 * (1 + (4 * m + 1)) ^ 2 := by
  79. refine ⟨⟨1 + 3 * m - 2 * k ^ 2, by ring⟩, ?_⟩
  80. have e : 12 * (1 + 3 * (4 * m + 1) - 2 * (2 * k) ^ 2) - 9 * (1 + (4 * m + 1)) ^ 2
  81. = 8 * (1 - 12 * k ^ 2 - 18 * m ^ 2) + 4 := by ring
  82. rw [e]
  83. generalize 1 - 12 * k ^ 2 - 18 * m ^ 2 = w
  84. omega
  85. /-! ### The prime 3, `3 ∤ C` -/
  86. /-- `v₃(Δ) = 3` when `3 ∤ c`; the model is minimal at 3. -/
  87. theorem disc_val3 (c : ℤ) (hc : ¬ (3 : ℤ) ∣ c) : (27 : ℤ) ∣ -1728 * c ∧ ¬ (81 : ℤ) ∣ -1728 * c := by
  88. refine ⟨⟨-64 * c, by ring⟩, ?_⟩
  89. omega
  90. /-- The singular point of `E mod 3` is `(-a, 0)`; the shift `X = x - a` gives `a₂ = -3a`, `a₄ = 3a² + 3b`,
  91. `a₆ = -a(a² + 3b + 2)`. -/
  92. theorem tate3_shift (a b x : ℤ) :
  93. (x - a) ^ 3 + 3 * b * (x - a) - 2 * a
  94. = x ^ 3 - 3 * a * x ^ 2 + (3 * a ^ 2 + 3 * b) * x - a * (a ^ 2 + 3 * b + 2) := by
  95. ring
  96. /-- After the shift `3 ∣ a₆` always (so Tate's step 2 applies; `b₂ = -12a`, additive reduction). -/
  97. theorem tate3_a6 (a b : ℤ) : (3 : ℤ) ∣ a * (a ^ 2 + 3 * b + 2) := by
  98. have h : (((a * (a ^ 2 + 3 * b + 2) : ℤ)) : ZMod 3) = 0 := by
  99. push_cast
  100. generalize (a : ZMod 3) = x
  101. generalize (b : ZMod 3) = y
  102. revert x y
  103. decide
  104. exact_mod_cast (ZMod.intCast_zmod_eq_zero_iff_dvd _ 3).mp h
  105. /-- Tate's step 3 at 3: `f₃ = 3` (type II) iff `9 ∤ a₆`, otherwise `f₃ = 2` (type III; type IV would give `f₃ = 1`).
  106. With `a = B²` and `3 ∤ B⁴ + b³`: `9 ∣ B²(B⁴ + 3b + 2)` iff `3 ∣ B`, or `B ≡ ±2 (mod 9)` and `3 ∣ b`, or
  107. `B ≡ ±4 (mod 9)` and `b ≡ 1 (mod 3)`. (For `B ≡ ±1 (mod 9)` it never holds.) -/
  108. theorem tate3_rule : ∀ B b : ZMod 9, 3 * (B ^ 4 + b ^ 3) ≠ 0 →
  109. (B ^ 2 * (B ^ 4 + 3 * b + 2) = 0 ↔
  110. (3 * B = 0 ∨ ((B = 2 ∨ B = 7) ∧ 3 * b = 0) ∨ ((B = 4 ∨ B = 5) ∧ 3 * (b - 1) = 0))) := by
  111. decide
  112. /-! ### `2 ∣ C` and `3 ∣ C` -/
  113. /-- `2 ∣ C` (`B`, `b` odd): the scaled invariants `c₄' = c₄/2⁴ = -9b`, `c₆' = c₆/2⁶ = 27a` have
  114. `c₄'³ - c₆'² = 1728Δ'` with `Δ' = Δ/2¹²`, integral since `2⁶ ∣ a² + b³`. -/
  115. theorem kraus2_scaling (a b : ℤ) :
  116. -144 * b = 2 ^ 4 * (-9 * b) ∧ 1728 * a = 2 ^ 6 * (27 * a) ∧
  117. 64 * ((-9 * b) ^ 3 - (27 * a) ^ 2) = 1728 * (-27 * (a ^ 2 + b ^ 3)) := by
  118. refine ⟨by ring, by ring, by ring⟩
  119. /-- Kraus' condition at 2 holds: `c₆' = 27B² ≡ 3 ≡ -1 (mod 4)` for `B` odd, so `(c₄', c₆')` come from a model over
  120. `ℤ₂`; as `c₄' = -9b` is odd, `E` has multiplicative reduction at 2 with `v₂(Δ_min) = p·v₂(C) - 6`, prime to `p`. -/
  121. theorem kraus2_c6 (k : ℤ) : (27 * (2 * k + 1) ^ 2) % 4 = 3 := by
  122. have e : 27 * (2 * k + 1) ^ 2 = 4 * (27 * k ^ 2 + 27 * k + 6) + 3 := by ring
  123. rw [e]
  124. generalize 27 * k ^ 2 + 27 * k + 6 = w
  125. omega
  126. /-- `3 ∣ C` forces `9 ∣ B⁴ + b³` with `3 ∤ B`, hence `B ≡ ±1 (mod 9)`. -/
  127. theorem cube_mod9 : ∀ B b : ZMod 9, 3 * B ≠ 0 → B ^ 4 + b ^ 3 = 0 → B = 1 ∨ B = 8 := by
  128. decide
  129. /-- `3 ∣ C` (so `3 ∤ b`): `81 ∤ c₄ = -144b`, so no rescaling by 3 exists, the model is minimal, the reduction is
  130. additive with `v₃(j) = 6 - v₃(Δ) < 0` (type `Iₙ*`, potentially multiplicative), and `f₃ = 2`. -/
  131. theorem not_scalable3 (b : ℤ) (hb : ¬ (3 : ℤ) ∣ b) : ¬ (81 : ℤ) ∣ -144 * b := by
  132. omega
  133. /-! ### The Ramanujan bound behind level lowering -/
  134. /-- If `a² ≤ 4ℓ` (Hasse–Weil / Ramanujan–Petersson for a rational eigenform) and `ℓ ≥ 2`, then `ℓ + 1 ± a > 0`,
  135. so `(ℓ+1)² - a² ≠ 0`. -/
  136. theorem ramanujan_pos (l a : ℤ) (hl : 2 ≤ l) (ha : a ^ 2 ≤ 4 * l) : 0 < l + 1 - a ∧ 0 < l + 1 + a := by
  137. have key : ∀ x : ℤ, x ^ 2 ≤ 4 * l → x < l + 1 := by
  138. intro x hx
  139. by_contra h'
  140. have h : l + 1 ≤ x := not_lt.mp h'
  141. have h0 : (0 : ℤ) ≤ l + 1 := by omega
  142. have h1 : (l + 1) * (l + 1) ≤ x * x := by nlinarith
  143. nlinarith
  144. have h1 := key a ha
  145. have h2 := key (-a) (by rw [neg_sq]; exact ha)
  146. constructor <;> linarith
  147. /-- Level lowering at `ℓ ∣ C`: `a_ℓ(f) ≡ ±(ℓ + 1) (mod p)`. For a rational form, `p ∣ ℓ + 1 - a` (`a = ±a_ℓ`) gives
  148. `p ≤ ℓ + 1` or `(p - ℓ - 1)² ≤ 4ℓ`, i.e. `p ≤ (√ℓ + 1)²`. -/
  149. theorem exponent_bound (l a p : ℤ) (hl : 2 ≤ l) (ha : a ^ 2 ≤ 4 * l) (hdiv : p ∣ l + 1 - a) :
  150. p ≤ l + 1 ∨ (p - (l + 1)) ^ 2 ≤ 4 * l := by
  151. have hpos := (ramanujan_pos l a hl ha).1
  152. have hle : p ≤ l + 1 - a := Int.le_of_dvd hpos hdiv
  153. by_cases h : p ≤ l + 1
  154. · exact Or.inl h
  155. · right
  156. have h' : l + 1 < p := not_le.mp h
  157. have h1 : 0 ≤ p - (l + 1) := by linarith
  158. have h2 : p - (l + 1) ≤ -a := by linarith
  159. nlinarith
  160. /-- The same for a prime `p ∣ (ℓ + 1)² - a²`. -/
  161. theorem exponent_bound_sq (l a p : ℤ) (hl : 2 ≤ l) (ha : a ^ 2 ≤ 4 * l) (hp : Prime p)
  162. (hdiv : p ∣ (l + 1) ^ 2 - a ^ 2) : p ≤ l + 1 ∨ (p - (l + 1)) ^ 2 ≤ 4 * l := by
  163. have e : (l + 1) ^ 2 - a ^ 2 = (l + 1 - a) * (l + 1 - -a) := by ring
  164. rw [e] at hdiv
  165. rcases hp.dvd_or_dvd hdiv with h | h
  166. · exact exponent_bound l a p hl ha h
  167. · exact exponent_bound l (-a) p hl (by rw [neg_sq]; exact ha) h
  168. end BealFrey
  169. #print axioms BealFrey.frey_disc
  170. #print axioms BealFrey.tate2_b1
  171. #print axioms BealFrey.tate3_rule
  172. #print axioms BealFrey.tate3_a6
  173. #print axioms BealFrey.kraus2_c6
  174. #print axioms BealFrey.cube_mod9
  175. #print axioms BealFrey.exponent_bound_sq