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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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

  1. 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
    1. Suppose H exists: it returns "halts" or "loops", always correctly.
    2. Build D(x): run H(x, x); if it says "halts", loop forever; if "loops", halt.
    3. Programs are data, so D can be fed its own description: consider D(D).
    4. If H says D(D) halts, then D(D) loops — H was wrong.
    5. If H says D(D) loops, then D(D) halts — wrong again.
    6. Every candidate H fails on some input, so no halting decider exists.

    Citation needed

  2. 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
    1. Case 1: S proves G. Then G is true (S proves only truths), but G says it is unprovable — contradiction.
    2. So S does not prove G.
    3. But that is exactly what G asserts — so G is true.
    4. Case 2: could S prove ¬G? That would be proving a falsehood, which S never does.
    5. So S proves neither G nor ¬G: a true sentence of arithmetic lies beyond S's proofs.
    6. Gödel's actual proof replaces "proves only truths" with consistency conditions, but this is the skeleton.

    Citation needed

  3. Show by reduction that "does program P ever print the word ERROR?" is undecidable.

    Drills: reductions as undecidability carriers.

    Derivation steps
    1. Suppose a decider E(P) answers the ERROR question for every program.
    2. Given any program Q and input i, build P: "run Q on i, printing nothing; when it finishes, print ERROR".
    3. P prints ERROR exactly when Q halts on i.
    4. So E(P) answers whether Q halts on i — a halting decider.
    5. No halting decider exists, so E cannot exist either.
    6. The same template kills almost any question about what a program will eventually do.

    Citation needed

  4. 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
    1. Flagging all and only non-halting runs is deciding the halting problem, since JavaScript can express any Turing machine.
    2. By Turing's theorem and the Church–Turing thesis, no such analyzer exists in any language or toolchain.
    3. So the claim as stated is false. What could be true instead?
    4. Either it misses some infinite loops (false negatives), or it flags some terminating code (false alarms), or it answers "unknown" sometimes.
    5. Honest tools pick a lane: restricted patterns caught soundly, or heuristics with false alarms. The right question for the vendor is which.

    Citation needed

  5. 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
    1. The theorem: if S is consistent (and strong enough), S cannot prove its own consistency.
    2. Contrapositive: if S does prove its own consistency, S is inconsistent.
    3. An inconsistent system proves everything — including its own consistency — by explosion.
    4. So the certificate is exactly what a broken system would also hand you; from inside, it carries no weight.
    5. 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.