Answer: For L =
{wwR∣win{a,b}∗}
, push the first half and pop it while reading the reversed second half; the middle is guessed nondeterministically.
- In q0, for each input symbol x in
{a,b}
, push x: delta(q0,x,Z)=(q0,xZ), delta(q0,x,x)=(q0,xx).
2. Guess the midpoint by an epsilon transition to q1: delta(q0,epsilon,Z)=(q1,Z) and delta(q0,epsilon,x)=(q1,x).
3. In q1, reading x must match and pop the top: delta(q1,a,a)=(q1,epsilon), delta(q1,b,b)=(q1,epsilon).
4. Accept when stack bottom Z0 is reached: delta(q1,epsilon,Z0)=(qf,epsilon).
5. For empty w, epsilon is accepted directly.
A stack gives the machine a memory. A pushdown automaton is a finite automaton equipped with a stack, which allows it to count and to match nested structures that a finite automaton cannot handle. Formally it has states, an input alphabet, a stack alphabet, transitions, a start state, a start stack symbol and a set of final states. Each transition consumes an input symbol or the empty string, pops the top stack symbol and pushes a string of stack symbols. The automaton accepts a context free language either by reaching a final state after reading the whole input or by emptying the stack. To recognize strings of the form w followed by the reverse of w, the machine pushes each symbol of the first half onto the stack without consuming anything in the nondeterministic version, or guesses the middle, and then for each symbol of the second half pops the stack and checks that the popped symbol matches the input. If the stack returns to the bottom symbol exactly when the input ends, the string is a palindrome and is accepted. For a language with twice as many b as a, push two stack symbols for each a and pop one for each b, accepting if the stack is empty and the input is exhausted. For the language with equal numbers of a, b and c, a single stack is not enough, which is why a two stack machine is needed. A complete answer describes the stack operations for each phase, gives the transition functions with stack symbols clearly defined, explains the nondeterministic guess where required and traces one accepted and one rejected string. Mentioning that the stack provides only last in first out access explains both the power and the limitation of the model.
Result: The NPDA accepts exactly even-length palindromes of the form w w^R; non-determinism guesses the midpoint.
Tip from Examiner: State the formal definition, show the construction or derivation step by step, and verify the result on a short sample string.