# Practice for Second Midterm Exam

### Directions:

• Answer the problems on the exam pages.
• There are seven problems, for 120 total points. Probable scale is somewhere around A=105, C=70.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.
• The first four problems are true/false, with five points for the correct boolean answer and up to five for a convincing justification (proof, counterexample, quotation of result from lecture, etc.)

```  Q1: 10 points
Q2: 10 points
Q3: 10 points
Q4: 10 points
Q5: 20 points
Q6: 30 points
Q7: 30 points
Total: 120 points
```

A few inconsequential typos were corrected on 6 April.

• Question 1 (10): (True/false with justification) There exists a language X such that X = L(M) for some three-tape Turing machine M, but X is not the language of any two-tape Turing machine.

• Question 2 (10): (True/false with justification) If A and B are two languages such that A ≤m B and B ≤m A, then A is TR if and only if B is TR.

• Question 3 (10): (True/false with justification) The language {(M,G): M is a DFA, G is a CFG, and L(M) = L(G)} is TD.

• Question 4 (10): (True/false with justification) The set of all Turing machines that accept themselves is not a TR language.

• Question 5 (20): This question asks you to describe two deterministic two-tape Turing machines. In each case be somewhat specific about what the machine writes on each tape and how it decides what to write.
• (a,10) Describe a deterministic two-tape Turing machine M such that L(M) = {an: n is prime}.
• (b,10) Describe a deteministic two-tape Turing machine such that L(M) = {w ∈ {0,1}*: w represents a prime number in binary} (Hint: Use your solution to part (a).)

• Question 6 (30): Two strings u and v over the same alphabet Σ are called anagrams if for every letter a in Σ, the number of a's in u equals the number of a's in v.
• (a,10) Prove that the language {(u,v): u and v are anagrams} is TD for any alphabet Σ.
• (b,20) Define the anagram Post Correspondence Problem or APCP to be the set of PCP dominoes P such that there exists a nonempty sequence of dominoes from P where the string made from the tops of each domino and the string made from the bottoms of each domino are anagrams. For Σ = {0,1}, prove that APCP is Turing decidable.

• Question 7 (30): Consider the following three languages -- in each case M and N represent binary representations of Turing machines with binary input alphabet:
• AND-PAIR = {(M,N): M ∈ L(N) ∧ N ∈ L(M)}
• OR-PAIR = {(M,N): M ∈ L(N) ∨ N ∈ L(M)}
• IFF-PAIR = {(M,N): M ∈ L(N) ↔ N ∈ L(M)}