Documentation

HexBerlekampZassenhaus.FactorizationData

Data produced by modular prime selection: the selected prime, the image of the input polynomial over that prime field, and its modular factors.

  • p : Nat

    The selected prime modulus.

  • bounds : ZMod64.Bounds self.p

    Word-arithmetic bounds witness for p, available for instance search.

  • fModP : FpPoly self.p

    The input polynomial reduced modulo p.

  • factorsModP : Array (FpPoly self.p)

    Its monic irreducible factors over the prime field.

Instances For
    @[instance_reducible]
    Equations
    structure Hex.LiftData :

    Data produced by Hensel lifting and consumed by integer recombination: the prime, the requested lift precision, and the lifted integer factors.

    • p : Nat

      The prime underlying the Hensel modulus.

    • p_pos : 0 < self.p

      Positivity of the prime, retained for arithmetic bounds.

    • k : Nat

      The exponent in the lifting modulus p ^ k.

    • liftedFactors : Array ZPoly

      The modular factors lifted to integer polynomials modulo p ^ k.

    Instances For

      Executable normalization data for the public integer factorization API.

      The public input is first split into its integer content, primitive part, initial X power, and primitive square-free part. The Berlekamp-Zassenhaus prime/lift/factorization computation runs on squareFreeCore; the other fields are reassembled around the resulting factors of the square-free part.

      • content : Int

        The signed-independent integer content of the input.

      • primitive : ZPoly

        The content-free input with normalized sign.

      • xPower : Nat

        The largest exponent of X dividing the primitive input.

      • xFreePrimitive : ZPoly

        The primitive input after removing its initial power of X.

      • squareFreeCore : ZPoly

        The primitive product of the distinct nonzero irreducible factors.

      • repeatedPart : ZPoly

        The primitive repeated-factor contribution.

      Instances For

        Executable data for the integer scaling transform that sends a primitive polynomial with positive leading coefficient to a monic integer polynomial with the same roots (scaled by the leading coefficient).

        If core has degree n and leading coefficient c, monic is the coefficientwise integer polynomial c^(n-1) * core (X / c): lower coefficient a_i becomes a_i * c^(n-1-i) and the leading coefficient is normalised to 1.

        • core : ZPoly

          The primitive positive-leading polynomial being transformed.

        • leadingCoeff : Int

          The leading coefficient of core.

        • degree : Nat

          The degree of core.

        • monic : ZPoly

          The integral monic polynomial obtained by the scaling transform.

        Instances For

          Coefficients of the degree-dependent transformed polynomial.

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

            The degree-dependent transform used for repeated-factor recovery.

            Equations
            Instances For
              @[simp]
              theorem Hex.ZPoly.ToMonicData.transformedCoeffs_size (core : ZPoly) (degree : Nat) :
              (transformedCoeffs core degree).size = degree + 1

              The transformed coefficient array has one entry per degree up to and including the prescribed top degree.

              theorem Hex.ZPoly.ToMonicData.transformedCoeffs_getD_top (core : ZPoly) (degree : Nat) :
              (transformedCoeffs core degree).getD degree 0 = 1

              The transformed coefficient array's top entry is one. Not @[simp]: the getD left-hand side is not simp-normal (simp rewrites it to a getElem access through transformedCoeffs_size); transformedCore_coeff_top applies it explicitly.

              @[simp]
              theorem Hex.ZPoly.ToMonicData.transformedCore_size (core : ZPoly) (degree : Nat) :
              DensePoly.size (transformedCore core degree) = degree + 1

              The transformed polynomial stores degree + 1 coefficients.

              The coefficient in the prescribed top degree of the transformed polynomial is one.

              The transformed polynomial is monic in the prescribed degree.

              @[simp]

              The transformed polynomial's degree is the prescribed degree.

              Build the ToMonicData packet for a square-free part by the integer scaling transform.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[simp]
                theorem Hex.ZPoly.toMonic_core (core : ZPoly) :
                core.toMonic.core = core

                The packet records its source polynomial unchanged.

                @[simp]

                The packet records the source's leading coefficient.

                @[simp]

                The packet records the source's degree.

                The polynomial stored by toMonic is monic, including the degenerate constant branches.

                The monic field of toMonic core is monic once the source has positive degree.

                The monic field preserves the recorded degree in nonconstant cases.

                Applying toMonic to an already-monic polynomial leaves its monic field equal to the original.

                Public factorization result for an integer polynomial Hex.ZPoly.

                The scalar carries the input's signed content: for nonzero inputs this is sign(lc f) * ZPoly.content f, while zero inputs use scalar 0. Polynomial factors are primitive, positive-leading-coefficient factors stored with explicit multiplicities; factor order remains operational, with the mathematical contract expressed by multiplying the scalar and stored factors.

                • scalar : Int

                  Signed scalar absorbing both sign and integer content.

                • factors : Array (ZPoly × Nat)

                  Polynomial factors paired with explicit positive multiplicities.

                Instances For
                  Equations
                  Instances For

                    Natural powers of an integer polynomial.

                    Equations
                    Instances For

                      Public wrapper for the polynomial power used by Factorization.product.

                      Equations
                      Instances For
                        @[simp]

                        The zeroth factor power is one.

                        @[simp]

                        Each successive factor power multiplies by the factor once more.

                        Expand multiplicity pairs into the ordered polynomial product.

                        Equations
                        Instances For
                          @[simp]
                          theorem Hex.Factorization.product_mk_empty (scalar : Int) :
                          { scalar := scalar, factors := #[] }.product = DensePoly.C scalar

                          A factorization with no polynomial factors multiplies to its scalar.

                          Characterize product using the public factorPower wrapper instead of the private recursion used internally.

                          Compute the normalization data required before the square-free computation.

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

                            Compute an integer polynomial's content and primitive part together. The logical surface is the ordinary pair of operations.

                            Equations
                            Instances For

                              One-pass runtime implementation of ZPoly.contentPrimitive: compute the coefficient gcd once, then reuse it for both the content and coefficient division.

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

                                Pointwise agreement between the specification contentPrimitive and its single-pass compiled implementation.

                                @[csimp]

                                @[csimp] bridge routing compiled contentPrimitive calls to the single-pass implementation.

                                Certified trial prime for the modular square-free fast path. 499 is a cheap fixed choice: it is large enough that a distinct-root input rarely reduces non-square-free at it, but it carries no guarantee (a rationally square-free input whose discriminant is divisible by 499 reduces non-square-free and simply takes the exact fallback -- never a wrong answer).

                                The trial prime 499 fits the word-arithmetic bounds of ZMod64.

                                The prepared-input form of the modular square-free trial.

                                Equations
                                Instances For

                                  Fast implementation of normalizeForFactor: a machine-word 𝔽_p square-freeness trial on the primitive x-free square-free part. When it fires (the input is square-free over ) the decomposition is trivial; otherwise it falls back to the exact rational computation, inlined rather than a self-call so the @[csimp] rewrite below does not make the fallback recurse. Proven equal to normalizeForFactor.

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

                                    @[csimp] bridge routing compiled normalization through the modular square-free fast path; the guard's soundness lemma makes both sides agree.

                                    The factor X with the requested multiplicity, omitted at multiplicity zero.

                                    Equations
                                    Instances For

                                      The repeated part as a singleton factor array, omitting the unit polynomial.

                                      Equations
                                      Instances For

                                        The signed content carried by the scalar part of a factorization.

                                        Equations
                                        Instances For

                                          Normalize a polynomial factor's sign by negating it whenever the leading coefficient is negative. The result has nonnegative leading coefficient and is associated to the input over .

                                          Equations
                                          Instances For

                                            A polynomial factor is recorded by the factorization routines only when it is not zero and not a unit (±1). Exposed publicly so that Mathlib-side lemmas can transport the predicate into ¬ IsUnit over Polynomial.

                                            Equations
                                            Instances For

                                              Increase the multiplicity of f, or append it with multiplicity one.

                                              Equations
                                              Instances For

                                                Collect equal factors and their multiplicities in first-occurrence order.

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

                                                  Factors that come from normalization before the primitive square-free part is factored.

                                                  Equations
                                                  Instances For

                                                    Reassemble normalization factors around the factors of the primitive square-free part.

                                                    Equations
                                                    Instances For
                                                      def Hex.exactQuotient? (target candidate : ZPoly) :

                                                      Exact-division check on integer polynomials: returns the quotient when quot * candidate = target exactly, and rejects unit candidates so iterated calls cannot loop forever on ±1.

                                                      Equations
                                                      Instances For
                                                        theorem Hex.exactQuotient?_product {target candidate quotient : ZPoly} (hquot : exactQuotient? target candidate = some quotient) :
                                                        quotient * candidate = target

                                                        Successful exact-division extracts a multiplication witness: exactQuotient? target candidate = some quotient implies quotient * candidate = target. Forward companion of exactQuotient?_eq_some_of_mul_eq_monic_of_pos_degree.

                                                        def Hex.consumeExactPower (target candidate : ZPoly) :

                                                        Greedy peel of candidate^? out of target via repeated exact division. Returns (residual, multiplicity) with the invariant candidate ^ multiplicity * residual = target. The recursion is bounded by fuel, which the caller chooses based on the source degree.

                                                        Equations
                                                        Instances For

                                                          Fold consumeExactPower over a list of candidate factors, accumulating emitted copies and tracking the residual that has not yet been factored. Invariant: polyProduct emitted * residual = initialRepeatedPart.

                                                          Equations
                                                          Instances For

                                                            Compute (emitted, residual) where each candidate factor q from coreFactors appears in emitted to the maximum multiplicity such that q^k exactly divides the running repeated-part. The fuel is the source size, which dominates any irreducible's multiplicity in repeatedPart.

                                                            Equations
                                                            Instances For