Automata & Complexity

Table of Contents

Pushdown automata

Unlike NFA, the PDA has memory – a stack of unlimited size.

Stack alphabet represented by Γ. Elements can be pushed/popped from the stack. Initially, stack contains stack start symbol z ∈ Γ.

On transition, read topmost element of stack, and exchange with zero or more new elements.

When NPDA reads words, need to keep track of current state, remaining input, current stack.

Transition (q’, v) ∈ δ(q, α, b) means that from state q with input α w and stack bu, the automaton can go to state q’ with input w and stack vu. In other words, $(q, \alpha w, bu) \vdash (q’, w, vu)$.

Transition graph for NPDA contains, for every (q’, v) ∈ δ(q, α, b), an arrow $q \xrightarrow{\alpha[b/v]} q’$. This reads as “if b is on the top of the stack, transition from state q to state q’, reading an α of input, and replacing the b on the top of the stack with v”.

Deterministic PDA:

Deterministic context-free language allows for efficient parsing.

Not all context-free languages are deterministic context-free.

It is decidable if two DPDAs generate same language.

Language L is context free ⇔ there exists NPDA for that language.

CFG to NPDA

Simulate leftmost derivations on stack.

Construct NPDA with:

Construct the PDA:

  1. Start with lambda transition that takes z on top of stack, and replaces it with the symbol.
  2. Simulate leftmost reductions for every rule. A rule is a λ transition that takes a a symbol on the stack, and replaces it with the expansion of the symbol.
    • e.g. rules S → aSa | aa
    • two lambda transitions (loops):
      • q1 to q1, taking an S on the stack, and replacing it with aSa
      • q1 to q1, taking an S on the stack, and replacing it with aa
  3. Add transitions for consuming terminals. For every terminal, add transition that consumes the terminal, and replaces the terminal on the stack with λ.
  4. Add a lambda transition to final state, that takes z on the top of the stack and replaces with λ.

NPDA to CFG

Assume there is one final state, which is reachable only with empty stack. If not, make it so.

Define CFG with: