In 1936, long before the first electronic computer was built, a young English mathematician called Alan Turing imagined a very simple machine: a strip of paper, a head that reads and writes one symbol at a time, and a short list of rules. Today we call it a Turing machine.
It looks almost too simple to be useful, and yet it can do everything that any computer can do: your phone, your laptop and the largest supercomputers in the world can't solve a single problem that a Turing machine can't. That is why, 90 years later, it is still the standard way to answer the question "what can a computer do, and what can it never do?".
This article explains, without assuming any knowledge of computer science, what a Turing machine is, how it runs, what it can and can't do, and the many types of Turing machines that people have invented since, with diagrams that show how they are classified. You can also run real Turing machines in your browser with our Turing Machine simulator.
Contents
A Turing machine is not a real machine made of metal and wires. It is an imaginary machine, a mathematical model of what it means to compute something by following rules. Turing called it an "automatic machine"; the name "Turing machine" was given to it a year later by the American logician Alonzo Church.
In 1936 the word "computer" meant a person: someone, often in a bank or in an observatory, whose job was to do long calculations with pencil and paper. Turing asked what such a person really does, step by step, and stripped it down to the bare minimum:
Turing argued that any calculation a person can do by following precise instructions can be broken down into these tiny steps. He wrote all this in a famous paper, On Computable Numbers, with an Application to the Entscheidungsproblem, where he used his machine to answer one of the big open questions of mathematics: is there a mechanical method that can decide whether any mathematical statement is true? His answer was no, and we will see why in the section about the halting problem.
Every Turing machine has the same four parts. Only the rules change from one machine to another.
_. The tape is the machine's memory, and since it is endless, the machine never runs out of memory.That's all. There is no addition, no comparison, no "if" or "loop" built into the machine. Everything a Turing machine does, it does by combining these tiny steps.
Before it starts, the input is written on the tape (all the other cells are blank), the head is placed on the first symbol of the input, and the machine is put in its start state. Then it repeats the same cycle again and again:
The machine stops, or halts, when it reaches a halting state, or when there is no rule for the current state and symbol. Whatever is written on the tape at that moment is the output.
Notice that the machine never "thinks" or chooses: at each step there is exactly one rule that applies, so the same input always produces the same run. That is why this kind of machine is called deterministic.
Computers store numbers in binary, using only the digits 0 and 1. For example, 1011 in binary is 8 + 0 + 2 + 1 = 11. To add 1 to a binary number you do the same as with ordinary numbers: start at the last digit, and while it is 1 turn it into 0 and carry 1 to the left, until you find a 0 (or the end of the number), which becomes 1. So 1011 + 1 = 1100, that is, 11 + 1 = 12.
Here is a Turing machine that does exactly that, with three states:
| State | Reads | Writes | Moves | Next state |
|---|---|---|---|---|
| right | 0 | 0 | Right | right |
| right | 1 | 1 | Right | right |
| right | _ | _ | Left | carry |
| carry | 1 | 0 | Left | carry |
| carry | 0 | 1 | Left | done |
| carry | _ | 1 | Left | done |
The same rules are often drawn as a state diagram: each state is a circle, and each rule is an arrow from one state to another, labeled with "symbol read → symbol written, move".
Click Step to run one rule at a time, or Run to let the machine go on its own. The highlighted row of the table is the rule that will be used next. You can type another binary number, or switch to the 2-state busy beaver, a famous little machine that starts on a tape full of zeros.
In state "right" the head reads "1". The rule says: write "1", move right, go to state "right".
Rules
| State | Reads | Writes | Moves | Next |
|---|---|---|---|---|
| right | 0 | 0 | R | right |
| right | 1 | 1 | R | right |
| right | _ | _ | L | carry |
| carry | 1 | 0 | L | carry |
| carry | 0 | 1 | L | done |
| carry | _ | 1 | L | done |
History: one row per step
The history on the right is a space-time diagram: the tape is drawn again after every step, one row below the other, so the whole computation can be seen at once. Our Turing Machine simulator draws the same kind of picture for machines that run for thousands or millions of steps, one pixel per cell, and the result can be surprisingly beautiful.
A Turing machine doesn't have to stop. Started on some input, it can do one of two things:
Turing asked: could there be a Turing machine that looks at the rules of any machine and its input, and always tells correctly, in a finite time, whether that machine will halt? This is the halting problem, and Turing proved that no such machine can exist. The idea of the proof fits in a few lines:
This was a shock: it showed that there are perfectly well-defined questions that no computer will ever be able to answer, however fast it is and however long it runs. Problems like this are called undecidable.
The halting problem is behind a famous game, the busy beaver: among all the machines with a given number of states that start on an empty tape and eventually halt, which one runs the longest? With 2 states the champion halts after 6 steps (it's the one in the demo above), with 3 states after 21 steps, with 4 states after 107 steps, and with 5 states after 47,176,870 steps, a value that was only proven in 2024 by an online collaboration of volunteers, the Busy Beaver Challenge. For 6 states nobody knows the answer, but some machines are known to halt after more than 101010⋰ steps, a tower of fifteen 10s stacked as exponents. You can run the busy beavers in our Turing Machine simulator.
Each Turing machine has its own fixed rules, so it seems that we need a different machine for every task: one to add numbers, one to sort a list, one to play chess. Turing's most important discovery, in the same 1936 paper, is that this is not necessary.
The rules of any Turing machine are just a finite table, so they can be written on a tape as a sequence of symbols. Turing showed how to build one special machine, the universal Turing machine, that reads such a description of another machine M, followed by an input, and then imitates M step by step, giving exactly the same result as M would.
This is the idea of the stored-program computer, and it's exactly what your computer does: it is one fixed piece of hardware, and the programs it runs are just data stored in its memory. John von Neumann, who described the design used by almost all computers since the 1940s, knew Turing's work well.
In the same year as Turing, Alonzo Church described a completely different way of computing, the lambda calculus, based on functions instead of machines. Other people proposed other models: recursive functions, Post's rewriting systems, and later register machines and programming languages. Remarkably, all of them turned out to be able to compute exactly the same things as Turing machines: each one can imitate the others.
This led to the Church-Turing thesis: anything that can be computed by following a step-by-step procedure (an algorithm) can be computed by a Turing machine. It isn't a theorem that can be proven, because "following a procedure" is an informal idea, but in 90 years no one has found a reasonable counterexample.
A system that can imitate any Turing machine is called Turing complete. Almost every programming language is Turing complete, and so are some systems that were never meant to compute anything:
The Game of Life and Rule 110 are cellular automata, grids of cells that all follow the same simple rule. Our article about cellular automata explains how they work.
Strictly speaking, a real computer is not quite a Turing machine, because its memory is finite, while the tape of a Turing machine never ends. But its memory is so large that, for most purposes, the Turing machine is a very good model of it.
In books, a Turing machine is usually defined as a list of seven things, a "7-tuple" M = (Q, Γ, b, Σ, δ, q0, F). It looks scary, but it is just the parts we have already seen, with names. The last column shows them for our binary machine.
| Symbol | Name | Meaning | In the example |
|---|---|---|---|
| Q | States | The finite set of states. | {right, carry, done} |
| Γ | Tape alphabet | The finite set of symbols that can be on the tape. | {0, 1, _} |
| b | Blank symbol | The symbol of the cells that were never written. It belongs to Γ. | _ |
| Σ | Input alphabet | The symbols allowed in the input, a part of Γ without the blank. | {0, 1} |
| δ | Transition function | The rules: for a state that is not halting and a symbol, it gives the symbol to write, the move (L or R) and the next state. | The six rules of the table above, like δ(carry, 1) = (0, L, carry) |
| q0 | Start state | The state the machine is in at the beginning. | right |
| F | Halting states | The states where the machine stops (sometimes split into accepting and rejecting). | {done} |
A snapshot of the machine at one moment, made of the content of the tape, the position of the head and the current state, is called a configuration. A run of the machine is a sequence of configurations, each one obtained from the previous one by applying one rule.
Since 1936, people have invented many variations of the Turing machine: with more tapes, with a 2D grid instead of a tape, with the power to guess, to flip coins, or to use quantum physics. A surprising fact is that almost none of these changes adds any computing power. A plain one-tape machine can imitate all of them: it may need many more steps, but it gets the same answers. Only two kinds of change really matter: taking something essential away, which makes the machine weaker, or adding something impossible to build, which makes it stronger (in theory).
The diagram below groups the variations by what they change. Click a group to jump to its explanation.
This group is the most important for understanding modern computer science. These machines all compute the same things as the standard machine, but some of them may be much faster for some problems, and the question of how much faster is one of the biggest open questions in mathematics.
If we take away something essential from a Turing machine, it becomes a weaker kind of machine, called an automaton. These machines are very important in practice, because they are simpler, faster and, unlike Turing machines, we can always predict what they will do.
Machines that can compute more than a Turing machine are called hypercomputers. They are useful thought experiments for mathematicians, but nobody knows how to build one, and most scientists believe it is impossible.
There are several ways to classify Turing machines and their relatives, depending on the question we ask: what problems can it solve at all, how fast can it solve them, and how does it behave when it runs?
Ordering the machines by the problems they can solve gives a set of nested boxes: every machine can solve all the problems of the boxes inside it, and more. For the inner four levels, this is the Chomsky hierarchy, named after the linguist Noam Chomsky, who classified the grammars of languages in the same way in 1956.
Note that "Turing machines that always halt" are not a different design, but ordinary Turing machines with a guarantee about their behavior. The gap between the two boxes is exactly where the undecidable problems live, like the halting problem.
The variations with the same power can still be very different in speed. Complexity theory classifies problems by the time or memory a given kind of machine needs to solve them, as the input gets bigger. "Polynomial time" means the number of steps grows like a power of the input size, like n² or n³, which is considered fast; "exponential time" means it grows like 2n, which quickly becomes hopeless. Each kind of machine defines its own class of problems:
| Class | Machine | Problems it contains |
|---|---|---|
| P | Deterministic Turing machine, in polynomial time | Problems that can be solved quickly, like sorting a list or finding the shortest route on a map. |
| NP | Nondeterministic Turing machine, in polynomial time | Problems whose solutions can be checked quickly, even if finding them seems hard, like solving a sudoku of any size: filling it in may take forever, but checking a filled grid is easy. |
| BPP | Probabilistic Turing machine, in polynomial time, right most of the time | Problems that can be solved quickly by flipping coins. Many researchers believe that BPP is actually equal to P. |
| BQP | Quantum Turing machine, in polynomial time, right most of the time | Problems that a quantum computer can solve quickly, like factoring large numbers. |
| PSPACE | Deterministic Turing machine with polynomial memory (any time). The same as AP, the alternating machine in polynomial time | Includes finding the winner of many two-player games played on boards of any size. |
| EXPTIME | Deterministic Turing machine, in exponential time | Includes finding the winner in chess and Go played on boards of any size. It's known that P is smaller than EXPTIME. |
Whether P equals NP, that is, whether every problem whose solution is easy to check is also easy to solve, is the famous P versus NP problem, one of the seven Millennium Prize Problems, with a prize of one million dollars for its solution. In terms of machines, it asks: is a nondeterministic Turing machine really faster than a deterministic one?
The table below shows how expensive it is for a standard one-tape machine to imitate each variation. If a machine takes t steps, the imitation takes about:
| Variation | Steps needed by a one-tape machine to imitate t steps |
|---|---|
| Tape with several tracks, more symbols | t: no slowdown at all |
| Tape infinite in both directions, head that can stay put | A small multiple of t |
| Several tapes | About t² (quadratic) |
| Several heads, 2D tape, random access memory | A power of t (polynomial) |
| Nondeterministic, alternating | Exponential, like 2t, as far as anyone knows |
| Probabilistic, quantum | Exponential in general, as far as anyone has proven (by trying every coin flip, or every branch of the superposition) |
| Oracle machine, infinite time Turing machine | Impossible: no Turing machine can imitate them |
A third way to classify machines is to look at what they actually do. The volunteers of the Busy Beaver Challenge, who had to examine tens of millions of machines with 5 states to find the champion, sorted the machines that run forever into families with typical behaviors, so that each family can be recognized and proven to never halt. The space-time diagrams below show four of them, each starting on an empty tape (time goes down, and the yellow cell is the head):
1RB1RZ_1LB0RC_1LC1LA1RB0RC_1LC0RA_0LC1LA1RB1LA_1LA0RA1LB1RA_1RA1LBOther families include counters, which count in binary on the tape forever, like our example machine adding 1 again and again, and machines whose behavior looks chaotic, with no visible pattern. The machines are written in the compact notation of the busy beaver community: one group per state (A, B, C), and for each symbol read (0, then 1) what to write, where to move and the next state, with Z as the halting state. You can paste them into our Turing Machine simulator to watch them run for longer.
Is my computer a Turing machine?
Almost. A computer can do everything a Turing machine can do, as long as it doesn't run out of memory, and a Turing machine can imitate everything a computer does. The only difference is that the tape of a Turing machine is infinite, while the memory of a computer is finite.
Has anyone built a real Turing machine?
Turing machines were never meant to be built: they are far too slow to be practical. But people have built physical ones for fun and for museums, with a strip of tape or paper and a moving head, and some have even been built out of LEGO bricks or wooden parts. The easiest way to see one running is a simulator like our Turing Machine tool.
What does "Turing complete" mean?
A programming language or a system is Turing complete if it can imitate any Turing machine, which means it can compute everything that is computable, given enough time and memory. Most programming languages are Turing complete, and so are some unexpected things, like the Game of Life.
Is a Turing machine the same as the Turing test?
No. Both were invented by Alan Turing, but the Turing test, from 1950, is a test of whether a machine can hold a conversation that can't be told apart from a human's. The Turing machine, from 1936, is a model of computation.
Are Turing patterns related to Turing machines?
Only through their author. Turing patterns, the spots and stripes of animal skins, come from a paper about chemistry and biology that Turing wrote in 1952. You can create them with our Turing Pattern Generator.
Are quantum computers more powerful than Turing machines?
Not in what they can compute: a normal Turing machine can imitate a quantum computer, only exponentially slower as far as anyone knows. Quantum computers may be much faster for some problems, but they can't solve undecidable problems like the halting problem.


