SOLUTIONS.
(1)
Let
G
be the following contextfree grammar, with
V
=
{
S, A
}
,
T
=
{
a, b
}
.
S
→
ASb

Ab
A
→
a

λ
(a)
Find an npda
M
such that
L
(
M
)=
L
(
G
).
SOLUTION:
F
=
{
q
f
}
.
δ
(
q
0
,λ,z
)=
{
(
q
1
,Sz
)
}
δ
(
q
1
,λ,S
)=
{
(
q
1
,ASb
)
,
(
q
1
,Ab
)
}
δ
(
q
1
,λ,A
)=
{
(
q
1
,a
)
,
(
q
1
,λ
)
}
δ
(
q
1
,a,a
)=
{
(
q
1
,λ
)
}
δ
(
q
1
,b,b
)=
{
(
q
1
,λ
)
}
δ
(
q
1
,λ,z
)=
{
(
q
f
,λ
)
}
(b)
Give a
leftmost
derivation from
G
of the string:
abbb
.
(WARNING: Make sure your derivation is leftmost.)
SOLUTION:
S
⇒
ASb
⇒
aSb
⇒
aASbb
⇒
aSbb
⇒
aAbbb
⇒
abbb
.
(c)
Give the corresponding sequence of instantaneous descriptions for
M
.
SOLUTION:
(
q
0
, abbb, z
)
‘
(
q
1
, abbb, Sz
)
‘
(
q
1
, abbb, ASbz
)
‘
(
q
1
, abbb, aSbz
)
‘
(
q
1
, bbb, Sbz
)
‘
(
q
1
, bbb, ASbbz
)
‘
(
q
1
, bbb, Sbbz
)
‘
(
q
1
, bbb, Abbbz
)
‘
(
q
1
, bbb, bbbz
)
‘
(
q
1
, bb, bbz
)
‘
(
q