CMPS 260 Spring 2022
HW #8: Turing Machines, Countable Sets, Recursive/RE Languages
Due: 2pm, Friday, May 13

1. Present a Turing machine that computes the function f: {a,b}* ⟶ {a,b}* defined by f(w) = ambn, where na(w) = m and nb(w) = n. In other words, given a string composed of a's and b's, it sorts them into alphabetical order, so that all the a's precede any b's. Specifically, the machine M should satisfy the condition

q0w  ⊢M  qhambn

That is, if the machine is started in q0 (its initial state) with its read/write head positioned at the leftmost symbol of input string w, it should terminate in its halting state (qh) with the read/write head positioned at the leftmost symbol of the resulting output string.

Provide a short narrative to explain, at a high level of abstraction, how your machine works.


2. Each move of a standard Turing Machine, as presented by Linz in Chapter 9, results in the machine overwriting the symbol in the current tape cell, moving one cell to the right or to the left, and entering some state. Suppose that we impose the restriction that the symbol written onto the current tape cell must be different from what was there before. That is, in this restricted type of Turing Machine, (qj,b,D) ∈ δ(qi,a) (where D is either 'L' or 'R') implies that a and b are distinct symbols.

Use a simulation argument to show that, for any standard TM M there exists a TM M', restricted in the way described above, such that L(M) = L(M'). To make it concrete, assume that the tape alphabet of M is {0, 1, ☐}. The condition L(M) = L(M') simply requires that, for each input string w ∈ {0,1}*, M halts in an accepting state iff M' halts in an accepting state. (In particular, the contents of the tapes of M and M' need not be identical when they halt.)

Hint: Give M' "extra" symbols in its tape alphabet, compared to the tape alphabet of M.


3. Present a convincing argument that the intersection of any recursive language L1 with any RE language L2 is RE.

Hint: One could make use of a decision algorithm for L1 to either


4. Let L be a language having infinitely many members. Present a convincing argument that L is recursive if there exists an enumeration procedure that "prints" its strings in ascending order by length (so that for any two strings printed consecutively, the second is at least as long as the first).

Hint: Describe a decision algorithm for L that makes use of the described enumeration procedure for L.


5.
  +---+
4 | 15| ...
  +---+---+
3 | 10| 14| ...
  +---+---+---+
2 | 6 | 9 | 13| ...
  +---+---+---+---+
1 | 3 | 5 | 8 | 12| ...
  +---+---+---+---+---+
0 | 1 | 2 | 4 | 7 | 11| ...
  +---+---+---+---+---+
    0   1   2   3   4
Provide an algebraic description of a bijection mapping the elements of ℕ×ℕ onto the set of positive integers (i.e., ℤ+). Highly suggested is that you base it upon the table fragment shown to the right, which strongly suggests such a bijection. For example, it suggests that f(0,3) = 7 and f(3,1) = 14.

Hint: The ordered pair (r,c) lies on the same diagonal as the other ordered pairs that sum to r+c. The number of such ordered pairs is r+c+1, r of which precede (r,c) in the enumeration described by the table fragment. Also preceding (r,c) in that enumeration are all ordered pairs whose sum is less than r+c.