Main

Lecture 8: Derandomization

Removing randomness while keeping the speed: enumeration, non-uniform advice, conditional probabilities with pessimistic estimators, k-wise independence, and PRGs (Nisan–Wigderson).

Last updated 27 June 2026

Lecture 8 — Derandomization (Derandomizácia)

Course 2-INF-135/15 Pravdepodobnostné algoritmy, LS 2025/26. Source slides: 07_RA_slidy_derandAlg.pdf (22 pages) + RA_slidy_derand.pdf (23 pages). Štátnicové syllabus topics covered here: derandomization — the method of conditional probabilities (with pessimistic estimators), limited (k-wise) independence and small sample spaces, pseudorandom generators, and the hardness-vs-randomness paradigm (Nisan–Wigderson). Worked algorithms: Schöning k-SAT via covering codes, parallel MIS, MaxCut, Set Balancing.


The one-paragraph map of the whole lecture

A randomized algorithm is allowed to flip coins. Derandomization asks: can we get the same guarantee without the coins — deterministically — and not pay too much in running time? The whole lecture is a menu of five answers, ordered from “brute and obvious” to “deep and conditional”:

  1. Enumeration — just try all coin sequences. Always works, but costs 2(#random bits)2^{(\#\text{random bits})}. Cheap only if the algorithm uses O(logn)O(\log n) bits.
  2. Non-uniform / non-constructive adviceone fixed bit-string works for all inputs of a given length. It exists by counting, but we may not be able to find it. Lands us in P/poly\mathsf{P/poly}, not P\mathsf{P}.
  3. Method of conditional probabilities — fix the random choices one at a time, always steering toward a better-than-average outcome. The workhorse for “the average object is good, give me a concrete good one.”
  4. Limited (k-wise) independence — if the analysis only ever uses interactions among kk variables at a time, replace true randomness by a tiny sample space that looks kk-wise independent. Few random bits \Rightarrow small space \Rightarrow enumerate it.
  5. Pseudorandom generators (PRG) — stretch a short truly-random seed into a long string that no small circuit can tell from random. Then enumerate seeds. This is the heavy machinery, and it rests on a beautiful trade: a hard function buys you randomness (Nisan–Wigderson).

The recurring question is always the same: what exactly did the probabilistic analysis actually need? The less it needed (only the expectation? only pairwise interactions? only fooling small circuits?), the cheaper the derandomization.


0. Two flavors, and the two trivial bookends

The slides split derandomization into:

Before the clever methods, two bookends that need almost no thought.

Bookend 1 — Enumeration (“hrubá sila”)

If A(x,r)A(x, r) uses r(x)r(|x|) random bits, simulate it for every r{0,1}r(x)r \in \{0,1\}^{r(|x|)} and take a majority vote (or, for RP, an OR). Correct by definition. Cost: a factor 2r(x)2^{r(|x|)}. So this is polynomial iff the algorithm uses only O(logn)O(\log n) random bits. That single observation is why so much of the lecture is about squeezing the random-bit budget down to O(logn)O(\log n) — see limited independence (§4) and PRGs (§7).

Bookend 2 — Non-constructive / non-uniform advice

Lemma. If A(x;r)A(x; r) decides a language LL with error <2x< 2^{-|x|}, then for every nn there is a fixed string r(n)r^{(n)} such that A(x;r(n))A(x; r^{(n)}) is correct for all x{0,1}nx \in \{0,1\}^n simultaneously.

Proof (probabilistic method / union bound). Fix nn. For a random rr, the bad event “A(;r)A(\cdot; r) is wrong on xx” has probability <2n< 2^{-n} for each fixed xx. There are 2n2^n inputs of length nn, so

Pr[x: A(x;r) wrong]x{0,1}nPr[A(x;r) wrong]<2n2n=1.\Pr\Big[\,\exists x:\ A(x; r)\text{ wrong}\,\Big] \le \sum_{x \in \{0,1\}^n} \Pr[A(x;r)\text{ wrong}] < 2^n \cdot 2^{-n} = 1.

A bad event of probability <1< 1 leaves room for a good rr, so a universal r(n)r^{(n)} exists. \square

Punchline. This puts every BPP\mathsf{BPP} language in P/poly\mathsf{P/poly} (the r(n)r^{(n)} are the polynomial advice). But the proof is non-constructive — it tells you a good advice string exists, not how to compute it. Turning “exists” into “here it is, in polynomial time” is the entire art of the rest of the lecture.

The first amplification step (error 2x\to 2^{-|x|}) is just running the algorithm O(n)O(n) times and voting — standard probability amplification from Lecture 3.


1. The RP “small witness set” theorem — a greedy set cover

This is the first non-trivial complexity-theoretic statement, and its proof is a clean greedy set-cover argument worth keeping.

Theorem. Let MM be an RP\mathsf{RP} algorithm using kk random bits on inputs of length nn. Then there is a set S{0,1}kS \subseteq \{0,1\}^k with S=n|S| = n such that for every input ww of length nn, some rSr \in S makes M(w,r)M(w, r) answer correctly.

So instead of 2k2^k random strings, nn fixed strings suffice — we just don’t yet know how to find them in poly time, but they exist and are few.

Proof. Build the Boolean matrix AA of size 2n×2k2^n \times 2^k:

A[input,rand]={1if M(input,rand) is correct,0otherwise.A[\text{input}, \text{rand}] = \begin{cases} 1 & \text{if } M(\text{input}, \text{rand}) \text{ is correct},\\ 0 & \text{otherwise.}\end{cases}

Because MM is RP\mathsf{RP} (after one amplification, say), every row has at least 2k12^{k-1} ones. Now greedily cover the rows:

S ← ∅
while A still has uncovered rows:
    every remaining row has ≥ 2^{k-1} ones
    ⇒ by averaging, ∃ a column j hitting ≥ half of the remaining rows
    S ← S ∪ {j};  delete the rows covered by column j

Each chosen column halves the number of uncovered rows. Starting from 2n2^n rows, after nn steps fewer than 11 remain. Hence Sn|S| \le n. \square

Why a column with “half the ones” must exist. If every remaining row has a 1/2\ge 1/2 fraction of 11s, then the total count of 11s is $\ge \tfrac12 \cdot (#\text{rows}) \cdot 2^k; by averaging over the $2^k columns, some column carries 12(#rows)\ge \tfrac12 (\#\text{rows}) of them. This “an average column is good” move is the seed of the conditional-probabilities method.

There is also a direct probabilistic proof (the “inak” on the slide): let FxF_x be the event that nn independent runs of MM all fail on xx. Then Pr[Fx]<(1/2)n\Pr[F_x] < (1/2)^n, and Pr[xFx]xPr[Fx]<2n2n=1\Pr[\bigcup_x F_x] \le \sum_x \Pr[F_x] < 2^n \cdot 2^{-n} = 1, so a single universal random string rr works — the same union bound as Bookend 2.


2. The method of conditional probabilities (metóda podmienených pravdepodobností)

This is the most important constructive technique in the lecture, and the one the exams hammer (3-cuts, monochromatic edges, K4K_4 colorings). Master this section.

The idea in one sentence

The probabilistic method says “a random object is good on average.” Conditional probabilities turns that existence proof into an algorithm: decide the random choices x1,x2,,xnx_1, x_2, \dots, x_n one at a time, and at each step pick the value that keeps the conditional expectation at least as good as before. Since the conditional expectation never drops below the unconditional one, the final fully-fixed object is at least as good as average.

Formally, suppose we want a large quantity CC and we know E[C]μ\mathbb{E}[C] \ge \mu. We fix x1,,xnx_1, \dots, x_n in order so that

μE[C]E[Cx1]E[Cx1,x2]E[Cx1,,xn]=C(x1,,xn).\mu \le \mathbb{E}[C] \le \mathbb{E}[C \mid x_1] \le \mathbb{E}[C \mid x_1, x_2] \le \cdots \le \mathbb{E}[C \mid x_1,\dots,x_n] = C(x_1,\dots,x_n).

The middle inequalities hold because, by the law of total expectation,

E[Cx1,,xi]=12E[C,xi+1=0]+12E[C,xi+1=1]max{the two children}.\mathbb{E}[C \mid x_1,\dots,x_i] = \tfrac12\,\mathbb{E}[C \mid \dots, x_{i+1}=0] + \tfrac12\,\mathbb{E}[C \mid \dots, x_{i+1}=1] \le \max\{\,\text{the two children}\,\}.

So always walk to the larger child. The conditional expectation is an average of its two children, hence at most the larger one — you can always avoid going down.

The one prerequisite. You must be able to compute the conditional expectation in polynomial time at each node. When you can compute it exactly, you greedily maximize it (§2.1). When you can’t, you replace it with a cleverly chosen pessimistic estimator (§2.2).

2.1 Worked example — MaxCut / LargeCut

Color each vertex viv_i with xi{0,1}x_i \in \{0,1\}. An edge is cut if its endpoints get different colors. Under a uniformly random coloring each edge is cut with probability 1/21/2, so E[C]=m/2\mathbb{E}[C] = m/2. We want a deterministic cut of size m/2\ge m/2.

Decide colors x1,,xnx_1, \dots, x_n in order. After fixing x1,,xix_1,\dots,x_i, split the first ii vertices into V0(i)V_0(i) (colored 00) and V1(i)V_1(i) (colored 11). Let CiC_i be the edges already cut, and EiE_i the still-undecided edges (both endpoints uncolored). When we color vi+1v_{i+1}:

E[C,xi+1=0]=Ci+E(V1(i)×{vi+1})+Ei2,\mathbb{E}[C \mid \dots, x_{i+1}=0] = C_i + \big|E \cap (V_1(i)\times\{v_{i+1}\})\big| + \tfrac{|E_i|}{2},
E[C,xi+1=1]=Ci+E(V0(i)×{vi+1})+Ei2.\mathbb{E}[C \mid \dots, x_{i+1}=1] = C_i + \big|E \cap (V_0(i)\times\{v_{i+1}\})\big| + \tfrac{|E_i|}{2}.

Reading this off: coloring vi+1v_{i+1} with 00 newly cuts its edges to the already-1 neighbors; coloring it 11 cuts its edges to the already-0 neighbors; the not-yet-decided edges still contribute 1/21/2 each either way. So the rule is simply:

Greedy rule. Color vi+1v_{i+1} the opposite of the majority color among its already-colored neighbors (break ties arbitrarily). Equivalently, place it on the side it has more edges to — those edges become cut.

Each step keeps E[C]\mathbb{E}[C \mid \cdot] from dropping, so the final cut has size m/2\ge m/2. Pure O(n+m)O(n+m) greedy, no coins.

Exam bridge (exam-1, the 3-cut). Partition vertices into three sets S,T,US,T,U. A random 3-partition cuts each edge with probability 2/32/3, so $\mathbb{E}[\text{3-cut}] = \tfrac23 m$. The identical conditional-expectation argument — at each vertex pick the part it has the fewest already-placed neighbors in — deterministically yields a 3-cut of size 23m\ge \tfrac23 m in polynomial time. The generalization to kk parts / kk colors and “few monochromatic edges m/k\le m/k” (exam-3) is the same machinery.

2.2 Worked example — Set Balancing (Spencer) and the pessimistic estimator

This is the subtle, professor-pleasing case: what if the “good event” is not an expectation you can track? Then you track a pessimistic upper bound on the probability of failure instead.

Problem (Set Balancing). Given sets S1,,SmB={b1,,bn}S_1,\dots,S_m \subseteq B = \{b_1,\dots,b_n\}, find a 2-coloring f:B{+1,1}f : B \to \{+1,-1\} making every set as balanced as possible. The discrepancy of set SiS_i is

Δ(Si,f)=bjSifj,Δ(S,f)=maxiΔ(Si,f).\Delta(S_i, f) = \Big|\sum_{b_j \in S_i} f_j\Big|, \qquad \Delta(S, f) = \max_i \Delta(S_i, f).

Assume (as the slides do) n=mn=m and each Si=δ|S_i| = \delta.

Now derandomize. The obstacle: the “good” event (Δ\Delta small) is a max of absolute values, not a sum — its conditional expectation is awkward. Fix: drive down a pessimistic estimator P~v\widetilde P_v of the probability that the final leaf is a bad coloring. Build the binary tree over colorings; a root-to-leaf path is good if it induces Δ(S,f)2δln2n\Delta(S,f) \le \sqrt{2\delta \ln 2n}, bad otherwise. Let PvP_v be the true fraction of bad leaves under vv. We have $P_v = \tfrac12(P_{v1}+P_{v,-1}) \ge \min{P_{v1}, P_{v,-1}}, so walking to the smaller child never increases $P. We can’t compute PvP_v, so we want P~v\widetilde P_v satisfying four conditions:

  1. P~root<1\widetilde P_{\text{root}} < 1,
  2. PvP~vP_v \le \widetilde P_v at every node (it really is an upper bound),
  3. P~vmin{P~v1,P~v,1}\widetilde P_v \ge \min\{\widetilde P_{v1}, \widetilde P_{v,-1}\} (a child is no worse),
  4. P~v\widetilde P_v is computable in polynomial time.

The estimator comes from the Chernoff moment-generating-function bound before taking limits. For a parameter tt,

Pr[TiΔ]E[etTi]etΔ,P~root=i=1nE[etTi]etΔ.\Pr[\,|T_i| \ge \Delta\,] \le \frac{\mathbb{E}[e^{t T_i}]}{e^{t\Delta}}, \qquad \widetilde P_{\text{root}} = \sum_{i=1}^n \frac{\mathbb{E}[e^{t T_i}]}{e^{t\Delta}}.

Because a coloring with Δ2δln2n\Delta \le \sqrt{2\delta\ln 2n} exists, there is a tt making P~root<1\widetilde P_{\text{root}} < 1 (condition 1). At a node vv where f1,,fjf_1,\dots,f_j are already decided, split Ti=Ti,dj+Ti,njT_i = T_{i,d}^{j} + T_{i,n}^{j} into the decided and not-yet-decided parts, and estimate

P~v=i=1nE[etTi,nj]et(ΔTi,dj).\widetilde P_v = \sum_{i=1}^n \frac{\mathbb{E}\big[e^{t\,T_{i,n}^{j}}\big]}{e^{t(\Delta - T_{i,d}^{j})}}.

The “averaging over the next bit” identity $\widetilde P_v = \tfrac12 \widetilde P_{v1} + \tfrac12 \widetilde P_{v,-1} \ge \min{\widetilde P_{v1}, \widetilde P_{v,-1}}$ gives condition 3, and each E[etTi,n]\mathbb{E}[e^{t T_{i,n}}] is a product of per-element factors 12(et+et)\tfrac12(e^t+e^{-t}), computable in polynomial time (condition 4).

The finish (why P~<1\widetilde P < 1 forces a good leaf). Walk down always to the smaller-P~\widetilde P child. By condition 3, P~\widetilde P never increases, so the leaf has P~<1\widetilde P < 1. But at a leaf the coloring is fully fixed, so the true PP is either 00 (good) or 11 (bad), and PP~<1P \le \widetilde P < 1 forces P=0P = 0. We have constructed a good coloring. \square

The deep point. Conditional probabilities does not require the quantity you care about to be an expectation. It only requires a polynomial-time-computable quantity that (i) upper-bounds the failure probability, (ii) starts below 11, and (iii) has the “average-of-children” property. That quantity is the pessimistic estimator, and the MGF/Chernoff bound is the standard place to get one.


3. Parallel MIS (Luby) and derandomization via pairwise independence

The Maximal Independent Set problem: find an inclusion-maximal independent set. Luby’s randomized algorithm is parallel and finishes in O(logn)O(\log n) rounds; the point here is that it can be derandomized into NC2\mathsf{NC}^2 (poly processors, O(log2n)O(\log^2 n) depth) because its analysis only ever uses pairwise independence.

The algorithm

MIS ← ∅
repeat:
    each vertex v marks itself with probability 1/(2·d(v))        → set S
    on each edge with both endpoints marked, the higher-degree endpoint wins → S′
    MIS ← MIS ∪ S′
    V ← V − ( S′ ∪ N(S′) )       (remove the new IS vertices and their neighbors)
until V = ∅

Two claims drive everything:

The good/bad bookkeeping

Call a vertex bad if more than 2/32/3 of its neighbors have degree d(v)\ge d(v) (it is “dominated”); otherwise good. An edge is bad if both endpoints are bad.

Why this derandomizes

The progress lemma is the crux, and its proof (L3, the part that actually bounds removals) uses only pairwise independence of the marks. So:

Each round is one deterministic parallel step over a poly-size space; O(logn)O(\log n) rounds \Rightarrow NC2\mathsf{NC}^2.

The lemma that licenses the swap (full \to pairwise). For indicators XiX_i with pi=Pr[Xi=1]p_i = \Pr[X_i=1]:

  1. independent: Pr[Xi>0]1i(1pi)\Pr[\sum X_i > 0] \ge 1 - \prod_i (1-p_i);
  2. pairwise independent: Pr[Xi>0]12min{1,ipi}\Pr[\sum X_i > 0] \ge \tfrac12 \min\{1, \sum_i p_i\}.

Part 2 is a Bonferroni / inclusion–exclusion bound: $\Pr[\sum X_i>0] \ge \sum_i p_i - \tfrac12\sum_{i\neq j}\Pr[X_i=X_j=1] = \sum p_i - \tfrac12\sum_{i\neq j}p_i p_j \ge \sum p_i\big(1 - \tfrac12\sum p_i\big)$, which is 12pi\ge \tfrac12\sum p_i when pi1\sum p_i \le 1; and when pi1\sum p_i \ge 1 pick a sub-collection with 12Spi1\tfrac12 \le \sum_{S} p_i \le 1 to get 1/4\ge 1/4. The point: “at least one event fires” needs only pairwise correlations — exactly what a small sample space can supply.


4. Limited independence and small sample spaces

This is the engine behind §3 and the exams. The principle:

If the analysis of a randomized algorithm only ever uses interactions among kk variables at a time, then we may feed it variables that are merely kk-wise independent instead of fully independent. Such variables live in a tiny sample space, generated from few truly-random bits, which we can then enumerate.

We want f:Σ(n)Σr(n)f : \Sigma^{\ell(n)} \to \Sigma^{r(n)} (short seed \to long pseudo-random output) with Prr[A(x,r)=1]Pry[A(x,y)=1]\Pr_{r}[A(x,r)=1] \approx \Pr_{y}[A(x,y)=1] for the real uniform yy.

4.1 nn pairwise-independent uniform bits from log(n+1)\lceil\log(n+1)\rceil truly-random bits

This is the construction to have at your fingertips (it is the answer to the pairwise-independent-coloring exam questions).

Uniform: each rir_i contains at least one bsb_s; conditioning on the others, ri=(jJi{s}bj)bsr_i = (\bigoplus_{j\in J_i\setminus\{s\}} b_j) \oplus b_s flips with bsb_s, so it is fair. Pairwise independent: for JiJiJ_i \neq J_{i'} there is (wlog) an sJiJis \in J_i \setminus J_{i'}; bsb_s randomizes rir_i but not rir_{i'}, so

Pr[ri=ari=a]=14=Pr[ri=a]Pr[ri=a].\Pr[r_i = a \wedge r_{i'} = a'] = \tfrac14 = \Pr[r_i=a]\Pr[r_{i'}=a'].

Punchline. nn pairwise-independent bits cost only t=O(logn)t = O(\log n) truly-random bits, i.e. a sample space of size 2t=O(n)2^t = O(n). Enumerate all O(n)O(n) seeds in polynomial time and keep the best outcome — the random bits are gone. This is exactly how the pairwise-independent graph-colorings of the exams are derandomized: the random coloring uses O(logn)O(\log n) true bits, you try all O(poly)O(\text{poly}) seeds, and you keep the coloring with m/k\le m/k monochromatic edges. Running time is poly(n,m,k)(n,m,k).

4.2 Chor–Goldreich 2-independent generator (from 2-universal hashing)

A function ff is an (m,t,)(m,t,\ell)-2-independent generator if

  1. f:ΣmΣtf : \Sigma^m \to \Sigma^{\ell\cdot t}, output split as f(x)=f1(x)f2(x)f(x)f(x) = f_1(x)\,f_2(x)\cdots f_\ell(x), each fi(x)=t|f_i(x)| = t;
  2. ff is computable in time poly(t)(t\ell);
  3. ij, α,βΣt: Pr[fi(x)=αfj(x)=β]=22t\forall i\neq j,\ \forall \alpha,\beta\in\Sigma^t:\ \Pr[f_i(x)=\alpha \wedge f_j(x)=\beta] = 2^{-2t}.

Theorem. For all ,t,m\ell, t, m with 2m2^m \ge \ell and mtm \ge t, an (2m,t,)(2m, t, \ell)-2-independent generator exists.

Construction. Use the 2-universal family $H = {h_{a,b}(x) = ax+b : a,b \in GF[2^m]}. Fix distinct $\alpha_1,\dots,\alpha_\ell \in GF[2^m] and set

f(a,b)=ha,b(α1)ha,b(α2)ha,b(α),keeping t bits of each ha,b(αi).f(a,b) = h_{a,b}(\alpha_1)\,h_{a,b}(\alpha_2)\cdots h_{a,b}(\alpha_\ell), \quad\text{keeping } t \text{ bits of each } h_{a,b}(\alpha_i).

Pairwise independence of ha,bh_{a,b} over the random seed (a,b)(a,b) gives Pra,b[fi=ufj=v]=22t\Pr_{a,b}[f_i = u \wedge f_j = v] = 2^{-2t} — exactly property 3. The seed is 2m2m bits, far fewer than the t\ell t output bits.

4.3 kk-independent uniform bits from linear codes (Alon–Babai–Itai)

To go beyond pairwise, the right language is linear codes.

Theorem (Alon–Babai–Itai). Let L1,,Lm{0,1}L_1,\dots,L_m \in \{0,1\}^\ell be such that any kk of them are linearly independent over GF[2]GF[2]. Draw RR{0,1}R \in_R \{0,1\}^\ell and set Xi:=Li,R=j=1Li,jrjmod2X_i := \langle L_i, R\rangle = \sum_{j=1}^\ell L_{i,j} r_j \bmod 2. Then X1,,XmX_1,\dots,X_m are kk-wise independent (and uniform).

Proof. Take any kk indices i1,,iki_1,\dots,i_k. The corresponding rows form a k×k\times\ell matrix HH of rank kk (independence), so R(Xi1,,Xik)=HRR \mapsto (X_{i_1},\dots,X_{i_k}) = H R^\top is a surjective linear map whose every fiber has size 2k2^{\ell-k}. Hence

Pr[Xi1=d1,,Xik=dk]=2k2=2k=j=1kPr[Xij=dj].\Pr[X_{i_1}=d_1,\dots,X_{i_k}=d_k] = \frac{2^{\ell-k}}{2^\ell} = 2^{-k} = \prod_{j=1}^k \Pr[X_{i_j}=d_j]. \qquad \square

Where do the LiL_i come from? From the parity-check matrix of a code: for an [n,k,d][n,k,d] code, any d1d-1 columns of HH are linearly independent. Take the BCH-style check matrix with n=2d1n = 2^d - 1 columns and rows the odd powers of the field elements y1,,ynGF[2d]y_1,\dots,y_n \in GF[2^d],

H=(111y1y2yny13y23yn3y12t1y22t1yn2t1),H = \begin{pmatrix} 1 & 1 & \cdots & 1\\ y_1 & y_2 & \cdots & y_n\\ y_1^3 & y_2^3 & \cdots & y_n^3\\ \vdots & & & \vdots \\ y_1^{2t-1} & y_2^{2t-1} & \cdots & y_n^{2t-1}\end{pmatrix},

which has minimum distance 2t+22t+2, so every 2t+12t+1 columns are independent. The columns live in {0,1}\{0,1\}^\ell with =(t+1)d=(t+1)logn\ell = (t+1)d = (t+1)\log n. Thus from RR{0,1}(t+1)lognR \in_R \{0,1\}^{(t+1)\log n} we obtain nn variables that are (2t+1)(2t+1)-wise independent and uniform — using only O(tlogn)O(t \log n) random bits.

4.4 kk-independent bits with an arbitrary distribution

Finally, kk-wise independent variables with prescribed (possibly biased) marginals Pr[Xi=1]=pi\Pr[X_i = 1] = p_i, using a sample space of size O(nk)O(n^k).

Theorem. For a prime pp with np2nn \le p \le 2n and k1k \ge 1, there is a uniform probability space (Ω,P)(\Omega, P) with Ω=pk|\Omega| = p^k and kk-independent variables X^1,,X^n\widehat X_1,\dots,\widehat X_n over it whose marginals match the targets up to rounding: dist(X^i,Xi)1/p1/n\mathrm{dist}(\widehat X_i, X_i) \le 1/p \le 1/n.

Construction. Let Ω\Omega be all polynomials q=q1+q2x++qkxk1q = q_1 + q_2 x + \cdots + q_k x^{k-1} of degree k1\le k-1 over F=GF(p)F = GF(p) (so Ω=pk|\Omega| = p^k), chosen uniformly. Set Yi=q(i)Y_i = q(i), then threshold: X^i=1\widehat X_i = 1 iff q(i)<ppiq(i) < p\cdot p_i. Because

(1i1i1k11i2i2k11ikikk1)(q1qk)=(Yi1Yik)\begin{pmatrix} 1 & i_1 & \cdots & i_1^{k-1}\\ 1 & i_2 & \cdots & i_2^{k-1}\\ \vdots & & & \vdots\\ 1 & i_k & \cdots & i_k^{k-1}\end{pmatrix} \begin{pmatrix} q_1 \\ \vdots \\ q_k\end{pmatrix} = \begin{pmatrix} Y_{i_1} \\ \vdots \\ Y_{i_k}\end{pmatrix}

is a Vandermonde (regular) system, for every target (d1,,dk)(d_1,\dots,d_k) there is a unique qq producing Yij=djY_{i_j} = d_j, so Pr[Yi1=d1,,Yik=dk]=pk\Pr[Y_{i_1}=d_1,\dots,Y_{i_k}=d_k] = p^{-k} — exactly kk-wise independence and Pr[q(i)=c]=1/p\Pr[q(i)=c] = 1/p. The threshold induces at most a 1/p1/p rounding error on each marginal. \square


5. Schöning’s k-SAT, Promise-Ball-k-SAT, and covering codes

A self-contained, beautiful derandomization: Schöning’s random-walk k-SAT algorithm is turned into the fastest known deterministic k-SAT algorithm, via covering codes, losing only an ε\varepsilon in the exponent.

Schöning’s randomized algorithm

choose α ∈ {0,1}^n uniformly at random
repeat (a bounded number of times):
    if F(α)=1 return α
    pick an unsatisfied clause C; flip one of its literals chosen uniformly at random

Theorem (Schöning). If FSATF \in \mathsf{SAT} (kk-CNF), one run finds a satisfying assignment with probability (k2(k1))n\ge \left(\dfrac{k}{2(k-1)}\right)^{n}.

Proof. Let α\alpha^* be a satisfying assignment and α\alpha the random start. Then Pr[dist(α,α)=r]=(nr)2n\Pr[\mathrm{dist}(\alpha,\alpha^*) = r] = \binom{n}{r} 2^{-n}. From Hamming distance rr, the random walk drifts toward α\alpha^* — each forced flip moves toward α\alpha^* with probability 1/(k1)\ge 1/(k-1) (the unsatisfied clause has a literal wrong in α\alpha but right in α\alpha^*). So $\Pr[\text{reach } \alpha^* \mid \mathrm{dist}=r] \ge (k-1)^{-r}$, and

Pr[success]r=0n(nr)2n(k1)r=2n(1+1k1)n=(k2(k1))n.\Pr[\text{success}] \ge \sum_{r=0}^n \binom{n}{r} 2^{-n} (k-1)^{-r} = 2^{-n}\Big(1+\tfrac{1}{k-1}\Big)^n = \Big(\tfrac{k}{2(k-1)}\Big)^n. \qquad \square

Repeating (2(k1)k)n\big(\tfrac{2(k-1)}{k}\big)^n times gives an RP\mathsf{RP} algorithm running in O(1.33n)O^*(1.33^n) for 3-SAT and O(1.5n)O^*(1.5^n) for 4-SAT.

Promise-Ball-k-SAT, deterministically

Promise-Ball-kk-SAT. Promise: a satisfying assignment lies inside Ballr(α)\mathrm{Ball}_r(\alpha) for given α,r\alpha, r. Find any satisfying assignment (not necessarily inside the ball).

Schöning’s lemma. If Ballr(α)\mathrm{Ball}_r(\alpha) contains a satisfying β\beta, then Schöning finds some satisfying assignment with probability (k1)r\ge (k-1)^{-r}.

The deterministic version is a bounded-depth search:

Search(F, α, r):
    if F(α)=1 return true
    if r=0    return false
    C ← an unsatisfied clause of F        (length ≤ k)
    for each literal u in C:
        if Search(F|u=1, flip α at u, r−1) = true return true
    return false

The recursion branches on the literals of an unsatisfied clause. A naïve count gives krk^r leaves; the sharper analysis notes that an unsatisfied clause needs to flip only k1k-1 “useful” literals (the assignment already disagrees with one), so

time(Search(F,α,r))=O((k1)r).\text{time}\big(\mathrm{Search}(F,\alpha,r)\big) = O^*\big((k-1)^r\big).

From the ball back to the whole cube — covering codes (Dantsin et al.)

We do not know where α\alpha^* is, so we cover {0,1}n\{0,1\}^n by balls and run Search\mathrm{Search} from each ball’s center.

Reduction. If AA solves Promise-Ball-kk-SAT in O(ar)O^*(a^r), then there is a BB solving kk-SAT in O ⁣((2aa+1)n)O^*\!\left(\big(\tfrac{2a}{a+1}\big)^{n}\right); BB is deterministic if AA is.

Idea. Take a covering code: a set of codewords (ball centers) such that every α{0,1}n\alpha \in \{0,1\}^n is within distance rr of some center. Run the deterministic Promise-Ball solver from each center. If FSATF\in\mathsf{SAT}, some satisfying assignment sits within rr of a center, and that call finds it. Balancing the ball radius against the number of centers (more, smaller balls vs fewer, larger ones) gives the (2aa+1)n\big(\tfrac{2a}{a+1}\big)^n bound.

With a=k1a = k-1 (deterministic Search), BB runs in O ⁣((2(k1)k)n)O^*\!\left(\big(\tfrac{2(k-1)}{k}\big)^n\right)matching the randomized Schöning running time, deterministically.

The covering-code existence lemma. Work over the alphabet {1,,k}t\{1,\dots,k\}^t (a kk-ary code, because each useful flip in a clause is one of kk literal choices). With Br(k)(u)={u:dH(u,u)r}B^{(k)}_r(u) = \{u': d_H(u,u')\le r\} and volk(t,r)=(tr)(k1)r\mathrm{vol}_k(t,r) = \binom{t}{r}(k-1)^r, there exists a code C{1,,k}tC \subseteq \{1,\dots,k\}^t of covering radius rr with

Ctlnkkt(tr)(k1)r.|C| \le \frac{t \ln k \cdot k^t}{\binom{t}{r}(k-1)^r}.

Proof (probabilistic method). Pick m=tlnkkt(tr)(k1)rm = \dfrac{t \ln k \cdot k^t}{\binom{t}{r}(k-1)^r} centers uniformly at random. A fixed word ww' is uncovered with probability

(1volk(t,r)kt)m<evolk(t,r)m/kt=etlnk=kt.\Big(1 - \tfrac{\mathrm{vol}_k(t,r)}{k^t}\Big)^{m} < e^{-\mathrm{vol}_k(t,r)\,m / k^t} = e^{-t\ln k} = k^{-t}.

Union over all ktk^t words gives <1< 1, so with positive probability every word is covered \Rightarrow such a code exists. The lecture then makes the radius r=t/kr = t/k and uses (tt/k)(k1)t/k\binom{t}{t/k}(k-1)^{t/k} estimates to push the deterministic Promise-Ball-kk-SAT to O ⁣((k1+ε)r)O^*\!\big((k-1+\varepsilon)^r\big) for any ε>0\varepsilon > 0.

Why “find a good code” is the hard part. The probabilistic argument shows a covering code exists; the algorithm needs an explicit one. The slides resolve this by pre-computing a small code for fixed r,k,tr,k,t (via a maximal independent family of unsatisfied clauses), so the search tree has only (k1+ε)r\approx (k-1+\varepsilon)^r leaves. The recursion (α,r)(α(w),rΔ)(\alpha, r) \rightsquigarrow (\alpha(w'), r-\Delta) shrinks the radius by Δ=t2t/k\Delta = t - 2t/k each level, and the number of leaves is bounded by Cr/Δ(k1)t2/Δr/t(k1+ε)r|C|^{r/\Delta} \le (k-1)^{t^2/\Delta\cdot r/t} \rightsquigarrow (k-1+\varepsilon)^r.


6. Pseudorandom generators and hardness vs. randomness

The deepest part: a general theorem that derandomizes all of BPP\mathsf{BPP} under a plausible hardness assumption. The slogan:

Hardness \Rightarrow randomness. A function that is hard to predict can be used to manufacture pseudo-randomness; pseudo-randomness lets us replace coins by enumeration. If sufficiently hard functions exist, BPP=P\mathsf{BPP} = \mathsf{P}.

Definitions

(S,ε)(S,\varepsilon)-pseudorandom. A distribution RR over {0,1}m\{0,1\}^m is (S,ε)(S,\varepsilon)-pseudorandom if every circuit CC of size S\le S is fooled: Pr[C(R)=1]Pr[C(Um)=1]<ε.\big|\Pr[C(R)=1] - \Pr[C(U_m)=1]\big| < \varepsilon. (UmU_m = uniform.)

PRG. A function G:{0,1}{0,1}G : \{0,1\}^* \to \{0,1\}^*, computable in time 2n2^n, is an S()S(\ell)-pseudorandom generator if G(z)=S(z)|G(z)| = S(|z|) and for every \ell the distribution G(U)G(U_\ell) is (S()3,110)\big(S(\ell)^3, \tfrac{1}{10}\big)-pseudorandom.

The generator stretches an \ell-bit seed into S()S(\ell) output bits that fool every circuit of size S()3S(\ell)^3. The bigger the stretch we can certify, the more randomness we save.

PRG \Rightarrow derandomization of BPP

Theorem. If an S()S(\ell)-PRG exists (SS time-constructible, nondecreasing), then for every polytime :NN\ell : \mathbb{N}\to\mathbb{N},

BPTIME(S((n)))DTIME(2c(n)).\mathsf{BPTIME}(S(\ell(n))) \subseteq \mathsf{DTIME}\big(2^{c\,\ell(n)}\big).

Proof sketch. Let LBPTIME(S((n)))L \in \mathsf{BPTIME}(S(\ell(n))) via A(x,r)A(x,r) with rr of length mS((n))m \le S(\ell(n)) and Prr[A(x,r)=L(x)]2/3\Pr_r[A(x,r)=L(x)] \ge 2/3. Replace the mm truly-random bits by G(z)G(z) for zR{0,1}(n)z \in_R \{0,1\}^{\ell(n)}. Enumerate all 2(n)2^{\ell(n)} seeds, compute each G(z)G(z) (time 2(n)2^{\ell(n)}), run the length-S()S(\ell) computation, and take a majority. The success probability can shift by at most 1/101/10 in passing from UmU_m to G(U)G(U_\ell) — otherwise A(x,)A(x,\cdot) (a small circuit) would distinguish G(U)G(U_\ell) from uniform, contradicting the PRG. So correctness stays 2/31/10\ge 2/3 - 1/10. Total time max{2c1(n),S((n))}=2c(n)\max\{2^{c_1\ell(n)}, S(\ell(n))\} = 2^{c\ell(n)}.

Punchline. For (n)=logn\ell(n) = \log n this is 2clogn=poly(n)2^{c\log n} = \mathrm{poly}(n), i.e. BPP=P\mathsf{BPP} = \mathsf{P}. Derandomizing BPP\mathsf{BPP} reduces to building a PRG with a logarithmic-length seed.

The hardness assumption

Average-case hardness. Havg(f)(n)H_{avg}(f)(n) is the largest circuit size SS such that no circuit CC of size SS satisfies $\Pr_{x\in{0,1}^n}[C(x)=f(x)] \ge \tfrac12 + \tfrac1S. I.e. $f cannot even be approximated — predicted noticeably better than a coin flip — by circuits up to size SS.

Such hard ff are believed to exist (e.g. they follow from $\mathsf{NP} \not\subseteq \mathsf{P/poly}$, “3-SAT is hard”).

Warm-ups — append one or two hard bits (via Yao)

Yao’s theorem (unpredictability == pseudorandomness). If for a distribution YY on {0,1}m\{0,1\}^m no size-2S2S circuit predicts bit ii from bits 1..i11..i-1 with advantage >ε/m> \varepsilon/m, then YY is (S,ε)(S,\varepsilon)-pseudorandom.

The Nisan–Wigderson generator (the real thing)

Theorem (Nisan–Wigderson). SS time-constructible, nondecreasing. If there is fDTIME(2O(n))f \in \mathsf{DTIME}(2^{O(n)}) with Havg(f)(n)S(n)H_{avg}(f)(n) \ge S(n), then there is an S(δ)δS(\delta\ell)^\delta-PRG, for some δ>0\delta > 0.

The two warm-ups appended one or two independent hard bits. NW appends many hard bits f(ZI1),,f(ZIm)f(Z_{I_1}), \dots, f(Z_{I_m}) — but to make mm large from a seed of length \ell, the index sets IjI_j must overlap. They must overlap little, or the outputs would be correlated. The right object is a combinatorial design.

(,n,d)(\ell,n,d)-design. A family I={I1,,Im}I = \{I_1,\dots,I_m\} with Ij{1,,}I_j\subseteq\{1,\dots,\ell\}, Ij=n|I_j| = n, and pairwise overlaps IjIjd|I_j \cap I_{j'}| \le d. (Almost-disjoint nn-subsets of an \ell-universe.)

NW generator. NWIf(Z)=f(ZI1)f(ZI2)f(ZIm)\mathrm{NW}^f_I(Z) = f(Z_{I_1})\cdot f(Z_{I_2})\cdots f(Z_{I_m}), where Z{0,1}Z\in\{0,1\}^\ell and ZIjZ_{I_j} is ZZ restricted to the indices in IjI_j.

Two lemmas assemble the theorem:

Proof of L15 — the key “overlap pays off” step. Suppose (for contradiction, via Yao) a size-S/2S/2 circuit CC predicts output bit ii, i.e. PrZ[C(f(ZI1),,f(ZIi1))=f(ZIi)]12+1102d/10\Pr_Z[C(f(Z_{I_1}),\dots,f(Z_{I_{i-1}})) = f(Z_{I_i})] \ge \tfrac12 + \tfrac{1}{10\cdot 2^{d/10}}. Split Z=(Z1,Z2)Z = (Z_1, Z_2) into the bits inside IiI_i and the rest, and fix Z2Z_2 by an averaging argument. Now every other output f(ZIj)f(Z_{I_j}) depends on the variable Z1Z_1 only through IiIjd|I_i \cap I_j| \le d coordinates — so each is computed by a tiny circuit of size d2d\le d\,2^d. Hard-wiring these into CC yields a circuit BB of size

2d/10#other outputsd2deach cheap+S/2C  <  S\underbrace{2^{d/10}}_{\#\text{other outputs}} \cdot \underbrace{d\,2^d}_{\text{each cheap}} + \underbrace{S/2}_{C} \;<\; S

that approximates ff on nn-bit inputs with advantage 12+1S\ge \tfrac12 + \tfrac1Scontradicting Havg(f)>22dH_{avg}(f) > 2^{2d}. \square

The whole arc in one breath. A function ff that is hard on average (no small circuit approximates it) can be sampled at mm almost-independent windows of one short seed; because the windows overlap in d\le d places, an adversary trying to predict one output bit could be turned into a small circuit for ff — impossible. So the output looks random to all small circuits: a PRG. Plug the PRG into the BPP theorem, set the seed to O(logn)O(\log n), and randomness was never needed: BPP=P\mathsf{BPP}=\mathsf{P}.


Closing themes table

Method What the analysis needed What you replace coins with Cost / Yield
Enumeration nothing try all 2r(n)2^{r(n)} seeds poly iff r(n)=O(logn)r(n)=O(\log n)
Non-uniform advice error <2n<2^{-n} one fixed string per length BPPP/poly\mathsf{BPP}\subseteq\mathsf{P/poly}, non-constructive
RP matrix theorem majority of seeds correct nn seeds (greedy set cover) small witness set, size nn
Conditional probabilities only the expectation E[C]\mathbb{E}[C] fix bits one-by-one, steer to better child deterministic E[C]\ge \mathbb{E}[C] object
Pessimistic estimator a poly-computable upper bound on failure drive P~root<1\widetilde P_{\text{root}}<1 down the tree works when Pr[good]\Pr[\text{good}] is not an expectation (Set Balancing)
Pairwise independence only 2-variable interactions jJibj\bigoplus_{j\in J_i} b_j, O(logn)O(\log n) bits O(n)O(n)-size space, enumerate (MIS NC2\to \mathsf{NC}^2)
kk-wise independence kk-variable interactions linear codes (any kk columns indep.) space poly(n)\mathrm{poly}(n) / O(nk)O(n^k)
Covering codes a ball contains a solution run Promise-Ball solver at every center deterministic kk-SAT \approx randomized time
PRG (Nisan–Wigderson) fool size-SS circuits stretch hard function over a design hardness \Rightarrow BPP=P\mathsf{BPP}=\mathsf{P}

The unifying lesson: derandomization is accounting. Find out exactly how much randomness the proof actually consumed — the expectation only? pairwise correlations only? indistinguishability to small circuits only? — and supply precisely that much from a tiny, enumerable source. The less the analysis truly needed, the cheaper (and sometimes free) the coins turn out to be.

derandomizationconditional-probabilitiespessimistic-estimatorpairwise-independencek-wise-independencecovering-codesSchoning-kSATparallel-MISMaxCutSetBalancingpseudorandom-generatorsNisan-Wigdersonhardness-vs-randomnessBPP

← Back to Randomized Algorithms