HexGFqField constructs the field GF(pⁿ) = Fₚ[x] / (f) for a prime p
and an irreducible degree-n modulus f of type Hex.FpPoly. It
builds on the quotient ring documented in
the HexGFqRing chapter: the field element type
Hex.GFqField.FiniteField wraps a single
Hex.GFqRing.PolyQuotient value, and every operation delegates to
quotient-ring arithmetic and re-reduces, so the canonical-representative
invariant from HexGFqRing carries over unchanged.
What the field adds over the ring is the structure that only exists when
the modulus is irreducible: multiplicative inverses (via the polynomial
extended GCD), division, integer powers, and the Frobenius endomorphism
a ↦ aᵖ. Irreducibility is a hypothesis
Hex.FpPoly.Irreducible carried in the type of every field
element, discharged in practice by a checkable Rabin certificate from
HexBerlekamp.
A field element is a quotient-ring residue together with the modulus
data and the irreducibility witness, all carried in the type. The
hypotheses hf : 0 < FpPoly.degree f and hirr : FpPoly.Irreducible f
(plus primality of p) appear as explicit arguments so that the field
structure is only available where it is justified.
The underlying reduced quotient-ring residue backing this field element.
Callers build elements through two smart constructors and read them back
through one projection. Hex.GFqField.ofQuotient wraps an existing
quotient residue, Hex.GFqField.ofPoly reduces a raw polynomial
modulo the modulus, and Hex.GFqField.repr recovers the canonical
representative, always of degree strictly below the modulus.
Project a finite-field element to its canonical polynomial representative.
The projection is canonical: representatives are always reduced below the
modulus degree, and equality of field elements is equality of their
quotient residues.
Integer literals reuse the quotient-ring cast and then rewrap the reduced
residue.
The operations that need irreducibility come next. Inversion runs the
polynomial extended GCD on the representative and the modulus, then
normalizes the Bézout coefficient by the constant unit factor of the
gcd. Irreducibility is exactly what forces that gcd to be a nonzero
constant for any nonzero element. Division is multiplication by the
inverse, and Frobenius is the p-th power map.
Field inversion stays on the quotient-reduction path by reusing the
polynomial extended-GCD witness, normalized by the gcd's constant unit factor.
The 0 case follows the usual junk-value convention required by
Lean.Grind.Field.
The Frobenius map is the p-th power map on the existing quotient
representation.
The standard typeclass instances Zero, One, Add, Mul, Neg,
Sub, Pow, Inv, and Div on Hex.GFqField.FiniteField are
backed by these operations, so ordinary field notation
(x + y, x * y, -x, x - y, x ^ n, x⁻¹, and x / y) works
over a Hex.GFqField.FiniteField.
21.3.3.1. Worked example: GF(5⁴) as F₅ modulo x⁴ + 2🔗
The example below builds the same modulus x⁴ + 2 used in the
HexGFqRing worked example, whose
reduction rule is x⁴ ≡ -2 ≡ 3 (mod 5), but now runs the field
operations: inverses, division, and Frobenius alongside the ring
operations. Irreducibility of the modulus is discharged by a Rabin
Hex.Berlekamp.IrreducibilityCertificate, whose pow chain and
Bézout witness are checked by the kernel-reducible
Hex.Berlekamp.checkIrreducibilityCertificateLinear and routed to
Hex.FpPoly.Irreducible through
Hex.Berlekamp.rabinTest_imp_irreducible.
The proof obligations that promote the wrapper from a ring to a field
are the inverse-cancellation laws. For any nonzero element, the
extended-GCD inverse is a genuine two-sided multiplicative inverse.
A nonzero field element cancels against its inverse on the left.
Division is definitionally multiplication by the inverse, and the field
is nontrivial (0 ≠ 1), which is where irreducibility (hence a
positive-degree modulus) is used.
These laws, together with the ring axioms inherited from HexGFqRing,
are bundled into a Lean.Grind.Field instance on
Hex.GFqField.FiniteField, plus a Lean.Grind.IsCharP instance
recording characteristic p. That instance is the entry point for
downstream proof automation over the executable finite field.
HexBerlekamp provides the irreducibility infrastructure. The
Hex.FpPoly.Irreducible hypothesis carried by every field
element is, in practice, produced from a checkable Rabin
Hex.Berlekamp.IrreducibilityCertificate via
Hex.Berlekamp.rabinTest_imp_irreducible, as shown in the
worked example above.
Downstream, HexConway builds Conway polynomials and canonical GF(pⁿ)
constructions on top of this field, reaching HexGFqRing
transitively through HexGFqField.
Like HexGFqRing,
HexGFqField is a purely computational library with no paired
*Mathlib correspondence: there is no HexGFqFieldMathlib, and
this chapter therefore carries no "computational vs. Mathlib
correspondence" cross-reference. The canonical mathematical home of
GF(pⁿ) is Mathlib's GaloisField / AdjoinRoot construction. A
correspondence between Hex.GFqField.FiniteField and those
structures is deferred to a downstream library if and when a
Mathlib-valued caller needs it.