Created
June 22, 2012 15:41
-
-
Save shouya/2973572 to your computer and use it in GitHub Desktop.
A Turing Machine program of a simple increaser.
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
/* | |
A TURING MACHINE PROGRAM OF A SIMPLE INCREASER | |
(it does increase a binary number continously) | |
*/ | |
TYPE SYMBOL: | |
. 0 1 | |
TAPE: | |
....0 | |
^ | |
STATES: | |
R_TO_END | |
S_CONV | |
HALT /* not used in this demo */ | |
BLANK: . /* blank symbol: '.' */ | |
INIT STATE: S_CONV | |
HALT STATE: HALT /* this machine never stops */ | |
ACTION TABLE: | |
@R_TO_END: | |
. -> , L S_CONV | |
0 -> , R , | |
1 -> , R , | |
@S_CONV: | |
. -> 1 S R_TO_END /* impossible */ | |
0 -> 1 S R_TO_END | |
1 -> 0 L S_CONV | |
RESULTS: | |
....0 S_CONV | |
^ | |
....1 R_TO_END | |
^ | |
....1. R_TO_END | |
^ | |
....1 S_CONV | |
^ | |
....0 S_CONV | |
^ | |
...10 R_TO_END | |
^ | |
...10 R_TO_END | |
^ | |
...10. R_TO_END | |
^ | |
...10 S_CONV | |
^ | |
...11 R_TO_END | |
^ | |
...11. R_TO_END | |
^ | |
...11 S_CONV | |
^ | |
...10 S_CONV | |
^ | |
...00 S_CONV | |
^ | |
..100 R_TO_END | |
^ | |
(...) | |
..100. R_TO_END | |
^ | |
..100 S_CONV | |
^ | |
..101 R_TO_END | |
^ | |
..101. R_TO_END | |
^ | |
..101 S_CONV | |
^ | |
..100 S_CONV | |
^ | |
..110 R_TO_END | |
^ | |
(...) | |
..111 (...) | |
.1000 (...) | |
.1001 (...) | |
.1010 (...) | |
.1011 (...) | |
.1100 (...) | |
.1101 (...) | |
.1110 (...) | |
.1111 (...) | |
10000 (...) | |
10001 (...) | |
(...) | |
11111 (...) | |
/* | |
In the action table it has defined operations for the states, each | |
states has a group of actions for it. The first step of each state, | |
is it read the symbol from current position of the tape of the turing | |
machine, and then do a specified instruction according the symbol which | |
it have read. | |
The instruction is a 3-element tuple, with the control of: | |
* symbol to write or erase(equivalent to write the BLANK symbol) | |
* state to turn to. | |
* direction to move to. Or `S` for stay, that means `don't move` | |
`,` in the action table means `not changed`: | |
* in the write section, it could be write current symbol down | |
* in the state section, it will change to current state | |
(equivalent to not changed) | |
* in the move-direction section, it is equal to `S`, which means stay. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment