Hermite reduction returns g and a squarefree remainder with A/D = g' + a/d full
This proof shows: correctness, termination.
Let K be a field of characteristic 0 and D∈K[x] nonzero, with squarefree factorization D=c∏i=1mDii, where c∈K, the Di are monic, squarefree and pairwise coprime, and Dm=1. All gcds are monic.
Lemma 1. For a polynomial E=c∏iEii of this form, gcd(E,E′)=∏iEii−1, and E/gcd(E,E′) is c∏iEi, a squarefree polynomial.
Proof. Let p be a monic irreducible factor of Ei, so p divides E exactly i times. Write E=piu with p∤u. Then E′=pi−1(ip′u+pu′). Since degp′<degp and p′=0 in characteristic 0, and p∤u, p does not divide ip′u, so it does not divide ip′u+pu′. Hence p divides E′ exactly i−1 times, and gcd(E,E′) contains p exactly i−1 times. Irreducible factors of E′ that do not divide E do not enter the gcd. □
Write Dk− for the value of D− at the start of pass k of the loop, k=1,2,…. By Lemma 1, D1−=∏iDii−1 and D∗=c∏iDi, and by induction, applying Lemma 1 to Dk− in line L4,
Dk−=i≥k∏Dii−k,Dk−∗=i>k∏Di,Dk−−=Dk+1−. Lemma 2 (line L5 is solvable). Let Fk=−D∗Dk−′/Dk−. Then Fk is a polynomial and gcd(Fk,Dk−∗)=1. Hence there are unique B,C with BFk+CDk−∗=A and degB<degDk−∗.
Proof. From the formula for Dk−, logarithmic differentiation gives Dk−′/Dk−=∑i>k(i−k)Di′/Di. Multiplying by D∗=c∏jDj gives Fk=−c∑i>k(i−k)Di′∏j=iDj, a polynomial. Let p be an irreducible factor of Dk−∗, so p∣Dl for one l>k. Every term of the sum with i=l contains the factor Dl, so it is divisible by p. The term with i=l is (l−k)Dl′∏j=lDj. Here l−k=0 in characteristic 0, p∤Dl′ because Dl is squarefree, and p∤Dj for j=l because the Dj are pairwise coprime. So p∤Fk. Therefore Fk and Dk−∗ are coprime. The extended Euclidean algorithm gives s,t with sFk+tDk−∗=1; then B=(sA)modDk−∗ and C=(A−BFk)/Dk−∗ satisfy the equation, the division being exact because BFk≡sFkA≡A modulo Dk−∗. If (B1,C1) is another solution with the degree bound, then (B−B1)Fk=(C1−C)Dk−∗, so Dk−∗∣B−B1 by coprimality, and the degree bound gives B=B1, hence C=C1. □
Lemma 3 (one pass). Suppose that before pass k, Ain/D=g′+A/(D∗Dk−) and degA<deg(D∗Dk−). Then after the pass, Ain/D=g′+A/(D∗Dk+1−) with the new values, and degA<deg(D∗Dk+1−).
Proof. Write E=Dk−, E∗=Dk−∗ and E−=Dk+1−, so E=E∗E−. By Lemma 2, A=BF+CE∗ with F=−D∗E′/E. Then
D∗EA−(EB)′=D∗EA−EB′+E2BE′=D∗EA−B′D∗+BD∗E′/E=D∗E∗E−CE∗−B′D∗. The term BD∗E′/E=−BF cancels against the part BF of A. Now E∗∣D∗, since every Di with i>k is a factor of D∗, so D∗/E∗ is a polynomial and the last fraction equals (C−B′D∗/E∗)/(D∗E−). This is the new A of line L6 over D∗Dk+1−, and line L7 adds B/E to g, so the identity holds after the pass.
For the degrees, let N=deg(D∗E). Then degF=degD∗−1 and degB<degE∗, so deg(BF)<degE∗+degD∗−1≤N−1 because degE∗≤degE. With degA<N this gives deg(CE∗)<N, so degC<N−degE∗=deg(D∗E−). Also deg(B′D∗/E∗)<degE∗−1+degD∗−degE∗+1=degD∗≤deg(D∗E−). So the new A has degree less than deg(D∗Dk+1−). □
Theorem. HERMITE-REDUCE(Ain,D) terminates after m−1 passes and returns g and a/d with Ain/D=g′+a/d, where d=D∗ is squarefree and dega<degd.
Proof. After line L1, Ain=PD+A with degA<degD, and g=∫P, so Ain/D=g′+A/D. After line L2, D=D∗D1−, so the hypothesis of Lemma 3 holds for k=1. By Lemma 3 and induction, it holds at the start of every pass. By the formula above, Dk− has degree 0 exactly when k≥m, so the loop of line L3 runs for k=1,…,m−1 and stops with D−=Dm−=1, a monic polynomial of degree 0. Then the identity reads Ain/D=g′+A/D∗ with degA<degD∗, and D∗=c∏iDi is squarefree by Lemma 1. Line L9 returns this. ■