
- Automata Theory - Applications
- Automata Terminology
- Basics of String in Automata
- Set Theory for Automata
- Finite Sets and Infinite Sets
- Algebraic Operations on Sets
- Relations Sets in Automata Theory
- Graph and Tree in Automata Theory
- Transition Table in Automata
- What is Queue Automata?
- Compound Finite Automata
- Complementation Process in DFA
- Closure Properties in Automata
- Concatenation Process in DFA
- Language and Grammars
- Language and Grammar
- Grammars in Theory of Computation
- Language Generated by a Grammar
- Chomsky Classification of Grammars
- Context-Sensitive Languages
- Finite Automata
- What is Finite Automata?
- Finite Automata Types
- Applications of Finite Automata
- Limitations of Finite Automata
- Two-way Deterministic Finite Automata
- Deterministic Finite Automaton (DFA)
- Non-deterministic Finite Automaton (NFA)
- NDFA to DFA Conversion
- Equivalence of NFA and DFA
- Dead State in Finite Automata
- Minimization of DFA
- Automata Moore Machine
- Automata Mealy Machine
- Moore vs Mealy Machines
- Moore to Mealy Machine
- Mealy to Moore Machine
- Myhill–Nerode Theorem
- Mealy Machine for 1’s Complement
- Finite Automata Exercises
- Complement of DFA
- Regular Expressions
- Regular Expression in Automata
- Regular Expression Identities
- Applications of Regular Expression
- Regular Expressions vs Regular Grammar
- Kleene Closure in Automata
- Arden’s Theorem in Automata
- Convert Regular Expression to Finite Automata
- Conversion of Regular Expression to DFA
- Equivalence of Two Finite Automata
- Equivalence of Two Regular Expressions
- Convert Regular Expression to Regular Grammar
- Convert Regular Grammar to Finite Automata
- Pumping Lemma in Theory of Computation
- Pumping Lemma for Regular Grammar
- Pumping Lemma for Regular Expression
- Pumping Lemma for Regular Languages
- Applications of Pumping Lemma
- Closure Properties of Regular Set
- Closure Properties of Regular Language
- Decision Problems for Regular Languages
- Decision Problems for Automata and Grammars
- Conversion of Epsilon-NFA to DFA
- Regular Sets in Theory of Computation
- Context-Free Grammars
- Context-Free Grammars (CFG)
- Derivation Tree
- Parse Tree
- Ambiguity in Context-Free Grammar
- CFG vs Regular Grammar
- Applications of Context-Free Grammar
- Left Recursion and Left Factoring
- Closure Properties of Context Free Languages
- Simplifying Context Free Grammars
- Removal of Useless Symbols in CFG
- Removal Unit Production in CFG
- Removal of Null Productions in CFG
- Linear Grammar
- Chomsky Normal Form (CNF)
- Greibach Normal Form (GNF)
- Pumping Lemma for Context-Free Grammars
- Decision Problems of CFG
- Pushdown Automata
- Pushdown Automata (PDA)
- Pushdown Automata Acceptance
- Deterministic Pushdown Automata
- Non-deterministic Pushdown Automata
- Construction of PDA from CFG
- CFG Equivalent to PDA Conversion
- Pushdown Automata Graphical Notation
- Pushdown Automata and Parsing
- Two-stack Pushdown Automata
- Turing Machines
- Basics of Turing Machine (TM)
- Representation of Turing Machine
- Examples of Turing Machine
- Turing Machine Accepted Languages
- Variations of Turing Machine
- Multi-tape Turing Machine
- Multi-head Turing Machine
- Multitrack Turing Machine
- Non-Deterministic Turing Machine
- Semi-Infinite Tape Turing Machine
- K-dimensional Turing Machine
- Enumerator Turing Machine
- Universal Turing Machine
- Restricted Turing Machine
- Convert Regular Expression to Turing Machine
- Two-stack PDA and Turing Machine
- Turing Machine as Integer Function
- Post–Turing Machine
- Turing Machine for Addition
- Turing Machine for Copying Data
- Turing Machine as Comparator
- Turing Machine for Multiplication
- Turing Machine for Subtraction
- Modifications to Standard Turing Machine
- Linear-Bounded Automata (LBA)
- Church's Thesis for Turing Machine
- Recursively Enumerable Language
- Computability & Undecidability
- Turing Language Decidability
- Undecidable Languages
- Turing Machine and Grammar
- Kuroda Normal Form
- Converting Grammar to Kuroda Normal Form
- Decidability
- Undecidability
- Reducibility
- Halting Problem
- Turing Machine Halting Problem
- Rice's Theorem in Theory of Computation
- Post’s Correspondence Problem (PCP)
- Types of Functions
- Recursive Functions
- Injective Functions
- Surjective Function
- Bijective Function
- Partial Recursive Function
- Total Recursive Function
- Primitive Recursive Function
- μ Recursive Function
- Ackermann’s Function
- Russell’s Paradox
- Gödel Numbering
- Recursive Enumerations
- Kleene's Theorem
- Kleene's Recursion Theorem
- Advanced Concepts
- Matrix Grammars
- Probabilistic Finite Automata
- Cellular Automata
- Reduction of CFG
- Reduction Theorem
- Regular expression to ∈-NFA
- Quotient Operation
- Parikh’s Theorem
- Ladner’s Theorem
Two-stack Pushdown Automata and Turing Machine
A traditional Pushdown Automaton has one stack, but there could be some variations. We can also have a two-stack pushdown automaton. Both are powerful computational models, but they differ in their structure and capabilities.
In this chapter, we will explain the basics of these models, and their key features with examples to present a clear understanding of how they work.
Basics of Two-stack Pushdown Automata
A Pushdown Automaton is a computational model similar to a finite automaton but with an added stack. The stack provides the machine with additional memory. These are used for recognizing context-free languages.
However, a standard PDA has limitations, particularly when it comes to languages that require more complex memory management. We can put another stack to make two-stack PDA. Take a look at the following block diagram −

Key Features of Two-stack Pushdown Automata
Following are some of the key features of two-stack pushdown automata −
- Two Stacks − Unlike a standard PDA, which has only one stack, a two-stack PDA has two stacks. This dual-stack setup allows it to simulate a Turing machine, making it more powerful than a single-stack PDA.
- Memory Management − With two stacks, the PDA can store and manage more complex information, enabling it to recognize languages that a standard PDA cannot.
- Deterministic and Non-deterministic − A two-stack PDA can be either deterministic or non-deterministic, but it is the non-deterministic version that fully captures the power of a Turing machine.
How Does a Two-Stack Pushdown Automata Work?
In a two-stack PDA, the machine uses one stack to push and pop symbols while the other stack performs similar operations. The interaction between these two stacks enables the PDA to keep track of more complex structures, such as nested sequences or multiple dependencies, which are common in context-sensitive languages.
Comparison with Turing Machine
The Turing Machine is most powerful computational model that can simulate any algorithm. It consists of an infinite tape, a tape head that reads and writes symbols on the tape, and a finite state control that dictates the machine's operations based on the current state and the symbol under the tape head.
Relationship between Two-stack PDA and Turing Machine
A Two-Stack PDA and Turing Machines are computationally equivalent that we can prove. A PDA is similar to FSM, but it has an additional memory, a stack, to help it recognize strings. If a PDA has more than one stack, we can call it a Turing machine.
Simulation − A two-stack PDA can simulate a Turing machine by using one stack to represent the portion of the tape to the left of the head and the other stack to represent the portion to the right.
Components of Two-stack PDA
A two-stack PDA is defined by a 9-tuple: $\mathrm{M \:=\: (Q,\: \Sigma,\: \Gamma,\: \Gamma',\: \delta,\: q0,\: z1,\: z2,\: F)}$
- Q − All the states the PDA can be in
- Σ − The input alphabet (symbols it can read)
- Γ − The alphabet for the first stack
- Γ' − The alphabet for the second stack
- δ − Rules for moving between states and using the stacks
- q0 − The starting state
- z1 − The bottom symbol for the first stack
- z2 − The bottom symbol for the second stack
- F − The final or accepting states
Example: Recognizing $\mathrm{\{a^{n} b^{n} c^{n} \: |\:n\: \geq\: 0\}}$
Let's see how a two-stack PDA can handle the language $\mathrm{\{a^{n} b^{n} c^{n} \: |\:n\: \geq\: 0\}}$. This language has equal numbers of a's, b's, and c's in that order. Which is not solvable by one stack PDA, but can be solvable by Turing Machines.
Strategy − Here's how we'll use our two stacks −
- While reading 'a', we'll push 'X' into stack 1.
- While reading 'b', we'll push 'Y' into stack 2.
- While reading 'c', we'll pop 'X' from stack 1 and 'Y' from stack 2.
- If both stacks are empty at the end, we accept the string.
Transition Functions − Here are the transition functions −
$$\mathrm{\delta(q0,\: \lambda,\: z1,\: z2)\: \rightarrow \:(qf,\: z1,\: z2)}$$
$$\mathrm{\delta(q0,\: a,\: z1,\: z2)\: \rightarrow \:(q0,\: Xz1,\: z2)}$$
$$\mathrm{\delta(q0,\: a,\: X,\: z2)\: \rightarrow \:(q0,\: XX,\: z2)}$$
$$\mathrm{\delta(q0,\: b,\: X,\: z2)\: \rightarrow \:(q0,\: X,\: Yz2)}$$
$$\mathrm{\delta(q0,\: b,\: X,\: Y)\: \rightarrow \:(q0,\: X,\: YY)}$$
$$\mathrm{\delta(q0,\: c,\: X,\: Y)\: \rightarrow \:(q1,\: \lambda,\: \lambda)}$$
$$\mathrm{\delta(q1,\: c,\: X,\: Y)\: \rightarrow \:(q1,\: \lambda,\: \lambda)}$$
$$\mathrm{\delta(q1,\: \lambda,\: z1,\: z2)\: \rightarrow \:(qf,\: z1,\: z2)}$$

Explanation of Transitions
- The first line handles the case of an empty input string.
- The next two lines handle reading 'a' and pushing 'X' to stack 1.
- The fourth and fifth lines handle reading 'b' and pushing 'Y' to stack 2.
- The sixth and seventh lines handle reading 'c' and popping from both stacks.
- The last line checks if we have finished the string with empty stacks.
Conclusion
In this chapter, we explained the concept of two-stack pushdown automata and Turing Machines. A two-stack PDA has more power because it can recognize all context-free languages, just like a regular PDA. In addition, a two-stack PDA can also recognize some context-sensitive languages, which regular PDAs cannot. Two-stack PDAs are equivalent to Turing machines! This means they can compute anything that is computable.