Hello! Welcome back to our study of Pushdown Automata.
In our last lesson, we formally defined the Pushdown Automaton (PDA) as a 7-tuple, (Q, Σ, Γ, δ, q₀, Z₀, F). We established that its key enhancement over a finite automaton is the addition of a stack, which is governed by a more powerful transition function, δ.
Today, we bring this static definition to life. Our goal is to learn how to trace the execution of a PDA on an input string, including all its stack manipulations. This will allow us to determine whether a string is accepted or rejected by the machine. We will explore both an intuitive, graphical approach and a more formal method using Instantaneous Descriptions, which will satisfy both the need for intuition and the mathematical rigor you appreciate.
1. Visualizing PDA Execution: The Graphical Notation
Just as with finite automata, we can represent PDAs with state transition diagrams. However, the transitions are more complex. A transition in a PDA depends not just on the input symbol, but also on the symbol at the top of the stack.
The common notation for a PDA transition is:a, b / c
This means:
a: The input symbol to be read from the tape. This can beεfor a transition that doesn't consume input.b: The symbol that must be at the top of the stack. The transition can only be taken if the top of the stack isb. This symbol is popped from the stack.c: The string of symbols to be pushed onto the stack. Ifcisε, nothing is pushed, resulting in a pure pop operation.
The video below explains this graphical notation and then provides an excellent step-by-step trace of a PDA executing on an input string.
Pushdown Automata (Graphical Notation)
This video from Neso Academy clearly explains the graphical notation for PDA transitions and then walks through a complete example of tracing an input string.
Please watch from 00:51 to 03:25 to understand the graphical notation. Then, watch from 06:37 to 09:18 to see a step-by-step trace of the PDA for the language L = {0ⁿ1ⁿ} on the input string '0011'. Focus on how each transition affects the current state, the remaining input, and the stack's contents.
As you saw in the video, the PDA for works by:
- Pushing a special symbol (like or
$) to mark the bottom of the stack. - For every
0it reads in the input, it pushes a0onto the stack. - When it sees the first
1, it transitions to a new state and starts popping. - For every
1it reads, it pops a0from the stack. - If the input is exhausted and the stack contains only the initial marker , it can move to a final state.
This visual trace gives us a strong intuitive feel for how a PDA computes. Now, let's formalize this process.
2. Formalizing Execution: Instantaneous Descriptions (IDs)
To trace a PDA's execution with mathematical precision, we use a notation called an Instantaneous Description (ID). An ID is a snapshot of the PDA's entire configuration at a single moment in time.
An ID is represented as a triple: (q, w, γ)
q: The current state of the PDA.w: The portion of the input string that has not yet been read.γ: The current content of the stack, written with the top of the stack as the leftmost symbol.
A single computational step, or "move," is denoted by the turnstile symbol, ⊢.(q₁, aw, Xβ) ⊢ (q₂, w, αβ)
This expression means that the PDA, in state q₁ with a as the next input symbol and X on top of the stack, can move to state q₂, consume the a, and replace X on the stack with the string α. This corresponds to a transition δ(q₁, a, X) containing (q₂, α).
For a more detailed and formal definition of IDs and the ⊢ notation, please review the following material.
These lecture slides from the University of Waterloo provide a clear, formal definition of Instantaneous Descriptions and the notation for single and multiple computation steps.
Read the content on slides 10 through 14. Start at the slide titled 'Instantaneous description of a PDA' and continue through 'Longer derivations'. Focus on understanding the formal definition of the ID triple (q, w, γ) and the meaning of the single-step (⊢) and multi-step (⊢*) notations.
3. A Step-by-Step Formal Trace
Let's revisit our PDA for and trace the input 0011 using the formal ID notation.
Here is a diagram of the PDA. Let's name the states from left to right. The initial state is and the final state is .

The initial configuration of the PDA for the input 0011 is: (q₀, 0011, Z).
Here is the sequence of moves:
-
(q₀, 0011, Z) ⊢ (q₀, 011, 0Z)
- Transition:
0, Z / 0Z(This is a simplified notation used in some diagrams. A more explicit set of transitions would be used, but the logic is to push a 0 while reading a 0). In our chosen diagram above, this corresponds to the loop0, Z / 0Zon state . - Explanation: In state
q₀, we read0withZon the stack. We stay inq₀, consume the0, and push0Zonto the stack (effectively, push0on top ofZ).
- Transition:
-
(q₀, 011, 0Z) ⊢ (q₀, 11, 00Z)
- Transition:
0, 0 / 00on state . - Explanation: In
q₀, read0with0on top of the stack. Stay inq₀, consume the0, and push00(push another0).
- Transition:
-
(q₀, 11, 00Z) ⊢ (q₁, 1, 0Z)
- Transition:
1, 0 / εfromq₀toq₁. - Explanation: In
q₀, read1with0on top. We transition to stateq₁, consume the1, and pushε(pop the0).
- Transition:
-
(q₁, 1, 0Z) ⊢ (q₁, ε, Z)
- Transition:
1, 0 / εon stateq₁. - Explanation: In
q₁, read1with0on top. Stay inq₁, consume the1, and pop the0.
- Transition:
-
(q₁, ε, Z) ⊢ (q₂, ε, Z)
- Transition:
ε, Z / Zfromq₁toq₂. - Explanation: In
q₁, with no more input (ε), we seeZon the stack. We move to the final stateq₂. The stack content remainsZ.
- Transition:
Since we have consumed the entire input (ε is left) and ended in a final state (q₂), the string 0011 is accepted.
The following video provides another narrated example of tracing a PDA using IDs, which can help reinforce the concept.
41-INSTANTANEOUS DESCRIPTION (ID) OF PDA IN AUTOMATA THEORY || ID OF PDA ||ACCEPTANCE OF STRING||TOC
This video provides another narrated walkthrough of tracing a PDA using Instantaneous Descriptions. Seeing a second example can help solidify your understanding of the process.
Watch from the beginning to 09:34. The video introduces the ID notation and then applies it to trace the string 'aaabbb' for the same language L = {aⁿbⁿ}. Note that it uses 'z_0' as the stack bottom marker and the notation is slightly different, but the core concept is identical.
Test your understanding!
Consider a PDA designed to accept the language of palindromes with a center marker: .
Here are its transitions:
δ(q₀, a, X) = {(q₀, aX)}for anyX ∈ {a, b, Z}(Pusha's andb's)δ(q₀, b, X) = {(q₀, bX)}for anyX ∈ {a, b, Z}δ(q₀, c, X) = {(q₁, X)}for anyX ∈ {a, b, Z}(Switch to popping mode)δ(q₁, a, a) = {(q₁, ε)}(Matcha's)δ(q₁, b, b) = {(q₁, ε)}(Matchb's)δ(q₁, ε, Z) = {(q₂, Z)}(Accept if stack is empty)
The states are , the start state is , the final state is , and the initial stack symbol is Z.
Trace the execution of this PDA for the input string abacaba. Is it accepted? Wait, that's not in the language. Let's trace the input string abccba. Write out the sequence of Instantaneous Descriptions.
Show answer
The initial configuration is (q₀, abccba, Z).
-
(q₀, abccba, Z)
⊢(q₀, bccba, aZ)- Uses
δ(q₀, a, Z) = {(q₀, aZ)}.
- Uses
-
(q₀, bccba, aZ)
⊢(q₀, ccba, baZ)- Uses
δ(q₀, b, a) = {(q₀, ba)}.
- Uses
-
(q₀, ccba, baZ)
⊢(q₁, cba, baZ)- Uses
δ(q₀, c, b) = {(q₁, b)}.
- Uses
-
(q₁, cba, baZ)
⊢(q₁, ba, aZ)- Uses
δ(q₁, c, b). Whoops, there's no transition forδ(q₁, c, b). Let's re-read the transitions. Ah, thectransitionδ(q₀, c, X) = {(q₁, X)}means it keeps the stack top the same. The logic is: readw, thenc, thenw^R.
Let's restart the trace correctly.
Initial ID: (q₀, abccba, Z)
(q₀, abccba, Z) ⊢ (q₀, bccba, aZ)(Readsa, pushesa)(q₀, bccba, aZ) ⊢ (q₀, ccba, baZ)(Readsb, pushesb)(q₀, ccba, baZ) ⊢ (q₁, cba, baZ)(Readsc, switches to stateq₁, stack unchanged)(q₁, cba, baZ) ⊢Hmm, input isc, stack top isb. There is no transitionδ(q₁, c, b). The machine crashes. The stringabccbais rejected.
This highlights a key part of tracing: if no valid transition exists for a given configuration, that path of computation halts.
Let's trace a string that is in the language, like
abcba.
Initial ID: (q₀, abcba, Z)(q₀, abcba, Z) ⊢ (q₀, bcba, aZ)(q₀, bcba, aZ) ⊢ (q₀, cba, baZ)(q₀, cba, baZ) ⊢ (q₁, ba, baZ)(q₁, ba, baZ) ⊢ (q₁, a, aZ)(q₁, a, aZ) ⊢ (q₁, ε, Z)(q₁, ε, Z) ⊢ (q₂, ε, Z)
Since we end in
q₂(a final state) with the input fully consumed, the stringabcbais accepted. - Uses
Conclusion
In this lesson, we have demystified the execution of a Pushdown Automaton. We've learned how to follow the machine's computation step-by-step, both visually and through a formal mathematical notation.
Key Takeaways:
- The execution of a PDA is determined by its current state, the remaining input, and the contents of its stack.
- A transition
a, b / cmeans: readafrom input, popbfrom the stack, and pushconto the stack. - An Instantaneous Description (ID),
(q, w, γ), provides a formal snapshot of the PDA's configuration. - The turnstile notation (
⊢) formally describes a single computation step, transforming one ID into another. - A string is accepted (by final state) if the PDA can process the entire string and land in one of its final states, regardless of what's left on the stack.
Preview of the Next Lesson:
Now that we can trace a PDA's execution, the next logical step is to build them ourselves. In the upcoming lesson, we will focus on how to design PDAs that accept specific languages by final state. We will develop strategies for translating language descriptions into the states and transitions of a working Pushdown Automaton.