This week I have been at the IPAM workshop on expander graphs, scheduled so that we could spend Valentine’s day attending lectures, thus symbolically demonstrating our love for math.

My talk was on the problem of checking whether a given hypergraph is an expander, focusing on the expansion property that is known as “quasirandomness.”

Because of the workshop, my Complexity class took a one-week break.

Last week, we talked about one of my favorite “elementary” results in complexity theory: approximate counting with an NP oracle.

Suppose that someone comes up with a polynomial time algorithm for SAT and proves that P=NP; then we know that a number of awesome consequences would follow (and some frightening ones, such as the impossibility of cryptography). We would still, however, not be able to solve combinatorial counting problems such as: given a graph, how many proper 3-colorings does it have, if any?

If the number of colorings is , we can compute it in time polynomial in , because the question “is the number of colorings at least ?” can be reduced to a SAT instance of size polynomial in and in the size of the graph. We might, however, be given a graph with vertices and a number of 3-colorings in the ballpark of . Then, even the awesome power of a polynomial time algorithm for SAT does not seem to help. Indeed it follows from Toda’s Theorem that, if one could solve the 3-coloring counting problem efficiently using a SAT oracle, then the polynomial hierarchy would collapse. (If the previous sentence did not make sense to you, let’s just say that there is good evidence that there is no algorithm that solves the 3-coloring counting problem efficiently by “just relying” on an efficient algorithm for SAT.)

Interestingly enough, however, we can *approximately* count solutions to any NP problem in probabilistic polynomial time, given an oracle for SAT. The idea is cleverly simple. Suppose we have some guess for the number of 3-colorings (for concreteness I continue to talk about 3-coloring, but the argument works for any NP counting problem), and we want to distinguish the cases in which is roughly right, or much higher, or much lower then the right count. If we can do that, then we can do binary search on until we find a “roughly right” value. (In fact, we don’t need to do binary search, we can try and we only need to make tries, where is the number of vertices, in order to get a constant-factor approximation.)

Here is the idea: identify colorings with elements of , where is the number of vertices, pick a random function and consider the question of how many 3-colorings are there that are: (i) proper colorings, and (ii) such that . If the number of proper 3-colorings is roughly , then the expected number of proper 3-colorings satisfying (ii) is around 100, with a standard deviation around 10, so there is a good probability that it is between 70 and 130, otherwise it would be more than 3 standard deviations from its mean. If the number of proper 3-coloring is much more than , say it’s more than , then very likely the number of proper 3-colorings mapping to 1 is more than 130, as otherwise it would be 4 standard deviations or more away from its mean. Similarly, it the number of proper 3-colorings is less than then it’s likely that fewer than 70 will map to 1.

Since we only need Chebyshev’s inequality in the above calculations, it is not necessary that be picked as a random function , but it is enough if is selected from a distribution of “pairwise independent hash functions,” that is a distribution such that, for every two inputs , if we pick at random from the family, then the values are independent and uniformly distributed in . It is not hard to see that if we pick a random matrix and a random vector , then the function defined as

is a pairwise independent hash function.

Our algorithm to check if the number of 3-colorings in a given graph is in the ballpark of is then to pick a pairwise independent hash function where and then check whether the number of proper 3-colorings in the graph such that is around 100. This is a problem that can solved with an NP oracle.

(There are a few more details one needs to work out: e.g. the above works well if is a large enough constants. For small we can do an exact calculation using the NP oracle as discussed at the beginning of the post. So far we are only getting a constant-factor approximation, but there are simple ways – that the reader is invited to reconstruct – to convert an algorithm that achieves an factor approximation for the number of proper 3-colorings into an algorithm that achieves , or even approximation. Alternatively, the analysis can be sharpened to directly give , or even approximation.)

Dear Luca,

Is there a family of pairwise independent hash functions from to for any (sufficiently large) positive integers and ?

Any pointer/suggestion is much appreciated.

Indeed [P=NP]. [MMM].