TExcelTAD
Home › Spectral Graph Theory & Modern Graph Algorithms › Walks on Expanders: Error Reduction and Pseudorandomness

Walks on Expanders: Error Reduction and Pseudorandomness

Independent random samples are expensive in random bits: tt samples from a set of size 2r2^r cost trtr bits. A random walk on a constant-degree expander whose vertices are those 2r2^r points costs only r+(t−1)log⁡2dr + (t - 1)\log_2 d bits for tt points, yet the points it visits behave, for many purposes, almost like independent samples. This lesson proves the key "hitting" property, applies it to reduce the error of randomized algorithms with few extra random bits (Ajtai, Komlós and Szemerédi, 1987; Cohen and Wigderson, 1989; Impagliazzo and Zuckerman, 1989), and states the Chernoff bound for expander walks.

Normalized expansion

Let GG be a dd-regular graph on nn vertices with walk matrix W=A/dW = A/d. Its eigenvalues are 1=ω1≥ω2≥⋯≥ωn≥−11 = \omega_1 \ge \omega_2 \ge \cdots \ge \omega_n \ge -1, and the normalized two-sided expansion is λˉ=max⁡(∣ω2∣,∣ωn∣)=λ(G)/d\bar\lambda = \max(\lvert\omega_2\rvert, \lvert\omega_n\rvert) = \lambda(G)/d. A random walk V1,V2,…,VtV_1, V_2, \ldots, V_t starts at a uniform vertex and moves to a uniform neighbour at each step. Each ViV_i alone is uniform, because the uniform distribution is stationary; the question is how correlated they are.

The hitting property

Theorem (Ajtai, Komlós and Szemerédi, 1987; in the form of Vadhan, Pseudorandomness, 2012, Theorem 4.17). Let B⊆VB \subseteq V have density μ=∣B∣/n\mu = \lvert B \rvert / n. Then

Pr⁡[V1∈B, V2∈B, …, Vt∈B]≤(μ+λˉ(1−μ))t.\Pr[V_1 \in B,\ V_2 \in B,\ \ldots,\ V_t \in B] \le \big(\mu + \bar\lambda(1 - \mu)\big)^t .

For independent samples the probability would be μt\mu^t. With μ=12\mu = \frac12 and λˉ=14\bar\lambda = \frac14, the walk gives (0.625)t(0.625)^t: still exponentially small in tt.

Proof sketch

Let PP be the diagonal 0/1 matrix projecting onto BB and u=1/nu = \mathbf{1}/n the uniform distribution. The probability that all tt visited vertices lie in BB is 1T(PW)t−1Pu=1T(PWP)t−1Pu\mathbf{1}^{\mathsf{T}}(PW)^{t-1}Pu = \mathbf{1}^{\mathsf{T}} (PWP)^{t-1} P u. Bound the operator norm of PWPPWP: for any xx supported on BB, decompose x=xˉ1+x⊥x = \bar x\mathbf{1} + x^\perp with x⊥⊥1x^\perp \perp \mathbf{1}. Then Wx=xˉ1+Wx⊥Wx = \bar x\mathbf{1} + Wx^\perp with ∥Wx⊥∥≤λˉ∥x⊥∥\lVert Wx^\perp \rVert \le \bar\lambda\lVert x^\perp \rVert, while projecting xˉ1\bar x \mathbf{1} onto BB keeps only a μ\mu fraction of its squared norm. Since xx lives on BB, Cauchy-Schwarz gives ∥xˉ1∥≤μ∥x∥\lVert \bar x\mathbf{1} \rVert \le \sqrt\mu\lVert x \rVert. Combining the two parts carefully gives ∥PWPx∥≤(μ+λˉ(1−μ))∥x∥\lVert PWPx \rVert \le (\mu + \bar\lambda(1-\mu))\lVert x \rVert. Finally, the vector (PWP)t−1Pu(PWP)^{t-1}Pu is supported on BB, which has μn\mu n vertices, so by Cauchy-Schwarz its entry sum is at most μn\sqrt{\mu n} times its Euclidean norm. With ∥Pu∥=μn/n\lVert Pu \rVert = \sqrt{\mu n}/n this gives Pr⁡[…]≤μn⋅∥PWP∥t−1⋅μn/n=μ (μ+λˉ(1−μ))t−1≤(μ+λˉ(1−μ))t\Pr[\ldots] \le \sqrt{\mu n} \cdot \lVert PWP \rVert^{t-1} \cdot \sqrt{\mu n}/n = \mu\, (\mu + \bar\lambda(1-\mu))^{t-1} \le (\mu + \bar\lambda(1-\mu))^t.

The program computes the exact probability 1T(PWP)t−1Pu\mathbf{1}^{\mathsf{T}}(PWP)^{t-1}Pu on the 8-regular Margulis-Gabber-Galil graph on 16×1616 \times 16 vertices from Constructing Expanders, for a random half of the vertices and for a structured half, the vertices (x,y)(x, y) with x<m/2x < m/2. (The second eigenvalue of this graph has multiplicity 4, so "the" second eigenvector, the usual source of a worst-case set, is not well defined; the structured half is nearly as sticky.)

python · try it yourself
import numpy as np

def mgg(m):
    n = m * m
    A = np.zeros((n, n))
    idx = lambda x, y: (x % m) * m + (y % m)
    for x in range(m):
        for y in range(m):
            v = idx(x, y)
            for u in (idx(x + 2 * y, y), idx(x - 2 * y, y), idx(x + 2 * y + 1, y), idx(x - 2 * y - 1, y),
                      idx(x, y + 2 * x), idx(x, y - 2 * x), idx(x, y + 2 * x + 1), idx(x, y - 2 * x - 1)):
                A[v, u] += 1
    return A

m = 16
n = m * m
W = mgg(m) / 8
w = np.linalg.eigvalsh(W)
lam = float(max(abs(w[-2]), abs(w[0])))
print(f"n = {n}, normalized lambda = {lam:.4f}")

sets = {
    "random half": np.random.default_rng(7).permutation(n)[: n // 2],
    "structured half x < m/2": np.flatnonzero(np.arange(n) // m < m // 2),   # vertex (x, y) has index x*m + y
}
for name, B in sets.items():
    mu = len(B) / n
    P = np.zeros((n, n)); P[B, B] = 1
    x = P @ np.full(n, 1 / n)                      # P u
    print(f"{name}: mu = {mu}")
    for t in range(1, 11):
        if t > 1:
            x = P @ (W.T @ x)                      # one more step that must stay inside B
        if t in (1, 2, 5, 10):
            print(f"  t = {t:2}: exact {float(x.sum()):.3e}   independent mu^t {mu ** t:.3e}   "
                  f"bound (mu + lambda (1 - mu))^t {(mu + lam * (1 - mu)) ** t:.3e}")
n = 256, normalized lambda = 0.7568
random half: mu = 0.5
  t =  1: exact 5.000e-01   independent mu^t 5.000e-01   bound (mu + lambda (1 - mu))^t 8.784e-01
  t =  2: exact 2.666e-01   independent mu^t 2.500e-01   bound (mu + lambda (1 - mu))^t 7.716e-01
  t =  5: exact 5.542e-02   independent mu^t 3.125e-02   bound (mu + lambda (1 - mu))^t 5.229e-01
  t = 10: exact 4.683e-03   independent mu^t 9.766e-04   bound (mu + lambda (1 - mu))^t 2.735e-01
structured half x < m/2: mu = 0.5
  t =  1: exact 5.000e-01   independent mu^t 5.000e-01   bound (mu + lambda (1 - mu))^t 8.784e-01
  t =  2: exact 3.750e-01   independent mu^t 2.500e-01   bound (mu + lambda (1 - mu))^t 7.716e-01
  t =  5: exact 1.877e-01   independent mu^t 3.125e-02   bound (mu + lambda (1 - mu))^t 5.229e-01
  t = 10: exact 6.549e-02   independent mu^t 9.766e-04   bound (mu + lambda (1 - mu))^t 2.735e-01

The graph is only a moderate expander (λˉ≈0.76\bar\lambda \approx 0.76), so the walk is visibly more "sticky" than independent sampling: after 10 steps it has stayed inside the random half about 5 times as often as μt\mu^t, and inside the structured half about 67 times as often. But both probabilities decay exponentially, at rates the theorem's bound guarantees; a better expander (smaller λˉ\bar\lambda) brings the walk closer to independent sampling.

Error reduction with few random bits

Let an RP algorithm use rr random bits and accept a "yes" instance with probability at least 12\frac12 (and never accept a "no" instance). The bad seeds B⊆{0,1}rB \subseteq \{0, 1\}^r on a yes instance have density μ≤12\mu \le \frac12. Three ways to get error 2−k2^{-k}:

Method Random bits Error after tt runs
tt independent runs trtr μt≤2−t\mu^t \le 2^{-t}
pairwise independent seeds (Chor and Goldreich, 1989) O(r+log⁡t)O(r + \log t) O(1/t)O(1/t), by Chebyshev
walk on an explicit dd-regular expander on {0,1}r\{0,1\}^r r+(t−1)log⁡2dr + (t - 1)\log_2 d (μ+λˉ(1−μ))t(\mu + \bar\lambda(1-\mu))^t

With an explicit expander of constant degree dd and λˉ≤14\bar\lambda \le \frac14, error 2−k2^{-k} needs t=O(k)t = O(k) steps and only r+O(k)r + O(k) random bits instead of O(rk)O(rk). For BPP algorithms (two-sided error), take the majority vote over the walk; the expander Chernoff bound below guarantees that the majority is correct except with probability 2−Ω(t)2^{-\Omega(t)}.

The expander Chernoff bound

Theorem (Gillman, 1998; stated). For a dd-regular graph with normalized expansion λˉ\bar\lambda, a set AA of density μ\mu, and the walk V1,…,VtV_1, \ldots, V_t started uniformly, the fraction of visits 1t∣{i:Vi∈A}∣\frac1t\lvert \{i : V_i \in A\} \rvert deviates from μ\mu by more than ε\varepsilon with probability at most 2exp⁡(−c(1−λˉ)ε2t)2\exp(-c(1 - \bar\lambda)\varepsilon^2 t) for an absolute constant c>0c > 0.

So expander walks are samplers: they estimate the density of any set as well as independent samples do, up to the factor 1−λˉ1 - \bar\lambda in the exponent. Sharper constants are known (Lezaud, 1998; Healy, 2008), and the bound extends to functions with values in [0,1][0, 1].

In C++

An explicit expander needs no adjacency list: the neighbours of (x,y)(x, y) in the Margulis-Gabber-Galil graph are computed by arithmetic, so the graph can have 2402^{40} vertices. The program estimates the density of a set A={(x,y):(x+y) mod 7<3}A = \{(x, y) : (x + y) \bmod 7 < 3\} (density about 37\frac37) on Zm2\mathbb{Z}_m^2 with m=220m = 2^{20}, using 4000 walk steps that each consume 3 random bits, and compares with 4000 independent samples that each consume 40 bits.

cpp · try it yourself
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <random>

using u64 = std::uint64_t;
const u64 m = u64(1) << 20;

// neighbour i (0..7) of (x, y) in the Margulis-Gabber-Galil graph on Z_m x Z_m
void step(u64& x, u64& y, int i) {
    switch (i) {
        case 0: x = (x + 2 * y) % m; break;
        case 1: x = (x + m - (2 * y) % m) % m; break;
        case 2: x = (x + 2 * y + 1) % m; break;
        case 3: x = (x + 2 * m - (2 * y + 1) % m) % m; break;
        case 4: y = (y + 2 * x) % m; break;
        case 5: y = (y + m - (2 * x) % m) % m; break;
        case 6: y = (y + 2 * x + 1) % m; break;
        default: y = (y + 2 * m - (2 * x + 1) % m) % m; break;
    }
}

bool in_A(u64 x, u64 y) { return (x + y) % 7 < 3; }

int main() {
    std::mt19937_64 rng(2024);
    const double density = 3.0 / 7.0;            // m is not a multiple of 7, but this is accurate to 1e-6
    std::printf("target density %.4f\n", density);
    for (int t : {500, 4000}) {
        double worst_walk = 0, worst_ind = 0;
        for (int rep = 0; rep < 20; ++rep) {
            u64 x = rng() % m, y = rng() % m;     // 40 random bits to start the walk
            int hits = 0;
            for (int s = 0; s < t; ++s) {
                hits += in_A(x, y);
                step(x, y, int(rng() % 8));       // 3 random bits per step
            }
            worst_walk = std::fmax(worst_walk, std::fabs(double(hits) / t - density));
            hits = 0;
            for (int s = 0; s < t; ++s) {                                   // 40 bits per sample
                u64 a = rng() % m;
                u64 b = rng() % m;
                hits += in_A(a, b);
            }
            worst_ind = std::fmax(worst_ind, std::fabs(double(hits) / t - density));
        }
        std::printf("t = %4d: worst error over 20 runs  walk %.4f (%d bits)   independent %.4f (%d bits)\n",
                    t, worst_walk, 40 + 3 * (t - 1), worst_ind, 40 * t);
    }
}
target density 0.4286
t =  500: worst error over 20 runs  walk 0.0546 (1537 bits)   independent 0.0414 (20000 bits)
t = 4000: worst error over 20 runs  walk 0.0172 (12037 bits)   independent 0.0177 (160000 bits)

Both estimators have errors of the order 1/t1/\sqrt t, but the walk uses about 13 times fewer random bits.

Further uses

  • Expander codes (Sipser and Spielman, 1996): a bipartite expander's check constraints define a code that can be decoded in linear time by flipping bits, because expansion guarantees that most corrupted bits have many unsatisfied checks.
  • Pseudorandom generators for space-bounded computation (Nisan, 1992; Impagliazzo, Nisan and Wigderson, 1994): recursively combining expander-style mixing fools log-space algorithms with O(log⁡2n)O(\log^2 n) seed bits.
  • Undirected connectivity in log space (Reingold, 2008): the zig-zag product turns each component into an expander of logarithmic diameter, which a log-space walk can explore exhaustively.

Test yourself

How many random bits does a walk V1,…,VtV_1, \ldots, V_t (tt vertices, t−1t - 1 steps) on a dd-regular expander with 2r2^r vertices use?

  1. trtr
  2. r+(t−1)log⁡2dr + (t - 1)\log_2 d
  3. rlog⁡2tr\log_2 t
  4. tlog⁡2dt\log_2 d only

What does the hitting property bound for a set BB of density μ\mu?

  1. Pr⁡[V1,…,Vt all lie in B]≤(μ+λˉ(1−μ))t\Pr[V_1, \ldots, V_t \text{ all lie in } B] \le (\mu + \bar\lambda(1 - \mu))^t
  2. Pr⁡[the walk never enters B]≤μt\Pr[\text{the walk never enters } B] \le \mu^t
  3. The expected number of visits to BB
  4. The mixing time

An RP algorithm has error 12\frac12 with rr random bits. With an explicit constant-degree expander, how many random bits give error 2−k2^{-k}?

  1. rkrk
  2. r+O(k)r + O(k)
  3. O(rlog⁡k)O(r\log k)
  4. 2k2^k

What does the expander Chernoff bound (Gillman) say about the fraction of time a walk spends in a set of density μ\mu?

  1. It is exactly μ\mu
  2. It deviates from μ\mu by more than ε\varepsilon with probability exp⁡(−Ω((1−λˉ)ε2t))\exp(-\Omega((1 - \bar\lambda)\varepsilon^2 t))
  3. It converges only for bipartite graphs
  4. It is at most λˉ\bar\lambda