1. Polynomial Identity Testing
In the first lecture we discussed the problem of testing equality of two bitstrings in a distributed setting. We reduced that problem to the problem of testing whether a certain polynomial is the zero polynomial. That was our first glimpse of polynomial identity testing (PIT).
Let us now define the general PIT problem, while still being a bit vague. Given two multivariate polynomials and over some field , we would like to decide if they are equal. Note that this is equivalent to deciding if their difference is zero. This equivalent form is often more convenient to think about because it only involves the single polynomial . So we could also define PIT to be: given a polynomial over some field , decide if is zero.
You might think this problem is rather dull and algebraic, but it actually captures many interesting and natural computational problems. For example, we’ve already seen that testing equality of strings reduces to PIT (even univariate PIT). We’ll see another example in Section 2.
Next we discuss an important way in which our definition of PIT is too vague.
What is a zero polynomial? Our definition of PIT did not say precisely what it means for to be zero. There are two possible meanings, which lead to two different computational problems. Our desired definition of PIT uses the second meaning.
- The Evaluates to Zero Everywhere(EZE) problem. Given a polynomial over , we must decide whether, for every choice of numbers , the value of is the number .
- The Polynomial Identity Testing (PIT) problem. Given a polynomial , we can write it as a sum over monomials with various coefficients. For example, given , we can expand it into a sum of monomials as
The problem is to decide whether, after expanding into monomials, are all coefficients of those monomials equal to zero? If so, we say that is the zero polynomial, or that it is identically zero.
It might never have occurred to you that EZE and PIT are different problems. If is identically zero then definitely it evaluates to zero everywhere. Is the converse true? Over any infinite field, like or , the converse is true: a polynomial evaluates to zero at every point if and only if it is identically zero. But over finite fields the converse is not true, so EZE and PIT are different problems. For example, the univariate polynomial over is not identically zero but and .
It is worth pointing out that trivial approaches do not solve these problems efficiently. The trivial approach for EZE is to exhaustively try every possible choice of numbers and evaluate . This requires evaluations. The trivial approach for PIT is to explicitly expand the polynomial into monomials, but if has degree then there can be such monomials, which is exponential in .
Let me also clarify what is meant by the degree of a multivariate polynomial (or even monomial). A monomial is any expression of the form where and are non-negative integers. The total degree of that monomial is . The total degree of a polynomial is defined to be the largest total degree of its monomials.
Our definitions of EZE and PIT are still vague in another important way.
How to represent a polynomial? What does it mean to be given a polynomial? One natural definition is to allow to be presented as an explicit algebraic formula involving only the variables , any numbers in , parentheses, and the operations of addition, subtraction and multiplication. For example, .
Alternatively, we could allow to be presented as a “black box”, meaning that we do not have an explicit representation of but our algorithms are allowed to evaluate by plugging in any desired numbers for . This is useful because we might have some weird representation for that is not an explicit formula. For example, let
Then is actually a polynomial in of total degree at most . We can easily choose numeric values for and evaluate at that point simply by plugging those numbers into the matrix and computing the determinant numerically. But it might be the case that does not have a concise representation as an explicit formula. (In this particular example the matrix is a Vandermonde matrix, and the explicit formula is known.)
For our purposes, it does not matter whether the polynomial is given as an explicit formula or as a black box. We discuss this issue further in Section 1.
1.1. Complexity Status
Unfortunately EZE is coNP-hard. There is a simple procedure to encode any 3SAT formula as a polynomial over such that the polynomial evaluates to zero everywhere if and only if the formula is unsatisfiable.
The complexity status of PIT is much more interesting. We will show that there is a randomized algorithm to decide PIT. However, there is no known deterministic algorithm for deciding PIT. Furthermore, if a deterministic algorithm existed then there would be remarkable consequences in complexity theory.
1.2. The Schwartz-Zippel Lemma
The main tool that we will use today is the Schwartz-Zippel lemma.
Lemma 1 Let be a polynomial of total degree . Assume that is not identically zero. Let be any finite set. Then, if we pick independently and uniformly from ,
To help understand the lemma, consider the case of polynomials over . The theorem says that if we evaluate at a random point, then we have small probability of seeing a root. Does that mean that polynomials over have finitely many roots? No! Consider the polynomial which has total degree . It has infinitely many roots because setting and to anything gives a root. However, if we fix and randomly choose then our probability of seeing a root is exactly , which matches the bound given by the Schwartz-Zippel lemma.
It is also worth noting that the conclusion of the theorem does not depend on .
Proof: We proceed by induction on .
The base case is the case , which is the univariate case we discussed in the first lecture. We claimed that any univariate polynomial of degree has at most roots. (The reason is that any univariate polynomial of degree factors uniquely into at most irreducible polynomials, each of which has at most one root.) So, the probability that is a root is at most .
Now we assume the theorem is true for polynomials with variables, and we prove it for those with variables. The main idea is to obtain polynomials with fewer variables by factoring out the variable from . Let be the largest power of appearing in any monomial of . Then
By our choice of , the polynomial is not identically zero. Furthermore its total degree is at most , so by induction
Define to be the event “”.
Let us now randomly choose the values of and assume that the event did not occur. Define to be the univariate polynomial
Since did not occur, the coefficient of in is non-zero, so is not identically zero. By the argument of our base case,
Define to be the event “”. By definition of , is equivalent to “”.
We’re almost done. The goal of the lemma is to bound , and so far we’ve bounded and . By a few manipulations, we get
which finishes the proof.
1.3. Solving PIT
With the Schwartz-Zippel lemma in hand, we can easily solve PIT. Suppose we are given a polynomial of total degree . Assume that . (For more on this point, see Section 1.)
Our algorithm simply picks uniformly and independently from (or if is infinite, a suitably large finite subset of ). If evaluates to a non-zero value, the algorithm announces that “ is not identically zero”. In this case we will never make an error: we have conclusive proof that is not identically zero. Otherwise, if , the algorithm announces that “ is identically zero”. In this case the Schwartz-Zippel lemma shows that probability of error is at most .
We can decrease the probability of error to any desired level by repeating the algorithm multiple times. This is the amplification by independent trials trick. For example, even if , then repeating the algorithm times reduces the probability of failure to at most
1.4. Further Discussion of Complexity Status
Our randomized algorithm above assumed that had total degree . Under that assumption, the Schwartz-Zippel lemma implies that any polynomial that evaluates to zero everywhere must be identically zero. Therefore, under the assumption that , the problems EZE and PIT are actually equivalent, so they can both be solved by our randomized algorithm. This also explains why EZE and PIT are equivalent for infinite fields.
It remains to discuss the case . In this case:
- EZE is NP-hard as mentioned above.
- PIT in the black box model cannot be solved. This is because there are polynomials which are not identically zero, but evaluate to zero everywhere (such as over ) and these cannot be distinguished from the identically zero polynomial.
- PIT in the explicit formula model is solvable! Since , the Schwartz-Zippel lemma does not give any useful information about the number of roots. The trick is to use a field extensionof . Any finite field can be extended to larger finite field which contains as a subfield. So instead of viewing as a polynomial over , we view it as a polynomial over a larger field with . This preserves the property of being identically zero, so we can simply run our randomized algorithm for over the field .
2. Bipartite Matching
We conclude by describing using PIT to solve the Bipartite Matching problem.
Let be a bipartite graph, meaning that and are disjoint sets of vertices, and every edge in has exactly one endpoint in and exactly one endpoint in . A matching in is a set of edges that share no endpoints. A perfect matching in is a set of edges such that every vertex is contained in exactly one edge of .
Polynomial time algorithms are known to decide if has a perfect matching, and even to construct such a matching. We will give a randomized algorithm to decide if has a perfect matching, by reducing that problem to PIT.
Let be the matrix whose rows are indexed by the vertices in and columns are indexed by the vertices in . The entries of are:
where are distinct variables.
Claim 1 is identically zero if and only if has no perfect matching.
Proof: By the Leibniz formula for determinants,
where the sum is over all bijections and is a function taking values in whose definition is irrelevant for our purposes.
The key observation is that a bijection from to is simply a pairing of elements in and elements in such that each vertex appears in exactly one pair. This is almost the same as our definition of a perfect matching. If each of those pairs were an edge in , then that pairing would be exactly a perfect matching in .
Conveniently, the monomial tells us exactly when that happens. More precisely, is a non-zero monomial if and only if corresponds to a perfect matching in . Furthermore, since all of these monomials involve distinct sets of variables, there can be no cancellations when we add up the monomials.
Therefore appears as a monomial in (possibly with a minus sign) if and only if corresponds to a matching in .
This claim yields the following algorithm for testing if a bipartite graph has a perfect matching. Let be any field of size at least . We can view as a polynomial over since all coefficients of its monomials are and . Assign every variable a random value from . Compute the numeric determinant . If the determinant is zero, say “ has no perfect matching”. Otherwise, say “ has a perfect matching”. Since has degree the Schwartz-Zippel lemma implies that the failure probability of this algorithm is at most .