The degree of a polynomial, defaulting to 0 for the zero polynomial.
Equations
Instances For
Constant polynomials have FpPoly.degree equal to 0.
Canonical remainder reduction modulo f, using the existing division surface.
Equations
- Hex.GFqRing.reduceMod f g = (Hex.DensePoly.divMod g f).snd
Instances For
A polynomial of degree strictly below the modulus is already its own canonical representative.
The zero polynomial is already canonical modulo any nonconstant modulus.
The one polynomial is already canonical modulo any nonconstant modulus.
Polynomials already known to be canonical representatives modulo f.
Equations
- Hex.GFqRing.IsReduced f g = ∃ (h : Hex.FpPoly p), g = Hex.GFqRing.reduceMod f h
Instances For
Executable quotient elements, carrying the reducedness invariant in the type.
A value of this type is a polynomial together with a proof that it lies in the
image of reduceMod f, so a raw FpPoly p cannot be supplied where one of these
is expected.
The modulus is required to be prime, which guarantees the representative is
canonical for every nonconstant f: reduceMod is a genuine remainder only
when the leading coefficient it divides by is a unit, and over a prime modulus
every nonzero coefficient is. Drop the hypothesis and canonicality can fail. At
p = 4 with f = 2X the division step subtracts zero and leaves the remainder
untouched, so f and 0 are congruent yet both reduced and distinct.
isReduced_iff_degree_lt states the contract this hypothesis buys.
Primality is sufficient, not necessary: a monic f needs no coefficient
inversion and would be canonical over any modulus. The uniform prime hypothesis
is the deliberate choice here, since every modulus this library serves is over a
prime field anyway.
reduceMod itself, and its degree-short-circuit lemmas above, stay general; it
is the quotient type that is restricted, because that is what carries the
canonicality claim.
Equations
- Hex.GFqRing.PolyQuotient f _hf = { g : Hex.FpPoly p // Hex.GFqRing.IsReduced f g }
Instances For
Inject a polynomial into the quotient by reducing it modulo f.
Equations
- Hex.GFqRing.ofPoly f hf g = ⟨Hex.GFqRing.reduceMod f g, ⋯⟩
Instances For
Project a quotient element to its canonical polynomial representative.
Equations
- Hex.GFqRing.repr x = x.val
Instances For
Quotient elements have decidable equality by comparing their canonical representatives.
The canonical representative of ofPoly f hf g is reduceMod f g.
Two quotient elements are equal whenever their canonical representatives agree.
A quotient element equals the canonical zero iff its representative reduces to zero.
A quotient element differs from the canonical zero iff its representative reduces nonzero.
Canonical representatives have degree strictly below the modulus.
Reducedness is exactly a degree bound, so the representative a
PolyQuotient stores is the unique one of its residue class.
This is the theorem behind the "equality is equality of canonical
representatives" contract, and it is where primality is load-bearing. The
forward direction is the one that needs it: a reduced polynomial is only known
to sit below the modulus because the remainder-degree law holds over a field,
and that law is what fails when the leading coefficient of f is not a unit.
The converse is reduceMod_eq_self_of_degree_lt, which holds generally.
Applying reduceMod to a reduced representative is a no-op.
The modulus itself reduces to the zero representative modulo itself.
Reducing both summands before quotient reduction preserves the canonical representative.
Reducing the left summand before quotient reduction preserves the representative.
Reducing the right summand before quotient reduction preserves the representative.
Reducing both factors before quotient reduction preserves the canonical representative.
Reducing the left factor before quotient reduction preserves the representative.
Reducing the right factor before quotient reduction preserves the representative.
Adding a right multiple of the modulus does not change the canonical representative.
Reducing the argument before applying ofPoly does not change the resulting quotient
element.