CS 252 Example Midterm Exam Consider the Turing Machine M1 with states {1, 2, 3, 4, 5, 6}, input alphabet {a, b}, tape alphabet {a, b, X, Y}, start state 1, accept state 6, and transition function given by the diagram. (graph5.pdf) 1 2 a X R 2 2 a a R 2 2 Y Y R 2 3 b Y L 3 3 Y Y L 3 4 a a L 3 5 X X R 4 4 a a L 4 1 X X R 5 5 Y Y R 5 6 - - R a. Trace the execution of M1 on the input string b. Give the configuration of M1 at each step of the execution. (A Turing Machine configuration includes the current state, the content of the tape, and the position of the tape head.) b. Trace the execution of M1 on the input string a. Give the configuration of M1 at each step of the execution. c. Trace the execution of M1 on the input string ab. Give the configuration of M1 at each step of the execution. d. Trace the execution of M1 on the input string aabb. Give the configuration of M1 at each step of the execution. Consider the language L1. Strings in L1 are composed of symbols from the alphabet {a, b}. L1 = { w | w contains an even number of a's and an odd number of b's } a. Is the language L1 regular? b. If L1 is regular, give the state diagram of a DFA that recognizes L1. If L1 is not regular, use the pumping lemma for regular languages to prove it. (Note that for some languages you need to pump down from xyz to xz.) Use the pumping lemma for regular languages to prove that the language L3 is not regular. Strings in L3 are composed of symbols from the alphabet {a, b}. (Note that for some languages you need to pump down from xyz to xz.) L3 = { a* b^n a* b^n a* | n >= 0 } a. Give the part of the proof that comes before choosing a string. b. Give the string you choose to use in the proof. c. Give the part of the proof that invokes the pumping lemma. d. Give the part of the proof that explains the different cases where the string can't be pumped. Give a regular expression that generates the language L2. Strings in L2 are composed of symbols from the alphabet {a, b}. L2 = { w | w begins or ends with either aa or bb } Follow parts a-d below to convert the Regular Expression to a Nondeterministic Finite Automaton. Please follow the steps of the construction described in Lemma 1.55. Please give the machine that results from following the construction. Please don't give some other equivalent machine. aa(a|b)*bb a. Give the state diagram of the NFA for the regex aa. b. Give the state diagram of the NFA for the regex (a|b). c. Give the state diagram of the NFA for the regex (a|b)*. d. Give the state diagram of the NFA for the complete regex aa(a|b)*bb. Consider the language L6. Strings in L6 are composed of symbols from the alphabet {a, b}. L6 = { a^n a* a^n b^n | n >= 0 } a. Is the language L6 context-free? b. If L6 is context-free, give a context-free grammar that generates L6. If L6 is not context-free, use the pumping lemma for context-free languages to prove it. (Note that for some languages you need to pump down from uvxyz to uxz.) Give the state diagram of a Pushdown Automaton that recognizes the language L5. Note that you need to design a PDA directly. Do not design a grammar and convert it to a PDA. Strings in L5 are composed of symbols from the alphabet {a, b}. L5 = { a^n b^n b^m a^m | n,m >= 0 } Consider the context-free grammar G1 with nonterminals {W, X, Y, Z}, terminals {a, b}, start symbol W, and productions listed below. W -> XYZ X -> Z Y -> aY | epsilon Z -> aZb | epsilon Convert G1 to an equivalent PDA using the procedure given in Lemma 2.21. Give the state diagram of the PDA. Please follow the steps of the construction described in Lemma 2.21. Please give the machine that results from following the construction. Please don't give some other equivalent machine. (Please note that this problem is the one and only case where you are allowed to have PDA transitions that push more than one symbol.) For each of the languages defined below (L1-L4), identify the smallest language class (a-c) that contains the language. (Note that some language classes may be used more than once and some may not be used at all.) Choose from among these language classes: Regular Context Free Not Context Free a. L1 = { a* b^m a* b^m a* | m >= 0 } b. L2 = { a* b* a* b^m a* | m >= 0 } c. L3 = { a^n b^m a^n b^m a^n | n,m >= 0 } d. L4 = { a^n b^m a* b^m a^n | n,m >= 0 }