A graphical Pushdown Automaton (PDA) simulator developed in Python to recognize the language:
L = { w^m a^n (i + j) d^n w^-m | n, m ≥ 0, w = (b + c) }*
This project was created as Practice #4: Pushdown Automata, with the goal of building a computational simulation of a PDA that validates strings in the language above and visually shows how the automaton works.
The simulator provides an interactive graphical interface where the user can enter a string from the keyboard and observe:
- the current automaton state
- the values of n and m
- the content of the stack
- the input tape
- step-by-step transitions
- final acceptance or rejection of the string
This helps illustrate how a pushdown automaton processes input and uses its stack to verify a formal language.
The main objective of this project is to simulate a pushdown automaton capable of recognizing the language:
L = { w^m a^n (i + j) d^n w^-m | n, m ≥ 0, w = (b + c) }*
The program was designed to:
- receive input strings from the keyboard
- simulate the PDA behavior computationally
- graphically display states and transitions
- show the stack evolution during execution
- indicate whether the string is accepted or rejected
The language has the following structure:
- w^m: a sequence of symbols made of
bandc - a^n: a sequence of
a - (i + j): a pivot symbol, either
iorj - d^n: a sequence of
dthat must match the number ofa - w^-m: the final part validated using the stack contents
- The automaton reads a prefix made of
bandcsymbols. - Then it reads a block of
asymbols. - It must find a pivot symbol:
iorj. - After that, it reads
dsymbols to match the number ofa. - Finally, it verifies the remaining symbols using the stack.
- The string is accepted only if the input is fully consumed and the stack is empty.
- Interactive graphical interface
- Keyboard input for test strings
- Visual simulation of PDA states
- Real-time stack display
- Input tape visualization
- Step-by-step navigation
- Automatic animation mode
- Speed control for the simulation
- Acceptance/rejection feedback
- Python 3
- Matplotlib
- Native Matplotlib widgets:
ButtonTextBoxSlider
Before running the project, make sure you have:
- Python 3 installed
- Matplotlib installed
Install Matplotlib with:
pip install matplotlib