📘 CodingMarble Learn

Computability: Turing Machines and the Limits of Computing

A Turing machine is a simple model of any computer: an endless tape of cells, a head that reads and writes one cell at a time, a finite set of states and a table of transition rules. Anything an algorithm can compute, a Turing machine can compute (Church–Turing thesis). A universal Turing machine reads another machine's rules from its tape and runs it. Some problems, like the halting problem, can never be solved by any algorithm: they are non-computable (undecidable).

🎬 Step-by-step story

  1. A Turing machine is very simple. It has a long tape of cells and a head. The head reads one cell at a time, can write a symbol and moves one cell left or right.
  2. The machine is always in one state. A rule says: in this state, if you read this symbol, write this, move this way, and go to that state.
  3. Watch it add 1 to 1011, which is eleven. Each 1 becomes 0 and the carry moves left. A 0 becomes 1. The answer 1100 is twelve. Then it halts.
  4. A universal Turing machine reads another machine's rules from the tape, next to the input. So one machine can run any machine. Today's computers work like this.
  5. This machine bounces forever. Turing proved that no program can check every program and always say if it will stop. This is the halting problem.
  6. Your turn: choose a machine, type a binary number, then press Step or Run. Does it halt?

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Why is such a simple machine important?

Because it can do anything any computer can do, given time and tape. So its limits are the limits of all computers.

How does the machine know what to do?

Only from its current state and the one symbol it reads. The rule table decides the rest.

How does the carry move left?

The rule for reading 1 in state carry writes 0 and moves left while staying in carry, so it keeps going until it finds a 0.

Can one machine really run every other machine?

Yes. The universal machine reads the other machine's rules from its tape like a program, then follows them.

Could we just run the program and wait to see if it halts?

If it halts you will know. But if it has not halted yet, you cannot tell if it never will. Waiting gives no answer.

What is computability?

Computability asks: which problems can be solved by an algorithm at all, given unlimited time and memory? It is different from complexity, which asks how fast a solvable problem can be solved.

To answer, Alan Turing (1936) invented a very simple imaginary machine. If even this machine can do everything any computer can do, then studying it tells us the limits of all computers.

Parts of a Turing machine: tape, states, transition rules

Rules can be drawn as a state transition diagram (circles for states, arrows labelled read / write, move) or written as a table. The memory is unlimited, which is why a Turing machine is more powerful than a finite state machine.

Tracing a Turing machine

Machine "add 1 to a binary number". Head starts on the rightmost digit in state carry.

Trace for 1011: 1011 → 1010 → 1000 → 1100, HALT. 11 + 1 = 12 ✓. In exams you write the tape and the state after each step.

The universal Turing machine and the Church–Turing thesis

A universal Turing machine (UTM) takes, on its tape, a coded description of another Turing machine M and M's input. It then behaves exactly like M. So one fixed machine can run any program you give it as data.

This is the idea behind the stored-program (von Neumann) computer: programs and data sit together in memory, and one processor can run any program. It also explains interpreters and emulators.

Church–Turing thesis: anything that can be computed by an effective, step-by-step method can be computed by a Turing machine. It is a thesis (widely accepted), not a proof.

Non-computable problems: the halting problem

The halting problem: given any program and its input, decide whether it will eventually stop or run forever.

Turing proved no algorithm can solve this for every program. Idea of the proof: suppose a program HALTS(P, x) always answers correctly. Build TROUBLE(P): if HALTS(P, P) says "halts", loop forever; otherwise stop. Now ask what TROUBLE(TROUBLE) does: if it halts, it must loop; if it loops, it must halt. A contradiction, so HALTS cannot exist.

A yes/no problem that no algorithm can always answer is undecidable. Other examples: checking whether two programs always give the same output. This means some problems are non-computable, however fast computers get.

Decidable, tractable and intractable

Try it: be the machine

Write 0111 on paper in boxes. Put a coin under the last digit: that is the head. Follow the three "add 1" rules, moving the coin and rewriting digits. You should end with 1000. Then design your own rule table that flips every bit (0 ↔ 1) moving right, and test it in the 3D free-play step.

Key formulas and definitions

Worked examples

1. Trace the "add 1" machine on 0111 (head on the last digit, state carry).

011<u>1</u> → 01<u>1</u>0 → 0<u>1</u>00 → <u>0</u>000 → 1000, HALT. 7 + 1 = 8 ✓. Four steps.

2. Write rules for a machine that flips every bit, starting on the leftmost digit, and stops at the first blank.

δ(F, 0) = (F, 1, R); δ(F, 1) = (F, 0, R); δ(F, _) = (HALT, _, –). On 1011 the tape becomes 0100.

3. Why can a universal Turing machine be seen as a model of a modern computer?

Because it stores another machine's instructions on the same tape as the data and runs them: just like a computer stores a program and data in memory and the CPU executes the program.

Common mistakes

Practice quiz

1. A Turing machine reads:
2. What makes a Turing machine more powerful than a finite state machine?
3. A universal Turing machine:
4. The halting problem is:
5. The Church–Turing thesis says:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is a Turing machine in simple words?

An imaginary machine with a tape of cells, a head that reads and writes one cell at a time, a set of states and rules. It is a model of any computer.

What is the halting problem?

The question of whether any program will stop or run forever on a given input. Turing proved no algorithm can answer it for every program.

What is the difference between computability and complexity?

Computability asks whether a problem can be solved by an algorithm at all; complexity asks how much time or memory a solvable problem needs.

Where this is taught

NetherlandsHAVO 5 (eindexamenjaar)Elective theme: Algorithms, computability and logic
NetherlandsVWO 6 (eindexamenjaar)Elective theme: Algorithms, computability and logic
England (GCSE, A level)Year 134.4 Theory of computation (A-level)

Learn first

Related lessons

All Computer Science lessons