Technopedia

The technologist’s encyclopedia

Computability and decidability

Computability and decidability is the study of what can and cannot be computed by a mechanical procedure. It answers “what can be mechanically decided?” and thereby bounds what proofs, algorithms, and machines can achieve. It is relevant whenever you must establish a hard limit — that no algorithm exists at all, not merely that none is known — for a decision problem.

This page takes the decidability angle: which problems are decidable, which are merely semi-decidable, and how the undecidable ones are ranked by the arithmetical hierarchy. The complexity-class angle — how fast a decidable problem can be solved (P, NP, and their relatives) — is treated on the Computer-Science side in Computability and Complexity Classes. The formal 7-tuple definition of a Turing machine and the P/NP machinery live there; this page builds on them rather than re-deriving them.

Authoritative sources

Models of computation

A model of computation is a precise formal definition of “mechanical procedure.” The three canonical models — Turing machines, the lambda calculus, and the general recursive functions — compute exactly the same class of functions, the computable (or recursive) functions. This robustness across independent definitions is the empirical content of the Church–Turing thesis: every effectively computable function is Turing-computable. The property that matters most for undecidability is universality: a single machine can take the description of any other machine as data and simulate it.

Details

Step 1 — What a model of computation is. A model of computation fixes, in mathematical terms, what counts as a mechanical procedure, so that “computable” stops being a vague word. A Turing machine is the standard choice: a finite control (a finite set of states) that reads and writes one cell of an unbounded tape at a time. The full 7-tuple definition, the notion of a decidable language, and the complexity classes built on top of it are developed on the Computer-Science side in Computability and Complexity Classes; here we only need the machine as a black box that either halts or runs forever.

Step 2 — Universality and self-reference. A Turing machine can be written down as a finite string of symbols, so a machine’s description is itself data. A universal machine UU reads a pair (⟨M⟩,w)(\langle M\rangle, w) — the code of a machine MM and an input ww — and simulates M(w)M(w) step for step. Because a machine’s code is just a string, a machine can be handed its own code as input. This self-reference is the engine behind every undecidability proof on this page: it is what lets us build a machine DD that reasons about its own behavior.

The simulator below runs a concrete Turing machine that decides the language L={0n1n:n≥0}L = \{0^n 1^n : n \ge 0\} — a decidable (but not regular) language. Load an input and step through to watch the machine mark off matched 00/1 pairs.

Authoritative sources

Example problem. Why does universality matter for undecidability, and not merely for convenience?

Solution

Every undecidability proof on this page needs a machine to be given its own description as input, so that the machine’s behavior can depend on a prediction about itself. Without universality there is no way to form the self-referential object (the diagonal machine DD), and the contradiction never arises. Universality is therefore not an engineering nicety but the logical precondition for the halting-problem argument.

Semi-decidability and recursively enumerable sets

A set S⊆NS \subseteq \mathbb{N} is semi-decidable (or recursively enumerable, r.e.) if some machine halts and accepts exactly the members of SS, and may run forever on non-members. SS is decidable iff both SS and its complement S‾\overline{S} are semi-decidable. SS is co-semi-decidable when its complement is semi-decidable. The decidable sets sit exactly at the intersection of the semi-decidable and the co-semi-decidable sets.

Details

Step 1 — Decidable vs. semi-decidable. A decider must answer both yes and no in finite time. A semi-decider only has to answer yes in finite time; on a “no” instance it is allowed to loop forever. So every decidable set is semi-decidable, but not conversely: a semi-decider can “miss” the negative answers by never halting on them.

Step 2 — A concrete semi-decidable set. The halting set K={e:φe(e) halts}K = \{e : \varphi_e(e) \text{ halts}\} (the set of machine codes that halt when run on their own code) is semi-decidable: to test whether e∈Ke \in K, run machine ee on input ee; if it halts, accept. If it never halts, the test runs forever — exactly the behavior a semi-decider is allowed to have. We will see in the next section that KK is not decidable, so it is a genuine example of a set that is semi-decidable but not decidable.

The three-way split is shown below: a set can be decidable (both directions answer), semi-decidable only (positives answer, negatives may loop), co-semi-decidable only (negatives answer, positives may loop), or neither.

semi-decidable (Σ₁) co-semi-decidable (Π₁) K (halts on own code) K̄ (loops on own code) decidable e.g. the even numbers outside both: neither semi-decidable nor co-semi-decidable

Authoritative sources

Example problem. Give a set that is co-semi-decidable but not decidable, and justify it.

Solution

The complement of the halting set, K‾={e:φe(e) does not halt}\overline{K} = \{e : \varphi_e(e) \text{ does not halt}\}, is co-semi-decidable (its complement KK is semi-decidable). It is not decidable: if K‾\overline{K} were decidable then KK would be decidable too (just flip the answer), contradicting the halting problem. So K‾\overline{K} is co-semi-decidable but not decidable.

Decidability and the halting problem

A decision problem is decidable when some algorithm answers yes or no for every input in finite time. The halting problem — deciding whether a given machine halts on a given input — is undecidable (Turing 1936; Church 1936). Undecidability is not exotic: the satisfiability of first-order logic (the Entscheidungsproblem), the word problem for groups, and many tiling problems are undecidable as well.

Details

Step 1 — Diagonalization. Suppose a decider H(M,w)H(M, w) existed, answering “halts” or “loops” for any machine MM and input ww. Build a machine DD that, on input mm, runs H(m,m)H(m, m) and does the opposite: if HH says “mm halts on mm,” then DD loops; otherwise DD halts. Now run DD on its own code DD: DD halts on DD exactly when it does not — a contradiction. So no such HH exists. (The same self-referential structure appears in Cantor’s proof that the reals are uncountable. Gödel’s incompleteness theorems reach a similar self-reference by a different route — arithmetization plus the fixed-point lemma, not direct diagonalization — see Mathematical logic.)

The diagram below lays out the diagonal: the rows are machines, the columns are inputs, and the highlighted diagonal is where each machine is run on its own code. The machine DD is built to disagree with the diagonal everywhere, so at the cell D(D)D(D) it must both halt and loop.

0 1 2 3 D machine ↓ M₀ M₁ M₂ M₃ D H L H L · L H L H · H H L L · L L H H · L L H L ✗ H = halts, L = loops, · = irrelevant. Yellow = the diagonal H(Mᵢ, Mᵢ). D is the opposite of the diagonal, so D(D) must both halt and loop — contradiction.

Authoritative sources

Step 2 — Reductions: spreading undecidability. Once one problem is known undecidable, others follow by reduction. A problem AA reduces to a problem BB (written A≤mBA \le_m B) if a machine can, given any instance of AA, produce an instance of BB that is a “yes” exactly when the original was. If BB were decidable, then so would be AA; so if AA is undecidable and A≤mBA \le_m B, then BB is undecidable too.

Concrete reduction. Show that ACCEPTS-SOMETHING ={M:M accepts at least one input}= \{M : M \text{ accepts at least one input}\} is undecidable by reducing the halting problem to it. Given a halting-problem instance $(M, w)$, build a machine M′M' that, on any input xx, first ignores xx, simulates M(w)M(w), and accepts if and only if M(w)M(w) halts. Then M′M' accepts some input (indeed every input) exactly when M(w)M(w) halts, so $(M, w) \in \text{HALT} \iff M’ \in \text{ACCEPTS-SOMETHING}$. If ACCEPTS-SOMETHING were decidable, HALT would be — contradiction.

The same reduction pattern proves the undecidability of the first-order Entscheidungsproblem (Church 1936), the word problem for groups (Novikov 1955; Adian 1958), and the tiling problem (Rogers 1952; Berger 1966).

Authoritative sources

Example problem. Reduce the halting problem to the problem ACCEPTS-EMPTY ={M:M accepts the empty string ε}= \{M : M \text{ accepts the empty string } \varepsilon\}.

Solution

Given $(M, w)$, build M′M' that, on input xx, first erases xx (overwriting the tape with blanks and returning to the start), then simulates M(w)M(w), accepting iff M(w)M(w) halts. M′M' accepts $\varepsilon$ (and in fact every input) exactly when M(w)M(w) halts, so $(M,w) \in \text{HALT} \iff M’ \in \text{ACCEPTS-EMPTY}$. If ACCEPTS-EMPTY were decidable, HALT would be — contradiction.

The arithmetical hierarchy

Undecidable problems come in degrees. The arithmetical hierarchy classifies sets of natural numbers by the quantifier pattern needed to define them over a decidable base:

The halting set KK is Σ₁-complete (it is Σ₁, and every Σ₁ set reduces to it); its complement is Π₁ and not semi-decidable.

Details

Step 1 — The decidable base. A decidable (Δ₀) predicate is one a machine can answer yes/no on in finite time. The hierarchy is built by stacking quantifiers over such a base. The base itself is level 0: a set defined by a decidable predicate with no quantifiers is just decidable.

Step 2 — The Σ₁ / Π₁ base of the hierarchy. Adding a single existential quantifier over a decidable predicate gives Σ₁: n∈S  ⟺  ∃x R(x,n)n \in S \iff \exists x\, R(x, n). To semi-decide such an SS, search x=0,1,2,…x = 0, 1, 2, \dots and accept the first xx with R(x,n)R(x, n); if none exists, the search runs forever. So Σ₁ = semi-decidable. Dually, a single universal quantifier gives Π₁ = co-semi-decidable. Concrete Σ₁ example: the halting set K={e:∃s [φe(e) halts within s steps]}K = \{e : \exists s\, [\varphi_e(e) \text{ halts within } s \text{ steps}]\} — the predicate “halts within ss steps” is decidable (simulate for ss steps), so KK is Σ₁.

Step 3 — Higher levels. Each further alternation raises the level. Concrete Σ₂ example: the set of machines that halt on every input, TOT={e:∀x ∃s [φe(x) halts within s steps]}\text{TOT} = \{e : \forall x\, \exists s\, [\varphi_e(x) \text{ halts within } s \text{ steps}]\}. The innermost predicate is decidable, then ∃s, then ∀x: a Σ₂ definition. TOT is not Σ₁ (it is not semi-decidable), which is why the hierarchy does not collapse at level 1.

The nested-boxes diagram below places these examples: Σ₁ (semi-decidable, containing KK) and Π₁ (co-semi-decidable, containing K‾\overline{K}) overlap exactly in the decidable sets, and both sit strictly inside Σ₂, which contains TOT.

Σ₂ (∃x ∀y) — one alternation TOT = { e : ∀x ∃s φₑ(x) halts in s steps } Σ₁ (∃x) — semi-decidable K halts on own code Π₁ (∀x) — co-semi-decidable K̄ loops on own code decidable = Σ₁ ∩ Π₁ evens Σ₁ ⊂ Σ₂ and Π₁ ⊂ Σ₂ are strict; the overlap Σ₁ ∩ Π₁ is exactly the decidable sets.

Authoritative sources

Example problem. Place the set TOT={e:φe is a total function}\text{TOT} = \{e : \varphi_e \text{ is a total function}\} in the hierarchy, and argue that it is not Σ₁.

Solution

TOT={e:∀x ∃s [φe(x) halts within s steps]}\text{TOT} = \{e : \forall x\, \exists s\, [\varphi_e(x) \text{ halts within } s \text{ steps}]\} is exactly the Σ₂ set from Step 3, so it is Σ₂. It is not Σ₁: if it were semi-decidable, then its complement (machines that fail to halt on some input, a Σ₁ set) would be co-semi-decidable, and together the two would make TOT decidable — but TOT is Σ₂-complete and not decidable. So TOT is a genuine Σ₂ set, one level above the halting set.

Quizz

Quizz

Problem. Show that the halting set K={e:φe(e) halts}K = \{e : \varphi_e(e) \text{ halts}\} is Σ₁-complete: (i) KK is Σ₁, and (ii) every Σ₁ set many-one reduces to KK.

Solution

(i) KK is Σ₁. e∈K  ⟺  ∃s [φe(e) halts within s steps]e \in K \iff \exists s\, [\varphi_e(e) \text{ halts within } s \text{ steps}], and the predicate “halts within ss steps” is decidable (simulate ee on ee for ss steps). So KK is Σ₁.

(ii) Every Σ₁ set reduces to KK. Let S={n:∃x R(x,n)}S = \{n : \exists x\, R(x, n)\} be any Σ₁ set, with RR decidable. Build a machine MnM_n (indexed by nn) that, on input xx, checks R(x,n)R(x, n) and accepts if true. Then MnM_n halts on input nn (i.e. n∈Kn \in K) exactly when there is some xx with R(x,n)R(x, n), i.e. exactly when n∈Sn \in S. The map n↦⟨Mn⟩n \mapsto \langle M_n\rangle is computable, so S≤mKS \le_m K. Hence KK is Σ₁-complete.

Consequence. Because KK is Σ₁-complete and undecidable, no Σ₁ set can be decidable unless the hierarchy collapses — and the halting problem is the canonical representative of the first level of undecidability.