[go: up one dir, main page]

0% found this document useful (0 votes)
19 views2 pages

2 Stack PDA

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

Suppose we've a language L that a two-stack PDA can handle.

We want to show that a Turing


Machine can handle it just as well. To do this, we need to set up a Turing Machine M that
can do everything the two-stack PDA does with an input w. The Turing Machine M uses a
tape, a bunch of states, and a tape head that reads and writes symbols. We'll set up the tape
to replicate the PDA's two stacks. We'll use the left part of the tape for the first stack and the
right part for the second, with a special symbol '#' to separate them. Initially, we throw the
input w onto the tape backwards, starting from the leftmost position. Here’s the step-by-
step computation of the two-stack PDA. At each step, the PDA reads the top symbols of the
two stacks, performs a push or pop operation on each stack, and changes its control state.
We can simulate these steps on the Turing Machine as follows:
1. The Turing Machine reads the symbol right under the head. This represents the top item
of the first stack.
2. Then, the head moves right until it reaches the '#' symbol, representing the top item of
the second stack.
3. Next, depending on what the PDA's transition function, it either adds or removes symbols
from the stacks, just like pushing or popping. This can be done by moving the head of the
Turing Machine to the left or right
4. Change the control state of the Turing Machine, according to the PDA's transition
function.
5. The steps 1-4 keeps going until the PDA either accepts or rejects the input. If the PDA
accepts the input w, then the Turing Machine M will also accept the input w, because it
simulates the behaviour of the PDA. Similarly, if the PDA rejects the input w, then the Turing
Machine M will also reject the input w. Therefore, we have shown that a language L
accepted by some two-stack PDA is also accepted by some deterministic Turing Machine.

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.

You might also like