In computational complexity theory, the time hierarchy theorems are important statements that ensure the existence of certain "hard" problems which cannot be solved in a given amount of time. As a consequence, for every time-bounded complexity class, there is a strictly larger time-bounded complexity class, and so the run-time hierarchy of problems does not completely collapse. One theorem deals with deterministic computations and the other with non-deterministic ones. The analogous theorems for space are the space hierarchy theorems.
Both theorems use the notion of a time-constructible function. A function f : N → N is time-constructible if there exists a deterministic Turing machine such that for every n in N, if the machine is started with an input of n ones, it will halt after precisely f(n) steps. All polynomials with non-negative integral coefficients are time-constructible, as are exponential functions such as 2n.
Deterministic time hierarchy theorem
Statement
For any time constructible function , there exists a language that is decidable in time but not in time .
Proof
We prove this by constructing a Turing machine that is a decider for a language that is not decidable in time. In order to ensure that finishes its computation in time we include in a counter of length , which is the number of bits required to store the number .
There are two parts to this construction. One part is to ensure that has a different output from all Turing machines. We do this by simulating a given Turing machine on input . If finishes its computation quickly enough (in time less than where is the length of the input string), we construct to have the opposite output (this is similar to the digitalisation technique explained in the Diagonalization Lemma). But what if does not halt in the alloted time? we still need to make sure that is a decider, so we add a counter to to make sure that it stops after steps.
The basic structure of TM is:
input: string with length if w 6 for some TM M then reject end if calculate and use this value to create counter while c > 0 do simulate with input for 1 step if accepts then reject else if rejects then accept end if decrement end while reject
Now we need to show that halts within time. In order to simulate , needs to keep track of 's state, the tape symbol is currently reading, and 's transition function. If were to store this information in one spot on its tape, as simulates may have to spend an arbitrary amount of time moving traveling back and forth retrieving this information about . So we introduce a notion of tracks on 's tape. In one track we will store information about , in the other track we will store information about 's current computation. We change 's tape alphabet to a set of pairs, one from each track. Then, in a constant amount of time (dependent on the length of , not the length of the entire input string ) can copy the information on the first track to the current ___location on the second track. So, if runs in time , can simulate it in time . We add the counter to a third tape (also to cut down on unbounded time of traveling between the current head position of and the clock). The actual clock updating operations require only because the length of the clock is . So, if we allow to execute for steps and each step requires time, will halt in time .
Formally we need to show that is not decidable in time. We prove this by contradiction. Assume that TM decides in time , which is . Then can simulate in time for some constant . So, for some constant , for all . Consider what happens when we run on input . This input is longer than , which means that will have time to simulate until it halts and then will do the opposite of on the same input. Thus, does not decide which contradicts our assumption. So, is not decidable in time.
Non-deterministic time hierarchy theorem
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)).
Corollaries
Corrollary 1
For any two functions , , where (n) is o( (n)/ (n)) and is time constructible, TIME( (n)) TIME( (n)).
This corollary shows that and belong to two different classes of TIME hierarchies (and that TIME( ) includes TIME( ). Note that we can say the two classes are different because TIME( ) is a strict subset of TIME( ).
Corrollary 2
For any two real number , TIME( ) TIME( )
This corollary shows that polynomials of different degree are in different TIME hierarchies and that the classes of the smaller degree polynomials are strict subsets of the classes of the larger degree polynomials.
Corrollary 3
By this corollary, the classes of polynomial time algorithms and exponential time algorithms are different.
Consequences
The time hierarchy theorems guarantee that the deterministic and non-deterministic version of the exponential hierarchy are genuine hierarchies: in other words P ⊂ EXPTIME ⊂ 2-EXP ⊂ ..., and NP ⊂ NEXPTIME ⊂ 2-NEXP ⊂ ...
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 O(n5000) time but not O(n4999) time. This is one argument against considering P to be a practical class of algorithms. This is unfortunate, since 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 complexity theory: whether P and NP, NP and PSPACE, PSPACE and EXPTIME, or EXPTIME and NEXPTIME are equal or not.