Might merge with Context-Free Languages

Transitions

A key thing to remember is that PDAs work non-deterministically

With PDAs, our transitions need to capture reading in symbols but also modifying a stack. We will introduce a notation which may seem unrelated at first :)

Transitions are written as .
This means “when reading , we can replace on the stack with by taking this transition”.
Of course, we can only take this transition if the symbol on top of the stack is .

At first, it’s not obvious that this encapsulates how a stack works. How do we push? How do we pop? How might we check the state of the stack before accepting or more generally, allowing passage to another state in the machine?

Intuition: For pushes/pops, we can view as meaning “when reading , we pop off the stack and push onto the stack by taking this transition”.

Pushing: We can represent just pushing as which means “when reading , we can push onto the stack”

Popping: We can represent just popping as which means “when reading , we can pop a off the stack”

Checking state: We can enforce needing a certain symbol on the top of the stack with which means “when reading , we require a to take this transition and don’t change the stack” (since replacing doesn’t do anything).

Using the empty string

Our transitions are quite strong. For , we’re saying that to take this transition:

  • must be the next symbol read AND
  • must be on top of the stack

We might want a transition with only one of these conditions; we can use for this!

Only reading

To ignore the stack part and just check

Neither

Analogous to -transitions in NFAs.

Bottom

Often, we also need the power to check whether the stack is empty. We can do this by pushing on a symbol (we will choose ) at the very start, so that it will be the first symbol pushed onto the stack.

We can then check whether the stack is empty with a transition which means “when reading , we can take this transition if the stack is empty”.

Of course, we might choose to replace "" with another symbol at the same time as checking whether the stack is empty.

CFGs and PDAs

is in Chomsky normal form if all rules:
where

Theorem: For every CFG G, there is a CFG in CNF s.t.

HMU 7.1.5

Cooke-Younger-Kasami propose a DP algorithm