Professional Documents
Culture Documents
Homework 9 Solutions
Homework 9 Solutions
Homework 9 Solutions
1. Let B be the set of all infinite sequences over {0, 1}. Show that B is uncountable,
using a proof by diagonalization.
n f (n)
1 (b11 , b12 , b13 , b14 , b15 , . . .)
2 (b21 , b22 , b23 , b24 , b25 , . . .)
3 (b31 , b32 , b33 , b34 , b35 , . . .)
4 (b41 , b42 , b43 , b44 , b45 , . . .)
.. ..
. .
2. Recall that EQCFG = { hG1 , G2 i | G1 and G2 are CFGs and L(G1 ) = L(G2 ) }.
Show that EQCFG is undecidable.
1
Define CFG G0 = (V, Σ, R, S), where V = {S} and S is the starting variable. There
is a rule S → `S in R for every terminal ` ∈ Σ. Also, G0 includes the rule S → ε.
For example, if Σ = {a, b}, then the rules in G0 are S → aS | bS | ε. It is easy to see
that L(G0 ) = Σ∗ .
Let R be a TM that decides EQCFG and construct TM S to decide ALLCFG . Then
S works in the following manner.
S = “On input hGi, where G is a CFG:
1. Run R on input hG, G0 i, where G0 is the CFG defined above
with L(G0 ) = Σ∗ .
2. If R accepts, accept. If R rejects, reject.”
2
Why did we convert the CFGs into Chomsky normal form? The reason is that there
is a procedure that always halts for checking whether a CFG in Chomsky normal form
can generate a particular string w or not.