Because of differences in monitors, sometimes the display of the contents of the tape in the Turing machine may not exactly line up with the read-write head. Before starting, adjust the position of the tape using the two buttons below.
Tape Movements
Changing Tape Contents, Current State, Program Elements
The contents of the tape, the current state (shown in the read/write head), and the values in the program instructions can be modified simply by clicking on the cell. The values will cycle through the allowable set repeatedly.
Last updated 2001/07/24
The example solves the problem of finding the right hand end of a tape starting anywhere within the non-blank characters on a tape with initial state A. Note that having skipped over the possible characters on the tape and finding a blank, it is necessary to move back one cell so as to point to the ending character. The program halts when there is no match with the state B (which has no applicable instructions in the program). Test the program first by following the example installed and then by entering your own strings on the tape (click on the cells to change the stored value) and by setting the starting state to A. Make sure the tape is in the correct position by using the arrow buttons alongside the tape.
This sample program solves the problem of starting anywhere within a non-blank section of a tape and locating the first (leftmost) cell containing a star (*). As in problem 1, the program is caused to halt when the character being sought is NOT contained in any instruction. Test the program first by following the example installed and then by entering your own strings on the tape (click on the cells to change the stored value) and by setting the starting state to A. Make sure the tape is in the correct position by using the arrow buttons alongside the tape.
This problem (also described in the notes) provides the simplest algorithmic description of the arithmetic operation of addition. Monadic numbers are those that contain as many symbols are in the value of the number. Thus the decimal number 4 is represented by 4 symbols, chosen in our example to be 1's. Thus 4decimal = 1111monadic. This solution sets up two numbers on the tape separated by the + symbol, and terminated on the right with star (*), and the initial state (A) pointing to that symbol. The process is simply to replace the + by 1 and then delete the rightmost 1 in the resulting representation. Test the program first by following the example installed and then by entering your own strings on the tape (click on the cells to change the stored value) and by setting the starting state to A. Make sure the tape is in the correct position by using the arrow buttons alongside the tape.
Sorting is a common problem in computing; this example shows that a Turing Machine is capable of such "complex" activity. In this case we limit the symbols in the string to be sorted to 0 or 1, and delimit the tape on both sides by *. Initially the string to be sorted in placed on the tape with the leftmost 0 or 1 over the read/write head and the initial state set to A.
In this program the states are used to "remember" what had been seen at the last step as follows:
Test the program first by following the example installed and then by entering your own strings on the tape (click on the cells to change the stored value) and by setting the starting state to A. Make sure the tape is in the correct position by using the arrow buttons alongside the tape.
Display Adjustment
Move tape left one cell.
Move tape right one cell.
Move tape left to rightmost non-blank character.
Move tape right to leftmost non-blank character.
© J.A.N. Lee, 2001.
State
Tape
State
Tape
Move
The starting state; also used to restart the sort after swapping the initial 1 and 0.
This state "remembers" that the last character examined was 0.
This state "remembers" that the last character examined was 1. Thus if the next character seen is a zero (0) a swap is necessary; we know that the character to be in this position after the swap will be 1 and thus it is inserted into the tape now.
A swap is in process (the state was changed to D from C) and thus a 0 will appear here, but continue to look left (i.e. move the tape right).
The state does most of the work! State E is used while looking left on the tape to see whether a 0 needs moving further to the left. If a 1 is seen above the E then then we know that the character to the right is 0 and needs swapping with this character, so move the tape right one space and go to state C. If a 0 is found then continue to look to the left (i.e. move the tape right). If we get to the left-hand end of the tape (*) then we restart the sort from the item to the right in state A.