CS 341: Foundations of Computer Science II
Prof. Marvin Nakayama
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.
Answer:
Each element in
B
is an infinite sequence
(
b
1
, b
2
, b
3
, ...
)
, where each
b
i
∈ {
0
,
1
}
.
Suppose
B
is countable.
Then we can define a correspondence
f
between
N
=
{
1
,
2
,
3
,...
}
and
B
.
Specifically, for
n
∈ N
, let
f
(
n
) =
(
b
n
1
, b
n
2
, b
n
3
, ...
)
, where
b
ni
is the
i
th bit in the
n
th sequence, i.e.,
n
f
(
n
)
1
(
b
11
, b
12
, b
13
, b
14
, b
15
, ...
)
2
(
b
21
, b
22
, b
23
, b
24
, b
25
, ...
)
3
(
b
31
, b
32
, b
33
, b
34
, b
35
, ...
)
4
(
b
41
, b
42
, b
43
, b
44
, b
45
, ...
)
.
.
.
.
.
.
Now define the sequence
c
= (
c
1
, c
2
, c
3
, c
4
, c
5
, ...
)
∈ B
over
{
0
,
1
}
, where
c
i
= 1
−
b
ii
. In other words, the
i
th bit in
c
is the opposite of the
i
th bit in the
i
th sequence. For example, if
n
f
(
n
)
1
(0
,
1
,
1
,
0
,
0
,...
)
2
(1
,
0
,
1
,
0
,
1
,...
)
3
(1
,
1
,
1
,
1
,
1
,...
)
4
(1
,
0
,
0
,
1
,
0
,...
)
.
.
.
.
.
.
then we would define
c
= (1
,
1
,
0
,
0
,...
)
. Thus,
c
∈ B
differs from each sequence
by at least one bit, so
c
does not equal
f
(
n
)
for any
n
, which is a contradiction.
Hence,
B
is uncountable.
2. Recall that
EQ
CFG
=
{ (
G
1
,G
2
) |
G
1
and
G
2
are CFGs and
L
(
G
1
) =
L
(
G
2
)
}
.
Show that
EQ
CFG
is undecidable.
Answer:
We will reduce
ALL
CFG
to
EQ
CFG
, where
ALL
CFG
=
{ (
G
) |
G
is a CFG and
L
(
G
) = Σ
∗
}
.
Sipser shows that
ALL
CFG
is undecidable.
1