Computer Science
Beginner
80 mins
Teacher/Student led
What you need:
Chromebook/Laptop/PC

Turing Machines and Computability

In this lesson, you'll explore the fascinating world of Turing machines and computability. Learn what a Turing machine is, understand its historical importance, and discover the limits of what computers can solve through clear, step-by-step guidance.
Learning Goals Learning Outcomes Teacher Notes

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Introduction

    In this lesson, you will explore Turing machines and the concept of computability. Turing machines are abstract models that help us understand the limits of what computers can do. You will learn about their historical context, how they work, and why some problems cannot be solved by any computer. 

    By the end of this lesson, you will be able to:

    • Describe what a Turing machine is and its key components.
    • Explain the historical significance of Turing machines.
    • Discuss the limits of computability, including the halting problem.
    • Describe what the Turing test is.
    • Reflect on how these concepts relate to modern computing.

    2 - Historical Context

    Alan Turing, a British mathematician and computer scientist, introduced the concept of the Turing machine in 1936. His work was part of efforts to solve fundamental questions in mathematics, such as whether all mathematical problems could be solved algorithmically. This was during a time when computers as we know them did not exist; Turing's model was purely theoretical.

    Turing's ideas gained practical importance during World War II, where he contributed to breaking German codes using early computing devices like the Bombe. His work laid the foundation for modern computer science. The Turing machine is considered a blueprint for all digital computers, showing that any computable problem can be solved by a machine following simple rules.

    Turing's legacy includes the Turing Award, often called the 'Nobel Prize of Computing', and his influence on artificial intelligence through the Turing Test, which assesses a machine's ability to exhibit human-like intelligence.

    3 - What is a Turing Machine?

    A Turing machine is an abstract mathematical model of computation that defines what it means for something to be computable. It is not a physical machine but a thought experiment to explore the power and limits of mechanical calculation.

    Imagine a Turing machine as a device with an infinite tape divided into cells, each holding a symbol (like 0 or 1). The machine has a head that can read and write symbols on the tape, move left or right, and change its internal state based on rules. The machine starts in an initial state, reads the symbol under the head, and follows the rules to decide what to do next. It continues this process step by step until it reaches a halting state, if it ever does.

    Key Components:

    • Tape: An infinite strip for storing data, like an unlimited memory. This means the machine never runs out of space, unlike real computers with finite storage.
    • Head: Reads the current symbol, writes a new one, and moves along the tape (left or right by one cell).
    • States: A finite set of conditions (e.g., state A, state B) that determine the machine's behaviour.
    • Transition Rules: A table that says, for a given state and symbol, what to write, how to move the head, and what the next state is.

    Example: Let's consider a simple Turing machine that adds 1 to a binary number on the tape. Suppose the tape contains the binary number '101' (which is 5 in decimal), with blanks on either side: ... □ 1 0 1 □ ... The head starts at the rightmost bit (the '1' on the right).

    The machine uses states like 'carry' (when we need to add 1 and flip bits) and 'done'. Here's how it works step by step:

    1. The head reads '1' (rightmost bit). Since we're adding 1, it flips it to '0', moves left, and enters a 'carry' state (like carrying over in addition).
    2. Now at '0', in 'carry' state: It flips '0' to '1', moves left, and goes to 'done' state (no more carry needed).
    3. Now at '1', in 'done' state: It leaves it as '1' and moves right to finish, halting.
    The tape now reads '110' (which is 6 in decimal). If the number was '111' (7), it would flip all '1's to '0's until the end, then add a '1' on the left, making '1000' (8).This shows how simple rules can perform addition by changing symbols and states.
    Turing machines can simulate any algorithm, making them a universal model of computation.

    4 - Practical Task: Turing Machine

    In this practical task, you will create and simulate a simple Turing machine using just pen and paper. This will help you understand how the components work together to perform a computation.

    Task: Design a Turing machine that checks if a binary string (a string of 0s and 1s) has an even number of 1s. If it does, the machine should halt in an 'accept' state; if odd, in a 'reject' state. The input is on the tape, and the head starts at the leftmost symbol.

    Steps to follow:

    1. Define the components:
      • Tape: Draw a strip of cells on your paper, like: □ 1 0 1 □ (for input '101'). Use □ for blank cells. The tape can extend as needed.
      • States: Use 'even' (starting state) and 'odd'.
      • Halting states: 'accept' (even) and 'reject' (odd).
      • Symbols: 0, 1, and □ (blank).
    2. Transition rules: These rules tell the machine what to do. Use the table below. The machine reads the symbol, writes the same symbol back (no change), moves right, and changes state as shown. When it reads a blank (□), it halts.
    Current StateRead SymbolWrite SymbolMoveNext State
    even00righteven
    even11rightodd
    even(halt)accept
    odd00rightodd
    odd11righteven
    odd(halt)reject
    1. Simulate it: Start in 'even' state at the leftmost symbol.
      • Example 1: Input '101' (two 1s, even). Step through: Read 1 (even to odd), move right; read 0 (odd to odd), move right; read 1 (odd to even), move right; read □ (even, halt accept).
      • Example 2: Input '1' (one 1, odd). Read 1 (even to odd), move right; read □ (odd, halt reject).
      • Try your own: Like '110' or '0'.

    Spend about 10 minutes on this. It's a simple way to see Turing machines in action.

    5 - Universal Turing Machines

    A universal Turing machine (UTM) is a special type of Turing machine that can simulate any other Turing machine. Given a description of another machine's rules and an input tape, the UTM can perform the same computation.

    Think of it like this: The UTM acts as a 'universal computer' that can run any program. You provide it with the 'code' – which is an encoded description of the rules of another Turing machine – along with the input data on its tape. The UTM then follows its own rules to mimic exactly what that other machine would do, step by step. This demonstrates that a single, fixed machine can replicate the behaviour of any other computational device.

    This concept shows that one machine can act like any computer, which is why modern computers are called 'universal'. It means that all computers, regardless of hardware, are equivalent in what they can compute if given enough time and memory.

    In practice, this relates to how programming languages can emulate each other or how virtual machines run software on different systems. For example, when you run an app on your phone that's designed for a different operating system, it's similar to a UTM simulating another machine.

    The Church-Turing thesis, proposed independently by Alan Turing and Alonzo Church, states that any function that can be effectively calculated – meaning it can be solved by a human following a precise list of instructions, like an algorithm – can be computed by a Turing machine.

    This thesis is not a proven fact but a widely accepted hypothesis that defines the boundaries of what is computable. It suggests that Turing machines (and thus modern computers) can perform any computation that is intuitively 'computable', but they cannot go beyond that into undecidable problems.

    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of DigitalSkills.org. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more