Theory of Computing

Push-down Automata

Push-down automata

Memory is an infinite-sized stack.

Basically, it is a non-deterministic finite automaton with an infinite stack.

It turns out that

PDAs can recognize context-free languages.

Transitions of NFA becomes: if in state q and see symbol a (or ε) in the input string and see symbol b on top of stack (or ignore it) then pop it, push c onto stack (or ε), go to state q’.

Two alphabets: input alphabet Σ and stack alphabet Γ.

Definition

Push-down automaton

is a 6-tuple (Q, Σ, Γ, δ, q₀, F) where

  • Q is a finite set of states
  • Σ is a finite set of symbol, called the input alphabet
  • Γ is a finite set of symbol, called the stack alphabet
  • δ : Q × (Σ ∪ {ε}) × (Γ ∪ {ε}) → 2Q × (Γ ∪ {ε}) is the transition function
  • q₀ is the starting state
  • F ⊆ Q is a finite set of accepting states

Context-free grammars

Notations

Example context-free grammar

Deriving strings from grammars

Suppose u, v, and w are strings of variables and terminals. Suppose there is a rule A → w. From the string uAv, we can obtain uwv. We write uAv → uwv, which is read as uAv yields uwv.

If u₁ → u₂ → … → uₖ (finite number of arrows), then u₁ →* uₖ, read as u₁ derives uₖ.

Given a grammar G, the language derived by the grammar is L(G) = {ω ∈ Σ* : S →* ω}, where S is the start variable.

In the above example, L(G) = {a, b}*.

The following grammar derives nothing, i.e. L(G) = ∅.

Meaning of “context-free”

Context-free languages

Context-free language
is one that can be derived from a context-free grammar.

Ambiguity

A grammar is ambiguous when it has multiple left-most derivations for the same string.

Equivalence of PDA and CFG

Theorem: a language L is recognized by a PDA if and only if L is described by a CFG.