Documentation

HexBerlekampZassenhaus.Recombination

def Hex.recombinationSearch (f : ZPoly) (localFactors : List ZPoly) :

Search for an integer-factor recombination of the lifted local factors.

The search enumerates subsets containing the first remaining local factor, accepts a subset only when its product exactly divides the current target, and then recurses on the quotient and unused local factors.

Equations
Instances For
    def Hex.recombinationSearchModAux (target : ZPoly) (modulus : Nat) (localFactors : List ZPoly) :

    Fuelled auxiliary for recombinationSearchMod. Recurses through subsetSplitsWithFirst localFactors: at every level the head local factor is forced into the candidate, the centred-lift result is normalised and checked against shouldRecordPolynomialFactor, and a successful exactQuotient? divides the search down to the remaining local factors and quotient.

    Equations
    Instances For
      def Hex.recombinationSearchMod (f : ZPoly) (modulus : Nat) (localFactors : List ZPoly) :

      Exhaustive lifted-factor recombination search at a fixed modulus. Drives the slow path by iterating subsets of the lifted local factors through recombinationSearchModAux.

      Equations
      Instances For

        Exhaustive recombination of the lifted local factors stored in d, run at the Hensel modulus p^k = liftModulus d. Returns the recovered integer factors as an array on success and #[] when the search fails.

        Equations
        Instances For
          def Hex.subsetsOfSizeWithComplement {α : Type} :
          List αNatList (List α × List α)

          Size-k sublists of xs, each paired with its complement, order preserved in both components. The size-class building block of the size-ordered classical recombination search.

          Equations
          Instances For

            Initial Hensel precision used by the fast BHKS doubling schedule.

            Equations
            Instances For

              Successor precision used by the fast BHKS doubling schedule.

              Equations
              Instances For
                def Hex.ZPoly.toMonicLiftData (core : ZPoly) (B : Nat) (primeData : PrimeChoiceData) :

                Build the fixed-precision Hensel lift data for the monic transform of an square-free part. The exhaustive slow path still recombines against the original primitive polynomial, but the lift stage sees the monic polynomial required by the Hensel computation.

                Equations
                Instances For

                  Multiplicative inverse of core's leading coefficient modulo p ^ k, read off the integer Bezout certificate s · ℓf + t · p^k = gcd(ℓf, p^k). When gcd(leadingCoeff core, p ^ k) = 1 (the good-prime condition p ∤ ℓf) this is a genuine inverse: leadingCoeffInverse core p k * leadingCoeff core ≡ 1 (mod p^k) (leadingCoeffInverse_mul_emod).

                  Equations
                  Instances For
                    def Hex.ZPoly.monicTarget (core : ZPoly) (p k : Nat) :

                    BHKS leading-coefficient-faithful monic target for core: rescale core by the modular inverse of its leading coefficient, then reduce modulo p ^ k.

                    This is van Hoeij's M1 normalisation (factor out ℓf, BHKS §2: f = ℓf·f₁···fr with the fᵢ monic in Z_p), distinct from the toMonic x ↦ x/ℓf substitution (M2). Over (ℤ/p^k)[x] it equals core · ℓf⁻¹, so its monic local factors divide core directly with no dilation. It is monic over ℤ when gcd(leadingCoeff core, p ^ k) = 1 and core is nonconstant (monicTarget_monic).

                    Equations
                    Instances For
                      def Hex.ZPoly.directLiftData (core : ZPoly) (B : Nat) (primeData : PrimeChoiceData) :

                      Fixed-precision Hensel lift data over core's own coordinate (BHKS-faithful).

                      Mirrors toMonicLiftData, but lifts core's monic modular factors against the leading-coefficient-normalised monicTarget rather than the x ↦ x/ℓf dilation (toMonic core).monic. The lifted factors therefore divide core in (ℤ/p^a)[x] directly, and the CLD lattice runs over core's own coordinate.

                      Equations
                      Instances For
                        theorem Hex.ZPoly.leadingCoeffInverse_mul_emod (core : ZPoly) (p k : Nat) (hpk : 1 < p ^ k) (hgcd : (DensePoly.leadingCoeff core).gcd (Int.ofNat (p ^ k)) = 1) :

                        The leadingCoeffInverse is a genuine inverse of core's leading coefficient modulo p ^ k when the leading coefficient is coprime to p ^ k (the good-prime condition p ∤ ℓf). This is the unit-residue fact the BHKS monic target rests on.

                        Size of reduceModPow is bounded by the source size (trimming only drops trailing zeros).

                        theorem Hex.ZPoly.monicTarget_size_eq (core : ZPoly) (p k : Nat) (hpk : 1 < p ^ k) (hgcd : (DensePoly.leadingCoeff core).gcd (Int.ofNat (p ^ k)) = 1) (hcore : 0 < DensePoly.size core) :

                        The direct-coordinate monic target has exactly the input polynomial's size. Reduction cannot add coefficients, while coprimality makes its top coefficient equal to one, so reduction cannot discard the input's top degree.

                        theorem Hex.ZPoly.monicTarget_monic (core : ZPoly) (p k : Nat) (hpk : 1 < p ^ k) (hgcd : (DensePoly.leadingCoeff core).gcd (Int.ofNat (p ^ k)) = 1) (hcore : 0 < DensePoly.size core) :

                        The BHKS leading-coefficient-faithful monic target is genuinely monic over ℤ when core's leading coefficient is coprime to p ^ k and core is nonconstant.

                        This is the load-bearing soundness fact for handling the existing monic Hensel lift against monicTarget (van Hoeij M1) instead of the toMonic x ↦ x/ℓf dilation (M2): the lift's producer lemma QuadraticMultifactorLiftInvariant_of_choosePrimeData requires its target monic, and monicTarget supplies that while keeping core's own coordinate.

                        CLD column-adequacy floor for the fast recovery acceptance condition.

                        A successful BHKS recovery at schedule coefficient bound k only certifies column adequacy (the BHKS Lemma 5.7 separation hsep) once the lift precision precisionForCoeffBound k primeData.p clears the per-coordinate CLD threshold. The lattice and its CLD columns are built directly over core, so the floor is twice the largest per-coordinate bound of core itself.

                        Equations
                        Instances For

                          Acceptance floor for the fast recovery loop: the CLD column-adequacy floor cldCoeffFloor joined with the direct Mignotte recovery bound of core.

                          Equations
                          Instances For

                            The recovery floor is at least the logarithmic-derivative coefficient floor.

                            The recovery floor is at least the direct coefficient-recovery bound.

                            @[irreducible]

                            An irreducible copy of the acceptance floor used when reducing the fast loop.

                            Definitionally bhksRecoveryFloor, but marked irreducible so that whnf in downstream proofs that case-split on a bhksRecoveryCoreWithBound application does not eagerly expand the (symbolic, structurally large) floor computation while reducing the loop's head if. The loop's behavioural unfolding lemma bhksRecoveryCoreWithBound_unfold re-exposes the plain bhksRecoveryFloor comparison, so proofs reason about the genuine floor.

                            Equations
                            Instances For

                              The opaque recovery threshold equals its mathematical coefficient floor.

                              def Hex.bhksRecoveryCoreWithBound (core : ZPoly) (B : Nat) (primeData : PrimeChoiceData) (k fuel : Nat) :

                              BHKS fast recovery recombination loop. Computes the CLD column-adequacy floor once (through the irreducible bhksRecoveryThreshold, so whnf in downstream proofs that case-split on this application does not eagerly expand the symbolic floor) and runs bhksRecoveryLoop.

                              Equations
                              Instances For

                                Finite list of Hensel precisions inspected by the fast BHKS recovery loop.

                                Equations
                                Instances For

                                  The fast-path cap B is itself a member of the canonical Hensel precision schedule the executable loop walks: henselPrecisionSchedule B (initialHenselPrecision B) (quadraticDoublingSteps B + 2).

                                  This is the connective schedule lemma used by the Mathlib-facing Group D forward-recovery wrapper: callers who supply ForwardRecoveryInputs at the canonical terminal precision no longer need to re-prove the executable doubling-schedule membership obligation.

                                  theorem Hex.bhksRecoveryCoreWithBound_eq_some_of_recovery_on_schedule_of_no_prior_recovery (core : ZPoly) (B : Nat) (primeData : PrimeChoiceData) {start fuel target : Nat} {factors : Array ZPoly} (hfloor : bhksRecoveryFloor core target) (hmem : target henselPrecisionSchedule B start fuel) (hno : ∀ (k : Nat), k henselPrecisionSchedule B start fuelk targetbhksRecover? core (core.directLiftData k primeData) = none) (hrecover : bhksRecover? core (core.directLiftData target primeData) = some factors) :
                                  bhksRecoveryCoreWithBound core B primeData start fuel = some factors

                                  If a target precision is on the fast recovery schedule, recovery succeeds there, and no other scheduled precision before the target succeeds, then the first-success loop returns exactly the target recovery.

                                  This is the executable-loop determinism skeleton. The BHKS precision theorem supplies the hno premise by ruling out successful recovery below the Mignotte/cap precision.