Interpret the first degree coefficients of an FpPoly as a base-p
index.
This is the encoder half of the bijection between degree-< degree
polynomials and Fin (p ^ degree); ofIndexBelowDegree is its inverse on
bounded inputs (coeffIndex_ofIndexBelowDegree,
ofIndexBelowDegree_coeffIndex), and the value is always below p ^ degree
(coeffIndex_lt).
Equations
- HexGFqMathlib.FpPoly.coeffIndex degree f = List.foldl (fun (acc i : ℕ) => acc + (Hex.DensePoly.coeff f i).toNat * p ^ i) 0 (List.range degree)
Instances For
Decode a base-p index into a polynomial with at most degree
coefficients.
The decoder half of the coeffIndex bijection. Its coefficients are
characterised by coeff_ofIndexBelowDegree_of_lt (in range, a simp normal
form) and coeff_ofIndexBelowDegree_of_ge (beyond the width, zero), and its
FpPoly.degree stays below degree when the width is positive
(ofIndexBelowDegree_degree_lt).
Equations
- HexGFqMathlib.FpPoly.ofIndexBelowDegree degree index = Hex.FpPoly.ofCoeffs (List.map (fun (i : ℕ) => Hex.ZMod64.ofNat p (index / p ^ i)) (List.range degree)).toArray
Instances For
Peeling the top position of the base-p encoding.
coeffIndex is the base-p interpretation of the per-position residue
digits, exposing Mathlib's Nat.ofDigits API.
A base-p positional sum of degree residue digits stays below p ^ degree.
Reconstructing a number below p ^ degree from its fixed-width base-p
digits.
Coefficients below the width read back the encoded base-p digit.
Coefficients at or beyond the width vanish.
The width-degree decoder produces a polynomial of size at most degree,
hence degree below degree whenever the width is positive.
A polynomial's stored size is at most one more than its FpPoly.degree.
Bounded reduced polynomials encode to indices below p ^ degree.
Decoded indices are represented by polynomials with degree below the
requested bound. The positivity hypothesis is necessary: at degree = 0 the
index type Fin (p ^ 0) = Fin 1 is inhabited but the decoder returns the zero
polynomial, whose FpPoly.degree is 0.
Encoding after decoding recovers the bounded index.
Decoding after encoding recovers a polynomial already below the degree bound.
The executable finite-field wrapper carries Mathlib's Field structure
through the field laws already proved for the implementation-facing
Lean.Grind.Field hierarchy.
Equations
- One or more equations did not get rendered due to their size.
Reduced polynomial representatives for the quotient by f.
Equations
- HexGFqMathlib.FiniteField.ReducedRep f = { g : Hex.FpPoly p // g.degree < f.degree }
Instances For
The executable finite-field wrapper is equivalent to its canonical reduced polynomial representatives.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reduced representatives are indexed by Fin (p ^ degree f). The
positive-degree hypothesis is needed for the decoder's degree bound (see
FpPoly.ofIndexBelowDegree_degree_lt); it is supplied at every call site by the
nonconstant-modulus assumption.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Generic finite-field elements are equivalent to the expected finite index type.
Equations
Instances For
The generic executable finite-field wrapper is finite.
The generic executable finite-field wrapper has the expected cardinality.
Canonical Conway-backed GFq values inherit the generic finite-field
enumeration.
Cardinality of the canonical Conway-backed GFq in terms of its selected
modulus degree.
The committed Conway modulus has the requested extension degree.
The committed Conway polynomial has the requested extension degree. This is
the Conway.conwayPoly-phrased twin of modulus_degree: it is the form simp
needs once the @[simp] lemma modulus_eq_conway has normalised
GFq.modulus h to Conway.conwayPoly p n h, and together with
FiniteField.fintype_card it drives Fintype.card (GFq p n h) to p ^ n.
Cardinality of canonical GFq p n as p ^ n.
Canonical Hex.GFq and Mathlib's
GaloisField have matching cardinalities.
Canonical Hex.GFq values are ring-equivalent to Mathlib's
GaloisField with the same characteristic and
extension degree.