4.6.10 · D5Theory of Computation

Question bank — Pushdown automata (PDA) — configuration, acceptance by empty stack - final state

2,075 words9 min readBack to topic

Before the traps, let us re-anchor every symbol used below, so nothing is invoked before it is named. Look at the picture: the stack is a vertical pile of plates, growing upward, with the very first plate () glued to the floor.

Figure — Pushdown automata (PDA) — configuration, acceptance by empty stack  -  final state

Reminder of the other moving parts:

  • A configuration (ID) is the triple = (state, remaining unread input, whole stack with top written leftmost).
  • Empty-stack acceptance : reach — stack literally has zero symbols.
  • Final-state acceptance : reach with — stack contents ignored.
  • = one legal step; = zero or more steps.

The next figure shows one step visually — how the ID changes when a plate is pushed:

Figure — Pushdown automata (PDA) — configuration, acceptance by empty stack  -  final state

And here is a full stepwise visual trace of on input , so you can watch the stack rise and fall and empty — the picture the "empty-stack" trap questions are really about:

Figure — Pushdown automata (PDA) — configuration, acceptance by empty stack  -  final state

True or false — justify

TRUE/FALSE: A PDA that accepts by final state must also have an empty stack to accept.
False. ignores the stack content entirely; you can end in a final state with junk symbols still on the stack and still accept. Only demands the stack be empty.
TRUE/FALSE: For empty-stack acceptance you must also pop the bottom marker .
True. "Empty" means zero symbols including . If is still sitting there the stack isn't empty, so no acceptance — you need an explicit -move that pops it.
TRUE/FALSE: Every language accepted by empty stack is also accepted by some final-state PDA.
True. Both modes recognise exactly the context-free languages, and there is a mechanical conversion (add a fresh marker below , reach a final state when resurfaces). See Context-Free Grammars.
TRUE/FALSE: In the ID the symbol is at the bottom of the stack.
False. By convention the top is written leftmost, so here is the top and is everything below it (the tail of the stack). Reading it backwards breaks every transition rule.
TRUE/FALSE: A DPDA (deterministic PDA) recognises exactly the same languages as a general PDA.
False. The stack blocks the subset-construction trick that makes NFAs and DFAs equal. DPDAs are strictly weaker; is context-free but not accepted by any Deterministic PDA (DPDA).
TRUE/FALSE: Every regular language is accepted by some PDA.
True. A PDA is an NFA plus a stack; just never touch the stack (always push back what you pop) and you have an NFA, which already covers all regular languages (Nondeterministic Finite Automata).
TRUE/FALSE: If is defined, the PDA can move without reading any input.
True. -moves consume no input; they let the machine rearrange the stack or change state "for free," which is essential for guessing (e.g. a palindrome's midpoint).
TRUE/FALSE: A single PDA move can push more than one symbol onto the stack.
True. The output string can be long: replaces top with above , netting a push. Pop () and peek () are just other choices of .
TRUE/FALSE: The transition function output being a set is only about handling -moves.
False. The set encodes nondeterminism — multiple legal (state, push-string) choices from one situation. -input is a separate feature; a set is needed even for ordinary input symbols.
TRUE/FALSE: PDAs and Turing Machines have equal recognising power.
False. A stack is LIFO-restricted memory; a Turing tape is freely readable/writable. PDAs recognise only context-free languages, a strict subset of what Turing machines recognise.

Spot the error

Someone writes the yields rule as . What's wrong?
Here is the top plate and is the stack below it. The input still shows after the step — but reading must consume it, so it should become . Only an -move leaves the input unchanged.
"For I'll pop an on each ." Why does this fail?
You have nothing to pop yet — the stack starts with just . You must push an per (build the count), then pop per . Popping during the 's underflows immediately.
A student claims but forgot rule . What breaks?
After matching all 's and 's the stack is , not empty, so nothing is accepted. Without the marker-popping -move the empty-stack machine accepts no strings.
"To convert final-state to empty-stack, just add -moves that pop everything from final states." What's the hidden bug?
A string that momentarily empties the stack mid-run could be accepted early. You must first add a fresh bottom marker that only the new dumping states can remove, so the original machine never empties by accident.
Someone models balanced brackets but keeps and uses final-state acceptance. Result?
With no final states, — nothing is ever accepted. only makes sense with empty-stack acceptance, where final states are irrelevant.
A PDA has used as "read and clear the whole stack." Why is that description wrong?
The output pops only the top symbol , not the entire stack. One move touches exactly one stack top; clearing the stack needs repeated -moves.

Why questions

Why is the "already-read" portion of the input not part of a configuration?
Look at figure s02 — only the remaining input and the current stack feed the next move. The consumed prefix can never influence a later move, so storing it would be redundant.
Why does adding a stack lift a machine from regular to context-free languages?
Finite states are like a robot with a few moods and no notepad — bounded memory, so it can't count arbitrarily high. The stack (figure s01's growing plate pile) is unbounded LIFO memory, so it can match nested/counted structure like that no finite state set can track.
Why is nondeterminism essential (not just convenient) for accepting ?
The midpoint is unmarked, so a deterministic machine cannot know when to switch from pushing to matching. A nondeterministic PDA guesses every possible midpoint (imagine many parallel copies of the trace in figure s03, each switching at a different plate) and one guess succeeds; see Pumping Lemma for CFLs for why some CFLs resist any DPDA.
Why does replacing "top by a string" unify push, pop, and peek into one rule?
Picture the top plate being swapped for a small pile: choosing pushes, pops, and leaves the top unchanged (peek). One transition schema covers all three by picking .
Why do we bother with two acceptance modes if they have equal power?
Different constructions are cleaner in each mode — grammar-to-PDA conversions naturally give empty-stack machines, while human-designed recognisers often read more naturally as final-state machines. Equal power means you can freely pick whichever is convenient.
Why can't the subset construction (which makes NFA = DFA) be reused to make PDA = DPDA?
Subset construction tracks the set of possible states, but a PDA's configuration also includes an unbounded stack — you cannot bundle infinitely many possible stacks into one finite deterministic state. Determinism therefore genuinely restricts PDAs. See Closure Properties of CFLs.

Edge cases

What does a PDA do on the empty input , and can it accept it?
With no input to read it can still take -moves. If those reach an empty stack (or a final state) it accepts ; e.g. a machine for accepts by immediately popping .
What happens if the machine reads all input but has -moves left it could take — is it stuck?
Nothing is forced. Because of nondeterminism, if any sequence of remaining -moves leads to acceptance the string is accepted; otherwise this branch just fails. Other branches may still succeed.
What if the stack becomes empty before all input is read?
That branch simply halts — with no stack top, no transition applies (every needs a top symbol), so it can make no further move and reads no more input. It cannot accept (input isn't finished); this is exactly why needs the marker to survive until the end.
Can a PDA be in a configuration with no applicable transition? What then?
Yes — a "dead" configuration. That computation branch just stops without accepting. It only matters whether some branch reaches an accepting configuration.
Is (the language containing only the empty string) accepted by some PDA?
Yes. Make the start state accept by empty stack via and provide no way to consume a real symbol, so only succeeds.
If a PDA never uses its stack (always pushes back exactly what it pops), what class does it recognise?
Exactly the regular languages — it behaves as a plain NFA. The stack is present but inert, so no extra power is gained.
Can an empty-stack PDA accept a language whose only string is long and non-nested, like ?
Yes. Any finite/regular language is context-free, so an empty-stack PDA works; it just pushes/pops trivially and empties at the end. The stack's power is unused but not required to be.

Recall Self-test: the four traps in one breath

Final ignores the stack; Empty means zero symbols including ; top is leftmost; DPDA is strictly weaker than PDA. Which mode ignores stack contents? ::: Final-state acceptance (). Where is the stack top written in an ID? ::: Leftmost in . Is DPDA equal to PDA? ::: No, strictly weaker (e.g. ).

The mnemonic below is anchored to the picture: four coloured plates, one per trap letter.

Figure — Pushdown automata (PDA) — configuration, acceptance by empty stack  -  final state