Algorithm Search⌘K

Proofs: Zippel's sparse interpolation

These are the human proofs of Zippel's sparse interpolation, at full length.

Zippel's algorithm interpolates correctly with high probability full

This proof shows: correctness.

Setting. K=Z/pZK = \mathbb{Z}/p\mathbb{Z} with pp prime. The polynomial f∈K[x1,…,xn]f \in K[x_1, \ldots, x_n] has tt terms and degree at most dd in each variable, with d<p−1d < p - 1. For 1≤i≤n1 \le i \le n, write

f=∑m∈Mici,m(xi+1,…,xn) m,f = \sum_{m \in M_i} c_{i,m}(x_{i+1}, \ldots, x_n)\, m,

where MiM_i is the set of monomials mm in x1,…,xix_1, \ldots, x_i with ci,m≠0c_{i,m} \ne 0. So MnM_n is the support of ff, ∣Mi∣≤t|M_i| \le t, and every m∈Mi+1m \in M_{i+1} has the form m′xi+1em' x_{i+1}^e with m′∈Mim' \in M_i. The anchor a2,…,ana_2, \ldots, a_n is chosen uniformly from {1,…,p−1}\{1, \ldots, p - 1\}.

Let AA be the event that ci,m(ai+1,…,an)≠0c_{i,m}(a_{i+1}, \ldots, a_n) \ne 0 for all 1≤i≤n−11 \le i \le n - 1 and all m∈Mim \in M_i.

Theorem. (a) The algorithm makes at most (d+1)(1+(n−1)t)(d + 1)(1 + (n - 1) t) probes and stops with probability 11. (b) If AA holds, the output is ff. (c) Pr⁡[A]≥1−n(n−1)dt/(2(p−1))\Pr[A] \ge 1 - n(n - 1) d t / \bigl(2(p - 1)\bigr).

Lemma 1 (dense interpolation and the Vandermonde solve)

A polynomial in one variable of degree at most dd is determined by its values at d+1d + 1 distinct points, and interp_dense returns its coefficients. If v1,…,vTv_1, \ldots, v_T are distinct, the system ∑mcmvmk=wk\sum_m c_m v_m^k = w_k, 0≤k<T0 \le 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 KK. For the second, the matrix (vmk)(v_m^k) is a Vandermonde matrix with distinct nodes, so it is invertible. Let Λ(z)=∏m(z−vm)\Lambda(z) = \prod_m (z - v_m) and Λm(z)=Λ(z)/(z−vm)=∑kλm,kzk\Lambda_m(z) = \Lambda(z) / (z - v_m) = \sum_k \lambda_{m,k} z^k. Then ∑kλm,kwk=∑m′cm′Λm(vm′)=cmΛm(vm)\sum_k \lambda_{m,k} w_k = \sum_{m'} c_{m'} \Lambda_m(v_{m'}) = c_m \Lambda_m(v_m), since Λm(vm′)=0\Lambda_m(v_{m'}) = 0 for m′≠mm' \ne m, and Λm(vm)=∏m′≠m(vm−vm′)≠0\Lambda_m(v_m) = \prod_{m' \ne m} (v_m - v_{m'}) \ne 0. This is the formula in the code, with Λm\Lambda_m computed by synthetic division. □\square

Lemma 2 (one stage)

Let 1≤i≤n−11 \le i \le n - 1, and suppose the skeleton before step L4 is MiM_i, with the coefficient of mm equal to ci,m(ai+1,…,an)c_{i,m}(a_{i+1}, \ldots, a_n). Then after step L7 the skeleton is {m∈Mi+1:ci+1,m(ai+2,…,an)≠0}\{ m \in M_{i+1} : c_{i+1,m}(a_{i+2}, \ldots, a_n) \ne 0 \}, with these values as coefficients. (For i+1=ni + 1 = n, read cn,mc_{n,m} as the coefficients of ff, which are nonzero.)

Proof. Fix one of the values bb of step L5. The polynomial gb=f(x1,…,xi,b,ai+2,…,an)g_b = f(x_1, \ldots, x_i, b, a_{i+2}, \ldots, a_n) equals ∑m∈Mici,m(b,ai+2,…,an) m\sum_{m \in M_i} c_{i,m}(b, a_{i+2}, \ldots, a_n)\, m, so its support is contained in MiM_i. This holds for every bb, with no condition on the random choices. With vm=m(r1,…,ri)v_m = m(r_1, \ldots, r_i), the probe at (r1k,…,rik)(r_1^k, \ldots, r_i^k) is ∑mci,m(b,…) vmk\sum_m c_{i,m}(b, \ldots)\, v_m^k. Step L4 ensures that the vmv_m are distinct, so by Lemma 1, step L6 returns ci,m(b,ai+2,…,an)c_{i,m}(b, a_{i+2}, \ldots, a_n) for every m∈Mim \in M_i. As a polynomial in xi+1x_{i+1}, ci,m(xi+1,ai+2,…,an)c_{i,m}(x_{i+1}, a_{i+2}, \ldots, a_n) has degree at most dd, and the d+1d + 1 values bb are distinct, so by Lemma 1 step L7 recovers it. Its coefficient of xi+1ex_{i+1}^e is ci+1,mxi+1e(ai+2,…,an)c_{i+1, m x_{i+1}^e}(a_{i+2}, \ldots, a_n), and this is 00 when mxi+1e∉Mi+1m x_{i+1}^e \notin M_{i+1}. Every element of Mi+1M_{i+1} has this form for some m∈Mim \in M_i. So the new skeleton is as claimed. □\square

Proof of the theorem

(a) Step L2 makes d+1d + 1 probes. For i≥1i \ge 1, the stage that adds xi+1x_{i+1} makes (d+1)(d + 1) times the size of the skeleton probes, and by Lemma 2 the skeleton is a subset of MiM_i, so it has at most tt elements. This gives the bound. Step L4 probes nothing. Each trial there fails only if m(r)=m′(r)m(r) = m'(r) for some distinct m,m′m, m' in the skeleton. The polynomial m−m′m - m' is nonzero of total degree at most idi d, so by the Schwartz-Zippel lemma a trial fails with probability at most (T2)id/(p−1)\binom{T}{2} i d / (p - 1). If this is below 11, the number of trials is finite with probability 11 (a geometric number of trials). Otherwise, when pp is very small, distinctness can be impossible. The code assumes pp is large compared with t2ndt^2 n d.

(b) By Lemma 1, step L2 returns f(x1,a2,…,an)=∑m∈M1c1,m(a2,…,an) mf(x_1, a_2, \ldots, a_n) = \sum_{m \in M_1} c_{1,m}(a_2, \ldots, a_n)\, m, and under AA all these coefficients are nonzero. So the skeleton is M1M_1 with the values that Lemma 2 needs. By induction with Lemma 2, under AA the skeleton after the stage for xi+1x_{i+1} is Mi+1M_{i+1} with coefficients ci+1,m(ai+2,…,an)c_{i+1,m}(a_{i+2}, \ldots, a_n). After the last stage it is MnM_n with the coefficients of ff. The early return for an empty skeleton is correct under AA: an empty M1M_1 means f=0f = 0.

(c) For each i≤n−1i \le n - 1 and m∈Mim \in M_i, ci,mc_{i,m} is a nonzero polynomial in xi+1,…,xnx_{i+1}, \ldots, x_n of total degree at most (n−i)d(n - i) d. By the Schwartz-Zippel lemma, with the anchor uniform on a set of p−1p - 1 elements, Pr⁡[ci,m(a)=0]≤(n−i)d/(p−1)\Pr[c_{i,m}(a) = 0] \le (n - i) d / (p - 1). A union bound over at most tt monomials for each ii gives

Pr⁡[not A]≤∑i=1n−1t(n−i)dp−1=n(n−1)dt2(p−1).■\Pr[\text{not } A] \le \sum_{i=1}^{n-1} \frac{t (n - i) d}{p - 1} = \frac{n (n - 1) d t}{2 (p - 1)}. \qquad \blacksquare

Remark. Without AA, 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)1 - n d / (p - 1), by the Schwartz-Zippel lemma applied to the difference.

Back to Zippel's sparse interpolation