Skip to content
Tape‑n‑Trace
PracticeSearch 26 tools

Final state ↔ empty stack

Hopcroft 2e §6.2.3–6.2.4. A PDA can accept by reaching a final state or by draining its stack, and the two are interconvertible. Both constructions turn on one new stack symbol, pushed underneath everything: going one way it is the tripwire that reveals the original stack just emptied, going the other it is the safety net that stops an accidental acceptance.

Machine (accepts by final state):

Original — L(P)

a, Z0/AZ0, a, A/AAb, A/εb, A/εε, Z0/Z0ε, Z0/Z0q0q1q2

Converted — N(P′)

ε, X0/Z0X0p0q0q1q2pe

Narration

A new start state p0 pushes Z0 above a new bottom marker X0 and hands control to q0. X0 is the safety net: if the original machine drains its own stack without having accepted, X0 is still there and the new machine does not accept by accident.

Hopcroft 2e, §6.2.4, Thm 6.11

Both machines on the same strings

The theorem says the languages are equal; here is a sample of it. (A sample is evidence, not the proof — the proof is the construction above.)

woriginalconverted
aaabbbacceptsaccepts
abacceptsaccepts
εacceptsaccepts
aabrejectsrejects
barejectsrejects