These are the human proofs of Brent-Kung composition algorithm, at full length.
BRENT-KUNG returns f(g) mod h with at most 2 ceil(sqrt(N)) - 2 products modulo h and one matrix product full
This proof shows: correctness.
Let R be a commutative ring, h∈R[x] of degree n≥1 with a unit leading coefficient, g∈R[x], and f=∑t=0N−1ftyt with N≥1. Let Q=R[x]/(h) and let π:R[x]→Q be the quotient map. Division with remainder by h is defined over R because the leading coefficient is a unit, and it gives each class of Q a unique representative of degree less than n. We write rep(aˉ) for it, so amodh=rep(π(a)). Let gˉ=π(g), k=⌈N⌉, m=⌈N/k⌉, and ft=0 for t≥N.
Lemma 1 (reduction is a homomorphism).π is a ring homomorphism, rep is R-linear, and f(g)modh=rep(f(gˉ)).
Proof.π is the quotient map by an ideal, so it is a ring homomorphism, and π(f(g))=f(gˉ). If a and b have degree less than n and c∈R, then a+cb has degree less than n and lies in the class π(a)+cπ(b), so by uniqueness rep is R-linear. □
Lemma 2 (baby steps). For 1≤i≤min(k,N−1), line L3 gives Gi=rep(gˉi), and G0=1=rep(1).
Proof.G1=gmodh=rep(gˉ) by line L2. If Gi−1=rep(gˉi−1), then Gi−1G1modh=rep(π(Gi−1G1))=rep(gˉi−1gˉ). Also rep(1)=1 since n≥1. □
Lemma 3 (the matrix product). Row j of C=A⋅B is the coefficient vector of rep(Fj(gˉ)), where Fj=∑i=0k−1fjk+iyi.
Proof. The entry of C in row j and column c is ∑iA[j][i]B[i][c]=∑ifjk+i[xc]Gi, so row j is the coefficient vector of ∑ifjk+iGi. A row i of B with i>N−1 is zero, and it meets only fjk+i with jk+i≥i≥N, which is 0, so those terms vanish. For the other i, Gi=rep(gˉi) by Lemma 2. By the linearity in Lemma 1, ∑ifjk+irep(gˉi)=rep(Fj(gˉ)). □
Proof. Each t<mk has a unique form t=jk+i with 0≤i<k and 0≤j<m, and N≤mk. Since Q is commutative, f(gˉ)=∑tftgˉt=∑jFj(gˉ)(gˉk)j. If m≥2, then N>k, so k≤N−1 and Gk=rep(gˉk) by Lemma 2. Let Cj=rep(Fj(gˉ)) be row j of C (Lemma 3). We claim that after line L9 for index j, and after line L7 for j=m−1, S=rep(∑t=jm−1Ft(gˉ)(gˉk)t−j). Line L7 gives it for j=m−1. If it holds for j+1, then S⋅Gkmodh=rep(∑t=j+1m−1Ft(gˉ)(gˉk)t−j) by Lemma 1, and adding Cj adds rep(Fj(gˉ)), by linearity of rep. At j=0 this is rep(f(gˉ))=f(g)modh by Lemma 1. If m=1, the loop does not run and S=C0=rep(f(gˉ)). □
Theorem (cost). Assume M(a)/a is nondecreasing and N≤n, degg<n. The algorithm does at most 2k−2 products modulo h, each costing at most 3M(n)+O(n) ring operations after a one-time cost of O(M(n)) for the inverse of the reversal of h. Line L6 costs at most mkn≤k2n ring multiplications and as many additions by the schoolbook method, and O(n(ω+1)/2) with an O(rω) matrix multiplication. So the total is O(nM(n)+n(ω+1)/2).
Proof.Count. Line L3 runs min(k,N−1)−1 times and line L9 runs m−1 times. From (k−1)2<N≤k2 we get m=⌈N/k⌉≤k, so the total is at most (k−1)+(k−1)=2k−2.
One product modulo h. Both factors have degree less than n, so their product costs at most M(n) and has degree at most 2n−2. Fast division of it by h has a quotient with at most n−1 coefficients. With the inverse of the reversal of h to precision n stored, by the cost theorem for fast polynomial division it costs at most M(n−1)+M(n)+O(n)≤2M(n)+O(n). The stored inverse costs O(M(n)) once, by Newton iteration.
Matrix product. Pad A to a k×k matrix with zero rows and B to a k×k⌈n/k⌉ matrix with zero columns. Then A⋅B is ⌈n/k⌉ products of k×k matrices. With k≤n+1, this costs O((n/k+1)kω)=O(n(ω+1)/2). The schoolbook bound mkn counts one multiplication per triple (row, inner index, column).
Rest. Lines L4, L5 and L7 and the additions of line L9 cost O(mn)=O(n3/2), which is within O(nM(n)) since M(n)≥n. Adding up gives the bound. ■