-
Notifications
You must be signed in to change notification settings - Fork 0
Pushdown Automata
AutomataLab supports both Deterministic (DPDA) and Nondeterministic (NPDA) Pushdown Automata for parsing Context-Free Languages. Unlike finite automata, PDAs incorporate a LIFO Stack into their execution.
When you connect two states in a PDA, the Transition Editor asks for three fields:
-
Read: The input symbol to consume (e.g.,
a). -
Pop: The symbol to pop from the top of the stack (e.g.,
Z). -
Push: The symbol(s) to push onto the stack (e.g.,
XZ).
On the canvas, this transition will render mathematically as a ; Z → XZ.
Just like
-
Empty Read: If you leave
Readempty, the transition will fire without consuming any input (an$\epsilon$ -transition). -
Empty Pop: If you leave
Popempty, the transition does not require or remove anything from the stack. -
Empty Push: If you leave
Pushempty, the transition does not push anything new (effectively just popping).
By convention in AutomataLab:
- The Top of the stack is visually represented at the top of the UI Stack panel.
- When you define a
Pushstring of multiple characters (e.g.,XZ), the first character in the string (X) ends up at the top of the stack. This aligns with standard push operations where the sequence is pushed in reverse order so the leftmost symbol is at the top.
A major feature of AutomataLab's PDA engine is intelligent tokenization of the Stack. You are not restricted to single-character characters like A, B, or Z.
In the toolbar, you can define the explicit Stack Alphabet (["id", "+", "*", "E"].
If your Push string is E+id, the engine does not push E, +, i, and d. Instead, it intelligently tokenizes the string against your declared E, +, and id.
If the user has not defined
When running a PDA, the right-hand Side Panel automatically switches to the Stack View. As the machine consumes input, you can watch tokens physically push onto and pop off the graphical stack in real time.
Unlike NFAs, an NPDA computation path cannot be merged into a trellis because two identical states might have completely different stack contents!
Because NPDAs truly branch exponentially, AutomataLab uses an infinite-loop guard (stepLimit) to prevent browser freezes on deeply recursive empty transitions. The Computation Tree Panel is critical here: click on the Tree icon in the sidebar to view the full branching hierarchy and click any node to instantly jump to that parallel timeline, loading its specific stack state.
AutomataLab strictly validates DPDA constraints before running:
- You cannot have two transitions from the same state that read the same input and pop the same symbol.
- If an
$\epsilon$ -read transition exists that popsZ, no other transition (even those reading input) can popZfrom that state.
Violations will be highlighted in the Validation Warning banner at the top of the canvas.
- Machine Workspace Guide
- Grammar Lab Guide (For converting CFGs to NPDAs)
AutomataLab v4.1.0 · Repository · Download · Web app · MIT License
Getting Started
Machine Workspace
- Workspace Overview
- Finite Automata
- Pushdown Automata
- Turing Machines & LBA
- Transition Table & Data Tools
Grammar Lab
Parser Studio
Project & Architecture