A simple simulator of the unary mathematical model of a Turing Machine, as studied at ESI Algiers. This project is designed for educational purposes, helping students visualize and understand how a Turing Machine operates step by step.
The simulator implements a unary representation of natural numbers and executes algorithms defined as formal Turing Machine instructions. It provides a visual tape, a reading head, and an execution environment similar to a small IDE.
- The tape is initially filled with
0s, which represent blanks. - The reading head starts at a fixed position and always reads the highlighted cell.
- The machine works only with natural numbers (including
0). - A number
nis represented usingn + 1bars (|).
Examples:
0→|2→|||5→||||||
- Multiple arguments are separated using an asterisk (
*).
Examples:
(2, 3)→|||*||||(1, 0, 2)→||*|*|||
!! No spaces are allowed between symbols.
Each instruction of the algorithm must follow this exact format:
<current_state>,<read_value>,<action_to_take>,<next_state>
- The current state of the machine.
- The symbol currently read by the head (
0,|, or*).
The action can be either a move or a write:
Move actions:
R→ move one cell to the rightL→ move one cell to the left
Write actions:
0→ write a blank|→ write a bar*→ write an asterisk
!! If the machine encounters a state/read-value combination with no defined instruction, the simulator will throw a runtime error.
- The state to transition to after executing the action.
Two cases:
- Defined next state → execution continues.
- Undefined next state → the program halts, marking the end of execution.
- You can manually stop execution at any time using the red “Halt” button in the interface.
- On the right side of the screen, below the IDE, you will find a set of remarks.
- These notes provide helpful guidance for using the simulator.
- A full and detailed documentation will be uploaded in the future and will replace these remarks.
This simulator is intended to:
- Help students understand formal Turing Machine execution
- Visualize tape manipulation and state transitions
- Experiment with unary algorithms in a controlled environment
- Full documentation
- Example programs (addition, subtraction, comparison, etc.)
- Improved error messages
- Export / import of machine definitions