Documentation

HexGF2Mathlib.Basic

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
    Instances For

      The i-th coefficient of toFpPoly p is the ZMod64 2 lift of the packed bit p.coeff i.

      @[simp]

      Unpacking the packed zero gives the generic zero.

      @[simp]

      Repacking the generic zero gives the packed zero.

      @[simp]

      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.

      @[simp]

      Unpacking then repacking recovers the packed polynomial: ofFpPoly is a left inverse of toFpPoly.

      @[simp]

      Repacking then unpacking recovers the generic polynomial. The generic side is degree-normalized, so no trailing zero coefficients are introduced.

      @[simp]

      Unpacking is additive: packed XOR addition becomes generic coefficientwise addition. Half of the RingEquiv obligation for equiv.

      @[simp]

      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
        @[simp]

        The forward direction of equiv is toFpPoly.

        @[simp]

        The inverse direction of equiv is ofFpPoly.

        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.

        Equations
        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
          Instances For
            theorem HexGF2Mathlib.GF2Poly.coeff_ofNatBelowDegree_of_lt (degree n j : ) (hj : j < degree) :
            (ofNatBelowDegree degree n).coeff j = n.testBit j

            Below the degree bound, ofNatBelowDegree reproduces the binary digits of its input: the characterising lemma for the decoding direction.

            theorem HexGF2Mathlib.GF2Poly.coeff_ofNatBelowDegree_eq_false_of_bound {degree n j : } (hn : n < 2 ^ degree) (hj : degree j) :

            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.

            theorem HexGF2Mathlib.GF2Poly.toNat_lt_of_degree_lt {p : Hex.GF2Poly} {degree : } (h : p.IsZero p.natDegree < degree) :
            toNat p < 2 ^ degree

            A polynomial known to have degree < degree has an index below 2 ^ degree under the packed binary interpretation.

            theorem HexGF2Mathlib.GF2Poly.ofNatBelowDegree_reduced (degree : ) (i : Fin (2 ^ degree)) :
            (ofNatBelowDegree degree i).IsZero (ofNatBelowDegree degree i).natDegree < degree

            Decoding a bounded index as low binary bits produces a reduced packed representative for that degree bound.

            theorem HexGF2Mathlib.GF2Poly.toNat_ofNatBelowDegree (degree : ) (i : Fin (2 ^ degree)) :
            toNat (ofNatBelowDegree degree i) = i

            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.

              @[simp]

              The inverse direction unpacks a Mathlib polynomial back to packed words.

              @[simp]

              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.