Unpack a packed GF2Poly into the generic dense polynomial over
Hex.ZMod64 2.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Repack a generic dense polynomial over Hex.ZMod64 2 into the packed
GF2Poly representation.
Equations
- HexGF2Mathlib.GF2Poly.ofFpPoly p = Hex.GF2Poly.ofWords (Hex.Array.ofFn' fun (i : Fin ((Hex.DensePoly.size p + 63) / 64)) => HexGF2Mathlib.GF2Poly.packWord✝ p ↑i)
Instances For
The i-th coefficient of toFpPoly p is the ZMod64 2 lift of the packed
bit p.coeff i.
Unpacking the packed zero gives the generic zero.
Repacking the generic zero gives the packed zero.
Unpacking the packed unit gives the generic unit.
The j-th coefficient of the repacked polynomial records whether the
generic coefficient p.coeff j is nonzero.
Repacking then unpacking recovers the generic polynomial. The generic side is degree-normalized, so no trailing zero coefficients are introduced.
Unpacking is multiplicative: the packed carry-less product becomes the
generic convolution product. The other half of the RingEquiv obligation for
equiv, and the reason the packed representation may be used as a drop-in for
FpPoly 2 in ring-level reasoning.
The packed GF2Poly representation is ring-equivalent to the generic
degree-normalized FpPoly 2 representation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
toFpPoly preserves degree?: the high bit of a packed polynomial becomes
the leading ZMod64 2 coefficient, and everything above it vanishes.
Packed GF(2) irreducibility transports to FpPoly 2 irreducibility across
toFpPoly. Both predicates are the project-local executable defs, so the
transport runs through the conversion layer directly.
Interpret a packed polynomial as the natural number with the same binary
coefficient bits. This gives correspondence modules a finite index for
bounded-degree representatives without changing the executable HexGF2
representation.
Instances For
The binary index and the packed representation agree bit for bit: bit j of
toNat p is the coefficient of x ^ j. This is the characterising lemma for
toNat, and callers should use it rather than unfolding the word fold.
Rebuild the low degree bits of a natural number as a packed polynomial.
The input is expected to be bounded by 2 ^ degree by callers that need a
canonical finite representative.
Equations
- HexGF2Mathlib.GF2Poly.ofNatBelowDegree degree n = Hex.GF2Poly.ofWords (Array.ofFn fun (i : Fin ((degree + 63) / 64)) => UInt64.ofNat (n / 2 ^ (64 * ↑i)))
Instances For
Below the degree bound, ofNatBelowDegree reproduces the binary digits of
its input: the characterising lemma for the decoding direction.
At or above the degree bound, a decoded index has no coefficients: together
with coeff_ofNatBelowDegree_of_lt this pins down ofNatBelowDegree on every
index, and it is what makes the decoded value a reduced representative.
Decoding a bounded index as low binary bits produces a reduced packed representative for that degree bound.
Encoding after decoding a bounded packed index preserves the index.
Decoding after encoding a reduced packed representative preserves the polynomial.
The packed GF(2) polynomial representation is ring-equivalent to Mathlib
polynomials over ZMod 2.
The composition of the packed-to-generic correspondence with the generic
prime-field one, which is what makes the packed representation reachable from
Mathlib rather than only from the rest of Hex. noncomputable because
Mathlib's polynomial multiplication is; the packed side stays executable.
Equations
Instances For
The forward direction of equivPolynomial transports the packed value
through the generic representation.
Deliberately not @[simp]: coeff_equivPolynomial below is the coefficient
normal form, and a simp set containing both would rewrite past its left-hand
side and leave a toZMod applied to an if.
The inverse direction unpacks a Mathlib polynomial back to packed words.
Coefficients survive the crossing: bit i of the packed representation is
the i-th Mathlib coefficient, as 1 or 0 in ZMod 2.
This is the lemma a caller reaches for first, and the reason it is stated
rather than left to simp: unfolding through both legs leaves a toZMod
applied to an if, which needs the branchwise cast lemmas to finish.