Hierarchy Theorems, co-r.e. sets, Reductions




CS154

Chris Pollett

Apr. 24, 2013

Outline

Hierarchy Theorems

When Can We Recognize `A_f`?

Lemma. `A_{f} \in \mbox{TIME}((f(n))^3 )`.

Proof. We will use a variation on our universal Turing machine from last week to prove this. Our machine, `U_f`, will have `4` tapes. Let `n= | langle M,x rangle|`. First, `U_f` uses `M_f` to write an alarm clock amount of time `I^{f(n)}` on the fourth tape. The fourth head is then rewound. Using the input `langle M, x rangle`, the second tape is initialized to encode the start state `s` of `M`, `langle M rangle` is copied to the third tape and converted into a 1-tape machine using our earlier simulation (this machine executes one step of the original machine in at most `O(f(n))` steps and we could linear speed this up to `f(n)` ). The first tape is set up with just `x` on it. Doing all this, takes `O(f(n))` time. The modified `M` is then simulated step by step. This involves:

  1. Comparing the current state, and current head position of tape `1` against the transition function of `M` on tape `3` until a match its found,
  2. applying the appropriate change to the first tape and updating the current state on the second tape, and
  3. advancing the alarm clock tape.
Simulating one step of the modified `M` take `O(f(n))` steps on `U_f`. So simulating one step of the original takes `O(f(n)^2)` steps on `U_f`. We simulate exactly `f(n)` steps of `M` by using our clock and determine if we have accepted by then. So the total time is `O(f(n)^3)`, which gives `A_f` in `\mbox{TIME}((f(n))^3 )` as desired.

When Can't We Recognize `A_f`?

Lemma. `A_{f} !in \mbox{TIME}( f( lfloor n/2 rfloor ))`.

Proof. Suppose `M_{A_f}` decides `A_f` in time `f(lfloor n/2 rfloor)`. Let `D_f` be the diagonalizing machine that computes:
`D_{f}( langle M rangle)`: if `M_{A_f}( langle M, M rangle)` accepts then reject else accept.
This machine on input `langle M rangle` runs in the same time as `M_{A_f}` on input `langle M, M rangle` (which is twice as long `+ 1` as `langle M rangle`). That is, it runs in time `f(lfloor (2n+1)/2 rfloor) = f(n)`. Does `D_f` accept its own description? Suppose `D_{f} ( langle D_f rangle)` accepts. By our definition of `D_f` this is done in at most `f(n)` steps. This means `M_{A_f}( langle D_f, D_f rangle)` rejects, which means `\langle D_f, D_f rangle !in A_f`. This means `D_f` on input `D_f` did not accept in `f(n)` steps, contradicting our starting assumption. Starting with `D_{f}(langle D_f rangle)` rejecting, we can follow a similar chain of reasoning to get a contradiction as well.

Hierarchy Theorems

Hierarchy Theorem Implications and Open Problems

Homework Problems

Problem 1. Give an offline TM which when started with `x#y` on its read only input tape outputs `lfloor x/y rfloor` on its output tape. Assume `{0,1, #}` is the input alphabet and numbers are in binary (lead zeros not allowed). On bad inputs your TM should halt, with `#` on the tape. If `y` is `0` output `#`. If `x` is `0` and `y` is a nonzero integer the output should be `0`.

Answer. We give a description of our TM at a level such that each of the submachines should be easily spec'd out so that you could do problems (2) and (3). We assume the tape alphabet has symbols `\ul{0}, \ul{1}, \ul{square}`. Let `s` be the start state of our machine, `\h\a\l\t` be a halt state. If the machine starts on a blank space, it writes `#` to the output tape and halts. i.e., `delta(s, square, square) = (\h\a\l\t, square, #, R, R)`. Similarly, `delta(s, #, square) = (\h\a\l\t, #, #, R, R)` The first sub-machine scans the input tape left-to-right until the # symbol is observed and moves 1 square beyond this. (On the work tape it can be moving right as well). It remembers as it did this if it ever saw a `1` or if it saw lead `0`'s on the input tape. If the machine is reading a blank square it halts and writes `#`. If then continues to the right until it sees a `1` or lead `0`'s or a blank square. If it never sees a `1` or ever sees lead 0's it writes `#` to the work tape and halt. Otherwise, if before the `#` on the work tape it never saw a `1`, it writes `0` and halts. If we haven't halted, we have now verified the input is in the correct format and both `x` and `y` are non-zero. We rewind the input tape to its left hand side. We scan left-to-right and copy `y` to the work tape. We then write #0 after `y` on the work tape so that the work tape looks like `y#0`. We next move to the `#` on both tapes. We then scan right-to-left on both tapes, until we get to a blank square on the input tape. If we are not reading a square on the work tape we erase everything before the # on the work tape and halt. If as we are scanning right-to-left on both tapes, we read a blank on the work tape, we write a 0. After this phase, we know `y` is less than `x` and has been padded with lead `0`'s to be of the same length. We next repeatedly, subtract `y` from `x` in passes. After the `m`th pass, the work tapes configuration will look like: `x-y cdot m#y#m `. To do the subtractions we use the underscore versions of symbols to keep track of which pair of squares we are subtracting. If the term before the first # is all 0's then, we erase up to the second sharp on the tape and output `m` and halt.

Problem 4. Give a nondeterministic Turing machine which recognizes the language of binary strings of integers `n` such that `n` is a product of integers `x` and `y` both of which are greater than `1`. You can give a high level description of your NTM.

Answer. We describe a 6-tape NTM to do this. We assume the input alphabet is `{0, 1}`. We assume the input is big-endian. On input `w`, the machine first runs a program which at each step reads an input square, if this square is not a blank space, it nondeterministically chooses to write a 0 or a 1 on the 2nd tape, and it independently, nondeterministically chooses to write a `0` or a `1` on the third tape. For the the 1st, 2nd, and 3rd tapes it moves right, all other tapes are assumed to stay put. Once it sees a blank, it rewinds tapes 1,2,3. After this pass the machine operates deterministically. So far the computation has been in linear time. Let `x` be the contents of the 2nd tape, `y` be the contents of the third tape. These numbers may have lead `0`'s. We now check to make sure both of these numbers are greater than `1`, by doing a single left right scan of the numbers verify that there was a position other than the low order position that was a `1`. If both numbers are not greater than one it halts and rejects. We next describe how to multiply `x` and `y` together to verify whether they equal `w`. We use the 4th tape to hold the total so far, the 5th tape to hold the next row of the long multiplication, and the 6th tape to hold a temporary total. Initialize tape 4 to 0. We then do the following steps until tape 3 is a string of `0`'s.

  1. Rewind all tapes to the left hand size of their values.
  2. Scan left-to-right on tape 2 and tape 5 until we see a space on both tapes. As we move right copy the value of the square of tape 2 to tape 5. Rewind tape 2 to its left hand side. Put tape 5 on the blank square next to its rightmost non-blank square. This copies the contents of tape 2 to 5.
  3. Scan left-to-right on tape 3, to see if there are any 1 squares. If not, break out of this sequence of steps.
  4. Now on tape 3, scan right-to-left, if one sees a 0 move left on tape 3, move right on tape 5 writing a 0 on tape 5. When one sees the first 1 on tape 3, stop, write a 0 over the 1 on tape 3, and add the contents of tape 5 to tape 4 with the output going to tape 6. This last thing can be done using a right-to-left scan of tapes 5 and 4 using carry save addition.
  5. Copy tape 6 to tape 4 and erase tape 6.
  6. Go to step 1.

Finally, after doing all these steps we rewind to the left tapes 1 and tape 4. Then we scan left-to-right and verify each square is the same. If we ever see a difference we reject. If we get to the end of the string without rejecting we accept. This whole algorithm is at most linear space and quadratic time.

A Specific Nonrecursively Enumerable Language I

A Specific Non-Recursively Enumerable Language II

Corollary. `\bar{A}_{TM}` is not r.e.

Proof. We proved in an earlier lecture `A_{TM}` is recursively enumerable. So if `\bar A_{TM}` were r.e., then `A_{TM}` would be decidable giving a contradiction with our result that `A_{TM}` is undecidable.

Reducibility

Example

Let `\mbox{HALT}_{TM} = { langle M, w rangle | \mbox{M is a TM and M halts on input w}}`.

Theorem. `\mbox{HALT}_{TM}` is undecidable.

Proof. Suppose `H` decides `\mbox{HALT}_{TM}` . From `H` we can construct a machine `S` which decides `A_{TM}` as follows:

`S =` On input `langle M, w rangle` an encoding of a TM `M` and a string `w`:

  1. We build a new string `langle M',w rangle` where `M'` is a machine which simulates `M` until `M` halts (if it does) and if `M` accepts `M'` accepts. Otherwise, if `M` rejects than `M'` moves right forever, one square at a time. The map `langle M,w rangle -> langle M', w rangle` is well-defined enough that it can be computed by a TM. This is our reduction.
  2. We then ask our decider for `H` if `langle M', w rangle` is in `H`? If `H` accepts we accept and if `H` rejects we reject.

Since the only way `M'` on input `w` halts is if `M` accepts `w`, we know `langle M,w rangle` is in `A_{TM}` iff `langle M', w rangle` is in `\mbox{HALT}_{TM}`. So if `H` was a decision procedure for `\mbox{HALT}_{TM}`, then `S` would be a decision procedure for `A_{TM}`. As we know there is no decision procedure for `A_{TM}` we know that the supposed `H` can't exist.

Complete Problems

Complete r.e. and NP problems

Theorem.

  1. `A_{TM}` is Turing-complete for r.e.
  2. `A_{\mbox{clocked TM}} := {\langle M, w, 1^t rangle | \mbox{M is a nondeterministic machine that accepts w in at most t steps} }` is Karp-complete for NP.

Proof. For (1), we already have show that `A_{TM}` is in r.e. (the set of recursively enumerable languages). Suppose `L` in r.e. is recognized by a machine `M`. The function `w -> langle M, w rangle` is Turing computable and `w in L` iff `langle M, w rangle in A_{TM}`. Therefore, `A_{TM}` is Turing-complete. For (2), we first show `A_{\mbox{clocked TM}}` is in NP. An nondeterministic algorithm to recognize this language is as follows: On input `\langle M, w, 1^t rangle`, nondeterministically guess a string `v` of length `t^2`, then verify that `v` codes a sequence of configurations of `M` of length `t`, the first being the start configuration of `M` on `w` and such that the `i+1`st configuration follows from the `i`th. If it does, and `M` accepts `w` then accept, else reject. Now suppose `L` is in NP. Then it can be decided by some nondeterministic machine `M` in time `p(n)` for some polynomial `p`. The function `w -> langle M, w, 1^{p(|w|)} rangle` is polynomial time computable and gives a reduction from `L` to `A_{\mbox{clocked TM}}`.

Emptiness Testing for TMs

A Problem about Regular Languages

Even problems about regular languages can sometimes be hard...

Let `\mbox{REGULAR}_{TM} = { \langle M \rangle | mbox {M is a TM and L(M) is a regular language}}`.

Theorem. `\mbox{REGULAR}_{TM}` is undecidable.

Proof. Suppose `R` decides `\mbox{REGULAR}_{TM}`. Then the following machine decides `A_{TM}`:
"`S =` On input `langle M,w rangle`, where `M` is a TM and `w` is a string:

  1. Construct the following machine `M'`:
    `M' = ''` On input `x`:
    If `x` has the form `0^n1^n`, accept.
    If `x` does not have this form, run `M` on input `w` and accept if `M` accepts `w`.
     // So if `M` accepts `w`, then `M'` accepts all strings; otherwise, `M'` only accepts strings of the form `0^n1^n`.' '
  2. Run `R` on input `langle M' rangle`.
  3. If `R` accepts, accept; otherwise, if `R` rejects, reject."

In the above, the map `langle M,w rangle -> langle M' rangle` can be viewed as a reduction from `A_{TM}` to `\mbox{REGULAR}_{TM}`.

Using reducibility from languages other than `A_{TM}`