A modern educational and experimental simulator for deterministic multi-tape Turing machines written in C++23.
It has three layers:
- Core: the actual machine model and simulator
- CLI: a terminal app for running a machine from a TOML config file
- GUI: a Qt front end that will allow to create, modify, save and open machines
- Features
- Machine Specification
- Machine File Format
- Requirements
- Project Structure
- Build
- Core
- CLI
- GUI
- Documentation
- Roadmap
- Contributing
- Acknowledgements
- License
- Deterministic multi-tape Turing machines
- Configurable through TOML
- Infinite tapes
- Interactive CLI
- Batch execution
- Project serialization
- Modern C++23 implementation
- Cross-platform
MTMS implements deterministic multi-tape Turing machines following the formal definition
where
-
$Q$ is the finite set of states. -
$\Sigma$ is the input alphabet. -
$\Gamma$ is the tape alphabet. -
$q_0 \in Q$ is the initial state. -
$\sqcup \in \Gamma$ is the blank symbol. -
$F \subseteq Q$ is the set of accepting states.
The transition function is
where (k) denotes the number of tapes.
MTMS uses a TOML-based domain-specific format to define Turing machines.
A machine file is composed of four main sections:
metadatamachinestatestransitions
examples/bin_inc.toml is a good starting point.
It defines:
- a 2-tape machine
- binary input alphabet
- a blank-aware tape alphabet
- states for copy, increment, and accept
- transitions that copy the input, then add 1
- C++23 compatible compiler (Clang 17+, GCC 13+ recommended)
- CMake 3.25+
- Ninja or Make (recommended: Ninja)
- toml++ (header-only, included in
include/toml++/toml.hpp)
See ARCHITECTURE.md
The project uses CMake.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build buildIf you want only the CLI, leave BUILD_CLI=ON and BUILD_GUI=OFF as they are. Otherwise:
# build the GUI AND the CLI
cmake -S . -B build -DBUILD_GUI=ON -DCMAKE_BUILD_TYPE=Release
# only build the GUI
cmake -S . -B build -DBUILD_CLI=OFF -DBUILD_GUI=ON -DCMAKE_BUILD_TYPE=ReleaseThe Core library is independent from both the CLI and GUI and contains the complete implementation of the Turing machine model:
- Symbols and the blank tape symbol [with Symbol]
- Alphabets for input (
Sigma) and tape work symbols (Gamma) [with Alphabet] - Strings as validated symbol sequences [with String]
- Tapes with an infinite left/right model [with Tape]
- States with accept/non-accept flags [with State]
- Transitions for deterministic multi-tape rules [with Transition]
- Projects that load and save TOML machine files [with Project]
- TuringMachine execution across multiple tapes [with TuringMachine]
In practice, the core:
- Reads a TOML blueprint using Project::load_project()
- Validates the machine structure
- Loads the input onto tape 0
- Steps through transitions one move at a time using TuringMachine::step()
- Stops on accept or halt/reject
- Can export the loaded machine back to TOML using Project::save_project()
The simulator is deterministic, multi-tape, and supports blank cells, left/right/stay movement, and a safety step cap during TuringMachine::run().
mtms-cli is the current user-facing app.
It:
- loads a machine from
--config - loads the input string with
--input - runs interactively by default
- runs silently in
--batchmode - can export the loaded machine to a TOML file with
--output
mtms-cli --config examples/bin_inc.toml --input "1011" --batch-c, --config <path>: machine config TOML file-i, --input <string>: input string loaded onto tape 0-b, --batch: non-interactive mode, prints a summary line-o, --output <path>: export the current project to TOML-h, --help: show help
- Interactive mode shows a live dashboard with the current state, step count, and all tapes.
- Batch mode prints a compact result like
STATUS=ACCEPTED;STEPS=...;FINAL_STATE=.... - If the input contains symbols outside the input alphabet, it fails early.
- If the TOML is invalid, incomplete, or non-deterministic, it stops before execution.
The GUI is currently under development.
The GUI will be the same machine viewer/editor on top of the core instead of a separate simulator. That means:
- load and inspect TOML machine files
- visualize states, tapes, and transitions
- step through execution visually
- show accept/reject clearly
- export the project back to TOML
In short: the core does the math, the CLI does the terminal workflow, and the GUI will be the friendlier visual front end.
The complete API reference is generated automatically using Doxygen and published through GitHub Pages.
| Documentation | Description |
|---|---|
| API Reference | https://wh0crypt.github.io/mtms |
| Examples | examples/ |
- Core library
- TOML project format
- Multi-tape simulator
- CLI application
- Qt graphical interface
- Doxygen documentation
- Unit tests
- Graphical state editor
- Interactive debugger
- Breakpoints
- Undo/Redo
- Export diagrams
Contributions are welcome.
If you would like to contribute:
- Fork the repository.
- Create a feature branch.
- Follow the project's coding style.
- Open a Pull Request.
Please open an issue before proposing major changes.
See CONTRIBUTING.md for detailed guidelines.
This project is licensed under the MIT License. See LICENSE for the full license text.
- toml++ — modern header-only TOML parser used in the core configuration system.
- TheLazyFerret — inspiration for the CLI workflow and interactive simulation design.
- Francisco de Sande and Gara Miranda Valladares — for teaching the Formal Languages and Automata Theory course that inspired this project.
- JFLAP — for inspiring the graphical representation and simulation of Turing machines.