Documentation

HexHensel.ModularDivision

Output of one quadratic Hensel doubling step. The four fields package the updated leading factor g (monic, the input g corrected modulo m^2), the updated complementary factor h, and the updated Bezout witnesses s, t satisfying s * g + t * h ≡ 1 (mod m^2).

  • g : ZPoly

    The updated monic factor.

  • h : ZPoly

    The updated complementary factor.

  • s : ZPoly

    The updated Bezout coefficient multiplying g.

  • t : ZPoly

    The updated Bezout coefficient multiplying h.

Instances For

    Canonical coefficient reduction modulo m^2.

    Equations
    Instances For

      Residue f - g * h corrected by the factor update of the quadratic Hensel step: starting from g * h ≡ f (mod m), this quantity is divisible by m and its lift drives the first-order correction that achieves g' * h' ≡ f (mod m^2).

      Equations
      Instances For

        Runtime implementation of factorError: the same residual with the product taken by Kronecker substitution (Hex.ZPoly.mulKronecker, value-equal to the schoolbook product by Hex.ZPoly.mulKronecker_eq). The bignum Hensel step is the only caller, and its g * h is the widest product in the lift.

        Equations
        Instances For
          @[csimp]

          Register the Kronecker product as the compiled implementation of factorError.

          The working modulus m * m = m² of one quadratic Hensel doubling step.

          Equations
          Instances For
            def Hex.ZPoly.canonicalMod (z : Int) (modulus : Nat) :

            Canonical nonnegative residue of z in the range [0, modulus).

            Equations
            Instances For

              Reduce a single coefficient to its canonical residue modulo .

              Equations
              Instances For

                Polynomial sum f + g with every coefficient reduced modulo .

                Equations
                Instances For

                  Polynomial difference f - g with every coefficient reduced modulo .

                  Equations
                  Instances For

                    Polynomial product f * g with every coefficient reduced modulo .

                    Public, unlike its sibling reductions, because its compiled implementation is swapped by a @[csimp] theorem, and csimp lemmas must be public.

                    Equations
                    Instances For

                      Runtime implementation of mulModSquare: the same reduced product with the multiplication taken by Kronecker substitution. Eight of the nine polynomial products in the bignum quadratic step go through this definition.

                      Equations
                      Instances For
                        @[csimp]

                        Register the Kronecker product as the compiled implementation of mulModSquare.

                        def Hex.ZPoly.mulMonomialModSquare (k : Nat) (coeff : Int) (q : ZPoly) (m : Nat) :

                        Modular multiplication by a single monomial. Kept as a separate specification so compiled division can avoid sending the monomial's leading zero coefficients through the generic schoolbook multiplier.

                        Equations
                        Instances For
                          def Hex.ZPoly.mulMonomialModSquareImpl (k : Nat) (coeff : Int) (q : ZPoly) (m : Nat) :

                          Linear-time implementation of modular monomial multiplication.

                          Equations
                          Instances For
                            theorem Hex.ZPoly.mulMonomialModSquare_eq (k : Nat) (coeff : Int) (q : ZPoly) (m : Nat) :

                            The shift-and-scale monomial kernel is exactly the generic modular product.

                            @[csimp]

                            Proof-backed compiled implementation of modular monomial multiplication.

                            Fuel-driven long-division kernel returning the quotient/remainder of the running rem by the monic divisor q, with all arithmetic reduced modulo . The Hensel theorem surface supplies monic divisors, so this exploits that invariant to avoid coefficient division in the modular hot path.

                            Equations
                            Instances For

                              Quotient and remainder of p divided by the monic divisor q, working modulo , with the dividend size supplying the recursion fuel.

                              Public, unlike its Aux worker, because its compiled implementation is swapped by a @[csimp] theorem, and csimp lemmas must be public.

                              Equations
                              Instances For

                                Windowed implementation of the modular monic division.

                                The windowed loop needs a monic divisor at a positive modulus -- the only shape the Hensel step ever divides by; every other input falls back to the specification loop, so the two agree on every input.

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

                                  Proof-backed compiled implementation of the modular monic division.