Documentation

HexBerlekampZassenhaus.PrimeSelection

The integer polynomial X.

Equations
Instances For

    Data from extracting the largest visible power of X from a dense integer polynomial.

    • power : Nat

      The largest exponent of X dividing the input.

    • core : ZPoly

      The quotient after removing that power of X.

    Instances For

      Remove the initial zero-coefficient run from a dense integer polynomial.

      Dense coefficients are stored in ascending degree order, so the initial zero run is exactly the executable power of X dividing the polynomial.

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

        The integer leading coefficient reduced to the candidate prime field.

        Equations
        Instances For

          The candidate prime does not divide the integer leading coefficient.

          Equations
          Instances For
            def Hex.gcdIsUnit {R : Type u} [Zero R] [DecidableEq R] (g : DensePoly R) :

            Executable test that a field-polynomial gcd is a unit.

            DensePoly.gcd is the raw Euclidean representative, so over a field it may be any nonzero constant associate of 1. In normalized dense representation, nonzero constants are exactly the polynomials with one stored coefficient.

            Equations
            Instances For

              The modular image is square-free according to the executable gcd-unit criterion.

              Equations
              Instances For

                Executable good-prime predicate for the Berlekamp-Zassenhaus computation.

                It checks that the modulus is at least 3, that the integer leading coefficient survives reduction modulo p, and that the modular image is square-free.

                Equations
                Instances For

                  Compiled good-prime predicate using the inverse-cached finite-field GCD.

                  Equations
                  Instances For
                    @[csimp]

                    Proof-backed compiled implementation of good-prime testing that computes one leading-coefficient inverse per polynomial remainder pass.

                    Assemble the executable good-prime result from its three mathematical components.

                    The ZMod64.Bounds instance witness for p = 3.

                    @[reducible, inline]

                    The Berlekamp--Zassenhaus hot path uses the shared bundled prime supplied by hex-mod-arith; it carries both the runtime modulus and its dependent bounds and primality evidence.

                    Equations
                    Instances For
                      def Hex.tableCandidates (lo hi : Nat) (hhi : hi 2 ^ 31) :

                      The committed table primes in [lo, hi), bundled with the bounds and primality evidence required by ZMod64.

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

                        A scored admissible small-prime candidate for default prime selection.

                        • p : Nat

                          Candidate prime.

                        • factorCount : Nat

                          Smaller scores are preferred; equal scores retain the earlier smaller prime.

                        Instances For

                          The default small-prime prefix, represented by the committed table window [3, 72).

                          Equations
                          Instances For

                            The remaining hot-path primes, represented by the committed table window [72, 501).

                            Equations
                            Instances For

                              The direct planner's prime candidate list: the deterministic small-prime prefix followed by every prime up to 499.

                              Equations
                              Instances For

                                Product of the fixed hot-path candidate primes.

                                Equations
                                Instances For

                                  The fixed hot-path list contains no repeated prime values.

                                  Soundness of the hot-path prime candidate list: every entry carries a prime in the closed range [3, 500]. The primality conjunct is the structure field; the bounds come from the two table windows.

                                  theorem Hex.exists_mem_hotPathCandidates_of_prime {p : Nat} (hprime : Nat.Prime p) (hge : 3 p) (hle : p 500) :

                                  Coverage of the hot-path prime candidate list: every prime p with 3 ≤ p ≤ 500 appears as the .m field of some candidate, by completeness of the committed table.

                                  Coerce an admissible nonzero modular image to its monic representative by dividing by its leading coefficient. monicModularImage f = scale c⁻¹ f where c = leadingCoeff f; the zero image maps to zero so the operation is total.

                                  Equations
                                  Instances For

                                    Normalizing a nonzero polynomial over a prime field produces a monic polynomial.

                                    A nonzero FpPoly p translates to isZero = false.

                                    monicModularImage of a nonzero polynomial is nonzero (it's a unit scalar of the original).

                                    monicModularImage is the identity on monic polynomials: dividing by a leading coefficient of 1 is a no-op.

                                    Multiplicativity of monicModularImage on nonzero polynomials. The leading coefficient of a product is the product of leading coefficients (no-zero-divisors over a prime field), so dividing both sides by their leading coefficients agrees with dividing the product by its leading coefficient.

                                    monicModularImage is multiplicative across Hex.Berlekamp.factorProduct on lists of nonzero factors: pulling each factor through monicModularImage before taking the product agrees with applying monicModularImage to the raw product. Inductive consequence of monicModularImage_mul_of_nonzero plus monicModularImage_eq_self_of_monic at the base case factorProduct [] = 1.

                                    Return the sorted degrees of the Berlekamp factors of f mod p at an explicit small prime supported by the executable prime-selection list.

                                    This testing-facing surface deliberately reuses the production small-prime computation. For complete linear splits, it records the explicit root-degree evidence directly so pinned conformance checks are not sensitive to the current Berlekamp witness splitting surface. It returns none if p is unsupported or the leading coefficient vanishes modulo p; the Berlekamp branch also requires the usual good-prime predicate.

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

                                      Scan the fixed hot-path prime list and return the best admissible scored candidate, if any.

                                      Equations
                                      Instances For

                                        Choose a small admissible prime for the Berlekamp-Zassenhaus computation.

                                        The search is bounded to a fixed ascending list of small primes. Candidate scores use the currently available executable modular factor surface; strict score improvement replaces the incumbent, so equal scores keep the smaller earlier prime.

                                        Instances For
                                          theorem Hex.choosePrimeScore?_isGoodPrime (f : ZPoly) (score : PrimeCandidateScore) (hscore : choosePrimeScore? f = some score) :
                                          (hbounds : ZMod64.Bounds score.p), isGoodPrime f score.p = true

                                          Any score the hot-path walk returns records a prime that passes the good-prime check for f.

                                          When choosePrime returns the winning score's prime, that prime passes the good-prime check for f.

                                          theorem Hex.isGoodPrime_ge_three (f : ZPoly) (p : Nat) [ZMod64.Bounds p] (hgood : isGoodPrime f p = true) :
                                          3 p

                                          A successful good-prime check certifies the modulus is at least three.

                                          A successful good-prime check certifies leading-coefficient admissibility.

                                          A successful good-prime check certifies the modular square-free precondition.

                                          A successful good-prime check rules out a vanishing modular image: the leading coefficient survives reduction modulo p, so the modular image retains at least one stored coefficient.

                                          leadingCoeffAdmissible forces the source polynomial to have at least one stored coefficient: the empty coefficient array would force leadingCoeffModP to vanish.

                                          Under leadingCoeffAdmissible, the modular image is nonzero. Companion of isGoodPrime_modP_isZero_false but with the weaker admissibility hypothesis (no square-free or 3 ≤ p requirement).

                                          Under leadingCoeffAdmissible, the modular image has the same size as the input: the top coefficient survives reduction, so the trailing-zero trim does nothing.

                                          Under leadingCoeffAdmissible, the modular image has the same degree? as the input.