Chapter recap
A PDA is a finite automaton with an unbounded stack: moves read a symbol or ε, look at the top, and replace it by a string. Acceptance by final state and by empty stack are equivalent for NPDAs; empty-stack DPDAs accept only prefix-free languages, so DCFLs use final state. DPDAs forbid competing moves; Regular ⊊ DCFL ⊊ CFL (wwᴿ separates). CFGs ↔ PDAs: expand/match simulation of leftmost derivations, and [pXq] triples back.
Merged rule card
From 3.3.1 Stack primer and the push-down automaton
- PDA (Q, Σ, Γ, δ, q₀, Z₀, F); δ(q, a|ε, X) ⊆ Q × Γ*; label a, X/γ (γ = ε pop, X keep, YX push).
- ID (q, w, γ), top first; ⊢ one move, ⊢* many.
- Nondeterministic by default; ε-moves still see the stack.
From 3.3.2 Acceptance by final state vs empty stack
- Final state: input read, state ∈ F, stack anything. Empty stack: input read, stack empty, state anything.
- NPDA: both conventions = CFL (convert with a new bottom marker).
- DPDA: empty stack ⇒ only prefix-free DCFLs; final state ⇒ all DCFLs. GATE default: final state.
From 3.3.3 Designing PDAs; DPDA vs NPDA; DCFL ⊂ CFL
- Recipe: stack stores what is unbounded; states store the phase; Z₀ detects empty; accept via ε, Z₀.
- DPDA: ≤ 1 move per (q, a|ε, X), and no ε-move competing with input moves.
- Regular ⊊ DCFL ⊊ CFL. wwᴿ, aⁿbⁿ ∪ aⁿb²ⁿ, aⁱbʲcᵏ (i=j or j=k): CFL not DCFL.
- DCFL ⇒ unambiguous grammar; not conversely.
From 3.3.4 CFG ↔ PDA equivalence
- CFG → PDA: push S; expand (q, ε, A) → (q, α); match (q, a, a) → (q, ε); accept on Z₀. Simulates leftmost derivations; nondeterministic.
- PDA → CFG: variables [p X q] (net pop of X from p to q).
- CFG = NPDA (final state) = NPDA (empty stack). One working state suffices.
Practice questions
- MCQ
Which language needs nondeterminism in a PDA?
- { aⁿbⁿ }
- { wcwᴿ }
- { wwᴿ }
- { aⁿbᵐ : n ≥ m }
- MSQ
Which are true?
- Every regular language is a DCFL
- Every DCFL is unambiguous
- DPDA = NPDA in power
- Final-state and empty-stack NPDAs are equivalent
- NAT
ID (q, ab, AZ). Move δ(q, a, A) ∋ (p, BBA). Stack size after the move?
Write your answer before opening the key.
- MCQ
A PDA accepting by empty stack ends with input read in a non-accepting state with Z on the stack. It:
- accepts
- rejects
- loops
- depends on F
- MSQ
Which are CFL but not DCFL?
- { wwᴿ }
- { aⁿbⁿ } ∪ { aⁿb²ⁿ }
- { aⁱbʲcᵏ : i = j or j = k }
- { aⁿbⁿ }
- MCQ
In CFG → PDA, the move for terminal a is:
- (q, ε, a) → (q, ε)
- (q, a, a) → (q, ε)
- (q, a, Z) → (q, aZ)
- (q, a, A) → (q, a)
- NAT
Empty-stack DPDAs can accept a language L only if L is prefix-free. How many strings of { a, ab, b, ba } must be removed to make it prefix-free (remove as few as possible)?
Write your answer before opening the key.
- MCQ
Which is a DCFL?
- { wwᴿ }
- { aⁿbᵐcⁿ }
- { aⁱbʲcᵏ : i = j or j = k }
- { aⁿbⁿcⁿ }
Answer key
Reveal answers when you’re ready
- C — No middle marker.
- A: DPDA.
- B: DPDA.
- D: DPDA.
- ABD — Standard facts.
- C: NPDA is stronger.
- 4 — Replace A by BBA: BBAZ.
- B — Stack is not empty.
- A: Z still there.
- C: Not determined by this.
- D: F is irrelevant.
- ABC — Standard examples.
- D: DCFL.
- B — Match and pop.
- A: Must read a.
- C: That pushes.
- D: Wrong.
- 2 — a is a prefix of ab, b of ba: remove one from each pair.
- B — Push a’s, ignore b’s, pop on c’s.
- A: Needs guessing.
- C: Inherently ambiguous.
- D: Not even a CFL.