% Template based on:
% https://www.cs.columbia.edu/~djhsu/coms4774-s21/scribe.html

\documentclass[12pt]{article}

\usepackage{amscd}
\usepackage{amsmath}
\usepackage{float}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{amsthm}
\usepackage{bbold}
\usepackage{bm}
\usepackage{colonequals}
\usepackage[dvips,letterpaper,margin=1in]{geometry}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{xcolor}

\usepackage{csquotes}
\MakeOuterQuote{"}

\definecolor{cblack}{rgb}{0,0,0}
\definecolor{cblue}{rgb}{0.121569,0.466667,0.705882}
\definecolor{corange}{rgb}{1.000000,0.498039,0.054902}
\definecolor{cgreen}{rgb}{0.172549,0.627451,0.172549}
\definecolor{cred}{rgb}{0.839216,0.152941,0.156863}
\definecolor{cpurple}{rgb}{0.580392,0.403922,0.741176}
\definecolor{cbrown}{rgb}{0.549020,0.337255,0.294118}
\definecolor{cpink}{rgb}{0.890196,0.466667,0.760784}
\definecolor{cgray}{rgb}{0.498039,0.498039,0.498039}

\usepackage{hyperref}
\hypersetup{
  linkcolor  = cblue,
  citecolor  = cgreen,
  urlcolor   = corange,
  colorlinks = true,
}

% Lecture information
\newcommand\coursename{CPSC 664, Spring 2023}
\newcommand\scribe{Curtis McDonald}
\newcommand\lecturer{Tim Kunisky}
\newcommand\lecturedate{January 26, 2023}
\newcommand\lecturetitle{Lecture 4: Random $k$-SAT II}

% Define theorem environments here.
\newtheorem{claim}{Claim}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{remark}[theorem]{Remark}
\newtheorem{assumption}[theorem]{Assumption}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{question}[theorem]{Question}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{conjecture}[theorem]{Conjecture}

% Some of my macros
\renewcommand{\AA}{\mathbb{A}}
\newcommand{\CC}{\mathbb{C}}
\newcommand{\DD}{\mathbb{D}}
\newcommand{\EE}{\mathbb{E}}
\newcommand{\FF}{\mathbb{F}}
\newcommand{\HH}{\mathbb{H}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\PP}{\mathbb{P}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\RR}{\mathbb{R}}
\renewcommand{\SS}{\mathbb{S}}
\newcommand{\ZZ}{\mathbb{Z}}
\DeclareSymbolFont{bbold}{U}{bbold}{m}{n}
\DeclareSymbolFontAlphabet{\mathbbold}{bbold}
\newcommand{\One}{\mathbbold{1}}

\newcommand{\ba}{\bm a}
\newcommand{\bb}{\bm b}
\newcommand{\bc}{\bm c}
\newcommand{\bd}{\bm d}
\newcommand{\be}{\bm e}
\newcommand{\bg}{\bm g}
\newcommand{\bh}{\bm h}
\newcommand{\bi}{\bm i}
\newcommand{\bj}{\bm j}
\newcommand{\bk}{\bm k}
\newcommand{\bbm}{\bm m}
\newcommand{\bp}{\bm p}
\newcommand{\bq}{\bm q}
\newcommand{\br}{\bm r}
\newcommand{\bs}{\bm s}
\newcommand{\bt}{\bm t}
\newcommand{\bu}{\bm u}
\newcommand{\bv}{\bm v}
\newcommand{\bw}{\bm w}
\newcommand{\bx}{\bm x}
\newcommand{\by}{\bm y}
\newcommand{\bz}{\bm z}

\newcommand{\bA}{\bm A}
\newcommand{\bB}{\bm B}
\newcommand{\bC}{\bm C}
\newcommand{\bD}{\bm D}
\newcommand{\bE}{\bm E}
\newcommand{\bF}{\bm F}
\newcommand{\bG}{\bm G}
\newcommand{\bH}{\bm H}
\newcommand{\bI}{\bm I}
\newcommand{\bL}{\bm L}
\newcommand{\bM}{\bm M}
\newcommand{\bN}{\bm N}
\newcommand{\bP}{\bm P}
\newcommand{\bQ}{\bm Q}
\newcommand{\bR}{\bm R}
\newcommand{\bS}{\bm S}
\newcommand{\bT}{\bm T}
\newcommand{\bU}{\bm U}
\newcommand{\bV}{\bm V}
\newcommand{\bW}{\bm W}
\newcommand{\bX}{\bm X}
\newcommand{\bY}{\bm Y}
\newcommand{\bZ}{\bm Z}

\newcommand{\zero}{\bm{0}}
\newcommand{\one}{\bm{1}}

\newcommand{\sA}{\mathcal{A}}
\newcommand{\sB}{\mathcal{B}}
\newcommand{\sC}{\mathcal{C}}
\newcommand{\sD}{\mathcal{D}}
\newcommand{\sE}{\mathcal{E}}
\newcommand{\sF}{\mathcal{F}}
\newcommand{\sG}{\mathcal{G}}
\newcommand{\sH}{\mathcal{H}}
\newcommand{\sI}{\mathcal{I}}
\newcommand{\sJ}{\mathcal{J}}
\newcommand{\sK}{\mathcal{K}}
\newcommand{\sL}{\mathcal{L}}
\newcommand{\sM}{\mathcal{M}}
\newcommand{\sN}{\mathcal{N}}
\newcommand{\sO}{\mathcal{O}}
\newcommand{\sP}{\mathcal{P}}
\newcommand{\sQ}{\mathcal{Q}}
\newcommand{\sR}{\mathcal{R}}
\newcommand{\sS}{\mathcal{S}}
\newcommand{\sT}{\mathcal{T}}
\newcommand{\sU}{\mathcal{U}}
\newcommand{\sV}{\mathcal{V}}
\newcommand{\sX}{\mathcal{X}}
\newcommand{\sY}{\mathcal{Y}}

\newcommand{\fB}{\mathscr{B}}
\newcommand{\fC}{\mathscr{C}}
\newcommand{\fE}{\mathscr{E}}
\newcommand{\fH}{\mathscr{H}}
\newcommand{\fI}{\mathscr{I}}
\newcommand{\fP}{\mathscr{P}}
\newcommand{\fV}{\mathscr{V}}

\DeclareSymbolFont{sfoperators}{OT1}{cmss}{m}{n}
% don't waste a math group
\DeclareSymbolFontAlphabet{\mathsf}{sfoperators}
% tell LaTeX to use sfoperators for names of operators
\makeatletter
\renewcommand{\operator@font}{\mathgroup\symsfoperators}
\makeatother

\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator{\GOE}{GOE}
\DeclareMathOperator{\sym}{sym}
\DeclareMathOperator{\Part}{Part}
\DeclareMathOperator{\poly}{poly}
\DeclareMathOperator{\Unif}{Unif}
\DeclareMathOperator{\Var}{Var}
\DeclareMathOperator{\Cov}{Cov}
\DeclareMathOperator{\Tr}{Tr}
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\obj}{obj}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\sgn}{sgn}

\renewcommand\Re{\operatorname{Re}}
\renewcommand\Im{\operatorname{Im}}
% These put symbols below.
\newcommand{\Px}{\mathop{\mathbb{P}}}
\newcommand{\Ex}{\mathop{\mathbb{E}}}
\newcommand{\Varx}{\mathop{\mathsf{Var}}}

\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}

%
% Put your custom macros here if you want.
%

\begin{filecontents}{2023-01-17.bib}
@book{MM-2011-NatureOfComputation,
  title={The nature of computation},
  author={Moore, Cristopher and Mertens, Stephan},
  year={2011},
  publisher={OUP Oxford}
}

@book{Durrett-2019-ProbabilityTheoryExamples,
  title={Probability: theory and examples},
  author={Durrett, Rick},
  volume={49},
  year={2019},
  publisher={Cambridge University Press}
}
\end{filecontents}

\begin{document}

% This creates the header for scribe notes.
\noindent \coursename \hfill Scribe: \scribe \\
\lecturedate \hfill Lecturer: \lecturer
\vspace{1em}

\hrule

\vspace{1.5em}
\begin{center}
  {\Large\lecturetitle}
\end{center}

\section{Review of Random $k$-SAT Problem}

Recall that we are studying the random $k$-SAT problem.
In this setting, we have a random Boolean formula $F:\{0,1\}^{n} \to \{0,1\}$ acting on $n$ Boolean input values $z_{1}, \cdots, z_{n}$.
So we can think of the formula as the function $F$ where given an entry $\bz$ in the $n$-dimensional hypercube, $F$ returns true or false for that $\bz$ vector. The Boolean formula is composed of $m$ clauses, each depending on $k$ of the input $z_{i}$ values. A single clause is a ``or'' ($\vee$) product of $k$ possibly negated $z_{i}$ values,
\begin{equation}
C_{j} = ((\neg)z_{i_{j,1}} \vee \cdots\vee (\neg) z_{i_{j,k}})
\end{equation}
where $\{i_{j,1}, \cdots, i_{j,k}\} \subset \{1, \cdots, n\}$ is a size-$k$ selection of indices which appear in the clause. The overall $F$ function is then the ``and'' ($\wedge$) product of these $m$ clauses,
\begin{equation}
F(z) = C_{1}(z) \wedge \cdots \wedge C_{m}(z)
\end{equation}

The function $F$ is constructed randomly in uniform choice of subsets $\{i_{j,1}, \cdots, i_{j,k}\}$ for each clause and uniform choice of negations within each clause (i.e., do we use $z_{i_{j,1}}$ or $\neg z_{i_{j,1}}$ in the clause). The question is, for a given $F$, does there exist an element of the hypercube $z$ such that $F(z) = 1$.
In other words, does there exist a set of truth assignments for the $z_{i}$ which satisfy $F$ and evaluate to 1 or true. If so, F is said to be \emph{satisfiable}; if not, $F$ is said to be \emph{unsatisfiable}.

The relationship depends on the relative sizes of $m$ (the number of clauses) and $n$ (the number of boolean inputs to the formula). Say $m = \alpha n$. The conjecture is that for each value of $k$, there is a threshold $\alpha^{*} = \alpha(^{*}k)$ such that
\begin{itemize}
\item If $\alpha > \alpha^{*}$, then $F$ is unsatisfiable w.h.p.
\item If $\alpha < \alpha^{*}$, then $F$ is satisfiable w.h.p.
\end{itemize}

\section{$k=2$ Simple Case}

As we will later see, the threshold for $k=3$ based on current research and empirical simulation appears to be about $\alpha^{*}(3) \approx 4.26$. But first, we look at the simpler case of $k=2$ where much of the complexity is reduced.

The $k=2$ case is easier to study since each clause is of the form $((\neg x) \vee (\neg) y)$ for binary variables $x$ and $y$. For such a clause to be true, say the clause $(\neg x \vee y)$, is equivalent to
\begin{enumerate}
\item If $x$ is true, then $\neg x$ is false, so $y$ must be true.
\item If $y$ is false, then $\neg x$ must be true, or equivalently $x$ must be false.
\end{enumerate}
Thus $x$ and $y$ must share the same truth value in such a clause in order for the clause to be true.
More generally, a 2-SAT instance corresponds to a graph of implications between the variables $z_i$ and their negations which show which variables must be true when others are true. The function $F$ is satisfiable if and only if there are no cycles in this graph that include $z_{i}$ and $\neg z_{i}$ for some $i$.

We can analyze the 2-SAT problem by studying this graph structure.
It turns out, in a phase transition similar to the emergence of a giant component in an Erd\H{o}s-R\'{e}nyi random graph, that the critical value is $\alpha^{*}(2) = 1$
This ``implication graph'' representation also shows that 2-SAT can be solved in polynomial time and, unlike $k$-SAT for $k \geq 3$ (assuming $\mathsf{P} \neq \mathsf{NP}$), belongs to the complexity class $\mathsf{P}$.

\section{$k = 3$ First Moment Method Initial Analysis}

Note that going forward, we will use the notation $x \in\{0,1\}^{n}$ and not $z$ as the input variable to the function $F$.

Similarly to how we analyzed the number partitioning problem, we are interested in the event $\{\exists x : F(x) = 1\}$. To study the probability that such an event will occur, we look at the size of the set of values which would satisfy this event,
\begin{align*}
Z&= \# \{x \in \{0,1\}^{n}: F(x) = 1\}.
\end{align*}
Note that $Z$ is a random variable depending on the random assignments that construct $F$. The expectation of $Z$ is
\begin{align*}
\EE[Z] &= \sum_{x} \PP[x~\text{satisfies}~F] \\
&= \sum_{x} \prod_{j=1}^{m}\PP[x~\text{satisfies}~C_{j}] \\
&= \sum_{x} \PP[x~\text{satisfies}~C_{1}]^{m},
\end{align*}
the last step following since each clause is chosen i.i.d.
Then, using negation
\begin{align*}
P(x~\text{satisfies}~C_{1})&= 1-\PP[x~\text{not satisfies}~C_{1}] \\
                           &= 1-\frac{1}{8} \\
                           &= \frac{7}{8}.
\end{align*}
Here we use that clause $C_{j}$ is the or of possibly negated $z_{i_{j,1}}, z_{i_{j,2}}, z_{i_{j,3}}$, so each has to be the wrong value with $\frac{1}{2}$ probability, so $\frac{1}{8}$ is probability of not satisfying this clause. So the sum becomes
\begin{align*}
\EE[Z]= 2^{n}\left(\frac{7}{8}\right)^{m}= 2^{n}\left(\frac{7}{8}\right)^{\alpha n}=\left(2\left(\frac{7}{8}\right)^{\alpha}\right)^{n}.
\end{align*}
The inner expression equaals 1 when $\alpha = \frac{\log (\frac{1}{2})}{\log \frac{7}{8}} \approx 5.19$, which we will call $\alpha^{(1)} \approx 5.19$, our first estimate for $\alpha^{*}(3)$. This leads to the following.

\begin{proposition}
If $\alpha > \alpha^{(1)} \approx 5.19$, then w.h.p.\ $F$ is unsatisfiable.
\end{proposition}
\noindent
This follows by the same Markov's inequality argument we have seen before.

Therefore, $\alpha^{*}(3)$, the conjectured threshold which divides satisfiablity and unsatisfiability for $k = 3$, if it exists, would have to be less than or equal to this value $\alpha^{*}(3) \leq \alpha^{(1)}$.

However, numerical experiments lead us to believe that $\alpha^{*}(3) \approx 4.26$.
So there is some ``gap'' in our argument.
What went wrong?

\section{$k = 3$ First Moment Method Improved Analysis}

In a nutshell, $Z$ was not the best random variable to which to apply the first moment method.
There is a better choice of counting variable which we apply the first moment method to and get a tighter bound on the threshold.

Note that by conditional probability
\begin{align*}
\EE[Z]&= \EE[Z \mid F \text{ is satisfiable}]\cdot \PP[F \text{ is satisfiable}].
\end{align*}
If, say, $\alpha = 5$, we have that $\alpha^{*} = 4.26 < \alpha < \alpha^{(1)}$, thus we think $F$ should be unsatisfiable w.h.p.\ (since $\alpha > \alpha^{*})$ but for $\alpha = 5$ the above expectation is not going to 0, it is going to infinity. So the above analysis would not conclude that $F$ is unsatisfiable.

The issue is that while $\PP[F \text{ is satisfiable}]$ may be small, $EE[Z \mid F \text{ is satisfiable}]$ maybe be large, forcing the overall expectation to diverge,, even if the probability is going to 0. So, we want a random variable which is smaller than $Z$ to better track when the probability is going to zero and not to unintentionally bring up the expectation.

The main idea is to only count ``special'' or ``canonical'' satisfying $x$ that exist whenever $F$ is satisfiable.

\begin{definition}
    $x$ satisfying $F$ is \textbf{locally maximal} if all neighbors $x^{\prime} = x$ with one 0 flipped to a 1 are not satisfying.
    That is, whenever we have:
\begin{align*}
\begin{matrix}
x = \\
x^{\prime} = 
\end{matrix} \begin{matrix}
\,\, 0&1&\textbf{0}&1&1&0&0&1\\
\,\, 0&1&\textbf{1}&1&1&0&0&1
\end{matrix}
\end{align*}
where $x$ is satisfying, then $x^{\prime}$ must not be satisfying.
\end{definition}
Basically, $x$ is a satisfying vector which has more 1's than any immediate neighbors which are also satisfying.

We then consider
\begin{align*}
Y =\#  \{x: x ~\text{satisfies}~ F \text{ and } x~\text{is locally maximal}\}
\end{align*}
\begin{proposition}
If $F$ is satisfiable, then there exists a locally maximal $x$ that satisfies $x$.
\end{proposition}
\begin{proof}
    If $F$ is satisfiable, there is one $x$ which satisfies $F$. Take that $x$ and go through the 0 values and try to flip them to 1 to get a new $^{\prime}$. If this new $x'$ still satisfies $F$, then set $x = x^{prime}$ and repeat this process. Eventually, we will get to an $x$ which is all 1, or none of the remaining 0's can be flipped to a 1 while still satisfying $F$.
    Thus we terminate at a locally maximal satisfying $x$.
\end{proof}

The set which $Y$ counts is a subset of the set that $Z$ counted, thus $Y \leq Z$.

By the same Markov's inequality argument as before, if $\EE[Y] \to 0$, then w.h.p.\ there does not exist a locally maximal satisfying $x$, and so by the Proposition w.h.p.\ $F$ is unsatisfiable.

So we study the expected value of $Y$,
\begin{align*}
\EE[Y]&= \sum_{x}\PP[ x~\text{satisfies}~F \text{ and } x~\text{is locally maximal}]
\end{align*}

\begin{claim}
If x is locally maximal, and some $x_{i} = 0$ for some $i$, then there must exist some ``blocking'' clause $C = C(i)$ that is false under $x^{\prime}$ where we flip $x_{i}$ and leave the rest the same.
\end{claim}
\noindent
This blocking clause must be of the form
\begin{align*}
C&= (\neg x_{i}) \vee(\cdots)\vee(\cdots)
\end{align*}
where the first term is true under $x$, and the other terms are false under $x$. Thus if we tried to flip $x_{i}$ this first term would become false, the rest are false, and thus clause would be false and we do not satisfy $F$ anymore.

We then have
\begin{align*}
&\PP[x~\text{satisfies}~F \text{ and } x~\text{is locally maximal}] \\
=& \PP[x~\text{satisfies}~F] \cdot \PP[x~\text{locally maximal} \mid x~\text{satisfies}~F].
\end{align*}
We already determined the marginal probability $PP[x~\text{satisfies}~F] = (\frac{7}{8})^{m}$ before, thus this conditional probability term can only decrease the joint probability (we are multiplying by a term between 0 and 1) and thus we will have a reduced probability and thus a reduced overall expectation.

We now calculate
\begin{align*}
& \PP[x~\text{locally maximal} \mid x~\text{satisfies}~F]\\
=& \PP[\text{there exists a blocking clause in F for every index i where}~x_{i} = 0 \mid x~\text{satisfies}~F]
\end{align*}
By the above structure of blocking clauses, each clause can only block at most one index $i$, and so it is reasonable to believe that each $i$ with $x_i = 0$ getting blocked by some clause are negatively correlated events.
Based on this intuition, we claim (without further justification) that
\begin{align*}
&\PP[\text{there exists a blocking clause in F for every index i where}~x_{i} = 0\mid x~\text{satisfies}~F] \\
&\leq \prod_{i: x_{i}=0}\PP[\text{there exists a clause in F blocking index } i \mid x~\text{satisfies}~F] \\
&= \prod_{i:x_{i}=0}(1-\PP[C \text{ does not block } i \mid x~\text{satisfies}~C]^{m}),
\end{align*}
in the last step again using that the clauses are i.i.d.

We now study $P(\text{C does not block i}|x~\text{satisfies}~C)$. By Bayes's rule,
\begin{align*}
\PP[C \text{ does not block } i \mid x~\text{satisfies}~C] &=1-\frac{\#\{C:  C~\text{blocks } i, x~\text{satisfies } C\}}{\# \{C: x~\text{satisfies}~C\}}\\
&= 1- \frac{\binom{n}{2}}{\frac{7}{8} \cdot 2^{3}\binom{n}{3}}
\end{align*}

Putting all this together, we have
\begin{align*}
\PP[x~\text{satisfies}~F\text{ and } x~\text{is locally maximal})&\leq \left(\frac{7}{8} \right)^{m}\left(\prod_{i: x_{i}=0}\left(1- \left(1- \frac{\binom{n}{2}}{7\binom{n}{3}}\right)^{m} \right) \right)\\
&=\left(\frac{7}{8} \right)^{m}\left(1- \left(1- \frac{\binom{n}{2}}{7\binom{n}{3}}\right)^{m} \right)^{\#\{i: x_{i}=0\}}
\end{align*}
Note that, for $k$ fixed and $n$ large,
\begin{align*}
\binom{n}{k}&= \frac{n(n-1)\cdots(n-k+1)}{k!} \approx \frac{n^{k}}{k!},
\end{align*}
and therefore
\begin{align*}
\frac{\binom{n}{2}}{7\binom{n}{3}} \approx \frac{3}{7n}.
\end{align*}
Plugging this in, the above simplifies to
\begin{align*}
\left(\frac{7}{8} \right)^{m}\left(1- \left(1- \frac{\binom{n}{2}}{7\binom{n}{3}}\right)^{m} \right)^{\#\{i: x_{i}=0\}}&\approx \left(\frac{7}{8} \right)^{m}\left(1-e^{-\frac{3}{7}\alpha}\right)^{\#\{i:x_{i}=0\}}.
\end{align*}
We sum over all $x$, and, using that the above quantity depends only on the number of 0's in $x$, we may reduce and use the binomial theorem,
\begin{align*}
\EE[Y] &\leq \sum_{f=0}^{n} \binom{n}{f}\left(\frac{7}{8} \right)^{m}\left(1-e^{-\frac{3}{7}\alpha}\right)^{f}\\
&=\left(\frac{7}{8} \right)^{\alpha n}(2-e^{-\frac{3}{7}\alpha})^{n}=\left[ \left(\frac{7}{8} \right)^{\alpha}(2-e^{-\frac{3}{7}\alpha}))\right]^{n}.
\end{align*}
As in the first calculation, we are interested in the $\alpha$ for which the inner quantity equals 1.
Before, this quantity was $2\left(\frac{7}{8}\right)^{\alpha}$, while now we an additional additive term of $e^{-\frac{3}{7}\alpha}$, which will decrease this quantity and make it equal 1 for a smaller $\alpha$.
It turns out that this value is approximately $\alpha^{(2)} \approx 4.67 < 5.19 = \alpha^{(1)}$, so this adjustment indeed improves the first moment method.

\begin{figure}[H]
\begin{center}
    \includegraphics[scale=0.8]{2023-01-26-fig1.png}
\end{center}
\end{figure}

\end{document}
