← Student tools · Problem 3 · Lecture 5 · Round 1 (30 pts)

ATM is undecidable · the contradiction machine

Walk the Mi×⟨Mj⟩ acceptance matrix, build D, watch the contradiction.

CLO-1R1·30 ptsL5
🔊 Listen

This is the most important undecidability proof in computer science. Every other "you cannot write a program to detect X" theorem ultimately reduces to this one. Compilers cannot tell you whether your loop terminates; static analyzers cannot prove arbitrary correctness; antivirus software cannot detect every possible malware behavior — all of it traces back to the impossibility shown here.

We proved (Problem 2) that ATM is recognizable: simulate, see what happens. Today we prove it is not decidable: no algorithm always halts with the correct yes/no answer. That is the cleanest possible gap between "recognize" and "decide".

What we are about to prove

There is no Turing machine H such that, for every ⟨M, w⟩, H halts and accepts iff M accepts w. Equivalently: no general-purpose halting checker can possibly exist.

The proof technique — diagonalization — is the same one Cantor used (Problem 1) to show the reals are uncountable. Same trick, different victim: now the diagonal kills a hypothetical decider.

🔊 Listen

Assume for contradiction that some TM H decides ATM. That means:

From H we will construct a new TM D that does this:

The contradiction machine D

D = "on input ⟨M⟩:
   1. run H(⟨M, ⟨M⟩⟩) — does M accept its own description?
   2. if H accepts: reject;
   3. if H rejects: accept."

Key point: D is itself a TM. We built it from H using two simple steps (run, flip). Since D is a TM, it has its own encoding ⟨D⟩. Now we feed ⟨D⟩ to D itself. Watch what happens.

Vocabulary check
  • Decider · TM that halts on every input. Outputs accept or reject.
  • ⟨M⟩ · M's description, as a finite string.
  • Diagonal cell (i, i) · row i = machine Mi, column i = input ⟨Mi⟩ — the case where the machine is fed itself.
🔊 Listen

Compute D(⟨D⟩) two ways and watch them disagree.

Case By definition of D But also (D is a TM)
D accepts ⟨D⟩⇒ H said D rejects ⟨D⟩
⇒ D rejects ⟨D⟩.
Direct contradiction.
D rejects ⟨D⟩⇒ H said D accepts ⟨D⟩
⇒ D accepts ⟨D⟩.
Direct contradiction.

Either way D contradicts itself. The only assumption we made was the existence of H. So H cannot exist.

The visualization below makes this concrete: we list TMs M1, M2, … as rows and their encodings ⟨M1⟩, ⟨M2⟩, … as columns. Cell (i, j) records whether Mi accepts ⟨Mj⟩. D's behavior is the flipped diagonal. Since D is a TM, D must appear somewhere as a row in this table — and that row contradicts the flipped diagonal at its own column. No such row can exist.

🔊 Listen
Walk the diagonal, then meet D Auto-plays
🔊 Listen

Suppose H existed and let's imagine 4 specific TMs M1…M4 with this acceptance behavior on their own descriptions:

i Mi(⟨Mi⟩) (what H says) D(⟨Mi⟩) (flipped)
1acceptreject
2rejectaccept
3acceptreject
4rejectaccept

D's row of answers is reject, accept, reject, accept. Since D is a TM, it sits in the list at some index — say D = M3. Then row 3 says D(⟨M3⟩) = accept, but D's row also says D(⟨M3⟩) = reject. Same input, two answers. Impossible. The exact index does not matter; the contradiction lives at wherever D appears.

🔊 Listen
🔊 Listen
  1. "But D might not exist as a TM." It does: D is just "run H, flip the answer." H is a TM, flipping a bit is trivial, composition of TMs is a TM.
  2. "Maybe H is just very slow." The proof allows H to take arbitrarily long. It only requires H to always halt. Any decider faces the contradiction.
  3. Confusing the diagonal flip with simulation. The diagonal cell Mi(⟨Mi⟩) is a yes/no fact, decided by H by hypothesis. D consults H, it does not simulate Mi.
  4. "This only kills decidability for one input." One contradiction is enough. Mathematics does not allow even one inconsistency.
  5. "What about a probabilistic H?" Same argument applies to any always-halting procedure. Randomness does not help; the diagonal still flips.
🔊 Listen
🔊 Listen

Total time: 12 minutes.