Algorithm Search⌘K

Proofs: Hensel lifting

These are the human proofs of Hensel lifting, at full length.

HENSEL-LIFT returns the unique lift of f = g h from modulus p to modulus p^k full

This proof shows: correctness.

Let f∈Z[x]f \in \mathbb{Z}[x] have degree nn, let pp be a prime that does not divide the leading coefficient lc(f)\mathrm{lc}(f), and let g0,h0∈Z[x]g_0, h_0 \in \mathbb{Z}[x] with h0h_0 monic of degree ee, f≡g0h0(modp)f \equiv g_0 h_0 \pmod p, and g0 mod pg_0 \bmod p, h0 mod ph_0 \bmod p coprime. Congruence of polynomials modulo mm means that every coefficient of the difference is a multiple of mm. Since h0h_0 is monic and lc(f)≢0(modp)\mathrm{lc}(f) \not\equiv 0 \pmod p, the reduction of g0g_0 modulo pp has degree n−en - e and leading coefficient ≡lc(f)\equiv \mathrm{lc}(f).

Lemma 1 (division by a monic polynomial). Let m≥2m \ge 2 and hh monic of degree ee. Every a∈Z[x]a \in \mathbb{Z}[x] has q,rq, r with a≡qh+r(modm)a \equiv q h + r \pmod m and deg⁡r<e\deg r < e, and if a≡0(modm′)a \equiv 0 \pmod{m'} for a divisor m′m' of mm, then q≡r≡0(modm′)q \equiv r \equiv 0 \pmod{m'}.

Proof. Long division by hh subtracts cxjhc x^j h, where cc is the current leading coefficient, and never divides, so it works over Z/mZ\mathbb{Z}/m\mathbb{Z}. The quotient and remainder are unique modulo mm: if qh+r≡q′h+r′q h + r \equiv q' h + r' with deg⁡r,deg⁡r′<e\deg r, \deg r' < e, and q−q′≢0q - q' \not\equiv 0, then the top coefficient of (q−q′)h(q - q') h is that of q−q′q - q', because hh is monic, so (q−q′)h(q - q')h has degree at least ee modulo mm, while r′−rr' - r has degree less than ee. So q≡q′q \equiv q', r≡r′r \equiv r'. Division is also unique modulo m′m', and reducing a division modulo mm gives one modulo m′m'. If a≡0(modm′)a \equiv 0 \pmod{m'}, then 0=0⋅h+00 = 0 \cdot h + 0 is the division of aa modulo m′m', so q≡r≡0(modm′)q \equiv r \equiv 0 \pmod{m'}. □\square

Lemma 2 (cofactors). Line L1 returns s,ts, t with sg0+th0≡1(modp)s g_0 + t h_0 \equiv 1 \pmod p, deg⁡s<e\deg s < e and deg⁡t<n−e\deg t < n - e.

Proof. Z/pZ\mathbb{Z}/p\mathbb{Z} is a field and the reductions of g0,h0g_0, h_0 are coprime, so the extended Euclidean algorithm gives s,ts, t with sg0+th0≡1s g_0 + t h_0 \equiv 1. If deg⁡s≥e\deg s \ge e, replace ss by s mod h0s \bmod h_0 and tt by t+(sdiv⁡h0) g0t + (s \operatorname{div} h_0)\, g_0; the sum is unchanged. Then th0≡1−sg0t h_0 \equiv 1 - s g_0 has degree less than e+(n−e)=ne + (n - e) = n, and since h0h_0 is monic, deg⁡t<n−e\deg t < n - e. The standard extended Euclidean algorithm already returns cofactors with these degrees. □\square

Invariant. At line L3, with m=p2im = p^{2^i} after ii iterations:

  1. f≡gh(modm)f \equiv g h \pmod m and sg+th≡1(modm)s g + t h \equiv 1 \pmod m;
  2. hh is monic of degree ee, deg⁡g≤n−e\deg g \le n - e, deg⁡s<e\deg s < e, deg⁡t<n−e\deg t < n - e;
  3. g≡g0g \equiv g_0 and h≡h0(modp)h \equiv h_0 \pmod p.

Initialization. Before the first iteration, m=pm = p, g=g0g = g_0 and h=h0h = h_0, so the invariant holds by the hypotheses and Lemma 2.

Maintenance. Assume the invariant at the top of an iteration. All arithmetic in lines L4 to L9 is modulo m2m^2, and we write g∗,h∗,s∗,t∗g^*, h^*, s^*, t^* for the new values.

The factors. e=f−gh≡0(modm)e = f - gh \equiv 0 \pmod m by part 1, so se≡0(modm)s e \equiv 0 \pmod m, and by Lemma 1 with m′=mm' = m, q≡r≡0(modm)q \equiv r \equiv 0 \pmod m. Hence g∗=g+te+qg≡gg^* = g + te + qg \equiv g and h∗=h+r≡h(modm)h^* = h + r \equiv h \pmod m, which gives part 3 since pp divides mm. As deg⁡r<e\deg r < e, h∗h^* is monic of degree ee. Next, using se=qh+rs e = q h + r,

f−g∗h∗=e−gr−teh−qgh−(te+qg) r=e−g(qh+r)−teh−(te+qg) r=e (1−sg−th)−(te+qg) r.f - g^* h^* = e - g r - t e h - q g h - (t e + q g)\, r = e - g(qh + r) - teh - (te + qg)\, r = e\,(1 - s g - t h) - (t e + q g)\, r.

In the first product e≡0e \equiv 0 and 1−sg−th≡0(modm)1 - sg - th \equiv 0 \pmod m; in the second te+qg≡0te + qg \equiv 0 and r≡0(modm)r \equiv 0 \pmod m. So f≡g∗h∗(modm2)f \equiv g^* h^* \pmod{m^2}. For the degree of g∗g^*: if g∗g^* had a coefficient ≢0(modm2)\not\equiv 0 \pmod{m^2} at some degree j>n−ej > n - e, take the largest such jj; then the coefficient of xj+ex^{j + e} in g∗h∗g^* h^* is that coefficient, since h∗h^* is monic, but ff has no term of degree j+e>nj + e > n. This contradicts f≡g∗h∗f \equiv g^* h^*, so deg⁡g∗≤n−e\deg g^* \le n - e.

The cofactors. b=sg∗+th∗−1≡sg+th−1≡0(modm)b = s g^* + t h^* - 1 \equiv s g + t h - 1 \equiv 0 \pmod m. With sb=ch∗+ds b = c h^* + d from line L8,

s∗g∗+t∗h∗=sg∗−dg∗+th∗−tbh∗−cg∗h∗=(1+b)−g∗(d+ch∗)−tbh∗=1+b−b (sg∗+th∗)=1+b−b(1+b)=1−b2.s^* g^* + t^* h^* = s g^* - d g^* + t h^* - t b h^* - c g^* h^* = (1 + b) - g^*(d + c h^*) - t b h^* = 1 + b - b\,(s g^* + t h^*) = 1 + b - b(1 + b) = 1 - b^2.

Since b≡0(modm)b \equiv 0 \pmod m, b2≡0(modm2)b^2 \equiv 0 \pmod{m^2}, so s∗g∗+t∗h∗≡1(modm2)s^* g^* + t^* h^* \equiv 1 \pmod{m^2}. For the degrees, deg⁡d<e\deg d < e and deg⁡s<e\deg s < e give deg⁡s∗<e\deg s^* < e. Then t∗h∗≡1−s∗g∗t^* h^* \equiv 1 - s^* g^* has degree less than e+(n−e)=ne + (n - e) = n modulo m2m^2, and as h∗h^* is monic of degree ee, deg⁡t∗<n−e\deg t^* < n - e, by the same top coefficient argument as for g∗g^*.

Line L10 sets m←m2=p2i+1m \leftarrow m^2 = p^{2^{i+1}}, so the invariant holds at the next test of line L3.

Termination. After ii iterations m=p2im = p^{2^i}, and the test m<pkm < p^k fails once 2i≥k2^i \ge k. So the loop runs ⌈log⁡2k⌉\lceil \log_2 k \rceil times.

Output. At line L11, m=p2im = p^{2^i} with 2i≥k2^i \ge k, so pkp^k divides mm, and part 1 gives f≡gh(modpk)f \equiv g h \pmod{p^k}. Reducing modulo pkp^k keeps hh monic of degree ee, because its leading coefficient is 11, and keeps g≡g0g \equiv g_0 and h≡h0(modp)h \equiv h_0 \pmod p by part 3. So the output meets the specification.

Uniqueness. If g′,h′g', h' is another output, with h′h' monic of degree ee, f≡g′h′(modpk)f \equiv g' h' \pmod{p^k}, g′≡g0g' \equiv g_0 and h′≡h0(modp)h' \equiv h_0 \pmod p, then g′≡gg' \equiv g and h′≡h(modpk)h' \equiv h \pmod{p^k} by the uniqueness theorem in Hensel's lemma, which needs exactly that g0,h0g_0, h_0 are coprime modulo pp and that h,h′h, h' are monic of the same degree. With coefficients in {0,…,pk−1}\{0, \ldots, p^k - 1\}, the output is therefore unique. ■\blacksquare

Back to Hensel lifting