More Computational Variants




CS154

Chris Pollett

Apr. 20, 2020

Outline

`k`-tape Turing Machines

One way you might try to improve the power of a TM is to allow multiple tapes.

Definition. A `k`-tape TM, where `k ge 1` is an integer, is a six-tuple `M=(Q, Sigma, Gamma, delta, q_0, F)` where `Q, Sigma, Gamma, q_0` are as in the 1-tape case. Now, however, the transition functions is a map `delta:Q times Gamma^k -> Q times Gamma^k times {L,R}^k`

TIME and SPACE classes.

Definition. We say that a language `L` is in `\mbox{TIME}(f(n))` (resp. `\mbox{SPACE}(f(n))`) if it is decided by some `k`-tape TM in time `f(n)` (resp. space `f(n)`).

Linear Speed-Up

Simulating `k`-tapes with `1`-tape

Theorem. Given any `k`-tape machine `M` that operates within time `f(n)` deciding `L`, we can construct a `1`-tape machine `M'`operating within time `O((f(n))^2)` deciding `L`.

Proof. Let `M=(Q, Sigma, Gamma, delta, q_0, F)` be a `k`-tape machine.

Quiz

Which of the following is true?

  1. Turing-recognizable and decidable are synonyms.
  2. A stay-put Turing Machine cannot in general be simulated by a Turing Machine.
  3. In an offline Turing Machine, at the start of a computation, the input is written on a read only tape.

Random Access Machines (RAMs)

The RAM Instruction Set

The allowable RAM instructions are listed below:

  1. Read j /* read into register j into accumulator */
  2. Read (j) /* look up value v of register j then read register v into the accumulator*/
  3. Store j /* store accumulator's value into register j */
  4. Store (j) /* look up value v of register j then store acumulators values into register v*/
  5. Load x /* set the accumulator's value to x */
  6. Add j /* add the value of register j to the accumulator's value */
  7. Sub j /* subtract the value of register j from the accumulator's value */
  8. Half /* divide accumulator's value by 2 round down (aka shift left)*/
  9. Jump j /* set the program counter to be the jth instruction */
  10. JPos j /* if the accumulator is positive, then set the program counter to be j */
  11. JZero j /* if the accumulator is zero, then set the program counter to be j */
  12. JNeg j /* if the accumulator is negative, then set the program counter to be j */
  13. HALT /* stop execution */

Example Program for Multiplication

Suppose we input into Register 1 and 2 two number `i_1` and `i_2` and we would like to multiply these two numbers. The following program could do this:

  1. Read 1 //(Register 1 contains `i_1` ; during the `k`th iteration
  2. Store 5 // Register 5 contains `i_1 cdot 2^k`. At the start `k=0`)
  3. Read 2
  4. Store 2 //(Register 2 contains `lfloor i_2/2^k rfloor` just before we increment `k` )
  5. Half //(now accumulator is `lfloor i_2/2^{k+1} rfloor`, we've chopped off the low order bit of `i_2`. The `k`th iteration begins)
  6. Store 3 // (Register 3 contains half Register 2, `lfloor i_2/2^{k+1} rfloor` )
  7. Add 3 //(so now accumulator is twice Register 3, `2 cdot lfloor i_2/2^{k+1} rfloor`)
  8. Sub 2 //(accumulator will be `0` if low order bit of what was stored in register 2 is `0`)
  9. JZero 13
  10. Read 4 //( so this and the next instruction add Register 5 to Register 4 only if the `k`th least significant bit of `i_2` is nonzero)
  11. Add 5
  12. Store 4 //(Register 4 contains `i_1 cdot (i_2 mod 2^k))`
  13. Read 5
  14. Add 5
  15. Store 5 // Register 5 contains `i_1 cdot 2^{k+1}`, so can start next round
  16. Read 3
  17. JZero 19
  18. Jump 4 //(if not, we repeat)
  19. Read 4 //(the result)
  20. Halt