Explicit binary fields defined by irreducible trinomials #
For every t : ℕ, the cyclotomic polynomial Φ_{3 ^ (t + 1)}(X) over 𝔽₂ = ZMod 2 is the
explicit trinomial
Cslib.trinomial t = X ^ (2 * 3 ^ t) + X ^ (3 ^ t) + 1.
Because 2 is a primitive root modulo 3 ^ (t + 1) for every t (orderOf 2 = 2 * 3 ^ t),
Cslib.trinomial t is irreducible over ZMod 2 (Cslib.irreducible_trinomial) Lidl and
Niederreiter, Theorem 2.47.
Unlike Cslib.BinaryField w, whose modulus Cslib.leastIrreducible w is defined by an exhaustive
search over binary codes, Cslib.TrinomialField t = AdjoinRoot (trinomial t) has a closed-form
sparse modulus of degree 2 * 3 ^ t for every t : ℕ without any runtime polynomial search.
Moreover, because (X ^ (3 ^ t) + 1) * trinomial t = X ^ (3 ^ (t + 1)) + 1 over ZMod 2, any
binary polynomial of degree less than 4 * 3 ^ t (whose binary code below 2 ^ (4 * 3 ^ t) splits
into four 3 ^ t-bit limbs, with the low two limbs kept together as a 2 * 3 ^ t-bit word)
reduces modulo trinomial t in closed form using only bitwise shifts, masks, and exclusive-or
(Cslib.reduceTrinomialCode, Cslib.mk_polyOfCode_reduceTrinomialCode). Paired with carryless
multiplication Cslib.clmul (Cslib.polyOfCode_clmul), this gives loop-free arithmetic for
Cslib.TrinomialField t on unsigned machine words.
Main definitions #
Cslib.trinomial: the binary trinomialX ^ (2 * 3 ^ t) + X ^ (3 ^ t) + 1.Cslib.clmul: carryless multiplication of natural-number polynomial codes over𝔽₂.Cslib.reduceTrinomialCode: 4-limb bitwise reduction modulotrinomial ton natural-number codes below2 ^ (4 * 3 ^ t)(four3 ^ t-bit limbs).Cslib.TrinomialField: the explicit binary fieldAdjoinRoot (trinomial t)of degree2 * 3 ^ t.Cslib.TrinomialField.basis,Cslib.TrinomialField.equivBits,Cslib.TrinomialField.equivFin,Cslib.TrinomialField.embed,Cslib.TrinomialField.embedFin: power basis, coordinate equivalences withBitString (2 * 3 ^ t)andFin (2 ^ (2 * 3 ^ t)), and embeddings of bit strings and bounded natural indices.
Main results #
Cslib.trinomial_eq_cyclotomic,Cslib.monic_trinomial,Cslib.natDegree_trinomial,Cslib.irreducible_trinomial:trinomial tis the3 ^ (t + 1)-th cyclotomic polynomial overZMod 2, monic of degree2 * 3 ^ t, and irreducible.Cslib.coeff_polyOfCode,Cslib.polyOfCode_injective,Cslib.polyOfCode_xor,Cslib.polyOfCode_shiftLeft,Cslib.polyOfCode_eq_and_add_shiftRight: bit-level correspondence betweenpolyOfCodeand bitwise operations onℕ.Cslib.polyOfCode_clmul,Cslib.clmul_lt_two_pow:clmulcomputes polynomial multiplication overZMod 2and respects bit-width bounds.Cslib.reduceTrinomialCode_lt,Cslib.mk_polyOfCode_reduceTrinomialCode:reduceTrinomialCodeproduces a< 2 ^ (2 * 3 ^ t)code congruent modulotrinomial t.Cslib.TrinomialField.card,Cslib.TrinomialField.val_equivFin_add,Cslib.TrinomialField.val_equivFin_mul: cardinality and unsigned-word arithmetic laws ofTrinomialField t.
References #
The binary trinomial X ^ (2 * 3 ^ t) + X ^ (3 ^ t) + 1 of degree 2 * 3 ^ t over ZMod 2.
Instances For
trinomial t is irreducible over ZMod 2 for every t : ℕ
Lidl and Niederreiter, Theorem 2.47.
Bitwise operations, carryless multiplication, and 4-limb reduction on polyOfCode #
Unfolding polyOfCode m into its constant term m : ZMod 2 and X * polyOfCode (m / 2).
Coefficient i of polyOfCode m is bit i of m read in ZMod 2.
polyOfCode is injective: distinct natural numbers have distinct binary polynomials.
If m < 2 ^ k, then polyOfCode m has degree strictly less than k.
Bitwise exclusive-or on codes corresponds to polynomial addition over ZMod 2.
Left-shifting a code by k bits multiplies its polynomial by X ^ k.
Splitting a code at bit k into its low k bits (a &&& (2 ^ k - 1)) and high bits
(a >>> k).
Carryless multiplication by 0 on the right is 0.
Carryless multiplication by 0 on the left is 0.
8-operation loop-free 4-limb reduction modulo trinomial t:
viewing a code c < 2 ^ (4 * 3 ^ t) as four 3 ^ t-bit limbs (with the low two limbs kept
together as cLow), reduces c to a code < 2 ^ (2 * 3 ^ t) representing the same element of
AdjoinRoot (trinomial t).
Instances For
For c < 2 ^ (4 * 3 ^ t), reduceTrinomialCode t c < 2 ^ (2 * 3 ^ t).
reduceTrinomialCode t c is congruent to c modulo trinomial t for every c : ℕ.
The explicit trinomial field TrinomialField t #
The explicit binary field of degree 2 * 3 ^ t: binary polynomials modulo trinomial t.
Instances For
The modulus trinomial t is irreducible, so the quotient is a field.
TrinomialField t is a field.
TrinomialField t is finite, through its coordinates in the power basis.
Equality in TrinomialField t, decided classically.
TrinomialField t has characteristic two.
The power basis 1, α, …, α ^ (2 * 3 ^ t - 1) at the root α of trinomial t.
Instances For
The encoding by bits: the 2 * 3 ^ t coordinates in the power basis as an additive
equivalence TrinomialField t ≃+ BitString (2 * 3 ^ t).
Instances For
Bit j of an element is its coordinate j in the power basis.
TrinomialField t has 2 ^ (2 * 3 ^ t) elements.
Numbering of TrinomialField t by Fin (2 ^ (2 * 3 ^ t)) via its power-basis bits.
Instances For
For c < 2 ^ (2 * 3 ^ t), the equivFin t coordinate of
AdjoinRoot.mk (trinomial t) (polyOfCode c) is c.
The inverse of equivFin t sends m : Fin (2 ^ (2 * 3 ^ t)) to
AdjoinRoot.mk (trinomial t) (polyOfCode m.val).
Every x : TrinomialField t is the class of polyOfCode (equivFin t x).val.
Addition in TrinomialField t corresponds to bitwise exclusive-or (^^^) on equivFin t
coordinates.
Multiplication in TrinomialField t corresponds to carryless multiplication clmul followed
by 4-limb reduction reduceTrinomialCode on equivFin t coordinates.
The embedding of bit strings of length b ≤ 2 * 3 ^ t into TrinomialField t.
Instances For
The embedding of keys Fin U (U ≤ 2 ^ (2 * 3 ^ t)) into TrinomialField t.
Instances For
Applying embedFin hU to u : Fin U gives AdjoinRoot.mk (trinomial t) (polyOfCode u.val).