Pledge: On my honor, I pledge that I have not discussed any of the questions on this exam with fellow students, nor will I until after 7 p.m. tonight. Signed: CSC-461 Exam #2 April 16, 2014 Name Time Started: Time Finished: Each question is equally weighted. You may omit two questions, but you must answer #8, and you can only omit one of #6 or #7. Circle the questions you are omitting. (Do not just leave them blank.) Show your work and state your assumptions for partial credit consideration. Unless explicitly stated, there are NO intended errors and NO trick questions. If in doubt, ask! You have two hours to work. 1. Answer the following questions. Explanations are not required, unless you think they would be helpful. (a) Show that the language generated by the grammar S 0S0 1S1 is regular. (This one is a semi-trick question.) [5 points] (b) Show that the language generated by the grammar S 0S S1 ε is regular. [5 points] (c) Give a CFG to generate {w ϵ {a,b}* w contains at least 3 b s}. [5 points] (d) Give a CFG to generate {w ϵ {a,b}* w has more a s than b s}. [5 points]
2. Create the following machines. In each case, fully specify the machine and give a brief description of the algorithm that it follows. Full credit will only be given if the machine takes advantage of its particular features. For example, generating a grammar and building the automatic PDA for that grammar is allowable, but not worthy of full credit. (a) Give a PDA for the language of odd length palindromes over {a,b}. You may specify the transition function or give a state diagram. (b) Give a deterministic, single-tape, one-way infinite Turing Machine for the language {a i b j i < j}. You may specify the transition function or give a state diagram. You may not use TM subroutines unless you specify them also.
3. Answer each of the following questions concerning the intersection of CFLs. [10 points each] (a) Below is a proof of a conjecture that is false. Identify the first step that is wrong, and clearly explain why. The explanation is more important than the step you identify. Conjecture: The intersection of two CFLs is a CFL. Proof: 1. We define the intersection of two context-free languages A and B A B = {w w ϵ A and w ϵ B} 2. The language X = A B is a subset of the language A. That is, X A. This is true since every string in X must also be in A. 3. Since X is a subset of A, and A is context free, X is context free. (b) Now, use the following two languages to show that the class of CFLs is in fact not closed under intersection: A = {a m b n c n m, n 0} B = {a n b n c m m, n 0}
4. (a) Prove that the class of decidable languages is closed under intersection. This should involve a construction as well as an argument that the construction shows the desired result. [7 points] (b) Prove that the class of Turing-recognizable languages is also closed under intersection. This should involve a construction as well as an argument that the construction shows the desired result. [7 points] (c) If A is a Turing-recognizable language and B A, is B necessarily a Turingrecognizable language? Prove your answer. [6 points]
5. Show that each of the following is decidable: (a) Let A = {<R,S> R and S are regular expressions and L(R) L(S)}. (Note that it is proper inclusion.) [10 points] (b) Let S = {<M> M is a DFA that accepts the reverse of w whenever it accepts w}. [10 points] 6. Show that the following language is decidable: REPEATS-STATE = {<M,w> M is a Turing Machine and M enters some state more than once in processing input w}
7. Consider the following CFG: S asa bsb a b (a) Describe the language that is generated by the CFG. [4 points] (b) Prove your answer by induction on the length of a string. (In your proof, if you have a portion that is genuinely analogous to something already completed, you may say so and omit repeating it.) [16 points] NOTE: This calls for a formal proof, not an informal argument. That the conjecture is true is probably something you consider to be obvious. But resist the temptation to let that insight lead you to an insufficient or incomplete proof.
8. Construct a standard (single-tape, one-way infinite, deterministic) TM to insert a single character from the alphabet at the tape head position. That is, the TM should change the configuration from yq0z to a halting configuration yqhaltαz, where y and z are arbitrary strings over the alphabet {a, b}, and α ϵ {a, b} is a single alphabet symbol. Include a brief explanation of how the TM works. You may not use TM subroutines unless you fully specify them also. Have a great break! (after tomorrow s Turing discussion, that is )