Assign 3 Ans
Assign 3 Ans
1
D = “On input hM i,
1. Construct an NFA M 0 such that L(M 0 ) = {wR | w ∈ L(M )}
2. Convert M 0 into an equivalent DFA M 00
3. Use C to compare L(M 00 ) and L(M )
4. If L(M 00 ) = L(M ), accept. Else, reject.
In the above TM, Step 1 can be done by converting M into M 0 in finite steps. The
idea is to (i) reverse the directions of all transition arrows in M , (ii) create a new
state q 0 in M 0 , and connects q 0 to each original final states of M with ε-transitions,
and (iii) make the original start state of M a final state of M 0 . It is easy to check
that L(M 0 ) = {wR | w ∈ L(M )}.
Also, both Step 2 and Step 3 can be done in finite steps, as we learnt from the lectures
(See Notes 4 pages 13–15, and Notes 12 pages 16–17). So, D runs in finite steps and
is thus a decider.
4. Ans. Let P ALDF A = {hM i | M is a DFA that accepts some palindrome}. To show
P ALDF A is decidable, we construct a decider D for P ALDF A as follows (Let K be a
TM that decides ECF G ):
D = “On input hM i,
1. Construct a PDA P such that L(P ) = {w | w is a palindrome}
2. Construct a PDA P 0 such that L(P 0 ) = L(P ) ∩ L(M )
3. Convert P 0 into an equivalent CFG G
4. Use K to check if L(G) is empty.
5. If L(G) is empty, reject. Else, accept.
In the above TM, Step 1 can be done in finite steps. Step 2 is based on Prob 2.18 and can
be done in finite steps. Step 3 is the conversion of PDA into an equivalent CFG, which can
be done in finite steps (See Notes 8, pages 28–34). Step 4 is done in finite steps, because
the decider K can check whether the language of a CFG is empty (For the existence of K,
see Notes 12, pages 20–21). In summary, D runs in finite steps for any input, and is thus
a decider.
In this problem, we are given a decider D that decides if the language of a CFG is infinite.
Then, we can show that C is decidable, by finding a corresponding decider F as follows:
2
4. Set count to be 0.
5. For x = 1, 2, . . . , p
i. For all string s with length = x,
Check if s can be generated by G; if so, increment count by 1.
6. If count = k, accept. Else, reject.
In the above TM F , Steps 1–2 correctly answer the case where L(G) is an infinite set, or
k = ∞. So, after Step 2, we only deal with a grammar G whose language is a finite set,
and our task is to check whether the language size is exactly k. To do so, the loop in Step
5 counts all string that can be generated by G, whose length is at most the pumping length
p. Because we know that L(G) is finite, we are sure that no strings of L(G) can be longer
than p. In other words, the value count correctly computes the exact number of strings in
L(G). So, Step 6 can check correctly answer the case when L(G) is finite, and k is finite.
Finally, it is easy to check that each step runs in finite number of steps. Thus, F is a
decider, so that C is a decidable language.