I'm trying to make a PDA that accepts the language $\{ w001w^\text{R} : w = \{0,1\}^* \}$ by empty stack. (Here $w^\text{R}$ denotes the reverse of the string $w$.) Our stack symbol s $\#$.
I've come up with this so far, but I don't know how to handle the $001$ in the middle of $w$ and $w^\text{r}$. Any suggestions?
-
Start by pushing $0,1$ onto the stack: $(q_0,0,\#) \rightarrow (q_0,0\#)$ and $(q_0,1,\#) \rightarrow (q_0, 1\#)$
-
Continue to push $0,1$ onto stack: $(q_0,0,0) \rightarrow (q_0,00)$, $(q_0,0,1) \rightarrow (q_0, 01)$, $(q_0,1,0) \rightarrow (q_0,10)$, $(q_0,1,1) \rightarrow (q0, 11)$
-
Handle $001$ and transition to $q_1$: I don't know how to do this
-
Pop $0,1$ off stack: $(q_1,0,0) \rightarrow (q_1,E)$, $(q_1,1,1) \rightarrow (q_1,E)$
If stack is empty after this point, than accept language.
Best Answer
The basic idea is to use the non-determinism of the PDA to "guess" where the middle $\mathtt{001}$ is, and don't push/pop anything to/from the stack while reading this guess. The rest of the PDA will be similar to the usual PDA to recognise the language $L_0 = \{ ww^\text{R} : w \in \{\mathtt{0},\mathtt{1} \}^* \}$ by empty stack. The main point is that if you guess wrong you just need to ensure that the stack doesn't empty at the end of the computation (or that the computation doesn't continue to the end of the string).
In broad outline, I would design the PDA as follows (assuming that $\#$ is pushed onto the stack before the computation begins):