Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Genus class numbers and the genus sum T5b(d)T_{5b}(d)T5b​(d)

Definition
ZInQGenus

by LG · Nov 21, 2026 · Mathlib 0df444a (Lean v4.33.1)

number-theoryz-is-diophantine-in-q

This bundle defines TYZ's genus class number and the genus sum of row 5b. For n≠0n\ne 0n=0, Q(−n)\mathbb{Q}(\sqrt{-n})Q(−n​) is represented as Mathlib's quadratic algebra, and g(n)=#(2 Cl(Q(−n)))g(n)=\#\bigl(2\,\mathrm{Cl}(\mathbb{Q}(\sqrt{-n}))\bigr)g(n)=#(2Cl(Q(−n​))) is the order of the subgroup of squares of the class group of its ring of integers. For a set BBB of prime factors of ddd, dB=∏p∈Bpd_B=\prod_{p\in B}pdB​=∏p∈B​p. A set partition of the primes of ddd is admissible for row 5b when exactly one block has dB≡7(mod8)d_B\equiv 7\pmod 8dB​≡7(mod8), exactly one has dB≡3(mod8)d_B\equiv 3\pmod 8dB​≡3(mod8), and every block is ≡7,3,\equiv 7,3,≡7,3, or 1(mod8)1\pmod 81(mod8). The genus sum T5b(d)∈Z/2ZT_{5b}(d)\in\mathbb{Z}/2\mathbb{Z}T5b​(d)∈Z/2Z sums ∏Bg(dB)\prod_{B} g(d_B)∏B​g(dB​) over the admissible partitions.

Definition code
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.Rank5b
Source
https://github.com/elliotglazer/diophantine-z-q/blob/964d7dd71f253091dbc5eac793b78cc56d1fcc73/ZInQKernel/RouteK/Rank5b/Sec3/RedeiStatement.lean#L24-L62
Read-back

What the Lean code literally says, in plain math · glm

The bundle defines the following, all noncomputable. QNeg(n)\mathrm{QNeg}(n)QNeg(n) is the quadratic algebra Q[ω]/(ω2=−n)\mathbb{Q}[\omega]/(\omega^2=-n)Q[ω]/(ω2=−n); for n≠0n\ne 0n=0 it is a field (because no rational rrr satisfies r2=−nr^2=-nr2=−n) and a number field. For a set BBB of prime factors of ddd, dProd(B)=∏p∈Bp\mathrm{dProd}(B)=\prod_{p\in B}pdProd(B)=∏p∈B​p, a nonzero natural number. gCl(n)\mathrm{gCl}(n)gCl(n) (for n≠0n\ne 0n=0) is the natural-number cardinality of the range of the squaring endomorphism x↦x2x\mapsto x^2x↦x2 of the class group of the ring of integers of QNeg(n)\mathrm{QNeg}(n)QNeg(n). A partition PPP of the prime factors of ddd satisfies Admissible5bNat(d,P)\mathrm{Admissible5bNat}(d,P)Admissible5bNat(d,P) iff exactly one block has product ≡7(mod8)\equiv 7\pmod 8≡7(mod8), exactly one block has product ≡3(mod8)\equiv 3\pmod 8≡3(mod8), and every block has product ≡7,3,\equiv 7,3,≡7,3, or 1(mod8)1\pmod 81(mod8); this predicate is decidable. T5bCl(d)∈Z/2Z\mathrm{T5bCl}(d)\in\mathbb{Z}/2\mathbb{Z}T5bCl(d)∈Z/2Z is the sum, over all set partitions PPP of the prime factors of ddd, of ∏B∈PgCl(dProd(B))\prod_{B\in P}\mathrm{gCl}(\mathrm{dProd}(B))∏B∈P​gCl(dProd(B)) (cast to Z/2Z\mathbb{Z}/2\mathbb{Z}Z/2Z) when PPP is admissible, and 000 otherwise.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me