Tree @master (Download .tar.gz)
Turmac
Version 0.4
Turmac is a file format for Turing machine descriptions. It aims to be somewhat self-describing and amenable to processing with common tools. To that end, it is defined as a subset of CSV files. In short, Turmac files look like this:
in state,if the symbol is,write the symbol,move the head,go to state
S0,_,1,R,S0
S0,1,1,L,@H
Turmac also defines a CSV format for TM traces (which are lists of configurations (which consist of the tape contents and current finite state)), which are useful for describing the full run of a Turing machine. The output of a Turing machine can also be described by a trace showing one (final) step. Traces look like:
at step,in state,at position,the cell contains,with heads present
1,S0,0,A,
2,S0,1,Z,1
For a fuller definition of the Turmac file formats, see the document
Definition-of-Turmac.md in the doc/ directory.
Quick start
The reference implementation, turmac, is written in Haskell. It may be either
compiled with GHC, or interpreted with Hugs. With one of these installed,
- clone this repository
- run
./build.shin the root directory of the repository - the executable is
./bin/turmac; you may want to put thebindirectory on your executable search path ($PATHenv var in Linux et al.)
turmac can do the following things:
- Simulate a Turing machine, given its Turmac description.
- Compile a Turmac description to a Python program that simulates the TM.
- Round-trip (parse and then dump out) a Turmac description.
- Normalize the state IDs and symbol labels in a Turmac description.
- Create a Turmac description that writes a given string to the tape.
TODO
- Define comments in language (6th column) and tests for this.
- Implement
--max-stepsfor simulator. - Describe harness for running the code produced by a compiler and
comparing it to the simulation run by
turmac. - Utility to create random Turing machines.
- (low) Ability to concatenate two Turing machines.
History
0.4
- Halt states are now any states whose names begin with
@. What was conventionally labelledHis now conventionally labelled@H. - Multiple halt states are allowed. This supports describing
language recognizer Turing machines with distinct "Accept"
and "Reject" states, conventionally labelled
@Aand@R. - Completely refactored command-line usage.
- Fixed 2 gaps in completeness-checker: it wasn't considering
states that had no rules but were the destination of a transition;
and it wasn't checking for handling
_(blank symbol), which is always a member of the set of symbols of a machine. - Improved the internal guarantee that the TM description is complete before normalization can happen on it.
- Added facility to check if input Turing machine is deterministic.
0.3
- Defined the execution trace format, and updated the implementation (both the simulator and the Python backend) to dump traces, and final configurations, in this format.
- Implemented
intercalate, allowingturmacto run under Hugs. - Tests are run under all implementations that are available.
- Kondey backend was removed on the grounds that, as an obscure and special-purpose intermediate language, it is out of scope for this general-purpose tool. It was moved to the Burro repo.
0.2
- Added beginnings of a Kondey backend for compiler (still WIP).
- Fixed
gentapesubcommand. It now takes a comma-separated list of symbols to write to the tape, and honours (and requires) the--backendoption. - Added
--normalizeflag, which works with all subcommands.
0.1
Initial release.
Commit History
@master
git clone https://git.catseye.tc/Turmac/
- Checkpoint fixing gentape subcommand. Chris Pressey 1 year, 7 months ago
- In Kondey backend, make sure tape head is over cell to be tested. Chris Pressey 1 year, 7 months ago
- Continue to develop the compiler to Kondey. Chris Pressey 1 year, 7 months ago
- Develop the compiler to Kondey. Chris Pressey 1 year, 7 months ago
- Add beginnings of the Kondey backend. Chris Pressey 1 year, 7 months ago
- Refactor IR. Chris Pressey 1 year, 7 months ago
- Note what version number we're at. Chris Pressey 1 year, 7 months ago
- Place it all in the public domain. Chris Pressey 1 year, 7 months ago
- Update README. Chris Pressey 1 year, 7 months ago
- Add normalization logic. Chris Pressey 1 year, 7 months ago
- Document flags. Add a Turmac example TM that copies a string. Chris Pressey 1 year, 7 months ago
- Round-trip (compile to Turmac); 3 more tests for format syntax. Chris Pressey 1 year, 7 months ago
- Update README. Chris Pressey 1 year, 7 months ago
- The blank symbol is represented by `_`, no longer by `0`. Chris Pressey 1 year, 7 months ago
- State IDs are strings. The start state is called 'S0'. Chris Pressey 1 year, 7 months ago
- Move the specification to `Definition-of-Turmac.md`. Chris Pressey 1 year, 7 months ago
- Replace `parse` subcommand with an `ir-dump` compiler backend. Chris Pressey 1 year, 7 months ago
- Add Language.Turmac.Simulator module, deprecating IRInterpreter. Chris Pressey 1 year, 7 months ago
- Push buildProgram further down. Chris Pressey 1 year, 7 months ago
- Tiny step of pushing buildProgram out of parse Chris Pressey 1 year, 7 months ago
- Split IR from TM model some more. Chris Pressey 1 year, 7 months ago
- Begin to split up concerns: IR is not needed for most things. Chris Pressey 1 year, 7 months ago
- Remove bogus example. Need to rewrite using string-valued states. Chris Pressey 1 year, 7 months ago
- Update Python backend. Chris Pressey 1 year, 7 months ago
- Switch to using string-valued state IDs and symbols. Chris Pressey 1 year, 7 months ago
- Add --backend flag. Chris Pressey 1 year, 8 months ago
- Repair the implementation of get_tape_contents(). Chris Pressey 1 year, 8 months ago
- One of the things in get_tape_contents() is not quite right Chris Pressey 1 year, 8 months ago
- Add feature to compile Turmac to TM implementation in Python. Chris Pressey 1 year, 8 months ago
- Clean up Interpreter module, it doesn't actually use state monad. Chris Pressey 1 year, 8 months ago