Polynomial Identity Testing

DeMillo-Lipton-Schwartz–Zippel Lemma

Let PP be a non-zero polynomial on nn variables of degree dd.
Let SS be the set of size at least d+1d + 1.
We randomly sample nn values, a1,a2,,aia_{1}, a_{2}, \dots, a_{i} from SS independently, uniformly and randomly. The theorem states that

P[P(a1,a2,,an)=0]dS\mathbb{P}[P(a_{1}, a_{2}, \dots, a_{n}) = 0] \leq \frac{d}{|S|}

Proof

Proof using mathematical induction on nn.
Base Case - n=1n = 1
We know that a dd-degree polynomial can have at most dd roots (Fundamental theorem of algebra). Hence, the bound holds true for n=1n = 1 variable polynomials.
Induction state - Assume it’s true for nk1n \leq k - 1, prove for n=kn = k
We have the variables x1,x2,,xnx_{1}, x_{2}, \dots, x_{n}
We can restructure the nn variable polynomial in terms of coefficients of x1x_{1}

P(x1,,xn)=i=0dx1iPi(x2,,xn)P(x_{1}, \dots, x_{n}) = \sum\limits_{i=0}^{d}x_{1}^{i}P_{i}(x_{2}, \dots, x_{n})

From our initial assumption, it’s known that PP is not identically 00, therefore we find the largest ii such that PiP_{i} is not identically 00.
Note that for any ii, degPidi\operatorname{deg} P_{i} \leq d - i, as the degree of x1iPix_{1}^{i}P_{i} is at most dd

We aim to prove the bound defined by the lemma using this structure

P[A]=P[AB]+P[ABc]=P[AB]P[B]+P[ABc]P[Bc]P[B]+P[ABc]\begin{aligned} \mathbb{P}[A] &= \mathbb{P}[A \cap B] + \mathbb{P}[A \cap B^{c}]\\ &= \mathbb{P}[A | B] \mathbb{P}[B] + \mathbb{P}[A | B^{c}]\mathbb{P}[B^{c}]\\ & \leq \mathbb{P}[B]+ \mathbb{P}[A | B^{c}] \end{aligned}

Here, we define events A,BA, B as\

A: P(r1,r2,,rn)=0B: Pi(r2,r3,,rn)=0\begin{aligned} A:\ P(r_{1}, r_{2}, \dots, r_{n}) = 0\\ B:\ P_{i}(r_{2}, r_{3}, \dots, r_{n}) = 0 \end{aligned}

Where rir_{i} are independently, uniformly, and randomly (i.u.a.r) sampled from SS.

P[B]\mathbb{P}[B]

We know that the degree of PiP_{i} is di\leq d - i. Therefore, by the induction hypothesis, for an n1n - 1 variable polynomial we get

P[Pi(r2,r3,,rn)=0]diS\mathbb{P}[P_{i}(r_{2}, r_{3}, \dots, r_{n}) = 0] \leq \frac{d-i}{|S|}

P[ABc]\mathbb{P}[A | B^{c}]

If Pi(r2,r3,,rn)0P_{i}(r_{2}, r_{3}, \dots, r_{n}) \neq 0, BcB^{c} occurs, we now know that the degree of the polynomial PP is ii, since all the Pj0,j>iP_{j} \equiv 0, \forall j > i. We can plug in the values of r2,r3,,rnr_{2}, r_{3}, \dots, r_{n}, and get an ii-degree univariate polynomial in terms of xix_{i}.

Therefore, with the help of the induction hypothesis, for a univariate polynomial we can say that

P[P(r1,r2,,rn)=0Pi(r2,r3,,rn)0]iS\mathbb{P}[P(r_{1}, r_{2}, \dots, r_{n}) = 0 | P_{i}(r_{2}, r_{3}, \dots, r_{n}) \neq 0] \leq \frac{i}{|S|}

P[A]\mathbb{P}[A]

Therefore, we get

P[P(r1,r2,,rn)=0]P[B]+P[ABc]diS+iS=dS\begin{aligned} \mathbb{P}[P(r_{1}, r_{2}, \dots, r_{n}) = 0] &\leq \mathbb{P}[B] + \mathbb{P}[A | B^{c}]\\ & \leq \frac{d-i}{|S|} + \frac{i}{|S|} = \frac{d}{|S|} \end{aligned}

Hence, proved.

Using this lemma, we can test if two multivariate polynomials f,gf, g are equal by identity testing polynomial h=fgh = f - g.

Randomized Algorithm for Polynomial Identity Testing

  1. Pick a set SS of size αd\alpha d, where α>1\alpha > 1
  2. Evaluate at a point aˉ\bar a (a vector of size nn) whose corrdinates are sample i.u.a.r from SS.
  3. If f(aˉ)=0f(\bar a) = 0 assert f0f \equiv 0, else f≢0f \not \equiv 0 .
P[Error]dS=1α\mathbb{P} [\text{Error}] \leq \frac{d}{|S|}= \frac{1}{\alpha}

The possible error is that a non-zero polynomial is asserted as a zero-polynomial.

Verifying Matrix Multiplication

An application of Polynomial Identity Testing is verifying matrix multiplication
Given matrices A,B,CA, B, C, we need to verify if AB=CAB = C.

This can be done in O(nw)O(n^{w}) (ww is the matrix multiplication exponent), but we can speed this up using randomization.

Let SS be a finite subset of R\mathbb{R}, and we choose xˉ=(x1,x2,,xn)\bar x = (x_{1}, x_{2}, \dots, x_{n}) i.u.a.r
We then verify if ABx=CxABx = Cx. If true, we say that AB=CAB = C, else return ABCAB \neq C.
Running this takes O(n2)O(n^{2}) time, as finding BxBx, A(Bx)A(Bx) and CxCx are all O(n2)O(n^{2}) time operations.

Probability Analysis

ABx,CxABx, Cx are both vectors, whose entries are linear forms in xx.

ABx=(L1(x),L2(x),,Ln(x))TCx=(L1(x),L2(x),,Ln(x))T\begin{aligned} ABx &= (L_{1}(x), L_{2}(x), \dots, L_{n}(x))^T\\ Cx &= (L_{1}'(x), L_{2}'(x), \dots, L_{n}'(x))^T \end{aligned}

If AB=CAB=C, then we know that xˉ,ABxˉ=Cxˉ\forall \bar x, AB\bar x = C \bar x, which essentially means
1in,Li(xˉ)Li(xˉ)=0\forall 1 \leq i \leq n, L_{i}(\bar x) - L_{i}'(\bar x)= 0
If ABCAB \neq C, then there exists some vector xˉ\bar x such that Li(xˉ)Li(xˉ)0L_{i}(\bar x) - L_{i}'(\bar x) \neq 0

Lemma - For any linear polynomial L(x)L(x)

P[L(aˉ)=0]1S\mathbb{P}[L(\bar a) = 0] \leq \frac{1}{|S|}

Proof - We can arrive to this result using the principle of deferred decision.

We know that we can represent L(x)L(x) as

L(x)=i=1nbixiL(x) = \sum\limits_{i=1}^{n}b_{i}x_{i}

Assume we randomly pick the first n1n - 1 values for xx as a1,a2,,an1a_{1}, a_{2}, \dots, a_{n-1}, we’d get

L(x)=bnxn+i=1n1biaiL(x) = b_{n}x_{n} + \sum\limits_{i=1}^{n -1}b_{i}a_{i}

For L(x)=0L(x) = 0,

bnxn=i=1n1biaib_{n}x_{n}= -\sum\limits_{i=1}^{n -1}b_{i}a_{i}

There is at max 11 possible value for xnx_{n} in SS for which this equality holds true, hence the probability of this being true is 1S\leq \frac{1}{|S|}.

Claim - If ABCAB \neq C, then P[ABx=Cx]1S\mathbb{P}[ABx = Cx] \leq \frac{1}{|S|}
Proof - When ABCAB \neq C, we say a bad event is when Li(xˉ)Li(xˉ)=0 i[n]L_{i}(\bar x) - L_{i}'(\bar x) =0\ \forall i \in [n], i.e we picked a vector such that ABx=CxABx = Cx event when ABCAB \neq C, which causes us to incorrectly say that AB=CAB = C.

The probability of the bad event occurring is bounded by

P[i=1n(Li(xˉ)Li(xˉ)=0)]maxi{P[Li(xˉ)Li(xˉ)=0]}\mathbb{P}\left[\bigwedge_{i=1}^{n}(L_{i}(\bar x) - L_{i}'(\bar x) = 0)\right] \leq \max_{i}\left\{\mathbb{P}[L_{i}(\bar x) - L_{i}'(\bar x) = 0]\right\}

And using the earlier Lemma, we can bound this further, giving us

P[i=1n(Li(xˉ)Li(xˉ)=0)]maxi{P[Li(xˉ)Li(xˉ)=0]}1S\mathbb{P}\left[\bigwedge_{i=1}^{n}(L_{i}(\bar x) - L_{i}'(\bar x) = 0)\right] \leq \max_{i}\left\{\mathbb{P}[L_{i}(\bar x) - L_{i}'(\bar x) = 0]\right\} \leq \frac{1}{|S|}

Hence proved.

Published Feb 2, 2023