Non-monic converse to exactQuotient?_product for divisors with positive
leading coefficient. Drops the Monic hypothesis from
exactQuotient?_eq_some_of_mul_eq_monic_of_pos_degree in favour of
0 < leadingCoeff candidate, handling the executable division through
ZPoly.divMod_eq_mul and packaging the result with
exactQuotient?_eq_some_of_divMod_eq_of_shouldRecord. Positive degree alone
discharges shouldRecordPolynomialFactor, since 0, C 1, and C (-1) all
have natDegree = 0.
Positive and negative divisors of the constant coefficient, hence all possible integer roots.
Equations
- Hex.integerRootCandidates f = List.flatMap (fun (d : Nat) => have r := Int.ofNat d; [r, -r]) (Hex.positiveDivisors✝ (Hex.DensePoly.coeff f 0).natAbs)
Instances For
The monic polynomial X - r.
Equations
Instances For
Remove integer-root factors using bounded repeated exact division.
Equations
Instances For
Standalone integer trial-division algorithm for the slow factorization path.
First peels monic linear integer-root factors (x - r) off core via
splitIntegerRootFactorsAux, then enumerates non-unit polynomial candidates
of degrees 1..deg(afterLinear)/2 with coefficients in [-B, B], dividing
each in turn into the running residual. The returned array consists of the
linear factors, the bounded-coefficient factors that exactly divided the
residual, and the final residual (omitted when it collapses to 1).
The companion theorems exhaustiveIntegerTrialCoreFactorsWithBound_polyProduct,
exhaustiveIntegerTrialCoreFactorsWithBound_normalizeFactorSign, and
exhaustiveIntegerTrialCoreFactorsWithBound_shouldRecord record the
local executable invariants needed by the slow-path factorization
reassembly callers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Zero is already its centred representative for every modulus.
A modulus prepared for repeated centred reduction.
centeredModNat states what the centred representative is: reduce, then
subtract the modulus when the residue is past halfway. Evaluating that
statement literally derives two values at every call -- the modulus in integer
form, and the doubled residue the halfway test 2 * r.natAbs ≤ m compares
against. At recovery precision the second is a fresh multi-limb natural,
allocated and freed once per leaf. A traversal that reduces against one fixed
modulus millions of times wants neither: comparing the residue against a
recorded m / 2 decides the same test and builds nothing.
The proof fields pin both derived values to the natural one, so a reduction
reading this object is interchangeable with one reading the modulus directly;
centered_eq is that statement.
- nat : Nat
The modulus.
- int : Int
The modulus as an integer.
- half : Int
The largest residue that is its own centred representative,
nat / 2. The recorded integer modulus is the modulus.
The recorded threshold is half the modulus, rounded down.
Instances For
Prepare a natural number for repeated centred reduction.
Equations
- Hex.LiftModulus.ofNat m = { nat := m, int := ↑m, half := ↑(m / 2), int_eq := ⋯, half_eq := ⋯ }
Instances For
A prepared modulus carries no freedom beyond the modulus it records.
The centred representative of z against a prepared modulus.
z % modulus is already the least nonnegative residue, so the centred
representative is that residue, less the modulus once it is past the recorded
halfway threshold. No representation of the modulus is built here: both the
reduction and the comparison read values the modulus arrived with.
Equations
Instances For
Reducing against a prepared modulus computes the centred representative.
Centred residue modulo p^b, the mod^± operation in the BHKS cut.
Equations
- Hex.centeredResiduePow p b x = Hex.centeredModNat x (p ^ b)
Instances For
BHKS two-sided cut Psi^a_b(x) = (x_amb - (x_amb mod^± p^b)) / p^b, where
x_amb := x mod^± p^a is the centered ambient representative.
Centering at the ambient modulus p^a before taking the lower-precision cut is
required for the intended semantics: a CLD coefficient passed in as a
nonnegative p^a-residue (p^a - c) of a negative exact value -c must be
recentered to -c before applying the p^b cut. Without this step the cut
produces an oversized output for negative exact coefficients, as shown by
the f = x^2 - 5*x + 6, g = x - 2, p = 5, a = 6 counterexample to the
old uncentered formulation.
Equations
- Hex.psiCut p a b x = if p ^ b = 0 then 0 else have xCentered := Hex.centeredResiduePow p a x; (xCentered - Hex.centeredResiduePow p b xCentered) / Int.ofNat (p ^ b)
Instances For
Bignum reference for cldQuotientMod: reduce f * g' / g modulo p^a
using Int polynomial arithmetic. This is the specification the word-sized
fast path is proven byte-identical to (cldQuotientMod_eq_spec).
Equations
- Hex.cldQuotientModBignum f g p a = Hex.ZPoly.reduceModPow (Hex.DensePoly.divMod ((f * Hex.DensePoly.derivative g).reduceModPow p a) g).fst p a
Instances For
Mod-p^a representative of f * g.derivative / g, the polynomial whose
x^j coefficient is the integer CLD coefficient [x^j] Phi(g) reduced
modulo p^a.
Exposed (rather than private) so the BHKS correspondence layer can state the congruence linking the executable quotient to the exact integer CLD coefficient.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Centred high-bit CLD coefficients for one lifted local factor.
The returned array has one entry for each coefficient index
0, ..., deg(f)-1; entry j is
Psi^a_{ell_j}([x^j] (f * g.derivative / g mod p^a)).
Equations
- One or more equations did not get rendered due to their size.
Instances For
One coefficient of f * g.derivative, computed without forming the
product polynomial.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Leading coefficients of the monic quotient f * g.derivative / g
modulo p^a, in descending degree order.
Monic long division determines the quotient from high degree downward. The
recurrence therefore stops after width coefficients and avoids constructing
the unused low-degree tail.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Aggregate BHKS CLD tail entry for a selected family of lifted local factors.
Unlike cldCoeffs, this cuts once after summing the selected
cldQuotientMod coefficients. This is the shape needed by the BHKS true-factor
support column: wraparound is controlled on the aggregate residue, not on the
sum of separately cut per-factor residues.
Equations
- One or more equations did not get rendered due to their size.
Instances For
centeredModNat depends only on its argument modulo m.
centeredModNat chooses a representative congruent to the input modulo m.
The BHKS cut decomposes the centered ambient representative into a lower
centered residue plus p^b times the high-bit cut coefficient.
If y is an exact integer with |y| ≤ B, y ≡ z (mod p^a), and the ambient
modulus p^a is large enough to separate the centered residue (2*B < p^a),
then centeredResiduePow p a z = y.
If an exact integer y with |y| ≤ B is congruent to z modulo p^a, and
both the ambient modulus p^a and the lower cut modulus p^b separate B
(2*B < p^a and 2*B < p^b), then the BHKS two-sided cut psiCut p a b z
vanishes.
Absolute-value form of psiCut_eq_zero_of_natAbs_le: under the same
hypotheses, |psiCut p a b z| ≤ B. Useful when callers carry the BHKS
column bound B = bhksCoeffBound f j and just need an upper bound on the
executable cut output.
In-range coordinate of cldCoeffs: for j < deg(f), the executable
cldCoeffs array entry is exactly psiCut applied to the corresponding
quotient coefficient.
In-range CLD coefficients are the high-bit part of cldQuotientMod.
Euclidean reconstruction for the division underlying cldQuotientMod: for a
monic divisor g, the raw quotient and remainder of numerator / g recompose
numerator, where numerator = (f * g') mod p^a is the dividend cldQuotientMod
feeds to DensePoly.divMod before its own mod-p^a reduction of the quotient.
The downstream modular-congruence correspondence reduces this exact identity mod p^a.
Per-coordinate BHKS cut thresholds for the all-coefficients CLD lattice.
Equations
- Hex.bhksCutThresholds f p = (List.map (fun (j : Nat) => Hex.bhksCoeffCutThreshold p f j) (List.range (Hex.DensePoly.natDegree f))).toArray
Instances For
In-range BHKS cut thresholds are the per-coordinate bhksCoeffCutThreshold.
Executable row-basis data for the BHKS all-coefficients CLD lattice.
The basis has row and column dimension factorCount + coeffWidth. Its first
factorCount columns are indicator coordinates, and its remaining
coeffWidth columns are CLD high-bit coordinates.
- p : Nat
The prime underlying the lifted factors.
- precision : Nat
- factorCount : Nat
The number of lifted modular factors.
- coeffWidth : Nat
The number of coefficient columns used for logarithmic derivatives.
The lifted modular factors defining the logarithmic derivatives.
Per-column powers of
pdiscarded from logarithmic-derivative coefficients.The scaled logarithmic-derivative coefficient rows.
- basis : Matrix Int (self.factorCount + self.coeffWidth) (self.factorCount + self.coeffWidth)
The square integer lattice basis containing indicator and coefficient columns.
Instances For
Projected BHKS rows after LLL reduction and the Gram-Schmidt cut.
cutRadiusSq4 stores 4 * B'^2 = 4r + n*r^2, avoiding square-root or
floating-point arithmetic for the BHKS cut radius.
- factorCount : Nat
The number of lifted-factor indicator coordinates.
- coeffWidth : Nat
The number of logarithmic-derivative coefficient coordinates before projection.
- cutRadiusSq4 : Nat
Four times the squared Gram-Schmidt cut radius.
- reducedRowCount : Nat
The number of LLL-reduced rows before the Gram-Schmidt cut.
The retained rows projected to their factor-indicator coordinates.
Instances For
Build the BHKS all-coefficients CLD row-basis matrix
[ I_r | A_tilde; 0 | diag(p^(a-l_j)) ].
The diagonal exponent uses natural subtraction; callers that need the exact
BHKS hypotheses should lift to a precision a satisfying every l_j ≤ a.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Prepared leading logarithmic-derivative rows for a nested column schedule.
- degree : Nat
Degree of the residual integer polynomial.
- p : Nat
The prime underlying the lifted factors.
- precision : Nat
The exponent in the lifting modulus.
The lifted factors whose support is to be partitioned.
Leading coordinates, in descending order.
Cut thresholds corresponding to
coordinates.Truncated logarithmic-derivative rows corresponding to
coordinates.
Instances For
The leading-coordinate lattice on the first width prepared columns.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The lower-right block of the lattice basis is the diagonal of prime powers
p ^ (a - threshold) that scales each CLD coordinate to its precision.
For a positive prime the lower-right diagonal entries are positive, so the lattice basis has full rank on its scaling block.
Four times the squared BHKS cut radius, 4 * (r + n * (r / 2)^2).
Equations
- Hex.bhksCutRadiusSq4 L = 4 * L.factorCount + L.coeffWidth * L.factorCount * L.factorCount
Instances For
Test whether one Gram-Schmidt row lies within the lattice cut radius.
Equations
Instances For
View an array of rows as an n-row matrix, padding absent rows with zeros.
Equations
- Hex.bhksRowsArrayToMatrix n rows = Hex.Matrix.ofFn fun (i : Fin n) (j : Fin m) => (rows.getD (↑i) (Vector.ofFn fun (x : Fin m) => 0))[j]
Instances For
Converting a matrix row array back to a matrix recovers the original matrix.
The chosen Lovász parameter is strictly above one quarter.
Length of the BHKS Lemma 5.7 prefix cut: one past the last Gram-Schmidt
index whose squared length is within the radius (0 if none passes). Because
the fold runs in increasing index order, the accumulator ends at
(max { i : ‖b*_i‖² ≤ radius }) + 1, so retaining indices < t keeps the
contiguous prefix b_0 … b_t in original order; including earlier rows whose
own Gram-Schmidt norm exceeds the radius.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Keep the initial reduced rows selected by the cut and project their indicator coordinates.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Indices of the initial reduced rows retained by the Gram-Schmidt cut.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Project the factor-indicator coordinates of the retained reduced rows.
Equations
- Hex.bhksProjectRetainedRows L reduced indices = Array.map (fun (i : Fin (L.factorCount + L.coeffWidth)) => Hex.bhksProjectIndicator L.factorCount L.coeffWidth (reduced.row i)) indices
Instances For
Proof-facing trace for the executable BHKS projected-row construction. It
records the unchecked LLL rows, their matrix view, the Gram determinant vector
used by the cut, the retained source row indices, and the projected retained
rows. bhksProjectedRows below is the old compact projection of this trace.
- reducedRows : Array (Vector Int (L.factorCount + L.coeffWidth))
The rows returned by exact LLL reduction.
- reducedMatrix : Matrix Int (L.factorCount + L.coeffWidth) (L.factorCount + L.coeffWidth)
The same reduced rows as a square matrix.
- gramDets : Vector Nat (L.factorCount + L.coeffWidth + 1)
Determinants of the leading Gram matrices used by the exact cut.
- retainedIndices : Array (Fin (L.factorCount + L.coeffWidth))
Indices of the reduced rows below the cut radius.
Retained full rows before discarding coefficient coordinates.
Retained rows restricted to factor-indicator coordinates.
Instances For
Compute the reduced rows, cut data, and projected rows used in lattice recovery.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The trace's reduced matrix is the matrix returned by exact LLL reduction.
Run LLL on a BHKS row-basis lattice, discard rows whose Gram-Schmidt squared
length exceeds the BHKS radius, and project survivors to the first r
indicator coordinates. The squared Gram-Schmidt lengths are computed from the
integer leading Gram determinant vector as d_{i+1}/d_i.
The result is the executable L' row data consumed by the later RREF /
equivalence-class recovery stage.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The production projection agrees field-by-field with the instrumented
bhksProjectedRowsTrace run, so trace-based proofs transfer to the
production path.