Awesome Turing Machine
Happy birthday, Crystal! This is your geeky gift of 2012.
If you have no idea of what Turing Machine is, here is a gentle introduction.
A Turing machine has an infinite one-dimensional tape divided into cells. Traditionally we think of the tape as being horizontal with the cells arranged in a left-right orientation. The tape has one end, at the left say, and stretches infinitely far to the right. Each cell is able to contain one symbol.
The machine has a read-write head which is scanning a single cell on the tape. This read-write head can move left and right along the tape to scan successive cells.
The action of a Turing machine is determined completely by (1) the current state of the machine (2) the symbol in the cell currently being scanned by the head and (3) a table of transition rules, which serve as the “program” for the machine.
Each transition rule is a 5-tuple:
<this state, this symbol, that state, that symbol, shift>
which can be read as saying ‘if the machine is in this state and the cell being scanned contains this symbol, then it move into that state, write that symbol on the tape in the current cell and make a shift left or shift right, or stand still’.
If the machine reaches a situation in which there is no unique transition rule to be carried out, i.e., there is none or more than one, then the machine halts.
Every Turing machine has the same machinery. What makes one Turing machine perform one task and another a different task is the table of transition rules that make up the machine’s program, and a specified initial state for the machine.
Turing machine is pretty simple, but actually it is sophisticated to calculate all computable functions. To exaggerate a little bit, a Turing machine is as sophisticated as a modern computer.
Here is an entry-level design: Two to Infinity.
Initial State | |||||
Transition Rule 1 | blank | 2 | shift right |
It starts with the state 0 and whenever it sees a blank cell, it fills it with 2 and makes a shift to the cell on the right. It’s simple, isn’t it?
I hope you’ve got some ideas of how to design a turing machine. Here is another breakdown of my invention. It is intended to do the following things.
- Erase all symbols on the tape.
- Write down ‘I always love you.’.
The table of rules looks like this:
Initial State | a | ||||
Transition Rule 1 | a | ␣ | a | blank | shift right |
Transition Rule 2 | a | ␣ | a | blank | shift right |
Transition Rule 3 | a | ! | a | blank | shift right |
Transition Rule 4 | a | “ | a | blank | shift right |
… | … | … | … | … | … |
Transition Rule 95 | a | ~ | a | blank | shift right |
Transition Rule 96 | a | blank | b | I | shift right |
Transition Rule 97 | b | blank | c | blank | shift right |
Transition Rule 98 | c | blank | d | a | shift right |
Transition Rule 99 | d | blank | e | l | shift right |
… | … | … | … | … | … |
Transition Rule 113 | r | blank | s | . | shift right |
We start from the initial state ‘a’, and erase whatever we see along the tape and keep shifting right until we meet the first blank. Those are fulfilled by the first 96 rules. After that we keep increasing the current state from ‘a’ to ‘z’ and write down ‘I always love you.’.
By setting the initial input as ‘No matter what is written on this tape,’, we are done.
Now you can build your own Turing Machine at awesometuringmachine.com. Enjoy yourself.
By the way, browse it on your smart phone and get surprised.