Zippel's algorithm interpolates correctly with high probability full
This proof shows: correctness.
Setting. K=Z/pZ with p prime. The polynomial f∈K[x1,…,xn] has t terms and degree at most d in each variable, with d<p−1. For 1≤i≤n, write
f=m∈Mi∑ci,m(xi+1,…,xn)m, where Mi is the set of monomials m in x1,…,xi with ci,m=0. So Mn is the support of f, ∣Mi∣≤t, and every m∈Mi+1 has the form m′xi+1e with m′∈Mi. The anchor a2,…,an is chosen uniformly from {1,…,p−1}.
Let A be the event that ci,m(ai+1,…,an)=0 for all 1≤i≤n−1 and all m∈Mi.
Theorem. (a) The algorithm makes at most (d+1)(1+(n−1)t) probes and stops with probability 1. (b) If A holds, the output is f. (c) Pr[A]≥1−n(n−1)dt/(2(p−1)).
Lemma 1 (dense interpolation and the Vandermonde solve)
A polynomial in one variable of degree at most d is determined by its values at d+1 distinct points, and interp_dense returns its coefficients. If v1,…,vT are distinct, the system ∑mcmvmk=wk, 0≤k<T, has exactly one solution, and solve_vandermonde returns it.
Proof. The first claim is Newton interpolation: the divided differences give the Newton form, and Horner's rule converts it to the monomial form, all in the field K. For the second, the matrix (vmk) is a Vandermonde matrix with distinct nodes, so it is invertible. Let Λ(z)=∏m(z−vm) and Λm(z)=Λ(z)/(z−vm)=∑kλm,kzk. Then ∑kλm,kwk=∑m′cm′Λm(vm′)=cmΛm(vm), since Λm(vm′)=0 for m′=m, and Λm(vm)=∏m′=m(vm−vm′)=0. This is the formula in the code, with Λm computed by synthetic division. □
Lemma 2 (one stage)
Let 1≤i≤n−1, and suppose the skeleton before step L4 is Mi, with the coefficient of m equal to ci,m(ai+1,…,an). Then after step L7 the skeleton is {m∈Mi+1:ci+1,m(ai+2,…,an)=0}, with these values as coefficients. (For i+1=n, read cn,m as the coefficients of f, which are nonzero.)
Proof. Fix one of the values b of step L5. The polynomial gb=f(x1,…,xi,b,ai+2,…,an) equals ∑m∈Mici,m(b,ai+2,…,an)m, so its support is contained in Mi. This holds for every b, with no condition on the random choices. With vm=m(r1,…,ri), the probe at (r1k,…,rik) is ∑mci,m(b,…)vmk. Step L4 ensures that the vm are distinct, so by Lemma 1, step L6 returns ci,m(b,ai+2,…,an) for every m∈Mi. As a polynomial in xi+1, ci,m(xi+1,ai+2,…,an) has degree at most d, and the d+1 values b are distinct, so by Lemma 1 step L7 recovers it. Its coefficient of xi+1e is ci+1,mxi+1e(ai+2,…,an), and this is 0 when mxi+1e∈/Mi+1. Every element of Mi+1 has this form for some m∈Mi. So the new skeleton is as claimed. □
Proof of the theorem
(a) Step L2 makes d+1 probes. For i≥1, the stage that adds xi+1 makes (d+1) times the size of the skeleton probes, and by Lemma 2 the skeleton is a subset of Mi, so it has at most t elements. This gives the bound. Step L4 probes nothing. Each trial there fails only if m(r)=m′(r) for some distinct m,m′ in the skeleton. The polynomial m−m′ is nonzero of total degree at most id, so by the Schwartz-Zippel lemma a trial fails with probability at most (2T)id/(p−1). If this is below 1, the number of trials is finite with probability 1 (a geometric number of trials). Otherwise, when p is very small, distinctness can be impossible. The code assumes p is large compared with t2nd.
(b) By Lemma 1, step L2 returns f(x1,a2,…,an)=∑m∈M1c1,m(a2,…,an)m, and under A all these coefficients are nonzero. So the skeleton is M1 with the values that Lemma 2 needs. By induction with Lemma 2, under A the skeleton after the stage for xi+1 is Mi+1 with coefficients ci+1,m(ai+2,…,an). After the last stage it is Mn with the coefficients of f. The early return for an empty skeleton is correct under A: an empty M1 means f=0.
(c) For each i≤n−1 and m∈Mi, ci,m is a nonzero polynomial in xi+1,…,xn of total degree at most (n−i)d. By the Schwartz-Zippel lemma, with the anchor uniform on a set of p−1 elements, Pr[ci,m(a)=0]≤(n−i)d/(p−1). A union bound over at most t monomials for each i gives
Pr[not A]≤i=1∑n−1p−1t(n−i)d=2(p−1)n(n−1)dt.■ Remark. Without A, the algorithm can lose a term and return a wrong polynomial without an error. One extra probe at a random point detects this with probability at least 1−nd/(p−1), by the Schwartz-Zippel lemma applied to the difference.