CS 341 Automata Theory
Elaine Rich
Homework 9
Due Thursday, Nov. 2 at11:00
1)
Build a
deterministic
PDA that accepts
L
$, where
L
= {
w
∈
{
a
,
b
}* : #
a
(
w
) = #
b
(
w
)}.
2)
Determine, for each of the following languages, whether it is (I) Regular, (II) Context free but not regular, or
(III) not context free.
Prove your answer.
a)
L
= {(
ab
)
n
a
n
b
n
:
n
> 0}
b)
L
= {
a
i
b
n
:
i
,
n
> 0 and
i
=
n
or
i
= 2
n
}
(a)
L
= {
xy
:
x
,
y
∈
{
a
,
b
}* and 
x
 = 
y
}
c)
L
= {
xwx
R
:
x
,
w
∈
{0, 1}
+
}
d)
L
= {0
i
1
j
:
i
,
j
≥
0 and
j
=
i
2
}
e)
L
=
¬
L
0
, where
L
0
= {
ww
:
w
∈
{
a
,
b
}*}
3)
Consider the language
L
= {
ba
m
1
ba
m
2
b
…
ba
mn
:
n
≥
2,
m
1, …,
mn
≥
0, and
mi
≠
mj
for some
i
,
j
}
a) Give a PDA that accepts
L
.
b) Write a contextfree grammar that generates
L
.
c) Prove that
L
is not regular.
4)
Give an example of a contextfree language
L
(
≠Σ
*) that contains a subset
L
1
that is not contextfree.
Prove
that
L
is context free.
Describe
L
1
and prove that it is not contextfree.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentCS 341 Automata Theory
Elaine Rich
Homework 9
Answers
1)
Build a
deterministic
PDA that accepts
L
$, where
L
= {
w
∈
{
a
,
b
}* : #
a
(
w
) = #
b
(
w
)}.
The idea is to use a bottom of stack marker so that
M
can tell what it should be counting.
If the top of the stack is an
a
, it is counting
a
’s.
If the top of the stack is a
b
, it is counting
b
’s.
If the top of the stack is #, then it isn’t counting
anything yet.
So if it is reading an
a
, it should start counting
a
’s.
If it is reading a
b
, it should start counting
b
’s.
M
= ({0, 1, 2}, {
a
,
b
}, {
a
,
b
}, 0, {2},
∆
), where
∆
=
{((0,
ε
,
ε
), (1, #)),
((1, $, #),(2,
ε
)),
/* starting and ending.
((1,
a
,
a
), (1,
aa
)),
((1,
b
,
a
), (1,
ε
)),
/* already counting
a
’s.
((1,
a
,
b
), (1,
ε
)),
((1,
b
,
b
), (1,
bb
)),
/* already counting
b
’s.
((1,
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 Rich
 #, Formal language, l. b, odd length, Elaine Rich Homework

Click to edit the document details