The whole, before the parts

This topic draws the two great boundary lines of the field: between what any algorithm can solve at all, and — within the solvable — between what can be solved affordably and what cannot. The single idea that carries both halves is the reduction: translating one problem into another so that a solution to the second would solve the first. Reductions let a single impossibility (the halting problem) condemn whole families of problems, and a single hard problem (satisfiability) stand for thousands. Citation needed

Terminology and core concepts

  1. The Turing machine

    A Turing machine is the field's reference model of computation: a finite control reading and writing one symbol at a time on an unbounded tape — deliberately minimal, so that anything proved impossible for it is impossible for want of ideas, not want of parts. Citation needed

    What are a Turing machine's two components?
    a finite control and an unbounded tape Citation needed
    Why is the model kept so minimal?
    so impossibility results cannot blame missing features Citation needed
    What is unbounded in a Turing machine?
    the tape; the control stays finite Citation needed
    Does giving a Turing machine more tapes enlarge what it can compute?
    no — only, at most, how fast Citation needed
    What is a universal Turing machine?
    one that runs any machine from its encoded description Citation needed
  2. The Church-Turing thesis

    The Church-Turing thesis holds that everything effectively computable is computable by a Turing machine; it is a thesis, not a theorem, because "effectively computable" is informal — but every mechanical model ever proposed has turned out exactly equivalent. Citation needed

    Why is the Church-Turing thesis not a theorem?
    "effectively computable" is an informal notion Citation needed
    What evidence supports the thesis?
    every proposed mechanical model proves equivalent Citation needed
    What does the thesis let an impossibility proof claim?
    no algorithm at all exists, in any formalism Citation needed
    Does a modern programming language outcompute a Turing machine?
    no — it computes exactly the same functions Citation needed
  3. Decidable and recognizable

    A yes/no problem is decidable when some algorithm answers correctly and halts on every input; it is merely recognizable when an algorithm halts with yes on every yes instance but may run forever on a no — a one-sided guarantee. Citation needed

    What does a decider do on every input?
    halts with the correct yes-or-no answer Citation needed
    Where may a recognizer fail to halt?
    on no instances Citation needed
    Is every decidable problem recognizable?
    yes — a decider is already a recognizer Citation needed
    If a problem and its complement are both recognizable, what follows?
    it is decidable — run both recognizers in parallel Citation needed
  4. The halting problem

    Whether a given program halts on a given input is undecidable: any claimed decider can be fed a program built to do the opposite of whatever the decider predicts about it, a self-reference that leaves no consistent answer — possible only because programs are data. Citation needed

    What is the halting problem?
    decide whether a given program halts on a given input Citation needed
    What move defeats every claimed halting decider?
    a program that does the opposite of the prediction about itself Citation needed
    What earlier idea makes that self-reference possible?
    programs are data, so a program can take itself as input Citation needed
    Is the halting problem recognizable?
    yes — run the program and say yes if it halts Citation needed
    Can a cleverer language make halting decidable?
    no — the diagonal argument applies to any formalism Citation needed
  5. Reductions

    Problem A reduces to problem B when an algorithm can translate any instance of A into an instance of B with the same answer; hardness then flows backwards — if A is undecidable and A reduces to B, then B is undecidable too. Citation needed

    What does a reduction from A to B provide?
    a translation of A-instances to B-instances, answers preserved Citation needed
    Which direction does hardness flow along a reduction?
    from the reduced problem to the target Citation needed
    If undecidable A reduces to B, what is B?
    undecidable Citation needed
    If A reduces to decidable B, what is A?
    decidable — translate, then decide Citation needed
    What is the usual proof that a new problem is undecidable?
    reduce the halting problem to it Citation needed
  6. Rice's theorem

    Rice's theorem generalises the halting result: every non-trivial question about what a program computes — its input/output behaviour, rather than its text — is undecidable, which is why perfect automatic verification of behaviour is off the table. Citation needed

    What kind of question does Rice's theorem cover?
    non-trivial questions about a program's input/output behaviour Citation needed
    What does "non-trivial" mean there?
    some programs have the property and some do not Citation needed
    Is "does this program ever output 0?" decidable?
    no — it is a non-trivial behavioural property Citation needed
    Is "is this program longer than 100 symbols?" decidable?
    yes — it asks about the text, not the behaviour Citation needed
  7. P and NP

    Among decidable problems, P holds those solvable in time polynomial in the input size — the formal rendering of "affordable" — while NP holds those whose yes instances can be verified in polynomial time given a certificate; whether finding is ever as easy as checking is the open P vs NP question. Citation needed

    What does membership in P mean?
    solvable in polynomial time Citation needed
    What does membership in NP mean?
    yes instances checkable in polynomial time with a certificate Citation needed
    Is P contained in NP?
    yes — a solver is its own checker Citation needed
    What is the certificate for "this number is composite"?
    a non-trivial factor Citation needed
    What is the status of P = NP?
    open — neither proved nor refuted Citation needed
  8. NP-completeness

    An NP-complete problem is one in NP to which every problem in NP reduces in polynomial time; the Cook-Levin theorem showed Boolean satisfiability is such a problem, so a polynomial algorithm for any one of them would collapse all of NP into P. Citation needed

    What two conditions make a problem NP-complete?
    it is in NP, and all of NP reduces to it Citation needed
    What did the Cook-Levin theorem establish?
    Boolean satisfiability is NP-complete Citation needed
    What would a polynomial algorithm for one NP-complete problem imply?
    P = NP Citation needed
    How is a new problem shown NP-complete in practice?
    reduce a known NP-complete problem to it Citation needed
    What does an NP-completeness proof tell a practitioner?
    stop seeking an exact fast algorithm; change the goal Citation needed
  9. Living with hardness

    An intractable problem is not a dead end: approximation algorithms trade exactness for a provable bound, heuristics trade guarantees for typical-case speed, and restricting the inputs often lands the special case back in P. Citation needed

    What does an approximation algorithm guarantee?
    an answer provably within a bound of optimal Citation needed
    What does a heuristic give up?
    the guarantee — it may fail on some inputs Citation needed
    How can restricting inputs defeat hardness?
    the special case may lie in P Citation needed
    Does NP-completeness forbid solving large real instances?
    no — real instances are often far from worst case Citation needed

Problems that prove it

  1. Reconstruct the diagonal argument that no halting decider exists.

    Drills: the self-reference move, step by step, until the contradiction is forced.

    Derivation steps
    1. Suppose decider H(p, x) correctly answers whether program p halts on input x.
    2. Build D(p): ask H(p, p); if yes, loop forever; if no, halt.
    3. D is a legitimate program — programs are data, so D can be built and can receive itself.
    4. Run D(D). If H says it halts, D loops; if H says it loops, D halts.
    5. Either way H was wrong about D(D). No such H exists.

    Citation needed

  2. Show that "does program p halt on empty input?" is undecidable, by reduction from the halting problem.

    Drills: building the translation, then checking hardness flows the right way.

    Derivation steps
    1. Given any halting instance (p, x), construct program q: "ignore my input; run p on the hard-coded x."
    2. q halts on empty input exactly when p halts on x — answers are preserved.
    3. The construction of q is itself an algorithm: paste x into a template.
    4. So a decider for empty-input halting would decide the halting problem.
    5. The halting problem is undecidable, so empty-input halting is too. Note the direction: the known-hard problem was reduced to the new one.

    Citation needed

  3. Show that Boolean satisfiability is in NP.

    Drills: the certificate-and-checker pattern that defines NP membership.

    Derivation steps
    1. The problem: does some true/false assignment make a given formula true?
    2. Certificate: the satisfying assignment itself — one truth value per variable, linear in size.
    3. Checker: substitute the values and evaluate the formula, one pass over its symbols.
    4. Evaluation is polynomial in the formula's length, so yes instances verify in polynomial time: satisfiability is in NP.
    5. Nothing here finds the assignment — that gap between checking and finding is the whole question.

    Citation needed

Sources

  • Michael Sipser, Introduction to the Theory of Computation — the standard treatment of decidability, reductions, and the classes.
  • Sanjeev Arora and Boaz Barak, Computational Complexity: A Modern Approach — the complexity half in full depth.
  • Michael Garey and David Johnson, Computers and Intractability — the classic guide to NP-completeness and its catalogue of problems.
  • Charles Petzold, The Annotated Turing — Turing's 1936 paper read line by line.

Learning path

Continue through Computer Science in order, using the concepts above to connect this topic to the next.