Algorithm Search⌘K

Proofs: Ben-Or and Tiwari algorithm

These are the human proofs of Ben-Or and Tiwari algorithm, at full length.

The Ben-Or and Tiwari algorithm recovers every polynomial with at most T terms from 2T values full

This proof shows: correctness, termination.

Let K=QK = \mathbb{Q} and f=∑j=1tcjxej∈K[x1,…,xn]f = \sum_{j=1}^{t} c_j x^{e_j} \in K[x_1, \ldots, x_n] with cj≠0c_j \ne 0, distinct ej∈Nne_j \in \mathbb{N}^n, and t≤Tt \le T. Let p1,…,pnp_1, \ldots, p_n be the first nn primes, mj=∏kpkejkm_j = \prod_k p_k^{e_{jk}}, and ai=f(p1i,…,pni)=∑jcjmjia_i = f(p_1^i, \ldots, p_n^i) = \sum_j c_j m_j^i for 0≤i<2T0 \le i < 2T, the values computed at lines L1 and L2. Let Λ(z)=∏j(z−mj)\Lambda(z) = \prod_j (z - m_j).

A recurrence of length LL for a0,…,aN−1a_0, \ldots, a_{N-1} is a monic polynomial Γ(z)=∑k=0Lγkzk\Gamma(z) = \sum_{k=0}^{L} \gamma_k z^k of degree LL with ∑k=0Lγkas+k=0\sum_{k=0}^{L} \gamma_k a_{s+k} = 0 for 0≤s≤N−1−L0 \le s \le N - 1 - L. In terms of the connection polynomial C(z)=1+C1z+⋯+CLzLC(z) = 1 + C_1 z + \cdots + C_L z^L used by Berlekamp-Massey, Γ(z)=zLC(1/z)\Gamma(z) = z^L C(1/z).

We use one known theorem. Massey's theorem (Massey 1969; MCA Section 12.3 gives an equivalent form through Padé approximation): on input a0,…,aN−1a_0, \ldots, a_{N-1}, the Berlekamp-Massey algorithm terminates after NN steps and returns a recurrence of the least possible length LL for this prefix.

Lemma 1 (distinct nodes). The mjm_j are distinct positive integers.

Proof. Each mjm_j is a product of positive primes, so it is a positive integer. If mj=mkm_j = m_k, uniqueness of prime factorization gives ejℓ=ekℓe_{j\ell} = e_{k\ell} for every ℓ\ell, so ej=eke_j = e_k and j=kj = k. □\square

Lemma 2 (the recurrence found is Λ\Lambda). The polynomial Γ\Gamma computed at line L3 equals Λ\Lambda, and t=deg⁡Γt = \deg \Gamma.

Proof. First, Λ\Lambda is a recurrence of length tt for the whole prefix: for every ss, ∑kλkas+k=∑jcjmjsΛ(mj)=0\sum_k \lambda_k a_{s+k} = \sum_j c_j m_j^s \Lambda(m_j) = 0. By Massey's theorem, line L3 returns a recurrence Γ\Gamma of least length LL, so L≤tL \le t.

Now let Γ\Gamma be any recurrence of length L≤tL \le t for a0,…,a2T−1a_0, \ldots, a_{2T-1}. Since L≤t≤TL \le t \le T, the defining relations hold for 0≤s≤2T−1−L0 \le s \le 2T - 1 - L, which includes 0≤s≤t−10 \le s \le t - 1 because 2T−1−L≥2t−1−t=t−12T - 1 - L \ge 2t - 1 - t = t - 1. For these ss,

0=∑k=0Lγkas+k=∑j=1t(cjΓ(mj))mjs.0 = \sum_{k=0}^{L} \gamma_k a_{s+k} = \sum_{j=1}^{t} \bigl(c_j \Gamma(m_j)\bigr) m_j^s .

This is a homogeneous linear system in the tt unknowns uj=cjΓ(mj)u_j = c_j \Gamma(m_j) whose matrix (mjs)0≤s<t, 1≤j≤t(m_j^s)_{0 \le s < t,\ 1 \le j \le t} is a Vandermonde matrix with distinct nodes by Lemma 1, hence nonsingular. So uj=0u_j = 0, and since cj≠0c_j \ne 0, Γ(mj)=0\Gamma(m_j) = 0 for every jj. The mjm_j are distinct, so Λ\Lambda divides Γ\Gamma. Then t≤Lt \le L, so L=tL = t, and two monic polynomials of the same degree, one dividing the other, are equal: Γ=Λ\Gamma = \Lambda.

If t=0t = 0, the argument says L=0L = 0 and Γ=1\Gamma = 1, and line L4 returns the zero polynomial, which is ff. □\square

Lemma 3 (the roots). If t≥1t \ge 1, line L5 terminates and returns m1,…,mtm_1, \ldots, m_t.

Proof. Λ\Lambda is monic with integer coefficients and the distinct integer roots mjm_j, so its discriminant Δ=∏j<k(mj−mk)2\Delta = \prod_{j < k} (m_j - m_k)^2 is a nonzero integer. The implementation tries primes qq in increasing order. For a prime q∤Δq \nmid \Delta, the mjm_j are distinct modulo qq, so Λ mod q=∏j(z−mj)\Lambda \bmod q = \prod_j (z - m_j) has exactly the tt roots mj mod qm_j \bmod q, and Λ′(mj)=∏k≠j(mj−mk)\Lambda'(m_j) = \prod_{k \ne j} (m_j - m_k) is a unit modulo qq. Only finitely many primes divide Δ\Delta, so such a qq is reached and the loop over qq terminates. For an earlier prime qq the test fails when the number of roots is not tt or a root is a root of Λ′\Lambda'; if it passes, the lifted values are still checked by exact evaluation at the end, so a wrong answer is never returned.

Fix a prime qq that passes the test and a root r0r_0 of Λ\Lambda modulo qq with Λ′(r0)≢0\Lambda'(r_0) \not\equiv 0. Since Λ≡∏j(z−mj)\Lambda \equiv \prod_j (z - m_j) and qq is prime, r0≡mj(modq)r_0 \equiv m_j \pmod q for some jj. Newton's step r′=r−Λ(r)Λ′(r)−1 mod Q2r' = r - \Lambda(r) \Lambda'(r)^{-1} \bmod Q^2, applied to r≡mj(modQ)r \equiv m_j \pmod Q, gives r′≡mj(modQ2)r' \equiv m_j \pmod{Q^2}: write r=mj+Qhr = m_j + Q h; by Taylor expansion Λ(r)≡QhΛ′(r)(modQ2)\Lambda(r) \equiv Q h \Lambda'(r) \pmod{Q^2}, so r′≡r−Qh≡mj(modQ2)r' \equiv r - Q h \equiv m_j \pmod{Q^2}. This is Hensel's lemma, and Λ′(r)\Lambda'(r) is invertible modulo Q2Q^2 because it is a unit modulo qq. The modulus is squared until it exceeds 2B2B, where B=1+max⁡k∣λk∣B = 1 + \max_k |\lambda_k| is Cauchy's bound, so ∣mj∣<B|m_j| < B. Then the symmetric representative of rr in (−Q/2,Q/2](-Q/2, Q/2] is mjm_j itself. Distinct roots modulo qq give distinct mjm_j, so all tt values are found, they satisfy Λ(mj)=0\Lambda(m_j) = 0 exactly, and the procedure returns them. □\square

Lemma 4 (the exponents). Line L6 computes eje_j from mjm_j.

Proof. Dividing mjm_j by pkp_k as long as the division is exact counts the exponent of pkp_k in mjm_j, which is ejke_{jk} by Lemma 1's factorization mj=∏kpkejkm_j = \prod_k p_k^{e_{jk}}. After all kk, the quotient is 1, so no error is raised. □\square

Lemma 5 (the coefficients). Line L7 returns c1,…,ctc_1, \ldots, c_t.

Proof. Fix jj and let Λj(z)=Λ(z)/(z−mj)=∑i=0t−1qjizi\Lambda_j(z) = \Lambda(z)/(z - m_j) = \sum_{i=0}^{t-1} q_{ji} z^i. Synthetic division computes it: comparing coefficients in Λ(z)=(z−mj)Λj(z)\Lambda(z) = (z - m_j)\Lambda_j(z) gives qj,t−1=λt=1q_{j,t-1} = \lambda_t = 1 and qj,i−1=λi+mjqjiq_{j,i-1} = \lambda_i + m_j q_{ji}, which is the loop in the implementation. Then

∑i=0t−1qjiai=∑k=1tck∑i=0t−1qjimki=∑k=1tckΛj(mk)=cjΛj(mj),\sum_{i=0}^{t-1} q_{ji} a_i = \sum_{k=1}^{t} c_k \sum_{i=0}^{t-1} q_{ji} m_k^i = \sum_{k=1}^{t} c_k \Lambda_j(m_k) = c_j \Lambda_j(m_j),

because Λj(mk)=0\Lambda_j(m_k) = 0 for k≠jk \ne j. Finally Λj(mj)=Λ′(mj)=∏k≠j(mj−mk)≠0\Lambda_j(m_j) = \Lambda'(m_j) = \prod_{k \ne j}(m_j - m_k) \ne 0 by Lemma 1, so the division in the implementation gives cjc_j. The system of line L7 has a nonsingular Vandermonde matrix, so this is its unique solution. □\square

Theorem. If f∈Q[x1,…,xn]f \in \mathbb{Q}[x_1, \ldots, x_n] has at most TT terms, BEN-OR-TIWARI(f,n,T)(f, n, T) terminates after exactly 2T2T evaluations and returns ff.

Proof. Lines L1 and L2 make 2T2T evaluations and stop. Line L3 terminates by Massey's theorem and, by Lemma 2, returns Λ\Lambda and the true number of terms tt. If t=0t = 0 then f=0f = 0 is returned at line L4. Otherwise Lemmas 3, 4 and 5 show that lines L5, L6 and L7 terminate and produce the roots mjm_j, the exponent vectors eje_j and the coefficients cjc_j, all nonzero. Line L8 returns ∑jcjxej=f\sum_j c_j x^{e_j} = f. ■\blacksquare

Back to Ben-Or and Tiwari algorithm