Library

NPDA · Context-free

Palindromes: guess the middle

Accepts even-length palindromes over {a,b}. The machine pushes symbols, nondeterministically guesses where the middle is, then pops and matches the mirror half.

first ha…mirroracc
The machine as drawn — 3 states, 6 transitions.

The author’s examples, run

abba → acceptbaab → acceptabaaba → acceptabab → rejectaba → reject