Genus class numbers and the genus sum
DefinitionZInQGenusThis bundle defines TYZ's genus class number and the genus sum of row 5b. For , is represented as Mathlib's quadratic algebra, and is the order of the subgroup of squares of the class group of its ring of integers. For a set of prime factors of , . A set partition of the primes of is admissible for row 5b when exactly one block has , exactly one has , and every block is or . The genus sum sums over the admissible partitions.
import Mathlib
import Mathlib.Algebra.QuadraticAlgebra.Basic
noncomputable section
open NumberField
namespace ZInQ.RouteK.Rank5b
/-- The field Q(sqrt(-n)), as Mathlib's quadratic algebra. -/
abbrev QNeg (n : ℕ) : Type := QuadraticAlgebra ℚ (-(n : ℚ)) 0
/-- No rational r satisfies r^2 = -n (for n != 0); this is the Fact the
QuadraticAlgebra field instance requires at this Mathlib pin. -/
instance QNeg.factNoRoot (n : ℕ) [NeZero n] : Fact (∀ r : ℚ, r ^ 2 ≠ -(n : ℚ) + 0 * r) := by
refine ⟨fun r hr => ?_⟩
have h0 : (0 : ℚ) < n := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne n)
rw [zero_mul, add_zero] at hr
nlinarith [sq_nonneg r]
instance QNeg.numberField (n : ℕ) [NeZero n] : NumberField (QNeg n) where
/-- d_B = product of the primes in B. -/
def dProd {d : ℕ} (B : Finset d.primeFactors) : ℕ := ∏ p ∈ B, (p : ℕ)
instance neZero_dProd {d : ℕ} (B : Finset d.primeFactors) : NeZero (dProd B) :=
⟨Finset.prod_ne_zero_iff.mpr fun p _ => (Nat.prime_of_mem_primeFactors p.2).ne_zero⟩
/-- TYZ's genus class number g(n) = #(2 Cl(Q(sqrt(-n)))). -/
def gCl (n : ℕ) [NeZero n] : ℕ :=
Nat.card (powMonoidHom 2 : ClassGroup (𝓞 (QNeg n)) →* ClassGroup (𝓞 (QNeg n))).range
/-- Admissibility for row 5b: one block = 7, one block = 3, all blocks 7, 3 or 1 mod 8. -/
def Admissible5bNat (d : ℕ) (P : Finpartition (Finset.univ : Finset d.primeFactors)) : Prop :=
(P.parts.filter fun B => dProd B % 8 = 7).card = 1 ∧
(P.parts.filter fun B => dProd B % 8 = 3).card = 1 ∧
∀ B ∈ P.parts, dProd B % 8 = 7 ∨ dProd B % 8 = 3 ∨ dProd B % 8 = 1
instance (d : ℕ) (P : Finpartition (Finset.univ : Finset d.primeFactors)) :
Decidable (Admissible5bNat d P) := by
unfold Admissible5bNat; infer_instance
/-- The genus sum of row 5b with TYZ's class-number g. -/
def T5bCl (d : ℕ) : ZMod 2 :=
∑ P : Finpartition (Finset.univ : Finset d.primeFactors),
if Admissible5bNat d P then ∏ B ∈ P.parts, ((gCl (dProd B) : ℕ) : ZMod 2) else 0
end ZInQ.RouteK.Rank5bRead-back
What the Lean code literally says, in plain math · glm
The bundle defines the following, all noncomputable. is the quadratic algebra ; for it is a field (because no rational satisfies ) and a number field. For a set of prime factors of , , a nonzero natural number. (for ) is the natural-number cardinality of the range of the squaring endomorphism of the class group of the ring of integers of . A partition of the prime factors of satisfies iff exactly one block has product , exactly one block has product , and every block has product or ; this predicate is decidable. is the sum, over all set partitions of the prime factors of , of (cast to ) when is admissible, and otherwise.