Computability and Complexity¶
From Computability, Complexity & Algorithms — Charles Brubaker and Lance Fortnow
This page is a comprehensive overview of the full course. Detailed notes for each topic are in their own files. The sections below give the full arc from formal languages through undecidability.
Part 1: Formal Languages and Countability¶
The distinction between procedural (algorithmic) and mathematical (set-theoretic) definitions of functions — the starting point for computability theory.¶
Functions vs. Computability¶
Procedural function: a finite algorithm that computes output from input.
Mathematical function: any set of ordered pairs \((x, y)\) with unique \(y\) per \(x\).
Not every mathematical function is computable. Some functions require infinitely many steps on some inputs — they lie beyond any algorithm’s reach.
A machine processing input to produce output — the basic computational model.¶
Strings and Languages¶
A string is a finite sequence of symbols from a finite alphabet \(\Sigma\). A language is any set of strings over \(\Sigma\).
Hierarchy: symbols → strings → languages.¶
Language operations:
Union \(A \cup B\), intersection \(A \cap B\), complement \(\overline{A}\), concatenation \(A \cdot B\), Kleene star \(A^*\).¶
Quiz: Evaluate language operation expressions.¶
Countability¶
A set is countable if it is finite or in bijection with \(\mathbb{N}\).
A bijection between integers and permutations demonstrates countability.¶
Enumerating all binary strings by length — strings over any finite alphabet are countable.¶
A countable union of finite sets is countable.¶
A countable union of countable sets is countable — proved by diagonal traversal.¶
Quiz: Identify the flaw in this proof.¶
Diagonalization — languages are uncountable:
Assume an enumeration of all languages. Construct a language \(L_D\) that differs from every enumerated language \(L_i\) on string \(s_i\) — \(L_D\) is not in the enumeration. Contradiction: the set of all languages is uncountable.¶
Key consequence: Programs are finite strings — countably many. But languages (equivalently, functions) are uncountable. Therefore uncountably many functions have no algorithmic solution.
Part 2: Turing Machines¶
Alan Turing (1912–1954), inventor of the Turing machine model.¶
A physical Turing machine — infinite tape, read/write head, finite control.¶
Motivating analogy: arithmetic done on paper with finite rules.¶
Human computation is bounded by perception — machines extend this without limit.¶
Formal Definition¶
A Turing machine is a 7-tuple \((Q, \Sigma, \Gamma, \delta, q_0, q_\text{acc}, q_\text{rej})\):
\(Q\) |
Finite set of states |
\(\Sigma\) |
Input alphabet (excludes blank \(\sqcup\)) |
\(\Gamma\) |
Tape alphabet (\(\Sigma \cup \{\sqcup\} \subseteq \Gamma\)) |
\(\delta\) |
\(Q \times \Gamma \to Q \times \Gamma \times \{L, R\}\) — transition function |
\(q_0\) |
Start state |
\(q_\text{acc}\) |
Accept state |
\(q_\text{rej}\) |
Reject state |
Turing machine components: tape, head, and finite control.¶
Mathematical notation for specifying a Turing machine.¶
Examples¶
TM testing whether a binary number is odd — check the last bit.¶
A configuration is a snapshot: current state, tape contents, head position. Computation is a sequence of configurations.¶
TM deciding \(\{w\#w \mid w \in \{0,1\}^*\}\) — match symbols across the \(\#\).¶
State-by-state trace of the equality-test computation.¶
Quiz: Determine the next configuration in a computation.¶
Quiz: Design a TM that right-shifts its tape contents by one cell.¶
Quiz: Design a TM recognising balanced parentheses.¶
Deciding vs. Recognising¶
A decider halts on every input — accepting members, rejecting non-members.¶
Quiz: Build a decider for strings containing at least one 1.¶
A recogniser accepts members but may loop on non-members. Every decidable language is recognisable; the converse fails.¶
\(L(M)\) = the set of strings \(M\) accepts.¶
Part 3: Church-Turing Thesis¶
Thesis: Everything computable is computable by a Turing machine.
This is a thesis (not a theorem) — it cannot be formally proved, but is supported by the equivalence of all known reasonable computational models.
Computational models — multitape TMs, RAM machines, modern CPUs — are all equivalent in power to the standard single-tape TM.¶
Multitape Turing Machines¶
A multitape TM has several tapes with independent read/write heads.¶
Example: duplicating input using two tapes.¶
Quiz: Design a multitape TM for substring search.¶
Simulation: A single-tape TM can simulate a \(k\)-tape TM by interleaving tape contents with markers for head positions.
Single-tape encoding of a multitape configuration.¶
Quiz: What is the overhead of the single-tape simulation?¶
Simulating a “stay-put” head movement using left-then-right.¶
Random Access Machines (RAM)¶
A RAM machine: registers, indexed memory, and arithmetic operations — resembles a modern CPU.¶
Pseudocode: RAM simulating a Turing machine (tape ↔ indexed memory).¶
Multitape Turing machine simulating a RAM using tapes for registers and memory.¶
Quiz: What is the time overhead of TM-simulating-RAM?¶
Part 4: Universality¶
A Universal Turing Machine (UTM) accepts an encoded machine description \(\langle M \rangle\) and input \(w\), then simulates \(M\) on \(w\). This shows that programs are data.
Encoding¶
Encoding a TM as a binary string: states as \(q_i\), symbols as \(a_j\), transitions as tuples.¶
Quiz: Encode a set of TM transitions.¶
Simulation¶
Phase 1: the UTM reads the encoded description and sets up its tapes.¶
Phase 2: the UTM matches the current (state, symbol) pair against encoded transitions and executes the corresponding step.¶
Recognisability vs. Decidability¶
Recognising: accept members, may loop on non-members. Deciding: accept members, reject non-members — always halts.¶
Relationship diagram: every decidable language is recognisable.¶
Theorem: A language is decidable \(\iff\) both it and its complement are recognisable.
Proof idea — alternating machines: Run two recognisers (one for \(L\), one for \(\overline{L}\)) in lock-step. Since every string belongs to exactly one, one recogniser must eventually accept.
Pseudocode for the alternating-machines decider.¶
Quiz: Which languages are recognisable / decidable given two recognisers?¶
Dovetailing¶
Empty dovetailing grid — rows are strings, columns are computation steps.¶
Diagonal traversal ensures every cell is eventually reached — used to recognise \(\{\langle M \rangle \mid L(M) \neq \emptyset\}\).¶
Recognisability Quizzes¶
Quiz: Is \(\{\langle M \rangle \mid M \text{ has } \leq 10 \text{ states}\}\) decidable?¶
Quiz: Is \(\{\langle M \rangle \mid M \text{ halts on } 34\}\) recognisable?¶
Quiz: Is \(\{\langle M \rangle \mid L(M) = \emptyset\}\) recognisable?¶
Quiz: Is \(\{\langle M \rangle \mid M \text{ halts on every input}\}\) decidable?¶
Part 5: Undecidability¶
Diagonalization¶
Diagonalization via English adjectives — the “heterological” paradox.¶
The diagonal entry for “heterological” forces a contradiction.¶
TM acceptance table — rows are machines \(M_i\), columns are encodings \(\langle M_j \rangle\).¶
Flipping the diagonal shows that no machine \(M_L\) can recognise \(L = \{\langle M \rangle \mid \langle M \rangle \notin L(M)\}\).¶
Quiz: Does diagonalisation apply to other computational models?¶
Mapping Reductions¶
If \(A \leq_m B\) then: \(B\) decidable \(\Rightarrow\) \(A\) decidable; \(A\) undecidable \(\Rightarrow\) \(B\) undecidable.¶
Quiz: Apply reduction consequences.¶
Template: reduction from \(D_{TM}\) to show a new language \(B\) is undecidable.¶
Quiz: Identify valid reduction directions.¶
The Halting Problem¶
Reduction \(D_{TM} \leq_m H_{TM}\): given \(\langle M \rangle\), build \(N\) that ignores its input and runs \(M\) on \(\langle M \rangle\). A decider for \(H_{TM}\) would decide \(D_{TM}\) — contradiction.¶
Filtering technique: reduction machines that conditionally simulate another machine.¶
Decidability Hierarchy Summary¶
Category |
Example |
Status |
|---|---|---|
Decidable |
String equality \(\{w\#w\}\) |
TM always halts with correct answer |
Recognisable (undecidable) |
Halting problem \(H_{TM}\) |
TM accepts “Yes” instances; may loop on “No” |
Unrecognisable |
Diagonal language \(L\) |
No TM can even semi-decide it |
Key Formulas and Definitions¶
Countability:
TM transition function:
Mapping reduction:
Decidability iff complement recognisable:
Diagonal language (unrecognisable):
Halting problem (undecidable, recognisable):