Homeβ€ΊStudy Resourcesβ€ΊComputer Scienceβ€Ί
What is the Halting problem?
Computer Science
A-Level

What is the Halting problem?

The Halting problem asks whether we can write a program that decides, for any program and any input, whether that program will eventually stop. Alan Turing showed no such program can exist, so the problem is unsolvable. It shows some problems cannot be solved by a computer. Example: a loop that subtracts 2 from n until n = 0. For n = 6 it stops after 3 steps. For n = 5 it never reaches 0. Answer: whether it halts depends on the input.

Quick answer: The Halting problem is the unsolvable problem of determining whether any program will eventually stop if given particular input. It shows that some problems cannot be solved by a computer. This page covers A Level Computer Science, AQA (7517), specification 4.4.4.7 Halting problem (A level only).

Key rule

  • The specification asks you to describe the Halting problem, but not to prove it.
  • No single algorithm can correctly decide, for every program and input, whether the program halts.
  • This makes the Halting problem a non-computable problem (4.4.4.6).
  • Individual programs can often be checked by hand. The problem is that there is no general method that works for all of them.

Extra example

Does this Python loop halt? Test it with n = 6 and n = 5.

while n != 0:
    n = n - 2
  1. n = 6: the values are 6, 4, 2, 0. The loop stops after 3 subtractions.
  2. n = 5: the values are 5, 3, 1, βˆ’1, βˆ’3 and so on. The value never equals 0.
  3. The loop halts for some inputs and runs forever for others.

Answer: It halts for n = 6 but not for n = 5, so you must check the input. A general halting checker for all programs cannot exist.

Want one-to-one help? Find an online Computer Science tutor with ExpertTutor.

Reviewed by

Want one-to-one support?

One-to-one online tuition can help you build confidence in your subject. Find a tutor who teaches your course.

Find a Tutor

Learn face to face in Glasgow

Prefer in-person lessons? Visit the ExpertTutor Glasgow Southside centre.

See the centre