\documentclass[11pt]{article}
\include{lecture}
\usepackage{alg}
\begin{document}


% *************
% LECTURE
% *************
\lecture{5}{2/09/2010}{Space-Bounded Nondeterminism}{Matthew Anderson \& Michael Correll}

Last lecture we discussed time-bounded nondeterminism.  We discussed
hierarchy results that showed given a little more time we could
solve a strictly larger subset of problems.  We then addressed the $\P$ vs. $\NP$ problem, proving that if $\P \neq \NP$ then there are problems in $\NP$ which are neither NP-complete nor in $\P$ and thus NP-intermediate.  Finally, we explored relativization showing that there exists an oracle, $A$, for which $\P^A = \NP^A$ and an oracle, $B$, for which $\P^B \neq \NP^B$, this implies that techniques that
relativize are not sufficient for resolving the $\P$ versus $\NP$ question.  

\section{Overview}

Today we continue our discussion of nondeterminism by looking at
space-bounded nondeterminism.  We are able to prove stronger results
in the space-bounded case than in the time-bounded case.  We 
prove three main results relating space-bounded nondeterminism to
other complexity classes.    

\begin{theorem}
\label{05.thm.1}
$\NSPACE(s(n) \subseteq \cup_{c>0} \DTIME(2^{cs(n)})$
\end{theorem}

\begin{theorem}
\label{05.thm.2}
$\NSPACE(s(n)) \subseteq \DSPACE(s^2(n))$
\end{theorem}

\begin{theorem}
\label{05.thm.3}
$co\NSPACE(s(n)) = \NSPACE(s(n))$
\end{theorem}


The proof of all the results assume that we have a space computable
function, $s(n) : \mathbb{N} \rightarrow \mathbb{N} $ such that $s(n)
\ge \log n$. The restriction that $s(n)$ must be space computable is
not necessary for the proofs of these theorems, we discuss how to
remove this restriction. We require $s(n) \ge \log n$, because space bounds
lower than logarithmic cause strange behavior and make it difficult
for the machine to act in an interesting manner on its linear input.

Theorem \ref{05.thm.1} says that everything that can be done in $\rm{NL}$
can be done in $\P$ and everything that can be done in $\rm{NPSPACE}$ can
be done in $\EXP$.  Theorem \ref{05.thm.2} gives us that in only
quadratically more space we can perform nondeterministic computation
deterministically.  No similar result is known for time-bounded
computation.  This result is made possible due to the fact that space is in a sense more ``flexible" than time (e.g. we can reuse space on tapes where we cannot reuse time steps) it is in a qualitative sense ``easier" to provide definite bounds and relationships between space complexity classes than it was with time complexity bounds.  The third result, Theorem $\ref{05.thm.3}$, follows from that fact that it is easier to compute
the complement of a language in space-bounded computation because you
can iterate over all of the witnesses and check that none are valid.
We will actually prove that $co\NSPACE(s(n)) \subseteq \NSPACE(s(n))$,
but by complementing twice we get the equality.  Theorem
$\ref{05.thm.3}$ implies a tight space hierarchy for nondeterministic
machines by using diagonalization. 

Directly from these results:
\begin{corollary}
\label{05.col.1}
$\L \subseteq \rm{NL} \subseteq \P \subseteq \NP \subset \PSPACE = \rm{NPSPACE}
\subseteq \EXP \subseteq \rm{NEXP}$.
\end{corollary}

\begin{proof}

$\L \subseteq \rm{NL}$ and $\P \subseteq \NP$ follow trivially from earlier results. $\rm{NL} \subseteq \P$ follows from Theorem $\ref{05.thm.1}$ above, using $s(n)=\log n$. $\NP \subseteq \PSPACE$ follows from a consideration of a $\PSPACE$ machine that iterates through every possible witness, verifying membership and thus emulating the computation of an $\NP$ machine.  $\PSPACE=\rm{NPSPACE}$ follows from Theorem $\ref{05.thm.2}$ above, since if there is only a quadratic overhead in converting from $\rm{NSPACE}$ to $\DSPACE$, the conversion from from $\rm{NPSPACE}$ to $\DSPACE$ will introduce only a squared term, which is still polynomial and thus in $\PSPACE$.  

\end{proof}

Whether these inclusions are strict is an open problem, the only
separations that are known come from the hierarchy results which we
discussed in previous lectures.  For example, we know $\L \subsetneq
\PSPACE$ but not whether $\L \subsetneq \NP$. 


\begin{corollary}
If $s, s' : \mathbb{N} \rightarrow \mathbb{N}$ such that $s(n)$ is
space constructable and $s(n) = \omega(s'(n))$ then $\NSPACE(s'(n))
\subsetneq \NSPACE(s(n))$.
\end{corollary}

The proof of this corollary follows the same diagonalization strategy
as we have seen before. Since complementation is easier in the
space domain a constant factor is sufficient to accomplish strictly
more.

Recall, from Lecture 1, that our definition of space usage of a
machine is the index of highest indexed cell it accesses.  If a
machine runs in space $s$, the machine's state (tape heads, tape
state, computation state) can be described using $O(s)$ bits. 


% *******************
% SECTION
% *******************
\section{Proof of $\NSPACE(s(n)) \subseteq \cup_{c > 0} \DTIME(2^{cs(n)})$}

\begin{proof}
  Consider a NTM $M$ running in space $s(n)$.  Fix an input $x \in
  \Sigma^n$.   Consider the configuration graph, $G = (V,E)$, of $M$
  on input $x$.  Each vertex represents a possible configuration of
  $M$ that does not use more that $s(n)$ space.  It follows that: 

  From this definition we can compute a bound for the number of vertices in this graph, viz.:
  \begin{equation}
  |V| \le |Q|\cdot n\cdot |\Gamma|^{s(n)\cdot k}]\cdot s(n)^{k} = 2^{O(s(n))}
  \end{equation}

   By construction, an input is accepted $\iff$ there exists a path from our initial state $Q_o$ to an accepting state $Q_f$ (WLOG we allow for one unique accepting state. This can be done by requiring that $M$ clear the work tapes and move the tape heads to the beginning before accepting an input in a final state). Thus the problem of ``is this input accepted on $M$" becomes a new problem, ``is there a valid path from one vertex to another in a digraph $G$," or the ST-CONNECTIVITY problem. This problem can be solved  in polynomial time. Thus a problem in $\NSPACE(s(n))$ can be encoded as a problem in $\DTIME(2^{O(s(n))})$.
\end{proof}

This proof works nicely if $s(n)$ is space constructable.  If this is
not the case or we do not know the value of $s(n)$, we can run the
procedure several times while increasing a fixed space-bound until the
computation has enough space to complete.  More precisely, iterate
over space bounds $s = 1,2,3,...$.  If the computation reaches an
accepting state, then accept.  If the computation does not accept but tries
to exceed the space bound, repeat this procedure with a larger space
bound.  If the computation does not on any path try to exceed the
space bound, then accept if there is a path to an accepting state,
otherwise reject.   

\begin{corollary}
  ST-CONNECTIVITY for directed graphs is complete for $\rm{NL}$ under  $\le_m^{\log}$.
\end{corollary}

\begin{proof}
ST-CONNECTIVITY $\in \rm{NL}$ since we can use non-determinism to guess a valid path to take from S to T. This problem takes log time since we need to track current location, a counter to determine whether we are within our space bound $n$, and a comparison to the accepting vertex. Since ST-CONNECTIVITY has been shown in the proof above to correspond to an encoding of a NTM, it follows that it is also hard for $\rm{NL}$.
\end{proof}

This corollary implies that if ST-CONNECTIVITY (STCON) $\in \L$ we have $\L = \rm{NL}$.
The STCON  problem is also known as the Direction Path Problem (DPP).
It is not known if DPP $\in \L$, however, the undirected version of
the problem is. 

\section{Proof of $\NSPACE(s(n)) \subseteq \DSPACE(s^2(n))$}

\begin{proof}
  Consider a NTM $M$ running in $\NSPACE(s(n))$.  Fix input $x \in
  \Sigma^n$.  Consider a computation tableau for a $M$: each row corresponds to a description of a step of computation, including inputs tape, work tape(s), tape head position, internal state, \&c. From a similar argument used above, the width of one row of the tableau is $O(s(n))\cdot 2^{O(s(n))}$. Assuming a unique final state (allowed WLOG by using a similar tape clearing scheme employed above, combined with the mandate that the most parsimonious computation route be used) there are $t(n)$ such rows in this tableau. 
  
  We will label the first row $c_0$ (encoding the initial configuration) and the final row $c_1$ (representing the accepting state's configuration). A row can be placed in the tableau $\iff$ it is a configuration representing a valid transition from the previous row.

  \begin{figure}[t]
    \centering
    \label{05.fig.1}
   $\begin{array}{|c|}\hline \mathrm{Initial \ configuration} \ c_0 \\ \hline \mathrm{Next \ configuration} \\ \hline \cdots \\ \hline \cdots \\ \hline \cdots \\ \hline \cdots \\ \hline \mathrm{Final\ configuration} \ c_1 \\ \hline
   \end{array}$
    \caption{An illustration of the configuration tableau used in the
      proof of Theorem $\ref{05.thm.2}$. The tableau has width $O(s(n))\cdot 2^{O(s(n))}$ .}
  \end{figure}

  Again, we would like to determine if there are a sequence of states
  that take us from $c_0$ to $c_1$ in $t$ time and using no more
  than $s(n)$ space.  A naive approach will take exponential space.
  To achieve the quadratic space blow up we use a divide and
  conquer strategy.  Instead of going directly from $c_0$ to $c_1$ we
  guess an intermediate state $c_{\frac{1}{2}}$ and verify
  independently that we can go from $c_0$ to $c_{\frac{1}{2}}$ and
  $c_{\frac{1}{2}}$ to $c_1$.  The benefit of doing it this way is
  that we can reuse the space used in the first part of the
  computation when we do the second part.  

  The highest level of the computation will look something like this:

  \begin{equation}
    x \in L(M) \Leftrightarrow (\exists c_{1/2})(\forall b \in
    \{0,1\}) c_{\frac{b}{2}} \vdash_M^{\frac{t}{2}} c_{\frac{b+1}{2}}
  \end{equation}
  This reduces the original problem into two subproblems of half the
  size.  We can apply this procedure recursively reusing the space
  that was taken up in the computation of the first part of the
  problem.  Because we are halving the size of the problem at each
  level after $\log t$ recursions we reach the base case where we have
  to verify that one state transitions to another in one step.  We can
  phrase this as a full quantified boolean formula:

  \begin{equation}
    x \in L(M) \Leftrightarrow (\exists c_{\frac{1}{2}})(\forall b_1
  \in \{0,1\})  (\exists  ...)(\forall ...) ... (\exists c_\frac{x}{t})(\forall
  b_y \in \{0,1\})  c_{\frac{x+b_y-1}{t}} \vdash_M^1
  c_{\frac{x+b_y}{t}} 
  \end{equation}

  The index $x$ in the last part of Equation 4 is dependent on the
  previous choices for the $b$ variables.  The predicate checks
  whether the configurations guessed to come immediately before and
  after $c_\frac{x}{t}$ have valid one step transitions to and from
  $c_\frac{x}{t}$. 

  Consider how much space is required to evaluate this boolean
  formula.  Each existential quantifier requires $s(n)$ space to
  describe the configuration.  Each universal quantifier requires one
  bit of information to store its value.  There are $\log t$ pairs of
  quantifiers so the total amount of space required is $O(s \cdot (\log t +
  1)) = O(s^2)$.

\end{proof}

Again we are implicitly assuming that $s$ is space constructable,
however we can apply the same technique as before to remove this
requirement.  

\subsection{TQBF}

The boolean formula which was introduced in the previous proof
is called a quantified boolean formula.  These types of formulas are
part of an interesting language called true quantified boolean
formulas.  TQBF can be interpreted as a language that contains first order sentential logical formulae that happen to be true.

\begin{definition}[True Quantified Boolean Formula (TQBF)]
  The language of all quantified boolean formulas which have a 
  number of quantifier alternations, contain no free variables and are
  true.  
\end{definition}

\begin{corollary}
  $\rm{TQBF}$ is complete for $\PSPACE$ under $\le_m^\P$. 
\end{corollary}

\begin{proof}
The proof of Theorem \ref{05.thm.2} gives a polynomial mapping
reduction for a general $\PSPACE$ problem transforming it into a
TQBF in polynomial time making TQBF hard for $\PSPACE$.  TQBF is in
$\PSPACE$ because a $\PSPACE$ machine can iterate over all
possibilities.
\end{proof} 

Note that $\PSPACE \subseteq \P^{\rm{TQBF}}$ by the corollary and
$\P^{\rm{TQBF}} \subseteq \PSPACE$ because all queries to the oracle can be
constructed in polynomial time and we have closure under polynomial
composition.  Therefore $\P^{\rm{TQBF}} = \PSPACE$.  Taking this idea
further we get the following containment:

\begin{equation}
\P^{\rm{TQBF}} = \PSPACE = \NP^{\rm{TQBF}} \subseteq
(\PSPACE^{\rm{TQBF}} = \PSPACE).
\end{equation}

The last equality is model dependent because it matters whether you
count the cells used on the oracle tape or not (if the oracle tape is
not counted, a $\PSPACE^{\rm{TQBF}}$ machine could abuse the oracle tape to
compute more than an unassisted $\PSPACE$ machine could).  This also
gives another example of an oracle (this time a natural one) for which
$\P^A = \NP^A$.  As before, note that techniques that relativize
cannot be the sole means to solve the $\P$ versus $\NP$ question. 

Many $\PSPACE$ complete problems can be interpreted as adversarial game theory calculations. TQBF can be thought of as a game between two players, $\forall$ and $\exists$ , who place quantifiers in a boolean formula. $\exists$ wins if, after no player can move, the formula is true. Determining if there is a dominating strategy for $\exists$ given a formula is a $\PSPACE$ complete problem. 

\section{Proof of $co\NSPACE(s(n)) = \NSPACE(s(n))$}

\begin{proof} 

  Consider a NTM $M$ using space $s(n)$ on a fixed input $x \in
  \Sigma^n$.  We saw before that given a graph and two vertices that
  reachability can be guessed reachability in $\log (|V|)$ space.
  This theorem shows that the complement can also be computed in log
  space, by showing that a path \emph{does not} exist.  
  
  It is sufficient for this proof to show that $\overline{\mathrm{ST-CONNECTIVITY}} \in \NL$, since we have already shown that ST-CONNECTIVITY is complete for $\NL$. By increasing the allowable size of the graph we use to represent the TM, this result will hold for higher spaces as well. 
  
  We can attempt this problem using  a method called ``inductive counting." For the purpose of this proof we will denote $c_k$ as ``the number of vertices reachable from $S$ in at most $k$ steps." We are interested in finding $c_n$, since this will solve the problem for us in the way listed above. We can find $c_0$ a priori (only one vertex, $S$, is reachable in 0 steps from $S$). If, given $c_k$, we can generate $c_{k+1}$, then by the mathematical principle of induction we can generate $c_n$.
  
  The key idea behind this proof is that if it is known how many
  vertices are reachable from the start vertex $u$, then it can be
  verified that the destination vertex $v$ is not one of those
  vertices by looking at all possible vertices and guessing and
  verifying whether they are reachable. In order to count the number
  of reachable vertices we use a procedure call inductive counting.  

  Suppose you have a subroutine that behaves as follows.  The
  subroutine takes as input the graph $G$, the start vertex $u$, the
  destination vertex $v$, the number of steps allowed $t$ and the 
  number of vertices $c_t$ within $t$ steps of $u$.  The subroutine
  has three possible return values: YES, NO and ?.  A YES answer means
  that it is possible to reach $v$ from $u$ in $t+1$ steps.  A NO
  answer means that it is not possible to reach $v$ from $u$ in a most
  $t+1$ steps.  A ? return value
  means that the procedure was unable to determine the answer.
  Consider the ? return value a value that indicates that the
  subroutine either made bad internal guesses or got bad input, in
  either case it's output could not be trusted and that computation
  path is compromised.  This subroutine will run in $\rm{NL}$, is
  always correct if it answers YES or NO, and at least one computation
  path returns YES or NO.  If value passed as $c_t$ is
  not correct the subroutine will return ?. 

  We will describe the subroutine more specifically later.  

  Consider how we can use the subroutine to solve the original
  problem.  Start with $c_0 = 1$ and try to compute $c_1$.  Set $c_1 =
  0$. Run the subroutine for all possible $v$.  If the subroutine says
  YES add one to $c_1$ and continue, if the subroutine
  says NO continue, if the subroutine says ? halt and reject.  The final
  value of $c_1$ after looping through all possible $v$'s is the
  number of vertices reachable from $u$ in one step.  Iterate this
  procedure to compute $c_{n-2}$.  Only the current and next values of
  $c_i$ need to be stored at any point in the computation.  Finally
  run the subroutine one last time with parameters
  ($G$,$u$,$n-1$,$c_{n-2}$,$v$), if the answer is NO, accept if the
  answer is ? or YES reject.   

  The entire computation only accepts if there exists a computation
  path that correctly tracks the counts and $v$ is not reachable from
  $u$.  If the last step says YES there was a path from $u$ to $v$.
  If the last step says ? the computation was inconsistent and it
  bails out by rejecting. 

  \subsection{Writing the Subroutine}
  
  The idea for the subroutine is simple: cycle through all the
  vertices and guess if they are reachable.  If the subroutines guess
  they are reachable it tries to verify they are reachable.  If a
  vertex is reachable, the subrountine modifies the count of reachable
  vertices seen so far then checks if $v$ is reachable in one
  additional step. The count must match the count passed in as a
  parameter to verify that $v$ was not reached. 
  
  \begin{algorithm}
    \algname{Subroutine}{$G$,$u$,$t$,$c_t$,$v$}
    \alginout{A graph $G$, a starting vertex $u$, a number of steps
    $t$, the number of vertices within $t$ steps of $u$ $c_t$, the
    destination vertex $v$}{YES if $v$ is reachable from $u$ in
    $\le t+1$ steps, NO if $v$ is not reachable from $u$ in $le t+1$
    steps, ? if the computation is not able to determine. If $c_t$ is
    correct at least one computation path will return the correct
    answer (not ?). }
  \begin{algtab}
    $c \leftarrow \emptyset$ \\
    \algforeach{$w \in V(G)$}
      Guess whether $w$ is reachable from $u$ in $\le t$ steps. \\
      \algif{Guessed yes}
        Verify guess by nondeterministically guessing a path from $u$ to
	$w$ in $\le t$ steps. \\
        \algif{Successfully verified}
	  \algif{$v$ can be reached from $w$ in one step}
	    \algreturn{YES} \\
	  \algelse
	    $c \leftarrow c+1$ \\
	  \algend
        \algelse 
	  \algreturn ? \\
	\algend
      \algend
    \algend
    \algif{$c = c_t$}
      \algreturn NO \\
    \algelse 
      \algreturn ? \\
    \algend
  \end{algtab}
  \end{algorithm}
  
\end{proof} 

The main point of this technique is that if the number of
positive instances (reachable vertices) is known guessing and
verifying positive instances will verify whether the count is correct.
Then the count can be used to check whether the instance in question
is a member of the positive set.  

\section{Next Time}

Next lecture we will discuss alternation as a generalization of the
hypothetical model of nondeterministic computation.  In particular
alternation captures all languages that can be specified with a fixed
number of quantifier alternations as a TQBF.

\end{document} 
