Hello! Welcome to the next phase of our journey into the theory of computation.
In our last module, we explored the world of Context-Free Languages and Pushdown Automata. We found that while they are more powerful than regular languages, they still have limitations. For instance, a language like is beyond their grasp. This limitation stems from the PDA's memory structure—a stack—which can't handle the "three-way" counting required for that language.
To model more complex computations—and indeed, to create a model that captures everything we believe is "computable"—we need a more powerful machine. This brings us to the final and most powerful model of computation we will study: the Turing Machine. Conceived by Alan Turing in 1936, this abstract machine forms the theoretical foundation of modern computer science.
Today's lesson addresses the first step in understanding this model: Define the formal 7-tuple structure of a standard Turing Machine (TM). We'll start with the intuitive idea and then build up to the rigorous mathematical definition.
1. From Automata to a General-Purpose Computer
Before diving into the formal details, let's build an intuition for what a Turing Machine is and why it's so powerful. Unlike DFAs, which can only move forward on their input, or PDAs, which have a restricted LIFO stack, a Turing Machine has a much more flexible memory model.
A Turing Machine consists of three main parts:
- An infinite tape: This tape is divided into cells, each capable of storing one symbol. It acts as the machine's memory, holding the input and providing unlimited space for computation.
- A tape head: The head can move left or right along the tape, one cell at a time. Crucially, it can both read the symbol in the cell it's currently on and write a new symbol to it.
- A finite state control: This is the "brain" of the machine, similar to the control unit in a CPU. It contains a finite number of states and a program—the transition function—that dictates the machine's actions.

At each step, the machine's action is determined by its current state and the symbol under the tape head. Based on these two pieces of information, the machine will:
- Change to a new state.
- Write a symbol on the tape at the current position (possibly the same one).
- Move the tape head one cell to the left or right.
This ability to move bidirectionally and write to the tape gives it the power to simulate any computer algorithm.
To get a dynamic feel for this, the following video provides an excellent introduction.
Turing Machines - what are they? + Formal Definition
This video from Easy Theory motivates the need for Turing Machines by highlighting the limitations of previous models and then provides a clear, intuitive walkthrough of the TM's components and operation.
Watch from the beginning to 09:16. The first two minutes recap why we need a more powerful model. The main segment (from 02:32) explains the tape, the tape head's read/write/move capabilities, and the concept of the blank symbol.
2. The Formal Definition of a Turing Machine
Now that we have the intuition, let's formalize it. Just as with DFAs and PDAs, we define a Turing Machine as a tuple of its components. A standard (deterministic) Turing Machine is a 7-tuple.

A Turing Machine (TM) is a 7-tuple , where:
-
is a finite set of states. This is the machine's internal memory of its current condition, just like in a DFA or PDA.
-
is the input alphabet, a finite set of symbols. This alphabet cannot contain the special blank symbol (). The initial input string is composed of symbols from .
-
is the tape alphabet, a finite set of symbols that the machine is allowed to write on its tape. It has two important properties:
- The input alphabet is a subset of the tape alphabet: .
- The blank symbol is in the tape alphabet, but not the input alphabet: and .
Your experience with systems that process data might offer an analogy here. is the raw input data, while includes any intermediate markers, tags, or processed values your algorithm might generate and use during its execution.
-
is the transition function. This is the "program" of the TM. It takes the current state and the symbol under the tape head as input and outputs the next state, the symbol to write, and the direction to move the head.
Let's break this down:
- Domain: . The function is defined for any non-halting state and any tape symbol.
- Codomain: . For a given
(current_state, symbol_read), the function returns a triplet:(next_state, symbol_to_write, direction_to_move).Lmeans move left,Rmeans move right.
-
is the start state, where the computation begins.
-
is the accept state. If the machine enters this state, it immediately halts and accepts the input.
-
is the reject state. If the machine enters this state, it immediately halts and rejects the input.
Why Explicit Accept/Reject States?
Unlike a DFA, which naturally stops after reading the last input symbol, a TM can move back and forth and might never stop (i.e., it can enter an infinite loop). The two halting states, and , provide a clear mechanism for the machine to terminate its computation and give a definitive "yes" or "no" answer. If a TM doesn't enter either of these states, it runs forever.
To solidify these formal definitions, please read the following excerpt from a set of lecture notes.
This document from the University of Waterloo provides a concise and clear formal definition of a Deterministic Turing Machine (DTM), matching the concepts we've just discussed.
Please read the section 'Formal definition of DTMs' (Definition 12.1 and the subsequent explanation). This will reinforce your understanding of each component of the 7-tuple and the interpretation of the transition function.
Test your understanding!
Suppose a Turing Machine is in state and the tape head is reading the symbol 'b'. The machine should then change to state , write a 'c' on the tape, and move the tape head to the left.
How would you represent this single step using the formal notation of the transition function ?
Show answer
The transition would be represented as:
This notation precisely captures that from state upon reading 'b', the machine transitions to state , writes 'c', and moves Left.
Conclusion
Today, we've taken the significant step of defining the Turing Machine, the most powerful computational model in our hierarchy. We have established both an intuitive understanding of its mechanics and a precise, formal definition.
Key Takeaways:
- A Turing Machine enhances previous models with an infinite tape and a tape head that can read, write, and move left or right.
- Its formal definition is a 7-tuple: .
- The input alphabet () is a subset of the tape alphabet (), which also includes the special blank symbol ().
- The transition function () is the core of the TM's logic, mapping a
(state, symbol)pair to a(new_state, new_symbol, move_direction)triplet. - Computation has three possible outcomes: it can accept (by entering ), reject (by entering ), or run forever.
Preview of the Next Lesson:
Just defining the machine isn't enough; we need to be able to describe its computation as it evolves over time. In the next lesson, we will learn how to trace the execution of a TM by defining its "configuration" or "instantaneous description," which captures a snapshot of the machine's state, tape contents, and head position at any given moment.