Last active
March 2, 2020 16:45
-
-
Save michlee1337/e8860a6f3a5424682f8cd9972b1ee219 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First we import the base automaton | |
from automata.base.automaton import Automaton #Begin by importing the following | |
from automata.tm.ntm import NTM | |
ntm = NTM( | |
states={'q1', 'q2', 'q3', 'q4','q5','q6','q7','q8','qA'}, | |
input_symbols={'0', '1', '#'}, | |
tape_symbols={'0', '1', '#','x','.'}, | |
transitions={ | |
'q1': { | |
'0': {('q2', 'x', 'R')}, | |
'1': {('q3', 'x', 'R')}, | |
'#': {('q8', '#', 'R')}, | |
'x': {}, | |
}, | |
'q2': { | |
'0': {('q2', '0', 'R')}, | |
'1': {('q2', '1', 'R')}, | |
'#': {('q4', '#', 'R')}, | |
'x': {}, | |
}, | |
'q3': { | |
'0': {('q3', '0', 'R')}, | |
'1': {('q3', '1', 'R')}, | |
'#': {('q5', '#', 'R')}, | |
'x': {}, | |
}, | |
'q4': { | |
'0': {('q6', 'x', 'L')}, | |
'1': {}, | |
'#': {}, | |
'x': {('q4', 'x', 'R')}, | |
}, | |
'q5': { | |
'0': {}, | |
'1': {('q6', 'x', 'L')}, | |
'#': {}, | |
'x': {('q5', 'x', 'R')}, | |
}, | |
'q6': { | |
'x': {('q6', 'x', 'L')}, | |
'#': {('q7', '#', 'L')}, | |
}, | |
'q7': { | |
'0': {('q7', '#', 'R')}, | |
'1': {('q7', '#', 'R')}, | |
'x': {('q1', 'x', 'R')}, | |
}, | |
'q8': { | |
'0': {}, | |
'1': {}, | |
'#': {}, | |
'.': {('qA', '.', 'R')}, | |
'x': {('q8', 'x', 'R')}, | |
} | |
}, | |
initial_state='q1', | |
blank_symbol='.', | |
final_states={'qA'} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment