FLINT3.7.0-dev
Algorithm

Multivariate Hensel lifting

Cost
Dense lifting of rr factors of AA with degrees d0,…,dmd_0, \ldots, d_m costs O(r∏i(di+1)2)O(r \prod_i (d_i + 1)^2) coefficient operations up to logarithmic factors in the worst case; sparse lifting is polynomial in the number of terms of the factors.

Hensel lifting is the step that turns a factorisation of a univariate (or bivariate) image of A∈Z[x0,…,xm]A \in \mathbb{Z}[x_0, \ldots, x_m] into a factorisation of AA itself. FLINT uses it in the factoring algorithms (Factorisation), in the EEZ-GCD algorithm (Hensel lifting) and, over finite fields, in the corresponding nmod_mpoly and fq_nmod_mpoly code. The setting is that of Wang [WanRot1975; Wan1978] with the notation of Schultz's notes [Sch-mpoly]; see also [GCL1992, Ch. 6] and [GG2003, §15].

Throughout, x0x_0 is the main variable, α=(α1,…,αm)\alpha = (\alpha_1, \ldots, \alpha_m) is the evaluation point for the other variables, and for a polynomial FF we write F(j)=F(x0,…,xj,αj+1,…,αm)F^{(j)} = F(x_0, \ldots, x_j, \alpha_{j+1}, \ldots, \alpha_m). Lifting proceeds from F(0)F^{(0)} to F(1)F^{(1)}, then F(2)F^{(2)}, and so on: at stage jj the factorisation A(j−1)=∏iFi(j−1)A^{(j-1)} = \prod_i F_i^{(j-1)} is lifted to A(j)=∏iFi(j)A^{(j)} = \prod_i F_i^{(j)} by computing the Taylor coefficients of the Fi(j)F_i^{(j)} in xj−αjx_j - \alpha_j one at a time.

Uniqueness#

A factorisation can only be lifted if it is determined by its image, and the leading coefficients in x0x_0 are the obstruction: if A=FGA = FG, then also A=(uF)(u−1G)A = (uF)(u^{-1}G) for any unit uu of the coefficient ring, and over Z[x1,…,xm]\mathbb{Z}[x_1, \ldots, x_m] a factor of the leading coefficient can move between FF and GG without changing the images up to scalars. The lifting therefore assumes that the leading coefficients are known (Leading coefficients explains how they are found).

Lemma 1 (Uniqueness of the lifted factors). Let DD be an integral domain, A,F1,…,Fr∈D[x0,…,xm]A, F_1, \ldots, F_r \in D[x_0, \ldots, x_m], α∈D\alpha \in D, and suppose that A=∏iFiA = \prod_i F_i, that lc⁡x0(Fi)(xm=α)≠0\operatorname{lc}_{x_0}(F_i)(x_m = \alpha) \ne 0, and that the images fi=Fi(xm=α)f_i = F_i(x_m = \alpha) are pairwise coprime in K[x0]K[x_0], where KK is the fraction field of D[x1,…,xm−1]D[x_1, \ldots, x_{m-1}]. If G1,…,GrG_1, \ldots, G_r satisfy A=∏iGiA = \prod_i G_i, Gi(xm=α)=fiG_i(x_m = \alpha) = f_i and lc⁡x0(Gi)=lc⁡x0(Fi)\operatorname{lc}_{x_0}(G_i) = \operatorname{lc}_{x_0}(F_i), then Gi=FiG_i = F_i for all ii.

Proof. Suppose not, and let k≥1k \ge 1 be the largest integer such that Gi≡Fi(mod(xm−α)k)G_i \equiv F_i \pmod{(x_m - \alpha)^k} for all ii. Write Gi=Fi+(xm−α)kHiG_i = F_i + (x_m - \alpha)^k H_i, with hi=Hi(xm=α)h_i = H_i(x_m = \alpha) not all zero. Since the leading coefficients agree, deg⁡x0hi<deg⁡x0fi\deg_{x_0} h_i < \deg_{x_0} f_i. Expanding ∏iGi−∏iFi=0\prod_i G_i - \prod_i F_i = 0 modulo (xm−α)k+1(x_m - \alpha)^{k+1} gives ∑ihi∏j≠ifj=0\sum_i h_i \prod_{j \ne i} f_j = 0. Then fif_i divides hi∏j≠ifjh_i \prod_{j \ne i} f_j, hence divides hih_i by coprimality, and hi=0h_i = 0 by the degree bound, for every ii; a contradiction.

Multivariate partial fractions#

Each lifting step needs the solution of a multivariate diophantine equation: given pairwise coprime β1,…,βr\beta_1, \ldots, \beta_r and tt, find δi\delta_i with

t=∑i=1rδi∏j≠iβj,deg⁡x0δi<deg⁡x0βi.(∗)t = \sum_{i=1}^r \delta_i \prod_{j \ne i} \beta_j, \qquad \deg_{x_0} \delta_i < \deg_{x_0} \beta_i. \tag{$\ast$}

Dividing by ∏jβj\prod_j \beta_j, this is the partial fraction decomposition t/∏jβj=∑iδi/βit / \prod_j \beta_j = \sum_i \delta_i / \beta_i.

Lemma 2 (Univariate partial fractions). Over a field KK, if β1,…,βr∈K[x0]\beta_1, \ldots, \beta_r \in K[x_0] are pairwise coprime and deg⁡t<∑ideg⁡βi\deg t < \sum_i \deg \beta_i, then (∗)(\ast) has a unique solution, given by δi=t⋅(∏j≠iβj)−1 mod βi\delta_i = t \cdot (\prod_{j \ne i} \beta_j)^{-1} \bmod \beta_i.

Proof. Reducing (∗)(\ast) modulo βi\beta_i gives δi∏j≠iβj≡t\delta_i \prod_{j \ne i} \beta_j \equiv t, and ∏j≠iβj\prod_{j \ne i} \beta_j is invertible modulo βi\beta_i; together with deg⁡δi<deg⁡βi\deg \delta_i < \deg \beta_i this determines δi\delta_i. With these δi\delta_i, the difference of the two sides of (∗)(\ast) is divisible by every βi\beta_i, hence by their product, and has smaller degree, so it is zero.

Over Z\mathbb{Z} the solution has rational coefficients in general; the lifting needs to know whether an integral solution exists. fmpz_poly_pfrac_precomp solves (∗)(\ast) modulo a power pkp^k of a prime for which the βi\beta_i stay coprime, checks the candidate by exact division, and increases kk until a bound on the solutions obtained from Cramer's rule and Hadamard's inequality (in terms of the norms of the βi\beta_i and their resultants) shows that no integral solution exists if the check still fails.

With more variables, the solution is computed variable by variable, as a dense interpolation in Taylor coefficients.

Algorithm 1: Multivariate partial fractions

Input: l≥0l \ge 0; t∈D[x0,…,xl]t \in D[x_0, \ldots, x_l]; βi(l)∈D[x0,…,xl]\beta_i^{(l)} \in D[x_0, \ldots, x_l] whose images βi(0)\beta_i^{(0)} are pairwise coprime; degree bounds d1,…,dld_1, \ldots, d_l. Output: δi\delta_i satisfying (∗)(\ast) for the βi(l)\beta_i^{(l)}, or failure.

  1. If l=0l = 0, solve with Lemma 2 (over Z\mathbb{Z}: as described above) and return.
  2. Otherwise, for k=0,1,…,dlk = 0, 1, \ldots, d_l: let t~\tilde t be the kk-th Taylor coefficient in xl−αlx_l - \alpha_l of t−∑iδi∏j≠iβj(l)t - \sum_i \delta_i \prod_{j \ne i} \beta_j^{(l)}, solve (∗)(\ast) for t~\tilde t and the βi(l−1)\beta_i^{(l-1)} recursively, giving δ~i\tilde \delta_i, and add δ~i(xl−αl)k\tilde\delta_i (x_l - \alpha_l)^k to δi\delta_i. Fail if a recursive call fails or a δi\delta_i exceeds the degree bound in xlx_l.

Theorem 3. If (∗)(\ast) has a solution with deg⁡xlδi≤dl\deg_{x_l} \delta_i \le d_l (and similarly for the other variables), Algorithm 1 returns it, and the solution is unique.

Proof. Uniqueness follows as in Lemma 1: two solutions differ by a solution of the homogeneous equation, whose lowest nonzero Taylor coefficients in xl−αlx_l - \alpha_l would solve the homogeneous equation for the βi(l−1)\beta_i^{(l-1)}, which by induction (down to Lemma 2) only has the zero solution. The Taylor coefficient of order kk of (∗)(\ast), given the coefficients of order less than kk of the δi\delta_i, is an equation of the same form for the coefficients of order kk with the βi(l−1)\beta_i^{(l-1)}, so the recursion computes the solution coefficient by coefficient.

fmpz_mpoly_pfrac implements Algorithm 1, keeping the products ∏j≠iβj(l)\prod_{j \ne i} \beta_j^{(l)} and their Taylor expansions for every level in an fmpz_mpoly_pfrac_t prepared by fmpz_mpoly_pfrac_init. When αl=0\alpha_l = 0 the Taylor coefficients are just the coefficients in xlx_l, and the expansion is replaced by a conversion to a univariate polynomial in xlx_l. Wang [Wan1978] recommends lifting modulo a power pkp^k of a prime; FLINT's dense lifting instead works with exact integer coefficients in all variables, and only the univariate base case computes modulo prime powers [Sch-mpoly].

The lifting step#

Algorithm 2: Hensel lifting in one variable

Input: A(m)A^{(m)}; factors F1,…,FrF_1, \ldots, F_r of A(m−1)A^{(m-1)} whose leading coefficients in x0x_0 have already been replaced by the correct ones in D[x1,…,xm]D[x_1, \ldots, x_m]; the degree dd of AA in xmx_m. Output: factors FiF_i with A(m)=∏iFiA^{(m)} = \prod_i F_i, or failure.

  1. Write Fi=∑kFi,k(xm−αm)kF_i = \sum_k F_{i,k} (x_m - \alpha_m)^k, with only Fi,0F_{i,0} known (apart from the leading coefficients).
  2. For k=1,…,dk = 1, \ldots, d: let tt be the kk-th Taylor coefficient of A(m)−∏iFiA^{(m)} - \prod_i F_i; solve t=∑iδi∏j≠iFj,0t = \sum_i \delta_i \prod_{j \ne i} F_{j,0} with Algorithm 1 at level m−1m - 1; add δi\delta_i to Fi,kF_{i,k}. Fail if there is no solution or if ∑ideg⁡xmFi>d\sum_i \deg_{x_m} F_i > d.

The Taylor coefficient tt only depends on the coefficients Fi,lF_{i,l} with l<kl < k, and FLINT has three ways to compute it:

  • the quintic version (_hlift_quintic, for many factors) keeps the error e=A−∏iFie = A - \prod_i F_i and recomputes it after each step, dividing by (xm−αm)k(x_m - \alpha_m)^k to extract tt; it finishes by checking e=0e = 0;
  • the quartic version (_hlift_quartic, for 3≤r<203 \le r < 20) computes t=[(xm−αm)k]A−∑k1+⋯+kr=k∏iFi,kit = [(x_m - \alpha_m)^k] A - \sum_{k_1 + \cdots + k_r = k} \prod_i F_{i,k_i} incrementally from the Taylor coefficients, using partial products F1F2F_1 F_2, F1F2F3F_1 F_2 F_3, ...;
  • _hlift_quartic2 specialises this to r=2r = 2: t=[(xm−αm)k]A−∑l=0kF1,lF2,k−lt = [(x_m - \alpha_m)^k] A - \sum_{l=0}^{k} F_{1,l} F_{2,k-l}.

The names refer to the exponent of the degree in the dense cost, as in [Sch-mpoly]. The quartic versions do not verify the final product; the callers check the factors by exact division.

Theorem 4 (Correctness of the lifting step). If A(m)A^{(m)} has a factorisation ∏iGi\prod_i G_i with Gi(m−1)=FiG_i^{(m-1)} = F_i (up to the known leading coefficients) and the conditions of Lemma 1 hold, then Algorithm 2 computes it. If it returns failure, no such factorisation exists.

Proof. By induction on kk, after step kk the FiF_i agree with the GiG_i modulo (xm−αm)k+1(x_m - \alpha_m)^{k+1}: the Taylor coefficient of order kk of A−∏iGi=0A - \prod_i G_i = 0 is an equation (∗)(\ast) for the coefficients Gi,kG_{i,k}, which by Theorem 3 has a unique solution, found by the algorithm. Since deg⁡xmGi≤d\deg_{x_m} G_i \le d, the lifting is complete after dd steps. If the factorisation does not exist, either some equation has no solution, the degrees exceed dd, or the final product differs from AA.

Bivariate lifting modulo prime powers#

For the bivariate factorisation of fmpz_bpoly_factor the factors of B(x,α)∈Z[x]B(x, \alpha) \in \mathbb{Z}[x] have no known leading coefficients. They are made monic modulo pkp^k and lifted in (Z/pkZ)[[y−α]][x](\mathbb{Z}/p^k\mathbb{Z})[[y - \alpha]][x] with the monic normalisation (_bivar_lift_quartic2, _bivar_lift_quartic and _bivar_lift_quintic in fmpz_mpoly_factor/bpoly_factor.c), to a precision in y−αy - \alpha given by the degree of BB and its leading coefficient; the true factors are then found by recombination (Dense bivariate factorisation). The prime power pkp^k is chosen above a bound on the coefficients of the factors.

Sparse Hensel lifting#

Dense lifting costs a polynomial in the dense size ∏i(di+1)\prod_i (d_i + 1), which is prohibitive for sparse polynomials in many variables. Zippel's sparse Hensel lifting [Zip1981] and Kaltofen's variant [Kal1985] assume, as in sparse interpolation, that each Taylor coefficient of a factor in the new variable xjx_j has the same support in the previous variables as the factor itself; the coefficients are then found from bivariate (in x0,x1x_0, x_1) factorisations of AA at the points xi=βikx_i = \beta_i^k (2≤i<j2 \le i < j) by solving transposed Vandermonde systems (Sparse interpolation in Hensel lifting). Monagan and Tuncer [MonTun2020] analyse the cost and the probability of failure.

FLINT's fmpz_mpoly_factor_irred_zippel reduces modulo a word-size prime pp, lifts the first two variables densely and the others with nmod_mpoly_hlift_zippel over Fp\mathbb{F}_p, and then lifts the factors from Fp\mathbb{F}_p to Z\mathbb{Z} by pp-adic Newton iteration on the same supports (the static function fmpz_mfactor_lift_prime_power_zippel). The result is verified by division.

Leading coefficients#

Before lifting, the leading coefficient ℓ=lc⁡x0(A)∈Z[x1,…,xm]\ell = \operatorname{lc}_{x_0}(A) \in \mathbb{Z}[x_1, \ldots, x_m] must be distributed among the factors. If ℓ\ell is an integer, it can be imposed on every factor, at the price of a power ℓr−1\ell^{r-1} multiplied into AA and removed at the end (the integer content of each lifted factor). Otherwise the factors of ℓ\ell must be assigned to the right factors of AA. Two methods are implemented, both needing the factorisation of ℓ\ell (FLINT factors it recursively).

Wang's method#

Lemma 5 (Wang's leading coefficient condition). Let ℓ=c∏j=1sLjej\ell = c \prod_{j=1}^{s} L_j^{e_j} with c∈Zc \in \mathbb{Z} and distinct irreducible nonconstant Lj∈Z[x1,…,xm]L_j \in \mathbb{Z}[x_1, \ldots, x_m]. Let A=∏i=1rAiA = \prod_{i=1}^r A_i be the factorisation of the primitive squarefree AA into irreducible factors, and suppose that A(x0,α)=δ∏i=1ruiA(x_0, \alpha) = \delta \prod_{i=1}^r u_i with δ∈Z\delta \in \mathbb{Z} and uiu_i primitive irreducible, Ai(x0,α)=κiuiA_i(x_0, \alpha) = \kappa_i u_i with κi∈Z\kappa_i \in \mathbb{Z}. If qq is a prime that divides Lj(α)L_j(\alpha) but divides neither cδc\delta nor any Lk(α)L_k(\alpha), k≠jk \ne j, then the exponent sijs_{ij} of LjL_j in lc⁡x0(Ai)\operatorname{lc}_{x_0}(A_i) is

sij=vq(δlc⁡(ui))vq(Lj(α)).s_{ij} = \frac{v_q(\delta \operatorname{lc}(u_i))}{v_q(L_j(\alpha))}.

Proof. Write lc⁡(Ai)=ci∏jLjsij\operatorname{lc}(A_i) = c_i \prod_j L_j^{s_{ij}} with ci∈Zc_i \in \mathbb{Z}. Then ∏ici=c\prod_i c_i = c and ∏iκi=δ\prod_i \kappa_i = \delta, and evaluating at α\alpha gives κilc⁡(ui)=ci∏kLk(α)sik\kappa_i \operatorname{lc}(u_i) = c_i \prod_k L_k(\alpha)^{s_{ik}}. Multiplying by δ/κi∈Z\delta/\kappa_i \in \mathbb{Z}, δlc⁡(ui)=ci(δ/κi)∏kLk(α)sik\delta \operatorname{lc}(u_i) = c_i (\delta / \kappa_i) \prod_k L_k(\alpha)^{s_{ik}}, where ci(δ/κi)c_i (\delta/\kappa_i) divides cδc\delta and is therefore not divisible by qq. Taking qq-adic valuations gives vq(δlc⁡(ui))=sijvq(Lj(α))v_q(\delta \operatorname{lc}(u_i)) = s_{ij} v_q(L_j(\alpha)).

If every Lj(α)L_j(\alpha) has such a prime, all exponents sijs_{ij} are determined [Wan1978]; the integer parts cic_i are not, and are handled by multiplying AA by a power of the remaining integer factor, which is removed again as the content of the lifted factors. fmpz_mpoly_factor_lcc_wang checks a sequential form of the condition (each Lj(α)L_j(\alpha) must keep a nontrivial factor after removing all primes of cδc\delta and of L1(α),…,Lj−1(α)L_1(\alpha), \ldots, L_{j-1}(\alpha); it returns 0 otherwise, and another point is tried) and computes the exponents by removing the values ∣Lj(α)∣|L_j(\alpha)| from δlc⁡(ui)\delta \operatorname{lc}(u_i) in the order j=s,…,1j = s, \ldots, 1 with fmpz_remove. The condition fails for evaluation points with small values, in particular for α=0\alpha = 0 when ℓ\ell has factors without constant term, which is why FLINT first tries the point 00 only when the input is dense enough, then random points.

For example, let A=A1A2A = A_1 A_2 with A1=x1(x1+x2)x0+1A_1 = x_1(x_1 + x_2) x_0 + 1 and A2=x2x0+x1−1A_2 = x_2 x_0 + x_1 - 1, so that ℓ=x1x2(x1+x2)\ell = x_1 x_2 (x_1 + x_2), c=1c = 1, and L1=x1L_1 = x_1, L2=x2L_2 = x_2, L3=x1+x2L_3 = x_1 + x_2. At α=(5,7)\alpha = (5, 7) the values Lj(α)=5,7,12L_j(\alpha) = 5, 7, 12 are pairwise coprime, and A(x0,α)=(60x0+1)(7x0+4)A(x_0, \alpha) = (60 x_0 + 1)(7 x_0 + 4) with δ=1\delta = 1. Removing 1212, 77 and 55 from lc⁡(u1)=60\operatorname{lc}(u_1) = 60 leaves 11 after one division by 1212 and one by 55, so lc⁡(A1)=L1L3\operatorname{lc}(A_1) = L_1 L_3; from lc⁡(u2)=7\operatorname{lc}(u_2) = 7 only 77 is removed, so lc⁡(A2)=L2\operatorname{lc}(A_2) = L_2. At α=(2,4)\alpha = (2, 4), on the other hand, the values 2,4,62, 4, 6 have no private primes and the point is rejected.

Kaltofen's method#

Kaltofen [Kal1985] determines the distribution of the factors of ℓ\ell one variable at a time from bivariate factorisations: for each v≥1v \ge 1, the bivariate image A(x0,α1,…,xv,…,αm)A(x_0, \alpha_1, \ldots, x_v, \ldots, \alpha_m) is factored with factors matched to the univariate factors uiu_i (by fmpz_bpoly_factor_ordered, which lifts the uiu_i in xvx_v); the leading coefficients of these bivariate factors are univariate in xvx_v and show which factors of the image of ℓ\ell go where; these are lifted back to the factors of ℓ\ell involving xvx_v. This works without Wang's condition, and fmpz_mpoly_factor_irred_wang falls back to it when the condition fails (fmpz_mpoly_factor_lcc_kaltofen, fmpz_mpoly_factor_lcc_kaltofen_step).

Since only coprime factors can be lifted, the step for xvx_v works with squarefree parts. The leading coefficients of the bivariate factors (polynomials in xvx_v, primitive) are replaced by their squarefree decompositions, which are then refined by GCDs into a single set of pairwise coprime squarefree bases. Let PP be the product of the distinct irreducible factors of ℓ\ell that involve xvx_v, a squarefree polynomial. If the product of the bases equals the primitive part of P(α1,…,xv,…,αm)P(\alpha_1, \ldots, x_v, \ldots, \alpha_m), the bases are lifted by Algorithm 2 to a factorisation of PP into polynomials in all variables (the images of the bases are coprime, so Lemma 1 applies). Each lifted base, raised to its multiplicity, is assigned to the factors whose bivariate leading coefficient contained it, and divided out of the factorisation of ℓ\ell. When all of ℓ\ell has been distributed, the integer content is assigned by comparing the contents of the bivariate leading coefficients with those of the assigned parts.

If neither method distributes the whole leading coefficient, the remaining part is imposed on every factor as for an integer leading coefficient, or the Zassenhaus method of Zassenhaus-style lifting, which lifts without leading coefficient information, is used.

Use in FLINT#

int fmpz_mpoly_hlift(slong m, fmpz_mpoly_struct * f, slong r, const fmpz * alpha, const fmpz_mpoly_t A, const slong * degs, const fmpz_mpoly_ctx_t ctx)
int fmpz_mpoly_factor_lcc_wang(fmpz_mpoly_struct * lc_divs, const fmpz_mpoly_factor_t lcAfac, const fmpz_t Auc, const fmpz_poly_struct * Auf, slong r, const fmpz * alpha, const fmpz_mpoly_ctx_t ctx)
int fmpz_mpoly_factor_lcc_kaltofen(fmpz_mpoly_struct * divs, const fmpz_mpoly_factor_t lcAf_, const fmpz_mpoly_t A, slong r, const fmpz * alpha, slong * degs, const fmpz_poly_factor_t uf, const fmpz_mpoly_ctx_t ctx)
int nmod_mpoly_hlift_zippel(slong m, nmod_mpoly_struct * B, slong r, const ulong * alpha, const nmod_mpoly_t A, const slong * degs, const nmod_mpoly_ctx_t ctx, flint_rand_t state)

Referenced from#

References#

  • [WanRot1975] P. S. Wang and L. P. Rothschild. Factoring multivariate polynomials over the integers. Mathematics of Computation 29 (1975), 935–950. https://doi.org/10.1090/S0025-5718-1975-0396471-3
  • [Wan1978] P. S. Wang. An improved multivariate polynomial factoring algorithm. Mathematics of Computation 32 (1978), 1215–1231. https://doi.org/10.1090/S0025-5718-1978-0568284-3
  • [Sch-mpoly] D. Schultz. Algorithms for multivariate polynomials. Notes in the FLINT source tree, src/mpoly/doc/MPolyAlgorithms.tex.
  • [GCL1992] K. O. Geddes, S. R. Czapor and G. Labahn. Algorithms for computer algebra. Springer, 1992. https://doi.org/10.1007/b102438
  • [GG2003] J. von zur Gathen and J. Gerhard, Modern Computer Algebra, second edition, Cambridge University Press (2003)
  • [Zip1981] R. Zippel. Newton's iteration and the sparse Hensel algorithm. Proceedings of SYMSAC 1981, ACM, 68–72. https://doi.org/10.1145/800206.806373
  • [Kal1985] E. Kaltofen. Sparse Hensel lifting. EUROCAL '85, Lecture Notes in Computer Science 204, Springer, 1985, 4–17. https://doi.org/10.1007/3-540-15984-3_230
  • [MonTun2020] M. Monagan and B. Tuncer. The complexity of sparse Hensel lifting and sparse polynomial factorization. Journal of Symbolic Computation 99 (2020), 189–230. https://doi.org/10.1016/j.jsc.2019.05.001
Cite this page

The FLINT team, “Multivariate Hensel lifting,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/multivariate/hensel-lifting.html (generated 2026-11-02).