Documentation

HexPolyFp.Frobenius

@[irreducible]
def Hex.FpPoly.powModMonicAux {p : Nat} [ZMod64.Bounds p] (f : FpPoly p) (hmonic : DensePoly.Monic f) :
NatFpPoly pFpPoly pFpPoly p

Exponentiation by squaring in the quotient F_p[x] / (f), reducing after every multiplication with the executable DensePoly.modByMonic routine.

Equations
Instances For
    def Hex.FpPoly.powModMonic {p : Nat} [ZMod64.Bounds p] (base f : FpPoly p) (hmonic : DensePoly.Monic f) (n : Nat) :

    Compute base^n mod f for monic f.

    Equations
    Instances For

      Modulus-size boundary for compiled fast-multiplication modular powers. Below this size the reduced operands stay in the schoolbook kernel range, so the retained loop also avoids repeated dispatcher checks.

      Equations
      Instances For
        @[irreducible]
        def Hex.FpPoly.powModMonicFastAux {p : Nat} [ZMod64.Bounds p] (f : FpPoly p) (hmonic : DensePoly.Monic f) :
        NatFpPoly pFpPoly pFpPoly p

        Compiled square-and-multiply loop using the coefficient-owner dispatcher.

        Equations
        • One or more equations did not get rendered due to their size.
        • f.powModMonicFastAux hmonic 0 x✝¹ x✝ = x✝
        Instances For
          @[inline]
          def Hex.FpPoly.powModMonicImpl {p : Nat} [ZMod64.Bounds p] (base f : FpPoly p) (hmonic : DensePoly.Monic f) (n : Nat) :

          Compiled modular-power dispatcher. Tiny moduli retain the reference loop; larger moduli use mulPackedFast while retaining ordinary monic reduction.

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

            Register the measured dispatcher as the compiled implementation.

            @[simp]
            theorem Hex.FpPoly.powModMonic_zero {p : Nat} [ZMod64.Bounds p] (base f : FpPoly p) (hmonic : DensePoly.Monic f) :
            base.powModMonic f hmonic 0 = 1

            The zeroth modular power is 1.

            def Hex.FpPoly.powModMonicLinear {p : Nat} [ZMod64.Bounds p] (base f : FpPoly p) (hmonic : DensePoly.Monic f) :
            NatFpPoly p

            Structurally recursive modular exponentiation. This is intentionally linear in the exponent: unlike powModMonic, it reduces by kernel computation on small closed terms.

            Equations
            Instances For

              Compute X^p mod f, the basic Frobenius generator used downstream.

              Equations
              Instances For

                Kernel-reducible variant of frobeniusXMod for small closed terms.

                Equations
                Instances For
                  def Hex.FpPoly.frobeniusXPowMod {p : Nat} [ZMod64.Bounds p] (f : FpPoly p) (hmonic : DensePoly.Monic f) (k : Nat) :

                  Compute X^(p^k) mod f for arbitrary k.

                  Equations
                  Instances For

                    Kernel-reducible variant of frobeniusXPowMod for small closed terms.

                    Equations
                    Instances For
                      @[simp]

                      The zeroth Frobenius power is the canonical representative of X modulo f.

                      theorem Hex.FpPoly.linearPow_mod_eq_of_mod_eq_mod {p : Nat} [ZMod64.Bounds p] (f h r : FpPoly p) (n : Nat) [ZMod64.PrimeModulus p] (hmod : h % f = r % f) :
                      h.linearPow n % f = r.linearPow n % f

                      linearPow has the same canonical remainder for bases with the same canonical remainder.

                      theorem Hex.FpPoly.powModMonic_pos_self_mod {p : Nat} [ZMod64.Bounds p] [ZMod64.PrimeModulus p] (base f : FpPoly p) (hmonic : DensePoly.Monic f) (n : Nat) (hn : 0 < n) :
                      base.powModMonic f hmonic n % f = base.powModMonic f hmonic n

                      For a positive exponent, powModMonic returns an already-reduced value.

                      @[simp]
                      theorem Hex.FpPoly.modByMonic_powModMonic_pos_eq_self {p : Nat} [ZMod64.Bounds p] [ZMod64.PrimeModulus p] (base f : FpPoly p) (hmonic : DensePoly.Monic f) (n : Nat) (hn : 0 < n) :
                      f.modByMonic (base.powModMonic f hmonic n) hmonic = base.powModMonic f hmonic n

                      The modByMonic spelling of powModMonic_pos_self_mod, useful for callers working entirely with the executable monic-reduction API.

                      theorem Hex.FpPoly.powModMonic_mod_eq_linearPow {p : Nat} [ZMod64.Bounds p] [ZMod64.PrimeModulus p] (base f : FpPoly p) (hmonic : DensePoly.Monic f) (n : Nat) :
                      base.powModMonic f hmonic n % f = base.linearPow n % f

                      powModMonic computes the same residue as linearPow.

                      theorem Hex.FpPoly.powModMonicLinear_eq_powModMonic {p : Nat} [ZMod64.Bounds p] [ZMod64.PrimeModulus p] (base f : FpPoly p) (hmonic : DensePoly.Monic f) (n : Nat) :
                      base.powModMonicLinear f hmonic n = base.powModMonic f hmonic n

                      The kernel-reducible linear exponentiation path agrees with the production square-and-multiply implementation. It is intentionally not a global simp rule: some conformance proofs unfold the linear evaluator to get kernel-reduced closed terms.

                      The kernel-reducible X^p mod f evaluator agrees with the production Frobenius generator.

                      The kernel-reducible X^(p^k) mod f evaluator agrees with the production Frobenius power routine.

                      The basic Frobenius generator is the first indexed Frobenius power.

                      @[simp]

                      frobeniusXMod outputs an already-reduced polynomial.

                      @[simp]

                      The modByMonic spelling of frobeniusXMod_mod_self.

                      theorem Hex.FpPoly.frobeniusXPowMod_succ {p : Nat} [ZMod64.Bounds p] [ZMod64.PrimeModulus p] (f : FpPoly p) (hmonic : DensePoly.Monic f) (k : Nat) :
                      f.frobeniusXPowMod hmonic (k + 1) = (f.frobeniusXPowMod hmonic k).powModMonic f hmonic p

                      Successor step for frobeniusXPowMod: raising the previous Frobenius image to the p-th power (mod f) advances the index by one.

                      frobeniusXPowMod f hmonic k reduces modulo f to the absolute monomial X^(p^k) reduced modulo f. This is the key identity relating the executable Frobenius computation to the absolute polynomial it represents.

                      @[simp]

                      frobeniusXPowMod outputs an already-reduced polynomial.

                      @[simp]

                      The modByMonic spelling of frobeniusXPowMod_mod_self.