How to Approximate a Set without Knowing Its Size in Advance

Rasmus Pagh, Gil Segev, Udi Wieder

TL;DR

Standard approximate membership data structures (like Bloom filters) require knowing the final set size in advance to allocate memory optimally. This paper proves that if the size is unknown, you must pay a fundamental space penalty of $\Omega(n \log \log n)$ bits, meaning the average number of bits per element cannot remain constant. The authors then present a clever, tight data structure that matches this lower bound while maintaining worst-case constant-time lookups.

What Problem Does This Paper Address?

The dynamic approximate membership problem asks us to maintain a representation of a set $S$ that supports fast "is $x$ in $S$?" queries. To save space, we tolerate a small false positive rate $\epsilon$ (saying "yes" when the element isn't there), but we forbid false negatives (if it's in the set, the answer must be "yes").

Classic solutions like Bloom filters are highly space-efficient, but they have a major catch: you must know the final size of the set ($n$) beforehand to tune them correctly. If your set grows larger than expected, the false positive rate skyrockets. If it ends up smaller, you've wasted memory.

In real-world data streams, we rarely know $n$ in advance. This paper tackles a fundamental question: What is the exact space complexity of approximate membership when the final set size is completely unknown?

Methods

The paper approaches this problem from both a theoretical lower-bound perspective and an algorithmic upper-bound perspective.

1. The Lower Bound (Compression Argument)

The authors prove their space lower bound using an elegant information-theoretic compression argument. They show that an approximate membership data structure can be used to encode and compress sets. If a data structure existed that didn't pay the extra space penalty when $n$ was unknown, it would violate fundamental counting limits by allowing sets to be compressed below their information-theoretic minimum.

2. Construction 1: Geometrically-Increasing Filters (Warm-up)

As a baseline, the authors propose a naive but intuitive approach: chain together a sequence of standard approximate membership structures ($B_i$) of geometrically increasing capacities ($2^i$). To keep the overall false positive rate bounded by $\epsilon$, the error rates of subsequent filters must shrink geometrically ($\epsilon_i = \Theta(\epsilon/i^2)$). While this achieves optimal space, querying requires checking every filter, leading to an undesirable $O(\log n)$ query time.

3. Construction 2: Signature Expansion in a Single Dictionary (Constant-Time)

To achieve $O(1)$ query time, the authors design a sophisticated structure that manages a single dynamic dictionary. They process insertions in epochs of size $2^i$. Instead of storing raw elements, they hash elements into bit-signatures using a pairwise independent hash function.

The key innovation is how they handle transitions between epochs: when moving from epoch $i$ to $i+1$, they don't just allocate a new filter; they dynamically "expand" the existing signatures in the dictionary. By storing a carefully chosen combination of prefix bits and extension bits, they prevent the dictionary from exploding in size—keeping it bounded to $O(2^i)$ values—while allowing lookups to happen in a single step.

Datasets

Not discussed in the paper. This is a purely theoretical paper focused on mathematical proofs and algorithmic design; no empirical datasets or experimental benchmarks were used.

Key Insights and Ideas

  • The $\log \log n$ Penalty: The most surprising takeaway is that you cannot achieve a constant average number of bits per element if the final set size is unknown. The space must scale with an additive $\Omega(n \log \log n)$ factor.
  • Information Leakage via Approximations: In an exact dictionary, adding an element is trivial because you know exactly what is in the set. In an approximate structure, you only know a superset of what was inserted. When forced to upscale the data structure without knowing the original elements, you must expand this superset, which inherently leaks space.
  • Dynamic Resolution Enhancement: Instead of cascading multiple independent filters, you can progressively lengthen hash signatures within a single dictionary, effectively "deepening" the resolution of your filter on the fly as more data arrives.

Key Results

  • Tight Space Bounds: The authors prove that any approximate membership structure with an unknown size $n$ must use at least $(1 - o(1))n \log(1/\epsilon) + \Omega(n \log \log n)$ bits of space. They match this with an upper bound structure utilizing $(1 + o(1))n \log(1/\epsilon) + O(n \log \log n)$ bits, proving their lower bound is tight.
  • Optimal Time Complexities: Their primary data structure achieves worst-case constant time $O(1)$ for membership queries and expected amortized $O(1)$ time for insertions.
  • De-amortization: They show the structure can be "de-amortized" to ensure that even insertions take worst-case $O(1)$ time with high probability, at the cost of a slightly relaxed space bound of $O(n \log(1/\epsilon) + n \log \log n)$ bits.

Limitations and Future Work

  • Large Hidden Constants: The de-amortization technique used to guarantee worst-case constant insertion times introduces non-trivial hidden constants, making it less appealing for immediate practical deployment.
  • The Leading Constant Gap: While the paper establishes the $\Omega(n \log \log n)$ factor, identifying the exact leading constant for this lower bound remains an open theoretical challenge.
  • Bridge to Practicality: Standard Bloom filters are beloved because they are incredibly simple and fast in practice. The optimal structure proposed here is theoretically beautiful but complex. A major avenue for future research is designing a simplified version that retains these optimal bounds but is clean enough for production systems.

Summary updated

BibTeX
@inproceedings{pagh2013how,
  author = {Rasmus Pagh and Gil Segev and Udi Wieder},
  title = {{How to Approximate a Set without Knowing Its Size in Advance}},
  booktitle = {FOCS},
  year = {2013},
  doi = {10.1109/focs.2013.17},
}
Figure