Outline
- PSPACE-completeness
- Savitch's Theorem
- `NL=coNL`
Introduction
- Last day, we established the following relationships for space complexity classes:
`DTIME(s(n)) subseteq SPACE(s(n)) subseteq NSPACE(s(n)) subseteq DTIME(2^(O(s(n)))).`
`NTIME(s(n)) subseteq NSPACE(s(n))`.
- So `NL subseteq P`, and `NPSPACE subseteq EXP`.
- We also said the grade school algorithm shows `\M\U\L\T = {(x, y, i)| \mbox{the }i\mbox{th bit of }x\cdot y\mbox{ is }1 }` is in `L`.
- Today, we are going to examine the relationship between deterministic and nondeterministic space.
- To establish a relationship we will be considering the following problem:
`\P\A\T\H = {langle G, s,t rangle | G mbox( is a directed graph in which there is a path from s to t) }`.
- We will show this problem is in `NL`.
- Before we do this we will look at a complete problems for PSPACE and space hierarchy results.
Results with Familiar Proofs
Theorem. (Space Hierarchy Theorem) If `f`, `g` are space-constructible satisfying `f(n) = o(g(n))` then
`SPACE(f(n)) ne SPACE(g(n))`
The proof is similar to the time hierarchy proof.
Next consider the language:
`\S\P\A\C\E \T\M\S\A\T = { langle M, w, 1^t rangle | mbox(DTM M accepts w in space t)}`
It's not hard to verify that this problem is a canonical PSPACE complete problem.
Definition. A quantified boolean formula (QBF) is a formula of the form `Q_1x_1Q_2x_2 ... phi(x_1, ... x_n)` where
`Q_i` is one of `forall` or `exists` and `x_i`'s range over `{0, 1}`, and where `phi` is a plain Boolean formula.
Theorem. TQBF, the set of true QBF formulas is PSPACE-complete
Proof. The book has the full proof. It is easy to cycle over values `x_i` re-using space to see that the problem is in PSPACE.
To see it is PSPACE complete is a similar argument to Cook-Levin, given a PSPACE machine `M` and an input `x`, we express as a QBF formula
that `C_(a\c\c\ept)` is reachable from `C_(s\t\a\r\t)` in the corresponding configuration graph.
Savitch's Theorem
Theorem. (Savitch) PATH is in `\S\P\A\C\E(log^2 n)`.
Proof of Savitch's Theorem
- Let `G` be a graph with `n` nodes, let `x` and `y` be nodes of `G`,and let `i ge 0`. We say that the predicate `PATH(x,y,i)` holds if: there is a path from `x` to `y` in `G` of length at most `2^i`.
- We can compute reachability of any two nodes in `G` if we can determine if `PATH(x,y, |~log n~|)` holds.
- We are going to build a TM with two tapes beside the input tape.
- We will assume the input tape has the adjacency matrix for `G`.
- We will assume the first tape has already copied onto it, the nodes `x`, `y` and the integer `i` in binary. This tape will typically store several triples of which `(x,y,i)` will be the leftmost.
- The other tape is used as scratch space...
Proof of Savitch's Theorem cont'd
- We start with `i=0` and try to compute `PATH(x, y, 0)`. This involves checking whether `x=y` or whether then is a single edge in the adjacency matrix between `x` and `y`. Both of which can be done in log space.
- For `i > 0` we can compute `PATH(x,y,i)` with the recursive algorithm:
- For all nodes `z` test whether `PATH(x, z, i-1)` and `PATH(z, y, i-1)`.
- We can generate each `z` in turn reusing space and perform the test. As there are n nodes it takes at `|~log n~|` bits to store `z`. Once a `z` is generated we add `(x,z, i-1)` to the main work tape. If there is a `PATH(x,z,i)`, we replace `(x,z,i-1)` on the work tape with `(y,z,i-1)` and compute `PATH(y,z,i-1)`. If there is no such path we move on to the next `z`.
- Notice at any given time in computing `PATH(x,y, |~log n~|)` we have at most log n many triples on the work tape and that each triple takes at most `3 |~log n~|` to store. So this algorithm is in `\S\P\A\C\E(log^2 n)` as desired.
In Class Exercise
Label the vertices of a hexagon 1, ..., 6 in clockwise order. Explain how the algorithm of the last slide would determine if there was a path from 1 to 4 in the hexagon.
Post your answers to the Apr 5 In-class Exercise.
Corollaries
Corollary. `\N\S\P\A\C\E(f(n)) subseteq \S\P\A\C\E([f(n)]^2 )` for any space-constructible function `f(n) ge log n`.
Proof. Recall from last day that the configuration graph on inputs of length `n` for a machine `M` whose language is in `\N\S\P\A\C\E(f(n))` has size at most `log n + k cdot f(n)` for some `k` (the `\log n` is used to record the position on the read-only input tape). Whether an accepting configuration is reachable from the start configuration is an instance of PATH so can be solved in `\S\P\A\C\E((|~log (2^(O( log n + k cdot f(n)) ))~|)^2 ) = \S\P\A\C\E( [f(n)]^2 )`.
Corollary. `NPSPACE=PSPACE`.
Is L=NL?
- The square factor in the time bound for PATH prevents us from showing that `L=NL`.
- Nevertheless, Immerman-Szelepscenyi were able to show:
Theorem. Given a graph `G` and a node `x`, the number of nodes reachable from `x in G` can be computed by a nondeterminstic TM within `log n` space.
Proof of Immerman-Szelepscenyi
The algorithm has four nested loops:
- The outer loop computes iteratively `|S(1)|`, `|S(2)|`, ..., `|S(n-1)|` where `S(k)` is the set of nodes in `G` that can be reached from x by paths of length `k`. Thus, `|S(n-1)|` is the number we want to compute.
- The second loop uses `|S(k-1)|` to compute `|S(k)|`. Let `l` be the current count. At the start of this loop `l=0`. The second loop checks for each node reusing space `u=1`,..,`n` if `u` is in `S(k)` and if it is increments `l=l+1`.
- The third loop is used by the second loop in determining if `u` is in `S(k)`. It checks each node v reusing space if it is in `S(k-1)`. Let `m` be a counter of the number of such `v` so far. To see if `u` is in `S(k)` we check whether `u=v` or there is an edge from `v` to `u`, in which case we report true. If we reach the last `v` and `m < |S(k-1)|`, then we reply no on this nondeterministic computation branch. If `m=|S(k-1)|`, then we say `u` is not in `S(k)`.
- The fourth loop is used to say whether `v` is in `S(k-1)`. Looping given `x` we nondeterministically guess `k-1` nodes `u_i`, in turn, for each pair checking there is an edge between them. We check the last one is `v`.
Another Corollary
Corollary. If `f ge log n` is a space constructible function, then `NSPACE(f(n)) = coNSPACE(f(n))`.
Proof. Suppose `L` is in `NSPACE(f(n))`, decided by some `M`. We will show that `bar L` is decided by some nondeterministic machine `bar M`. On input `x`, `bar M` runs the algorithm of the last theorem on the configuration graph of `M` on `x`. If while running this algorithm `bar M` discovers an accepting computation of `u` is in `S(k)`, then it halts and rejects (it is deciding the complement). Otherwise, if `|S(n-1)|` is computed and no accepting computation has been encountered, `bar M` accepts.
Remark. We have PATH is in NL by the previous result. One can actually show PATH is NL-complete with respect to logspace reductions. (We'll talk about such reduction later). If you recall our deterministic algorithm for 2-SAT relied heavily of being able to check for paths in graphs. One can verify that this algorithm was in fact in NL. It turns out 2-SAT is also NL-complete under logspace reductions.