CS 341 Automata Theory
Elaine Rich
Homework 8
Due Thursday, Oct. 26
1)
Prove that the grammar
G
= {{
S
,
a
,
b
}, {
a
,
b
},
R
,
S
}, where
R
=
{
S
→
a
S
a
,
S
→
b
S
b
,
S
→
ε
}
correctly defines the language {
ww
R
:
w
∈
{
a
,
b
}*}.
2)
Build a PDA for each of the following languages:
a)
L
= {
a
n
b
m
:
m
≥
n
,
m

n
is even}
(a)
L
= {
x
c
n
:
x
∈
{
a
,
b
}*, #
a
(
x
) =
n
or #
b
(
x
) =
n
}
b)
L =
{
w
∈
{0, 1}* : every 0 has a matching 1 somewhere}.
No 1 can match more than one 0.
So 10, 101011
∈
L
, but 001
∉
L
.
c)
L
= {
a
n
b
m
:
m
≤
n
≤
2
m
}
d)
L
=
L
1
*, where
L
1
= {
xx
R
:
x
∈
{
a
,
b
}*}
3)
Show that the CF languages are closed under the operation
pref
defined on any language
L
over
some alphabet
Σ
:
pref
(
L
) = {
w
:
5
x
∈
Σ
*,
wx
∈
L
}
(Hint:
You can do this using either grammars or PDAs.
If you choose to use grammars, you
may wish to begin by converting the grammar to Chomsky Normal Form.)
4)
In class, I asserted that the class of languages accepted by PDAs that accept by accepting state is
equivalent to the class accepted by PDAs that accept by accepting state and empty stack.
I
proved half of that assertion (that for every accepting state/empty stack PDA there is an
equivalent accepting state one).
Prove the other half.
5)
For each of the following grammars
G
, construct an unambiguous grammar for
L
(
G
).
a)
G
= ({
S
,
a
,
b
}, {
a
,
b
},
R
,
S
), where
R
=
S
→
ε
S
→
a
S
a
S
→
b
S
b
S
→
SS
b)
G
= ({
S
,
a
,
b
}, {
a
,
b
},
R
,
S
), where
R
=
S
→
ε
S
→
a
S
a
S
→
b
S
b
S
→
a
S
b
S
→
b
S
a
S
→
SS
6)
Convert the following grammar to Chomsky normal form:
G
= ({
S
,
T
,
V
,
a
,
b
,
c
}, {
a
,
b
,
c
},
R
,
S
), where
R
=
S
→
a
TV
a
T
→
a
T
a

b
T
b

ε

V
V
→
c
V
c

ε