Skip to content

ericshantos/turing-py

Repository files navigation

[🇧🇷] Lê em português

Turing-py

A simple and extensible Turing Machine simulator written in Python, designed for learning, experimentation, and educational purposes.

PyPI Python 3.12 License: MIT

Install directly from the Python Package Index (PyPI):

pip install turing-py

📚 About

A Turing Machine is an abstract computational model introduced by Alan Turing in 1936. It is widely used in computer science to study the limits of computation and algorithm design.

turing-py provides a Python implementation that enables:

  • Simulation of Turing Machines
  • Creation of custom transition rules
  • Step-by-step computation
  • Experimentation with theoretical algorithms

This project is intended for:

  • Computer Science students
  • Theory of Computation courses
  • Developers interested in computational models
  • Educational demonstrations

📦 Installation

Install using pip:

pip install turing-py

Or install from source:

git clone https://github.com/ericshantos/turing-py.git
cd turing-py
pip install .

✨ Features

  • Deterministic Turing Machine simulation
  • Customizable tape input
  • Configurable states and transitions
  • Step-by-step execution
  • Simple and modular Python architecture
  • Easy to extend and modify
  • CLI-ready structure

📂 Project Structure

turing-py/
│
├── pyproject.toml
├── README.md
├── LICENSE
├── .gitignore
│
├── src/
    └── tmpy/
        ├── __init__.py
        │
        ├── machine/
        │   ├── __init__.py
        │   ├── turing_machine.py
        │   ├── tape.py
        │   └── states.py
        │
        ├── alphabet/
        │   ├── __init__.py
        │   ├── symbol.py
        │   ├── alphabet.py
        │   └── tape_alphabet.py
        │
        └─ transition/
            ├── __init__.py
            ├── transition.py
            ├── transition_function.py
            └── direction.py

🧪 Example Turing Machines

Examples you can implement using turing-py:

  • Binary increment machine
  • Palindrome checker
  • Unary addition
  • Even/Odd binary checker
  • String copying machine

🧩 How It Works

A Turing Machine consists of:

  • Tape – infinite memory divided into cells
  • Head – reads and writes symbols on the tape
  • States – machine configuration states
  • Transition Function – rules that determine the next action

Each step follows this rule:

(Current State, Read Symbol) → (Next State, Write Symbol, Move Direction)

Where direction can be:

  • L → Move left
  • R → Move right

🤝 Contributing

Contributions are welcome!

To contribute:

  1. Fork the repository
  2. Create a new branch
git checkout -b feature/my-feature
  1. Make your changes
  2. Commit your work
git commit -m "Add new feature"
  1. Push to your fork
git push origin feature/my-feature
  1. Open a Pull Request

📜 License

This project is licensed under the MIT License.


👨‍💻 Author

Developed by Eric Santos.

About

A Turing Machine implementation in Python with customizable states, tape and transition functions.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages