Department of Applied Physics and Information Science, University of California, San Diego, La Jolla, California 92037
Received August 29, 1969
The amount of storage needed to simulate a nondeterministic tape bounded Turing machine on a deterministic Turing machine is investigated. Results include the following: Theorem. A nondeterministic -tape bounded Turing machine can be simulated by a deterministic -tape bounded Turing machine, provided . Computations of nondeterministic machines are shown to correspond to threadings of certain mazes. This correspondence is used to produce a specific set, namely the set of all codings of threadable mazes, such that, if there is any set which distinguishes nondeterministic tape complexity classes from deterministic tape complexity classes, then this is one such set.
Introduction
A well-known open problem in the theory of formal languages and computational complexity is to decide whether or not there exists a nondeterministic context-sensitive language, that is, to decide whether or not there is a set which is accepted by a nondeterministic linear bounded automaton, but is accepted by no such deterministic machine. In this paper, we give some partial answers to a natural generalization of this problem. We attempt to answer the following question: "Given a nondeterministic tape bounded Turing machine which accepts a set , how much addition storage does a deterministic Turing machine require to recognize ?"
More specifically, we show that any nondeterministic -tape bounded Turing machine can be simulated by a deterministic -tape bounded Turing machine, provided . Thus, in particular, every context-sensitive language can be recognized within deterministic storage , where is the length of the input. As a corollary of the proof of this theorem, we get that if a context-sensitive language is
- This work is based on a portion of the author's doctoral dissertation in the Department of Mathematics of the University of California, Berkeley. Most of the results were announced in [9]. Part of this research was done while the author was a National Science Foundation Graduate Fellow.
accepted by a nondeterministic linear bounded automaton within polynomial time, then the language is accepted by a deterministic Turing machine within storage . It is also shown that if nondeterministic and deterministic tape complexity classes are equal for "small" functions, then they are equal for "large" functions.
The notion of a maze is formalized and computations of nondeterministic machines are related to threadings of certain mazes. This relation is used to obtain a specific set, namely the set of codings of threadable mazes, such that, if there is any set which distinguishes nondeterministic tape complexity classes from deterministic tape complexity classes, then this is one such set. That is, there is a nondeterministic Turing machine which accepts the codings of threadable mazes within storage . Also, if there is a deterministic Turing machine which accepts them within the same storage, , then, for every storage function , any nondeterministic -tape bounded Turing machine can be stimulated by a deterministic -tape bounded Turing machine.
Machine Model
The device studied in this paper is the multitape Turing Machine. In the terminology of [3], it is a Turing machine with finitely many two-way infinite storage tapes and a read only input tape provided with end markers. We shall give only an informal definition of the device. A multitape Turing machine (hereafter called simply Turing machine) is a finite state control attached to a read only input tape and finitely many read/write storage tapes. The tapes are divided into squares. Each square of a storage tape is capable of holding one symbol from the finite storage tape alphabet . The input tape will always contain a finite string of symbols from the finite input alphabet . The string is separated by two symbols not in called left and right end markers. Each tape has one head communicating with the finite control.
At any point in time, each head will scan one square on its tape and the control will be in one state. Depending on this state and the symbols scanned by the heads, the machine will, in one step, assume another state, overwrite a symbol on the scanned square of each of its storage tapes, and then shift some of its heads (including possibly the input head) either left or right one square. The finite control is designed so that the input head will never leave the segment of tape containing and the end markers. The machine is said to be deterministic if there is only one possible action at each step. It is said to be nondeterministic if there are finitely many possible actions at each step.
Some states are distinguished and called accepting states and one state is distinguished and called the initial state. We say the deterministic machine accepts the input string over if enters an accepting state after finitely many steps, when started in the initial state, with all storage tapes blank, on its input tape and its input head scanning the left end marker. The definition is the same in the case is nondeterministic except that we merely require that there be a possible finite sequence of steps leading to an accepting state, starting from the initial configuration described above.
Definition. Suppose is a function on the natural numbers, is a Turing machine (deterministic or nondeterministic), and is a set of strings over the input alphabet of . is said to accept the set within storage provided that
(i) for each string in , there is at least one possible computation of which accepts and in which each storage tape head scans at most squares, and
(ii) accepts no string not in . is the length of the string, .
In this paper we are considering only the growth rates of storage functions. That is, for our purposes, the storage functions and are the same, for any constant . This identification of functions follows from the fact that our Turing machines are allowed arbitrary finite storage tape alphabets. Thus, any Turing machine which operates in storage can be modified to operate in storage and still accept the same set of tapes. (See, for example, [3].) We assume the reader is familiar with such tape reduction techniques.
In what follows, it will sometimes be convenient to assume that the storage functions are "nice". The niceness condition we want is that the functions be measurable [4].
Definition. A function is said to be measurable if there is some Turing machine with just one storage tape such that, given any input of length , the machine will halt after a computation in which the storage tape head scans exactly squares.
Apparently, all common storage functions are measurable. In particular, any polynomial in and is measurable.
Deterministic Simulation of Nondeterministic Turing Machines
Theorem 1. If a set, , is accepted by a nondeterministic Turing machine, , within storage , then is accepted by some deterministic Turing machine, , within storage .
Proof. The theorem is proved by exhibiting an algorithm whereby can simulate the computations of . The algorithm is similar to that used by Lewis, Stearns, and Hartmanis [7] to show that every context-free language is accepted by a deterministic Turing machine within storage .
Suppose the Turing machine has storage tapes, storage tape alphabet , and internal state set . Let , where and are two new symbols. An instantaneous description (ID) of is a string over of the form pq u₁ ↓ v₁ u₂ ↓ v₂ ... uₖ ↓ vₖ, where p is a number in dyadic notation¹ indicating the position of the input head of , q is an element of Q indicating that the finite control of is in state q, and are elements of , . is interpreted to mean that is the contents of the ith storage tape of and the head on this tape is scanning the first symbol of string . Thus, except for the contents of the input tape, an ID of is a complete description of a configuration of .
Since accepts the set within storage , it follows that for each string w of length n accepted by , there is a computation of accepting w in which every ID has length not exceeding . Furthermore, since each ID is of length at most , the computation need take no more than steps. c and are constants depending only on and not on the input w.
We first give the algorithm for the case: is measurable.
Given an input of length n, initializes its computation by dividing one of its storage tapes into blocks (called registers), each of length , followed by blocks (called tags), each capable of storing either 0 or 1. This it can easily do if is measurable. [y] is the largest integer not exceeding y. Note that each register is capable of holding any ID of in which the nonblank portion of every storage tape is at most . has a second storage tape for scratch work.
The idea of the algorithm is as follows. has the string w as input. In the course of the algorithm, will consider two ID's I, stored in particular registers. For a prechosen m, it will need to check if, with input w, can in steps change its configuration from I to . Furthermore, will have to perform this task using only m registers. proceeds as follows. It runs through (in a systematic way) all ID's of and for each , checks to see if there is a computation of at most steps from I to , and a computation of at most steps from to . needs one register to keep track of the , leaving it with registers. So has reduced the task of simulating moves of using m registers to simulating moves of using registers. then reduces each computation of steps to two computations of steps. continues to reduce the length of the computations it need check until it need only check, for appropriate ID's and , whether, with input w, can in one step go from to . This it can easily do using zero storage. Now if there is any accepting computation of , then there is one which accepts in steps. So can simulate this computation using registers or about squares of storage tape.
We now define some notation for a formal statement of the algorithm. Since ID's are strings over a finite alphabet, , they may be considered to be integers in m-adic notation, where m is the number of symbols in . More precisely, if then the string will represent the number . We will not distinguish between a string and the number it represents.
¹ The string over the alphabet {1, 2} is the dyadic representation of the number .
DEFINITION. If and are ID's of and if can in one step, with input , pass from configuration to configuration , or if , then we will write . In the algorithm we will test if is true for arbitrary strings over . If either or is not an ID of , then the test fails.
In the following algorithm, denotes the contents of the -th register and denotes the contents of the -th tag . has a string as input and all references to computations of mean computations of under the input and in which the nonblank portion of each work tape remains at most squares long. At any point in the computation of , if , then there is a computation of from the start ID to .
ALGORITHM FOR MACHINE
Summary of Notation
is the input string. is the length of . is the least integer such that . is such that, with as input, if accepts at all, then accepts in steps. is the initial ID of . is the largest integer whose -adic representation can be stored in a register. is the contents of the -th register. is the contents of the -th tag.
D0 (Initialize). Compute and set up the registers and tags. For set and . Set (the initial ID) and .
D1 (Test). If each , go to D3. Otherwise, let be the smallest index such that . Test: For some index , and . Yes: Go to D2. No: Go to D3.
D2 (Clear Storage) ( as in D1). If is an accepting ID, ACCEPT. Otherwise, set and for set and . Go to D1.
D3 (Back Track). If for each , REJECT. Otherwise, let be the smallest index such that . Set , , and for set , . Go to D1.
Clearly the algorithm works within storage , where is a constant depending only on . By standard techniques [3] the constant can be reduced to one. A simple induction on the number of steps completed shows that if accepts an input , then the nondeterministic machine does. Thus, it will suffice to show that accepts all strings that accepts. To show this, we need some preliminary lemmas. The lemmas are easier to state in case the machine does not stop when it accepts. So assume D2 (Clear Storage) has been modified to omit the first line ("If is an accepting ID, ACCEPT"). We shall say is in configuration
if it is about to execute D1, and the contents of the registers and tags are, respectively, and .
Lemma 1. (For modified D2). For each index and each integer () if at some time in a computation of the configuration of is
for some and some , then at some later time the configuration will be
or
where is the least index in (1) such that and . (If no such exists, then (2) happens.)
The algorithm is trying to establish that there is a computation of from the start ID to . It is trying to do this using only registers to the left of . So the lemma says that can get any ID into any register, if it needs to.
Proof. A formal proof would use induction on and . We list some representative configurations in a computation. This should make the lemma clear. Note that since is a string all of whose digits are the same, is not an ID and, hence, is not true for any integer . Suppose is started in configuration (1) and that at no later time does assume configurations (3). will then assume the following configurations:
where or 1.
Finally, via D3, assumes (2) as desired.
Lemma 2. (For modified D2). Suppose that at some time in a computation the configuration of is
with and any values for the 's and remaining 's. If for some index and there is a computation of of at most steps from to , then at some later time the configuration of will be (4) with .
The lemma says that registers are sufficient for to check a computation of steps of .
Lemma 3. (For modified D2). Suppose that at some time in a computation the configuration of is
for any values of the 's and 's. If for some index and there is a computation of of at most steps from to , then at some later time the configuration of will be
Proof of Both Lemmas. Lemmas 2 and 3 are basically a single lemma and are proven simultaneously by induction on . The base case, , is clear. Assume both lemmas hold with replaced by . We will show that Lemma 2 holds for .
Suppose is in configuration (4) with and that for some index, , there is a computation of from to of at most steps. Decomposing this computation from to , we get that there is a such that there are computations of at most steps from to and from to . By Lemma 1, it follows that, at some later time, either the configuration of is
with or the configuration is (4) with . Configuration (4) with is the desired outcome. So assume assumed configuration (7) with . By induction hypothesis on Lemma 2, it follows that at some still later time the configuration of will be (7) with . If we then apply the induction hypothesis on Lemma 3, we get that at a still later time the configuration of will be (4) with . So Lemma 2 holds for . Lemma 3 for is established in a similar fashion. Thus, the induction hypothesis is established and the proof of both lemmas is completed.
Using Lemmas 1 and 2 it is easy to complete the proof of the theorem. Suppose the nondeterministic machine accepts . We must show that accepts . Since accepts , there is an accepting ID, , of such that there is a computation, with as input, of at most steps from (the initial ID of ) to . By Lemma 1, it follows that eventually assumes configuration
with . By Lemma 2, it follows that at some later time will assume configuration (8) with . All this was for the modified D2. The unmodified D2 will accept rather than set . This completes the proof of Theorem 1 in the case: is measurable.
If is not measurable, then the above algorithm must be altered, since cannot necessarily mark off blocks of length within storage proportionate to . However, if were somehow given the value of , then by the above procedure, could determine whether or not accepts the input within storage . So operates as follows. first assumes . If accepts within storage , then will accept. If does not accept within storage 1, then next assumes . If accepts within storage 2, then accepts. If not, then next assumes . proceeds in this manner trying larger and larger values for . If accepts the input , then will eventually find the correct value for and accept within storage proportionate to . If does not accept , then computes forever on input . This completes the proof of Theorem 1.
The context-sensitive languages are precisely those sets accepted by nondeterministic Turing machines within storage (see, for example, [3]). So, setting in Theorem 1, we get,
Corollary 1. Every context-sensitive language is accepted by some deterministic Turing machine within storage .
Theorem 1 can be generalized as follows.
Theorem 2. If a set, , is accepted by a nondeterministic Turing machine within storage and time , then is accepted by some deterministic Turing machine within storage .
Definition. A Turing machine, , is said to accept a set, , within storage and time provided that
(i) for each in , there is at least one computation of which accepts , takes at most steps, and in which each work tape head scans at most squares, where is the length of , and provided that
(ii) accepts no string not in .
Proof of Theorem 2. An analysis of the proof of Theorem 1 shows that the algorithm uses a bound on the storage of the nondeterministic machine to obtain a bound, namely exponential in the storage, on the time of the nondeterministic machine. It then marks off blocks of storage, where is a bound on the time. Clearly, if the time bound were easy to compute, the algorithm could be modified to use it as the bound on the time. We would then get Theorem 2. If the time function is not easy to compute, then we use the same sort of trick as that used for nonmeasurable functions in the proof of Theorem 1.
Corollary 2. If a context-sensitive language is accepted by a nondeterministic Turing machine within linear storage and polynomial time, then it is accepted by some deterministic Turing machine within storage .
The following theorem says that for any "well behaved" storage function , if every nondeterministic -tape bounded Turing machine can be simulated by a deterministic -tape bounded Turing machine, then for all larger storage functions nondeterministic and deterministic tape complexities are the same.
THEOREM 3. Suppose that and are measurable, that is monotone increasing and unbounded and that , for all . Let the function be defined as follows. For each natural number , is the least natural number such that .
Suppose further that for any set, , if is accepted by a nondeterministic Turing machine within storage , then is accepted by a deterministic Turing machine within storage . It then follows that for any set, , if is accepted by a nondeterministic Turing machine within storage , then is accepted by a deterministic Turing machine within storage .
The theorem is a bit stronger than it seems. For most common storage functions, , there is a constant such that , for all and . Thus, in these cases, the conclusion can be strengthened to say that any set accepted within nondeterministic storage can be accepted within deterministic storage . In particular,
COROLLARY 3. Suppose is a polynomial in and , for some constant . Suppose further that for any set, , if is accepted by a nondeterministic Turing machine within storage , then is accepted by some deterministic Turing machine within storage .
It then follows that for any measurable function and any set, , if is accepted by a nondeterministic Turing machine within storage , then is accepted by some deterministic Turing machine within storage .
Among other things, the corollary says that if every context-sensitive language is accepted by a deterministic linear bounded automaton (i.e., deterministic Turing machine with storage bound ), then nondeterministic and deterministic tape complexities are the same for all measurable tape bounds .
Proof of Corollary 3. It is easy to check that for any such polynomial , there is a constant such that for all . So . is the function defined in the statement of the theorem. By definition of , . So .
Assume the hypothesis of the corollary and suppose is accepted by a nondeterministic Turing machine within storage . By the Theorem 3, is accepted by a deterministic Turing machine within storage . So, by standard tape reduction techniques [3], it follows that is accepted by a deterministic Turing machine within storage . Finally, since , this means that is accepted by a deterministic Turing machine within storage .
Proof of Theorem 3. Assume the hypothesis of the Theorem 3 and suppose is a set accepted by a nondeterministic Turing machine, , within storage .
We will construct a deterministic machine, , which accepts within storage .
Let be a new symbol. Let . A nondeterministic Turing machine, , which accepts within storage can be constructed as follows. Given input , first marks off squares of storage, where . It then checks to see if . If this is not the case, then and the computation halts. If , then mimics to see if is in . If accepts, then it does. Since , this machine will accept within storage . So, by hypothesis, there is a deterministic machine, , which accepts within storage . Furthermore, since is measurable, we may assume that on every input of length , halts after a computation in which at most squares of storage tape are scanned. (Our definitions merely require this when the machine accepts the input.)
The deterministic machine, , which accepts within storage operates as follows. Given an input , mimics operating on for various values of . It first tries . If accepts , then does. If not, it then tries . If accepts , then does. If not, it then tries . If accepts , the does. If not, it then tries , and so forth. If is in , then will eventually find the least such that and will accept within storage . This completes the proof of Theorem 3.
It is natural to ask if there is any storage function whose deterministic and nondeterministic complexity classes are equal. The answer was given by Manuel Blum and is "yes". Blum showed that there are arbitrarily large storage functions such that a set is accepted within deterministic storage if, and only if, it is accepted within nondeterministic storage . These functions are not, however, "well-behaved" and Theorem 3 does not apply to them. They are not measurable. A sketch of the proof of Blum's result appears in [8].
One may also ask if there is a storage function (large enough to be interesting) whose deterministic and nondeterministic complexity classes are different. The next section is devoted to this question. Only an incomplete answer is given, however, and the question is open.
Mazes and Turing Machines
Informally, a maze is a set of rooms connected by one-way corridors. Certain rooms are designated goal rooms and one room is designated the start room. Thus, a maze is a directed graph with certain nodes or rooms distinguished. The maze is threadable if there is a path from the start room to some goal room.
A nondeterministic Turing machine, with input , gives rise in a natural way to a maze. The rooms of the maze are the instantaneous descriptions of the machine and the corridors are given by the transition function of the machine. That is there is a corridor from room to room if, with input , the machine can in one step change its configuration from to . The initial instantaneous description of the machine is designated the start room. Those instantaneous descriptions which include an accepting state are designated goal rooms. The machine will accept the input if, and only if, the corresponding maze is threadable.
The algorithm for simulating a nondeterministic Turing machine, given in the last section, is really an efficient method for determining whether the corresponding maze is threadable. In this section we show that if an efficient enough method for "threading" mazes could be found, then deterministic machines could simulate nondeterministic machines in the same storage. More precisely, the set of threadable mazes, suitably coded, can be recognized by a nondeterministic Turing machine within storage . This set can be recognized by some deterministic Turing machine within storage if, and only if, deterministic -tape bounded Turing machines can simulate nondeterministic -tape bounded Turing machines, for all .
Definition. A maze over (a finite alphabet) is a quadruple, , where is a finite set of strings over ( is the set of rooms), is a binary relation on (giving the corridors), is an element of ( is the start room), and is a subset of ( is the set of goal rooms).
Definition. The maze is threadable if there is a sequence of rooms such that (the start room), is an element of (the goal rooms), and holds for .
Definition. Let ], [,* be three new symbols. A coding of the maze is a string of the form
where is the start room of ; is an enumeration without repetitions of the rooms in ; for , is an enumeration without repetitions of all in such that holds; and is an enumeration without repetitions of the rooms in .
Notation. denotes the set of all codings of threadable mazes over .
Theorem 4. For any finite alphabet , there is a nondeterministic Turing machine which accepts within storage .
Proof. If the maze has length , then it has at most rooms. So each room can be coded by a number which can be stored in squares of tape. More specifically, if the maze is given by (1), then the room is coded by the number in dyadic notation. The algorithm is very simple. The machine writes down the code number of the initial room on its work tape, finds the possible next rooms, guesses at one of them, erases its work tape, and writes down a coding of its guess. It then finds the possible next rooms, guesses at one of them and so forth. After each guess it checks to see if it has reached a goal room. If it has, it accepts. Clearly the work tape will be bounded by , for some constant .
A straight forward crossing sequence argument, like that of Cobham [2] shows that the bound, in Theorem 4, is the best possible, up to a constant factor.
Applying Theorems 1 and 4 to yields
Corollary 4. For any finite alphabet , there is a deterministic Turing machine which accepts within storage .
Lemma 4. For any finite alphabets and with at least two elements, is accepted by some deterministic Turing machine within storage if, and only if, is.
Proof. For every coding, , of a maze over , there is a coding, , of a maze over which is isomorphic to . So is in if, and only if, is in . More specifically, if is
then may be taken to be
where if is the number of symbols in , then is the -adic representation of the number and so is an element of . Since the 's and 's and are each equal to some , this defines on them as well.
Given a deterministic machine, , which accepts within storage , we construct a deterministic machine, , which accepts within storage , as follows. Given an input , operates by mimicking operating in . More specifically, suppose has input as in (1). When is simulating with the input head of someplace in , where is some or in (1), then will have its input head reading the first symbol of and will have written on an auxiliary storage tape. uses this auxiliary storage tape containing to mimic the input tape of . When, in the mimicking process, the input head of would leave the left (respectively, right) end of , then moves its input head to the or to the left (respectively, right) of , calculates of this or and replaces by of this or . of this or becomes the new and the simulation continues. To calculate the new , need only compare the new to each until it finds the which equals . This it can do symbol by symbol and, thus, keep the amount of storage tape used less than , for some constant .
Since and are symmetric in the statement of the lemma, this is sufficient to prove the lemma.
Theorem 5. For any finite alphabet, , with at least two elements, the following statements are equivalent:
(1) is accepted by some deterministic Turing machine within storage .
(2) For any finite alphabet , any set, , of strings over and any function , if is accepted by a nondeterministic Turing machine within storage , then is accepted by some deterministic Turing machine within storage .
Proof. Statement (1) follows from statement (2) by Theorem 4.
Assume (1) holds and that is a set accepted by some nondeterministic Turing machine, , within storage . We will construct a deterministic machine, , which accepts within the same storage bound . Assume is measurable. We will later indicate how this restriction may be eliminated. With each string over the input alphabet of associate the maze , where is the set of all ID's of in which the nonblank portion of each work tape has length at most , is the start ID of , is the set of ID's in which include an accepting state, and is defined by: holds if, and only if, . Clearly, accepts if, and only if, is threadable. Let denote a coding of the maze . The deterministic machine which accepts operates as follows. Given an input , constructs on one of its storage tapes, and then simulates the machine of statement (1) to determine whether is in . If it is, then accepts . By Lemma 4, we may assume is large enough so that all ID's of are strings over . So is in if, and only if, accepts . Thus, accepts precisely the set . is of the length at most , where and is a constant depending only on . Except for the tape used to store , operates in storage which is proportionate to .
The machine cannot write down the entire string, , at once and still work within the allotted storage. However, all that is necessary in order to simulate the machine of statement (1) is that be able to compute one symbol at a time of the string and keep track of the symbols position in . This it could do provided it could, within storage , generate , from right to left, one symbol at a time.
Our remarks so far applied to any coding of the maze . We now fix to be the following coding of the maze
where for each , and is the usual "less than" ordering on the natural numbers. Recall that the 's, 's, and 's are strings over a finite alphabet and, thus, may be regarded as numbers in -adic notation, for some . By definition of , the 's, 's, 's, and are ID's of of length less than , where is a constant depending only on . can generate symbol by symbol, in the allotted storage, as follows. can easily calculate , the initial ID of . Having generated , next runs through in numerical order, all strings of length less than until if finds one which is an ID of . This will be . So has generated . Next it produces all such that . In this way, it generates the . Next it runs through, in numerical order, all strings of length less than until it finds the first such string which is an ID of and is greater than . This is . It now may erase . The only thing it need keep in storage at this point is . then proceeds to generate the . It generates from in the same way it computed from . It proceeds in this way until it finds the largest . Having generated the largest and its associated 's, it then generates the 's as follows. It runs through all strings of length at most and checks to see which are ID's which include an accepting state. Those that do are the . This completes the generating process and the proof for the case: is measurable.
If is not measurable, then cannot necessarily generate precisely the strings of length less than within storage proportionate to and so the above procedure will not work. However, if were somehow given the value of , then by the above procedure it could determine whether or not is accepted by within storage . uses the same sort of trick as was used for nonmeasurable functions in the proof of Theorem 1. That is, first it assumes . If accepts the input within storage , then accepts . If not, next tries . If accepts within storage , then does. If not, tries next, and so forth. If accepts the input , then will eventually find the correct value for and accept within storage proportionate to .
An unsolved problem in the theory of tape complexity is whether there is some set of strings and some function such that is accepted by some nondeterministic Turing machine within storage but accepted by no deterministic Turing machine within storage . Theorem 5 shows that if any such and exist, then and will do.
SAVITCH
Acknowledgments
The author thanks Stephen A. Cook for his help and encouragement in this work.