In computational complexity theory, the time hierarchy theorems are important statements about time-bounded computation on Turing machines. Informally, these theorems say that given more time, a Turing machine can solve more problems. For example, there are problems that can be solved with n2 time but not n time, where n is the input length.
The time hierarchy theorem for deterministic multi-tape Turing machines was first proven by Richard E. Stearns and Juris Hartmanis in 1965.[1] It was improved a year later when F. C. Hennie and Richard E. Stearns improved the efficiency of the Universal Turing machine.[2] Consequent to the theorem, for every deterministic time-bounded complexity class, there is a strictly larger time-bounded complexity class, and so the time-bounded hierarchy of complexity classes does not completely collapse. More precisely, the time hierarchy theorem for deterministic Turing machines states that for all time-constructible functions f(n),
DTIME\left(o\left(f(n)\right)\right)\subsetneqDTIME(f(n){logf(n)})
In particular, this shows that
DTIME(na)\subsetneqDTIME(nb)
a<b
The time hierarchy theorem for nondeterministic Turing machines was originally proven by Stephen Cook in 1972.[3] It was improved to its current form via a complex proof by Joel Seiferas, Michael Fischer, and Albert Meyer in 1978.[4] Finally in 1983, Stanislav Žák achieved the same result with the simple proof taught today.[5] The time hierarchy theorem for nondeterministic Turing machines states that if g(n) is a time-constructible function, and f(n+1) = o(g(n)), then
NTIME(f(n))\subsetneqNTIME(g(n))
The analogous theorems for space are the space hierarchy theorems. A similar theorem is not known for time-bounded probabilistic complexity classes, unless the class also has one bit of advice.[6]
f:N → N
n\inN
We need to prove that some time class TIME(g(n)) is strictly larger than some time class TIME(f(n)). We do this by constructing a machine which cannot be in TIME(f(n)), by diagonalization. We then show that the machine is in TIME(g(n)), using a simulator machine.
Time Hierarchy Theorem. If f(n) is a time-constructible function, then there exists a decision problem which cannot be solved in worst-case deterministic time o(f(n)) but can be solved in worst-case deterministic time O(f(n)log f(n)). ThusDTIME(o(f(n)))\subsetneqDTIME\left(f(n)logf(n)\right).
Note 1. f(n) is at least n, since smaller functions are never time-constructible.
Example. There are problems solvable in time nlog2n but not time n. This follows by setting
f(n)=nlogn
o\left(nlogn\right).
We include here a proof of a weaker result, namely that DTIME(f(n)) is a strict subset of DTIME(f(2n + 1)3), as it is simpler but illustrates the proof idea. See the bottom of this section for information on how to extend the proof to f(n)logf(n).
To prove this, we first define the language of the encodings of machines and their inputs which cause them to halt within f
Hf=\left\{([M],x) | M accepts x in f(|x|) steps\right\}.
Notice here that this is a time-class. It is the set of pairs of machines and inputs to those machines (M,x) so that the machine M accepts within f(|x|) steps.
Here, M is a deterministic Turing machine, and x is its input (the initial contents of its tape). [''M''] denotes an input that encodes the Turing machine M. Let m be the size of the tuple ([''M''], x).
We know that we can decide membership of Hf by way of a deterministic Turing machine R, that simulates M for f(x) steps by first calculating f(|x|) and then writing out a row of 0s of that length, and then using this row of 0s as a "clock" or "counter" to simulate M for at most that many steps. At each step, the simulating machine needs to look through the definition of M to decide what the next action would be. It is safe to say that this takes at most f(m)3 operations (since it is known that a simulation of a machine of time complexity T(n) for can be achieved in time
O(T(n) ⋅ |M|)
Hf\inTIME\left(f(m)3\right).
The rest of the proof will show that
Hf\notinTIME\left(f\left(\left\lfloor
m | |
2 |
\right\rfloor\right)\right)
so that if we substitute 2n + 1 for m, we get the desired result. Let us assume that Hf is in this time complexity class, and we will reach a contradiction.
If Hf is in this time complexity class, then there exists a machine K which, given some machine description [''M''] and input x, decides whether the tuple ([''M''], x) is in Hf within
TIME\left(f\left(\left\lfloor
m | |
2 |
\right\rfloor\right)\right).
We use this K to construct another machine, N, which takes a machine description [''M''] and runs K on the tuple ([''M''], [''M'']), ie. M is simulated on its own code by K, and then N accepts if K rejects, and rejects if K accepts. If n is the length of the input to N, then m (the length of the input to K) is twice n plus some delimiter symbol, so m = 2n + 1. Ns running time is thus
TIME\left(f\left(\left\lfloor
m | |
2 |
\right\rfloor\right)\right)=TIME\left(f\left(\left\lfloor
2n+1 | |
2 |
\right\rfloor\right)\right)=TIME\left(f(n)\right).
Now if we feed [''N''] as input into N itself (which makes n the length of [''N'']) and ask the question whether N accepts its own description as input, we get:
We thus conclude that the machine K does not exist, and so
Hf\notinTIME\left(f\left(\left\lfloor
m | |
2 |
\right\rfloor\right)\right).
The reader may have realised that the proof gives the weaker result because we have chosen a simple Turing machine simulation for which we know that
Hf\inTIME(f(m)3).
It is known[7] that a more efficient simulation exists which establishes that
Hf\inTIME(f(m)logf(m))
If g(n) is a time-constructible function, and f(n+1) = o(g(n)), then there exists a decision problem which cannot be solved in non-deterministic time f(n) but can be solved in non-deterministic time g(n). In other words, the complexity class NTIME(f(n)) is a strict subset of NTIME(g(n)).
The time hierarchy theorems guarantee that the deterministic and non-deterministic versions of the exponential hierarchy are genuine hierarchies: in other words P ⊊ EXPTIME ⊊ 2-EXP ⊊ ... and NP ⊊ NEXPTIME ⊊ 2-NEXP ⊊ ....
For example,
P\subsetneqEXPTIME
P\subseteqDTIME(2n)\subsetneqDTIME(22n)\subseteqEXPTIME
DTIME\left(2n\right)\subseteqDTIME\left(o\left(
22n | |
2n |
\right)\right)\subsetneqDTIME(22n)
The theorem also guarantees that there are problems in P requiring arbitrarily large exponents to solve; in other words, P does not collapse to DTIME(nk) for any fixed k. For example, there are problems solvable in n5000 time but not n4999 time. This is one argument against Cobham's thesis, the convention that P is a practical class of algorithms. If such a collapse did occur, we could deduce that P ≠ PSPACE, since it is a well-known theorem that DTIME(f(n)) is strictly contained in DSPACE(f(n)).
However, the time hierarchy theorems provide no means to relate deterministic and non-deterministic complexity, or time and space complexity, so they cast no light on the great unsolved questions of computational complexity theory: whether P and NP, NP and PSPACE, PSPACE and EXPTIME, or EXPTIME and NEXPTIME are equal or not.
The gap of approximately
logf(n)
For these models, the theorem has the following form:
If f(n) is a time-constructible function, then there exists a decision problem which cannot be solved in worst-case deterministic time f(n) but can be solved in worst-case time af(n) for some constant a (dependent on f).Thus, a constant-factor increase in the time bound allows for solving more problems, in contrast with the situation for Turing machines (see Linear speedup theorem). Moreover, Ben-Amram proved[10] that, in the above models, for f of polynomial growth rate (but more than linear), it is the case that for all
\varepsilon>0
(1+\varepsilon)f(n)