Lecture from: 14.10.2025 | Video: Videos ETHZ
From Finite Automata to a Universal Model
We’ve explored the world of finite automata and seen their limitations. While they are excellent for recognizing regular patterns, they fail on languages that require unbounded counting, like our canonical example .
To solve such problems, we need a more powerful model of computation. We need a machine that isn’t limited by a finite number of states as its only form of memory. This brings us to the central concept of this course: the Turing Machine.
This model was conceived by Alan Turing in 1936, remarkably, before the existence of modern digital computers. He wasn’t trying to build a physical machine; he was trying to formalize the very essence of what it means for a human “computer” (a person performing calculations) to follow a mechanical procedure.
The Intuition: A Human with Paper
Imagine a mathematician performing a calculation, like long multiplication, following a set of rules learned in school. What happens in a single step?
- They read a constant number of symbols (e.g., two digits).
- They perform a calculation in their head (applying a rule).
- They find a place on the paper to write the result.
- They might keep a small, constant-sized piece of information in their head (like a carry digit).
Turing abstracted this process. He imagined a machine with two key components:
- A finite control: This is like the mathematician’s brain. It contains a finite set of rules and can be in one of a finite number of internal “states of mind.”
- An infinite tape: This is the paper. It’s an infinitely long strip, divided into cells, each capable of holding one symbol. This provides the machine with unbounded memory.
The machine interacts with the tape via a read/write head.
/Semester-3/Theoretical-Computer-Science/Lecture-Notes/attachments/Pasted-image-20251201220740.png)
In a single step, the Turing machine:
- Reads the symbol under the head.
- Based on its current state and the symbol it read, it consults its transition function (its “program”).
- This function tells it to:
- Write a new symbol onto the tape cell it’s currently on.
- Move the head one cell to the left (L), one cell to the right (R), or not at all (N).
- Change to a new internal state.
This simple model, with its ability to both read and write on an infinite tape and move back and forth, is powerful enough to capture the full notion of “algorithm.”
Formal Definition of a Turing Machine
A Turing Machine (TM) is formally defined as a 7-tuple:
- : A finite set of states, just like in a DFA.
- : The input alphabet. These are the symbols the initial input word is made of.
- : The tape alphabet (or working alphabet). This is the set of all symbols that can be written on the tape. It must include the input alphabet (). It also contains two special symbols:
⊔(or□): The blank symbol, which fills the infinite tape beyond the input.$(or⊳): The start symbol or left-end marker, which marks the beginning of the tape.
- : The start state.
- : The unique accept state.
- : The unique reject state.
- : The transition function. This is the heart of the machine. It maps a state and a tape symbol to a new state, a new tape symbol, and a head movement. Note that once the machine enters an accept or reject state, its computation halts; there are no transitions out of them.
How a Turing Machine Computes
Configurations
A configuration of a TM is a snapshot of its entire state: the contents of the tape, the position of the head, and the current state of the finite control. We can represent this crisply as a string. For a tape containing ...$x_1...x_i...x_n..., with the machine in state and the head over symbol , we write the configuration as:
The state symbol is placed just before the symbol the head is currently scanning.
- Start Configuration: For an input word , the computation begins in the configuration q_0 \ w$.
Steps and Computations
A step is a transition from one configuration to another, denoted by . The rules depend on the head movement specified by .
- Neutral Move (N): If , the machine writes and stays put.
- Left Move (L): If , the machine writes and moves left.
- Right Move (R): Analogous to the left move.
A computation is a sequence of configurations where for all . We use for the reflexive, transitive closure (“reaches in zero or more steps”).
Halting and Outcomes
Unlike a DFA, which always halts after reading the input, a TM’s computation might never end. It could loop forever. This leads to three possible outcomes for any given input word:
- Accept: The computation reaches a configuration containing the state .
- Reject: The computation reaches a configuration containing the state .
- Loop: The computation never reaches or and continues indefinitely.
Languages and Functions of Turing Machines
Recognizing Languages
- The language accepted by a TM , denoted , is the set of all input words for which the computation of halts in the accept state.
- A language is called recursively enumerable (or Turing-recognizable) if there exists a TM such that . We denote this class of languages as .
- A language is called recursive (or decidable) if there exists a TM that always halts on every input, and . This is a stronger condition. We denote this class as .
Computing Functions
A TM can also be used to compute a function . We say a TM computes if for every input , the machine halts in the accept state with the tape containing just \F(x)$.
A function is called total computable if such a halting TM exists for it.
Example:
We know this language is not regular. Let’s sketch how a Turing machine could decide it.
Input on tape: $...$000111...
High-level Algorithm:
- Move the head to the first
0. Replace it with a special symbol, sayA. - Move the head right, past all the
0s and1s, until you find the last1. - Replace that
1with another special symbol, sayB. - Move the head back to the left until you find the leftmost
A. - Move one step right to the next
0. - Repeat the process: change the
0to anA, find the rightmost1, change it to aB, and return.
Outcomes:
- If, while searching for a
1to match a0, you find no more1s, there were too many0s. Reject. - If, after matching all the
0s, you scan left and find there are still unmatched1s on the tape, there were too many1s. Reject. - If, after changing the last
0to anA, you find no more1s to match it with, and there are also no0s left, then the counts were equal. Accept.
/Semester-3/Theoretical-Computer-Science/Lecture-Notes/attachments/Pasted-image-20251201223245.png)
This back-and-forth process, using the tape as both input and scratch memory, is something a DFA could never do. It demonstrates the fundamental power gained from having a read/write head on an infinite tape.