A Lean 4 formalization of quadratic number fields ℚ(√d) and the classification
of their ring of integers, built on mathlib's QuadraticAlgebra.
(RingOfIntegers/Classification.lean)
For squarefree d ≠ 1, the ring of integers 𝓞 (ℚ(√d)) is classified as:
- If
d % 4 ≠ 1, then𝓞 (ℚ(√d)) ≃+* ℤ[√d]. - If
d % 4 = 1, writingd = 1 + 4k, then𝓞 (ℚ(√d)) ≃+* ℤ[(1+√d)/2].
Key declarations: ringOfIntegers_equiv_zsqrtd_of_mod_four_ne_one,
ringOfIntegers_equiv_zOnePlusSqrtOverTwo_of_mod_four_eq_one,
ringOfIntegers_classification.
Classical examples:
- Gaussian integers (
d = -1):𝓞 (ℚ(√(-1))) ≃+* ℤ[i] - Eisenstein integers (
d = -3):𝓞 (ℚ(√(-3))) ≃+* ℤ[ω]whereω = (1+√(-3))/2
(RingOfIntegers/Discriminant.lean)
The number field discriminant of ℚ(√d) is computed as:
discr_formula:Δ(ℚ(√d)) = if d % 4 = 1 then d else 4 * d
Examples: Δ(ℚ(√(-1))) = -4, Δ(ℚ(√(-3))) = -3, Δ(ℚ(√(-5))) = -20.
(RingOfIntegers/ZsqrtdMathlibInstances.lean)
For squarefree d ≠ 1:
isDedekindDomain_iff_mod_four_ne_one:ℤ√dis a Dedekind domain if and only ifd % 4 ≠ 1
This follows from the ring of integers classification — ℤ√d is a Dedekind domain
precisely when it equals the full ring of integers 𝓞 (ℚ(√d)).
Qsqrtd (d : ℚ) := QuadraticAlgebra ℚ d 0— the quadratic fieldℚ(√d)(Basic.lean)- Parameters:
[Fact (Squarefree d)] [Fact (d ≠ 1)]— explicitFactinstances (Parameters.lean,RingOfIntegers/CommonInstances.lean) Zsqrtd dandZOnePlusSqrtOverTwo k— the two candidate integral models (RingOfIntegers/Zsqrtd.lean,RingOfIntegers/ZOnePlusSqrtOverTwo.lean)
The project is organized around a small number of medium-sized files. In the
ring-of-integers development, closely related material is usually grouped into a
single file and separated with sections, rather than split into many tiny
modules.
In particular:
Integrality.leandevelops the main integrality transport and half-integer normal form arguments.TraceNorm.leanisolates the trace/norm preliminaries used by the classification proofs.Classification.lean,Norm.lean, andDiscriminant.leaneach collect one main narrative, with internalsections for subresults.
This project formalizes:
- Quadratic number fields as
Qsqrtd d := QuadraticAlgebra ℚ d 0 - Parametrization via squarefree integers and uniqueness of the parameter
- Ring of integers classification (
ringOfIntegers_classification) - Discriminant formula (
discr_formula) - Dedekind domain characterization (
isDedekindDomain_iff_mod_four_ne_one) - Totally real / totally complex / CM field classification
- Integrality criteria via trace and norm
- Norm multiplicativity and unit criterion (
N(z) = ±1) - Ideal theory in
ℤ[√d]: quotient by prime ideals, ramification - Concrete verified examples for
ℤ[√(-5)]: ideal factorization, primality, ramification/inertia
QuadraticNumberFields/
├── lakefile.toml
├── lean-toolchain
├── QuadraticNumberFields.lean # Root import module
├── QuadraticNumberFields/
│ ├── Basic.lean # Qsqrtd type, norm, trace, field instances
│ ├── Instances.lean # NumberField instance for quadratic extensions
│ ├── Parameters.lean # Rescaling, squarefree normalization, uniqueness
│ ├── FieldClassification.lean # Quadratic field ↔ squarefree parameter
│ ├── TotallyRealComplex.lean # Totally real / complex / CM classification
│ ├── RingEquiv.lean # Dedekind domain transfer via ring equivalences
│ ├── Euclidean/
│ │ └── Basic.lean # Norm-Euclidean classification framework
│ ├── Examples/
│ │ └── ZsqrtdNeg5/
│ │ ├── Ideals.lean # Ideal factorization and primality in ℤ[√(-5)]
│ │ └── RamificationInertia.lean # Ramification indices and inertia degrees
│ └── RingOfIntegers/
│ ├── Classification.lean # Main classification theorem
│ ├── CommonInstances.lean # Fact instances for d = -1, -3, -5
│ ├── Discriminant.lean # Discriminant formula
│ ├── HalfInt.lean # Half-integer normal form (a'+b'√d)/2
│ ├── Integrality.lean # Integrality transport and normal forms
│ ├── ModFour.lean # Modulo-4 arithmetic lemmas
│ ├── Norm.lean # Norm formulas and unit criteria
│ ├── TraceNorm.lean # Trace/norm integrality preliminaries
│ ├── ZOnePlusSqrtOverTwo.lean # ℤ[(1+√d)/2] ring model
│ ├── Zsqrtd.lean # ℤ[√d] ring model and mathlib bridge
│ ├── ZsqrtdIdeals.lean # Ideal theory: membership, primality, quotients
│ └── ZsqrtdMathlibInstances.lean # Dedekind domain for mathlib's ℤ√d
├── blueprint/ # leanblueprint source files
└── home_page/ # Homepage content for docgen-action / GitHub Pages
lake exe cache get # Download mathlib cache (required, speeds up build significantly)
lake buildThis project was originally developed at ClassificationOfIntegersOfQuadraticNumberFields. It has since been restructured and expanded in this repository.