\documentclass[11pt]{article}
\include{lecture}


\usepackage{hyperref}
\begin{document}

% ********************
% LECTURE
% ********************
\lecture{15}{3/09/2010}{Space-Bounded Derandomization}
{Amanda Hittson and Jake Rosin}


% ******* ********* ********* ********* ********* ********* ********* 

Last time we used expanders to reduce the error of probabilistic 
algorithms by increasing randomness by only a small amount.  
Today we attempt the opposite:
reducing the amount of randomness required with a bounded 
increase in error. This lecture focuses on derandomization in a space-bounded 
setting; in the next lecture we will look at derandomization under time-bounds.

% *******************
% SECTION
% *******************
\section{Pseudorandom Generators}
\begin{definition}
  An $\varepsilon$-PRG (PRG stands for PseudoRandom Generator) 
  for a class $\mathcal{A}$ of algorithms is a 
  collection $(G_r)_r$ of deterministic procedures where 
  $G_r: \{0,1\}^{\ell(r)} \rightarrow \{0,1\}^{r}$
  such that for all $A \in \mathcal{A}$:
  \begin{equation}
    \label{14:eqn:PRG1}
    (\forall^{\infty} x)\hspace{12 pt} \|A(x,U_r) - A(x,G_r(U_{\ell(r)}))\|_1
    < 2\varepsilon, 
  \end{equation}
  where $r$ is the number of random bits $A$ uses on $x$
  (and is also the length of the output of $G_r$), 
  $U_n$ denotes $n$ bits taken from the uniform distribution, 
  $\ell(r)$ is the seed length (discussed below) and 
  $\forall^{\infty}$ means ``for all except finitely many.''
\end{definition}
Note that if $A$ is a decision algorithm, Equation \ref{14:eqn:PRG1} 
is equivalent to:
\begin{equation}
  (\forall^\infty x)\hspace{12 pt}
  \left[
    |\text{Pr}_{\rho \leftarrow U_r}
      [A(x,\rho) = 1] - 
      \text{Pr}_{\sigma \leftarrow U_{\ell(r)}}
        [A(x,G_r(\sigma)) = 1]|
      < \varepsilon
  \right]
\end{equation}

There are three important parameters to the above definition.

\begin{itemize}
\item Error $\varepsilon$: the deviation from the original randomized
algorithm.  For example, if the original algorithm has a probability
of error $\frac{1}{3}$ and $\varepsilon = \frac{1}{6}$, the probability
of error for the new algorithm will be $< \frac{1}{2}$.
We want $\varepsilon$ to be small, but it suffices that it
be ``small enough'' given the amplification techniques discussed in
previous lectures.
\item Seed length $\ell(r)$: the number of random bits required as input to
the pseudorandom generator.  We want this small.  
\item Complexity: measured in terms of the output length $r$.
We want PRGs with low complexity so that using them to generate random 
bits does not increase the total cost of running a randomized algorithm by
too much.
\end{itemize}

% ******************
% SECTION
% ******************

\section{Uses of PRGs}
Pseudorandom generators can be used to reduce the amount of randomness
required to run a randomized algorithm.  As a side effect they
can reduce the complexity of a deterministic simulation of a
randomized algorithm, by explicitly computing the probability of
acceptance over the set of all possible PRG seeds $\ell(r) < r$.
Namely, if $G$ is a $\frac{1}{6}$-PRG for $\BPTIME(t)$ computable in
$\DTIME(t')$, then

\begin{equation}
  \BPTIME(t) \subseteq \DTIME(2^{\ell(t)} \cdot (t'(t) + t))
\end{equation}
This is by cycling over all random seeds, running the algorithm on the 
output of $G$ for each, and outputting the majority answer.
For each seed value, the random string must be generated, taking
$t'(t)$ time, and the algorithm must be run, for an additional
$t$ steps.  Since this enumerates all possible seeds and the
cumulative error is $< \frac{1}{2}$, a majority vote
provides the correct answer.

Similarly, if $G$ is a $\frac{1}{6}$-PRG for $\BPSPACE(s)$ computable in
$\DSPACE(s')$, then

\begin{equation}
  \BPSPACE(s) \subseteq \DSPACE(\ell(2^s) + s'(2^s) + s)
\end{equation}

Given a PRG computable in polynomial time $t'$  with logarithmic seed
length $\ell(t)$, $\BPP \subseteq \P$.  Similarly given a PRG with logarithmic
seed length that runs in log space, $\BPL \subseteq$ L.  Such pseudorandom
generators are not known to exist, but this is an approach used
to attempt to prove the containments.

% *****************
% SECTION
% *****************
\section{Space-Bounded Derandomization}
Although we do not yet know how to construct a $\log$ space computable 
PRG with $O(\log r)$ seed length, there are nontrivial constructions
approaching this goal.  We now present a construction based on expanders.
\begin{theorem}
  \label{th:prg}
  There exists an $\varepsilon$-PRG for $\BPSPACE(s)$ with
  \begin{equation}
    \ell(r) = O(\log{\frac{r}{s}} \cdot (s + \log{\frac{1}{\varepsilon}}))
  \end{equation}
  computable in space $O(\ell(r))$.
\end{theorem}

\begin{corollary}
  There is a $\frac{1}{6}$-PRG for BPL with $\ell(r) = O(\log^2{r})$ 
  and computable in space $O(\log^2{r})$, thus 
  $\BPL \subseteq \DSPACE(\log^2{n})$.
\end{corollary}
This was already known, due to $\BPL \subseteq$ $\NC^2$, but this theorem
shows it can be done with PRGs as well.  
\footnote{An alternative construction can be used to show that
$\BPL\subseteq\DSPACE(\log^{1.5}{n})$ which is the best known bound.}

The idea behind this proof is dividing a space-bounded randomized
computation into $2^k$ phases.  Each phase uses $r'$ random bits,
where $r' = \frac{r}{2^k}$.  Since the operation of this machine
is bounded by space $s$, $s$ bits must pass from phase to phase.

By pairing these blocks and using an expander to produce their random
bits, we can reduce the overall level of randomness
used by the machine.  Consider an expander with degree $d$ and $2^{r'}$ 
vertices.  We let $G_{2r'}$ produce $2r'$ pseudorandom bits by
choosing a vertex in the expander at random, then moving to a random
neighbor (this is equivalent to selecting an edge at random and using
its endpoints).  $G_{2r'}$ requires a seed length of $r'\log{d}$ random bits 
for each block pair; if this is $< 2r'$ we have reduced the amount of 
randomness.  This process is diagrammed in \autoref{fig.blocks}.

\begin{figure}
\centering
  \input{14.blocks.1.pstex_t}

  \vspace{24 pt}

  \input{14.blocks.2.pstex_t}
  \caption{Dividing computation into blocks, with $s$ bits passing between
    each block.  The original computation is shown above, and below it is 
    shown with random bits of adjacent blocks coming from picking adjacent
    vertices in an expander.}
\label{fig.blocks}
\end{figure}

If the expander used is good enough, the output from the modified
block pair will not differ greatly from the output of the original.
We rely on the expander mixing lemma to prove this.

Call the distribution of input (output resp.) states to a block pair
$S_{in}$ ($S_{out}$)
and the random inputs to the pair $\rho_{\text{left}}$ and $\rho_{\text{right}}$.
There are two distributions to consider for ($\rho_{\text{left}}$,$\rho_{\text{right}}$):

\begin{itemize}
\item Random: $U_{2r'}$ - the original randomized input.
\item Pseudo-random: $G_{2r'}(U_{r'},U_{\log{d}})$ - output from our expander.
Note than $G_{2r'}(\rho,\sigma) = (\rho, \sigma$-th neighbor of $\rho$ in
the expander).
\end{itemize}
The following lemma bounds the difference in output distribution between 
the two scenarios.
\begin{lemma}
\label{14:lem:key}
For any distribution $S_{in}$ on $s$ bits where $\lambda$ is the
second largest eigenvalue of the expander,
\begin{equation}
|S_{out}(S_{in}, U_{2r'}) - S_{out}(S_{in}, G_{2r'}(U_{r'},U_{\log d}))|_1
\leq 2^s \cdot\lambda
\end{equation}
\end{lemma}

We soon prove this lemma, but for now we finish the description
of the PRG and the proof of its properties using this lemma.  
We first want to bound the difference in output
distribution of running the algorithm on purely random bits versus running
the algorithm by grouping pairs of blocks and producing the random bits 
from the expander.
Consider hybrid distributions, where $D_i$ is
the distribution formed by using the random distribution for the
first $2i$ blocks, then switching to the pseudo-random distribution for
the remainder.  Thus $D_{2^{k-1}}$ is perfectly random, and
$D_0$ is entirely pseudo-random.  The difference between these
two distributions is the difference between the randomized 
algorithm and our pseudorandom version.  From the triangle
inequality and our key lemma we find:

\begin{equation}
\label{15:eq:difference}
\|D_{2^{k-1}} - D_0\|_1 = \left\| \sum_{i=0}^{2^k-1} D_i - D_{i-1} \right\|_1
\leq \sum_{i=1}^{2^{k-1}} \|D_i - D_{i-1}\|_1
\leq 2^{k-1} \cdot 2^s \cdot \lambda
\end{equation}

This provides a bound on the error introduced by the first step
of the derandomization.  The amount of randomness has been reduced
from $2r'$ for each block pair to $r'+ \log{d}$, a savings of roughly
$r'$ as $d$ is constant.  This is not a large savings but note that
we have reduced our original block chain to an easier instance of the
same problem - one with $2^{k-1}$ blocks, each taking $r'+ \log{d}$
random bits.  These new computational blocks can be paired, with the
$r' + \log{d}$ random bits being generated by the expander as
described above.  Pairing blocks recursively (as shown in
\autoref{fig.blocks.three}) results in a PRG with the following
parameters:
\begin{itemize}
\item $\varepsilon < 2^k \cdot 2^s \cdot \lambda$.  This bound is
  found by summing \eqref{15:eq:difference} over all levels of recursion.
\item $\ell(r) = r' + k \cdot \log{d}$.  Each reduction requires an
  additional $\log{d}$ random bits.
\item $O(\ell(r))$ space complexity.  To compute a given output bit of the 
  PRG, we must compute neighbor relations in a series of expanders.  Each
  of these can be computed in linear space, so the amount of space used
  at the topmost level dominates.  Hence the total space used by the PRG
  is $O(\ell(r))$.
\end{itemize}

\begin{figure}
\centering
  \input{14.blocks.3.pstex_t}
\caption{Recursively pairing blocks and applying the expander.  $k$
expansions cover the entire computation.}
\label{fig.blocks.three}
\end{figure}

As defined above $r$ and $r'$ are related through $r' = \frac{r}{2^k}$.
The important terms in the parameters for this PRG are $\lambda$ and
$d$.  Any constant degree expander will have a constant $\lambda$, which
will eventually be overshadowed by $2^s$, resulting in 
$\varepsilon > 1$.  To grow $\lambda$ along with $s$ we begin with a
constant-degree constant-$\lambda$ expander and raise it to the $t$-th
power.  Allowing multi-edges in this graph results in a simple expression
of the new degree and the second largest eigenvalue in absolute value, namely 
$\lambda(G^t) = (\lambda(G))^t$, and $d(G^t) = (d(G))^t$.  Since we want
the error of our PRG to be less than $2\varepsilon$ we must 
satisfy
\begin{equation}
2^{k+s} \cdot \lambda_0^t < 2\varepsilon
\end{equation}
We rearrange to derive the value of $t$ that must be used, and plug in 
$d^t$ as the degree to determine the seed length
\begin{align}
&t = \Theta(k + s + \log{\frac{1}{\varepsilon}}) \\
&\ell(r) = \frac{r}{2^k} + k \cdot \Theta(k + s + \log{\frac{1}{\varepsilon}})
   \cdot \log{d}
\end{align}

We know that $k \leq s$, since there are at most $2^s$ blocks
in our construction and each block uses at least one random bit.  
Seed length can, therefore, be defined as
\begin{equation}
\ell(r) = \frac{r}{2^k} + k \cdot \Theta(s + \log{\frac{1}{\varepsilon}})
\end{equation}
The second term grows with $k$ while the first descends.  We have remarked
before that setting the two terms equal and solving for $k$ gives a result
that is minimal to within constant factors.
We use $k = \log{\frac{r}{s}}$.  The seed length becomes

\begin{equation}
\ell(r) = O(\log{\frac{r}{s}} \cdot (s + \log{\frac{1}{\varepsilon}}))
\end{equation}
finishing the proof of \autoref{th:prg}.  All that remains is to prove
Lemma 1.

\medskip

Notice that in our construction each block was treated as a black
box.  The only connection between blocks was the $s$ bits representing
the state of the machine.  The algorithm relies on only these $s$
bits being transmitted between blocks, but places no limit on the
computations performed by each block individually.  This PRG therefore
works for any algorithm which can be divided into $2^k$ blocks with
limited communication from block to block, even if each block
uses unbounded space.

% % *****************
% % SECTION
% % *****************

% \section{Proof of Lemma 1}
% We use the expander
% mixing lemma for this, and so the proof involves finding the
% appropriate sets to which to apply the lemma.
% \begin{proof}
% First notice that we can prove the lemma by only
% considering point distributions.  Point distributions place all probability
% in a single point.  Any distribution $S_{in}$ is a convex combination of point
% distributions $X_1, X_2, ..., X_k$.  For a randomized process $Z$, 
% if we consider the quantity
% $$\Delta(S_{in}) = \| Z(S_{in},U_{2r'}) - Z(S_{in},G(U_{r'},U_{\log d}))\|_1,$$
% we know by the triangle inequality for 1-norm that 
% $\Delta(S_{in}) \leq \Sigma_{k} \Delta(X_k)$.  Hence, we only need to consider
% a point distribution $s_{in}$.

% We have defined $S_{in}$ and $S_{out}$ as the distributions of inputs
% to, and outputs from, respectively, a pair of blocks.  We now define
% $S_{mid}$ as the distribution of states when control passes from the
% first block of a pair to the second.  With this distribution we
% represent the probability of moving from some input state $s_{in}$ to
% some output state $s_{out}$ using perfectly random bits as follows

% \begin{align}
% \text{Pr}[s_{in} \rightarrow s_{out}] 
%    &= \sum_{s_{mid}} \text{Pr}[ s_{in} \rightarrow s_{mid}
%                                        \rightarrow s_{out}] \\
% \label{prob14}
%    &= \sum_{s_{mid}} \text{Pr}[(\rho_{\text{left}}, \rho_{\text{right}}) \in S \times T]
% \end{align}

% Where $S$ and $T$ are defined as:

% \begin{align}
% S = S_{s_{in}, s_{mid}} &= \{\rho_{\text{left}} | s_{in} 
%                   \rightarrow s_{mid}\} \\
% T = T_{s_{mid}, s_{out}} &= \{\rho_{\text{right}} | s_{mid} 
%      		  \rightarrow s_{out}\}
% \end{align}

% In terms of the notation of the expander mixing lemma \autoref{prob14} 
% can be written $\sum_{s_{mid}} \mu(S) \cdot \mu(T)$, as $\rho_{\text{left}}$
% and $\rho_{\text{right}}$ are chosen independently at random.

% Under the pseudorandom distribution, the probability of picking an edge 
% between $S$ and $T$ is replaced by  $\frac{|E(S,T)|}{dN}$ rather than
% $\mu(S)\cdot\mu(T)$.  Using the expander mixing lemma:

% $$
% \begin{array}{c}
% \displaystyle
% \left|\Pr_{(\rho_{\text{left}}, \rho_{\text{right}}) \leftarrow U_{2r'}}
% [s_{in}\rightarrow s_{out}]
% - \Pr_{(\rho_{\text{left}}, \rho_{\text{right}}) \leftarrow G_{2r'}(U_{\ell(2r')})}
% [s_{in}\rightarrow s_{out}]
% \right| = \\
% \displaystyle = 
% \left|\sum_{s_{mid}} \mu(S)\mu(T) - \sum_{s_{mid}}\frac{|E(S,T)|}{dN}\right|
% \leq \sum_{s_{mid}} \lambda \sqrt{\mu(S)\mu(T)}
% \end{array}
% $$

% This inequality represents the probability of generating a single
% fixed $s_{out}$.  To find the difference in probability over $S_{out}$
% we take the sum:

% \begin{equation}
% |S_{out}(s_{in}, \text{random}) - S_{out}(s_{in}, \text{pseudo})|_1
%   \leq \sum_{s_{out}} \sum_{s_{mid}} \lambda \sqrt{\mu(S)\mu(T)}
% \end{equation}

% By Cauchy-Schwartz we can bound this summation by:

% \begin{equation}
% \sum_{s_{out}} \sum_{s_{mid}} \lambda \sqrt{\mu(S)\mu(T)}
%  \leq \lambda \cdot \sqrt{\sum_{s_{out}} \sum_{s_{mid}} \mu(S)}
%                     \sqrt{\sum_{s_{out}} \sum_{s_{mid}} \mu(T)}
% \end{equation}

% Given the definition of $S$ provided above, it should be clear that
% $\sum_{s_{mid}} \mu(S)$ = 1.  Similarly, the order of summations
% in the last term can be reversed, and $\sum_{s_{out}} \mu(T)$ = 1.  We
% have therefore demonstrated that:

% \begin{equation}
% |S_{out}(S_{in}, \text{random}) - S_{out}(S_{in}, \text{pseudo})|_1
%  \leq \lambda \cdot \sqrt{2^s} \cdot \sqrt{2^s} 
%  = 2^s \cdot \lambda
% \end{equation}

% \end{proof}


% \medskip

% An alternate proof of Theorem \ref{th:prg}
% using universal hash functions exists, which shows
% $\BPSPACE(s) \subseteq \DTISP(2^{O(s)}, s^2)$.  The proof above
% is more general, as discussed, due to the sole requirement that the
% computation can be divided into discrete blocks with limited 
% communication.

% The alternate proof shows that $\BPSPACE(s) \subseteq \DSPACE(s^2)$, which
% we now already know.  By exploiting the properties of that construction,
% however, the inclusion can be improved to 
% $\BPSPACE(s) \subseteq \DSPACE(s^{\frac{3}{2}})$.  Although randomness
% is conjectured to provide no more than a constant factor improvement
% in space complexity, an overhead of $\sqrt{s}$ is the best known.

% *****************
% SECTION
% *****************

\section{Next Lecture}
In the next lecture we will see a proof of Lemma \ref{14:lem:key} using 
the Expander Mixing Lemma. 
We will also look at time-bounded derandomization.  In
a time-bounded setting no non-trivial derandomizations are known; it
is possible (though it would be surprising) that $\BPP = \EXP$.  However,
it is possible to perform non-trivial derandomizations under certain
reasonable assumptions.  As we will see, if there exists a problem in
linear exponential time that requires circuits of linear exponential size
then $\BPP = \P$.  In other words, if non-uniformity doesn't help to speed
up computations, neither does randomness.
\end{document}
