Advanced

Turing Machines

AicademyAicademy
·A-Level Computer Science·AQA 7517·6 min
4.4.5.1 Turing machine

What Is a Turing Machine?

A Turing machine is a theoretical model of computation proposed by Alan Turing in 1936. It is not a real device — it is a mathematical model that defines what it means for a function to be computable.

A Turing machine consists of:

ComponentDescription
TapeAn infinite sequence of cells, each holding one symbol; extends infinitely in one direction
Read-write headReads the current cell; can write a new symbol to it; moves left or right one cell
Finite set of states ()The machine is always in exactly one state; includes a start state and halting states
Alphabet ()Finite set of symbols the tape can contain; includes a special blank symbol ( or )
Transition function ()Defines what the machine does in each (state, symbol) situation

Start state: the machine begins in a designated start state with the input written on the tape.

Halting states: states with no outgoing transitions. When the machine enters a halting state, it stops. There may be an accept state and a reject state.

The Transition Function

The transition function is the heart of a Turing machine. For each combination of current state and current symbol, it specifies:

  1. The new state to transition to
  2. The symbol to write on the current cell (may be the same as the current symbol)
  3. The direction to move the head: Left (L) or Right (R)

where = current state, = current symbol, = new state, = symbol to write, .

Example entry:

Meaning: in state , reading symbol 0 → write 1, move right, enter state .

The transition function can be represented as:

  • A transition table (rows = states, columns = input symbols)
  • A state transition diagram (circles = states, labelled arrows = transitions)

A Transition Table and Diagram

Machine: flip all 0s to 1s and all 1s to 0s on a tape, then halt

Alphabet: where = blank

StateSymbol readWriteMoveNew state
01R
10R
R (halt)

State transition diagram:

          0 → write 1, R
          1 → write 0, R
          ┌─────────────┐
          ↓             │
    ──→  (q₀) ─────────┘
          │ B → write B, R
         (qH)   ← halting state

Trace — input tape: 0 1 1 0 B …

StepStateHead posTapeAction
110 1 1 0 Bread 0 → write 1, R
221 1 1 0 Bread 1 → write 0, R
331 0 1 0 Bread 1 → write 0, R
441 0 0 0 Bread 0 → write 1, R
551 0 0 1 Bread B → write B, R
661 0 0 1 Bhalt

Output: 1 0 0 1 (all bits flipped) ✓

Hand-Tracing a Turing Machine

When tracing a Turing machine step by step:

  1. Look up the current state and the symbol under the head in the transition table
  2. Write the new symbol to the current cell
  3. Move the head left or right as specified
  4. Transition to the new state
  5. Repeat until a halting state is reached (or it becomes clear the machine will not halt)

Machine: add 1 to a binary number

Alphabet: . The tape holds the binary number. The head starts at the rightmost digit.

StateReadWriteMoveNew state
10L (carry: keep flipping 1s to 0s)
01R (no carry: write 1, done)
1R (overflow: write leading 1)

Trace — adding 1 to 1 0 1 (head starts at rightmost digit, position 3):

StepStateHeadTapeAction
131 0 1read 1 → write 0, L
221 0 0read 0 → write 1, R
331 1 0halt

Result: 1 1 0 = 6 in binary. Input was 1 0 1 = 5. Correct: 5 + 1 = 6. ✓

How much of this have you taken in?

Quiz yourself on this section — free, no card needed.

Test myself

The Universal Turing Machine

A Universal Turing Machine (UTM) is a Turing machine that can simulate any other Turing machine.

A UTM takes two inputs on its tape:

  • An encoding of the Turing machine to simulate (its states, alphabet, and transition function)
  • The input to be processed by

The UTM then simulates step by step on that input, producing the same output as if had run directly.

Why the UTM matters:

  1. It defines computability — a function is computable if and only if a Turing machine (and therefore a UTM) can compute it
  2. It is the theoretical model for the stored-program computer — a real computer executes a program (the encoding of the machine) stored alongside data (the input), just as a UTM simulates with 's description on the same tape
  3. It underpins the halting problem — Turing used the UTM to prove the halting problem is unsolvable

The Church-Turing thesis states that any function computable by any algorithm can be computed by a Turing machine. This means Turing machines define the absolute boundary of what is computable.

Common Exam Mistakes

1. Forgetting that halting states have no outgoing transitions

A halting state is defined by having no transitions — the machine simply stops. A state that has some transitions is not a halting state even if it could eventually be reached from itself.

2. Confusing the Turing machine with the UTM

An ordinary Turing machine solves one specific problem. A Universal Turing Machine can simulate any other Turing machine. They are different machines.

3. Getting the transition notation wrong

has five components: current state, current symbol, new state, symbol to write, direction. Missing the direction or confusing write-symbol with move-direction loses marks in transition table questions.

4. Stating that a Turing machine can compute anything

Turing machines can compute exactly the computable functions. The halting problem is an example of a non-computable function — no Turing machine can solve it for all inputs.

Generate revision on any topic you study

Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set — personalised to your level.

Lessons on anything

Structured, level-matched lessons on any topic you study

Practice quizzes

Find out what you actually know before the exam does

Flashcard sets

Lock in key concepts with instant revision cards

Ask Aica

Stuck on something? Get a clear explanation, any time

Prev

Limits of Computation and Tractability

Next

Number Systems and Bases

Related lessons

7 Slides

Lesson

Finite State Machines

A-Level Computer Science · AQA 7517

7 days ago

7 Slides

Lesson

Limits of Computation and Tractability

A-Level Computer Science · AQA 7517

10 hours ago