Giter Site home page Giter Site logo

tsim's Introduction

Turing Machine Simulator

This project implements a Turing machine simulator, and includes a number of Turing machines to demonstrate how it works.

Turing Machine Conventions

We choose to represent a Turing machine using the TURING signature. This is the best place to start to gain an understanding of the complete system.

For a quick summary, our TURING signature sets up the following conventions:

  • a tape alphabet that includes a blank symbol
  • a two-way infinite tape, represented as a two-way unbounded array
  • a state transition function that allows (but does not require) writing and moving in the same operation
  • a single initial and a single final state

Again, you are encouraged to read the TURING signature for more details.

Building and Running

This code complies cleanly under both SML/NJ and MLton. If possible, we strongly recommend compiling it using MLton, as it is orders of magnitude faster.

MLton

Once you've installed MLton, building is just one simple command.

You can get usage information by running the command with no arguments.

$ make mlton

$ ./tsim
usage: ./tsim (add|mult|exp) <n> <m>

$ ./tsim add 1 1
[Q0]  11 11
     ^
[Q1]  11 11
      ^
[Q1]  11 11
       ^
[Q1]  11 11
        ^
[Q2]  11111
         ^
[Q2]  11111
          ^
[Q2]  11111
           ^
[Q3]  11111
          ^
[Q4]  1111
         ^
[Q5]  111
        ^
[Q5]  111
       ^
[Q5]  111
      ^
[Q5]  111
     ^
[Q6]  111
     ^
Answer: 2

SML/NJ

The build system isn't quite as polished, but it still works well enough.

$ make smlnj

$ sml -m sources.cm app/call-main.sml
... stuff ...
usage: ./tsim (add|mult|exp) <n> <m>

$ sml -m sources.cm app/call-main.sml add 1 1
... stuff ...
[Q0]  11 11
     ^
[Q1]  11 11
      ^
[Q1]  11 11
       ^
[Q1]  11 11
        ^
[Q2]  11111
         ^
[Q2]  11111
          ^
[Q2]  11111
           ^
[Q3]  11111
          ^
[Q4]  1111
         ^
[Q5]  111
        ^
[Q5]  111
       ^
[Q5]  111
      ^
[Q5]  111
     ^
[Q6]  111
     ^
Answer: 2

Supported Turing Machines

We implement three Turing machines: addition, multiplication, and exponentiation. The attributions for these machines can be found in Credits. Each has been implemented ascribing to the TURING signature, and resides in lib/turing/.

Credits

License

MIT License

Copyright Jacob Zimmerman. See badge link above for license information.

tsim's People

Contributors

jez avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.