All of my Theory Exams From 2017–2019 Good luck! 1492740742 Page 2 Coderson, Cody Question 1. [30 points (2 points each)] Answer true or false to each of the following. Put an ‘X’ in the T box if the answer is always true, and in the F box otherwise. No justification needed. (a) T F If M is a DFA with k states, then L(M ) contains a string of length k − 1. (b) T F If L is a finite language, then L ∩ (LL ∪ L? ) is regular. (c) T F Let L be any regular language. Then #(L) = {1|w| : w ∈ L} is regular. (d) T F Let L ⊆ {0, 1}? be the language consisting of all strings having an equal number of 01 substrings and 10 substrings. Then L is not regular. (e) T F Let L ⊆ {0, 1, 2}? be the language consisting of all strings having an equal number of 01 substrings and 10 substrings. Then L is not regular. (f) T F The set of non-regular languages is closed under complement. Let Li for i ≥ 0 be an infinite set of regular languages. Then ( ∞ S (g) T F i=1 Li ) is regular. (h) T F Let L = {wxw : |w| ≤ 1 + |x|, w ∈ {0, 1}? , x ∈ {0, 1}? }. Then L is regular. (i) T F For a given non-empty regular language L, let kd be the smallest number of states for any DFA recognizing L, and kn be that for any NFA recognizing L. Then kn = kd . (j) T F For any non-empty language L, L? is infinite. (k) T F For a DFA D, L(D) is infinite if and only if it accepts some string with length at least the number of states of D. (l) T F A computation in an NFA on an input with n characters is a sequence of exactly (n + 1) states. (m) T F Every NFA has the same language as some GNFA with 2 states. (n) T F For a set of states S in an NFA, there can be an ε-transition from state s ∈ E(S) to state t ∈ / E(S). (o) T F Suppose two DFAs D1 , D2 have n1 , n2 states each, and f1 , f2 final states each. Now form the DFA D from the product construction for the union of their languages. Then D has f1 × n1 + f2 × n2 − f1 × f2 final states. 1 1492740742 Page 3 Coderson, Cody Question 2. [30 points (20+10)] Prove that L1 = {(011)n+1 (010)n : n ≥ 0} is not regular. Let L2 ⊆ {0, 1}? be the language consisting of all strings that have exactly one more occurrence of 011 substrings than 010 substrings. Prove that L2 is not regular, without using the Pumping Lemma (Hint: use L1 ). 1 1492740742 Page 4 Coderson, Cody Question 3. [30 points (10+10+10)] Fix Σ = {0, 1}. Let L1 ⊆ Σ? be the language of all strings having at least one 0, and L2 ⊆ Σ? be the language of all strings such that their binary representation is not divisible by 3. Construct two DFAs D1 , D2 for L1 , L2 respectively. Using D1 and D2 , give a state diagram of a DFA recognizing L1 ∩ L2 , using only the techniques from class. Using the DFA in the previous part, describe in English, as well as in a state diagram, how to generate a DFA recognizing the symmetric difference of L1 , L2 (strings that belong to exactly one of L1 , L2 ). 1 1492740742 Page 5 Coderson, Cody Question 4. [30 points (15 + 15)] Construct an equivalent NFA for the regular expression (01 ∪ 2)? using only and exactly the methods described in class. Convert the NFA you just created into an equivalent DFA, using only and exactly the methods described in class. 1 1492740742 Page 6 Coderson, Cody Question 5. [30 points (10 + 20)] Construct an equivalent NFA for the following regular grammar, using only the techniques described in class (S is the start variable): S → aA A → ε | bS | bA | aB B → b | aS Then convert the NFA you create into an equivalent regular expression, using only the techniques described in class. Show all steps. 1 1492740742 Page 7 Coderson, Cody Question 6. [15 points (10+5)] Let Σ, Γ be alphabets. A homomorphism, h, is a function from Σ? → Γ? with the property that h(xy) = h(x)h(y) for all x, y ∈ Σ? . If w = w1 · · · wn ∈ Σ? and each wi ∈ Σ, then h(w) = h(w1 ) · · · h(wn ). For any language L ⊆ Σ? , let the homomorphism of L be: h(L) = {h(w) : w ∈ L}. Prove that regular languages are closed under homomorphism. Give an example of a non-regular language L0 and a homomorphism h such that h(L0 ) is regular. 1 1492740742 Page 8 Coderson, Cody Question 1. Let L = {w ∈ {0, 1}? : |w| is a power of n, and n is even}. Prove that L is not context-free. Recall the definition of homomorphism from Midterm #1: let Σ, Γ be alphabets. A homomorphism, h, is a function from Σ? → Γ? with the property that h(xy) = h(x)h(y) for all x, y ∈ Σ? . If w = w1 · · · wn ∈ Σ? and each wi ∈ Σ, then h(w) = h(w1 ) · · · h(wn ). For any language L ⊆ Σ? , let the homomorphism of L be: h(L) = {h(w) : w ∈ L}. Show that context-free languages are closed under homomorphism (Hint: use a CFG, and this is easier than it looks!) 1 1492740742 Page 9 Coderson, Cody Question 2. Complete one (1) of the following two problems. Attempting both will result in a score that is the minimum of both attempts. (a) A backtracking Turing Machine (BTM) is just like a normal TM except that there is another transition that “backtracks”–when taken from state q, this transition instantly resets the tape contents and tape head location to be exactly when the machine was last in state q. If the machine was not in state q before, the tape does not change. Prove that the languages recognized by BTMs are equivalent to those recognized by “stan- dard” (deterministic, single-tape) TMs. (b) A stack Turing machine (STM) is like a normal TM except in every tape cell there is, in addition to a symbol, a stack. On each transition taken, the machine, in addition to modifying the cell’s symbol and move left or right, can push or pop from that individual cell’s stack (or both, or neither, as how a PDA can). If the STM attempts to pop from a cell’s stack that is empty, the computation terminates. Prove that the languages recognized by STMs are equivalent to those recognized by “stan- dard” (deterministic, single-tape) TMs. 1 1492740742 Page 10 Coderson, Cody Question 3. Convert the following CFG into CNF (S is the start variable), using exactly the methods from class. S → aBc | ab B → SB | ε Show all steps. 1 1492740742 Page 11 Coderson, Cody Question 4. Here is the same CFG from Question 3: S → aBc | ab B → SB | ε Convert this CFG into an equivalent PDA, using exactly the methods from class. Suppose we were to convert the above PDA back into an equivalent CFG. Write 5 rules that this resulting CFG would have, using exactly the methods from class: 1 from the first rule type, and 2 from each of the second and third rule types. 1 1492740742 Page 12 Coderson, Cody Question 5. Construct a state diagram of a Turing Machine to recognize the language: {0n #12n #23n : n ≥ 0}. 1 1492740742 Page 13 Coderson, Cody Question 6. Let INFINITEDFA = {hM i : M is a DFA and L(M ) is an infinite language}. Show that this lan- guage is decidable. (Hint: use the decider for EDFA , and the pumping lemma may also help.) Let THREEDFA = {hM i : M is a DFA and M accepts at most 3 strings}. Show that this language is decidable (Hint: use the decider for INFINITEDFA ). 1 1492740742 Page 14 Coderson, Cody Question 1. [35 points (3 each + 2)] Using one of the descriptions empty, finite, regular, CFL, recognized by LBA, decidable, recognizable, and not recognizable to classify languages, indicate the most restrictive class to which each language belongs. No justification is needed. language Member of most restrictive class ... {w ∈ {0, 1}? : #0 (w) = #1 (w)} {hGi : G is a CFG and L(G) 6= ∅} {ai bj ck d` : i + j + k + ` is a multiple of 27} strings representing (non-reversed) accepting computation histories EDF A ∩ IN F IN IT EDF A EQT M ALLCF G 100 10 1010 {w ∈ {0, 1}? : #0 (w) ≤ 8675309, #1 (w) ≤ 1010 } complement of a CFL L1 L2 where L1 , L2 are recognizable language of a PDA that always pops and never pushes on any transition For 2 more points, what is ∅? ∅? 1 1492740742 Page 15 Coderson, Cody Question 2. [40 points (10+15+15)] Let L1 = {w ∈ {0, 1}? : w contains the subsequence 11} and L2 = {w ∈ {0, 1}? : w starts with a 0}. Construct DFAs for L1 and L2 . Construct a DFA for the language L1 ∩ L2 , using exactly the methods from class. Using the DFA you made for L1 , convert it into an equivalent regex, using exactly the methods from class. 1 1492740742 Page 16 Coderson, Cody Question 3. [35 points (20+15)] Consider the following NFA: b, ε q0 q1 a a a, ε a, ε q2 b q3 b Convert this NFA into an equivalent DFA, using exactly the methods from class. Convert the original NFA into an equivalent regular grammar, using exactly the methods from class. 1 1492740742 Page 17 Coderson, Cody Question 4. [40 points (15+25)] Here is a CFG (S is the start variable); convert it to an equivalent PDA using exactly the methods from class. S → aBb B → ac | S | ε Using the same grammar above, convert it to CNF. Show all steps. 1 1492740742 Page 18 Coderson, Cody Question 5. [35 points (6 + 9 + 20)] Let Square(L) = {ww : w ∈ L}, and Double(L) = {wx : w, x ∈ L}. Explain why, in general, Square(L) 6= Double(L). Also say why if L is a CFL, Double(L) is also a CFL. Prove that there is a regular language L for which Square(L) is not a regular language. Prove that there is a CFL L for which Square(L) is not a CFL. 1 1492740742 Page 19 Coderson, Cody Question 6. [40 points (20 + 20)] Let N, k, v, t be positive integers with k ≥ v ≥ t. A perfect hash family (PHF) is an N × k array (N rows, k columns) where each cell has one of v possible symbols and for any t of the k columns, at least one of the rows restricted to those columns has all distinct values. We call t the “strength” of the perfect hash family. Let L = {hN, k, v, ti : there exists a PHF with N rows, k columns, v symbols, and strength t}. Show that L is decidable. Let W EIRDN F A = {hM i : M is an NFA, M has at most 7 states, accepts ε, and L(M ) is infinite}. Show that W EIRDN F A is decidable. 1 1492740742 Page 20 Coderson, Cody Question 7. [35 points (20+15)] Prove that SU P EROBEYT M = {hM1 , M2 i : M1 , M2 are TMs, L(M1 ) ⊆ L(M2 ), and L(M2 ) contains at least 1 more string than L(M1 ) does} is not decidable. (Hint: ETM ) Prove that IN T ERCF LT M = {hM i : M is a TM and L(M ) is the intersection of 2 CFLs, and L(M ) is also a CFL} is not decidable. 1 1492740742 Page 21 Coderson, Cody Question 8. [40 points] Consider all of the language classes we have discussed: empty, finite, regular, context-free, de- cidable, recognizable, enumerable, not recognizable, and languages recognized by LBAs. Draw a single diagram (or several statements) that depicts all containments of these language classes. For each containment that is proper, say class C1 is properly contained in class C2 , indicate two (2) languages that are in C2 but not in C1 . If C1 = C2 for any two classes, indicate why they are equal, or what method we saw that proved they are equal. 1 1492740742 Page 22 Coderson, Cody Question 9. [55 points (20+20+15)] We want to color graphs (maybe it has some obscure application with networks): given a graph G, we can color each vertex with one of k colors. We say that an edge is compatible if both endpoints are assigned different colors. Our goal is to determine: is there such an assignment of colors for which every edge is compatible? When this happens, we say that G is k-colorable. Let kCOLOR be the language: {hG, ki : G is a graph and G is k-colorable}. Show that 3COLOR is NP-complete (Hint: reduce from 3SAT). Show that 3COLOR ≤p 4COLOR. In other words, given an arbitrary graph G, produce a graph G0 so that G is 3-colorable iff G0 is 4-colorable. Show that 1COLOR and 2COLOR are in P. 1 1492740742 Page 23 Coderson, Cody Question 1: (40 points total) For each of the following, if the statement is true, answer “True”; otherwise, answer “False.” If you say true, explain (BRIEFLY) why it is true; if you say false, give a counterexample. All of the points are for the explanation, but you must answer true or false! Each one is worth 4 points. (a) Decidable languages are closed under concatenation. (b) Recognizable languages are closed under complement. (c) A nondeterministic TM accepts an input if and only if all computation paths on that input lead to some accepting configuration. (d) Nondeterministic TMs are computationally equivalent to standard TMs. (e) EQLBA = {hM1 , M2 i : M1 , M2 are LBAs and L(M1 ) = L(M2 )} is undecidable. (f) All regular languages are decidable. 1 1492740742 Page 24 Coderson, Cody (g) If one can show how to increment a number in binary on a TM in a finite amount of time, then one can show the Church-Turing thesis is true. (h) There exists a language L 6= Σ? such that there is a reduction f : L → Σ? (i.e., L ≤ Σ? ). (i) The reason recognizers are required to halt on strings in their language comes from the definition of accepting computation. (j) The minimum number of states allowed in any TM is 1. 1 1492740742 Page 25 Coderson, Cody Question 2: (30 points total) (a) (15 points) My friend counts characters in strings, and does not actually care about what the strings are. He considers the “lengths language” for decidable language L, which is the language len(L) = {1|w| : w ∈ L}. I am skeptical of his claim that len(L) decidable implies L decidable. Is my friend right? Prove or disprove the claim. (b) (15 points) My friend turns to regular languages, and thinks that it is decidable to check, for a given DFA D, whether L(D) ⊆ 1? , even if the alphabet of D contains other characters than just 1. Is my friend right? Prove or disprove the claim. 1 1492740742 Page 26 Coderson, Cody Question 3: (30 points total) (a) (15 points) Recall the acceptance problem AT M = {hM, wi : M accepts input w}. Consider the following language: CHALM ERS = {hM i : M is a TM and L(M ) contains the strings steamed and hams}. Show the reduction AT M ≤ CHALM ERS. Based off of this, what can you conclude about CHALM ERS? (b) (10 points) Can you apply Rice’s theorem to CHALM ERS? If so, do it; if not, explain why you cannot. (c) (5 points) Can you apply Rice’s theorem to SKIN N ER = {hM i : L(M ) contains the strings hM i and Aurora Borealis}? If so, do it; if not, explain why you cannot. 1 1492740742 Page 27 Coderson, Cody Question 4: (30 points total) (a) (5 points) For a language L, briefly justify why, in general, LL 6= {ww : w ∈ L}. (b) (10 points) Construct a DFA for {w ∈ {0, 1, 2}? : w starts with 10, and ends with 2}. (c) (15 points) My friend likes the “majority” problem from pset 1, that if A, B, C are decidable, then the set of strings in at least two of these three languages is also decidable. Show that if A, B, C are regular, then the majority of A, B, C is also regular. 1 1492740742 Page 28 Coderson, Cody Question 5: (20 points total) A stack-added TM (SATM) is a TM with all the usual amenities (change state, move left/right, etc.), but also includes a stack for each cell of the tape, in addition to the symbol already there (the symbol has nothing to do with the contents of the stack). On each transition, in addition to viewing the symbol in the cell as well as write a symbol in the same cell, the SATM can (1) push a symbol into the viewed cell’s stack, (2) pop a symbol from that stack, (3) pop then push from that stack, or (4) neither push nor pop from that stack. We will ensure that the SATM is always deterministic. The elements that can be pushed are from a separate alphabet Π (not necessarily the same as the input or tape alphabet). All of the stacks start empty. If a pop is attempted on an empty stack, the computation stops. (a) (5 points) Give a transition function for an SATM. (b) (5 XC points) Give a formal definition of computation for an SATM for a transition that moves right. (c) (15 points) Do SATMs decide/recognize the same languages as TMs do? Explain. 1 1492740742 Page 29 Coderson, Cody Question 1: (40 points total) For each of the following, if the statement is true, answer “True”; otherwise, answer “False.” If you say true, explain (BRIEFLY) why it is true; if you say false, give a counterexample. All of the points are for the explanation, but you must answer true or false! Each one is worth 5 points. (a) CFLs are closed under the regular operations. (b) Regular languages are closed under symmetric difference. (c) It may be nice to know if my Turing Machine has the same behavior as a DFA (and thus the TM has a regular language); determining if this is the case is decidable. (d) Suppose we want to convert a regular grammar into CNF; then we can avoid one of the 5 steps in the conversion process. 1 1492740742 Page 30 Coderson, Cody (e) F IN IT EDF A = {hM i : M is a DFA and L(M ) is finite} is decidable. (f) EP DA = {hP i : P is a PDA and L(P ) = ∅} is undecidable, and proved similar to the AT M ≤ ELBA reduction. (g) Suppose we applied the PDA to CFG conversion algorithm, without any simplifications, and the PDA had n states originally. Then we cannot know, just from the number of states of the PDA, how many rules the CFG will have. (h) Closure under union and intersection imply closure under complement. 1 1492740742 Page 31 Coderson, Cody Question 2: (40 points total) (a) (20 points total) I want to verify if a given C++ lexical analyzer satisfies a specification for some system, written as an DFA D. The analyzers will be provided as regexes R; I want to check whether all behavior of R is satisfied by D. Formalize the problem as a language. Then answer whether or not this problem is decidable, and explain. (b) (20 points) Suppose now that we have found that D is too prohibitive in size to use, but also want to have additional features for our users. Specifically, we want to check whether a DFA D0 exists such that D0 has the same behavior as D, and accepts strings from a set F given as input, and for D0 to have fewer states than D does. Formalize the problem as a language. Then answer whether or not this problem is decidable, and explain. 1 1492740742 Page 32 Coderson, Cody Question 3: (40 points total) (a) (15 points) Your boss makes the following argument: (1) Any finite language is regular. (2) So, any language containing exactly one string is regular. (3) The language {0α 1β } for fixed integers α, β is regular, since it has exactly one string. (4) Regular languages are closed under union. √ √ (5) The language {0α 1β : α < β OR β < α} is regular because it is a union of regular languages (namely, finite ones); hence, by (4), the language is regular. The “OR” here means either one of these cases hold, or both. √ √ But you know that {0α 1β : α < β OR β < α} is not regular (via the problem below), so at least one of the above statements is wrong. Show (BRIEFLY) where the error(s) is/are, and explain your reasoning. √ √ (b) (25 points) Show that {0α 1β : α < β OR β < α} is not regular. 1 1492740742 Page 33 Coderson, Cody Question 4: (40 points total) (a) (5 points) Construct a regex for all strings in {0, 1}? that start with 0 and end with 1. (b) (15 points) Convert your regex from part (a) into an equivalent NFA. Only the resulting NFA is needed. (c) (20 points) Convert your NFA from part (b) into an equivalent DFA. 1 1492740742 Page 34 Coderson, Cody Question 5: (40 points total) (a) (30 points) For the CFG below, convert it into CNF; show all steps. Here, S is the start variable, e, a are the terminals, and M is a variable. S → Me | a M → SM a | ε (b) (10 points) For the original CFG, convert it into an equivalent PDA. 1 1492740742 Page 35 Coderson, Cody Question 6: (40 points total) (a) (10 points) Construct a DFA for all strings in {0, 1}? that contain 101 as a substring. (b) (30 points) Convert your DFA into an equivalent regex; show all steps. 1 1492740742 Page 36 Coderson, Cody Answer True or False or Open: 1. The number of decidable languages is uncountable. 2. The language {ai bj ck d` : i + j + k + ` is a multiple of 27} is regular. 3. The language {w ∈ {0, 1}? : |w| is a power of n, and n is a positive even integer} is a CFL. 4. N P 6= P SP ACE. 5. EQDF A is not P SP ACE-complete. (Hint: how much storage do you need to solve EQDF A ?) 6. Deterministic context-free languages are closed under reversal (the reversal of a string w = w1 · · · wn is wR = wn · · · w1 , and the reversal of a language is the reversal of all the strings in it). 7. Let L = {0α 1β : α ≤ 2β }. Then L is not regular. 8. Call an NFA ε-free if it does not contain a ε-transition anywhere. Let N be such an NFA, and convert it to D using the “build states as you go” method from class. Then if N has n states, it is possible that D has 2n states, and no DFA D0 exists with L(D0 ) = L(N ) and D0 has 2n − 1 states. 9. Σ? is N P -complete. 10. Enumerable languages are closed under concatenation. 11. ALLDP DA = {hM i : M is an DPDA with L(M ) = Σ? } is in P . 12. SU BLBA = {hM1 , M2 i : M1 , M2 are LBAs and L(M1 ) ⊆ L(M2 )} is in T IM E(2n ). 13. If L is a language, then L? is infinite. 14. The algorithm we discussed in class to solve 3SAT took O(2n n) time. Nevertheless, there is an algorithm that solves 3SAT in o(2n ) time (note: this does not say 2o(n) time, which is an open problem.) 15. If a language L is N P -hard, then L can be undecidable. 16. Let P be a C++ program, and let hP i be the string representation of it. Let L = {hP i : P is a C++ program that compiles without errors}. You can assume that the C++ compiler uses a CFG for parsing. Then L is undecidable. 17. If there is an NFA N with n states with a constant number of input symbols, then there is an equivalent regular expression R for N that the length of R is O(n). 18. Let P C be the set of all languages that have polynomial-time certifiers/verifiers. Then P C = NP. 19. Let N1 , N2 be two NFAs with n1 , n2 states respectively. Then there is a DFA D with at most n1 × n2 states that has the language L(N1 ) ∩ L(N2 ). 20. Let M be a Turing Machine that accepts an input w if and only if there is a DFA that accepts w. Then L(M ) is in T IM E(n). 21. Let B be the problem of deciding if the length of a shortest path in a graph between two given vertices s, t is at most a parameter k, and let C be the problem of deciding if a given 2SAT instance is satisfiable. Then B ≤p C. 22. Let P be a PDA on n states and a constant number of input/stack symbols, and consider converting P to an equivalent CFG G. Then, without simplification of the rules, G will have O(n4 ) rules. 23. Let B be the problem of deciding of a graph has a cycle of length 3 or not (i.e., finding a triangle). Then CLIQU E ≤p B. 1 1492740742 Page 37 Coderson, Cody 24. Consider the problem B of deciding whether a given boolean formula in conjunctive normal form is satisfiable, but any time the formula has a literal x, it does not have the literal x. Then B is N P -complete. 25. If a language L is unary (i.e., L ⊆ {0}? ), we saw in class that L might not be regular. But L? is always regular. 26. If A = B ∪ C and A, B are deterministic context-free, then C is context-free. 27. A CFG is idiotic if all rules are of the form A → wB or A → ε where A, B are variables, and w is a nonempty string. Then the language of every idiotic CFG is regular. 28. A regular grammar is extending if in addition to the four types of rules it may have, it can also have A → Ba where A, B are variables and a is a terminal. Then the language of every extending regular grammar is also regular. 29. Any nontrivial property of the languages of CFGs is undecidable, due to Rice’s theorem. 30. Suppose AT M is decidable. Then EQT M is decidable. 31. Let SU BREG,DCF L = {hM, Di : M is a DFA, D is a DPDA, and L(M ) ⊆ L(D)}. Then SU BREG,DCF L is undecidable. 32. The Time Hierarchy theorem implies that T IM E(n) 6= T IM E(n log n). 33. If a language L is recognizable and L is recognizable, then L can be decided by an LBA. 34. The complement of a CFL is decidable. 35. Suppose I have a CFG G with n terminals and m variables that, for any rule in G, the rule contains at most 10 terminals or variables (or a mix of both) on the RHS. Now convert G into a CFG G0 in CNF without simplifying. Then one can now precisely determine the number of rules in G0 . 36. For any language L, {www : w ∈ L} is equal to LLL. 37. We want to color graphs (maybe it has some obscure application with networks): given a graph G, we can color each vertex with one of k colors. We say that an edge is compatible if both endpoints are assigned different colors. Our goal is to determine: is there such an assignment of colors for which every edge is compatible? When this happens, we say that G is k-colorable. Let kCOLOR be the language: {hG, ki : G is a graph and G is k-colorable}. Then 2COLOR is N P -complete. 38. Same setup as the previous question; you may assume without proof that 3COLOR is N P - complete. Then, 3COLOR ≤p 4COLOR. 39. I have a Turing Machine model where the machine, on input w, can never write a different symbol over where w is, but can write any symbol past where w is on the tape. In other words, the input w never “changes.” Then this variant is equivalent to the standard model. 40. If the polynomial hierarchy (P H) collapses (i.e., has finitely many levels), then P H = P SP ACE. 1 1492740742 Page 38 Coderson, Cody 1. For a type T of machines, AT = {hM, wi : M is a machine of type T and w ∈ L(M )}. Then (a) ADFA , APDA , ALBA , and ATM are undecidable. (b) ADFA , APDA , ALBA , and ATM are decidable. (c) ADFA , APDA , and ALBA are decidable but ATM is undecidable. (d) ADFA and APDA are decidable but ALBA and ATM are undecidable. (e) ADFA is decidable but APDA , ALBA and ATM are undecidable. 2. For a type T of machines, ET = {hM i : M is a machine of type T and L(M ) = ∅}. Then (a) EDFA , EPDA , ELBA , and ETM are undecidable. (b) EDFA , EPDA , ELBA , and ETM are decidable. (c) EDFA , EPDA , and ELBA are decidable but ETM is undecidable. (d) EDFA and EPDA are decidable but ELBA and ETM are undecidable. (e) EDFA is decidable but EPDA , ELBA and ETM are undecidable. 3. For a type T of machines, EQT = {hM1 , M2 i : M1 , M2 are machines of type T and L(M1 ) = L(M2 )}. Then (a) EQDFA , EQLBA , and EQTM are undecidable. (b) EQDFA , EQLBA , and EQTM are decidable. (c) EQDFA and EQLBA are decidable but EQTM is undecidable. (d) EQDFA is decidable but EQLBA and EQTM are undecidable. (e) The answer depends on whether P = N P or not. 4. Rice’s theorem implies that (a) No property of a Turing machine’s language is decidable. (b) Exactly two properties of a Turing machine’s language are decidable. (c) Basmati goes best with curry. (d) The Church-Turing thesis is true. (e) No property of a Turing machine is decidable. 5. Anaconda Corporation has announced a new product that, when given a Python program P as input, can determine whether P can go into an infinite loop on any input. Which of the following is true? (a) The Church-Turing thesis says they are wrong. (b) Their product might work because it only handles Python programs. (c) Their product might work if it has a library of every possible Python program. (d) Their product does not work because Python programs can be converted to Turing machines. (e) Anaconda Corporation is scamming me because they are snakes. 6. Deterministic and nondeterministic machines are equivalent for (a) none of finite automata, pushdown automata, and Turing machines. (b) finite automata but not pushdown automata or Turing machines. (c) finite automata, pushdown automata, and Turing machines. (d) finite automata and pushdown automata, but not Turing machines. (e) finite automata and Turing machines but not pushdown automata. 1 1492740742 Page 39 Coderson, Cody 7. Machines that can enter an infinite loop include: (a) PDA, LBA, TM, and NTM but not DFA, NFA, or DPDA. (b) NFA, PDA, TM, and NTM but not DFA, DPDA, or LBA. (c) NFA, DPDA, PDA, LBA, TM, and NTM but not DFA. (d) NFA, DPDA, PDA, TM, and NTM but not DFA or LBA. (e) TM and NTM but not DFA, NFA, DPDA, PDA, or LBA. 8. Even if a machine enters an infinite loop on some input, an equivalent machine of the same type may exist that never loops infinitely. The existence of such an equivalent machine can be guaranteed for (a) DPDA, PDA, LBA, TM, and NTM. (b) DPDA, PDA, TM, and NTM but not LBA. (c) DPDA and TM, but not PDA, LBA, or NTM. (d) DPDA, PDA, and LBA but not TM or NTM. (e) DPDA but not PDA, LBA, TM, or NTM. 9. The halting problem is undecidable. This means that (a) For every program P and every input w, there is no algorithm to decide whether P terminates on input w. (b) Turing machines are not as powerful as programs in Java. (c) For every program P , there is some input w so that there is no algorithm to decide whether P terminates on input w, but (a) is not true. (d) There is no algorithm to decide whether P terminates on input w when P and w are both provided as input, but (c) is not true. (e) There is an algorithm to decide whether P terminates on input w when P and w are both provided as input, but (b) is not true. 10. In software testing, given a program as input, we want to find a set of inputs to ensure that every statement of code is executed. (a) This can be done when the program is in C++ but not always for other programming languages. (b) This can never be done because of the Church-Turing thesis. (c) There is no algorithm to decide whether this can be done or not. (d) No one cares about code coverage. (e) This can always be done because of the Church-Turing thesis. 11. Classes of languages that are closed under intersection include: (a) context-free, decidable, and recognizable. (b) decidable and recognizable but not context-free (c) recognizable but not context-free or decidable (d) decidable but not context-free or recognizable (e) not context-free, decidable, or recognizable. 12. Classes of languages that are closed under complementation include: (a) context-free, decidable, and recognizable. (b) decidable and recognizable but not context-free 1 1492740742 Page 40 Coderson, Cody (c) recognizable but not context-free or decidable (d) decidable but not context-free or recognizable (e) not context-free, decidable, or recognizable. 13. Classes of languages that are closed under union include: (a) context-free, decidable, and recognizable. (b) decidable, and recognizable but not context-free (c) recognizable but not context-free or decidable (d) decidable but not context-free or recognizable (e) not context-free, decidable, or recognizable. 14. The intersection of a context-free language and a regular language (a) must be regular but may not be finite. (b) must be context-free and cannot be regular. (c) must be context-free but may also be regular. (d) must be finite but may not be empty. (e) must be empty. 15. A class of languages is closed under subsets if whenever L is in the class and L0 ⊆ L, L0 is also in the class. The classes that are closed under subsets include: (a) regular, context-free, decidable, and recognizable. (b) regular, decidable, and recognizable but not context-free (c) none of regular, context-free, decidable, or recognizable. (d) regular and decidable but not context-free or recognizable. (e) regular but not context-free, decidable, or recognizable. 16. We have been assigned the task of selecting an interface language for a device controller. Two proposals have been made. The first, method Eh, uses C++ as the language. The second, method Bee, uses regular expressions. Without knowing the details of either method, but based on your knowledge of CSE 355, a primary benefit of Eh over Bee is (a) Eh does not make a buzzing sound when it runs. (b) Eh can compute everything that Bee can, and more. (c) Eh is conceptually simpler than Bee. (d) Eh is faster than Bee. (e) Eh has a bigger installed code base than Bee. 17. Same setup as the previous question. A primary benefit of Bee over Eh is (a) Bee requires fewer computational resources than Eh. (b) Bee makes a very pleasant buzzing sound when it runs. (c) Bee is conceptually simpler than Eh. (d) Bee costs less than Eh. (e) Bee is faster than Eh. 18. Same setup as the previous question. Now I find out that my device controller controls a disk, and needs to know how many reads have occurred since the last write to disk. Then (a) I cannot use Eh because it is not able to keep track of the count of reads. 1
Enter the password to open this PDF file:
-
-
-
-
-
-
-
-
-
-
-
-