Proofs: Dense polynomial (recursive dense representation)
These are the human proofs of Dense polynomial (recursive dense representation), at full length.
The recursive dense operations keep the invariant, and pseudo-division is correct full
This proof shows: correctness, termination.
Let be a commutative ring with a zero test. A value over is a list standing for . When is itself represented in this way, operations in are the operations of this page one level down. We prove each statement for given that it holds for the coefficient ring; for the base ring, such as or , the operations are exact by assumption. This is an induction on the number of variables.
Lemma 1 (NORMALIZE). NORMALIZE returns the longest prefix of whose last entry is nonzero, or the empty list, and it represents the same polynomial.
Proof. Lines L7 and L8 remove entries from the end while the last one is zero. The removed entries are coefficients equal to 0, so the polynomial does not change. When the loop stops, the list is empty or its last entry is nonzero. Each pass removes one entry, so it stops after at most passes. By the induction hypothesis, an entry of a polynomial ring is zero exactly when it is the empty list, so the zero test is correct at every level.
Lemma 2 (ADD and MUL). ADD and MUL represent and and meet (N).
Proof. Line L1 sets , with for and for ; this is the definition of the sum, coefficient by coefficient. For MUL, if one factor is zero the product is zero (line L3). Otherwise, line L5 adds to once for each pair , so at the end , the coefficient of in , for ; there are no terms of higher degree. The sums and products of coefficients are correct and meet (N) one level down by the induction hypothesis. Lemma 1 gives (N) at the top level.
Scaling, negation, evaluation by Horner's rule and the derivative are similar: each computes the defining formula entry by entry and then normalizes.
Theorem (pseudo-division). Let , , and . PSEUDO-DIVMOD terminates and returns with and .
Proof. Write and let count the passes of the loop of line L10. We claim that at the test of line L10,
At the start , , and (line L9), so the claim holds. Suppose it holds and the body runs, so and . Let and (line L11). Line L12 gives the new values and . Then
The coefficient of in is , because is commutative, and has no term of higher degree, because has degree and has degree . So . Line L13 sets . The claim holds for .
Since falls by at least one in each pass and the loop runs only while , starting from , there are at most passes when , and none when . So the loop terminates with , and . Line L14 returns and , and
while scaling does not raise the degree of . This is the stated identity.
Uniqueness. If is not a zero divisor of , the pair is unique: if with , then . If , the left side has degree at least , because its leading coefficient is , while the right side has smaller degree. So and . Polynomial rings over or a field have no zero divisors, so this applies to every level of the recursive representation over such a base.