Documentation

HexBerlekampZassenhaus.Classical.CombinationIterator

theorem Hex.subsetsOfSizeWithComplement_mem {α : Type} (l : List α) (d : Nat) (sc : List α × List α) :
sc subsetsOfSizeWithComplement l d(∀ (x : α), x sc.fstx l) ∀ (x : α), x sc.sndx l

Every selected and rejected entry emitted by the extensional combination specification comes from its input list.

structure Hex.DirectSplit (basis : LiftData) :

A dividing candidate and the exact unused support complement.

Instances For
    inductive Hex.DirectLevelResult (basis : LiftData) :

    Result of streaming one complete subset-cardinality level.

    Instances For

      Lifted polynomials selected by an indexed support list.

      Equations
      Instances For
        def Hex.directSelectedDegree (basis : LiftData) (selected : List (DirectLiftedIndex basis)) :

        Cached degree statistic evaluated before candidate construction.

        Equations
        Instances For
          def Hex.directSelectedTrail (basis : LiftData) (selected : List (DirectLiftedIndex basis)) :

          Cached trailing-coefficient residue evaluated before candidate construction.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            def Hex.tryDirectSplit (coreLc : Int) (target : ZPoly) (basis : LiftData) (selected : List (DirectLiftedIndex basis)) :

            Evaluate one indexed direct split after its cheap cached statistics.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              structure Hex.LiftSupport (basis : LiftData) :

              The traversal data of one lifted basis.

              Nothing here mentions a target: the lift modulus and the lifted factors are what a Hensel lift produced, so one of these is reusable for as long as the basis is, across every residual polynomial searched against it. The proposal traversal takes that reuse (peelDirect prepares one per peel run); the head-forced traversal still prepares one per cardinality level.

              The lift modulus is basis.p ^ basis.k, which at recovery precision is wide enough to need several limbs, and rebuilding it at every traversal step is the dominant cost of a support that no candidate test ever sees. It is recorded prepared, in every representation the traversal reduces against: the residue update multiplies modulo its integer form and the trailing filter compares against its halfway threshold, so neither derives anything from the modulus at a leaf. The proof fields pin the arrays to the lifted factors elementwise and to their length, so a traversal reading this is interchangeable with one reading the factors directly.

              Instances For
                def Hex.LiftSupport.degree {basis : LiftData} (lift : LiftSupport basis) (i : DirectLiftedIndex basis) :

                The recorded degree of a lifted factor.

                Equations
                Instances For
                  def Hex.LiftSupport.trail {basis : LiftData} (lift : LiftSupport basis) (i : DirectLiftedIndex basis) :

                  The recorded trailing coefficient of a lifted factor.

                  Equations
                  Instances For
                    @[simp]

                    A recorded degree is the degree of the lifted factor it indexes.

                    @[simp]
                    theorem Hex.LiftSupport.trail_spec {basis : LiftData} (lift : LiftSupport basis) (i : DirectLiftedIndex basis) :

                    A recorded trailing coefficient is the constant term of the lifted factor it indexes.

                    @[simp]

                    The recorded modulus is the prepared lift modulus.

                    theorem Hex.LiftSupport.modulusNat_spec {basis : LiftData} (lift : LiftSupport basis) :

                    The recorded modulus records the lift modulus. Not @[simp]: simp already closes this via modulus_spec and LiftModulus.nat_ofNat.

                    theorem Hex.LiftSupport.modulusInt_spec {basis : LiftData} (lift : LiftSupport basis) :
                    lift.modulus.int = (liftModulus basis)

                    The recorded integer modulus is the lift modulus. Not @[simp]: simp already closes this via modulus_spec and LiftModulus.int_ofNat.

                    def Hex.liftSupport (basis : LiftData) :

                    Compute the traversal data of a lifted basis.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def Hex.directLeaf (coreLc : Int) (target : ZPoly) (cached : TargetImage target) (basis : LiftData) (modulus : LiftModulus) (head : DirectLiftedIndex basis) (xs selectedRev rejectedRev : List (DirectLiftedIndex basis)) (selectedDegree : Nat) (selectedTrail : Int) :

                      Evaluate one traversal leaf.

                      The degree and trailing-coefficient filters read only the incrementally maintained statistics, so a support they reject never reverses the selected indices, never maps them to lifted polynomials, and never builds a candidate. The complementary support is concatenated only after an exact divisor is found. The prefilter runs once: a surviving leaf continues with directCandidateAfterPrefilter rather than re-entering tryDirectCandidate.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        theorem Hex.directLeaf_eq (coreLc : Int) (target : ZPoly) (cached : TargetImage target) (basis : LiftData) (modulus : LiftModulus) (head : DirectLiftedIndex basis) (xs selectedRev rejectedRev : List (DirectLiftedIndex basis)) (selectedDegree : Nat) (selectedTrail : Int) :
                        directLeaf coreLc target cached basis modulus head xs selectedRev rejectedRev selectedDegree selectedTrail = match tryDirectCandidate coreLc target modulus (directSelectedFactors basis (head :: selectedRev.reverse)) selectedDegree selectedTrail with | some (candidate, quotient) => DirectLevelResult.found { selected := head :: selectedRev.reverse, remaining := rejectedRev.reverse ++ xs, candidate := candidate, quotient := quotient } 1 | none => DirectLevelResult.exhausted 1

                        The guarded leaf agrees with evaluating the candidate test directly. The prefilter is tryDirectCandidate's own first step, so guarding on it changes only when the arguments are built, and every field of the result -- including the tried count -- is unchanged.

                        def Hex.scanDirectCombinations (coreLc : Int) (target : ZPoly) (basis : LiftData) (lift : LiftSupport basis) (image : TargetImage target) (head : DirectLiftedIndex basis) (xs : List (DirectLiftedIndex basis)) (choose : Nat) (selectedRev rejectedRev : List (DirectLiftedIndex basis)) (selectedDegree : Nat) (selectedTrail : Int) :

                        Stream the choose-element subsets of xs. selectedRev and rejectedRev are prefixes already decided by the caller. Inclusion is visited before exclusion, matching the ordinary lexicographic combination order.

                        Equations
                        Instances For
                          def Hex.scanDirectLevel (coreLc : Int) (target : ZPoly) (basis : LiftData) (head : DirectLiftedIndex basis) (tail : List (DirectLiftedIndex basis)) (tailCard : Nat) :

                          Stream one head-forced level.

                          Both prepared objects are built here, so a head search that runs several cardinalities rebuilds the whole lift support -- modulus, degree array and trail array -- and reduces the target again at each one. That is where the mixed object left them; giving them the lifetimes their dependencies describe, as the proposal traversal now has, means threading them through findDirectHead and searchDirectAux, which the classical completeness and correctness proofs quantify over.

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

                            Stage counters for the unforced low-cardinality candidate sweep.

                            • leaves : Nat

                              Combinatorial leaves visited.

                            • degreeSurvivors : Nat

                              Leaves surviving the cached degree bound.

                            • trailingSurvivors : Nat

                              Leaves also surviving the trailing-coefficient divisibility test.

                            • constructed : Nat

                              Integer candidate polynomials constructed.

                            • recordable : Nat

                              Constructed candidates passing the nonunit recording filter.

                            • exactDivisions : Nat

                              Candidates sent to exact polynomial division.

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

                                Add candidate-stage counters componentwise.

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

                                  Result of one instrumented unforced subset-cardinality level.

                                  Instances For
                                    def Hex.scanDirectSubsets (coreLc : Int) (target : ZPoly) (basis : LiftData) (lift : LiftSupport basis) (image : TargetImage target) (xs : List (DirectLiftedIndex basis)) (choose : Nat) (selectedRev rejectedRev : List (DirectLiftedIndex basis)) (selectedDegree : Nat) (selectedTrail : Int) :

                                    Stream the choose-element subsets of the complete lifted support.

                                    Unlike scanDirectCombinations, no distinguished factor is forced into every candidate. This is the low-cardinality iterator: it visits each subset once, retains the exact complementary support, and never materializes the family of subsets.

                                    Equations
                                    Instances For
                                      def Hex.scanDirectSubsetLevel (coreLc : Int) (target : ZPoly) (basis : LiftData) (lift : LiftSupport basis) (image : TargetImage target) (support : List (DirectLiftedIndex basis)) (cardinality : Nat) :

                                      Stream one unforced subset-cardinality level.

                                      Both prepared objects are supplied by the caller: the lift data is constant for the peel run, and the target image belongs to the residual whose cardinality schedule this level is one step of.

                                      Equations
                                      Instances For