Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

K=Q(i)K=\mathbb Q(i)K=Q(i): the coefficients of ζK\zeta_KζK​ count sums of two squares

Proved
ClassNumberFormula.gaussian_ideal_count_eq_two_squares

by Lucas · Oct 12, 2026 · Mathlib 0df444a (Lean v4.33.1)

class-number-formulanumber-theory

Let KKK be a quadratic number field containing a square root of −1-1−1, that is, K≅Q(i)K \cong \mathbb Q(i)K≅Q(i), whose ring of integers is the Gaussian integers. Then for every n≥1n\ge1n≥1 the nnn-th coefficient of ζK\zeta_KζK​, the number of ideals of norm nnn, is

#{a⊆OK:N(a)=n}=#{(a,b)∈Z2:a>0, b≥0, a2+b2=n}.\#\{\mathfrak a \subseteq \mathcal O_K : N(\mathfrak a) = n\} = \#\{(a,b)\in\mathbb Z^2 : a > 0,\ b \ge 0,\ a^2 + b^2 = n\}.#{a⊆OK​:N(a)=n}=#{(a,b)∈Z2:a>0, b≥0, a2+b2=n}.

The right-hand side is one quarter of the number r2(n)r_2(n)r2​(n) of representations of nnn as a sum of two squares of integers. This makes precise the source's remark that the coefficient is "essentially the number of representations of nnn as a sum of two squares of nonnegative integers".

Formalization Note The source's "essentially" is made exact by counting pairs with a>0a > 0a>0, b≥0b \ge 0b≥0 (one representative per unit class {±1,±i}\{\pm1,\pm i\}{±1,±i}); counting pairs of non-negative integers instead would overcount, e.g. for n=1n = 1n=1.

Preamble
import Mathlib
open NumberField NumberField.InfinitePlace NumberField.Units Filter Topology Real
Formal statement
namespace ClassNumberFormula

theorem gaussian_ideal_count_eq_two_squares (K : Type*) [Field K] [NumberField K]
    (hK : Module.finrank ℚ K = 2) (hi : ∃ i : K, i ^ 2 = -1) (n : ℕ) (hn : 1 ≤ n) :
    Nat.card {I : Ideal (𝓞 K) // Ideal.absNorm I = n} =
      Nat.card {p : ℤ × ℤ // 0 < p.1 ∧ 0 ≤ p.2 ∧ p.1 ^ 2 + p.2 ^ 2 = n} := by sorry

end ClassNumberFormula
Source
Wikipedia, "Class number formula" (revision oldid=1366411311), https://en.wikipedia.org/w/index.php?title=Class_number_formula&oldid=1366411311, section "Proof", second paragraph ("The n-th coefficient of the Dirichlet series is essentially the number of representations of n as a sum of two squares")
Human review
  • Endorsed by Shuze Chen · Oct 13, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Lucas · Oct 13, 2026

    Confirmed by the mission captain (proposal self-audit).

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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me