# First Midterm Exam, Spring 2017

### Directions:

• Answer the problems on the exam pages.
• There are nine problems (some with multiple parts) for 125 total points. Actual scale was A = 100, C = 64.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.
• The first six questions are statements -- in each case say whether the statement is true or false and give a convincing justification of your answer -- a proof, counterexample, quotation from the book or from lecture, etc. You get five points for the correct boolean answer (so there is no reason not to guess if you don't know) and up to five for the justification.

```  Q1: 10 points
Q2: 10 points
Q3: 10 points
Q4: 10 points
Q5: 10 points
Q6: 10 points
Q7: 20 points
Q8: 15 points
Q9: 30 points
Total: 125 points
```

The language X over the alphabet {a, b, c} is defined by the grammar with start symbol S and rules S → aS, S → T, T → bbT, T → bc, T → Tcc, and T → ε.

The language Y over the alphabet {a, b, c} is the set {aibjck: (j = k) ∨ (|j - k| = 2)}.

The language Z over the alphabet {a, b, c} is the set {aibjck: i > j > k ≥ 0}.

A language is called Turing recognizable if and only if it is equal to the language L(M) for some (standard, deterministic, one-tape) Turing machine M. It is called Turing decidable if it is the language L(M) for some Turing machine that halts (accepts or rejects) on every input.

A string-cell Turing machine (SCTM) has a state set Q, including start state q0, accepting state qa, and rejecting state qr, an input alphabet Σ, a tape alphabet Γ with Σ ⊆ Γ, and a tape that is a sequence of cells c1, c2, c3,... At any time, the content of a tape cell is a string in Γ*. (The empty string ε plays the role of the blank symbol.) The transition function δ takes input in Q × (Γ ∪ {ε}) and has output in Q × (Γ ∪ {d, ε}) × {L, R, S}. Depending on the the current state and the leftmost character in the string in the current cell (or ε if the current cell has the empty string), the machine can either append an new character to the left of that string, delete the leftmost character (d), or leave the string unchanged (ε), and then either move left, move right, or stay put. The machien runs on an input string w ∈ Σ* by starting in state q0, looking at cell c1 which contains w, with all other cells containing ε. As with Sipser's TM's, if it is supposed to move left from c1 it stays put instead.

A restricted string-cell Turing machine (RSCTM) is a string-cell Turing machine that has only two cells (any attempt to move right from c2 results in staying put) and can only delete characters from c1, not add them.

• Question 1 (10): True or false with justification: The languages X and Y, defined above, are equal.

• Question 2 (10): True or false with justification: The language Z, defined above, is context-free.

• Question 3 (10): True or false with justification: For any non-negative integer n, let z(n) be the number of strings of length n in the language Z defined above. Then there exists a positive real number c and an integer n0 such that for all integers n with n > n0, z(n) ≥ cn2.

• Question 4 (10): True or false with justification: Let G be any context-free grammar in Chomsky normal form, and let M be any ordinary Turing machine that halts on all inputs. Then it is possible that L(G) ∩ L(M) is not a Turing decidable language.

• Question 5 (10): True or false with justification: Let USQ be the language {an2: n ≥ 0}. Then there exists a restricted string-cell Turing machine R (as defined abpve) such that L(R) = USQ.

• Question 6 (10): True or false with justification: There exist two languages U and V such that neither U nor V is context-free, but U ∪ V is context-free.

• Question 7 (20): Consider the language X defined above. Is is regular? If it is not, prove that it is not by giving an infinite set of pairwise X-distinguishable strings. If it is, give all of the following: (a) a DFA for X, (b) a regular expression for X, and (c) the index of X, i.e., the number of equivalence classes for its Myhill-Nerode relation. You may use standard constructions to convert one of these things to another, or produce each one directly from the definition of the language.

• Question 8 (15): Suppose that I have an ordinary NFA N with no moves into its start state, a single final state different fro the start state, and no moves out of its final state. I can transform N into a PDA P, in the normal form for the PDA-to-CFG construction, by taking each transition (p, a, q), adding a new state r dedicated to that transition, and replacing the transition with two: (p, a, ε; r, c) and (r, ε, c; q, ε). (Note: I gave you the choice of using the same new stack letter c for all the pairs of transitions, or using a different letter for each pair.)

What happens when I then carry out the PDA-to-CFG construction? Carry it out to get a grammar, starting with the following N: state set {i, p, q, f}, start state i, only final state f, alphabet {a, b}, and transitions (i, ε, p), (p, a, q), (q, b, p), and (p, ε, f). Feel free to omit nonterminals and rules that cannot lead to generating any string of terminals.

Describe in English what happens when this construction is applied to a general NFA.

• Question 9 (30): The Church-Turing thesis says that any "reasonable" model of general computation will lead to the same classes of recongnizable and decidable languages. Above we have defined the new model of string-cell Turing machines. We explore here whether it is in fact a "reasonable" model.

• (a, 15) Let S be an arbitrary SCTM. Give an implementation-level description (nt a state table, but enough to allow someone with enough time on their hands to design the state table) of an ordinary (deterministic, one-tape) Turing machine M such that L(M) = L(S).

• (b, 15) Is every Turing recognizable language equal to L(S) for some SCTM S? Prove your answer. If your answer involves the construction of a machine, give an implementation-level description rather than a state table.