# Randomized Algorithms (Spring 2010)/The probabilistic method

## The Basic Idea

Suppose we want prove the existence of mathematic objects with certain properties. One way to do so is to explicitly construct such an object. This kind of proofs can be interpreted as deterministic algorithms which find the object with desirable properties.

The probabilistic method provides another way of proving the existence of objects: instead of explicitly constructing an object, we define a probability space of objects in which the probability is positive that a randomly selected object has the required property.

The basic principle of the probabilistic method is very simple, and can be stated in intuitive ways:

• If an object chosen randomly from a universe satisfies a property with positive probability, then there must be an object in the universe that satisfies that property.
For example, for a ball(the object) randomly chosen from a box(the universe) of balls, if the probability that the chosen ball is blue(the property) is >0, then there must be a blue ball in the box.
• Any random variable assumes at least one value that is no smaller than its expectation, and at least one value that is no greater than the expectation.
For example, if we know the average height of the students in the class is ${\displaystyle \ell }$, then we know there is a students whose height is at least ${\displaystyle \ell }$, and there is a student whose height is at most ${\displaystyle \ell }$.

Although the idea of the probabilistic method is simple, it provides us a powerful tool for existential proof. In same cases, the proof itself is a randomized algorithm, and if we are lucky, the algorithm could be very efficient.

### Counting or sampling

Circuit complexity

A boolean function is a function is the form ${\displaystyle f:\{0,1\}^{n}\rightarrow \{0,1\}}$.

Formally, a boolean circuit is a directed acyclic graph. Nodes with indegree zero are input nodes, labeled ${\displaystyle x_{1},x_{2},\ldots ,x_{n}}$. A circuit has a unique node with outdegree zero, called the output node. Every other node is a gate. There are three types of gates: AND, OR (both with indegree two), and NOT (with indegree one).

Computations in Turing machines can be simulated by circuits, and any boolean function in P can be computed by a circuit with polynomially many gates. Thus, if we can find a function in NP that cannot be computed by any circuit with polynomially many gates, then NP${\displaystyle \neq }$P.

The following theorem due to Shannon says that functions with exponentially large circuit complexity do exist.

 Theorem (Shannon 1949) There is a boolean function ${\displaystyle f:\{0,1\}^{n}\rightarrow \{0,1\}}$ with circuit complexity greater than ${\displaystyle {\frac {2^{n}}{3n}}}$.
Proof.
 There are ${\displaystyle 2^{2^{n}}}$ boolean functions ${\displaystyle f:\{0,1\}^{n}\rightarrow \{0,1\}}$. Fix an integer ${\displaystyle t}$, we then count the number of circuits with ${\displaystyle t}$ gates. By the De Morgan's laws, we can assume that all NOTs are pushed back to the inputs. Each gate has one of the two types (AND or OR), and has two inputs. Each of the inputs to a gate is either a constant 0 or 1, an input variable ${\displaystyle x_{i}}$, an inverted input variable ${\displaystyle \neg x_{i}}$, or the output of another gate; thus, there are at most ${\displaystyle 2+2n+t-1}$ possible gate inputs. It follows that the number of circuits with ${\displaystyle t}$ gates is at most ${\displaystyle 2^{t}(t+2n+1)^{2t}}$. Uniformly choose a boolean function ${\displaystyle f}$ at random. Note that each circuit can compute one boolean function (the converse is not true). The probability that ${\displaystyle f}$ can be computed by a circuit with ${\displaystyle t}$ gates is at most ${\displaystyle {\frac {2^{t}(t+2n+1)^{2t}}{2^{2^{n}}}}.}$ If ${\displaystyle t=2^{n}/3n}$, then ${\displaystyle {\frac {2^{t}(t+2n+1)^{2t}}{2^{2^{n}}}}=o(1)<1.}$ Therefore, there exists a boolean function ${\displaystyle f}$ which cannot be computed by any circuits with ${\displaystyle 2^{n}/3n}$ gates.
${\displaystyle \square }$

Note that by Shannon's theorem, not only there exists a boolean function with exponentially large circuit complexity, but almost all boolean functions have exponentially large circuit complexity.

Ramsey number

Recall the Ramsey theorem which states that in a meeting of at least six people, there are either three people knowing each other or three people not knowing each other. In graph theoretical terms, this means that no matter how we color the edges of ${\displaystyle K_{6}}$ (the complete graph on six vertices), there must be a monochromatic ${\displaystyle K_{3}}$ (a triangle whose edges have the same color).

Generally, the Ramsey number ${\displaystyle R(k,\ell )}$ is the smallest integer ${\displaystyle n}$ such that in any two-coloring of the edges of a complete graph on ${\displaystyle n}$ vertices ${\displaystyle K_{n}}$ by red and blue, either there is a red ${\displaystyle K_{k}}$ or there is a blue ${\displaystyle K_{\ell }}$.

Ramsey showed in 1929 that ${\displaystyle R(k,\ell )}$ is finite for any ${\displaystyle k}$ and ${\displaystyle \ell }$. It is extremely hard to compute the exact value of ${\displaystyle R(k,\ell )}$. Here we give a lower bound of ${\displaystyle R(k,k)}$ by the probabilistic method.

 Theorem (Erdős 1947) If ${\displaystyle {n \choose k}\cdot 2^{1-{k \choose 2}}<1}$ then it is possible to color the edges of ${\displaystyle K_{n}}$ with two colors so that there is no monochromatic ${\displaystyle K_{k}}$ subgraph.
Proof.
 Consider a random two-coloring of edges of ${\displaystyle K_{n}}$ obtained as follows: For each edge of ${\displaystyle K_{n}}$, independently flip a fair coin to decide the color of the edge. For any fixed set ${\displaystyle S}$ of ${\displaystyle k}$ vertices, let ${\displaystyle {\mathcal {E}}_{S}}$ be the event that the ${\displaystyle K_{k}}$ subgraph induced by ${\displaystyle S}$ is monochromatic. There are ${\displaystyle {k \choose 2}}$ many edges in ${\displaystyle K_{k}}$, therefore ${\displaystyle \Pr[{\mathcal {E}}_{S}]=2\cdot 2^{-{k \choose 2}}=2^{1-{k \choose 2}}.}$ Since there are ${\displaystyle {n \choose k}}$ possible choices of ${\displaystyle S}$, by the union bound ${\displaystyle \Pr[\exists S,{\mathcal {E}}_{S}]\leq {n \choose k}\cdot \Pr[{\mathcal {E}}_{S}]={n \choose k}\cdot 2^{1-{k \choose 2}}.}$ Due to the assumption, ${\displaystyle {n \choose k}\cdot 2^{1-{k \choose 2}}<1}$, thus there exists a two coloring that none of ${\displaystyle {\mathcal {E}}_{S}}$ occurs, which means there is no monochromatic ${\displaystyle K_{k}}$ subgraph.
${\displaystyle \square }$

For ${\displaystyle k\geq 3}$ and we take ${\displaystyle n=\lfloor 2^{k/2}\rfloor }$, then

{\displaystyle {\begin{aligned}{n \choose k}\cdot 2^{1-{k \choose 2}}&<{\frac {n^{k}}{k!}}\cdot {\frac {2^{1+{\frac {k}{2}}}}{2^{k^{2}/2}}}\\&\leq {\frac {2^{k^{2}/2}}{k!}}\cdot {\frac {2^{1+{\frac {k}{2}}}}{2^{k^{2}/2}}}\\&={\frac {2^{1+{\frac {k}{2}}}}{k!}}\\&<1.\end{aligned}}}

By the above theorem, there exists a two-coloring of ${\displaystyle K_{n}}$ that there is no monochromatic ${\displaystyle K_{k}}$. Therefore, the Ramsey number ${\displaystyle R(k,k)>\lfloor 2^{k/2}\rfloor }$ for all ${\displaystyle k\geq 3}$.

Note that for sufficiently large ${\displaystyle k}$, if ${\displaystyle n=\lfloor 2^{k/2}\rfloor }$, then the probability that there exists a monochromatic ${\displaystyle K_{k}}$ is bounded by

${\displaystyle {n \choose k}\cdot 2^{1-{k \choose 2}}<{\frac {2^{1+{\frac {k}{2}}}}{k!}}\ll 1,}$

which means that a random two-coloring of ${\displaystyle K_{n}}$ is very likely not to contain a monochromatic ${\displaystyle K_{2\log n}}$. This gives us a very simple randomized algorithm for finding a two-coloring of ${\displaystyle K_{n}}$ without monochromatic ${\displaystyle K_{2\log n}}$.

Blocking number

Let ${\displaystyle S}$ be a set. Let ${\displaystyle 2^{S}=\{A\mid A\subseteq S\}}$ be the power set of ${\displaystyle S}$, and let ${\displaystyle {S \choose k}=\{A\mid A\subseteq S{\mbox{ and }}|A|=k\}}$ be the ${\displaystyle k}$-uniform of ${\displaystyle S}$.

We call ${\displaystyle {\mathcal {F}}}$ a set family (or a set system) with ground set ${\displaystyle S}$ if ${\displaystyle {\mathcal {F}}\subseteq 2^{S}}$. The members of ${\displaystyle {\mathcal {F}}}$ are subsets of ${\displaystyle S}$.

Given a set family ${\displaystyle {\mathcal {F}}}$ with ground set ${\displaystyle S}$, a set ${\displaystyle T\subseteq S}$ is a blocking set of ${\displaystyle {\mathcal {F}}}$ if all ${\displaystyle A\in {\mathcal {F}}}$ have ${\displaystyle A\cap T\neq \emptyset }$, i.e. ${\displaystyle T}$ intersects (blocks) all member set of ${\displaystyle {\mathcal {F}}}$.

 Theorem Given a set family ${\displaystyle {\mathcal {F}}\subseteq {S \choose k}}$, where ${\displaystyle m=|{\mathcal {F}}|}$ and ${\displaystyle n=|S|}$, ${\displaystyle {\mathcal {F}}}$ has a blocking set of size ${\displaystyle \left\lceil {\frac {n\ln m}{k}}\right\rceil }$.
Proof.
 Let ${\displaystyle \tau =\left\lceil {\frac {n\ln m}{k}}\right\rceil }$. Let ${\displaystyle T}$ be a set chosen uniformly at random from ${\displaystyle {S \choose \tau }}$. We show that ${\displaystyle T}$ is a blocking set of ${\displaystyle {\mathcal {F}}}$ with a probability >0. Fix any ${\displaystyle A\in {\mathcal {F}}}$. Recall that ${\displaystyle {\mathcal {F}}\subseteq {S \choose k}}$, thus ${\displaystyle |A|=k}$. And {\displaystyle {\begin{aligned}\Pr[A\cap T=\emptyset ]&={\frac {\left|{S-A \choose \tau }\right|}{\left|{S \choose \tau }\right|}}\\&={\frac {n-k \choose \tau }{n \choose \tau }}\\&={\frac {(n-k)\cdot (n-k-1)\cdots (n-k-\tau +1)}{n\cdot (n-1)\cdots (n-\tau +1)}}\\&<\left(1-{\frac {k}{n}}\right)^{\tau }\\&\leq \exp \left(-{\frac {k\tau }{n}}\right)\\&\leq {\frac {1}{m}}.\end{aligned}}} By the union bound, the probability that there exists an ${\displaystyle A\in {\mathcal {F}}}$ that misses ${\displaystyle T}$ ${\displaystyle \Pr[\exists A\in {\mathcal {F}},A\cap T=\emptyset ]\leq m\Pr[A\cap T=\emptyset ] Thus, the probability that ${\displaystyle T}$ is a blocking set ${\displaystyle \Pr[\forall A\in {\mathcal {F}},A\cap T\neq \emptyset ]>0.}$ There exists a blocking set of size ${\displaystyle \tau =\left\lceil {\frac {n\ln m}{k}}\right\rceil }$.
${\displaystyle \square }$

The theorem also hints us to a randomized algorithm. In order to make the algorithm efficient, we relax the size of ${\displaystyle T}$ to ${\displaystyle \tau ={\frac {2n\ln m}{k}}}$. Uniformly choose ${\displaystyle \tau }$ elements from ${\displaystyle S}$ to form the set ${\displaystyle T}$, by the above analysis, the probability that ${\displaystyle T}$ is NOT a blocking set is at most

${\displaystyle m\exp \left(-{\frac {n\tau }{k}}\right)=m\exp(-2\ln m)={\frac {1}{m}}.}$

Thus, a blocking set is found with high probability.

### Linearity of expectation

Maximum cut

Given an undirected graph ${\displaystyle G(V,E)}$, a set ${\displaystyle C}$ of edges of ${\displaystyle G}$ is called a cut if ${\displaystyle G}$ is disconnected after removing the edges in ${\displaystyle C}$. We can represent a cut by ${\displaystyle c(S,T)}$ where ${\displaystyle (S,T)}$ is a bipartition of the vertex set ${\displaystyle V}$, and ${\displaystyle c(S,T)=\{uv\in E\mid u\in S,v\in T\}}$ is the set of edges crossing between ${\displaystyle S}$ and ${\displaystyle T}$.

We have seen how to compute min-cut: either by deterministic max-flow algorithm, or by Karger's randomized algorithm. On the other hand, max-cut is hard to compute, because it is NP-complete. Actually, the weighted version of max-cut is among the Karp's 21 NP-complete problems.

We now show by the probabilistic method that a max-cut always has at least half the edges.

 Theorem Given an undirected graph ${\displaystyle G}$ with ${\displaystyle n}$ vertices and ${\displaystyle m}$ edges, there is a cut of size at least ${\displaystyle {\frac {m}{2}}}$.
Proof.
 Enumerate the vertices in an arbitrary order. Partition the vertex set ${\displaystyle V}$ into two disjoint sets ${\displaystyle S}$ and ${\displaystyle T}$ as follows. For each vertex ${\displaystyle v\in V}$, independently choose one of ${\displaystyle S}$ and ${\displaystyle T}$ with equal probability, and let ${\displaystyle v}$ join the chosen set. For each vertex ${\displaystyle v\in V}$, let ${\displaystyle X_{v}\in \{S,T\}}$ be the random variable which represents the set that ${\displaystyle v}$ joins. For each edge ${\displaystyle uv\in E}$, let ${\displaystyle Y_{uv}}$ be the 0-1 random variable which indicates whether ${\displaystyle uv}$ crosses between ${\displaystyle S}$ and ${\displaystyle T}$. Clearly, ${\displaystyle \Pr[Y_{uv}=1]=\Pr[X_{u}\neq X_{v}]={\frac {1}{2}}.}$ The size of ${\displaystyle c(S,T)}$ is given by ${\displaystyle Y=\sum _{uv\in E}Y_{uv}}$. By the linearity of expectation, ${\displaystyle \mathbf {E} [Y]=\sum _{uv\in E}\mathbf {E} [Y_{uv}]=\sum _{uv\in E}\Pr[Y_{uv}=1]={\frac {m}{2}}.}$ Therefore, there exist a bipartition ${\displaystyle (S,T)}$ of ${\displaystyle V}$ such that ${\displaystyle |c(S,T)|\geq {\frac {m}{2}}}$, i.e. there exists a cut of ${\displaystyle G}$ which contains at least ${\displaystyle {\frac {m}{2}}}$ edges.
${\displaystyle \square }$

Maximum satisfiability

Suppose that we have a number of boolean variables ${\displaystyle x_{1},x_{2},\ldots ,\in \{\mathrm {true} ,\mathrm {false} \}}$. A literal is either a variable ${\displaystyle x_{i}}$ itself or its negation ${\displaystyle \neg x_{i}}$. A logic expression is a conjunctive normal form (CNF) if it is written as the conjunction(AND) of a set of clauses, where each clause is a disjunction(OR) of literals. For example:

${\displaystyle (x_{1}\vee \neg x_{2}\vee \neg x_{3})\wedge (\neg x_{1}\vee \neg x_{3})\wedge (x_{1}\vee x_{2}\vee x_{4})\wedge (x_{4}\vee \neg x_{3})\wedge (x_{4}\vee \neg x_{1}).}$

The satisfiability (SAT) problem ask whether the CNF is satisfiable, i.e. there exists an assignment of variables to the values of true and false so that all clauses are true. The maximum satisfiability (MAXSAT) is the optimization version of SAT, which ask for an assignment that the number of satisfied clauses is maximized.

SAT is the first problem known to be NP-complete (the Cook-Levin theorem). MAXSAT is also NP-complete. We then see that there always exists a roughly good truth assignment which satisfies half the clauses.

 Theorem For any set of ${\displaystyle m}$ clauses, there is a truth assignment that satisfies at least ${\displaystyle {\frac {m}{2}}}$ clauses.
Proof.
 For each variable, independently assign a random value in ${\displaystyle \{\mathrm {true} ,\mathrm {false} \}}$ with equal probability. For the ${\displaystyle i}$th clause, let ${\displaystyle X_{i}}$ be the random variable which indicates whether the ${\displaystyle i}$th clause is satisfied. Suppose that there are ${\displaystyle k}$ literals in the clause. The probability that the clause is satisfied is ${\displaystyle \Pr[X_{k}=1]\geq (1-2^{-k})\geq {\frac {1}{2}}}$. Let ${\displaystyle X=\sum _{i=1}^{m}X_{i}}$ be the number of satisfied clauses. By the linearity of expectation, ${\displaystyle \mathbf {E} [X]=\sum _{i=1}^{m}\mathbf {E} [X_{i}]\geq {\frac {m}{2}}.}$ Therefore, there exists an assignment such that at least ${\displaystyle {\frac {m}{2}}}$ clauses are satisfied.
${\displaystyle \square }$

## Alterations

### Independent sets

An independent set of a graph is a set of vertices with no edges between them. The following theorem gives a lower bound on the size of the largest independent set.

 Theorem Let ${\displaystyle G(V,E)}$ be a graph on ${\displaystyle n}$ vertices with ${\displaystyle m}$ edges. Then ${\displaystyle G}$ has an independent set with at least ${\displaystyle {\frac {n^{2}}{4m}}}$ vertices.
Proof.
 Let ${\displaystyle S}$ be a set of vertices constructed as follows: For each vertex ${\displaystyle v\in V}$: ${\displaystyle v}$ is included in ${\displaystyle S}$ independently with probability ${\displaystyle p}$, ${\displaystyle p}$ to be determined. Let ${\displaystyle X=|S|}$. It is obvious that ${\displaystyle \mathbf {E} [X]=np}$. For each edge ${\displaystyle e\in E}$, let ${\displaystyle Y_{e}}$ be the random variable which indicates whether both endpoints of are in ${\displaystyle S}$. ${\displaystyle \mathbf {E} [Y_{uv}]=\Pr[u\in S\wedge v\in S]=p^{2}.}$ Let ${\displaystyle Y}$ be the number of edges in the subgraph of ${\displaystyle G}$ induced by ${\displaystyle S}$. It holds that ${\displaystyle Y=\sum _{e\in E}Y_{e}}$. By linearity of expectation, ${\displaystyle \mathbf {E} [Y]=\sum _{e\in E}\mathbf {E} [Y_{e}]=mp^{2}}$. Note that although ${\displaystyle S}$ is not necessary an independent set, it can be modified to one if for each edge ${\displaystyle e}$ of the induced subgraph ${\displaystyle G(S)}$, we delete one of the endpoint of ${\displaystyle e}$ from ${\displaystyle S}$. Let ${\displaystyle S^{*}}$ be the resulting set. It is obvious that ${\displaystyle S^{*}}$ is an independent set since there is no edge left in the induced subgraph ${\displaystyle G(S^{*})}$. Since there are ${\displaystyle Y}$ edges in ${\displaystyle G(S)}$, there are at most ${\displaystyle Y}$ vertices in ${\displaystyle S}$ are deleted to make it become ${\displaystyle S^{*}}$. Therefore, ${\displaystyle |S^{*}|\geq X-Y}$. By linearity of expectation, ${\displaystyle \mathbf {E} [|S^{*}|]\geq \mathbf {E} [X-Y]=\mathbf {E} [X]-\mathbf {E} [Y]=np-mp^{2}.}$ The expectation is maximized when ${\displaystyle p={\frac {n}{2m}}}$, thus ${\displaystyle \mathbf {E} [|S^{*}|]\geq n\cdot {\frac {n}{2m}}-m\left({\frac {n}{2m}}\right)^{2}={\frac {n^{2}}{4m}}.}$ There exists an independent set which contains at least ${\displaystyle {\frac {n^{2}}{4m}}}$ vertices.
${\displaystyle \square }$

The proof actually propose a randomized algorithm for constructing large independent set:

 Algorithm Given a graph on ${\displaystyle n}$ vertices with ${\displaystyle m}$ edges, let ${\displaystyle d={\frac {2m}{n}}}$ be the average degree. For each vertex ${\displaystyle v\in V}$, ${\displaystyle v}$ is included in ${\displaystyle S}$ independently with probability ${\displaystyle {\frac {1}{d}}}$. For each remaining edge in the induced subgraph ${\displaystyle G(S)}$, remove one of the endpoints from ${\displaystyle S}$.

Let ${\displaystyle S^{*}}$ be the resulting set. We have shown that ${\displaystyle S^{*}}$ is an independent set and ${\displaystyle \mathbf {E} [|S^{*}|]\geq {\frac {n^{2}}{4m}}}$.

### Intersecting families

An ${\displaystyle {\mathcal {F}}\subseteq 2^{S}}$ is an intersecting family if for any ${\displaystyle A,B\in {\mathcal {F}}}$ it holds that ${\displaystyle A\cap B\neq \emptyset }$.

Suppose that ${\displaystyle n\geq 2k}$. For ${\displaystyle {\mathcal {F}}\subseteq {S \choose k}}$, where ${\displaystyle |S|=n}$, we can let all ${\displaystyle A\in {\mathcal {F}}}$ contain one common element ${\displaystyle a\in S}$ and ${\displaystyle A-\{a\}}$ enumerates all ${\displaystyle {n-1 \choose k-1}}$ possible combinations of ${\displaystyle (k-1)}$ elements in ${\displaystyle S}$. This gives us an intersecting family of size ${\displaystyle |{\mathcal {F}}|={n-1 \choose k-1}}$.

The following theorem says that this is the largest possible cardinality an intersecting ${\displaystyle {\mathcal {F}}}$ can achieve. The theorem was first proved by Erdős, Ko, and Rado in 1938, but published 23 years later. It is a fundamental result in the area of extremal set theory, which studies the maximum (or minimum) possible cardinality of a set system satisfying certain structural assumption. In this example, the structural assumption is intersecting.

Here we present a probabilistic proof by Katona.

 Theorem (Erdős-Ko-Rado 1961) Let ${\displaystyle {\mathcal {F}}\subseteq {S \choose k}}$, where ${\displaystyle |S|=n}$ and ${\displaystyle n\geq 2k}$. If ${\displaystyle {\mathcal {F}}}$ is an intersecting family then ${\displaystyle |{\mathcal {F}}|\leq {n-1 \choose k-1}}$.
Proof.
 (due to Katona 1972). Without loss of generality, let ${\displaystyle S=[n]}$. For ${\displaystyle i\in [n]}$, let ${\displaystyle A_{i}=\{(i+j){\bmod {n}}\mid j\in [k]\}}$. Then we make the following claim. Claim 1: ${\displaystyle {\mathcal {F}}}$ can contain at most ${\displaystyle k}$ many ${\displaystyle A_{i}}$. The claim can be easily proved by observing that for any ${\displaystyle i,j\in [n]}$ that ${\displaystyle i, ${\displaystyle A_{i}}$ and ${\displaystyle A_{j}}$ are disjoint if ${\displaystyle j-i>k}$, thus in order to make ${\displaystyle {\mathcal {F}}}$ intersecting, all ${\displaystyle A_{i},A_{j}\in {\mathcal {F}}}$ have ${\displaystyle |i-j|\leq k}$. This is violated once there are more than ${\displaystyle k}$ many ${\displaystyle A_{i}}$ in ${\displaystyle {\mathcal {F}}}$. Now we prove the Erdős-Ko-Rado theorem. Let a permutation ${\displaystyle \sigma }$ of ${\displaystyle [n]}$ and an integer ${\displaystyle i\in [n]}$ be chosen uniformly and independently at random. Let ${\displaystyle R=\{\sigma ((i+j){\bmod {n}})\mid j\in [k]\},\quad {\mbox{ or equivalently }}R=\sigma (A_{i})}$. By Claim 1, for any fixed permutation ${\displaystyle \sigma }$, the family ${\displaystyle {\mathcal {F}}}$ can contain at most ${\displaystyle k}$ of the sets ${\displaystyle \sigma (A_{i})}$, thus conditioning on any particular ${\displaystyle \sigma }$, ${\displaystyle \Pr[R\in {\mathcal {F}}\mid \sigma ]\leq {\frac {k}{n}}}$. Hence ${\displaystyle \Pr[R\in {\mathcal {F}}]\leq {\frac {k}{n}}.}$ On the other hand, by our construction, ${\displaystyle R}$ is uniformly chosen from ${\displaystyle {S \choose k}}$, thus ${\displaystyle \Pr[R\in {\mathcal {F}}]={\frac {|{\mathcal {F}}|}{n \choose k}}.}$ Therefore, ${\displaystyle |{\mathcal {F}}|\leq {\frac {k}{n}}{n \choose k}={n-1 \choose k-1}.}$
${\displaystyle \square }$

## The Lovász Local Lemma

Consider a set of "bad" events ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$. Suppose that ${\displaystyle \Pr[A_{i}]\leq p}$ for all ${\displaystyle 1\leq i\leq n}$. We want to show that there is a situation that none of the bad events occurs. Due to the probabilistic method, we need to prove that

${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right]>0.}$
Case 1: mutually independent events.

If all the bad events ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$ are mutually independent, then

${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right]\geq (1-p)^{n}>0,}$

for any ${\displaystyle p<1}$.

Case 2: arbitrarily dependent events.

On the other hand, if we put no assumption on the dependencies between the events, then by the union bound (which holds unconditionally),

${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right]=1-\Pr \left[\bigvee _{i=1}^{n}A_{i}\right]\geq 1-np,}$

which is not an interesting bound for ${\displaystyle p\geq {\frac {1}{n}}}$. If we make no further assumption on the dependencies between the events, this bound is tight.

Example
Consider that a ball is uniformly thrown into one of the ${\displaystyle (n+1)}$ bins. Let the "bad" events ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$ be defined as that ${\displaystyle A_{i}}$ represents that the ball falls into the ${\displaystyle i}$th bin. The only good event is that the ball falls into the ${\displaystyle (n+1)}$th bin. Clearly, ${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right]=1-n\cdot {\frac {1}{n+1}}}$. Thus the above union bound is achieved.

This example shows that dependencies between the events could cause troubles.

We would like to know what is going on between the two extreme cases: mutually independent events, and arbitrarily dependent events. The Lovász local lemma provides such a tool.

### The local lemma

The local lemma is powerful tool for showing the possibility of rare event under limited dependencies. The structure of dependencies between a set of events is described by a dependency graph.

 Definition Let ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$ be a set of events. A graph ${\displaystyle D=(V,E)}$ on the set of vertices ${\displaystyle V=\{1,2,\ldots ,n\}}$ is called a dependency graph for the events ${\displaystyle A_{1},\ldots ,A_{n}}$ if for each ${\displaystyle i}$, ${\displaystyle 1\leq i\leq n}$, the event ${\displaystyle A_{i}}$ is mutually independent of all the events ${\displaystyle \{A_{j}\mid (i,j)\not \in E\}}$.
Example
Let ${\displaystyle X_{1},X_{2},\ldots ,X_{m}}$ be a set of mutually independent random variables. Each event ${\displaystyle A_{i}}$ is a predicate defined on a number of variables among ${\displaystyle X_{1},X_{2},\ldots ,X_{m}}$. Let ${\displaystyle v(A_{i})}$ be the unique smallest set of variables which determine ${\displaystyle A_{i}}$. The dependency graph ${\displaystyle D=(V,E)}$ is defined by
${\displaystyle (i,j)\in E}$ iff ${\displaystyle v(A_{i})\cap v(A_{j})\neq \emptyset }$.

This construction gives a general framework for the probability spaces with limited dependencies and is central to the constructive proof of the Lovász local lemma. In this example, each event is a predicate of variables, and the events are dependent if they depend on some common events.

The following lemma, known as the Lovász local lemma, first proved by Erdős and Lovász in 1975, is an extremely powerful tool, as it supplies a way for dealing with rare events.

 Theorem (The local lemma: general case) Let ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$ be a set of events. Suppose that ${\displaystyle D=(V,E)}$ is a dependency graph for the events and suppose there are real numbers ${\displaystyle x_{1},x_{2},\ldots ,x_{n}}$ such that ${\displaystyle 0\leq x_{i}<1}$ and for all ${\displaystyle 1\leq i\leq n}$, ${\displaystyle \Pr[A_{i}]\leq x_{i}\prod _{(i,j)\in E}(1-x_{j})}$. Then ${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right]\geq \prod _{i=1}^{n}(1-x_{i})}$.

The following is a special case, the symmetric version of the Lovász local lemma.

 Theorem (The local lemma: symmetric case) Let ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$ be a set of events, and assume that the following hold: for all ${\displaystyle 1\leq i\leq n}$, ${\displaystyle \Pr[A_{i}]\leq p}$; the maximum degree of the dependency graph for the events ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$ is ${\displaystyle d}$, and ${\displaystyle ep(d+1)\leq 1}$. Then ${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right]>0}$.

The original proof of the local lemma is by induction. Here we will present a constructive proof for a special case, which is more algorithmic than the original proof. This proof is due to Moser, first published in his talk in STOC 2009, and later a generalized version collaborated with Tardos appears in JACM 2010.

### Moser's proof

We consider a restrictive case.

Let ${\displaystyle X_{1},X_{2},\ldots ,X_{m}\in \{\mathrm {true} ,\mathrm {false} \}}$ be a set of mutually independent random variables which assume boolean values. Each event ${\displaystyle A_{i}}$ is an AND of at most ${\displaystyle k}$ literals (${\displaystyle X_{i}}$ or ${\displaystyle \neg X_{i}}$). Let ${\displaystyle v(A_{i})}$ be the set of the ${\displaystyle k}$ variables that ${\displaystyle A_{i}}$ depends on. The probability that none of the bad events occurs is

${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right].}$

In this particular model, the dependency graph ${\displaystyle D=(V,E)}$ is defined as that ${\displaystyle (i,j)\in E}$ iff ${\displaystyle v(A_{i})\cap v(A_{j})\neq \emptyset }$.

Observe that ${\displaystyle {\overline {A_{i}}}}$ is a clause (OR of literals). Thus, ${\displaystyle \bigwedge _{i=1}^{n}{\overline {A_{i}}}}$ is a ${\displaystyle k}$-CNF, the CNF that each clause depends on ${\displaystyle k}$ variables. The probability

${\displaystyle \bigwedge _{i=1}^{n}{\overline {A_{i}}}>0}$

means that the the ${\displaystyle k}$-CNF ${\displaystyle \bigwedge _{i=1}^{n}{\overline {A_{i}}}}$ is satisfiable.

The satisfiability of ${\displaystyle k}$-CNF is a hard problem. In particular, 3SAT (the satisfiability of 3-CNF) is the first NP-complete problem (the Cook-Levin theorem). Given the current suspect on NP vs P, we do not expect to solve this problem generally.

However, the condition of the Lovasz local lemma has an extra assumption on the degree of dependency graph. In our model, this means that each clause shares variables with at most ${\displaystyle d}$ other clauses. We call a ${\displaystyle k}$-CNF with this property a ${\displaystyle k}$-CNF with bounded degree ${\displaystyle d}$.

Therefore, proving the Lovasz local lemma on the restricted forms of events as described above, can be reduced to the following problem:

Problem
Find a condition on ${\displaystyle k}$ and ${\displaystyle d}$, such that any ${\displaystyle k}$-CNF with bounded degree ${\displaystyle d}$ is satisfiable.

In 2009, Moser comes up with the following procedure solving the problem. He later generalizes the procedure to general forms of events. This not only gives a beautiful constructive proof to the Lovasz local lemma, but also provides an efficient randomized algorithm for finding a satisfiable assignment for a number of events with bounded dependencies.

Let ${\displaystyle \phi }$ be a ${\displaystyle k}$-CNF of ${\displaystyle n}$ clauses with bounded degree ${\displaystyle d}$, defined on variables ${\displaystyle X_{1},\ldots ,X_{m}}$. The following procedure find a satisfiable assignment for ${\displaystyle \phi }$.

 Solve(${\displaystyle \phi }$) Pick a random assignment of ${\displaystyle X_{1},\ldots ,X_{m}}$. While there is an unsatisfied clause ${\displaystyle C}$ in ${\displaystyle \phi }$ Fix(${\displaystyle C}$).

The sub-routine Fix is defined as follows:

 Fix(${\displaystyle C}$) Replace the variables in ${\displaystyle v(C)}$ with new random values. While there is unsatisfied clause ${\displaystyle D}$ that ${\displaystyle v(C)\cap v(D)\neq \emptyset }$ Fix(${\displaystyle D}$).

The procedure looks very simple. It just recursively fixes the unsatisfied clauses by randomly replacing the assignment to the variables.

We then prove it works.

#### Number of top-level callings of Fix

In Solve(${\displaystyle \phi }$), the subroutine Fix(${\displaystyle C}$) is called. We now upper bound the number of times it is called (not including the recursive calls).

Assume Fix(${\displaystyle C}$) always terminates.

Observation
Every clause that was satisfied before Fix(${\displaystyle C}$) was called will still remain satisfied and ${\displaystyle C}$ will also be satisfied after Fix(${\displaystyle C}$) returns.

The observation can be proved by induction on the structure of recursion. Since there are ${\displaystyle n}$ clauses, Solve(${\displaystyle \phi }$) makes at most ${\displaystyle n}$ calls to Fix.

We then prove that Fix(${\displaystyle C}$) terminates.

#### Termination of Fix

The idea of the proof is to reconstruct a random string.

Suppose that during the running of Solve(${\displaystyle \phi }$), the Fix subroutine is called for ${\displaystyle t}$ times (including all the recursive calls).

Let ${\displaystyle s}$ be the sequence of the random bits used by Solve(${\displaystyle \phi }$). It is easy to see that the length of ${\displaystyle s}$ is ${\displaystyle |s|=m+tk}$, because the initial random assignment of ${\displaystyle m}$ variables takes ${\displaystyle m}$ bits, and each time of calling Fix takes ${\displaystyle k}$ bits.

We then reconstruct ${\displaystyle s}$ in an alternative way.

Recall that Solve(${\displaystyle \phi }$) calls Fix(${\displaystyle C}$) at top-level for at most ${\displaystyle n}$ times. Each calling of Fix(${\displaystyle C}$) defines a recursion tree, rooted at clause ${\displaystyle C}$, and each node corresponds to a clause (not necessarily distinct, since a clause might be fixed for several times). Therefore, the entire running history of Solve(${\displaystyle \phi }$) can be described by at most ${\displaystyle n}$ recursion trees.

Observation 1
Fix a ${\displaystyle \phi }$. The ${\displaystyle n}$ recursion trees which capture the total running history of Solve(${\displaystyle \phi }$) can be encoded in ${\displaystyle n\log n+t(\log d+O(1))}$ bits.

Each root node corresponds to a clause. There are ${\displaystyle n}$ clauses in ${\displaystyle \phi }$. The ${\displaystyle n}$ root nodes can be represented in ${\displaystyle n\log n}$ bits.

The smart part is how to encode the branches of the tree. Note that Fix(${\displaystyle C}$) will call Fix(${\displaystyle D}$) only for the ${\displaystyle D}$ that shares variables with ${\displaystyle C}$. For a k-CNF with bounded degree ${\displaystyle d}$, each clause ${\displaystyle C}$ can share variables with at most ${\displaystyle d}$ many other clauses. Thus, each branch in the recursion tree can be represented in ${\displaystyle \log d}$ bits. There are extra ${\displaystyle O(1)}$ bits needed to denote whether the recursion ends. So totally ${\displaystyle n\log n+t(\log d+O(1))}$ bits are sufficient to encode all ${\displaystyle n}$ recursion trees.

Observation 2
The random sequence ${\displaystyle s}$ can be encoded in ${\displaystyle m+n\log n+t(\log d+O(1))}$ bits.

With ${\displaystyle n\log n+t(\log d+O(1))}$ bits, the structure of all the recursion trees can be encoded. With extra ${\displaystyle m}$ bits, the final assignment of the ${\displaystyle m}$ variables is stored.

We then observe that with these information, the sequence of the random bits ${\displaystyle s}$ can be reconstructed from backwards from the final assignment.

The key step is that a clause ${\displaystyle C}$ is only fixed when it is unsatisfied (obvious), and an unsatisfied clause ${\displaystyle C}$ must have exact one assignment (a clause is OR of literals, thus has exact one unsatisfied assignment). Thus, each node in the recursion tree tells the ${\displaystyle k}$ random bits in the random sequence ${\displaystyle s}$ used in the call of the Fix corresponding to the node. Therefore, ${\displaystyle s}$ can be reconstructed from the final assignment plus at most ${\displaystyle n}$ recursion trees, which can be encoded in at most ${\displaystyle m+n\log n+t(\log d+O(1))}$ bits.

The following theorem lies in the heart of the Kolmogorov complexity. The theorem states that random sequence is incompressible.

 Theorem (Kolmogorov) For any encoding scheme , with high probability, a random sequence ${\displaystyle s}$ is encoded in at least ${\displaystyle |s|}$ bits.

Applying the theorem, we have that with high probability,

${\displaystyle m+n\log n+t(\log d+O(1))\geq |s|=m+tk}$.

Therefore,

${\displaystyle t(k-O(1)-\log d)\leq n\log n.}$

In order to bound ${\displaystyle t}$, we need

${\displaystyle k-O(1)-\log d>0}$,

which hold for ${\displaystyle d<2^{k-\alpha }}$ for some constant ${\displaystyle \alpha >0}$. In fact, in this case, ${\displaystyle t=O(n\log n)}$, the running time of the procedure is bounded by a polynomial!

#### Back to the local lemma

We showed that for ${\displaystyle d<2^{k-O(1)}}$, any ${\displaystyle k}$-CNF with bounded degree ${\displaystyle d}$ is satisfiable, and the satisfied assignment can be found within polynomial time with high probability. Now we interprete this in a language of the local lemma.

Recall that the symmetric version of the local lemma:

 Theorem (The local lemma: symmetric case) Let ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$ be a set of events, and assume that the following hold: for all ${\displaystyle 1\leq i\leq n}$, ${\displaystyle \Pr[A_{i}]\leq p}$; the maximum degree of the dependency graph for the events ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$ is ${\displaystyle d}$, and ${\displaystyle ep(d+1)\leq 1}$. Then ${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right]>0}$.

Suppose the underlying probability space is a number of mutually independent uniform random boolean variables, and the evens ${\displaystyle {\overline {A_{i}}}}$ are clauses defined on ${\displaystyle k}$ variables. Then,

${\displaystyle p=2^{-k}}$

thus, the condition ${\displaystyle ep(d+1)\leq 1}$ means that

${\displaystyle d<2^{k}/e}$

which means the Moser's procedure is asymptotically optimal on the degree of dependency.