Theory of Computation · Decidability and Undecidability
Definition of Algorithm as a Halting Turing Machine
Overview
An algorithm is formally a Turing machine that is guaranteed to halt. Comparing the countability of algorithms (countable) with the countability of problems (uncountable) proves that some problems have no algorithm at all.
Key concepts
- Algorithm: A Turing machine that is guaranteed to halt. A general Turing machine is not an algorithm, because it may run forever; only a halting Turing machine qualifies.
- Computability and decidability: These two terms mean the same thing here — both ask whether there exists an algorithm for a problem.
- Problem vs. language: Every problem can be identified with a language, so counting languages is the same as counting problems.
- Uncountable languages: The set of all possible languages is uncountable, so there exist languages for which no machine exists at all — languages that are not even recursively enumerable.
- Countable Turing machines: The set of all Turing machines is countable.
- Countable halting Turing machines: Halting Turing machines form a subset of all Turing machines, and every subset of a countable set is countable.
- Countable algorithms: Since a halting Turing machine is an algorithm, the set of all algorithms is countable.
- Uncountable problems: The number of languages is uncountable, and every problem corresponds to a language, so the number of problems is uncountable.
How it works
- The set of all possible languages is uncountable, so some languages have no machine at all (not even recursively enumerable).
- For a problem, "there is an algorithm" means exactly "there is a Turing machine for that problem which always halts." A machine not guaranteed to halt is not an algorithm, because an algorithm must halt after a finite number of steps.
- The set of all Turing machines is countable.
- Halting Turing machines are a subset of all Turing machines, and every subset of a countable set is countable, so halting Turing machines are countable.
- A halting Turing machine is an algorithm, so the set of all algorithms is countable.
- The number of languages is uncountable, and every problem corresponds to a language, so the number of problems is uncountable.
- Number of problems is uncountable while number of algorithms is countable, so there are some problems for which no algorithm exists (undecidable / uncomputable problems).
- The following three statements are used interchangeably:
- "there is an algorithm for the problem"
- "there is a Turing machine which halts for the problem"
- "the problem is computable / decidable"
Drawing the diagram…
Formulas
- — every subset of a countable set is countable.
- ; problems have no algorithm.
- Turing machine that halts on every input (halts after a finite number of steps).
Comparison
| Object | Countability | Meaning |
|---|---|---|
| Turing machines | Countable | General machines; may or may not halt |
| Halting Turing machines | Countable (subset of TM) | Exactly the algorithms |
| Algorithms | Countable | Procedures that always halt in finite steps |
| Languages / problems | Uncountable | Some have no machine at all; some have no algorithm |
| Turing machine | Algorithm |
|---|---|
| Need not halt | Must halt after a finite number of steps |
| Larger class (countable) | Subclass of halting TMs (countable) |
Revision summary
- An algorithm is a Turing machine that is guaranteed to halt; a non-halting TM is not an algorithm.
- Computability and decidability mean the same thing here: does an algorithm exist?
- Turing machines are countable; halting Turing machines (algorithms) are a subset, hence countable.
- Languages (problems) are uncountable, so some languages are not even recursively enumerable, and some problems have no algorithm.
- "There is an algorithm" "there is a halting Turing machine" — these phrases are used interchangeably.
Previous-year exam insights
- A language is Turing-decidable (recursive) iff there exists a TM that halts on every input and accepts exactly the strings in the language; a language is recursively enumerable (Turing-recognizable) iff there exists a TM that accepts every string in the language (and may loop forever on strings not in it).
Decidable ⊂ RE ⊂ all languages, and the inclusion is strict.
Asked inGATE 2026GATE 2015UGC NET 2019 - The complement of a decidable language is decidable; the complement of an RE language need not be RE. A language is decidable iff both it and its complement are RE (Post's theorem).
Asked inGATE 2015GATE 2005 - Every finite language is decidable/recursive; every regular and every context-free language is decidable.
NP ⊆ decidable, so every language in NP is Turing decidable (statement 'some NP language is not decidable' is false).
Asked inGATE 2015 - A language is recursive iff it can be effectively enumerated in lexicographic order (or in any order by a TM); effective enumerability in lexicographic order implies decidability, since you can compare the generated strings with the input and stop.
Asked inGATE 2003GATE 2004 - Bounded-step questions are decidable: for a fixed k, the language {<M> | M takes more than k steps on some input} is decidable, because the first k steps of M depend only on the first k+1 input symbols, so simulating M for k steps on all of the finitely many inputs of length at most k+1 suffices.
The unbounded halting problem is undecidable.
Asked inGATE 2021 - Closure: decidable (recursive) languages are closed under complement, union, intersection, concatenation, Kleene star; RE languages are closed under union, intersection, concatenation, Kleene star but NOT under complement.
Asked inGATE 2005GATE 2015