


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Fall 2009 Test 1 practice questions
Closed book test. You can bring a sheet with notes on both sides. You can cite/use without re-proving: (a) Theorems, Lemmas, and Examples either covered in the class or covered in chapters 1 through 4 of the text, (b) Problems and exercises from Chapters 1 and 2 of the text, and (b) Home work problems from this course. You may not use any other source. Please state your assumptions. Please write neat, legible, precise, and succinct answers.
(a) Any subset of a decidable language is also decidable. False. Σ∗^ is a decidable language (it is regular). Further, any language is a subset of Σ∗. In particular, AT M ⊂ Σ∗, which is not decidable (Theorem 4.9 of the book). (b) Turing recognizable sets are closed under complement. False. The set AT M is Turing-recognizable, but the set A¯T M is not (Theorem 4.17 of the book). In general, the complement of any undecidable but Turing-recognizable language is not Turing-recognizable (deduce from Theorem 4.19 of the book). (c) If A and B are undecidable then so is A ∪ B. False. As in part (c) above, both A = AT M and B = A¯T M are undecidable, but Σ∗^ = A
⋃ B is clearly decidable. (d) The language N OT EM P T YCFG = {G | G is a context − free grammar and L(G) is not empty is undecidable. False. The given language is the complement of the decidable language EM P T YCFG = {G | G is a context − fre and decidable languages are closed under complement.
(a) Show that N EM P T YT M is recognizable. Construct a deterministic Turing machine A which recognizes N EM P T YT M. Let s 1 , s 2 , · · · be a list of all strings in Σ∗^ in lexicographic order. The machine A repeats the following for i = 1 , 2 , 3 ,.. .:
1.1 Run M for i steps on the strings s 1 , s 2 , · · · , si. 1.2 If any computations accept then accept. If L(M ) is not empty then it accepts some string sj in some k steps for some j and k. The string sj will get generated and M will be run on sj for k steps eventually. On the other hand, if L(M ) is empty, the machine A runs forever. Hence it recognizes the given language. (b) Is EM P T YT M recognizable? Why? No, because if both a language and its complement are Turing-recognizable, then both languages are decidable (Theorem 4.16 in the book). By part (a) above, N EM P T YT M is recognizable, but by the assumption in the question EM P T YT M is undecidable. Hence EM P T YT M must be Turing non- recognizable, because otherwise both will be decidable.
(a) Is N EQCF G decidable? Why? No, because decidable languages are closed under complement (just reverse the output of the Turing machine recognizing L). Hence, if N EQCF G is decidable, then EQCF G will also be decidable. (b) Show that N EQCF G is recognizable. Construct a deterministic Turing machine M which recognizes N EQCF G. By Theorem 4.6 in the book, for every context-language G, the language ACF G(G) = {< G, w > |G generates w} is decidable. M first constructs two Turing machines M (G) and M (H) for ACF G(G) and ACF G(H) respectively. Next M goes over all strings in x ∈ Σ∗^ in the following manner: it first enumerate all strings of length l, before proceeding to strings of length l + 1. All strings of length l, it enumerates in lexicographic order. This can easily be achieved by simulating a binary counter on the tape. For each string x thus enumerated, it checks whether M (G) accepts < G, x > and also, whether M (H) accepts < H, x >. If the answer to one question is yes, while that for the other is no, it outputs accept. Otherwise, if the answer to both questions is the same (whether both yes or both no), it goes on to the next string. Clearly if L(G) 6 = L(H), the machine will accept at the first string which belongs to their symmetric difference L(G) 4 L(H) = (L(G)\L(H))
⋃ (L(H)\L(G)). On the other hand if L(G) = L(H), the machine loops on forever. Hence it recognizes the given language. (c) Is EQCF G recognizable? Why? No, because if both a language and its complement are Turing-recognizable, then both languages are decidable (Theorem 4.16 in the book). By part (b) above, N EQCF G is recognizable, but by the assump- tion in the question EQCF G is undecidable. Hence EQCF G must be Turing non-recognizable, because otherwise both will be decidable.
{〈G, x〉 | G is a context − free grammar that generates some string w, where x is a substring of w}
Consider the language Lx = {w|x is a substring of w}. Clearly, Lx is a regular language since Lx = {uxv | u, v ∈ Σ∗} and is accepted by a DFA Dx. (An NFA Nx for Lx loops on the initial and final state and has a path of length |x|. This NFA can be converted to a DFA Dx.) Here is a Turing machine which decides the given language:
(a) On input < G, x >, first construct DFA Dx. (b) Construct a PDA M for G. (c) Construct a PDA M ′^ for the language L(M ) ⋂^ L(Dx) (the intersection of a PDA and a DFA is again a PDA). (d) Construct a context-free grammar G′^ for L(M ′) (Lemma 2.15 of the book). (e) Check whether L(G′) is non-empty i.e., L(G) 6 = φ (ECF G is decidable, Theorem 4.7 of the book). (f) If L(G′) 6 = φ accept, otherwise reject.
This is true because < G, x > belongs to the given language iff L(G)
⋂ Lx is non-empty.