# Chapter 2: Context-Free Languages

## Chapter 2.2, Pushdown Automata

A pushdown automaton (PDA) is a finite automaton that also has access to a stack with infinite memory.

### Factoids

• Context-free grammars generate context-free languages (CFLs).
• Pushdown automata recognize context-free languages.
• Context-free grammars and pushdown automata are equivalent. (Monday's reading will show how to prove this.)
• Unlike regular languages, the set of non-deterministic CFLs is larger than the set of deterministic CFLs.

### Pushdown Automaton 6-Tuple

A pushdown automaton is a 6-tuple (Q, Σ, Γ, δ, q0, F), where Q, Σ, Γ, and F are all finite sets, and

1. Q is the set of states,
2. Σ is the input alphabet,
3. Γ is the stack alphabet,
4. δ: Q × Σε × Γε → P(Q × Γε) is the transition function,
5. q0 is the start state, and
6. F ⊆ Q is the set of accept states.

### Lecture Problem

• Design a PDA that recognizes {wwR | w ∈ {1,2}*}.
• What is each element of the 6-tuple?
• Show the sequence of states that the PDA goes through to accept the string 2112.
• Show the context-free grammar that generates this language.

### Active Learning Problem

• Design a PDA that recognizes {1n2k3n | w ∈ {1, 2, 3}*}.
• What is each element of the 6-tuple?
• Show the sequence of states that the PDA goes through to accept the string 1122233.
• Show the context-free grammar that generates this language.

### Acceptance

PDA M accepts input w (w1...wm where each wi ∈ Σε) if there is a sequence of states r0, ..., rm ∈ Q and strings s0, ..., sm ∈ Γ* such that

1. r0 = q0 and s0 = ε
2. (ri+1, b) ∈ δ(ri, wi+1, a) for i = 0, 1, ..., m-1 where si = at and si+1 = bt for some a, b ∈ Γε and t ∈ Γ*
3. rm ∈ F