Documentation

HexPolyFp.Packed

def Hex.ZMod64.mulWord (p : Nat) [Bounds p] (a b : UInt64) :

Overflow-safe modular product of two raw words, reconstructing residues and delegating to the (extern-backed) ZMod64.mul. Defined so that mulWord p x.val y.val = (x * y).val.

Equations
Instances For
    def Hex.ZMod64.subWord (p : Nat) [Bounds p] (a b : UInt64) :

    Overflow-safe modular difference of two raw words, reconstructing residues and delegating to ZMod64.sub. Defined so that subWord p x.val y.val = (x - y).val.

    Equations
    Instances For
      @[simp]

      The backing word of the zero residue is the zero word.

      theorem Hex.ZMod64.val_eq_zero_iff {p : Nat} [Bounds p] (x : ZMod64 p) :

      A residue's backing word is zero exactly when the residue is zero.

      theorem Hex.ZMod64.mulWord_val {p : Nat} [Bounds p] (x y : ZMod64 p) :
      mulWord p x.val y.val = (x * y).val

      The word multiply agrees with the residue product read off in words.

      theorem Hex.ZMod64.subWord_val {p : Nat} [Bounds p] (x y : ZMod64 p) :
      subWord p x.val y.val = (x - y).val

      The word subtract agrees with the residue difference read off in words.

      Pack a residue coefficient array into its backing words.

      Equations
      Instances For

        Reconstruct a residue coefficient array from raw words.

        Equations
        Instances For
          @[simp]
          theorem Hex.FpPoly.toWords_getD {p : Nat} [ZMod64.Bounds p] (a : Array (ZMod64 p)) (i : Nat) :
          (toWords a).getD i 0 = (a.getD i Zero.zero).val

          Reading a packed word with default 0 is the residue coefficient read with default 0, packed.

          theorem Hex.FpPoly.toWords_set! {p : Nat} [ZMod64.Bounds p] (a : Array (ZMod64 p)) (i : Nat) (v : ZMod64 p) :
          (toWords a).set! i v.val = toWords (a.set! i v)

          Writing a residue then packing equals packing then writing the word.

          Packing a zero-filled array gives a zero-word-filled array.

          Reconstructing the words of a residue array recovers the original array.

          Packed downward degree scan: the highest index below fuel with a nonzero word, mirroring DensePoly.arrayDegreeAux.

          Equations
          Instances For

            Packed degree: the highest index of a nonzero word, mirroring DensePoly.arrayDegree?.

            Equations
            Instances For

              One packed elimination coefficient write, mirroring DensePoly.subtractScaledShiftStep with overflow-safe word arithmetic.

              Equations
              Instances For

                One full packed elimination step rem - coeff * xˢʰⁱᶠᵗ * q, mirroring DensePoly.subtractScaledShift.

                Equations
                Instances For
                  def Hex.FpPoly.divModArrayAuxPacked (p : Nat) [ZMod64.Bounds p] (q : Array UInt64) (qDegree : Nat) (scaleLead : UInt64UInt64) (fuel : Nat) (quot rem : Array UInt64) :

                  The packed fuel-bounded long-division loop, mirroring DensePoly.divModArrayAux.

                  Equations
                  Instances For

                    Packed monic division remainder, sharing the signature of FpPoly.modByMonic (so a @[csimp] swap would be well-typed, though it is intentionally not registered; see the module docstring). Packs both operand arrays, runs the packed loop with scaleLead = id (the divisor is monic), and reconstructs the remainder.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Packed degree scan agrees with the reference scan on packed input.

                      Packed degree agrees with the reference degree on packed input.

                      theorem Hex.FpPoly.subtractScaledShiftStepPacked_eq {p : Nat} [ZMod64.Bounds p] (q : Array (ZMod64 p)) (shift : Nat) (coeff : ZMod64 p) (rem : Array (ZMod64 p)) (j : Nat) :

                      One packed elimination coefficient write corresponds to the reference write.

                      theorem Hex.FpPoly.foldl_subtractScaledShiftStepPacked {p : Nat} [ZMod64.Bounds p] (q : Array (ZMod64 p)) (shift : Nat) (coeff : ZMod64 p) (xs : List Nat) (rem : Array (ZMod64 p)) :

                      Folding the packed step over any index list corresponds to folding the reference step.

                      theorem Hex.FpPoly.subtractScaledShiftPacked_eq {p : Nat} [ZMod64.Bounds p] (rem q : Array (ZMod64 p)) (shift : Nat) (coeff : ZMod64 p) :

                      A full packed elimination step corresponds to the reference step.

                      theorem Hex.FpPoly.divModArrayAuxPacked_eq {p : Nat} [ZMod64.Bounds p] (q : Array (ZMod64 p)) (qDegree fuel : Nat) (quot rem : Array (ZMod64 p)) :
                      divModArrayAuxPacked p (toWords q) qDegree id fuel (toWords quot) (toWords rem) = (toWords (DensePoly.divModArrayAux q qDegree id fuel quot rem).fst, toWords (DensePoly.divModArrayAux q qDegree id fuel quot rem).snd)

                      The packed long-division loop corresponds, coordinatewise, to the reference loop with scaleLead = id.

                      theorem Hex.FpPoly.modByMonicPacked_eq {p : Nat} [ZMod64.Bounds p] (f g : FpPoly p) (hmonic : DensePoly.Monic f) :
                      f.modByMonic g hmonic = f.modByMonicPacked g hmonic

                      Value correspondence. The packed monic-division remainder equals the reference FpPoly.modByMonic for every modulus p (every Bounds p).