Loading [MathJax]/jax/output/HTML-CSS/jax.js
Skip to main content

Universal Turing Machine and Its Simulation

The theorems we have which we will show is 

TheoremThere exists a Turing Machine U such that for every x,α{0,1} U(x,α)=Mα(x) where Mα denotes the turing machine represented by α. Moreover, if Mα halts on input x within T steps then U(x,α) halts within cTlogT steps where C is a number of independent of |x| and depending only on Mαs alphabet size, number of tapes and number of states 

For this, we need some equivalency between some special Turing machine models

Theorem 1: For every f:{0,1}{0,1} and time-constructible T:NN if f is computable in time T(n) by a Turing Machine M using alphabet Γ then it is computable in time 4log|Γ|T(n) by a Turing Machine ˆM using the alphabet {,,0,1}

Theorem 2: Define a single-tape Turing machine to be a Turing Machine that has only one read-write tape, that is used as input, work tape, and output tape. For every f:{0,1}{0,1} and time-constructible T:NN if f is computable in time T(n) by a Turing Machine M using k tapes then it is computable in time 5kT2(n) by a single-tape Turing Machine ˆM.

Theorem 3: Define a bidirectional Turing machine to be a Turing Machine whose tapes are infinite in both directions. For every f:{0,1}{0,1} and time-constructible T:NN if f is computable in time T(n) by a bidirectional Turing Machine M using k tapes then it is computable in time 4T(n) by a standard Turing Machine ˆM.


Now coming back to the proof, we'll first proof a weaker version.

Weaker Version: CTlogT is replaced by CT2

Proof of Weaker Version: Our universal TM U is given an input (x,α), where α represents some TM M, and needs to output M(x). By Theorem 1 and Theorem 2, we may assume

  1. M has a single work tape (in addition to the input and output tape)
  2. M uses the alphabet {,,0,1}

Note that these transformations may introduce quadratic slowdown

    The TM U uses the alphabet {,,0,1} and three work tapes in addition to its input and output tape. U uses its input tape, output tape, and one of the work tapes in the same way M uses its three tapes. In addition, U will use its first extra work tape to store the table of values of M 's transition function, and its other extra work tape to store the current state of M

Simulation: To simulate one computational step of M,U scans the table of M 's transition function and the current state to find out the new state, symbols to be written, and head movements, which it then executes. 


Now we will prove the actual theorem.

Proof of Actual Theorem: The general structure of U will be as in the case of CT2. U will use its input and output tape in the same way M does and will also have extra work tapes to store M 's transition table and current state and to encode the contents of M 's work tapes. The main obstacle we need to overcome is that we cannot use Theorem 2 to reduce the number of M 's work tapes to one

    Let k be the number of tapes that M uses (apart from its input and output tapes) and Γ its alphabet. We may assume that U uses the alphabet Γk. Thus we can encode in each cell of U's main work tape k symbols of Γ, each corresponding to a symbol from one of M's tapes. This means that we can think of U's main work tape not as a single tape but rather as k parallel tapes; that is, we can think of U as having k tapes with the property that in each step all their read-write heads go in unison either one location to the left, one location to the right, or stay in place. 

We still have to deal with the fact that M's k read-write heads can each move independently to the left or right, whereas U 's parallel tapes are forced to move together.

Idea: Since we can not move Us read-write head in different directions at once we simply move parallel tapes ``under'' the head.

    To simulate a single step of M, we shift all the nonblank symbols in each of these parallel tapes until the head's position in these parallel tapes corresponds to the heads' positions of M's k tapes. For example, if k=3 and in some particular step M's transition function specifies the movements L,R,R, then U will shift all the nonblank entries of its first parallel tape one cell to the right, and shift the nonblank entries of its second and third tapes one cell to the left. The above approach is still not good enough to get O(TlogT) time simulation. The reason is that there may be as many as T nonblank symbols in each parallel tape and so each shift operation may cast U as much as T operations per each step of M resulting Θ(T2) time simulation.

We will deal with this problem by encoding the information on the tapes in a way that allows us to amortize the work performing a shift.

Idea: We will ensure that we do not need to move all the nonblank symbols of the tape in each shift operation. Specifically, we will encode the information in a way that allows half of the shift operations to be performed using 2c steps, for some constant c, a quarter of them using 4c steps, and more generally 2i fraction of the operations will take 2ic steps, leading to simulation in roughly cTlogT time.

Encoding M's tapes on  M's tape:

 We add a special kind of blank symbol to the alphabet of M’s parallel tapes with the properties that this symbol is ignored in the simulation. For example, if M's tape contents are 010 then, this can be encoded as 010 or 010 and so on or just 010.

    For convenience, we think of U's parallel tapes as infinite in both the left and right directions by the Lemma. Thus we index their locations by 0,±1,±2, Normally we keep U's head on location 0 of these parallel tapes. We will only move it temporarily to perform a shift when, following our general approach, we simulate a left hand movement by sifting the tape to the right and vice versa. At the end of the shift, we return the head to location 0.

    We split each of U's parallel tapes into zones that we denote by R0, L0, R1, L1, (We'll only need to go up to RlogT, LlogT since the turing machine runs for time T, it can at most access T cells of each tape.). The cell at location 0 is not at any zone. Zone R0 contains two cells immediately right of location 0 (i.e. location +1,+). Zone R1 contains the four cells +3,+4,+5,+6. Generally for every i1, Zone R1 contains the 2×2i cells that are right to the Ri1 (i.e. locations 2i+11,,2i+22). Similarly Zone L0 contains two cells indexed by 1 and 2 and generally  Zone Li contains the cells 2i+2+2,,2i+1+1

Invariants: We shall always maintain the following invariants

  • Each of the zones is either empty, full, or half-full with non--symbols. That is, the number of symbols in zone Ri that are not is either 0, 2i, or 2×2i and the same holds for Li . (We treat the ordinary symbol the same as any other symbol in Γ, and in particular a zone full of ’s is considered full). We assume that initially all the zones are half-full. We can ensure this by filling half of each zone with symbols in the first time we encounter it.
  • The total number of non--symbols in RiLi is 2×2i. That is, either Ri is empty and Li is full, or Ri is full and Li is empty, or they are both half-full.
  • Location 0 always contains a non--symbol.

Performing a Shift: Now when performing the shifts, we do not always have to move the entire tape, but we can restrict ourselves to only using some of the zones.

    We illustrate this by showing how U performs a left shift on the first of its parallel tapes

  1. U finds the smallest i0 such that Ri0 is not empty (Hence R0,R1,,Ri01 are empty). Note that this is also the smallest i0 such that Li0 is not full. We call this number i0 the index of this particular shift. 
  2. U puts the leftmost non--symbol of Ri0 in position 0. We now denote the new zones as Ri,Li. Now there are 2×2i01 non--symbols remain in Ri0 if Ri0 is full and otherwise 2i01 non--symbols remain in Ri0
    • Now if Ri0 was full before we shift the 2×2i01 to the R0,,Ri0 each of the zones becomes half filled. In other words we shift the leftmost 2i01 non--symbols to the zones R0,,Ri01 each of which becomes half filled because in total they take the space i01i=02×2i=2(2i01). And hence Ri0 also becomes half filled because 2i0 non--symbols remain in Ri0
    • If Ri0 was half-full before we shift the 2i01 non--symbols of Ri0 into the zones R0,,Ri01 filling up exactly half of the symbols of each Ri zones where i{0,,i01}. Now the zone Ri0 is empty.
  3. U performs symmetric operation to the left of position 0. That is for j starting from i01 down to 0, U literally moves the 2×2j symbols of Lj to fill the cells of Lj+1. Finally U moves the symbol originally in position 0 to L0
    • So if Ri0 was full before Li0 was empty and all L0,,Li01 were full. After the shifting Lj contains all the 2×2j symbols of Lj1. So Li0 becomes half filled. And since at each step Lj1 was emptied to move all its content to Lj in the next step Lj1 becomes half filled. Therefore all L0,,Li01 are half filled. 
    • If Ri0 was half filled before Li0 was also half filled and all L0,,Li01 were full. After the shifting Lj contains all the 2×2j symbols of Lj1. So Li0 becomes full. And since at each step Lj1 was emptied to move all its content to Lj in the next step Lj1 becomes half filled. Therefore all L0,,Li01 are half filled.
  4. At the end of the shift all of the zones R0,L0,R1,L1,,Ri01,Li01 are half-full, Ri0 has 2i0 fewer non--symbols and Li0 has 2i0 additional non--symbols. Thus our invariants are maintained

Complexity Analysis: The total cost of performing a shift is proportional to the total size of all zones involved R0,L0,,Ri0,Li0. That is O(i0j=02×2j)=O(2i0) operationsAfter performing a shift with index i the zones R0,L0,,Ri1,Li1 are half-full which means it will take at least 2i1 left shifts before the zones L0,,Li1 becomes empty or at least 2i11 right shifts before the zones R0,,Ri1 becomes empty. Hence once we perform a shift with index i, the next 2i1 shifts of that particular parallel tape will all have index less than i. This means that for every one of parallel tapes at most a 12i fraction of the total number of shifts have index i. Since we perform T shifts and the highest possible index is in the course of simulating T steps of M is O(llogTi=1T2i12i)=O(TlogT)

Comments

Popular posts from this blog

Hierarchy Theorems (Time, Space, Alternation)

There are many hierarchy theorems based on Time, Space, Nondeterminism, Randomization etc. Time Hierarchy Theorem (Version 1) : If f,g are time-constructible functions satisfying f(n)logf(n)=o(g(n)), then DTIME(f(n))DTIME(g(n)) Proof:  Consider the following Turing machine D: "On input x, run for f(|x|)log(f(|x|)) steps the Universal TM U to simulate the execution of Mx on x. If U outputs some bit b{0,1} in this time, then output the opposite answer (i.e., output 1b ). Else output 0.” Here Mx is the machine represented by the string x.      By definition, D halts within f(n)log(f(n)) steps and hence the language L decided by D is in DTIME(g(n)). Claim:  L DTIME (f(n)) Proof:  For contradiction's sake, assume that there is some TM M and constant c such that TM M, given any input x{0,1}, halts within cf(|x|) steps and outputs D(x)....

Cook - Levin Theorem

Around 1971, Cook and Levin independently discovered the notion of NPcompleteness and gave examples of combinatorial NPcomplete problems whose definition seems to have nothing to do with Turing machines. Soon after, Karp showed that NPcompleteness occurs widely and many problems of practical interest are NPcomplete. To date, thousands of computational problems in a variety of disciplines have been shown to be NPcomplete. SAT is the language of all satisfiable CNF formulae. Cook-Levin Theorem : SAT is NPcomplete Before we go into the proof first we need to define some things Configuration of a Turing Machine: A configuration of a Turing Machine at any point of time t is basically the snapshot of the turning machine at that time. It is an ordered pair of the head position, current state, and tape content. Any configuration is initialized and ended with a special symbol, let # mark its ending. Then the contents of the tape at the left of ...

Function Automata: A Technique to Solve Finite State Automata Problems

Here I will describe a strategy or technique to solve some finite state automata problems. This strategy was first taught to us by my Theory of Computation Professor. The term 'Function Automata' is given to me since we use function-like structures in this.     Suppose you are given a language that is a regular set L. So there exists a DFA for L, LD=(Q,Σ,δ,q1,F) where Q is the set of states, Σ is the set of alphabets, δ is the transition function, S is the starting state and f is the set of final states. Now let Q={q1,q2,,qn where nN. Now we will do a kind of subset construction but every new state will have n states of Q but they can repeat. So (q1,q1,,q1n times) is a state of the new automata. Now, what is the meaning of these new states? Let f=(qk1,qk2,,qkn) be a new state where qki's are not necessary to be diff...