Step 5 of 6 in Logic
Incompleteness & Computability
Gödel, the halting problem, and the hard limits of formal systems. Citation needed
The whole, before the parts
The previous topic ended on a triumph: for first-order logic, proof and truth coincide. This topic is about where the triumph stops. Ask a formal system to capture not just logic but arithmetic — the ordinary truths about whole numbers — and Gödel showed it must leave truths unproven; ask for a mechanical method that settles every question about what programs do, and Turing showed none exists. One idea carries both results: self-reference. A system rich enough to describe arithmetic can describe its own proofs, and a machine that runs programs can be fed a description of itself, and in each case a diagonal twist turns that self-description into a hard limit. Citation needed
Terminology and core concepts
-
Arithmetization: formulas as numbers
Gödel numbering assigns every formula and every derivation a unique natural number, so statements about proofs become statements about numbers — and a system that can talk about numbers can therefore talk about itself. Citation needed
- What does a Gödel numbering assign to each formula?
- a unique natural number Citation needed
- What do statements about proofs become under the coding?
- statements about numbers Citation needed
- Why does coding give a system self-reference?
- its own formulas become objects it can talk about Citation needed
- What must be mechanically checkable for "y codes a proof of x" to be arithmetic?
- proof-checking itself Citation needed
- What modern fact makes arithmetization unsurprising?
- programs and data are both just bytes Citation needed
-
The first incompleteness theorem
Using the coding, Gödel built a sentence G that in effect says "this sentence is not provable in this system"; if the system is consistent it can prove neither G nor ¬G, so any consistent formal system containing enough arithmetic is incomplete. Citation needed
- What does the Gödel sentence G assert, informally?
- its own unprovability in the system Citation needed
- What follows if the system proved G?
- it would prove a falsehood about itself Citation needed
- What is a sentence the system proves neither way called?
- undecidable in (independent of) the system Citation needed
- Which systems does the theorem bite?
- consistent ones containing enough arithmetic Citation needed
- Does adding G as a new axiom finish the job?
- no — the enlarged system has its own Gödel sentence Citation needed
- Does the theorem contradict first-order completeness?
- no — that concerns logic alone, this concerns arithmetic theories Citation needed
-
The second incompleteness theorem
The statement "this system is consistent" can itself be written as an arithmetic sentence, and Gödel's second theorem says a consistent system of the required strength cannot prove it — a system cannot certify its own reliability. Citation needed
- What can a consistent system of sufficient strength not prove about itself?
- its own consistency Citation needed
- How is "the system is consistent" made into arithmetic?
- no number codes a proof of a contradiction Citation needed
- What ambition of Hilbert's did this undercut?
- proving mathematics consistent by elementary means Citation needed
- Can a stronger system prove a weaker one consistent?
- yes — the bar is only on self-certification Citation needed
- What would a system proving its own consistency actually reveal?
- that it is inconsistent Citation needed
-
Algorithms made precise: the Turing machine
A Turing machine is a finite table of states driving a read/write head over an unbounded tape; it is the simplest honest model of "mechanical procedure", and computable means computable by some Turing machine. Citation needed
- What are a Turing machine's two components?
- a finite state table and an unbounded tape Citation needed
- What does the machine do at each step?
- read, write, move one cell, change state Citation needed
- What does "computable" mean after Turing?
- some Turing machine computes it Citation needed
- Why an unbounded tape rather than a fixed memory?
- no fixed bound fits every computation Citation needed
- What is a universal machine?
- one that runs any machine from its description Citation needed
-
The Church–Turing thesis
Every independent attempt to formalize "mechanically computable" — Turing machines, Church's lambda calculus, recursive functions — turned out to compute exactly the same functions; the thesis takes this convergence as evidence that the informal notion has been captured. Citation needed
- What did the rival formalizations of computability turn out to share?
- exactly the same computable functions Citation needed
- What does the Church–Turing thesis claim?
- mechanical computability is Turing computability Citation needed
- Why is the thesis not a theorem?
- one side is informal — nothing to prove from Citation needed
- What licenses the thesis anyway?
- every proposed model has agreed with the rest Citation needed
- What does the thesis let an impossibility proof conclude?
- no machine means no algorithm of any kind Citation needed
-
The halting problem
No program can decide, for every program and input, whether that program eventually halts; the proof feeds a hypothetical halting-decider a twisted copy of itself and derives a contradiction — the same diagonal move as Gödel's, run on machines. Citation needed
- What question does the halting problem ask?
- will this program on this input ever halt? Citation needed
- What is the verdict?
- no algorithm decides it for all cases Citation needed
- What is the proof's key construction?
- a program that does the opposite of its predicted behavior on itself Citation needed
- Does undecidability forbid deciding halting for many particular programs?
- no — only for all programs uniformly Citation needed
- Which earlier result shares the halting problem's diagonal engine?
- the first incompleteness theorem Citation needed
-
Reduction: spreading undecidability
A reduction turns one problem into another: if solving problem B would let you solve the halting problem, then B is undecidable too — and by this route undecidability spreads to program equivalence, first-order validity, and almost every interesting question about program behavior. Citation needed
- How does a reduction prove B undecidable?
- a B-solver would solve the halting problem Citation needed
- Which way must the reduction run?
- from the known-hard problem to B Citation needed
- Is "do these two programs behave identically?" decidable?
- no — halting reduces to it Citation needed
- What did Church and Turing show about first-order validity?
- it is undecidable — no decision procedure exists Citation needed
- How does first-order logic remain complete yet undecidable?
- valid formulas get found; invalid ones may search forever Citation needed
-
Living with the limits
The theorems bound what uniform mechanical methods can do, not what can be known: practical tools dodge the wall by accepting three-way answers (yes, no, give up), restricting the programs considered, or settling for time limits — which is why type checkers and static analyzers exist despite Turing. Citation needed
- What do the limit theorems constrain?
- uniform mechanical methods, not knowledge itself Citation needed
- What is the three-way-answer dodge?
- allow "yes", "no", and "cannot tell" Citation needed
- How does restricting the input language help?
- the restricted question can become decidable Citation needed
- Why is a timeout not a halting-problem solver?
- a timeout proves slowness, not non-halting Citation needed
- Did incompleteness halt mathematics?
- no — it mapped the limits of formalization Citation needed
Problems that prove it
-
Walk the diagonal proof that no program H(prog, input) correctly decides halting in every case.
Drills: the self-reference twist, step by step.
Derivation steps
- Suppose H exists: it returns "halts" or "loops", always correctly.
- Build D(x): run H(x, x); if it says "halts", loop forever; if "loops", halt.
- Programs are data, so D can be fed its own description: consider D(D).
- If H says D(D) halts, then D(D) loops — H was wrong.
- If H says D(D) loops, then D(D) halts — wrong again.
- Every candidate H fails on some input, so no halting decider exists.
Citation needed
-
Reconstruct the first incompleteness argument from the sentence G = "G is not provable in system S", assuming S is consistent and proves only truths of arithmetic.
Drills: the fork that leaves G true but unprovable.
Derivation steps
- Case 1: S proves G. Then G is true (S proves only truths), but G says it is unprovable — contradiction.
- So S does not prove G.
- But that is exactly what G asserts — so G is true.
- Case 2: could S prove ¬G? That would be proving a falsehood, which S never does.
- So S proves neither G nor ¬G: a true sentence of arithmetic lies beyond S's proofs.
- Gödel's actual proof replaces "proves only truths" with consistency conditions, but this is the skeleton.
Citation needed
-
Show by reduction that "does program P ever print the word ERROR?" is undecidable.
Drills: reductions as undecidability carriers.
Derivation steps
- Suppose a decider E(P) answers the ERROR question for every program.
- Given any program Q and input i, build P: "run Q on i, printing nothing; when it finishes, print ERROR".
- P prints ERROR exactly when Q halts on i.
- So E(P) answers whether Q halts on i — a halting decider.
- No halting decider exists, so E cannot exist either.
- The same template kills almost any question about what a program will eventually do.
Citation needed
-
A vendor claims their analyzer "detects all infinite loops in any JavaScript code, with no false alarms". Diagnose the claim.
Drills: applying the limit theorems to a real-world claim.
Derivation steps
- Flagging all and only non-halting runs is deciding the halting problem, since JavaScript can express any Turing machine.
- By Turing's theorem and the Church–Turing thesis, no such analyzer exists in any language or toolchain.
- So the claim as stated is false. What could be true instead?
- Either it misses some infinite loops (false negatives), or it flags some terminating code (false alarms), or it answers "unknown" sometimes.
- Honest tools pick a lane: restricted patterns caught soundly, or heuristics with false alarms. The right question for the vendor is which.
Citation needed
-
Explain why a system S proving "S is consistent" would be bad news, not good news, using the second incompleteness theorem.
Drills: reading the second theorem's contrapositive.
Derivation steps
- The theorem: if S is consistent (and strong enough), S cannot prove its own consistency.
- Contrapositive: if S does prove its own consistency, S is inconsistent.
- An inconsistent system proves everything — including its own consistency — by explosion.
- So the certificate is exactly what a broken system would also hand you; from inside, it carries no weight.
- Confidence in S must come from outside: a stronger system, or informal mathematical judgment.
Citation needed
Sources
- Torkel Franzén, Gödel's Theorem: An Incomplete Guide to Its Use and Abuse — what the theorems do and do not say, against the folklore.
- George Boolos, John Burgess, and Richard Jeffrey, Computability and Logic — the standard rigorous route through Turing machines to incompleteness.
- Charles Petzold, The Annotated Turing — Turing's 1936 paper read line by line.
- Douglas Hofstadter, Gödel, Escher, Bach — the self-reference engine made vivid.
Learning path
Continue through Logic in order, using the concepts above to connect this topic to the next.