Objectives:
| Explain in your own words how the additional PDA transitions are added and why this creates an equivalent PDA. |
Open file ex9.2 in the PDA editor. We want a CFG which recognizes
this language. Select Convert to grammar. Oops! You
get an error message because the NPDA is not in the correct format.
Correct this by adding another state and replace the transition with two:
One that goes from q1 to the new state and pushes two symbols "xb"
where x is just an added symbol (b,a;xb). Then another which goes from
the new state to q2 and pops the x (l,x;l).
Try the conversion again with the fixed NPDA. We are now ready to
convert to a CFG. Variables in the grammar will be represented in the
form (qi, A, qj) where qi and qj represent states from the NPDA and A is a
stack symbol. The meaning of this variables is "if when moving along a
path from state qi to state qj, the stack is exactly the same except that A
is removed from the stack". The start variable S will be represented
by our goal (q0, Z,q4)
The full algorithm is given on pp190-194 of
your text. It is kind of messy but basically, for each transition from
(qi,a,A) to qj which pops the A,
generate one production (qi, A, qj) -> a
For each transition of the form (qi,a,A) to qj which pops the A and
pushes BC, generate the productions
(qiAqk)-> a(qjBql)(qlCqk) for all qk and ql.
This should create a grammar that starts
with the goal and works backwards to generate the input. Test it out
with the Hints from JFLAP. Then export the grammar and test both the
original NPDA and the grammar to assure yourself that they are equivalent.