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] have degree n, let p be a prime that does not divide the leading coefficient lc(f), and let g0,h0∈Z[x] with h0 monic of degree e, f≡g0h0(modp), and g0modp, h0modp coprime. Congruence of polynomials modulo m means that every coefficient of the difference is a multiple of m. Since h0 is monic and lc(f)≡0(modp), the reduction of g0 modulo p has degree n−e and leading coefficient ≡lc(f).
Lemma 1 (division by a monic polynomial). Let m≥2 and h monic of degree e. Every a∈Z[x] has q,r with a≡qh+r(modm) and degr<e, and if a≡0(modm′) for a divisor m′ of m, then q≡r≡0(modm′).
Proof. Long division by h subtracts cxjh, where c is the current leading coefficient, and never divides, so it works over Z/mZ. The quotient and remainder are unique modulo m: if qh+r≡q′h+r′ with degr,degr′<e, and q−q′≡0, then the top coefficient of (q−q′)h is that of q−q′, because h is monic, so (q−q′)h has degree at least e modulo m, while r′−r has degree less than e. So q≡q′, r≡r′. Division is also unique modulo m′, and reducing a division modulo m gives one modulo m′. If a≡0(modm′), then 0=0⋅h+0 is the division of a modulo m′, so q≡r≡0(modm′). □
Lemma 2 (cofactors). Line L1 returns s,t with sg0+th0≡1(modp), degs<e and degt<n−e.
Proof. Z/pZ is a field and the reductions of g0,h0 are coprime, so the extended Euclidean algorithm gives s,t with sg0+th0≡1. If degs≥e, replace s by smodh0 and t by t+(sdivh0)g0; the sum is unchanged. Then th0≡1−sg0 has degree less than e+(n−e)=n, and since h0 is monic, degt<n−e. The standard extended Euclidean algorithm already returns cofactors with these degrees. □
Invariant. At line L3, with m=p2i after i iterations:
- f≡gh(modm) and sg+th≡1(modm);
- h is monic of degree e, degg≤n−e, degs<e, degt<n−e;
- g≡g0 and h≡h0(modp).
Initialization. Before the first iteration, m=p, g=g0 and h=h0, 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 m2, and we write g∗,h∗,s∗,t∗ for the new values.
The factors. e=f−gh≡0(modm) by part 1, so se≡0(modm), and by Lemma 1 with m′=m, q≡r≡0(modm). Hence g∗=g+te+qg≡g and h∗=h+r≡h(modm), which gives part 3 since p divides m. As degr<e, h∗ is monic of degree e. Next, using se=qh+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. In the first product e≡0 and 1−sg−th≡0(modm); in the second te+qg≡0 and r≡0(modm). So f≡g∗h∗(modm2). For the degree of g∗: if g∗ had a coefficient ≡0(modm2) at some degree j>n−e, take the largest such j; then the coefficient of xj+e in g∗h∗ is that coefficient, since h∗ is monic, but f has no term of degree j+e>n. This contradicts f≡g∗h∗, so degg∗≤n−e.
The cofactors. b=sg∗+th∗−1≡sg+th−1≡0(modm). With sb=ch∗+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. Since b≡0(modm), b2≡0(modm2), so s∗g∗+t∗h∗≡1(modm2). For the degrees, degd<e and degs<e give degs∗<e. Then t∗h∗≡1−s∗g∗ has degree less than e+(n−e)=n modulo m2, and as h∗ is monic of degree e, degt∗<n−e, by the same top coefficient argument as for g∗.
Line L10 sets m←m2=p2i+1, so the invariant holds at the next test of line L3.
Termination. After i iterations m=p2i, and the test m<pk fails once 2i≥k. So the loop runs ⌈log2k⌉ times.
Output. At line L11, m=p2i with 2i≥k, so pk divides m, and part 1 gives f≡gh(modpk). Reducing modulo pk keeps h monic of degree e, because its leading coefficient is 1, and keeps g≡g0 and h≡h0(modp) by part 3. So the output meets the specification.
Uniqueness. If g′,h′ is another output, with h′ monic of degree e, f≡g′h′(modpk), g′≡g0 and h′≡h0(modp), then g′≡g and h′≡h(modpk) by the uniqueness theorem in Hensel's lemma, which needs exactly that g0,h0 are coprime modulo p and that h,h′ are monic of the same degree. With coefficients in {0,…,pk−1}, the output is therefore unique. ■