47.05.05 · theoretical-cs / 05-randomized-algorithms

Derandomization: Pairwise Independence and the Method of Conditional Expectations

shipped3 tiersLean: none

Anchor (Master): Arora and Barak 2009 Computational Complexity: A Modern Approach (Cambridge) Ch. 16; Nisan 1992 Pseudorandom Generators for Space-Bounded Computation (Combinatorica) (Nisan's generator, BPL = L, k-wise independence)

Intuition Beginner

A randomised algorithm flips coins to make decisions. Sometimes it performs well on average but poorly in the worst case. Derandomisation asks: can we replace the coin flips with deterministic choices that are just as good?

The answer is often yes, and the techniques are surprisingly concrete. The method of conditional expectations works by fixing one random bit at a time. At each step, you compute what happens if the bit is 0 versus 1, and choose the better option. Since the expectation over both choices is good, at least one choice must be good. Repeating this for every bit gives a deterministic solution as good as the expected random outcome.

Pairwise independence is another key tool. A collection of random variables is pairwise independent if every pair is independent, even though the whole collection may not be. This is much cheaper than full independence: you can generate pairwise independent bits from only truly random bits. If an algorithm only needs pairwise independence (and many do), you can reduce the randomness drastically.

Together, these techniques suggest a deeper conjecture: every efficient randomised algorithm has an efficient deterministic counterpart. This is the P = BPP conjecture, and while unproven, the derandomisation tools we have give substantial evidence in its favour.

Visual Beginner

Method of conditional expectations for MAX-CUT:

  Graph: a--b--c (3 vertices, 2 edges)
  
  Random partition: each vertex independently L/R
  Expected cut edges: 1.0 (each edge cut with prob 1/2)
  
  Fix v_a = L: E[cut | v_a=L] = 1/2 + 1/2 + 1/2 = 1.5
  
  Fix v_b = R (conditional on v_a = L):
    E[cut | v_a=L, v_b=R] = 1 + 1/2 = 1.5
  
  Fix v_c = L:
    Cut = {a-b: L,R = cut! b-c: R,L = cut!} = 2 edges
    Deterministic solution: 2 edges >= expected 1.0
Technique Randomness reduction Deterministic guarantee
Conditional expectations Eliminates all randomness Achieves expected value
Pairwise independence bits from seed Same variance properties
Nisan's PRG bits from seed Fool space-bounded machines

Worked example Beginner

We derandomise a simple randomised algorithm for MAX-CUT on a triangle graph with vertices and edges .

The randomised algorithm: assign each vertex independently and uniformly to side or . Each edge is cut (endpoints on different sides) with probability . The expected number of cut edges is .

Derandomise via conditional expectations. Define = number of cut edges.

Step 1. Compute . Edges and are cut with prob each (since are random). Edge is cut with prob . So . Similarly . Both equal the unconditional expectation. Choose .

Step 2. Compute . Edge : both , not cut. Edge : cut with prob . Edge : cut with prob . .

Compute . Edge : , cut. Edge : cut with prob . Edge : cut with prob . .

, so choose .

Step 3. Compute . Cut edges: yes, yes, yes. .

Compute . Cut edges: yes, no, no. .

, so choose .

The deterministic partition cuts all 3 edges. The derandomised algorithm found the optimal max-cut.

Check your understanding Beginner

Formal definition Intermediate+

Definition (pairwise independence). Random variables over are pairwise independent if for every and every :

Definition (pairwise independent hash family). A family of functions is pairwise independent if for uniformly random , for all and :

Definition (method of conditional expectations). Given a random variable with , the method fixes sequentially: at step , choose such that:

Such an always exists because .

Definition (Nisan's pseudorandom generator). A PRG -fools space- algorithms if for every space- algorithm :

Counterexamples to common slips

  • "Pairwise independence implies full independence." No. Three pairwise independent bits are pairwise independent but is determined by , so they are not fully independent.

  • "The method of conditional expectations works for any random variable." It requires that the conditional expectations are efficiently computable. This is the case for many natural objectives (cut size, satisfied clauses) but not in general.

  • "Derandomisation means BPP = P." This is conjectured but not proven. The techniques here derandomise specific algorithms; a full derandomisation would require stronger pseudorandom generators than currently known.

Key theorem with proof Intermediate+

Theorem (derandomising MAX-CUT via conditional expectations). There is a deterministic polynomial-time algorithm that, given a graph , finds a partition cutting at least edges.

Proof. The randomised algorithm assigns each vertex independently to or with probability . Each edge is cut with probability (the two endpoints are in different sides). By linearity of expectation, the expected number of cut edges is .

For derandomisation, order the vertices . At step , the algorithm has fixed sides for and computes:

where is the number of cut edges. Since is uniform in the original algorithm:

So . Choose corresponding to the larger value.

After all steps, all vertices are fixed. The resulting partition cuts edges, and .

The conditional expectation at each step is computable in time by summing over edges: for each edge , the probability it is cut given the current partial assignment depends only on whether and are already fixed. The total running time is .

Bridge. The method of conditional expectations is the foundational reason many randomised algorithms can be made deterministic: the existence of a good expected value guarantees that some deterministic choice achieves it, and sequential fixing finds that choice efficiently. This builds toward the more powerful derandomisation tools of Nisan's PRG which handles algorithms whose analysis requires more than expectation (e.g., variance, tail bounds). This is exactly the pattern that appears again in 47.05.01 where pairwise independent hash families reduce randomness for universal hashing, and it generalises to the conjecture BPP = P which would mean all efficient randomised algorithms can be derandomised. The central insight is that expectation-based derandomisation is a combinatorial shadow of the deeper algebraic structure of pseudorandomness, and putting these together with the randomised approximation schemes of 47.05.04 yields a complete toolkit: randomise for convenience, then derandomise for efficiency.

Exercises Intermediate+

Lean formalization Intermediate+

Mathlib has pairwise independence in its probability theory library (Probability.Independence) but no connection to derandomisation. The method of conditional expectations has no formalization. Nisan's PRG is absent entirely. A natural formalization target would be a proof that the conditional-expectations method produces a partition achieving the expected cut size, using Mathlib's SimpleGraph and Finset structures for the graph. This unit ships without a lean_module.

Advanced results Master

Three directions push derandomisation beyond the basic techniques.

Result 1 (Nisan-Wigderson generator). For hardness-based derandomisation, the Nisan-Wigderson generator (1994) converts any function that is hard for circuits of size into a PRG that fools circuits of size . Given a function that no circuit of size can compute, the generator stretches random bits to pseudorandom bits. The construction uses a combinatorial design (a set system with small pairwise intersections) to extract many pseudorandom bits from a single hard function evaluation. The key theorem: if requires exponential-size circuits, then [Arora-Barak Ch. 16].

Result 2 (Impagliazzo-Wigderson hardness-vs-randomness). Impagliazzo and Wigderson (1997) proved that if there exists a language in that requires exponential-size circuits, then . This is the strongest known result connecting circuit lower bounds to derandomisation. The converse direction (derandomisation implies lower bounds) is also known in a weaker form: implies circuit lower bounds. This establishes that derandomisation and circuit complexity are two faces of the same question [Arora-Barak Ch. 16].

Result 3 (Reingold's theorem: SL = L). Omer Reingold (2005) proved that undirected - connectivity can be solved in deterministic logspace (SL = L). The algorithm uses the zig-zag product of expander graphs to transform any graph into an expander in logarithmic space, then performs a deterministic traversal. This is a landmark derandomisation result because randomised logspace algorithms for - connectivity (random walk on the graph) were known for decades, and derandomising them required fundamentally new graph-theoretic machinery [Arora-Barak Ch. 16].

Synthesis. Derandomisation techniques form a hierarchy of power: conditional expectations handles expectation-based analyses, pairwise independence handles variance-based analyses, and pseudorandom generators handle arbitrary statistical tests. The central insight is that each level corresponds to a stronger notion of "randomness-like" behaviour, and this builds toward the hardness-versus-randomness paradigm where circuit lower bounds are the key to full derandomisation. This is exactly the pattern that appears again in 47.06.01 where one-way functions generate pseudorandomness for cryptographic purposes, and it generalises to the conjecture that BPP = P, which would mean that all efficient randomised algorithms are just efficient deterministic algorithms in disguise. Putting these together with the approximation algorithms of 47.04.08 and the FPRAS of 47.05.04 yields the full picture: randomness is a tool of convenience, not of necessity, and the boundary between randomised and deterministic computation maps directly to the boundary between known and unknown circuit lower bounds.

Full proof set Master

Proposition 1 (pairwise independent construction). For any prime power , there exists a pairwise independent hash family of size where , with seed length .

Proof. For any distinct and any targets :

This is a system of two linear equations in two unknowns over . Subtracting gives . Since , and has an inverse in , so is uniquely determined. Then is also unique. So exactly one pair satisfies the system, giving:

This establishes pairwise independence.

Proposition 2 (conditional expectations invariant). Let with . Define . Then for all .

Proof. By induction on . Base case : by assumption. Inductive step: assume . By the law of total expectation:

Since , we have and . Therefore:

Connections Master

  • 47.05.01 — Universal hashing uses pairwise independence for bounded collision probability; this unit shows the same constructions serve as derandomisation tools.

  • 47.03.01 — BPP is the class of problems with efficient randomised algorithms; derandomisation aims to show BPP = P, collapsing randomised and deterministic polynomial time.

  • 47.06.01 — Pseudorandom generators for cryptography (based on one-way functions) are cousins of the PRGs used for derandomisation; the difference is that cryptographic PRGs must fool efficient adversaries, while derandomisation PRGs must fool specific algorithmic tests.

  • 47.05.04 — FPRAS algorithms use randomness for approximate counting; derandomising them would give deterministic approximation schemes, but the conditional expectations method often fails because intermediate expectations are #P-hard to compute.

Historical & philosophical context Master

The method of conditional expectations was implicit in the work of Erdős and Selfridge (1973) on combinatorial games, and was formalised as a derandomisation tool by Beck and Spencer in the 1980s. Pairwise independent hash families were introduced by Carter and Wegman (1979) for universal hashing, and their derandomisation applications were developed by Alon, Babai and Itai (1986) and by Luby (1986).

Nisan's pseudorandom generator for space-bounded computation (1990) was a breakthrough, showing that RL (randomised logspace) is contained in L^{3/2}. Reingold's 2005 proof that SL = L was a landmark derandomisation, resolving a decades-old open problem using expander graph technology rather than pseudorandom generators directly.

The broader question—whether BPP = P—remains open. The Impagliazzo-Wigderson theorem (1997) shows it is equivalent to proving sufficiently strong circuit lower bounds. This places derandomisation squarely within the mainstream of complexity theory: understanding randomness in computation is inseparable from understanding the limits of efficient computation itself [Arora-Barak Ch. 16].

Bibliography Master

@book{arora2009computational,
  author    = {Arora, Sanjeev and Barak, Boaz},
  title     = {Computational Complexity: A Modern Approach},
  publisher = {Cambridge University Press},
  year      = {2009},
}
@article{nisan1992pseudorandom,
  author  = {Nisan, Noam},
  title   = {Pseudorandom Generators for Space-Bounded Computation},
  journal = {Combinatorica},
  volume  = {12},
  number  = {4},
  pages   = {449--461},
  year    = {1992},
}
@article{reingold2005undirected,
  author  = {Reingold, Omer},
  title   = {Undirected Connectivity in Log-Space},
  journal = {Journal of the ACM},
  volume  = {55},
  number  = {4},
  year    = {2008},
}
@article{impagliazzo1997p,
  author  = {Impagliazzo, Russell and Wigderson, Avi},
  title   = {$P = BPP$ if $E$ Requires Exponential Circuits: Derandomizing the {XOR} Lemma},
  journal = {Proceedings of the 29th ACM Symposium on Theory of Computing},
  year    = {1997},
  pages   = {220--229},
}