Universal Turing Machine Emulator
utme is a library that provides Turing machine emulation in pure Python.
With utme, you can define a Turing machine, run it with an input and inspect its output.
Note: I wrote this library to help myself understand Turing machines. utme is not suitable for efficient/performant Turing machine emulation.
Why is it called universal?
As the library allows you to define any valid Turing machine (universal or not) and run it, the library itself is equivalent to a universal Turing machine (a Turing machine that accepts another Turing machine and an input for it, and yields its output).
While utme does not emulate a universal Turing machine by itself, I found
the name cool (It was originally utm, but then I found out it was already
taken by another project on PyPI).
That said, there is an example script that
composes universal_machine; a universal Turing machine using utme.
The script also provides encode/decode functions that converts utme
objects from and into valid tapes for universal_machine (so you can even pass
universal_machine (with an input) to itself!).
Installation
utme is available in the Python Package Index:
pip install utme
The library has zero dependencies and should work on any Python (3.12+) implementation on any platform.
Documentation
utme's API is documented at the definition level (via docstrings where possible, and comments otherwise).
The library code is around 250 logical line of codes, so you can easily read the source code to understand implementation details.
Exported objects are categorized and enumerated briefly in the package's docstring:
python -m pydoc utme
Examples
Examples of Turing machines implemented using utme are included in the examples directory.
Development
You only need uv and just on your POSIX system to get
started.
Run just (without arguments) to see available tasks.
Contribution
Before you submit a patch, please run just precommit and make sure the task
runs successfully. Patches that don't pass just precommit will not be
merged.
License
utme is licensed under the MIT (Expat) license.
Copyright (C) 2025 Karam Assany (karam.assany@disroot.org)
Release files for utme 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| utme-1.0.1.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| utme-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.2 kB
Release files / utme-1.0.1.tar.gz
| Download URL | utme-1.0.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
deddb326f9fd387f1de0cf1be3eba7a76618f8d33858f7f641369b1e3ab7ba0c
|
|
BLAKE2b-256 checksum How to use checksums |
ab5661d3357997803e722074a033cc5b6960a7eb78455c01e70857d1d22b9550
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|
Release files / utme-1.0.1-py3-none-any.whl
| Download URL | utme-1.0.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1097acbb6170df0180752324224f8813a379655700693900c0d6a9e92d1e65a8
|
|
BLAKE2b-256 checksum How to use checksums |
21a4f4b307e2f16d3b8ff0b5dbec0af17b4645d4688876a98ff827912958b5ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.3
|