Formally certifying number field invariants
Alain Chavarri Villarello, Sander R. Dahmen
cs.LO
Jul 28, 2026 · v1
math.NT
TL;DR
Lean 4 formalization certifies number field invariants (discriminant, signature, class group) using externally-computed certificates checked against Mathlib definitions.
Abstract
Number fields, which generalize the rational numbers, are fundamental objects in number theory. Many of their key arithmetic properties are captured by invariants whose computation is among the central tasks of computational algebraic number theory and a focus of several computer algebra systems and databases. In this paper, we describe a Lean 4 formalization for certifying several of these number field invariants. Building on previous work on certifying rings of integers, we extend this certification approach to further invariants including the signature, the unit group modulo $p$-th powers, and, ultimately, the class group. We also improve discriminant certification, allowing verifications for higher-degree number fields infeasible in previous work. We introduce structures based on representations of algebraic objects suited to computation, including reusable ones for certifying ideal arithmetic. Along the way, we formalize several underlying mathematical results, for instance on real closed fields and pseudo-remainder sequences, which are of independent interest. We apply our framework to verify hundreds of entries of the $\textit{L-functions and modular forms database}$ (LMFDB) concerning the discriminant, signature, class number, and class group structure of various number fields. To this end, we wrote a SageMath script that computes the certificates and outputs Lean proofs of the corresponding statements.
Problem
Computer algebra systems compute number field invariants (ring of integers, discriminant, signature, class group) via complex unverified code that can contain bugs. There is a need to formally certify these invariants inside a trusted proof assistant.
Approach
A certification approach is used: a SageMath script computes certificates and emits Lean proofs, which are checked in Lean 4 against Mathlib definitions. Building on prior work certifying rings of integers, the authors extend the framework to signature, unit group modulo p-th powers, and the class group, using p-saturation certificates. Underlying results including Sturm's theorem, real closed fields, and pseudo-remainder sequences are formalized, along with reusable structures for ideal arithmetic and an improved discriminant computation via resultants.
Results
The framework verifies hundreds of LMFDB entries concerning discriminant, signature, class number, and class group structure of various number fields. The improved discriminant certification enables verification of higher-degree fields infeasible in previous work.