Space Lower Bounds from Communication Complexity
The upper bounds of the course come with matching lower bounds, and almost all of them are proved the same way: a streaming algorithm with little memory would give a cheap communication protocol for a problem known to need a lot of communication. This lesson sets up the reduction, states the two communication problems that do most of the work (INDEX and DISJOINTNESS), and derives from them the bounds for exact distinct counting and for , the role of approximation and randomization, and the threshold for higher moments. Proofs of the communication bounds themselves are stated, not proved; the reductions are given in full.
From streams to messages
In one-way two-party communication, Alice holds an input , Bob holds , Alice sends one message to Bob, and Bob must output . In the randomized version they share random bits and Bob must be correct with probability at least (or ) on every input. The cost is the length of the message in bits.
Lemma (streaming to communication). Suppose a one-pass streaming algorithm with bits of memory computes on streams of the form "a stream that depends only on , followed by a stream that depends only on ". Then there is a one-way protocol for with an -bit message, with the same error probability.
Proof. Alice runs the algorithm on (with the shared random bits as its coins) and sends the memory state. Bob loads the state, continues the run on and outputs the answer.
With passes, the state is handed back and forth, messages of bits, so a lower bound of bits on (two-way) communication gives . A lower bound on communication is therefore a lower bound on space, and it holds for every algorithm, however clever, which is what makes the method powerful.
Two hard problems
INDEX. Alice holds , Bob holds an index ; Bob must output . One-way communication only (Bob cannot talk back).
Theorem (stated; Ablayev, 1996; Kremer, Nisan and Ron, 1999). Every randomized one-way protocol for INDEX with error at most sends at least bits, where is the binary entropy. In particular it needs bits for .
Intuition. Bob can ask for any of the bits, so the message must allow recovering a random bit of a random with error , which by Fano's inequality requires bits of information per bit of .
DISJOINTNESS. Alice holds , Bob holds ; decide whether . Two-way communication allowed.
Theorem (stated; Kalyanasundaram and Schnitger, 1992; Razborov, 1992). Every randomized protocol for DISJOINTNESS with error at most communicates bits, even when and the sets intersect in at most one element.
Exact distinct counting needs bits
Theorem. Every randomized one-pass algorithm that computes exactly with probability uses bits of memory.
Proof. Reduce INDEX. Alice streams the set and Bob appends the single item . Before Bob's item the number of distinct items is (Bob can read it from the algorithm, or Alice can append it to the message in bits), and Bob's item adds one more distinct item exactly when . An exact algorithm therefore answers INDEX, and the lemma turns bits of memory into an -bit message.
The reduction also shows why approximation is necessary: Bob's item changes by one, a relative change of , invisible to any -approximation with . The program makes the reduction concrete. Its "algorithm" is a Bloom-filter-based distinct counter with bits; Alice runs it on her set, the state is the message, and Bob asks whether item increases the count. The table compares the measured error with the information-theoretic requirement: a protocol with error must use at least bits.
import math, random
MASK = (1 << 64) - 1
def mix64(x):
x = (x + 0x9E3779B97F4A7C15) & MASK
x = ((x ^ (x >> 30)) * 0xBF58476D1CE4E5B9) & MASK
x = ((x ^ (x >> 27)) * 0x94D049BB133111EB) & MASK
return x ^ (x >> 31)
class BloomDistinct:
"""A one-pass 'distinct counter' with s bits: a Bloom filter with 2 hashes that counts items it has not seen."""
def __init__(self, s, salt):
self.s, self.salt, self.bits, self.count = s, salt, 0, 0
def add(self, x):
h = mix64(x ^ self.salt)
pos = [h % self.s, (h >> 32) % self.s]
if not all(self.bits >> p & 1 for p in pos):
self.count += 1
for p in pos:
self.bits |= 1 << p
def state(self): # everything Alice must send: s bits (+ the counter)
return self.bits, self.count
def index_protocol(x, i, s, salt):
"""INDEX from distinct counting: Alice streams {j : x_j = 1}, sends the state, Bob appends i."""
alg = BloomDistinct(s, salt)
for j, bit in enumerate(x):
if bit:
alg.add(j)
msg = alg.state() # the one-way message
bob = BloomDistinct(s, salt)
bob.bits, bob.count = msg
before = bob.count
bob.add(i)
return 0 if bob.count > before else 1 # the count grew: i was new, so x_i = 0
def H(p):
return 0.0 if p in (0, 1) else -p * math.log2(p) - (1 - p) * math.log2(1 - p)
rng = random.Random(1999)
n, trials = 256, 400
print(f"INDEX with n = {n}: answer x_i from an s-bit message")
print(" s bits s/n measured error bound: any protocol with this error needs s/n >= 1 - H(error)")
for s in [32, 64, 128, 256, 512, 1024, 2048]:
wrong = 0
for t in range(trials):
x = [rng.randrange(2) for _ in range(n)]
i = rng.randrange(n)
wrong += index_protocol(x, i, s, t) != x[i]
d = wrong / trials
print(f" {s:6} {s / n:4.2f} {d:14.3f} {1 - H(d):.3f}")INDEX with n = 256: answer x_i from an s-bit message
s bits s/n measured error bound: any protocol with this error needs s/n >= 1 - H(error)
32 0.12 0.512 0.000
64 0.25 0.492 0.000
128 0.50 0.385 0.039
256 1.00 0.220 0.240
512 2.00 0.075 0.616
1024 4.00 0.035 0.781
2048 8.00 0.000 1.000
The measured points respect the bound, as they must. With bits the Bloom-filter counter is wrong about a quarter of the time or more; at the error is still 7.5%, more than an optimal protocol would need for that many bits, because a Bloom filter is not an optimal encoding. No algorithm of any kind can do much better: a near-zero error forces .
and other moments need bits
Theorem (Alon, Matias and Szegedy, 1996). Every randomized algorithm with passes that approximates within a factor better than 2 with probability uses bits.
Proof. Reduce DISJOINTNESS: stream Alice's set, then Bob's. Every item has frequency 1 or 2, and exactly when the sets intersect. An approximation within a factor below 2 distinguishes from , and a -pass algorithm with bits gives a protocol with bits of communication.
The same stream shows that exact and exact for need bits even with several passes: and both reveal whether the sets intersect, while does not, as the table confirms.
import random
from collections import Counter
def stream_from(A, B):
return sorted(A) + sorted(B) # Alice's items, then Bob's
rng = random.Random(7)
n = 20
print(" |A| |B| A and B disjoint? F_inf F_0 |A| + |B| - F_0 F_2 - (|A| + |B|)")
for t in range(6):
A = set(rng.sample(range(n), 5))
B = set(rng.sample(range(n), 5)) if t % 2 else set(rng.sample(sorted(set(range(n)) - A), 5))
f = Counter(stream_from(A, B))
F0, F2, Finf = len(f), sum(v * v for v in f.values()), max(f.values())
print(f" {len(A):3} {len(B):3} {str(not (A & B)):>17} {Finf:5} {F0:3} {len(A) + len(B) - F0:15} {F2 - len(A) - len(B):17}") |A| |B| A and B disjoint? F_inf F_0 |A| + |B| - F_0 F_2 - (|A| + |B|)
5 5 True 1 10 0 0
5 5 False 2 8 2 4
5 5 True 1 10 0 0
5 5 False 2 8 2 4
5 5 True 1 10 0 0
5 5 False 2 9 1 2
Approximation, randomization and the constants
The reductions above use exactness or a factor below 2. For approximation algorithms, finer communication problems give the finer bounds:
- Deterministic approximation. A deterministic algorithm that estimates within a factor 1.1 needs bits (Alon, Matias and Szegedy, 1996). The proof uses a large family of sets with small pairwise intersections (from an error-correcting code): the algorithm's state must distinguish them, because merging two of them changes by a constant factor. So for , randomization is essential.
- The term. Any randomized -approximation of or needs bits (Indyk and Woodruff, 2003; Woodruff, 2004), by reduction from Gap-Hamming: Alice and Bob hold and must decide whether their Hamming distance is above or below . Its one-way complexity is , and its two-way complexity too (Chakrabarti and Regev, 2011), so even multi-pass algorithms cannot avoid the term.
- Higher moments. For with , the reduction uses multi-party disjointness: players with sets that are either pairwise disjoint or share exactly one common element. Choosing makes a shared element contribute to , about as much as everything else. The players must communicate bits in total, up to logarithmic factors in the earlier results (Bar-Yossef, Jayram, Kumar and Sivakumar, 2004; Chakrabarti, Khot and Sun, 2003; Gronemeier, 2009), so one of the messages of a one-pass simulation has bits, which gives the space bound , matched by the algorithm of Indyk and Woodruff (2005) up to polylogarithmic factors.
- Heavy hitters. INDEX also shows that additive error for frequencies needs bits: Alice encodes a -element subset of as a stream with each element repeated, and point queries recover it.
| Problem | Lower bound | Communication problem |
|---|---|---|
| exact , one pass | bits | INDEX |
| exact or (), within factor , passes | bits | DISJOINTNESS |
| deterministic within | bits | equality on a code |
| for , | bits | Gap-Hamming |
| for , | bits | multi-party disjointness |
Test yourself
How does a one-pass streaming algorithm with bits of memory give a one-way protocol?
- Alice sends her whole input
- Alice runs the algorithm on her part of the stream and sends the -bit memory state; Bob continues the run on his part
- Bob sends his input to Alice
- They run the algorithm twice
In the reduction from INDEX to exact , what does Bob learn from the change in when he appends item ?
- The size of Alice's set
- Whether was already in Alice's set, that is : grows by one exactly when
- The number of ones in
- Nothing
Why does approximating within a factor below 2 need bits?
- Because can be huge
- Because streaming Alice's set and then Bob's gives exactly when the sets intersect, so the algorithm would solve DISJOINTNESS
- Because hashing fails
- Because of INDEX with one bit
Which communication problem gives the lower bound for -approximating ?
- INDEX
- Gap-Hamming: deciding whether the Hamming distance of two vectors of length is above or below its typical value by
- Equality
- Pointer chasing