Algorithm Search⌘K

Proofs: Pseudo-division

These are the human proofs of Pseudo-division, at full length.

Pseudo-division returns q and r with lc(g)^(m - n + 1) f = q g + r and deg r < n full

This proof shows: correctness.

Let RR be a commutative ring, f,g∈R[x]f, g \in R[x] with g≠0g \ne 0, m=deg⁡fm = \deg f, n=deg⁡gn = \deg g, ℓ=lc⁡(g)\ell = \operatorname{lc}(g) and g=∑j=0ngjxjg = \sum_{j=0}^{n} g_j x^j, so gn=ℓg_n = \ell.

The case m<nm < n. Line L2 returns (0,f)(0, f). Here δ=0\delta = 0, and ℓ0f=0⋅g+f\ell^0 f = 0 \cdot g + f with deg⁡f<n\deg f < n. If f=0f = 0, then m=−∞<nm = -\infty < n and the same holds.

The case m≥nm \ge n. Let d=m−n≥0d = m - n \ge 0. Write r(k)r^{(k)} for the value of the array rr, read as a polynomial, before step kk of line L4, for k=d,d−1,…,0k = d, d - 1, \ldots, 0, and r(−1)r^{(-1)} for its value after step 00. Let

Qk=∑i=k+1dti ℓ i−k−1xi.Q_k = \sum_{i = k + 1}^{d} t_i\, \ell^{\,i - k - 1} x^i .

Invariant. For each kk from dd down to −1-1:

  1. ℓd−kf=Qk g+r(k)\ell^{d - k} f = Q_k\, g + r^{(k)};
  2. every coefficient of r(k)r^{(k)} at a position j>n+kj > n + k is 00.

Initialization (k=dk = d). Qd=0Q_d = 0 and r(d)=fr^{(d)} = f, so part 1 reads f=ff = f. Part 2 holds because deg⁡f=m=n+d\deg f = m = n + d.

Maintenance. Assume the invariant for k≥0k \ge 0. Line L5 sets tkt_k to the coefficient of xn+kx^{n + k} in r(k)r^{(k)}. Lines L6 and L7 change the positions 0,…,n+k−10, \ldots, n + k - 1, and line L8 sets position n+kn + k to 00. The positions above n+kn + k are not changed and stay 00 by part 2.

We claim that r(k−1)=ℓ r(k)−tkxkgr^{(k-1)} = \ell\, r^{(k)} - t_k x^k g. At a position j<n+kj < n + k, the coefficient of ℓ r(k)\ell\, r^{(k)} is ℓ⋅rj(k)\ell \cdot r^{(k)}_j, which line L6 computes, and the coefficient of tkxkgt_k x^k g is tkgj−kt_k g_{j - k} (taken as 00 when j<kj < k), which line L7 subtracts. At position n+kn + k, the coefficient of ℓ r(k)−tkxkg\ell\, r^{(k)} - t_k x^k g is ℓtk−tkgn=ℓtk−tkℓ=0\ell t_k - t_k g_n = \ell t_k - t_k \ell = 0, because RR is commutative, and line L8 stores this 00. At positions above n+kn + k, both r(k)r^{(k)} and xkgx^k g have zero coefficients. This proves the claim and part 2 for k−1k - 1, since now position n+kn + k is 00 too.

For part 1, multiply the invariant for kk by ℓ\ell:

ℓd−k+1f=ℓQk g+ℓ r(k)=(ℓQk+tkxk) g+(ℓ r(k)−tkxkg).\ell^{d - k + 1} f = \ell Q_k\, g + \ell\, r^{(k)} = (\ell Q_k + t_k x^k)\, g + (\ell\, r^{(k)} - t_k x^k g).

The second summand is r(k−1)r^{(k-1)} by the claim, and

ℓQk+tkxk=∑i=k+1dti ℓ i−kxi+tkxk=∑i=kdti ℓ i−kxi=Qk−1.\ell Q_k + t_k x^k = \sum_{i = k + 1}^{d} t_i\, \ell^{\,i - k} x^i + t_k x^k = \sum_{i = k}^{d} t_i\, \ell^{\,i - k} x^i = Q_{k-1}.

So ℓd−(k−1)f=Qk−1 g+r(k−1)\ell^{d - (k - 1)} f = Q_{k-1}\, g + r^{(k-1)}.

End. For k=−1k = -1 the invariant gives ℓd+1f=Q−1 g+r(−1)\ell^{d + 1} f = Q_{-1}\, g + r^{(-1)} with Q−1=∑i=0dtiℓixiQ_{-1} = \sum_{i=0}^{d} t_i \ell^i x^i, and r(−1)r^{(-1)} has zero coefficients at all positions j>n−1j > n - 1, that is deg⁡r(−1)<n\deg r^{(-1)} < n. Line L9 computes the coefficients qk=tkℓkq_k = t_k \ell^k of Q−1Q_{-1}, with ℓk\ell^k obtained by repeated multiplication, and line L10 returns r(−1)r^{(-1)} truncated to positions 0,…,n−10, \ldots, n - 1, which loses only zero coefficients. Stripping zero top coefficients does not change either polynomial. Since d+1=m−n+1=δd + 1 = m - n + 1 = \delta, the output satisfies ℓδf=qg+r\ell^{\delta} f = q g + r with deg⁡r<n\deg r < n.

Termination. The loop of line L4 runs d+1d + 1 times, and each inner loop is finite. ■\blacksquare

Back to Pseudo-division