## CS 3133, A Term 1998 Foundations of Computer Science Homework 4 (due Oct. 6)

#### Instructions

Do the problems listed below. State problems completely as part of your solutions. Give a brief explanation of your solution strategy for each problem. Your solutions should be legible and coherent. Your arguments should be sufficiently clear and airtight so as to convince any skeptical but reasonable jury. Solutions should be written on only one side of each sheet of paper. Separate sheets should be stapled together.

#### Problems

1. Design a 3-tape Turing machine over the input alphabet {0,1} that will add binary strings u, v of equal (but unspecified) lengths. Tapes 1 and 2 are read-only. Tape 1 contains BuB. Tape 2 contains BvB. Tape 3 initially contains all B's. The computation should halt with BwB written on Tape 3, where w is the usual binary sum of u and v. Trace the computation performed by your machine on each of the following input pairs:
• u=1010, v=1000 (w should be 10010)
• u=0101, v=0111 (w should be 1100)

2. In this problem L denotes the language of all strings over {a,b} that contain at least one a. Turing machines are assumed to have a single one-way tape. Input strings may be written anywhere on the tape; in particular, there may be several blanks on the tape before the first non-blank symbol.
• Design a Turing machine M that halts in an accepting state if, and only if, the input string belongs to L. If the input string does not belong to L then M should either halt in a non-accepting state or else not halt at all.
• Using your machine M from the first part of this problem, design another Turing machine M' that enumerates the strings of L. Assume given a machine E that enumerates the set of all strings over the alphabet {a,b}. Each string over {a,b} appears infinitely many times in E's enumeration to account for an arbitrary number of blanks at the beginning of the string. The machine E is a black box except that you can start it at will and you have access to its output tape at all times during the ensuing enumeration. Consecutive strings on E's output tape are separated by a single delimiter symbol #. You may assume that M, E, and M' change states synchronously.

3. Show that the language L defined in the preceding problem is not decidable (i.e., not recursive).
Hint: Suppose tentatively that L is decidable. This means that there is some Turing machine M (with a one-way tape) that halts for every input string over {a,b} (including the empty string), halting in an accepting state if the input string contains at least one a, and halting in a nonaccepting state if the input string contains no a's. Let k be the number of steps in the computation of M for a totally blank input string. Show that a string consisting of a single a, with blanks in all other positions, will be rejected by M if it is placed at an appropriate location on the tape. Explain carefully how a contradiction arises, and extract the appropriate conclusions.