From the tape to today's computers
The phone or computer you are reading this on cannot compute anything that a Turing machine cannot. Given enough tape and enough time, a machine with a rule table like the ones in Turing Daily could carry out any program it runs. That is a claim about what can be computed. In speed, the two are very far apart.
Part by part
| Turing machine | Computer | What is different |
|---|---|---|
| Tape | Memory and storage | The tape never runs out. Memory is finite, but very large. |
| Head position | Memory address | The head moves one cell per step. A processor can reach any address directly. |
| Symbol in a cell | Bit or byte | A Turing Daily cell holds A, B or blank. A byte holds one of 256 values. |
| State | Program counter and registers | The state is all the machine carries. The program counter says which instruction comes next, and the registers hold a few numbers close at hand. |
| Rule table | Program | An ordinary Turing machine has its program built in. In a universal machine, the table does the job of the processor and the program sits on the tape. |
| ✓ | The program exits | In Turing Daily, a machine that never stops fails. Many programs, like an operating system, are meant to run until someone stops them. |
Why memory has addresses
A palindrome reads the same forwards and backwards, like ABBA. Deciding whether a string is a palindrome is a standard exercise for Turing machines, and it shows what a tape costs. This machine does it with six states:
State 1 erases the first symbol and remembers it by going to state 2 for A or state 3 for B. That state walks right to the end, and state 4 or 5 checks that the last symbol is the same and erases it too. State 6 walks back to the start, and the machine begins again on a string two symbols shorter. If state 4 or 5 finds a blank instead, the remembered symbol was the middle one of a string of odd length, which is fine. When nothing is left, the input was a palindrome and the machine stops on ✓. If the last symbol is wrong, the machine reaches an empty cell of the table and stops without ✓. On ABAA, state 5 reads A in the second round and stops there.
| Step | State | Reads | Writes | Moves | Next | Tape after |
|---|---|---|---|---|---|---|
| 1 | 1 | A | blank | right | 2 | BBA |
| 2 | 2 | B | B | right | 2 | BBA |
| 3 | 2 | B | B | right | 2 | BBA |
| 4 | 2 | A | A | right | 2 | BBA |
| 5 | 2 | blank | blank | left | 4 | BBA |
| 6 | 4 | A | blank | left | 6 | BB |
| 7 | 6 | B | B | left | 6 | BB |
| 8 | 6 | B | B | left | 6 | BB |
| 9 | 6 | blank | blank | right | 1 | BB |
| 10 | 1 | B | blank | right | 3 | B |
| 11 | 3 | B | B | right | 3 | B |
| 12 | 3 | blank | blank | left | 5 | B |
| 13 | 5 | B | blank | left | 6 | (blank) |
| 14 | 6 | blank | blank | right | 1 | (blank) |
| 15 | 1 | blank | blank | right | ✓ | (blank) |
Each round walks across what is left of the string twice, so when the input gets twice as long, the run gets about four times as long:
| Length | Steps on the tape | Comparisons in RAM |
|---|---|---|
| 2 | 6 | 1 |
| 4 | 15 | 2 |
| 8 | 45 | 4 |
| 16 | 153 | 8 |
| 32 | 561 | 16 |
| 64 | 2,145 | 32 |
For a palindrome of length n, this machine takes (n + 1)(n + 2) / 2 steps. A better table can save some of that, but not much. In 1965 F. C. Hennie proved that on a single tape, any machine that recognises palindromes needs a number of steps that grows with the square of the length.1 The information has to be carried across the middle of the tape again and again, and the head can only carry as much as its state holds.
A program on a computer does the job differently. The string sits in memory, where every character has an address, so the program compares the first character with the last, then the second with the second last, and is done after about n / 2 comparisons. Reaching a cell by its address instead of walking there is what random access means in random-access memory, or RAM: any cell, in any order, without passing the cells in between.
A second tape also helps. With two tapes, a machine can copy the input and then read one copy forwards while it reads the other backwards, which takes a number of steps that grows only in proportion to the length. None of this changes what can be computed. A one-tape machine can imitate a computer with addresses, only more slowly, and the slowdown is at most polynomial: if the computer takes t steps, the machine needs at most some fixed power of t.2 That is why the Turing machine is still the yardstick for running time. When Juris Hartmanis and Richard Stearns started the study of computational complexity in 1965, they counted the steps of Turing machines with several tapes3, and the P versus NP question, one of the best known open problems in mathematics, is still officially stated in terms of Turing machines.2
The program on the tape
The first large electronic computers were not programmed the way computers are now. ENIAC, finished at the end of 1945, was set up for each problem by plugging in cables and setting switches by hand, and moving it to a new problem could take days.4
Turing's universal machine had pointed another way in 1936.5 A description of a machine is only a row of symbols, so it can sit on the same tape as the data, and one fixed machine can carry out any description it is given. In June 1945 John von Neumann's First Draft of a Report on the EDVAC described a computer that keeps its instructions in the same memory as its numbers.6 Early in 1946 Turing presented his own design, the Automatic Computing Engine, to Britain's National Physical Laboratory.7 On 21 June 1948 a small experimental machine at the University of Manchester, later nicknamed the Baby, ran a program held in its own electronic memory. It is usually counted as the first computer to do so.8
Every computer since has worked this way. Programs are data: they are saved in files, copied, downloaded and read by other programs. A compiler is a program that reads a program and writes another one. An emulator lets one computer run software written for a different one, which is the universal machine's trick of carrying out another machine's description.
Turing complete
A programming language or a machine is called Turing complete if it can imitate any Turing machine, given enough memory. Almost every programming language is, and so are some systems nobody designed for computing, such as Conway's Game of Life, a grid of cells that switch on and off by a few simple rules.9 The term says nothing about speed or convenience.
Strictly speaking, no real computer is Turing complete, because its memory is finite. A computer with a fixed amount of memory can only be in a fixed, if enormous, number of situations, so in principle it is a very large machine with finitely many states. Turing's tape is not infinite either, though. At any moment only finitely many cells have been written, and another cell is there whenever the head needs one. That is close to how computers are used: when one runs short of space, it can be given more.
The halting problem at work
The halting problem shows up in everyday software. In his doctoral thesis of 1951, Henry Rice took Turing's result further. Take any property of what a program does when it runs, as long as some programs have it and some do not. Then no program can decide, for every program, whether it has that property.10 Whether a program ever divides by zero, whether it ever sends a certain file anywhere, whether two programs always give the same answers: no single method settles these for every program.
So tools that check programs have to choose. A compiler or a code checker that is unsure can stay quiet and miss some real bugs, or it can warn and sometimes raise false alarms. Fred Cohen showed in 1987 that the same holds for computer viruses: no program can tell, for every program, whether it is a virus.11 Antivirus software recognises known patterns and suspicious behaviour, and it can never be complete.
When a program might run forever, the everyday answer is the one Turing Daily uses: a limit. A web browser offers to stop a page that stops responding, a server cuts off a request that takes too long, and Turing Daily gives up after 1,000 steps. A limit cannot tell whether the program would have finished. It only ends the wait.
Sources
- F. C. Hennie, One-tape, off-line Turing machine computations, Information and Control 8 (1965), 553–578.
- Stephen Cook, The P versus NP Problem, Clay Mathematics Institute, 2000.
- J. Hartmanis and R. E. Stearns, On the computational complexity of algorithms, Transactions of the American Mathematical Society 117 (1965), 285–306.
- ENIAC, Wikipedia.
- A. M. Turing, On Computable Numbers, with an Application to the Entscheidungsproblem, Proceedings of the London Mathematical Society s2-42 (1936), 230–265.
- John von Neumann, First Draft of a Report on the EDVAC (1945), IEEE Annals of the History of Computing 15 (1993), 27–75.
- A. M. Turing, Proposed Electronic Calculator (1946), in B. E. Carpenter and R. W. Doran (eds.), A. M. Turing's ACE Report of 1946 and Other Papers, MIT Press, 1986.
- Manchester Baby, Wikipedia.
- Elwyn Berlekamp, John Conway and Richard Guy, Winning Ways for Your Mathematical Plays, vol. 2, Academic Press, 1982.
- H. G. Rice, Classes of recursively enumerable sets and their decision problems, Transactions of the American Mathematical Society 74 (1953), 358–366.
- Fred Cohen, Computer viruses: Theory and experiments, Computers & Security 6 (1987), 22–35.