Modelcore
Nondeterministic Turing machine
Also called NTM.
Turing machine with multiple allowed transitions; accepts if some computation path accepts.
A nondeterministic Turing machine is a Turing machine whose transition function gives a set of possible moves, so a configuration can have several successors. It accepts an input when at least one of its computation paths reaches the accept state. Its running time is the length of its longest path. The class NP is the set of languages that such a machine decides in polynomial time, and the best known deterministic simulation takes time exponential in the running time. Whether this loss can be avoided is open, and it is the P versus NP question.
The machine
A nondeterministic machine has the same parts as the one-tape machine of the Turing machine page, except for the transition function. Its states include a start state , accept and reject. Its tape alphabet is , its input alphabet is , and
where is the power set. The set is finite and can be empty. Let , and assume . Configurations are as for the deterministic machine. We write when follows from by one move in . A configuration can have zero, one or up to successors.
A computation path on an input is a sequence with that stops at a halting configuration (state accept or reject) or at a configuration with no successor, or else goes on without end. The paths form a tree, the computation tree, whose root is and whose nodes have at most children.
Acceptance. accepts if some computation path on ends in a configuration with state accept. The language of is . The word is not in when no path accepts: every path then rejects, stops without a successor, or runs forever. decides if and every path on every input is finite. The rule is one-sided. A single accepting path is enough to accept, but all paths must fail to reject. The machine does not guess "correctly" in any physical sense. The definition says only that a good sequence of choices exists.
Example. Let be the set of words over whose third symbol from the right is . The machine below guesses the position of that . In state it scans right, and when it reads a it may either go on in or commit to this by entering . After the commit it reads two more symbols, then needs a blank. A pair that the table does not list has .
| State | Reads | Choices |
|---|---|---|
| or | ||
| or | ||
| or | ||
| (accept, , ) |
On the computation tree has three paths. The path that commits at the second symbol accepts after 5 steps. The two paths that stay in at the second symbol both stop without a successor after 4 steps. So accepts , and indeed the third symbol from the right is . On the only path stops after 4 steps, so rejects. Every path on a word of length has at most steps. So decides in time .
What it counts
The time of a path is its number of steps. runs in time if, for every input of length , every computation path has at most steps. In particular halts on every path. This is the measure of Sipser: the longest path of the tree, not the shortest accepting path. It is the measure of this page. For a function , is the set of languages that some nondeterministic multitape machine decides in time . The class is
The space of a path is the number of distinct cells that the head visits, and the space of is the largest over all paths. The cost of a run does not add the costs of the branches: the paths are alternative runs, not parallel work that you pay for.
A nondeterministic machine is not a probabilistic machine. It assigns no probability to its paths, and it has no error. It also does not model a real parallel computer, because the number of branches can be exponential in the time.
Relation to other models
Every deterministic machine is a nondeterministic machine with for all , so . The multitape version has the transition function . The one-tape simulation of the multitape Turing machine page carries over to the nondeterministic case: the machine makes its choice at the step where the deterministic simulation applies . So the polynomial-time classes do not depend on the number of tapes.
Theorem (deterministic simulation). Let be a nondeterministic machine that runs in time , where for all , and let . Then a deterministic multitape machine decides in time . A deterministic one-tape machine decides in time too. Hence .
Proof. Take with one tape and as above. Number the elements of each set as . A string is a list of choices. The run along starts in and does this for . If the configuration is halting or has (this includes ), the run stops. Else it makes move number of . The status of the run is accept if it stops in, or ends in, a configuration with state accept. It is alive if it makes all moves and the last configuration is not halting. Else it is dead.
The machine has three tapes: the input, a work tape on which it simulates , and a tape that holds the string . For in turn, and for each in lexicographic order, performs the run along . It copies the input to the work tape, then simulates the moves with the help of . Then it erases the work tape. If a run has status accept, accepts. After all strings of length , if no run was alive, rejects. Else it goes on with .
Correctness. Suppose accepts . Some accepting path has steps and a list of choices , and the run along has status accept. reaches level unless it accepts earlier. At each level it can reject only if no run is alive. A reject at level would mean that no run along a string of length is alive. But the first choices of the accepting path give a run of that length that makes all moves and is not halting, because . So that run is alive. Hence does not reject before level , and it accepts at level at the latest. Conversely, accepts only after a run of status accept, and that run is a real accepting path of . So accepts if and only if accepts , as long as halts.
Suppose does not accept . At level no run is alive: an alive run is a path of with steps whose last configuration is not halting, and no path has more than steps. So halts at level at the latest. It does not accept, because no run has status accept. It rejects.
Time. stops by level . The number of strings it tries is at most . For each string, spends steps to copy the input, steps to simulate the moves (each move is a constant number of steps), steps to erase the work tape, and steps to produce the next string. This is steps in all, since and . The total is , because is a constant and for . A one-tape machine simulates with a square of this time (the claim of the multitape page), and . A machine with more tapes is simulated in the same way, with steps for each of its moves.
Theorem (recognizers). For every nondeterministic machine there is a deterministic machine with . If every path of is finite on every input, can be made a decider.
Proof. Let be the machine of the proof above, with this change: it stops with accept when a run has status accept, and otherwise it goes on to level while some run is alive, and it rejects when a level has no alive run. If accepts , the argument above shows that accepts at level at the latest, even when other paths of run forever, because the search is by level and so is breadth first. If does not accept , then never accepts, and it either rejects or runs forever, so . Now suppose that every path of on is finite. The computation tree is finitely branching with no infinite path, so by König's lemma it is finite. Then it has some depth , and no run is alive at level , so halts. Hence decides .
The same simulation shows for , when the space counts the cells of all tapes. The work tape and the string have cells, and reuses them for each run. The Savitch theorem is a separate result about nondeterministic space.
Known results in the model
- NP. . A language is in NP if and only if there are polynomials (with natural-number coefficients) and a deterministic machine such that runs in time and . The string is a certificate, and is a verifier. The proof is below.
- Place of NP. , because a deterministic machine is a nondeterministic machine. By the theorem above, and . See P, PSPACE and EXPTIME. Whether is open.
- Complete problems. The Cook-Levin theorem shows that SAT is NP-complete. SAT is in NP because a machine can guess an assignment of the variables and check it in polynomial time.
- Acceptance is not symmetric. coNP is the class of complements of languages in NP. The definition gives no machine for it, because "no path accepts" is a universal statement. Whether is open.
Proof of the certificate characterization. Here is a polynomial with natural-number coefficients, and is a polynomial. Assume that . Let decide with every path of at most steps, where is a polynomial. Let be the machine that, on with coded in binary, runs on and uses as the choice at step . rejects if a choice is out of range, if ends before halts, or if halts in reject. accepts if reaches accept. The run takes steps on a multitape machine. If , an accepting path has at most steps, and its list of choices is a certificate of length . If accepts , the run is an accepting path of , so .
Conversely, assume that , and are as stated. Let be coded as , a separator symbol, then , and measure the time of in . Let work in three stages on an input of length . First it writes ones on a work tape. This is deterministic and takes time polynomial in , because is a fixed polynomial with natural-number coefficients. Second it writes a string on another tape, symbol by symbol. At each step it chooses among writing , writing and stopping, and it counts its symbols against the ones so that it stops after symbols at the latest. Third it simulates on the coded pair , which has length at most , and accepts if and only if accepts. Each path has polynomially many steps, because and the third stage takes at most simulated steps. A path accepts if and only if its string makes accept. So accepts if and only if some with makes accept, that is, if and only if . Hence .
References
- Michael Sipser, Introduction to the Theory of Computation, third edition, Section 3.2 (nondeterministic Turing machines) and Section 7.3 (the class NP)
- Sanjeev Arora and Boaz Barak, Computational Complexity: A Modern Approach, Chapter 2, Section 2.1 (the class NP), including Section 2.1.2 (nondeterministic Turing machines)
- Christos H. Papadimitriou, Computational Complexity, Addison-Wesley, 1994, Section 2.7 (nondeterministic machines)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag 8WWSGW Edit this page History Report an error Markdown JSON