2 Stack PDA
2 Stack PDA
2 Stack PDA
Now, suppose a Turing Machine already accepts a language L. We need a two-stack PDA to
do the same job. This PDA will use its two stacks to mimic the Turing Machine's actions on its
tape. The two-stack PDA will have a finite stack alphabet, a finite set of control states, and
two stacks. We will initialize one of the stacks with the input w in reverse order, similar to
how we initialized the tape of the Turing Machine. At each step of computation, the PDA will
read the top symbols of the two stacks, perform a push or pop operation on each stack, and
change its control state, similar to the steps of the Turing Machine. We can simulate these
steps on the two-stack PDA as follows:
1. Read the top item of the first stack, simulating the Turing Machine’s tape head reading a
symbol.
2. Check the top item of the second stack, just like the tape head moving right until it
reaches to the '#' symbol.
3. Do the push or pop operations according to the Turing Machine's transition function. This
can be done by pushing or popping symbols onto the stacks.
4. Change the control state of the PDA, according to the Turing Machine's transition
function.
5. Repeat the above steps until the Turing Machine reaches its accept or reject state. If the
Turing Machine accepts the input w, then the two-stack PDA will also accept the input w,
because it simulates the behaviour of the Turing Machine. Similarly, if the Turing Machine
rejects the input w, then the two-stack PDA will also reject the input w.
Therefore, we have shown that a language L accepted by some deterministic Turing Machine
is also accepted by some two-stack PDA.
In conclusion, we have shown that two-stack PDAs are equivalent to Turing machines: a
language L is accepted by some two-stack PDA if and only if it is accepted by some
deterministic Turing Machine.