Convert a PDA to a CFG

609 Views Asked by At

My professor doesn't do a very good job at explaining the process of converting a PDA to a CFG. Can someone help explain it?

The way I see it (but it produces wrong results) is each production is created by an instruction. And if it is a push instruction, then the production is the items on the stack plus the input symbol. And if it is a pop instruction, then the symbol is just the input symbol.

So (a,X)/push(a) would produce X --> aAX

Then say I had b,a/pop would produce A --> b

I have an example problem. I believe the correct solution is

S --> $lambda$ | aSa | bSb

enter image description here