Skip to main content

Calculate the result of a turing machine on a given tape

Project description

Table of Contents

Introduction

Run any Turing machine possible using this function and see if the turing machine, accepts or rejects the tape you input to it.

Installation

pip install turing-machine-utils

Usage

from turing_machine_utils import create_turing_machine

# Define Turing Machine states, alphabet, and transition rules
states = ['q0', 'q1', 'accept', 'discard']
transition_rules = {
    ('q0', '0'): ('q1', '1', 'R'),
    ('q0', '1'): ('q0', '0', 'R'),
    ('q1', '0'): ('accept', '0', 'L'),
    ('q1', '1'): ('discard', '1', 'L'),
}

# Define the input tape
tape = ['0', '1', '0', '1', '0']

# Run the Turing Machine
result, new_tape, state, symbol = create_turing_machine(tape, states, transition_rules)
print("Result:", result)

remember that the machine will start calculating the response from the first state. So the first element on the states list must be the beginning state

The result will be:

  1. 1 if the tape is accepted by the turing machine
  2. -1 if the state is discarded by the turing machine
  3. 0 if an undefined transition is found by the turing machine

The new_tape is the tape with the changes to the original tape

The state and symbol are normally None. They get values that say when the turing machine reached an undefined point

Configuration

No specific configuration options are available at the moment.

Contributing

Feel free to contribute by reporting issues, suggesting improvements, or submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turing_machine_utils-1.0.7.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

turing_machine_utils-1.0.7-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file turing_machine_utils-1.0.7.tar.gz.

File metadata

  • Download URL: turing_machine_utils-1.0.7.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for turing_machine_utils-1.0.7.tar.gz
Algorithm Hash digest
SHA256 db56a2bd52ecd12b6156ffa5917f5894921ea2e3294ddfe13a4d0bbd51277e41
MD5 955ae0615c1db0a60fc75151656b5bfd
BLAKE2b-256 88db4921fac79015832ee56dc1a96b52174d5cf5c4ef4d17d67e67f63ec009fe

See more details on using hashes here.

File details

Details for the file turing_machine_utils-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for turing_machine_utils-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ba73277a4ec836f4d3c7b777547bd7da721445c43ae257afa72c99f0094c217d
MD5 e02b5c5ca3e316b7d98bd728d3c2dd93
BLAKE2b-256 91c009545625b7e0302eb515fb622a24687ddf9cd20c1ffd3e79c72bb7cf862e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page