% Not more than 80 characters wide
%12345679801234567980123456798012345679801234567980123456798012345679801234567980
\documentclass[11pt]{article}

\usepackage{lecture}
\usepackage{tikz}
\usetikzlibrary{arrows}

\def\01{\{0,1\}}
\def\yti{y_{t_i}}
\def\yt1{y_{t_1}}

\newcommand{\func}[3]{#1 : #2 \rightarrow #3}

\newcommand{\bfunc}[3]{\func{#1}{\01^{#2}}{\01^{#3}}}

\def\={\dot{=}}

\begin{document}

\lecture{21}{4/10/2013}{Randomness and Space}{Adam Everspaugh}

\draft % put this here only if you want to indicate this is a draft

In this lecture we construct a family of psuedorandom generators that operate
in logarithmic space and can $\epsilon$-fool branching programs of constant width.

\section{Branching Programs and Generators}

Recall that a branching program $B$ of length $n$ and width $w$ is a set of
functions $(B_1, B_2, \ldots B_r)$ such that each $B_i : \{0,1\} \rightarrow
[w].$  A branching program can also be viewed as a layered, acyclic graph in
which every layer has the same number of vertices (representing states of the
program), and every vertex (except the ones in the last layer) have exactly
2 outgoing edges labelled 0 or 1.  These edges indicate moving to a new
state based on an input of 0 or 1.

Also recall the INW-generator: $G_i(xy) = G_{i-1}(x)G_{i-1}(E(x,y))$ where $E$
is an extractor $E_i:\01^{is}\times\01^s \rightarrow \01^{2^i}.$  The INW
generator is $\epsilon$-psuedorandom for the following types of
constant-width branching programs and seed lengths:

\[
\begin{array}{r|l}
\text{BP}  &  \text{seed length}\\  
\hline
all & \approx(\log r)(\log{\frac{rw}{\epsilon}})\\
regular & \approx(\log r)(\log{\frac{w\log r}{\epsilon}})\\
permutation & \approx(\log r)(poly(w) + \log \frac{1}{\epsilon})\\
\end{array}
\]

A \emph{regular} branching program is one where every pair of consecutive layers
forms a bipartite, regular graph.  A \emph{permutation} branching program is one
where the mapping between any two consecutive layers is a permutation (a
bijection).  

Note that our seed length for permutation branching programs is not necessarily
better than the seed length for regular branching programs because it contains a
$poly(w)$ term.  However, if we fix the width $w$ to a constant value, then we
can fully derandomize permutation branching programs in logarithmic space.

\section{Logspace Generator}

We'll define a new generator that stretches a seed of length $\approx \log w$ to
a length of $r$ (the length of our branching program).  We'll do this in
logarithmic space under the condition that $r \leq poly( \log w)$ ($r$ is much
smaller than it could be).

Use the following $(\frac{n}{2}, \beta)$-extractor:
\begin{equation*}
\func{E}{\01^n\times\01^d}{\01^{\frac{n}{4}}}, \text{ where } d \leq O(\log
\frac{n}{\beta}),
\end{equation*}
\begin{equation*}
n \= \log w, 
~t_i \= 8(\log w)^\gamma, \text{ with constant } \gamma,  0 < \gamma < 1.
\end{equation*}
Note: The value $\gamma$ simply allows us to control the error.

\begin{definition}[Logspace Generator $G_i$] 
Define our logspace generator\\
$\bfunc{G_i}{n+t_1d}{2n^{1+i\gamma}}$ and it's helper function\\
$\func{G_i'}{\01^n \times \01^d \times \ldots \times
\01^d}{\01^{t_i\frac{n}{4}}}$
recursively as:
\begin{equation*}
 G_i'(x~y_1~y_2  \ldots y_{t_i}) \= E(x,y_1) E(x,y_2) \ldots E(x,y_{t_i}) 
\end{equation*}
\begin{equation*}
 G_i \= G_i' \circ G_{i-1}' \circ \ldots \circ G_2' \circ G_1'
 \end{equation*}   
 \end{definition}

We can visualize an application of $G_i$ as a series of applications of
the helper function $G_i'$ where the output of $G_1'$ is fed into $G_2'$ and so
on. Each application of the helper function $G_i'$ expands the input to a larger
output by rearranging the inputs that go into the extractor $E$.  This gives
$G_i$ an output length that is exponentially longer than it's input.

\begin{center}

\tikzstyle{box}=[draw, fill=blue!20, minimum size=2em,distance=2cm]
\tikzstyle{init} = [pin edge={to-,thin,black},distance=2cm]

\begin{tikzpicture}[node distance=2.5cm,auto,>=latex']
    \node [init] (s) {$xy_1\ldots y_{t_1}$};
    
    \node [box] (g1) [right of=s] {$G_1'$};
    \node [init] (out1)[right of=g1] {$xy_1\ldots y_{t_1}\ldots y_{t_2}$};
    \node [box] (g2) [right of=out1] {$G_2'$};
    \node [init] (out2)[right of=g2,node distance=1.5cm] {$\ldots$};

    \node [box] (gi) [right of=out2,node distance=1.5cm] {$G_i'$};
    \node [init] (e) [right of=gi] {$output$};

    \path[->] (s) edge node {} (g1);
    \path[->] (g1) edge node {} (out1);
    \path[->] (out1) edge node {} (g2);
    \path[->] (g2) edge node {} (out2);
    \path[->] (out2) edge node {} (gi);
    \path[->] (gi) edge node {} (e);
\end{tikzpicture}

\end{center}

Let's analyze how much $G_i$ stretches it's input.  Our input is of length $n +
t_1d$:
\[	n+t_1d \leq n + \delta n\gamma \log \frac{n}{\beta} \]
\[ \text{ If } \log \frac{1}{\beta} \leq n^{1-\gamma} \Rightarrow \] 
\[   n + \delta n\gamma \log \frac{n}{\beta} \leq O(n) = \log w  \] 

And our output is of length $t_i\frac{n}{4} = 2n^{1 + i\gamma}$.   
So, as long as $\beta$ is ``not too small'', our generator $G_i$ stretches
$O(\log w)$ bits to $\rightarrow poly(\log w)$ bits. 

\subsection{Space Requirements}

A quick analysis of $G_i$ shows that it can be computed in logarithmic space:
\begin{itemize}
  \item $E(x,y)$ can be computed in $space = O(n) = O(\log w)$.
  \item Each $G_i'$ runs $E$ iteratively, so $G_i'$ can be computed is $space =
  O(\log w)$.
  \item $G_i$ can be comnputed in $space = i \cdot \log w \leq O(\log w)$  
\end{itemize}

\subsection{Psuedorandomness for Branching Programs}

We'll prove inductively that the logspace generator $G_i$ is
$\epsilon$-psuedorandom for branching programs of constant width and some
bounded length.

\begin{theorem}[$G_i~\epsilon$-fools branching programs]
$G_i$ is $\epsilon$-psuedorandom for branching programs of constant width and
length $t_i\frac{n}{4}$ where $\epsilon = t_i(\beta + \frac{1}{w})$.
\end{theorem}

For our proof, we'll start with the following lemma.

\begin{lemma}[Basis for $G_1$]
$G_1$ is $\epsilon$-psuedorandom for branching programs of constant width and
length $t_1\frac{n}{4}$ where $\epsilon = \epsilon_1 = t_1(\beta +
\frac{1}{w})$.
\end{lemma}

Note:
\[ \epsilon = t_1(\beta + \frac{1}{w}) \leq \frac{\log w}{w} + \beta \log w. \]
So, we require that $\beta = \frac{1}{poly(w)}$ to ensure our generator can be
computed in $space = \log w$.

Consider the sequence of bits output from $G_1(x~y_1 \ldots y_{t_1})$.
Each bit takes us to a new layer in a branching program $B$, but we'll ignore
intervening layers and only examine the layers that we arrive at after applying
the $\frac{n}{4}$ bits from each extractor call $E(x,y_i)$.  Call this sequence
of layers: $L_1, L_2, \ldots L_{l-1}, L_{l}$.

Let $P_l$ be the distribution on layer $L_l$ after the psuedorandom walk with
input $G_1(xy_1\ldots \yt1)$.  Let $T_l$ be distribution of the same definition
with uniformly random input.  Notice that:
\[ P_l^u(v) = \Pr[ \text{psuedorandom walk starting at u ends at v}] \]
\[ T_l^u(v) = \Pr[ \text{uniformly random walk starting at u ends at v}] \]
\[ \text{where } u \in L_i, v \in L_l, \text{ for some layer } L_i 
\text{ in branching program } B. \]

\begin{claim} $d_{stat}(T_l, P_l)  \leq l\cdot(\frac{1}{w}+\beta)$
\end{claim}
\begin{proof}[Claim]

\[ d_{stat}(T_l, P_l) \]
\[ = d_{stat}(\Sigma_{u \in L_{l-1}}T_{l-1} \cdot T_l^u,  
     \Sigma_{u \in L_{l-1}}P_{l-1} \cdot P_l^u )
\]
By the triangle inequality $d(A,C) \leq d(A,B) + d(B,C)$:
\[
 \leq d_{stat}(\Sigma_{u}T_{l-1}(u) \cdot T_l^u,  
     \Sigma_{u}P_{l-1}(u) \cdot T_l^u ) +
     d_{stat}(\Sigma_{u}P_{l-1}(u) \cdot T_l^u,
     \Sigma_{u}P_{l-1}(u) \cdot P_l^u )
\]
Terms $d(A,B)$ only differ by their distributions, and terms $d(B,C)$ can be
factored:
\[
 \leq d_{stat}(T_{l-1}, P_{l-1}) +   
     \Sigma_{u}( P_{l-1}(u) \cdot d_{stat}(T_l^u, P_l^u ) )
\]
We can split our sum based on the ``hard to reach'' vertices and the remaining
vertices. Let set of ``hard to reach'' vertices be  
$H = \{u | u\in L_{l-1}, P_{l-1}(u) < \frac{1}{w^2} \}$.  
And let the remaining ``easier to reach" vertices
be the set 
$E = \{u | u\in L_{l-1}, P_{l-1}(u) \geq \frac{1}{w^2} \}$.
\[
 \leq (l-1)(\frac{1}{w} + \beta) +   
     \Sigma_{u \in H}(\frac{1}{w^2}\cdot 1 ) +
     \Sigma_{u \in E}(P_{l-1}(w)) \cdot
     d_{stat}(T_L^u, P_l^u) 
\]
Our sum of ``easier to reach'' vertices in $E$ is the sum over a probability
distribution, so it has a value of at most 1 and our statistical distance is at
most $\beta$ by the guarantee of our extractor, so:
\[  \leq (l-1)(\frac{1}{w} + \beta) + \frac{1}{w} + \beta \]
\[  \leq l(\frac{1}{w} + \beta) \]
\end{proof}

\begin{lemma}[Inductive Step]
If $G_i$ is $\epsilon$-psuedorandom for a branching program $B$ of constant
width $w$ and bounded length, then $G_{i+1}$ is also $\epsilon$-psuedorandom for
$B$.
\end{lemma}
\begin{proof}
First, observe that:
\begin{align*}
G_i & = (G_i' \circ G_{i-1}' \circ \ldots G_1')\\ 
G_{i+1} &= G_{i+1}' \circ (G_i' \circ G_{i-1}' \circ \ldots G_1')\\ 
G_{i+1} &= G_{i+1}' \circ (G_i) 
\end{align*}

Let $B' = (B \circ G_i)$ and observe that $B'$ is also a branching program of
constant width and $space = O(w)$.  By our claim, $G_{i+1}'$ is
$\epsilon$-psuedorandom for $B'$ and this implies that $G_{i+1}' \circ G_i$ is
$\epsilon$-psuedorandom for $B$.  Since $G_{i+1} = G_{i+1}' \circ G_i$, then we
have:
\[ G_i ~\epsilon \text{-psuedorandom for } B \Longrightarrow 
G_{i+1} ~\epsilon \text{-psuedorandom for } B \]
\end{proof}

\bibliographystyle{alpha}
% \bibliography{references}

\end{document}
