Hwsoln 08
Hwsoln 08
Homework 8 Solutions
1. Consider the decision problem of testing whether a DFA and a regular expression are
equivalent. Express this problem as a language and show that it is decidable.
Recall that the proof of Theorem 4.5 defines a Turing machine F that decides the
language EQDFA = { hA, Bi | A and B are DFAs and L(A) = L(B) }. Then the
following Turing machine T decides C:
2. Consider the decision problem of testing whether a CFG generates the empty string.
Express this problem as a language and show that it is decidable.
1
G′ does not include the rule S ′ → ε, then ε 6∈ L(G′ ). Thus, a Turing machine that
decides AεCFG is as follows:
M = “On input hGi, where G is a CFG:
1. Convert G into an equivalent CFG G′ = (V ′ , Σ, R′ , S ′ )
in Chomsky normal form.
2. If G′ includes the rule S ′ → ε, accept. Otherwise, reject.”
3. Let Σ = {0, 1}, and consider the decision problem of testing whether a regular
expression with alphabet Σ generates at least one string w that has 111 as a substring.
Express this problem as a language and show that it is decidable.
Answer: The language of the decision problem is
A = { hRi | R is a regular expression describing a language over Σ containing
at least one string w that has 111 as a substring
(i.e., w = x111y for some x and y) }.
Define the language C = { w ∈ Σ∗ | w has 111 as a substring }. Note that C is a
regular language with regular expression (0 ∪ 1)∗ 111(0 ∪ 1)∗ and is recognized by
the following DFA DC :
0 0, 1
1
1 1
1 2 3 4
0
0
2
4. Consider the emptiness problem for Turing machines:
(Actually, ETM also contains all hM i such that hM i is not a valid Turing-machine
encoding, but we will ignore this technicality.)
Answer: We need to show there is a Turing machine that recognizes ETM , the com-
plement of ETM . Let s1 , s2 , s3 , . . . be a list of all strings in Σ∗ . For a given Turing
machine M , we want to determine if any of the strings s1 , s2 , s3 , . . . is accepted by
M . If M accepts at least one string si , then L(M ) 6= ∅, so hM i ∈ ETM ; if M
accepts none of the strings, then L(M ) = ∅, so hM i 6∈ ETM . However, we cannot
just run M sequentially on the strings s1 , s2 , s3 , . . .. For example, suppose M accepts
s2 but loops on s1 . Since M accepts s2 , we have that hM i ∈ ETM . But if we run M
sequentially on s1 , s2 , s3 , . . ., we never get past the first string. The following Turing
machine avoids this problem and recognizes ETM :