Search code examples
context-free-grammarcomputation-theorypushdown-automatoncontext-free-language

can i push two symbols to the stack of a pushdown automata?


I would like to know if for a given pushdown automata, where the initial symbol or Z0 is y, can i stack two Xs when i read 'a' from chain of strings during a transition?

Say that i have a transition function as it follows: (s1, a, y) -> (s2, e, xxy). Is such transition valid? Here's a paint image for better understanding in-case it's still not clear.

enter image description here

where Z0 = Y


Solution

  • This is really a question of how you're defining PDAs - what conventions do you choose to use. Typically, I think the convention is that one transition pushes one symbol. However, allowing arbitrary strings to be pushed adds no power to the PDA model (although it can reduce the number of required states). To see this, take any PDA that pushes strings of length greater than one onto the stack. This PDA can be transformed into a PDA that pushes strings of length at most one onto the stack by introducing additional states with empty/lambda/epsilon transitions to push one symbol at a time. This doesn't even turn DPDAs into NPDAs since there will still only be at most one transition possible at any given time in the new PDA if that was the case before the transformation.

    In fact, the construction used to show PDAs can accept the languages of CFGs explicitly relies on being able to push strings of arbitrary length in one transition. That construction works by pushing the start symbol and then nondeterministically pushing productions for nonterminals. Since the RHS of productions are typically longer than one symbol, the construction would be much uglier if the resulting PDA had to have separate paths of states for every production. By allowing the pushing of strings of arbitrary length, the construction generates a two-state NPDA for any CFG.