What is a Turing Machine? An Informal Introduction to Computation V Vinay [email protected] On the occasion of Alan Turing’s centenary. Remember the old arithmetic book when you were a child? 3 2 9 7 4 You can enter only one digit into a cell. 1 To simplify, why not have all cells in a single row? 3 2 9 7 4 Now, 32974 will not change unless we make it change. So, let us define some rules that can change the cell contents. But first ... the mood of a Turing machine! 2 A Turing machine can be in many moods. Angry Happy Peaceful Sad Make up as many moods (i.e., colors) as you need. Of course, the names (Angry/Happy etc) are not important. We could have called the moods 1,2,3,4 if we wanted. 3 The other thing is that like a good child, you focus on a single cell at a time. 3 2 9 7 4 Your entire focus is on this cell with a “9” now. This comes from looking at horses with blinkers. Focus, Focus, FOCUS! 4 We add your current mood to the cell you are focussing on. 3 2 9 7 4 3 2 9 7 4 Or 5 Now to the rules. Here is an example rule. If your mood is red, and you see the digit “7”, change the digit to “6”, move right, and your current mood is green! if digit:7, mood: then digit:6, move:right, color: 6 A Turing machine is a set of rules defined on a set of colors and a set of digits. We assume the number of cells is arbitrary. You will never run out of cells. This is a blank cell. 3 2 9 7 4 The rules can also say what to do on a blank cell. Otherwise the machine will halt. 7 Let us define a simple Turing machine. Our machine will have three moods: It uses digits 0 and 1 and # for blank digit:0, mood: then digit:1, move:right, mood: (Rule 1) if digit:1, mood: then digit:1, move:left, mood: (Rule 2) if digit:1, mood: then digit:1, move:left, mood: (Rule 3) if digit:#, mood: then digit:#, move:halt, mood: (Rule 4) machine halts if digit:#, mood: then digit:#, move:halt, mood: (Rule 5) machine halts if 8 Example 1: digit:0, mood: then digit:1, move:right, mood: (Rule 1) if digit:1, mood: then digit:1, move:left, mood: (Rule 2) if digit:1, mood: then digit:1, move:left, mood: (Rule 3) if digit:#, mood: then digit:#, move:halt, mood: (Rule 4) if digit:#, mood: then digit:#, move:halt, mood: (Rule 5) if Input: # 0 0 1 0 0 # Which rule matches this scenario? (Rule 1) does so let us apply it. # 1 0 1 0 0 # (Rule 1) matches so let us apply it. # 1 1 1 0 0 # (Rule 2) matches so let us apply it. # 1 1 1 0 0 # (Rule3) matches so let us apply it. # 1 1 1 0 0 # (Rule 3) matches so let us apply it. # 1 1 1 0 0 # (Rule 4) matches so let us apply it. # 1 1 1 0 0 # The machine has halted! 9 Example 2: digit:0, mood: then digit:1, move:right, mood: (Rule 1) if digit:1, mood: then digit:1, move:left, mood: (Rule 2) if digit:1, mood: then digit:1, move:left, mood: (Rule 3) if digit:#, mood: then digit:#, move:halt, mood: (Rule 4) if digit:#, mood: then digit:#, move:halt, mood: (Rule 5) if Input: # 0 0 0 0 # (Rule 1) matches so let us apply it. # 1 0 0 0 # (Rule 1) matches so let us apply it. # 1 1 0 0 # (Rule 1) matches so let us apply it. # 1 1 1 0 # (Rule 1) matches so let us apply it. # 1 1 1 1 # (Rule 5) matches so let us apply it. # 1 1 1 1 # The machine has halted! 1 0 Great! So what does this machine do? It rewrites a “0” to “1” from left to right until it hits a “1” or a “#”. So, 00000100 becomes 11111100, 00000 becomes 11111, 1000 becomes 1000 1 1 That’s it! You understand a Turing Machine now. Congratulations! It all seems very simple. So what is the big deal?! It turns out that all known models of computation anybody has thought of are equivalent to this simple model: the Turing Machine! And that includes your PC/ Mac/iPhone/whatever. 1 2 Turing did more. He showed the existence of a universal turing machine that could simulate any other machine. The “other” machine now became its Software! Voila! Turing also showed that there are problems that cannot be solved! For example, there is no program that can tell if a given program will halt or not. Turing proved all this in 1936 at the age of 24, more than 10 years before the first digital computer was built! Turing was chemically castrated by an estrogen injection for being gay by the Alan Turing: 23rd June 1912 - 7th June 1954 British govt. He died shortly thereafter. 1 3
© Copyright 2025 Paperzz