Lean formalization of the Riemann Hypothesis (Alpöge, 2026-11-20) being cleaned up by members of the Lean community.
Python
refactor(Lib/General/NumberTheory/FrobeniusOrbits): extract self-adjoint pair bijection helper
Rohan Arun49581e16d301
diff --git a/src/Lib/General/NumberTheory/FrobeniusOrbits.lean b/src/Lib/General/NumberTheory/FrobeniusOrbits.leanindex 096e712f409..7cb250bcfba 100644--- a/src/Lib/General/NumberTheory/FrobeniusOrbits.lean+++ b/src/Lib/General/NumberTheory/FrobeniusOrbits.lean@@ -67,6 +67,19 @@ section InertResidueopen Nat NumberField New HasPrimitiveRoot5040 FiniteField Ideal Quotient selfAdjoint+/-- Given a square root `i` of `-1` in a finite field `k` with `star i ≠ i`, pairs of+elements of `selfAdjoint k` are in bijection with `k` via `(x, y) ↦ (x - i * y) / 2`. -/+private lemma card_pairs_selfAdjoint_eq {k : Type*} [Field k] [StarRing k] [Finite k]+ {i : k} (hi_sq : i * i = -1) (hi_moved : star i ≠ i) :+ Nat.card (selfAdjoint k × selfAdjoint k) = Nat.card k := by+ have h_star : star i = -i := by grind [star_mul, star_neg, star_one, mul_self_eq_mul_self_iff]+ refine card_congr ⟨fun (x, y) ↦ (x - i * y) / 2,+ fun z ↦ (⟨z + star z, .add_star_self z⟩, ⟨i * z + star (i * z), .add_star_self _⟩),+ fun ⟨⟨x, hx⟩, ⟨y, hy⟩⟩ ↦ by+ simp [mem_iff.1 hx, mem_iff.1 hy, h_star]+ grind,+ fun z ↦ by grind [star_mul']⟩+/-- A finite field with an involution that moves a square root of `-1` has `r ^ 2` elements,where `r`, the number of fixed points, is `3` modulo `4`. -/lemma New.card_selfAdjoint {k : Type*} [Field k] [StarRing k] [Finite k] {i : k}@@ -75,14 +88,8 @@ lemma New.card_selfAdjoint {k : Type*} [Field k] [StarRing k] [Finite k] {i : k}-- `star i` is a square root of `-1` other than `i`, so it is `-i`, and `-i ≠ i` gives `2 ≠ 0`.have h_star : star i = -i := by grind [star_mul, star_neg, star_one, mul_self_eq_mul_self_iff]refine ⟨?_, ?_⟩- -- `(x, y) ↦ (x - i * y) / 2` is a bijection from pairs of fixed points onto `k`.· rw [sq, ← card_prod]- refine card_congr ⟨fun (x, y) ↦ (x - i * y) / 2,- fun z ↦ (⟨z + star z, .add_star_self z⟩, ⟨i * z + star (i * z), .add_star_self _⟩),- fun ⟨⟨x, hx⟩, ⟨y, hy⟩⟩ ↦ by- simp [mem_iff.1 hx, mem_iff.1 hy, h_star]- grind,- fun z ↦ by grind [star_mul']⟩+ exact card_pairs_selfAdjoint_eq hi_sq hi_moved-- `-1` is not a square in the field of fixed points: its square roots `±i` are moved.· cases nonempty_fintype (selfAdjoint k)by_contra h