The Lovász Local Lemma
The union bound proves that no bad event happens, with positive probability, when the bad probabilities add up to less than 1. At the other extreme, if the bad events are mutually independent, none of them happens with probability , however many there are. The Lovász Local Lemma (LLL) covers the large middle ground: many bad events, each one rare and each one dependent on only a few others. It was proved by Erdős and Lovász (1975) and is one of the most powerful existence tools in combinatorics. This lesson states the symmetric and general forms, proves them, and applies the lemma to -SAT. The next lesson turns it into an algorithm.
Dependency graphs
An event is mutually independent of a set of events if for every event formed from the by intersections and complements (with ). This is stronger than being independent of each separately.
A dependency graph for events is a graph on such that each is mutually independent of the events that are not its neighbours. Write for the neighbours of . In the most common setting, the variable setting, every event is determined by a few independent random variables, and and are adjacent when and share a variable; that graph is always a valid dependency graph.
The symmetric lemma
Theorem (symmetric LLL). Let be events with for all , with a dependency graph of maximum degree at most . If
then : with positive probability, none of the events happens.
The original condition of Erdős and Lovász was ; the sharper form above is due to Lovász and first appeared in a paper of Spencer (1977). The constant cannot be improved in general (Shearer, 1985). Notice what is absent: the number of events. A billion bad events are fine as long as each one is rare and locally dependent.
The general lemma and its proof
Theorem (general LLL). If there are numbers with
then .
The symmetric version follows with : then , using .
Proof of the general lemma
Claim. For every and every set with ,
Induction on . Split into and , and write . If , then is mutually independent of the events in , so the conditional probability is . Otherwise
The numerator is at most , by mutual independence from . For the denominator, list and use the chain rule:
where each conditional probability is at most by the induction hypothesis (the conditioning set is smaller than ). Dividing gives the claim.
The lemma. By the chain rule and the claim,
Application: sparse -SAT is satisfiable
A -CNF formula has clauses of exactly literals on distinct variables. Choose every variable independently and uniformly. Clause is violated only if all of its literals are false, so . The event is determined by the variables of , so and need to be adjacent only when the clauses share a variable.
Corollary. If every clause shares variables with at most other clauses and , the formula is satisfiable. In particular this holds when no variable occurs in more than clauses.
Proof. The first part is the symmetric LLL with . For the second, a clause has variables, each in at most clauses including itself, so and .
The number of clauses plays no role. The program builds a 5-CNF formula with 100 variables in which every variable occurs in exactly 2 clauses (, so the occurrence bound holds). There are 40 clauses, so the union bound fails (), yet the LLL guarantees a satisfying assignment.
import random
from math import e
rng = random.Random(21)
n, k = 100, 5
slots = [v for v in range(n) for _ in range(2)] # every variable in exactly 2 clauses
while True:
rng.shuffle(slots)
clauses = [slots[i:i + k] for i in range(0, len(slots), k)]
if all(len(set(c)) == k for c in clauses): # distinct variables in each clause
break
clauses = [[(v, rng.choice((True, False))) for v in c] for c in clauses] # literal: (variable, wanted value)
m = len(clauses)
deg = [sum(1 for j, D in enumerate(clauses) if j != i and {v for v, _ in C} & {v for v, _ in D})
for i, C in enumerate(clauses)]
d = max(deg)
p = 2 ** -k
print(f"{m} clauses of width {k} on {n} variables; max dependency degree d = {d}")
print(f"union bound: m p = {m * p:.3f} (>= 1, no conclusion)")
print(f"symmetric LLL: e p (d + 1) = {e * p * (d + 1):.3f} (<= 1, satisfiable)")
print(f"general LLL lower bound on Pr[random assignment satisfies]: (1 - 1/(d+1))^m = {(1 - 1 / (d + 1)) ** m:.2e}")
def satisfied(assign):
return all(any(assign[v] == want for v, want in C) for C in clauses)
samples = 5000
good = sum(satisfied([rng.random() < 0.5 for _ in range(n)]) for _ in range(samples))
print(f"measured fraction of satisfying random assignments: {good / samples:.3f}; (1 - p)^m = {(1 - p) ** m:.3f}")40 clauses of width 5 on 100 variables; max dependency degree d = 5
union bound: m p = 1.250 (>= 1, no conclusion)
symmetric LLL: e p (d + 1) = 0.510 (<= 1, satisfiable)
general LLL lower bound on Pr[random assignment satisfies]: (1 - 1/(d+1))^m = 6.80e-04
measured fraction of satisfying random assignments: 0.289; (1 - p)^m = 0.281
The LLL's lower bound is tiny, below here, but it is positive, and that is all an existence proof needs. Here the true probability is much larger, close to , because the clauses overlap so little that they behave almost independently. In general, satisfying assignments guaranteed by the LLL can be exponentially rare, so sampling random assignments until one works is not an efficient algorithm. The program below shows the effect on 6-CNF formulas in which every variable occurs in 3 clauses (, so the LLL condition holds for every size).
import random
from math import e
def lll_instance(n, k, occ, rng):
"""Each round cuts a random permutation of the variables into clauses of k distinct variables."""
clauses = []
for _ in range(occ):
perm = list(range(n))
rng.shuffle(perm)
clauses += [[(v, rng.random() < 0.5) for v in perm[i:i + k]] for i in range(0, n, k)]
return clauses
rng = random.Random(22)
k, occ = 6, 3 # 2^6 / (6e) = 3.92, so 3 occurrences per variable are allowed
print(" n clauses e p (d+1) (1 - p)^m satisfying among 1000 random assignments")
for n in [48, 96, 192, 384]:
cl = lll_instance(n, k, occ, rng)
vs = [{v for v, _ in C} for C in cl]
d = max(sum(1 for j in range(len(cl)) if j != i and vs[i] & vs[j]) for i in range(len(cl)))
good = 0
for _ in range(1000):
a = [rng.random() < 0.5 for _ in range(n)]
good += all(any(a[v] == w for v, w in C) for C in cl)
print(f"{n:3} {len(cl):7} {e * 2 ** -k * (d + 1):9.3f} {(1 - 2 ** -k) ** len(cl):9.4f} {good}") n clauses e p (d+1) (1 - p)^m satisfying among 1000 random assignments
48 24 0.552 0.6853 692
96 48 0.552 0.4696 472
192 96 0.552 0.2205 223
384 192 0.552 0.0486 41
As grows, the fraction of satisfying assignments shrinks exponentially (roughly like with proportional to ), while the LLL still guarantees that one exists. Finding one efficiently needed a new idea, which arrived 35 years after the lemma: Moser-Tardos resampling.
Other applications, stated
- Hypergraph 2-colouring. If every edge of a -uniform hypergraph meets at most other edges and , the vertices can be 2-coloured with no monochromatic edge (each edge is monochromatic with probability ).
- Ramsey lower bounds. The LLL improves the union-bound lower bound for the diagonal Ramsey numbers by a factor of 2: (Spencer, 1977).
- Packet routing. Leighton, Maggs and Rao (1994) used the LLL to show that packets along given paths can be scheduled in steps, where is the congestion and the dilation.
Test yourself
What does the symmetric Lovász Local Lemma require?
- Each , each event depends on at most others, and
- The events are mutually independent
- At most events in total
In a 10-CNF formula, each clause shares variables with at most other clauses. What is the largest for which the LLL guarantees satisfiability?
Why does the LLL not directly give an efficient algorithm?
- Its proof uses the axiom of choice
- The probability it guarantees can be exponentially small, so random sampling may need exponentially many tries
- It only applies to infinite families of events
- Checking the dependency graph is NP-hard
In the variable setting, when must two events be adjacent in the dependency graph?
- Always
- When they depend on a common random variable
- When they have the same probability
- Never