Lecture from: 24.10.2025 | Video: Videos ETHZ
We pick up where we left off: Nondeterministic Turing Machines (NTMs). It is crucial to dispel a common myth immediately: Nondeterminism is not randomness.
In a randomized algorithm, you flip a coin, and we analyze the probability of getting the right answer. In Nondeterminism, the machine has a “magical” ability to guess the correct path among many options. If there exists any sequence of choices that leads to the accept state, the NTM finds it.
The Computation Tree
For a Deterministic TM (DTM), the computation is a straight line: Configuration . For an NTM, because the transition function maps to a set of possible moves, the computation forms a tree.
- Root: Start configuration.
- Branches: Different choices made at each step.
- Acceptance: An input is accepted if at least one node in the entire tree is an accepting configuration.
- Rejection: An input is rejected only if every branch ends in a rejecting state.
Example: The Traveling Salesperson Problem (TSP)
To see the power of this model, consider TSP: Given a graph, is there a tour that visits every node exactly once?
- Deterministic approach: We must iterate through all permutations of nodes and check them. This is incredibly slow ().
- Nondeterministic approach:
- Guess: The NTM nondeterministically writes a permutation of numbers on the tape. Because of the branching nature, effectively every permutation is generated on some branch of the computation tree.
- Verify: The machine deterministically checks if the sequence on the tape is a valid tour in the graph. This verification takes polynomial time.
If a Hamiltonian cycle exists, one branch will guess it correctly and accept. Thus, the NTM solves TSP efficiently. This leads to the complexity class NP (Nondeterministic Polynomial time), which we will discuss later.
Equivalence of NTM and DTM
Since NTMs seem so powerful (solving TSP instantly!), do they allow us to solve problems that are fundamentally impossible for DTMs? The answer is no.
Theorem: For every Nondeterministic Turing Machine , there exists an equivalent Deterministic Turing Machine .
The Simulation Problem
How do we simulate the NTM using a DTM ? If we simply use Depth-First Search (DFS) on the computation tree of , we might fail. Why? Because a specific branch of might run forever (infinite loop). If follows that path, it will never return to check the other branches, potentially missing an accepting state elsewhere.
The Solution: Breadth-First Search (BFS)
We must simulate the tree layer by layer.
- Check all computations of 1 step.
- Check all computations of 2 steps.
- …and so on.
Construction of : We use a 3-tape DTM (which we know is equivalent to a 1-tape DTM):
- Input Tape: Stores the original input .
- Simulation Tape: Used to simulate one specific branch of .
- Address Tape: Stores a sequence of numbers (e.g.,
1-3-2) telling which choices to make in the tree.
The Algorithm:
- Generate the next “address” string in canonical order (lexicographically: ).
- Clear the simulation tape and copy onto it.
- Run on the simulation tape. Whenever needs to make a nondeterministic choice, look at the next digit on the Address Tape to decide which move to make.
- If the simulation reaches , Accept.
- If the simulation rejects or runs out of address digits (meaning this branch is valid but hasn’t accepted yet), abort this branch and loop back to Step 1.
If accepts , the accepting configuration exists at some finite depth. Our BFS enumeration will eventually generate the address string that leads to that node, and will accept. Thus, nondeterminism does not increase computability, only efficiency.
Countability: The Size of Infinity
To prove that there are problems computers cannot solve, we must compare the number of possible programs vs. the number of possible problems.
Countable Sets
A set is countable if we can list its elements: .
- (Natural numbers) is countable.
- (All binary strings) is countable (Canonical order: ).
- (Pairs of numbers) is countable. (Cantor’s “zigzag” or anti-diagonal argument proves we can map 2D coordinates to a 1D list).
/Semester-3/Theoretical-Computer-Science/Lecture-Notes/attachments/Pasted-image-20251202172512.png)
The Set of Turing Machines is Countable
Every Turing Machine can be encoded as a finite binary string.
- We assume a standardized encoding (e.g., encoding states, transitions, and alphabets into binary).
- Therefore, the set of all Turing Machines is a subset of .
- Since is countable, the set of all Turing Machines is countable. We can enumerate them: .
The Set of Problems is Uncountable
A “problem” is a language (a set of strings). The set of all possible languages over is the power set .
Using Cantor’s Diagonalization argument (similar to proving the real numbers are uncountable), we can show that the set of all languages is uncountable.
Conclusion: There are countably many algorithms (), but uncountably many problems (). Therefore, there are infinitely many problems that cannot be solved by any algorithm.
The Diagonal Language ()
We know unsolvable problems exist. Now, we will construct one explicitly using Diagonalization.
Let’s define an infinite boolean matrix where:
- Rows () represent the enumeration of all Turing Machines:
- Columns () represent the enumeration of all input strings:
The entry if machine accepts word . It is otherwise (rejects or loops).
/Semester-3/Theoretical-Computer-Science/Lecture-Notes/attachments/Pasted-image-20251202174116.png)
We define the Diagonal Language to be the set of strings that “flip” the behavior on the diagonal:
If accepts , then . If does not accept , then .
Theorem
is not Recursively Enumerable (RE). Meaning: No Turing Machine exists that recognizes this language.
Proof by Contradiction
- Assume is RE. Then there exists some TM such that .
- Since we enumerated all TMs, this machine must appear in our list at some index . So, .
- Consider the input string (the -th word). Is ?
- Case A: Assume .
- By definition of , this means does not accept .
- But since , if is in the language, must accept it.
- Contradiction.
- Case B: Assume .
- By definition of , this means accepts .
- But since , if accepts it, it must be in the language.
- Contradiction.
Both cases lead to a contradiction. Therefore, the machine cannot exist. is undecidable and not even RE.
The Method of Reduction
We have successfully constructed one specific language, , that is provably not recursively enumerable. This is a massive breakthrough, we’ve found a crack in the foundation of computability. But constructing diagonalization arguments from scratch for every new problem is tedious and difficult.
To explore the landscape of undecidable problems further, we need a scalable tool. That tool is Reduction.
The Core Intuition
Reduction is a method of converting one problem into another. It’s a concept you use constantly in programming: “I don’t want to write a sorting algorithm from scratch; I’ll just transform my data into a list and call the standard library’s .sort() function.”
In theoretical computer science, we use this logic in reverse to prove hardness:
“If I had a machine that could solve Problem B, I could easily use it to solve Problem A. But I already know Problem A is impossible to solve. Therefore, the machine for Problem B cannot exist.”
This implies that Problem B is at least as hard as Problem A.
Recursive Reduction ()
The most general form of this idea is Recursive Reduction.
Imagine we have two languages, and . We want to know if we can solve . We don’t know how, but let’s pretend we have a magic “Black Box” (or Oracle) for . We don’t know how the Black Box works, but we know that if we feed it a string , it instantly and correctly tells us whether .
Definition: We say is recursively reducible to (written ) if we can construct a Turing Machine that decides , provided is allowed to query the Oracle for .
The Logic Chain:
- We want to prove is undecidable.
- We take a known undecidable problem, like .
- We show . (i.e., “If I could solve , I could solve ”).
- Since solving is impossible, solving must also be impossible.
Many-One Reduction ()
While recursive reduction is powerful, we often use a stricter, more structured version called Many-One Reduction (or Input-to-Input Reduction). This is the standard tool for proving undecidability.
Instead of a general algorithm that can call the Oracle multiple times, we demand a simple translation. We want a function that translates instances of Problem A directly into instances of Problem B.
Definition: Language is Many-One reducible to (denoted ) if there exists a computable function such that for every input string :
What this means
- computable function: There is a Turing Machine that, given input , halts and leaves just on its tape. The translation process itself must be doable!
- condition: The translation must preserve the answer.
- If is a “Yes” instance of , then must be a “Yes” instance of .
- If is a “No” instance of , then must be a “No” instance of .
The Reduction Machine
If , and we had a hypothetical decider for , we could build a decider for like this:
- Input: .
- Run the translator: Compute .
- Run the oracle: Run on input .
- Output: Return whatever returns.
Because , this machine correctly decides .
The Contradiction Strategy
To prove is undecidable:
- Start with (which we know is undecidable).
- Construct a computable function that transforms any string into a string .
- Prove that .
- This establishes .
- If were decidable, the machine described above would solve .
- This is impossible. Therefore, is undecidable.
Lemma 5.3 (Connection)
If , then .
Many-One reduction is a special case of recursive reduction where we call the oracle exactly once at the very end and return its answer directly. For proving basic undecidability, this “simple” translation is almost always what we use.
/Semester-3/Theoretical-Computer-Science/Lecture-Notes/attachments/Pasted-image-20251202180620.png)
This framework is the sledgehammer of theoretical computer science. Once we have , we never have to use diagonalization again. We just keep reducing: Every problem in this chain inherits the “unsolvability” of the ones before it.