Formal
Languages
and the
Theory of
Computation

Fall 2016
course
navigation

virtual turing machine - readme

the old version : vtm

Some years ago I wrote a "vtm" command line tool in perl. It's installed on csmarlboro.org among other places, and runs *.vtm files as described at

the new spec : yvtm

This year I'm updating that idea with a YML Virtual Turing Machine (yvtm) spec.
Here's an example .yvtm source file for the 3 state busy beaver. (See https://en.wikipedia.org/wiki/Busy_beaver .)
# busybeaver3.yvtm tape: "0" start: one blank: "0" accept: [] reject: [] machine: # current read next write move # state symbol state symbol to # ----- ------ -------- ----- ----- - [ one, 0, two, 1, right ] - [ one, 1, HALT, 1, right ] - [ two, 0, three, 0, right ] - [ two, 1, two, 1, right ] - [ three, 0, three, 1, left ] - [ three, 1, one, 1, left ]
To read this into a python program, for example, all you need do is
import yaml turing = yaml.load(open('busybeaver3.yvtm'))
which would give you this data structure
turing = {'tape' : '0', 'accept' : [], 'reject' : [], 'blank' : '0', 'machine': [['one', 0, 'two', 1, 'right'], ['one', 1, 'HALT', 1, 'right'], ['two', 0, 'three', 0, 'right'], ['two', 1, 'two', 1, 'right'], ['three', 0, 'three', 1, 'left'], ['three', 1, 'one', 1, 'left']] }
(Note: YAML will put bare words into quote strings. However, it will also convert bare numbers into number by default, so you will need to be a bit careful with symbols like 0 and convert them appropriately.)
I've also written a yvtm.py program which gives output like this :
$ python yvtm.py -help yvtm.py : YAML Virtual Turing Machine in python Usage: python yvtm.py [-quiet] [-help] [-tape=...] filename.yvtm $ python yvtm.py -quiet busybeaver3.yvtm 1 1 1 <1> 1 1 : HALT $ python yvtm.py busybeaver3.yvtm <0> : one 1 <0> : two 1 0 <0> : three 1 <0> 1 : three <1> 1 1 : three <0> 1 1 1 : one 1 <1> 1 1 : two 1 1 <1> 1 : two 1 1 1 <1> : two 1 1 1 1 <0> : two 1 1 1 1 0 <0> : three 1 1 1 1 <0> 1 : three 1 1 1 <1> 1 1 : three 1 1 <1> 1 1 1 : one 1 1 1 <1> 1 1 : HALT ** HALT ** (No matching rule)
After giving you a chance to write something that implements this, I'll upload mine.