Docsity

Quiz 1 Computability, Algorithms, and Complexity | CS 6505, Quizzes of Computer Science

Toggle sidebar
bg1
Computability, Algorithms, and Complexity
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.
1. Answer TRUE/FALSE and give very brief justification.
(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 ¯
AT 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 Aand Bare undecidable then so is A∪B.
False. As in part (c) above, both A=AT M and B=¯
AT M are undecidable, but Σ∗=ASBis clearly
decidable.
(d) The language N OT E MP T YCFG ={G|Gis 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|Gis a context −free grammar and L(G) is not empty}
and decidable languages are closed under complement.
2. Show that a language Lis decidable if and only if some enumerator enumerates the language in lexicographic
order. (Assume that Lis an infinite language.)
Let Ebe an enumerator that enumerates the strings of Lin lexicographic order. Lis assumed to be infinite.
A decider Don input wdoes the following: Repeat running Euntil either Eoutputs wor outputs a string
whose length is greater than w. If w6∈ L, the enumerator has to output a string longer than weventually
since Lis infinite. In the former case halt and accept and in the latter case, halt and reject.
Given a decider Dfor L. An enumerator Egenerates strings siin lexicographic order, use Dto decide if si
is Lor not, and output siif Daccepts si.
3. Let EM P T YTM ={hMi | Mis a 1 −tape DTM and L(M) is empty}.
Assume as given that this language is undecidable. Let N EM P T YT M be the complement of the language
EM P T YT M . That is,
N EM P T YT M ={hMi | Mis a 1 −tape DTM and L(M) is NOT empty}.
(a) Show that N EM P T YTM is recognizable.
Construct a deterministic Turing machine Awhich recognizes N EM P T YT M .
Let s1, s2,· · · be a list of all strings in Σ∗in lexicographic order.
The machine Arepeats the following for i= 1,2,3, . . .:
1
pf3
pf4

Partial preview of the text

Download Quiz 1 Computability, Algorithms, and Complexity | CS 6505 and more Quizzes Computer Science in PDF only on Docsity!

Computability, Algorithms, and Complexity

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.

  1. Answer TRUE/FALSE and give very brief justification.

(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.

  1. Show that a language L is decidable if and only if some enumerator enumerates the language in lexicographic order. (Assume that L is an infinite language.) Let E be an enumerator that enumerates the strings of L in lexicographic order. L is assumed to be infinite. A decider D on input w does the following: Repeat running E until either E outputs w or outputs a string whose length is greater than w. If w 6 ∈ L, the enumerator has to output a string longer than w eventually since L is infinite. In the former case halt and accept and in the latter case, halt and reject. Given a decider D for L. An enumerator E generates strings si in lexicographic order, use D to decide if si is L or not, and output si if D accepts si.
  2. Let EM P T YTM = {〈M 〉 | M is a 1 − tape DTM and L(M ) is empty}. Assume as given that this language is undecidable. Let N EM P T YT M be the complement of the language EM P T YT M. That is, N EM P T YT M = {〈M 〉 | M is a 1 − tape DTM and L(M ) is NOT empty}.

(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.

  1. Let EQCF G = {< G, H > | G and H are CFGs and L(G) = L(H)}. Assume as given that this language is undecidable. Let N EQCF G be the complement of the language EQCF G. That is, N EQCF G = {< G, H > | G and H are CFGs and L(G) 6 = L(H)}.

(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.

  1. Let a k-PDA be a pushdown automaton that has k stacks. Thus a 0-PDA is an NFA and a 1-PDA is a conventional PDA. We know that 1-PDAs recognize languages that are not recognizable by a 0-PDA. Show that a 2-PDA P can simulate a 1-tape DTM M using the following steps:
  1. Show that the following language is 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.