Algorithm Search⌘K

Proofs: Primitive polynomial remainder sequence algorithm

These are the human proofs of Primitive polynomial remainder sequence algorithm, at full length.

The primitive PRS algorithm returns the gcd in R[x] full

This proof shows: correctness.

Setting. RR is a unique factorization domain with field of fractions KK. A polynomial in R[x]R[x] is primitive when its coefficients have no common prime factor. We use two forms of Gauss's lemma: (G1) a product of primitive polynomials is primitive; (G2) if p,q∈R[x]p, q \in R[x] are primitive and p=λqp = \lambda q with λ∈K∗\lambda \in K^*, then λ\lambda is a unit of RR. (G2) follows from (G1) by clearing denominators: write λ=a/b\lambda = a / b with a,b∈Ra, b \in R coprime; then bp=aqb p = a q, the content of the left side is bb and of the right side is aa, up to units, so aa and bb are units.

Lemma 1. For f,g∈R[x]f, g \in R[x] not both zero, gcd⁡(f,g)=gcd⁡(cont⁡f,cont⁡g)⋅gcd⁡(pp⁡f,pp⁡g)\gcd(f, g) = \gcd(\operatorname{cont} f, \operatorname{cont} g) \cdot \gcd(\operatorname{pp} f, \operatorname{pp} g) up to a unit. Proof. Any common divisor dd of ff and gg splits as cont⁡(d)pp⁡(d)\operatorname{cont}(d) \operatorname{pp}(d). By (G1) the content of f=cont⁡(f)pp⁡(f)f = \operatorname{cont}(f) \operatorname{pp}(f) factors by contents, so cont⁡(d)∣cont⁡(f)\operatorname{cont}(d) \mid \operatorname{cont}(f) and pp⁡(d)∣pp⁡(f)\operatorname{pp}(d) \mid \operatorname{pp}(f), and the same for gg. Conversely the product on the right divides both ff and gg. □\square

Lemma 2. Let A,B∈R[x]A, B \in R[x] with B≠0B \ne 0 and deg⁡A≥deg⁡B\deg A \ge \deg B. Then prem⁡(A,B)=LC⁡(B)e(A mod B)\operatorname{prem}(A, B) = \operatorname{LC}(B)^{e} (A \bmod B) with e=deg⁡A−deg⁡B+1e = \deg A - \deg B + 1, where A mod BA \bmod B is the remainder in K[x]K[x]. In particular deg⁡prem⁡(A,B)<deg⁡B\deg \operatorname{prem}(A, B) < \deg B, and gcd⁡K[x](A,B)=gcd⁡K[x](B,prem⁡(A,B))\gcd_{K[x]}(A, B) = \gcd_{K[x]}(B, \operatorname{prem}(A, B)). Proof. LC⁡(B)eA=QB+r\operatorname{LC}(B)^e A = Q B + r in R[x]R[x] with deg⁡r<deg⁡B\deg r < \deg B, by the pseudo-division algorithm. Divide by LC⁡(B)e≠0\operatorname{LC}(B)^e \ne 0: then A=(Q/LC⁡(B)e)B+r/LC⁡(B)eA = (Q / \operatorname{LC}(B)^e) B + r / \operatorname{LC}(B)^e, and by uniqueness of division in K[x]K[x], r/LC⁡(B)e=A mod Br / \operatorname{LC}(B)^e = A \bmod B. A polynomial divides AA and BB exactly when it divides BB and A−qBA - qB. □\square

The algorithm. Lines L1 to L3 handle the cases where ff or gg is 00: gcd⁡(0,0)=0\gcd(0, 0) = 0 and gcd⁡(f,0)=f\gcd(f, 0) = f up to a unit. Otherwise, after line L2, deg⁡f≥deg⁡g≥0\deg f \ge \deg g \ge 0 and g≠0g \ne 0. By Lemma 1 it is enough to show that the loop returns gcd⁡(pp⁡f,pp⁡g)\gcd(\operatorname{pp} f, \operatorname{pp} g) (times cc), or cc when this gcd is 1.

Invariant. At line L5, AA and BB are primitive, B≠0B \ne 0, deg⁡A≥deg⁡B\deg A \ge \deg B, and gcd⁡K[x](A,B)=gcd⁡K[x](pp⁡f,pp⁡g)\gcd_{K[x]}(A, B) = \gcd_{K[x]}(\operatorname{pp} f, \operatorname{pp} g) up to a factor in K∗K^*.

It holds at the start. In a pass, let r=prem⁡(A,B)r = \operatorname{prem}(A, B). If r≠0r \ne 0, then the new pair is (B,pp⁡(r))(B, \operatorname{pp}(r)); pp⁡(r)\operatorname{pp}(r) is primitive, pp⁡(r)\operatorname{pp}(r) is rr times an element of K∗K^*, and by Lemma 2 deg⁡pp⁡(r)<deg⁡B\deg \operatorname{pp}(r) < \deg B and gcd⁡K[x](B,pp⁡(r))=gcd⁡K[x](B,r)=gcd⁡K[x](A,B)\gcd_{K[x]}(B, \operatorname{pp}(r)) = \gcd_{K[x]}(B, r) = \gcd_{K[x]}(A, B). So the invariant holds again.

Termination. deg⁡B\deg B falls strictly in each pass and is at least 00, so the loop ends after at most deg⁡g+1\deg g + 1 passes.

Result. There are two ways to leave the loop.

(i) Line L7: r=0r = 0. Then BB divides AA in K[x]K[x], so gcd⁡K[x](A,B)=B\gcd_{K[x]}(A, B) = B up to K∗K^*. By the invariant, B=λhB = \lambda h with h=gcd⁡R[x](pp⁡f,pp⁡g)h = \gcd_{R[x]}(\operatorname{pp} f, \operatorname{pp} g) and λ∈K∗\lambda \in K^*; here we use that a gcd in R[x]R[x] of two primitive polynomials is primitive and is a gcd in K[x]K[x] (it divides both in K[x]K[x], and every divisor in K[x]K[x] becomes, after making it primitive, a divisor in R[x]R[x] by (G1)). Both BB and hh are primitive, so by (G2) λ\lambda is a unit of RR, and BB is the gcd in R[x]R[x]. Line L7 returns c⋅Bc \cdot B, which is gcd⁡(f,g)\gcd(f, g) by Lemma 1.

(ii) Line L9: deg⁡B=0\deg B = 0, so BB is a nonzero constant, and it is a unit of KK. So gcd⁡K[x](pp⁡f,pp⁡g)=1\gcd_{K[x]}(\operatorname{pp} f, \operatorname{pp} g) = 1, and the primitive gcd hh in R[x]R[x] has degree 0; being primitive, it is a unit of RR. Line L9 returns cc, which is gcd⁡(f,g)\gcd(f, g) by Lemma 1.

Over Z\mathbb{Z}, the content is taken with the sign of the leading coefficient, so every BB has a positive leading coefficient, c>0c > 0, and the returned gcd is the normalized one. ■\blacksquare

Back to Primitive polynomial remainder sequence algorithm