# Second Midterm Exam

### Directions:

• Answer the problems on the exam pages.
• There are seven problems on pages 2-6, for 120 total. 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 questions are each statements which you are to determine to be true or false. You get five points for a correct boolean answer (so there is no reason not to guess if you are not sure) and up to five for a convincing justification (proof, counterexample, quotation from the text or 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
```

• Question 1 (10): (True/False with justification) Define the language SUBCFG to be {(G1, G2): G1 and G2 are CFG's and L(G1) ⊆ L(G2)}. Then SUBCFG is not Turing decidable.

• Question 2 (10): (True/False with justification) Define the language TRTM to be {M: M is a Turing machine and L(M) is TR}. Then TRTM is Turing decidable.

• Question 3 (10): (True/False with justification) Let A be any Turing decidable language. There must exist an enumerator E that outputs all the elements of A in nonincreasing order , which means that E never outputs a longer string after a shorter one.

• Question 4 (10): (True/False with justification) For any Turing machine M, define LD(M) to be the language of all strings w such that ww (the concatenation of two copies of w) is in L(M). There exists a Turing machine N such that LD(N) = L(N).

• Question 5 (30): For this question, recall that the alphabet of a one-tape Turing machine must contain a blank character, which initially occupied all the cells on the tape to the right of the input. The blank character cannot occur as part of the input string, and (following Sipser) we assume that there are no tape cells to the left of the input string

A left-blank Turing machine is a one-tape Turing machine that always moves left when it sees a blank character. We define ALBTM to be the set of pairs (M, w) where M is a left-blank Turing machine and w ∈ L(M).

• (b,10) Similarly, a right-blank Turing machine is a one-tape Turing machine that always moves right when it sees a blank, and ARBTM is the set of pairs (M, w) where M is a right-blank Turing machine and w ∈ L(M). Is ARBTM Turing decidable? Prove your answer.

• Question 6 (30): This question deals with functions from N to N, where N is the set {1,2,3,...}. Define S to be the set of all functions from N to N. A function in S is called periodic if there are positive integers t and q such that for all n with n ≥ t, f(n) = f(n+q). For example, the function whose values in order are (3, 16, 3, 3265, 24, 7, 24, 7, 24, 7, 24, 7,...) is periodic because we may take t = 5 and q = 2. Define SP to be the set of all periodic functions in S.

• (a,10) Prove that S is an uncountable set. (Hint: If f is any function from N to S, show that f is not onto by giving an example of a function in S that is not in the range of f.)

• (b,10) Prove that SP is a countable set.

• (c,10) Prove that every function in SP is Turing computable.

• Question 7 (30): Here are three easy questions dealing with mapping reducibility. Recall that if A and B are any two languages, A ≤m B means that there exists a Turing computable (always-defined) function f such that for any string x, x ∈ A if and only if f(x) ∈ B.

• (a, 10) Prove that if A ≤m B and B ≤m C for any three languages A, B, and C, then A ≤m C. (This is solved exercise 5.6 in Sipser, but of course you may not just quote it.)

• (b, 10) Recall that ATM is the set of pairs (M, W) where M is a Turing machine and w ∈ L(M). Recall that LBOS is the set of Turing machines M such that M ∉ L(M). Prove that LBOSm A TM.

• (c, 10) Prove that A TMm LBOS.