# Lovász Local Lemma

Suppose that we are give a set of "bad" events ${\displaystyle A_{1},A_{2},\ldots ,A_{n}}$. We want to know that it is possible that none of them occurs, that is:

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

Obviously, a necessary condition for this is that for none of the bad events its occurrence is certain, i.e. ${\displaystyle \Pr[A_{i}]<1}$ for all ${\displaystyle i}$. We are interested in the sufficient condition for the above. There are two easy cases:

Case 1: mutual independence.

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

${\displaystyle \Pr \left[\bigwedge _{i=1}^{m}{\overline {A_{i}}}\right]=\prod _{i=1}^{m}(1-\Pr[A_{i}])}$

and hence this probability is positive if ${\displaystyle \Pr[A_{i}]<1}$ for all ${\displaystyle i}$.

Case 2: arbitrary dependency.

On the other extreme, if we know nothing about the dependencies between these bad event, the best we can do is to apply the union bound:

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

which is positive if ${\displaystyle \sum _{i=1}^{m}\Pr \left[A_{i}\right]<1}$. This is a very loose bound, however it cannot be further improved if no further information regarding the dependencies between the events is assumed.

## Lovász Local Lemma (symmetric case)

In most situations, the dependencies between events are somewhere between these two extremal cases: the events are not independent of each other, but on the other hand the dependencies between them are not total out of control. For these more general cases, we would like to exploit the tradeoff between probabilities of bad events and dependencies between them.

The Lovász local lemma is such a 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, which is a graph with events as vertices and each event is adjacent to the events which are dependent with it in the dependency graph.

 Definition (dependency graph) Let ${\displaystyle A_{1},A_{2},\ldots ,A_{m}}$ be a set of events. A graph ${\displaystyle D=(V,E)}$ with set of vertices ${\displaystyle V=\{A_{1},A_{2},\ldots ,A_{m}\}}$ is called a dependency graph for the events ${\displaystyle A_{1},\ldots ,A_{m}}$ if every event ${\displaystyle A_{i}}$ is mutually independent of all the events in ${\displaystyle \{A_{j}\mid (A_{i},A_{j})\not \in E\}}$.

The maximum degree ${\displaystyle d}$ of the dependency graph ${\displaystyle D}$ is a very useful information, as it tells us that every event ${\displaystyle A_{i}}$ among ${\displaystyle A_{1},A_{2},\ldots ,A_{m}}$ is dependent with how many other events at most.

Remark on the mutual independence
In probability theory, an event ${\displaystyle A}$ is said to be independent of events ${\displaystyle B_{1},B_{2},\ldots ,B_{k}}$ if for any disjoint ${\displaystyle I,J\subseteq \{1,2,\ldots ,k\}}$, we have
${\displaystyle \Pr \left[A\mid \left(\bigwedge _{i\in I}B_{i}\right)\wedge \left(\bigwedge _{i\in J}{\overline {B}}_{i}\right)\right]=\Pr[A]}$,
that is, occurrences of events among ${\displaystyle B_{1},B_{2},\ldots ,B_{k}}$ have no influence on the occurrence of ${\displaystyle A}$.
Example
Let ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$ 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_{n}}$. Let ${\displaystyle {\mathsf {vbl}}(A_{i})}$ be the unique smallest set of variables which determine ${\displaystyle A_{i}}$. The dependency graph ${\displaystyle D=(V,E)}$ is defined as that any two events ${\displaystyle A_{i},A_{j}}$ are adjacent in ${\displaystyle D}$ if and only if they share variables, i.e. ${\displaystyle {\mathsf {vbl}}(A_{i})\cap {\mathsf {vbl}}(A_{j})\neq \emptyset }$.

The following theorem was proved by Erdős and Lovász in 1975 and then later improved by Lovász in 1977. Now it is commonly referred as the Lovász local lemma. It is a very powerful tool, especially when being used with the probabilistic method, as it supplies a way for dealing with rare events.

 Lovász Local Lemma (symmetric case) Let ${\displaystyle A_{1},A_{2},\ldots ,A_{m}}$ be a set of events, and assume that the followings hold: ${\displaystyle \Pr[A_{i}]\leq p}$ for every event ${\displaystyle A_{i}}$; every event ${\displaystyle A_{i}}$ is mutually independent of all other events except at most ${\displaystyle d}$ of them, and ${\displaystyle \mathrm {e} p(d+1)\leq 1}$. Then ${\displaystyle \Pr \left[\bigwedge _{i=1}^{n}{\overline {A_{i}}}\right]>0}$.

Here ${\displaystyle d}$ is the maximum degree of the dependency graph ${\displaystyle D}$ for the events ${\displaystyle A_{1},\ldots ,A_{m}}$.

Intuitively, the Lovász Local Lemma says that if a rare (but hopefully possible) event is formulated as to avoid a series of bad events simultaneously, then the rare event is indeed possible if:

• none of these bad events is too probable;
• none of these bad events is dependent with too many other bad events;

Here the tradeoff between "too probable" and "too many" is characterized by the ${\displaystyle \mathrm {e} p(d+1)\leq 1}$ condition.

According to a result of Shearer in 1985, the condition of the Lovász Local Lemma cannot be substantially improved if only the bounds on ${\displaystyle p}$ and ${\displaystyle d}$ are known.

## Lovász Local Lemma (asymmetric case)

Sometimes when applying the local lemma, a few bad events are much more probable than others or are dependent with more other bad events. In this case, using the same upper bounds ${\displaystyle p}$ on the probability of bad events or ${\displaystyle d}$ on the number of dependent events will be much wasteful. To more accurately deal with such general cases, we need a more refined way to characterize the tradeoff between local dependencies and probabilities of bad events.

We need to introduce a few notations that will be frequently used onwards. Let ${\displaystyle {\mathcal {A}}=\{A_{1},A_{2},\ldots ,A_{m}\}}$ be a set of events. For every event ${\displaystyle A_{i}\in {\mathcal {A}}}$, we define its neighborhood and inclusive neighborhood as follows:

• inclusive neighborhood: ${\displaystyle \Gamma ^{+}(A_{i})\,}$ denotes the set of events in ${\displaystyle {\mathcal {A}}}$, including ${\displaystyle A_{i}}$ itself, that are dependent with ${\displaystyle A_{i}}$. More precisely, ${\displaystyle A_{i}}$ is mutually independent of all events in ${\displaystyle {\mathcal {A}}\setminus \Gamma ^{+}(A_{i})}$.
• neighborhood: ${\displaystyle \Gamma (A_{i})=\Gamma ^{+}(A_{i})\setminus \{A_{i}\}}$, that is, ${\displaystyle \Gamma (A_{i})}$ contains the events in ${\displaystyle {\mathcal {A}}}$ that are dependent with ${\displaystyle A_{i}}$, not including ${\displaystyle A_{i}}$ itself.

The following is the asymmetric version of the Lovász Local Lemma. This generalization is due to Spencer.

 Lovász Local Lemma (general case) Let ${\displaystyle {\mathcal {A}}=\{A_{1},A_{2},\ldots ,A_{m}\}}$ be a set of events, where every event ${\displaystyle A_{i}\in {\mathcal {A}}}$ is mutually independent of all other events excepts those in its neighborhood ${\displaystyle \Gamma (A_{i})\,}$ in the dependency graph. Suppose there exist real numbers ${\displaystyle \alpha _{1},\alpha _{2},\ldots ,\alpha _{m}\in [0,1)}$ such that for every ${\displaystyle A_{i}\in {\mathcal {A}}}$, ${\displaystyle \Pr[A_{i}]\leq \alpha _{i}\prod _{A_{j}\in \Gamma (A_{i})}(1-\alpha _{j})}$. Then ${\displaystyle \Pr \left[\bigwedge _{A_{i}\in {\mathcal {A}}}{\overline {A_{i}}}\right]\geq \prod _{i=1}^{m}(1-\alpha _{i})}$.

This generalized version of the local lemma immediately implies the symmetric version of the lemma. Namely, ${\displaystyle \Pr \left[\bigwedge _{i}{\overline {A_{i}}}\right]>0}$ if the followings are satisfied:

1. ${\displaystyle \Pr[A_{i}]\leq p}$ for all ${\displaystyle A_{i}\in {\mathcal {A}}}$;
2. ${\displaystyle \mathrm {e} p(d+1)\leq 1}$, where ${\displaystyle d=\max _{A_{i}\in {\mathcal {A}}}|\Gamma (A_{i})|}$ is the maximum degree of the dependency graph.

To see this, for every ${\displaystyle A_{i}\in {\mathcal {A}}}$ let ${\displaystyle \alpha _{i}={\frac {1}{d+1}}}$. Note that ${\displaystyle \prod _{A_{j}\in \Gamma (A_{i})}(1-\alpha _{j})\geq \left(1-{\frac {1}{d+1}}\right)^{d}>{\frac {1}{\mathrm {e} }}}$.

With the above two conditions satisfied, for all ${\displaystyle A_{i}\in {\mathcal {A}}}$, it is easy to verify:

${\displaystyle \Pr[A_{i}]\leq p\leq {\frac {1}{\mathrm {e} (d+1)}}<{\frac {1}{d+1}}\left(1-{\frac {1}{d+1}}\right)^{d}\leq \alpha _{i}\prod _{A_{j}\in \Gamma (A_{i})}(1-\alpha _{j})}$,

which according to the Lovász Local Lemma (general case), implies that

${\displaystyle \Pr \left[\bigwedge _{i=1}{\overline {A_{i}}}\right]\geq \prod _{i=1}^{m}(1-\alpha _{i})=\left(1-{\frac {1}{d+1}}\right)^{m}>0}$.

This gives the symmetric version of the local lemma.

## A non-constructive proof of LLL

We then give the proof of the generalized Lovász Local Lemma. In particular, this proof is non-constructive, in contrast to the constructive proofs that we are going to introduce later, which are basically algorithms.

Apply the chain rule. The probability that none of the bad events occurs can be expressed as:

{\displaystyle {\begin{aligned}\Pr \left[\bigwedge _{i=1}^{m}{\overline {A_{i}}}\right]=\prod _{i=1}^{m}\Pr \left[{\overline {A_{i}}}\mid \bigwedge _{j=1}^{i-1}{\overline {A_{j}}}\right]=\prod _{i=1}^{m}\left(1-\Pr \left[A_{i}\mid \bigwedge _{j=1}^{i-1}{\overline {A_{j}}}\right]\right).\end{aligned}}}

It is then sufficient to show that

${\displaystyle \Pr \left[A_{i}\mid \bigwedge _{j=1}^{i-1}{\overline {A_{j}}}\right]\leq \alpha _{i}}$,

which will prove the lemma.

We then prove a slightly more general statement:

(induction hypothesis) ${\displaystyle \Pr \left[A_{i_{1}}\mid \bigwedge _{j=2}^{\ell }{\overline {A_{i_{j}}}}\right]\leq \alpha _{i_{1}}}$ for any distinct events ${\displaystyle A_{i_{1}},A_{i_{2}}\ldots ,A_{i_{\ell }}\in {\mathcal {A}}}$.

The proof is by induction on ${\displaystyle \ell }$. For ${\displaystyle \ell =1}$, due to the assumption in the Lovász Local Lemma

${\displaystyle \Pr[A_{i_{1}}]\leq \alpha _{i_{1}}\prod _{A_{j}\in \Gamma (A_{i_{1}})}(1-\alpha _{j})\leq \alpha _{i_{1}}}$.

For general ${\displaystyle \ell }$, assume the hypothesis is true for all smaller ${\displaystyle \ell }$. Without loss of generality, assume that ${\displaystyle A_{i_{2}},\ldots ,A_{i_{k}}}$ are the events among ${\displaystyle A_{i_{2}}\ldots ,A_{i_{\ell }}}$ that are dependent with ${\displaystyle A_{i_{1}}}$, and ${\displaystyle A_{i_{1}}}$ is mutually independent of the rest ${\displaystyle A_{i_{k+1}},\ldots ,A_{i_{\ell }}}$.

Then applying the following basic conditional probability identity

${\displaystyle \Pr[A\mid BC]={\frac {\Pr[AB\mid C]}{\Pr[B\mid C]}}}$,

we have

${\displaystyle \Pr \left[A_{i_{1}}\mid \bigwedge _{j=2}^{\ell }{\overline {A_{i_{j}}}}\right]={\frac {\Pr \left[A_{i}\wedge \bigwedge _{j=2}^{k}{\overline {A_{i_{j}}}}\mid \bigwedge _{j=k+1}^{\ell }{\overline {A_{i_{j}}}}\right]}{\Pr \left[\bigwedge _{j=2}^{k}{\overline {A_{i_{j}}}}\mid \bigwedge _{j=k+1}^{\ell }{\overline {A_{i_{j}}}}\right]}}={\frac {\text{Numerator}}{\text{Denominator}}}.}$

Due to the mutual independence between ${\displaystyle A_{i_{1}}}$ and ${\displaystyle A_{i_{k}+1},\ldots ,A_{i_{\ell }}}$, the ${\displaystyle {\text{Numerator}}}$ becomes

${\displaystyle {\text{Numerator}}\leq \Pr \left[A_{i_{1}}\mid \bigwedge _{j=k+1}^{\ell }{\overline {A_{i_{j}}}}\right]=\Pr[A_{i_{1}}],}$

which according to the assumption in the Lovász Local Lemma, is bounded as

${\displaystyle {\text{Numerator}}\leq \alpha _{i_{1}}\prod _{A_{j}\in \Gamma (A_{i_{1}})}(1-\alpha _{j}).}$

Applying the chain rule to the ${\displaystyle {\text{Denominator}}}$ we have

${\displaystyle {\text{Denominator}}=\prod _{j=2}^{k}\Pr \left[{\overline {A_{i_{j}}}}\mid \bigwedge _{r=j+1}^{\ell }{\overline {A_{i_{r}}}}\right].}$

Note that there are always less than ${\displaystyle \ell }$ events involved, so we can apply the induction hypothesis and have

${\displaystyle {\text{Denominator}}\geq \prod _{j=2}^{k}(1-\alpha _{i_{j}})\geq \prod _{A_{j}\in \Gamma (A_{i_{1}})}(1-\alpha _{j}),}$

where the last inequality is due to the fact that ${\displaystyle A_{i_{2}},\ldots ,A_{i_{k}}\in \Gamma (A_{i_{1}})}$.

Combining everything together, we have

${\displaystyle \Pr \left[A_{i_{1}}\mid \bigwedge _{j=2}^{\ell }{\overline {A_{i_{j}}}}\right]\leq \alpha _{i_{1}}.}$

As we argued in the beginning, this proves the general Lovász Local Lemma.

# Random Search for Exact-${\displaystyle k}$-SAT

We start by giving the definition of ${\displaystyle k}$-CNF and ${\displaystyle k}$-SAT.

 Definition (exact-${\displaystyle k}$-CNF) A logic expression ${\displaystyle \phi }$ defined on ${\displaystyle n}$ Boolean variables ${\displaystyle x_{1},x_{2},\ldots ,x_{n}\in \{\mathrm {true} ,\mathrm {false} \}}$ is said to be a conjunctive normal form (CNF) if ${\displaystyle \phi }$ can be written as a conjunction(AND) of clauses as ${\displaystyle \phi =C_{1}\wedge C_{2}\wedge \cdots \wedge C_{m}}$, where each clause ${\displaystyle C_{i}=\ell _{i_{1}}\vee \ell _{i_{2}}\vee \cdots \vee \ell _{i_{k}}}$ is a disjunction(OR) of literals, where every literal ${\displaystyle \ell _{j}}$ is either a variable ${\displaystyle x_{i}}$ or the negation ${\displaystyle \neg x_{i}}$ of a variable. We call a CNF formula a exact-${\displaystyle k}$-CNF if every clause consists of exact ${\displaystyle k}$ distinct literals.

For example:

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

is an exact-${\displaystyle 3}$-CNF formula.

Remark
The notion of exact-${\displaystyle k}$-CNF is slightly more restrictive than the ${\displaystyle k}$-CNF, where each clause consists of at most ${\displaystyle k}$ variables. The discussion of the subtle differences between these two definitions can be found here.

A logic expression ${\displaystyle \phi }$ is said to be satisfiable if there is an assignment of values of true or false to the variables ${\displaystyle {\boldsymbol {x}}=(x_{1},x_{2},\ldots ,x_{n})}$ so that ${\displaystyle \phi ({\boldsymbol {x}})}$ is true. For a CNF ${\displaystyle \phi }$, this mean that there is a truth assignment that satisfies all clauses in ${\displaystyle \phi }$ simultaneously.

The exact-${\displaystyle k}$-satisfiability (exact-${\displaystyle k}$-SAT) problem is that given as input an exact-${\displaystyle k}$-CNF formula ${\displaystyle \phi }$ decide whether ${\displaystyle \phi }$ is satisfiable.

 exact-${\displaystyle k}$-SAT Input: an exact-${\displaystyle k}$-CNF formula ${\displaystyle \phi }$. Output: whether ${\displaystyle \phi }$ is satisfiable.

It is well known that ${\displaystyle k}$-SAT is NP-complete for any ${\displaystyle k\geq 3}$. The same also holds for the exact-${\displaystyle k}$-SAT.

## Satisfiability of exact-${\displaystyle k}$-CNF

Inspired by the Lovasz local lemma, we now consider the dependencies between clauses in a CNF formula.

Given a CNF formula ${\displaystyle \phi }$ defined over Boolean variables ${\displaystyle {\mathcal {X}}=\{x_{1},x_{2},\ldots ,x_{n}\}}$ and a clause ${\displaystyle C}$ in ${\displaystyle \phi }$, we use ${\displaystyle {\mathsf {vbl}}(C)\subseteq {\mathcal {X}}}$ to denote the set of variables that appear in ${\displaystyle C}$. For a clause ${\displaystyle C}$ in a CNF formula ${\displaystyle \phi }$, its degree ${\displaystyle d(C)=|\{D\neq C\mid {\mathsf {D}}\cap {\mathsf {C}}\neq \emptyset \}|}$ is the number of other clauses in ${\displaystyle \phi }$ that share variables with ${\displaystyle C}$. The maximum degree ${\displaystyle d}$ of a CNF formula ${\displaystyle \phi }$ is ${\displaystyle d=\max _{C{\text{ in }}\phi }d(C)}$.

By the Lovasz local lemma, we almost immediately have the following theorem for the satisfiability of exact-${\displaystyle k}$-CNF with bounded degree.

 Theorem Let ${\displaystyle \phi }$ be an exact-${\displaystyle k}$-CNF formula with maximum degree ${\displaystyle d}$. If ${\displaystyle d+1\leq 2^{k}/\mathrm {e} }$ then ${\displaystyle \phi }$ is always satisfiable.
Proof.
 Let ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$ be Boolean random variables sampled uniformly and independently from ${\displaystyle \{{\text{true}},{\text{false}}\}}$. We are going to show that ${\displaystyle \phi }$ is satisfied by this random assignment with positive probability. Due to the probabilistic method, this will prove the existence of a satisfying assignment for ${\displaystyle \phi }$. Suppose there are ${\displaystyle m}$ clauses ${\displaystyle C_{1},C_{2},\ldots ,C_{m}}$ in ${\displaystyle \phi }$. Let ${\displaystyle A_{i}}$ denote the bad event that ${\displaystyle C_{i}}$ is not satisfied by the random assignment ${\displaystyle X_{1},X_{2},\ldots ,X_{n}}$. Clearly, each ${\displaystyle A_{i}}$ is dependent with at most ${\displaystyle d}$ other ${\displaystyle A_{j}}$'s. And our goal is to show that ${\displaystyle \Pr \left[\bigwedge _{i=1}^{m}{\overline {A_{i}}}\right]>0}$. Recall that in an exact-${\displaystyle k}$-CNF, every clause ${\displaystyle C_{i}}$ consists of exact ${\displaystyle k}$ variable, and is violated by precisely one local assignment among all ${\displaystyle 2^{k}}$ possibilities. Thus the probability that ${\displaystyle C_{i}}$ is not satisfied is ${\displaystyle \Pr[A_{i}]=2^{-k}}$. Assuming that ${\displaystyle d+1\leq 2^{k}/\mathrm {e} }$, i.e. ${\displaystyle \mathrm {e} (d+1)2^{-k}\leq 1}$, by the Lovasz local lemma (symmetric case), we have ${\displaystyle \Pr \left[\bigwedge _{i=1}^{m}{\overline {A_{i}}}\right]>0}$.
${\displaystyle \square }$

## The random search algorithm

The above theorem basically says that for a CNF if every individual clause is easy to satisfy and is dependent with few other clauses then the CNF should be always satisfiable. However, the theorem only states the existence of a satisfying solution, but does not specify a way to find this solution. Next we give a simple randomized algorithm and prove it can find the satisfying solution efficiently under a slightly stronger assumption than the Lovasz local lemma.

Given as input a CNF formula ${\displaystyle \phi }$ defined on Boolean variables ${\displaystyle {\mathcal {X}}=\{x_{1},x_{2},\ldots ,x_{n}\}}$, recall that for a clause ${\displaystyle C}$ in a CNF ${\displaystyle \phi }$, we use ${\displaystyle {\mathsf {vbl}}(C)\subseteq {\mathcal {X}}}$ to denote the set of variables on which ${\displaystyle C}$ is defined.

The following algorithm is due to Moser in 2009. The algorithm consists of two components: the main function Solve() and a sub-routine Fix().

 Solve(CNF ${\displaystyle \phi }$) Pick values of ${\displaystyle x_{1},x_{2}\ldots ,x_{n}}$ uniformly and independently at random; While there is an unsatisfied clause ${\displaystyle C}$ in ${\displaystyle \phi }$ Fix(${\displaystyle C}$);

The sub-routine Fix() is a recursive procedure:

 Fix(Clause ${\displaystyle C}$) Replace the values of variables in ${\displaystyle {\mathsf {vbl}}(C)}$ with new uniform and independent random values; While there is unsatisfied clause ${\displaystyle D}$ (including ${\displaystyle C}$ itself) that ${\displaystyle {\mathsf {vbl}}(C)\cap {\mathsf {vbl}}(D)\neq \emptyset }$ Fix(${\displaystyle D}$);

It is an amazing discovery that this simple algorithm works well as long as the condition of Lovasz local lemma is satisfied. Here we prove a slightly weaker statement for the convenience of analysis.

 Theorem Let ${\displaystyle \phi }$ be an exact-${\displaystyle k}$-CNF formula with maximum degree ${\displaystyle d}$. There is a ${\displaystyle d_{0}=\Theta (2^{k})}$ such that if ${\displaystyle d+1 then the algorithm Solve(${\displaystyle \phi }$) finds a satisfying assignment for ${\displaystyle \phi }$ in time ${\displaystyle O(n+km\log m)}$ with high probability.

Note that in the Lovasz local lemma, the above ${\displaystyle d_{0}}$ is ${\displaystyle d_{0}=2^{k}/\mathrm {e} }$. So this theorem archives asymptotically the same bound as the Lovasz local lemma.

The analysis is based on a technique called entropy compression. This is a very clever idea and may be very different from what you might have seen so far about algorithm analysis. We first give a high-level description of this idea:

• We use ${\displaystyle {\mathsf {Alg}}(r,\phi )}$ to abstractly denote an algorithm ${\displaystyle {\mathsf {Alg}}}$ running on an input ${\displaystyle \phi }$ with random bits ${\displaystyle r\in \{0,1\}^{*}}$. For an algorithm with no access to the random bits ${\displaystyle r}$, once the input ${\displaystyle \phi }$ is fixed, the behavior of the algorithm as well as its output is deterministic. But for randomized algorithms, the behavior of ${\displaystyle {\mathsf {Alg}}(r,\phi )}$ is a random variable even when the input ${\displaystyle \phi }$ is fixed.
• Fix an arbitrary (worst-case) input ${\displaystyle \phi }$. We try to construct a succinct representation ${\displaystyle c}$ of the behavior of ${\displaystyle {\mathsf {Alg}}(r,\phi )}$ in such a manner that the random bits ${\displaystyle r}$ can always be fully recovered from this succinct representation ${\displaystyle c}$. In other words, ${\displaystyle {\mathsf {Alg}}(r,\phi )}$ gives an encoding (a 1-1 mapping) of the random bits ${\displaystyle r}$ to a succinct representation ${\displaystyle c}$.
• It is a fundamental law that random bits cannot be compressed significantly by any encoding. Therefore if a longer running time of ${\displaystyle {\mathsf {Alg}}(r,\phi )}$ would imply that the random bits ${\displaystyle r}$ can be encoded to a succinct representation ${\displaystyle c}$ which is much shorter than ${\displaystyle r}$, then we prove the running time of the algorithm ${\displaystyle {\mathsf {Alg}}(r,\phi )}$ cannot be too long.
• A natural way to reach this last contradiction is to have the following situation: As the running time of ${\displaystyle {\mathsf {Alg}}(r,\phi )}$ grows, naturally both lengths of random bits ${\displaystyle r}$ and the succinct representation ${\displaystyle c}$ of the behavior of ${\displaystyle {\mathsf {Alg}}(r,\phi )}$ grow. So if the former grows much faster than the latter as the running time grows, then a large running time may cause the length of ${\displaystyle r}$ significantly greater than the length of ${\displaystyle c}$.

We now proceed to the analysis of ${\displaystyle {\text{Solve}}(\phi )}$ and prove the above theorem.

From now on we assume that the input instance ${\displaystyle \phi }$ is an arbitrarily fixed exact-${\displaystyle k}$-CNF formula with maximum degree ${\displaystyle d}$:

• Let ${\displaystyle T}$ denote the total number of time the function ${\displaystyle {\text{Fix}}()}$ is being called (including both the calls in ${\displaystyle {\text{Solve}}(\phi )}$ and the recursive calls).
• Let ${\displaystyle t=\min\{T,2^{m}\}}$.

Note that ${\displaystyle T}$ and ${\displaystyle t}$ are random variables which depend solely on the random bits used by the algorithm (after the input ${\displaystyle \phi }$ being fixed). We are going to show that ${\displaystyle t=O(m\log m)}$ with high probability, which means ${\displaystyle T=O(m\log m)}$ with high probability.

The reason we consider ${\displaystyle t=\min\{T,2^{m}\}}$ is that we are not sure whether ${\displaystyle T}$ is finite or infinite, so we "truncate" ${\displaystyle T}$ if it becomes too large. This truncation threshold is quite arbitrary as long as it is significantly greater than ${\displaystyle m\log m}$.

We start by making the following simple observations:

• A clause ${\displaystyle C}$ in ${\displaystyle \phi }$ will be satisfied after Fix(${\displaystyle C}$) returned and will remain as being satisfied afterwards.
• At the moment a Fix(${\displaystyle C}$) being called, the clause ${\displaystyle C}$ must be unsatisfied.
 Proposition There are at most ${\displaystyle m}$ top-level callings to Fix(), where ${\displaystyle m}$ is the total number of clauses in ${\displaystyle \phi }$. If a Fix(${\displaystyle C}$) is being called, the values of variables in ${\displaystyle C}$ are uniquely determined.

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.