6.3
General results on nondeterministic complexity
classes
The following simple relations connect the nondeterministic time- and space complexity classes:
Theorem 6.3.1 Let f be a well-computable function. Then
• NTIME(f(n))⊆DSPACE(f(n)) • NSPACE(f(n))⊆Sc>0DTIME(2cf(n)).
6.3. GENERAL RESULTS ON NONDETERMINISTIC COMPLEXITY CLASSES 93 Proof.
6.3.1: The essence of the construction is that all legal computations of a nondeterministic Turing machine can be tried out one after the other using only as much space as needed for one such legal computation; above this, we need some extra space to keep track of where we are in the trieout of of the cases.
More exactly, this can be described as follows: LetT be a non-deterministic Turing ma- chine recognizing language L in time f(n). As mentioned, we can assume that all legal computations ofT take at mostf(n) steps wherenis the length of the input. Let us modify the work ofT in such a way that (for some inputx) it will choose first always the lexicograph- ically first action (we fix some ordering of Σ and Γ, this makes the actions lexicographically ordered). We give the new (deterministic) machine called S an extra “bookkeeping” tape on which it writes up which legal action it has chosen. If the present legal computation of
T does not end with the acceptance ofxthen machine S must not stop but must look up, on its bookkeeping tape, the last action (say, this is the j-th one) which it can change to a lexicographically larger legal one. Let it perform a legal computation ofT in such a way that up to thej-th step it performs the steps recorded on the bookkeeping tape, in thej-th step it performs the lexicographically next legal action, and after it, the lexicographically first one (and, of course, it rewrites the bookkeeping tape accordingly).
The modified, deterministic Turing machine S tries out all legal computations of the original machine T and uses only as much storage as the original machine (which is at most
f(n)), plus the space used on the bookkeeping tape (which is again onlyO(f(n))).
6.3.1: Let T = hk,Σ,Γ,Φi be a non-deterministic Turing machine recognizing L with storage f(n). We can assume that T has only one tape. We want to try out all legal computations ofT. Some care is needed since a legal computation of T can last as long as 2f(n)steps, so there can even be 22f(n)
legal computations; we do not have time for checking this many computations.
To better organize the checking, we illustrate the situation by a graph as follows. Let us fix the length n of the inputs. By configuration of the machine, we understand a triple (g, p, h) whereg ∈ Γ, −f(n)≤p≤f(n) and h∈Σ2f(n)+1. The stateg is the state of the
control unit at the given moment, the number psays where is the head and hspecifies the symbols on the tape (since we are interested in computations whose storage need is at most
f(n) it is sufficient to consider 2f(n) + 1 cells). It can be seen that number of configurations is at most |Γ|(2f(n) + 1)m2f(n)+1= 2O(f(n)). Every configuration can be coded by a word
of lengthO(f(n)) over Σ.
Prepare a directed graphGwhose vertices are the configurations; we draw an edge from vertex u to vertex v if the machine has a legal action leading from configurationu to con- figurationv. Add a vertex v0 and draw an edge tov0 from every configuration in which the
machine is in state STOP and has 1 on cell 0 of its tape. Denoteuxthe starting configuration
corresponding to input x. Wordx is in L if and only if in this directed graph, a directed path leads fromux tov0.
On the RAM, we can construct the graphGin time 2O(f(n))and (e.g. using breadth-first
search) we can decide in timeO(|V(G)|) = 2O(f(n))whether it contains a directed path from
uxto v0. Since the RAM can be simulated by Turing machines in quadratic time, the time
bound remains 2O(f(n)) also on the Turing machine. ¤
The following interesting theorem shows that the storage requirement is not essentially decreased if we allow non-deterministic Turing machines.
Theorem 6.3.2 (Savitch’s Theorem) If f(n) is a well-computable function and f(n)≥ lognthen
NSPACE(f(n))⊆DSPACE(f(n)2).
Proof. Let T = h1,Σ,Γ,Φi be a non-deterministic Turing machine recognizing L with storage f(n). Let us fix the length n of inputs. Consider the above graphG; we want to decide whether it contains a directed path leading fromuxto v0. Now, of course, we do not
want to construct this whole graph since it is very big. We will therefore view it as given by a certain “oracle”. Here, this means that about any two vertices, we can decide in a single step whether they are connected by an edge. More exactly, this can be formulated as follows. Let us extend the definition of Turing machines. An Turing machine with oracle (for G) is a special kind of machine with three extra tapes reserved for the “oracle”. The machine has a special state ORACLE. When it is in this state then in a single step, it writes onto the third oracle-tape a 1 or 0 depending on whether the words written onto the first and second oracle tapes are names of graph vertices (configurations) connected by an edge, and enters the state START. In every other state, it behaves like an ordinary Turing machine. When the machine enters the state ORACLE we say itasks a question from the oracle. The question is, of course, given by the pair of strings written onto the first two oracle tapes, and the answer comes on the third one.
Lemma 6.3.3 Suppose that a directed graph G is given on the set of of words of length t. Then there is a Turing machine with an oracle forGwhich for given verticesu, vand natural numberq decides, using storage at most O(qt), whether there is a path of length at most2q
fromutov.
Proof. The Turing machine to be constructed will have two tapes besides the three oracle- tapes. At start, the first tape contains the pair (u, q), the second one the pair (v, q). The
6.3. GENERAL RESULTS ON NONDETERMINISTIC COMPLEXITY CLASSES 95 work of the machine proceeds in stages. At the beginning of some intermediate stage, both tapes will contain a few pairs (x, r) wherexis the name of a vertex andt ≤q is a natural number.
Let (x, r) and (y, s) be the last pair on the two tapes. In the present stage, the machine asks the question wether there is a path of length at most min{2r,2s} from x to y. If
min{r, s}= 0 then the answer can be read off immediately from an oracle-tape. If min{r, s} ≥ 1 then letm= min{r, s}−1. We write a pair (w, m) to the end of the first tape and determine recursively whether there is a path of length at most 2m from w to y. If there is one then
we write (w, m) to the end of the second tape, erase it from the end of the first tape and determine whether there is a path of length at most 2mfromxtow. If there is one then we
erase (w, m) from the end of the second tape: we know that there is a path of length at most min{2r,2s} fromxtoy. If there is no path of length at most 2meither betweenxandwor
betweenw andy then we try the lexicographically nextw. If we have tried allw’s then we know that there is no path of length min{2r,2s} betweenxandy.
It is easy to see that the second elements of the pairs are decreasing from left to right on both tapes, so at most qpairs will ever get on each tape. One pair requiresO(t+ logq) symbols. The storage thus used is onlyO(qlogq+qt). This finishes the proof of the lemma. ¤
Returning to the proof of the theorem, note that the question whether there is an edge between two vertices of the graph G can be decided easily without the help of additional storage; we might as well consider this decision as an oracle. The Lemma is therefore ap- plicable with values t, q = O(f(n)), and we obtain that it can be decided with at most
tq+qlogq=O(f(n)2) storage whether from a given vertexu
xthere is a directed path into
v0, i.e. whether the word xis inL. ¤
As we noted, the class PSPACE of languages decidable on a deterministic Turing machine in polynomial storage is very important. It seems natural to introduce the class NPSPACE which is the class of languages recognizable on a non-deterministic Turing machine with polynomial storage. But the following corrollary of Savitch’s theorem shows that this would not lead to any new notion: