Probabilistic Polynomials and Hamming Nearest Neighbors

Josh Alman, Ryan Williams

Abstract

Finding the exact nearest neighbor in high-dimensional Hamming space has long been a computational bottleneck, typically requiring either quadratic time in the number of points or exponential time in the dimension. This paper presents a novel construction for probabilistic polynomials that compute symmetric Boolean functions, such as MAJORITY, with an optimal degree bound of $O(\sqrt{n \log(1/\epsilon)})$. By leveraging these low-degree polynomials within the framework of fast matrix multiplication, we provide the first truly subquadratic time algorithm for the exact Batch Hamming Nearest Neighbor (BHNN) problem in superlogarithmic dimensions, effectively breaking a long-standing algorithmic barrier.

Introduction

The search for the closest pair of points in high-dimensional space is a fundamental challenge across computer science, with applications ranging from error-correcting codes to machine learning and information retrieval. In high dimensions, this problem is notoriously difficult—a phenomenon often referred to as the "curse of dimensionality." While approximate solutions, such as Locality Sensitive Hashing (LSH), offer efficiency at the cost of precision, exact solutions have historically been constrained to $O(n^2)$ brute-force comparisons or $O(n 2^d)$ lookup-based approaches.

This research addresses the Batch Hamming Nearest Neighbor (BHNN) problem: given a database of $n$ vectors and $n$ query vectors in a $d$-dimensional Hamming space (where $d > \log n$), the goal is to find the exact nearest neighbor for every query. We demonstrate that by refining the polynomial method in algorithm design, it is possible to bypass the quadratic complexity threshold for dimensions significantly larger than previously thought possible.

Methods: The Polynomial Method and Fast Matrix Multiplication

The core of our approach lies in the polynomial method, which transforms a discrete computational problem into the evaluation of a multivariate polynomial. To determine if two vectors have a small Hamming distance, one must essentially compute a variation of the MAJORITY function on their bitwise differences.

1. Optimal Probabilistic Polynomials

We construct a probabilistic polynomial—a distribution of polynomials that correctly computes a function with probability at least $1-\epsilon$. Our construction for the MAJORITY function utilizes a recursive sampling strategy. By sampling a fraction of the inputs, the algorithm estimates whether the Hamming weight is significantly far from the threshold. If the weight is close to the threshold, the algorithm falls back to an exact interpolating polynomial. This strategy achieves a degree of $O(\sqrt{n \log(1/\epsilon)})$, which we prove is optimal for all symmetric Boolean functions.

2. Evaluation via Fast Matrix Multiplication

The efficiency of the BHNN algorithm depends on how quickly these polynomials can be evaluated over all $n^2$ pairs of points. By maintaining an incredibly low polynomial degree, the number of resulting monomials remains manageable. We embed the evaluation process into fast rectangular matrix multiplication algorithms. This allows the simultaneous computation of distances for all query-database pairs in time faster than the standard $O(n^2)$ brute-force approach.

Key Insights and Theoretical Contributions

  • Tightness of the Razborov-Smolensky Bound: A landmark 1987 result established that probabilistic polynomials for MAJORITY require a degree of at least $\Omega(\sqrt{n})$. Our work proves that this lower bound is tight up to constant factors, achieving $O(\sqrt{n})$ for constant error.
  • Symmetric Function Generalization: We show that the optimal degree bound applies not just to MAJORITY, but to any symmetric Boolean function (where the output depends solely on the number of ones in the input).
  • The Algorithmic Bridge: The reduction in polynomial degree serves as a bridge, allowing algebraic techniques (matrix multiplication) to solve combinatorial problems (nearest neighbors) with subquadratic efficiency.
  • SETH Hardness: We provide a complexity-theoretic justification for the limits of these algorithms. We prove that solving the Bichromatic Hamming Closest Pair problem in $2^{o(d)} n^{2-\epsilon}$ time would refute the Strong Exponential Time Hypothesis (SETH), suggesting our bounds are near the theoretical limit.

Results

Our algorithmic framework yields several significant improvements in computational complexity:

  • Subquadratic BHNN: The exact Batch Hamming Nearest Neighbors problem is solved in randomized $n^{2 - 1/O(c(n)\log^2 c(n))}$ time for dimensions $d = c(n)\log n$.
  • Dimensionality Thresholds: We achieve "truly subquadratic" runtimes ($O(n^{2-\epsilon})$) for $d = O(\log n)$, and maintain subquadratic performance for dimensions up to $d = o(\log^2 n / (\log \log n)^2)$.
  • Extended Applications: These results extend beyond Hamming distance to include $\ell_1$ norm (for bounded integers), maximum inner product, and maximum Jaccard coefficient calculations.

Discussion and Future Work

While this work represents a major theoretical advancement, several challenges remain regarding its practical implementation. The constants hidden within the Big-O notation and the inherent overhead of fast matrix multiplication algorithms may limit the immediate utility of these methods for real-world datasets. Furthermore, the algorithm is Monte Carlo randomized, providing correctness with high probability rather than absolute certainty.

Future research will explore whether these techniques can be adapted for more complex metrics, such as Edit Distance, which possesses a much higher circuit complexity than Hamming distance. Additionally, we are interested in whether these offline batch algorithms can be converted into efficient online data structures or if alternative evaluation techniques, such as fast multipoint polynomial evaluation, could further optimize performance.

Summary updated

BibTeX
@inproceedings{alman2015probabilistic,
  author = {Josh Alman and Ryan Williams},
  title = {{Probabilistic Polynomials and Hamming Nearest Neighbors}},
  booktitle = {FOCS},
  year = {2015},
  url = {https://openreview.net/forum?id=1Aw47xL_Df},
}
Figure