Automata Theory TEST 1 Answers Max points: 156 Grade basis: 150 Median grade: 81% 1. (2 pts) See text. You can t be sloppy defining terms like this. You must show a bijection between the natural numbers and elements of the set. 2. (6 pts) First, this set is infinite, so you can t simply enumerate it. You can t start with (0, 0), (0, 1), (0, 2)... because it will never terminate. You have to use the zig-zag approach: (0, 0), (0, 1), (1, 0), (0, 2), (1, 1), (2, 0),... 3. (4 pts) a, aa, bb, aaa, abb, bba, aaaa, aabb, bbaa, bbbb 4. (4 pts) It s a problem that has a yes/no answer. 5. (4 pts) You need to use the proper symbols. (q 1, abbaba) (q 2, bbaba) (q 4, baba) (q 3, aba) (q 4, ba) (q 3, a) (q 4, ɛ) 6. (6 pts) Create an FA M for the original language. Create a new machine M from M constructed as follows: M has all of M s states, with S now the only accepting state. Create a new start state S and create epsilon transitions to M s original accepting states; these states are no longer accepting in M. Reverse the direction of all transitions that were in M. M now accepts the reverse of the language thet M accepted. Convert this new machine into canonical form, as well as the machine in question. See if they are the same machine (see text for details). 7. (6 pts) XOR of three bits produces a single output: 0 when there are an even number of ones, or 1 for an odd number. 8. (6 pts) An NFA is slightly simpler. 9. (6 pts) b a + b + a The key here is that once an a is encountered, it can be followed by any number of a s, but once a b follows, any additional a s must be followed only by more a s and nothing else. 1
10. (a) (6 pts) S e L e + S e + e L e + e S e + e e (b) (6 pts) (c) (4 pts) Yes. Right hand sides all contain a single terminal or a single terminal followed by a single nonterminal.. (d) (3 pts) No. Cannot get more than one parse tree for the same string. Many answered yes because the grammar generates more than one string. That would make every grammar ambiguous. 11. (a) (3 pts) ɛ, aa, bb, abba, aaaa, bbbb, aabbaa, etc. NOTE: aabaa is NOT a member; these strings must be even length. (b) (4 pts) No. Consider catenating aa and bb to get aabb, which is not in the language. 12. (10 pts) 2
13. (10 pts) 14. (10 pts) (a) (2 pts) See diagram. Null transitions are not included. Note that if you included them, there are none into state q1 and none out of state a. (b) (6 pts) 13 : b ab = b 14 : ab a = ab a 1a : ab = 33 : b b = b 34 : a b a = a 3a : b = 43 : b b = b 44 : b = 4a : ɛ b = ɛ 3
15. (8 pts) Strings in the language are ɛ, b, ab, bb, abb, bab, bbb, abab, abbb, bbba, bbbb, A string cannot have aa as a substring. The following doesn t consider every string in lexicographic order; just the important ones. [ɛ, b, ab, bb, abb, bab, bbb,...] adding anything to any of these have the same results. Conceptually, these are all strings that end in a b. Consider a: When adding an a to any string in the ɛ class the result is still valid; but adding an a to a results in a rejected string, so a belongs in a new class. [a, ba, aba, bba,...] These are the legal strings that end in a. Consider aa: No matter what is added the result is rejected, which is not the case for the other two. So we need a separate case for strings with aa as a substring. [aa, aaa, aab, baa,...] These are the illegal strings with aa as a substring. 16. (6 pts) 17. (10 pts) Start off with classes [c, d, e] and [a, b, f] (accepting and non-accepting). For [a, b, f] a 1 distinguishes between a, b and f (a, b transition to accepting, f does not). This results in three classes: [c, d, e], [a, b], and [f]. At this point, all elements within each class transition to the same classes on 0 and 1, so no more distinctions can be made. In the DFA, you can t forget the accepting states: 18. (4 pts) 4
19. (8 pts) Proof: Let w = (ab) k/2 b k. (Many of you used (ab) k b 2k.) xy falls in (ab) k/2 and xy k; w k. If x = ɛ and y = (ab) k/2, then pumping y in or out will upset the m/n balance. But we have to consider y as various subsets of (ab) k/2. If y = (ab) i, i < k/2, the same argument holds. If y = (ba) i, i < k/2, the balance is again not maintained. Also, y could be just a single s or b, both of which must be discussed. Most had the right idea; they just didn t consider ALL possible cases for y (and many only consideed the case when x = ɛ!.) 20. (6 pts) Consider w = (ab) k/2 (a b). This meets the criteria of the pumping theorem. y is a suffix of (ab) k/2. Consider any non-empty value for y. If it is just b, we have a string of the form (ab) k/2 1 ab (a b) L: if we pump out, then m = k/2 1 and the a is part of (a b). If we pump in, then the first pumped b is part of the (ab) k/2 and the remaining b s part of (a b). No matter what we let y be, the prefix of the string will have the form (ab) m, and what follows is part of the (a b) suffix. 21. (6pts) False. Consider languages a n b n c n and a n b n, n 0, both of which are not regular. Their intersection is ɛ, which is regular. 22. (8 pts) Create an FA, or RE, or RG. Show it is finite. Show it has a finite number of equivalence classes. 5