Exercises for the fifth tutorial

Nils Anders Danielsson

  1. Is the following problem χ-decidable?

      is-powCExp → Bool
      is-pow p = if ∀ m ∈ ℕ. ∀ n ∈ ℕ. p ⌜(m, n)⌝ ⇓ ⌜mn⌝ then true else false

    You can assume that 00 = 1.

  2. Is the following problem χ-decidable?

      is-pow ∈ { (fe) | f ∈ ℕ × ℕ → ℕ, e ∈ CExp, e implements f } → Bool
      is-pow (f, _) = if ∀ m ∈ ℕ. ∀ n ∈ ℕ. f (m, n) = mn then true else false

    You can assume that 00 = 1.

  3. Show how one can, for an arbitrary n ∈ ℕ, construct a Turing machine that, if started with an empty tape (containing nothing but blanks), terminates with n contiguous ones on the tape, and the head at the tape’s left end.

    You may wish to use Anthony Morphett’s Turing machine simulator. (If you go to “Advanced options”, then you can choose to use semi-infinite tapes.)

  4. Implement a Turing machine that adds one natural number to another. If the input consists of 1m01n0 (for m, n ∈ ℕ), i.e. m ones followed by a zero, n ones, and a final zero, then the machine should terminate with 1m + n0.

    Bonus exercise: Implement truncated subtraction (λ m n. max 0 (m - n)).

  5. What does the following Turing machine do?

  6. What does the following Turing machine do when given input of the form 111…1#111…1?

  7. Suggest a method for representing χ programs as strings suitable for manipulation by a Turing machine.

    What properties does your method have?