February 22, 2008 * L and NL * Logspace Reductions * PATH is NL-complete LOGSPACE CLASSES L = SPACE(log(n)) NL = NSPACE(log(n)) By theorems we have shown earlier, we know: L subset of NL = co-NL subset of P subset of NP subset of PSPACE The directed s-t Connectivity problem has an important role in space complexity. We have already seen its significance in various simulation proofs, including Savitch's Theorem. PATH = {: G is a directed graph that has a directed path from s to t} Theorem: PATH is in NL. Proof: We nondeterministically guess the path from s to t and check each hop of the path. In order to check a hop, we need to write the tail and head of the hop, each of which takes O(log(n)) space. End Proof LOGSPACE REDUCTIONS Definition: A log space transducer is a TM with a read-only input tape, a write-only input tape, and a read/write work tape. On an input of length n, the work tape may contain O(log n) input symbols. A log space transducer M computes a function f: Sigma^* -> Sigma^* where f(w) is the string remaining on the output tape after M halts. We also assume that M halts on all inputs and that the head on the output tape goes left to right only. Note that the output of a log space transducer is polynomial in the input length. Why? First, the running time is polynomial. Why? Because there are only a polynomial number of configurations. In any step, it can only write one output symbol, so the size of the output is polynomial in the input. Definition: Language A <=L B, if there exists a log space transducer f such that w is in A iff f(w) is in B. Definition: A language B is NL-complete if (a) B is in NL, and (b) A <=L B for all A in NL. Theorem: If A <=L B and B is in L, then A is in L. Proof: Let us recall the proof of the analogous theorem for P. If A <=P B and B is in P, then a poly-time DTM for A is to simply first use the reduction TM to map given w to f(w) and then run the TM for B on f(w). Let us try doing the same here. The problem we have here is that while a poly-time reduction TM is simply poly-time, a log space transducer could have an output that is larger than log space. Instead our TM for A will keep track of individual symbols of f(w) and pass them to the TM for B as needed. More precisely, the TM for A simulates the TM for B and passes it a symbol of f(w) on a need to do basis. Whenever the TM for B needs the ith symbol from f(w), the TM for A runs the logspace transducer for f long enough to compute the ith symbol of f(w). Note that since the length of f(w) is polynomial in |w|, the space in the worktape used for simulating the TM for B is also O(log(n))). End Proof PATH IS NL-COMPLETE Theorem: PATH is <=L-complete for NL. Proof: We have already shown that PATH is in NL. We next show that every language in NL has a logspace reduction to PATH. Consider a language in NL that is decided by a nondeterministic Turing machine M running in logspace. Given an input w, we would like to construct f(w) using a logspace transducer such that M accepts w iff f(w) is in PATH. What should f(w) look like? It is a s-t connectivity problem. A natural choice is to set up the configuration graph and ask whether the start config is connected to the accept config. Since M is a logspace machine, there are |w|^k configurations of M, each requiring O(log(|w|)) space. Note that the output f(w) is polynomial in |w|, not logarithmic, but that's ok, as long as we compute f(w) with only logarithmic worktape. Without loss of generality, assume that M has a unique accept configuration. We lexicographically go through all strings of length O(log(|w|)), checking whether each one could be a valid configuration of M. If it is, we write it out on the output tape. This gives the nodes in the graph of f(w). For the edges, we go through each configuration again, check whether it is valid, and if so, write out all the possible configurations it can yield in one step (by looking at the transition function of M). Finally, we write down the start configuration and the accept configuration to the input tape. Clearly, f is computable by a logspace transducer and M accepts w iff there is a path from the start config to the accept config. End Proof