\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{relsize}
\newcounter{lecnum}
\usepackage{graphicx}
\graphicspath{./}
\usepackage{caption}
\usepackage{subcaption}
\newcommand{\abs}[1]{\lvert #1 \rvert}
\newcommand{\lecture}[4]{
   \newpage
   \setcounter{lecnum}{#1}
   \noindent

   \begin{center}
   \framebox{
      \vbox{\vspace{2mm}
    \hbox to 16cm { {\bf CS761 Derandomization and Pseudorandomness
                        \hfill 2022-23 Sem I} }
       \vspace{4mm}
       \hbox to 16cm { {\Large \hfill Lecture #1: #2  \hfill} }
       \vspace{2mm}
       \hbox to 16cm { {\it Scribe: #4  \hfill  Lecturer: #3} }
      \vspace{2mm}}
   }
   \end{center}
   \vspace*{4mm}
}

\newtheorem{theorem}{Theorem}[lecnum]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{algorithm}[theorem]{Algorithm}

\newcommand{\E}{\mathbb{E}}
\newcommand{\F}{\mathbb{F}}

\begin{document}

\lecture{3}{09/08/22}{Rohit Gurjar}{Raj Aryan Agrawal}
\section*{Pairwise Independence}
\begin{definition}[Pairwise Independence]
Let $X_1, X_2, \dots, X_n$ be random variables such that for any $i,j$ $i \neq j$, we have $$\forall \alpha, \beta ~ Pr(X_i = \alpha | X_j = \beta) = Pr(X_i = \alpha)$$
Or we can write it as $$Pr(X_i = \alpha, X_j = \beta) = Pr(X_i = \alpha) Pr(X_j = \beta)$$
\end{definition}
This can be extended to k-wise independence.

\textbf{Notation:} We will use $X \in_R S$ to denote that the random variable $X$ is chosen uniformly randomly from $S$.
\begin{claim}
Choose $X_1 \in_R \{0,1\}$ and  $X_2 \in_R \{0,1\}$ and set $X_3 = X_1 \oplus X_2$ (where $\oplus$ is the XOR operation). 
Then the variables $X_1, X_2, X_3$ are pairwise independent. 
\end{claim}
To see the claim verify that $\Pr(X_3 = \alpha | X_i = \beta) = 1/2$ for  $i = 1,2$ and for any $\alpha, \beta \in \{0,1\}$.

\section*{Max Cut Problem}
\begin{problem}[Max Cut Problem]
Given a graph $G = (V, E)$, the max cut problem is to find a partition of $V = A \cup B$ such that $$\abs{\{(v_1, v_2) \in E \mid v_1 \in A, v_2 \in B\}}$$ is maximized.
\end{problem}
That is, we need to find a cut with the maximum number of cut edges. The problem is known to be NP-hard, so we don't expect an efficient algorithm that
gives an exact answer. 
 Let us  see a simple randomized algorithm that gives a good approximation. 

\subsection*{Randomized (1/2)-Approximation Algorithm}
\begin{algorithm}
For each vertex $v \in V$, put it in set $S$ with probability $1/2$, independently. Then the set of cross edges is
$$\delta(S) = \{(u,v) | u \in S, v \notin S\}.$$
The partition is then $S$ and $V - S$.
\end{algorithm}

\begin{claim}
In expectation, this algorithm gives the size of the  cut within 1/2 approximation of the maximum cut. That is
$$E[|\delta(S)|] \geq \frac{Max Cut}{2}$$
\end{claim}
\begin{proof}
For each edge $e \in E$, define 
\[
X_e = \begin{cases} 
1 & if~ e \in \delta(S)\\
0 & otherwise
\end{cases}	
\]
First, let us note that $\Pr[X_e = 1] = 1/2$ because for any edge, its two endpoints will fall into different parts with probability 1/2.
Hence, $\E[X_e]=1/2$.
Now, the expected number of cross edges would be 

$$\E[|\delta(S)|] = \E\left[\sum_{e \in E} X_e\right] = \sum_{e \in E} \E[X_e] = \sum_{e \in E} 1/2 = \frac{|E|}{2}$$
by using linearity of expectation. Since $Max Cut \leq |E|$, we have 

$$\E[|\delta(S)|] \geq \frac{Max Cut}{2}$$
\end{proof}

\paragraph{Question.}
In the above analysis, have we really used the fact that the vertices were put in $S$ \emph{independently} of each other?
The answer is no. 
Linearity of expectation certainly does not need any kind of independence assumption. 
So, the only crucial part is to find the probability $\Pr[X_e = 1] = 1/2$.
This probability will be 1/2, as long as the two endpoints fall in $S$ randomly and \emph{independently} of each other. 
In other words, we only need that any two vertices are independent of each other. We do not need complete independence. 
And that's exactly pairwise independence. 

Here is a modified algorithm. 
\begin{algorithm}
Generate $n$ pairwise independent random bits, say $b_1, b_2, \dots, b_n$. 
Put the $i$th vertex in $S$ if and only if $b_i=1$.
\end{algorithm}

The advantage is that to generate $n$ pairwise independent bits, we need much fewer random bits than $n$.
Let's see one such generation procedure. 

\subsection*{Generating pairwise independent bits}
%To implement the algorithm, by just directly choosing a true random variable for each vertex gives $|V|$ bits of randomness for this algorithm.\\
The idea is inspired from the XOR example seen above.  

\begin{algorithm}
Take k independent random bits $b_1, b_2, \dots, b_k$, we can generate $2^k -1$ random variables defined as, $\forall S \subseteq \{1,2,\dots, k\}$, $S\neq \phi$, define $$b_S = \bigoplus_{i \in S} b_i$$
\end{algorithm}
The correctness of the construction can be seen by the below 2 propositions
\begin{proposition}
$Pr[b_S = 1] = \frac{1}{2} ~\forall S \subseteq \{1,2, \dots, k\}$.
\end{proposition}
\begin{proposition}
For any $S\neq T$ and for any $\alpha, \beta \in \{0,1\}$,  $Pr[b_S = \alpha \mid b_T = \beta] = \frac{1}{2}$
\end{proposition}
For the latter, %let us assume that $S \not\subset T$, without loss of generality.
 we can argue that if we fix all bits of $T$, we still have some bits in $S$ which are randomly set, which gives probability of $1/2$. This argument only works when $S \not\subseteq T$. If $S \subset T$, then we will argue that $b_T$ is independent of $b_S$, which is equivalent to saying that $b_S$ is independent of $b_T$.

Thus our algorithm can run using only $\log |V|$ number of random bits.
Now, we will use this fact crucially to make the algorithm completely deterministic.
The idea is that any randomized algorithm using $k$ bits can be simulated deterministically with a $2^k$ blow up in the running time. 



\subsection*{Deterministic Algorithm}
\begin{algorithm} 
Enumerate over all choices of $(b_1, b_2, \dots, b_k) \in \{0,1\}^{\log |V|}$, and for each choice, and assign the vertices according to the random bits $\{b_T\} ~\forall T \subseteq \{0,1\}^{\log |V|}$.
\end{algorithm}

That is, we have $2^{\log |V|} = |V|$ many choices for $(b_1, b_2, \dots, b_k)$ and thus, we have the same number of partitions. 
The guarantee we have is that the expectation of the cut-set size over these $|V|$ many partitions is at least $|E|/2$. 
In particular, one of these partitions will have cut-set size at least $|E|/2$. 
Note that this deterministic algorithm does not even look at the input graph. 
It is just going over a pre-determined small set of partitions and one of them is guaranteed to be large enough. 

The following example will be helpful. 
Suppose $|V|=8$. Then we will take three bits $b_1, b_2, b_3$, and go over all 8 possibilities for them. 
For each fixing of $b_1, b_2, b_3$, we will generate the following 8 bits:
\[0, b_1, b_2, b_3, b_1 \oplus b_2, b_2 \oplus b_3, b_1 \oplus b_3, b_1 \oplus b_2 \oplus b_3.\]
These eight bits will determine which vertex goes to which part. 
The following table describes different partitions of vertices we will go over. 
The vertices are indexed as $v_0, v_1, \dots, v_7$.

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c||c|}
\hline
$v_0$ & $v_1$ & $v_2$ & $v_3$ & $v_4$ & $v_5$ & $v_6$ & $v_7$  & \\
0 & $b_1$ & $b_2$ & $b_3$ & $b_1 \oplus b_2$ & $b_2 \oplus b_3$ & $b_1 \oplus b_3$ & $b_1 \oplus b_2 \oplus b_3$ & Partition \\
\hline
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & $\{v_0, v_1, v_2, v_3, v_4, v_5, v_6, v_7\} \cup \phi$ \\

0 & 1 & 0 & 0 & 1 & 0 & 1 & 1 & $\{v_0, v_2, v_3, v_5\} \cup \{v_1, v_4, v_6, v_7\} $ \\

0 & 0 & 1 & 0 & 1 & 1 & 0 & 1 & $\{v_0, v_1, v_3, v_6\} \cup \{v_2, v_4, v_5, v_7\} $ \\

0 & 0 & 0 & 1 & 0 & 1 & 1 & 1 & $\{v_0, v_1, v_2, v_4\} \cup \{v_3, v_5, v_6, v_7\} $ \\

0 & 1 & 1 & 0 & 0 & 1 & 1 & 0 & $\{v_0, v_3, v_4, v_7\} \cup \{v_1, v_2, v_5, v_6\} $ \\

0 & 0 & 1 & 1 & 1 & 0 & 1 & 0 & $\{v_0, v_1, v_5, v_7\} \cup \{v_2, v_3, v_4, v_6\} $ \\

0 & 1 & 0 & 1 & 1 & 1 & 0 & 0 & $\{v_0, v_2, v_6, v_7\} \cup \{v_1, v_3, v_4, v_5\} $ \\

0 & 1 & 1 & 1 & 0 & 0 & 0 & 1& $\{v_0, v_3, v_4, v_5\} \cup \{v_1, v_2, v_3, v_7\} $ \\
\hline
\end{tabular}
\end{center}
Our guarantee is that no matter what the graph is on 8 vertices, one of the above 8 partitions will have at least $|E|/2$ cut edges. 

We have seen that using $\log n$ independent random bits, we can generate $n$ pairwise independent bits. 
Is this optimal? Can we do the same using a small number of random bits? It turns out that $\log n$ is indeed the optimal. 

%   use this deterministic set formed using above construction and use that to create our partition $S \cup (V-S)$ as in the randomized algorithm. 

\begin{proposition}
For any sequence of $n$ pairwise independent random bits, the sample space size must be at least $n$.
\end{proposition}
We will prove this in the next lecture. 
%That is, we cannot do better than less than $\log n$ random bits for the $|V|$ pairwise independent bits.

\section*{Pairwise Independent Variables}
Suppose we want to construct random variables which are not bits, but have a larger sample space. 
Can we still generate pairwise independent random variables. 
It will be convenient to see the sample space as a finite field.
We will construct $n$ random variables $X_1, X_2, \dots, X_n \in \F$ for a finite field $\F$ and $n = |\F|$.
 We want that, $$\forall \alpha \in \F, \forall i~Pr(X_i = \alpha) = \frac{1}{|\F|}$$ and $$\forall \alpha,\beta \in \F, \forall i,j~ Pr(X_i = \alpha, X_j = \beta) = \frac{1}{|\F|^2}$$

\begin{claim}
Choose $k$ independent random values $b_1, b_2, \dots, b_k \in_R \F$. Define for any $S \in \{1,2,\dots, k\}$ $$b_S = \sum_{i \in S} b_i$$
The summation is over the field. 
Th random variables  $\{ b_S : S \subseteq \{1, 2, \dots, k\}, S \neq \phi \}$ are pairwise independent.
\end{claim}
The argument for this is the same as before. Remember that we had used $\oplus$ for bits, which is simply the addition operation in $GF(2)$. 
Thus, our seed length is roughly $\log n \cdot \log |\F|$. 
Also, it is not clear if we can generalize this construction to $k$-wise independence. 
We will discuss a different construction which easily generalizes to $k$-wise independence and also has a better seed length.

\begin{claim}
Randomly choose $a,b \in_R F$ and then generate the following random variables $$ \{az + b: z \in \F\}.$$
These $|\F|$ random variables are pairwise independent.
\end{claim}
To generalize to $k$-wise independence, we would use degree $k-1$ polynomial.
We will discuss in the next lecture. 
\end{document}