<commit_before>Turing Machine in Python
========================

A simple Turing machine simulator using Python.

This project can be seen as a single implementation with three different
interfaces for using the Turing machines:

- Python API, where this machine can be used both as a Turing a-machine
  (automatic machine) or as a c-machine (choice machine);
- CLI (Command Line Interface), for a-machines; [*TODO*]
- Web UI in Flask, for a-machines.


About the Turing Machine
------------------------

The Turing a-machine (automatic machine) was defined by <NAME> in
his paper "On computable numbers, with an application to the
Entscheidungsproblem" (1936):

http://classes.soe.ucsc.edu/cmps210/Winter11/Papers/turing-1936.pdf

There are several useful books and other sources of information available
about that machine, for example the Wikipedia has a several references about
it:

http://en.wikipedia.org/wiki/Turing_machine

There are some diferences with the way Turing organized the ideas and his
terminology with the one used by some contemporary writers. The names
and expressions within this project tried to be as near as possible to the
ones used in his original paper. That happened as well with the way the
machine rules/instructions are written as an input for the system, trying
to remember the ordering and contents written by Turing himself in that
writing. As an example::

  b None ->  P0  R  c
  c None ->    R    e
  e None ->  P1  R  f
  f None ->    R    b

This is the first example given by Turing in his paper, written in the same
order he wrote::

  m-configuration ; scanned symbol -> behaviour ; final m-configuration

Where the ``m-configuration`` is the name he gives for the internal "state
of mind" of the computer, and the behaviour is a list of tasks to be performed
in order. Later he "normalizes" it into 3 (three) kinds of rules that entails
every other rule, however in this implementation here, the syntax allows
more than such minimalism. For example, his second example, which generates
the same tape as the result, also works in this system::

  b None ->   P0   b
       0 -> R R P1 b
       1 -> R R P0 b

For more information about the maths behind the machine, the reader should
find it on the links above.


Testing
-------

The tests are done over the project core (i.e., the API), in a TDD-like
fashion. All tests can be run with py.test directly or in a virtual
environment, needing pytest-cov package for code coverage statistics. The
easier way to run all tests in all Python versions sandboxed in a virtual
environment each one is using tox::

  $ sudo pip install tox
  $ tox

It'll run with CPython and PyPy (see tox.ini for the specific versions). This
package works in these Python versions successfully with the same single code
souce, working in both Python 2.7 and 3.x. The tests includes
the two examples said in the "About the Turing Machine" section, although
these aren't for finding something like a "final" m-configuration (indeed,
they're endless examples).


Installing
----------

For installing the API, just install the package as usual::

  $ sudo python setup.py install

or, given ``git`` and ``pip`` are installed::

  $ sudo pip install git+https://github.com/danilobellini/pyturing

For the web UI, this is a common Flask project, needing the flask itself for
practical use. It was [manually] tested with Flask 0.9 (Python 2.7.3) and
Flask 0.10.1 (Python 3.3.0). It can be installed in a virtual environment
easily after cloning the project from GitHub::

  $ virtualenv --distribute --python=python3.3 venv
  $ source venv/bin/activate
  $ pip install flask
  $ python main.py

This is mainly for debugging and evaluation. As a flask project, for deploying
you'll need an IaaS/PaaS that allows WSGI servers (better yet if there's
everything already done for Flask).


Turing DSL (Domain Specific Language)
-------------------------------------

The Turing Machine is a machine with rules/instructions, such as::<commit_msg>Travis CI img+link in README.rst<commit_after>Turing Machine in Python
========================

.. image:: https://travis-ci.org/danilobellini/pyturing.png?branch=master
   :target: https://travis-ci.org/danilobellini/pyturing

A simple Turing machine simulator using Python.

This project can be seen as a single implementation with three different
interfaces for using the Turing machines:

- Python API, where this machine can be used both as a Turing a-machine
  (automatic machine) or as a c-machine (choice machine);
- CLI (Command Line Interface), for a-machines; [*TODO*]
- Web UI in Flask, for a-machines.


About the Turing Machine
------------------------

The Turing a-machine (automatic machine) was defined by <NAME> in
his paper "On computable numbers, with an application to the
Entscheidungsproblem" (1936):

http://classes.soe.ucsc.edu/cmps210/Winter11/Papers/turing-1936.pdf

There are several useful books and other sources of information available
about that machine, for example the Wikipedia has a several references about
it:

http://en.wikipedia.org/wiki/Turing_machine

There are some diferences with the way Turing organized the ideas and his
terminology with the one used by some contemporary writers. The names
and expressions within this project tried to be as near as possible to the
ones used in his original paper. That happened as well with the way the
machine rules/instructions are written as an input for the system, trying
to remember the ordering and contents written by Turing himself in that
writing. As an example::

  b None ->  P0  R  c
  c None ->    R    e
  e None ->  P1  R  f
  f None ->    R    b

This is the first example given by Turing in his paper, written in the same
order he wrote::

  m-configuration ; scanned symbol -> behaviour ; final m-configuration

Where the ``m-configuration`` is the name he gives for the internal "state
of mind" of the computer, and the behaviour is a list of tasks to be performed
in order. Later he "normalizes" it into 3 (three) kinds of rules that entails
every other rule, however in this implementation here, the syntax allows
more than such minimalism. For example, his second example, which generates
the same tape as the result, also works in this system::

  b None ->   P0   b
       0 -> R R P1 b
       1 -> R R P0 b

For more information about the maths behind the machine, the reader should
find it on the links above.


Testing
-------

The tests are done over the project core (i.e., the API), in a TDD-like
fashion. All tests can be run with py.test directly or in a virtual
environment, needing pytest-cov package for code coverage statistics. The
easier way to run all tests in all Python versions sandboxed in a virtual
environment each one is using tox::

  $ sudo pip install tox
  $ tox

It'll run with CPython and PyPy (see tox.ini for the specific versions). This
package works in these Python versions successfully with the same single code
souce, working in both Python 2.7 and 3.x. The tests includes
the two examples said in the "About the Turing Machine" section, although
these aren't for finding something like a "final" m-configuration (indeed,
they're endless examples).

You can see these tests running in Travis CI:

https://travis-ci.org/danilobellini/pyturing

Installing
----------

For installing the API, just install the package as usual::

  $ sudo python setup.py install

or, given ``git`` and ``pip`` are installed::

  $ sudo pip install git+https://github.com/danilobellini/pyturing

For the web UI, this is a common Flask project, needing the flask itself for
practical use. It was [manually] tested with Flask 0.9 (Python 2.7.3) and
Flask 0.10.1 (Python 3.3.0). It can be installed in a virtual environment
easily after cloning the project from GitHub::

  $ virtualenv --distribute --python=python3.3 venv
  $ source venv/bin/activate
  $ pip install flask
  $ python main.py

This is mainly for debugging and evaluation. As a flask project, for deploying
you'll need an IaaS/PaaS that allows WSGI servers (better yet if there's
everything already done for Flask).


Turing DSL (Domain Specific Language)
-------------------------------------

The Turing Machine is a machine with rules/instructions, such as::
{'fraction_non_alphanumeric': 0.08199103790723022, 'fraction_numerical': 0.00920431149327843, 'mean_word_length': 3.559911651021535, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3887741', 'n_tokens_mistral': 2331, 'n_tokens_neox': 2190, 'n_words': 1205}