Recursive languages and sets

From Wikipedia, the free encyclopedia
Jump to: navigation, search
This article is a temporary experiment to see whether it is feasible and desirable to merge the articles Recursive set, Recursive language, Decidable language, Decidable problem and Undecidable problem. Input on how best to do this is very much welcome on the article's talk page. This is a work in progress so the current version may seem awkward.

In computability theory, a set is decidable, computable, or recursive if there is an algorithm that terminates after a finite amount of time and correctly decides whether a given object belongs to the set. Decidability of a set is of particular interest when the set is viewed as a decision problem; a decidable set is also a decidable problem, computable problem, and recursive problem. The remainder of this article uses the term decidable, although recursive and computable are equivalent in this context.

A language is a set of finite strings over a particular alphabet. A language is decidable (also computable, recursive) if it is a decidable set, that is, if there is a finite-time algorithm that can decide whether a given finite string is in the language.

A set, language, or decision problem that is not decidable is undecidable, non-recursive, non-computable, or uncomputable. There are many known undecidable sets; one of the earliest, and most famous, examples is the halting problem.

Decidable sets and languages are a strict subclass of the class of recursively enumerable sets. For those sets, it is only required that there is an algorithm that correctly decides when an input is in the set; the algorithm may fail to terminate for inputs not belonging to the set.

Formal definition[edit]

A subset S of the natural numbers is called decidable if there exists a total computable function f such that f(x) = 0\, if x \in S and f(x) \not = 0 if x \notin S. In other words, the set S is decidable if and only if the indicator function 1_{S} is computable.

A parallel definition applies to sets of strings over some finite alphabet; these sets are often called languages. A language is decidable if there is a computable function taking strings over the alphabet as input, which returns 0 when presented with a string not in the language, and returns 1 when presented with a string in the language.

The definition can be extended to arbitrary countable sets via Gödel numberings. If each element of a set U has a unique associated natural number, a subset C of U is called computable if the set of natural numbers corresponding to the elements of C is decidable under the definition above. A similar definition can be made in which elements of U are identified with finite strings rather than natural numbers.

The definition can also be extended to sets of ordered pairs, ordered triples, and more generally finite sequences of objects. One way to do this is to use computable functions taking more than one argument – for example, a set A of ordered pairs of elements of a set X is decidable if there is a computable function g taking two arguments, such that for all x and y in X, g(x,y)= 0 if the pair (x,y) is not in A, and g(x,y)=1 if the pair is in A. Another way of defining decidability for sets of sequences is to use a pairing function to identify each sequence with a single object (natural number or string). Then the definitions of decidability above can be directly applied. This second method is particularly useful when the set in question contains sequences of varying lengths.


There are many examples of decidable sets:

  • The empty set is decidable, and the entire set of natural numbers is decidable.
  • Every finite or cofinite subset of the natural numbers is decidable.
  • The set of prime numbers is decidable.
  • The finite binary strings with an even number of 1s is decidable.
  • If f is a computable function then the set of pairs (x,y) such that f(x) = y is decidable.

It is possible for a set to be decidable even if the precise algorithm that decides it is not known. For example, consider the set A containing all natural numbers n such that there is a pair of twin primes larger than n. It is not presently known whether there are infinitely many twin primes, or whether (otherwise) there is a largest pair of twin primes. But in either case, the set A is decidable. If there are infinitely many twin primes, A contains every natural number, and is thus decidable. Otherwise, there is a largest pair of twin primes, which means A is finite, and thus decidable. This means that, regardless of whether there are infinitely many twin primes, the set A is decidable, despite the fact that the correct algorithm has not been identified.


The class of decidable sets has numerous closure properties.

  • If A is a decidable set then the complement of A is also a decidable set.
  • If A and B are decidable sets then AB, AB, and A \setminus B are decidable.
  • If A and B are decidable sets then A × B is decidable; this is the set of pairs (x,y) such that x is in A and y is in B. Moreover, the image of A × B under the Cantor pairing function is decidable.
  • The preimage of a decidable set under a total computable function is a decidable set.
  • The image of a decidable set under a total computable bijection is decidable.

Sets of strings have additional closure properties. If L and P are two decidable languages, then the following languages are also decidable:

  • The Kleene star L. A string is in this set if and only if it can be obtained by concatenating zero or more elements of L, with repetition allowed.
  • The concatenation LP. A string is in this set if and only if it can be written as an element of L followed by an element of P.

Several characterizations of decidable sets are known.

  • A set A is decidable if and only if both A and the complement of A are recursively enumerable sets.
  • A set of natural numbers is decidable if and only if it is at level \Delta^0_1 of the arithmetical hierarchy.
  • A set of natural numbers is decidable if and only if it is either the range of a nondecreasing total computable function or is the empty set. Conversely, the image of a decidable set under a nondecreasing total computable function is decidable.

Decidable languages[edit]

A decidable language in mathematics, logic and computer science, is a type of formal language which is also called recursive or Turing-decidable. Since computational problems can be formulated in terms of testing membership in a language, showing that a language is decidable is thus considered the same as showing that an equivalent computational problem is decidable.[1] In other words, we can say that a language L is decidable if there is a Turing Machine which decides L and halts on every input (meaning it either accepts or rejects, but never enters an infinite loop). A computational problem is thus considered decidable if it can be solved by a computer.

The class of all decidable languages is often called R, although this name is also used for the class RP. All decidable languages are recursively enumerable, and all regular, context-free and context-sensitive languages are decidable. In other words, all languages recognized by DFA’s, NFA’s, and CFG’s are decidable. However, not all languages recognized by a TM are decidable. Similarly, not all languages that are recognizable are decidable.[2]

This type of language was not defined in the Chomsky hierarchy of (Chomsky 1959), and there is no simple class of formal grammars that capture the decidable languages.[citation needed]

List of Common Decidable Languages and Problems [3][edit]

A_{DFA} = \{\langle B,w \rangle \mid B \text{ is a DFA that accepts input string } w \}

A_{NFA} = \{\langle B,w \rangle \mid B \text{ is a NFA that accepts input string } w \}

A_{REX} = \{\langle R,w \rangle \mid R \text{ is a regular expression that generates string } w \}

A_{CFG} = \{\langle G,w \rangle \mid G \text{ is a CFG that generates string } w \}

E_{DFA} = \{\langle A \rangle \mid A \text{ is a DFA and } L \left( A \right)= \empty \}

EQ_{DFA} = \{\langle A, B \rangle \mid A \text { and } B \text{ are DFA's and } L \left( A \right)= L\left( B \right) \}

E_{CFG} = \{\langle G \rangle \mid G \text{ is a CFG and } L \left( G \right)= \empty \}


A decision problem is, informally, a problem whose solution is either "yes" or "not". Each such problem is characterized by the set of inputs whose solution is "yes". As a result, decision problems are formally defined as being sets, either of strings or of natural numbers: any such set defines the problem of deciding whether a given object belongs to the set.

A decision problem A is called decidable or effectively solvable if A is a recursive set, that is, there exists an algorithm for establishing the presence of the element in the set. A problem is called partially decidable, semidecidable, solvable, or provable if A is a recursively enumerable set. Partially decidable problems and any other problems that are not decidable are called undecidable.

The halting problem[edit]

Main article: Halting problem

In computability theory, the halting problem is a decision problem which can be stated as follows:

Given a description of a program and a finite input, decide whether the program eventually halts when started with that input, or whether it runs forever..

Alan Turing proved in 1936 that a general algorithm to solve the halting problem for all possible program-input pairs cannot exist; the set of pairs (e,n) such that the program with description e halts on input n is undecidable.

Decidability of logical theories[edit]

Main article: Decidability (logic)

In mathematical logic, a theory is a set of formal sentences that is closed under logical consequence (essentially, any sentence that can be proved from sentences in the theory is itself in the theory). Important examples are the set of all arithmetical sentences that are satisfied by the set of natural numbers, and the set of arithmetical sentences provable from the axioms of Peano arithmetic.

Many formal theories have been studied in the context of decidability. For example, the theory of the real numbers (in the signature of fields) is decidable, while the first-order theory of the natural numbers is not. Gödel's incompleteness theorem implies that no first-order theory capable of interpreting a sufficient amount of the theory of the natural numbers can be decidable.

List of undecidable problems[edit]

In computability theory, an undecidable problem is a problem whose language is not a recursive set. More informally, such problems cannot be solved in general by computers; see decidability. This is a list of undecidable problems. Note that there are uncountably many undecidable problems, so this list is necessarily incomplete. Though undecidable languages are not recursive languages, they may be a subset of Turing recognizable languages.

Problems related to abstract machines[edit]

  • The halting problem (determining whether a specified machine halts or runs forever).
  • The busy beaver problem (determining the length of the longest halting computation among machines of a specified size).
  • Rice's theorem states that for all non-trivial properties of partial functions, it is undecidable whether a machine computes a partial function with that property.

Other problems[edit]


  1. ^ Sipser, Michael (2013). Introduction to the Theory of Computation, Third Edition. Boston, MA: Cengage Learning. p. 195. ISBN 978-1-133-18779-0. 
  2. ^ Sipser, Michael (2013). Introduction to the Theory of Computation, Third Edition. Boston, MA: Cengage Learning. p. 201. ISBN 978-1-133-18779-0. 
  3. ^ Sipser, Michael (2013). Introduction to the Theory of Computation, Third Edition. Boston, MA: Cengage Learning. pp. 194–200. ISBN 978-1-133-18779-0. 
  • Chomsky, Noam (1959), "On certain formal properties of grammars", Information and Control 2 (2): 137–167, doi:10.1016/S0019-9958(59)90362-6. 
  • Cutland, N. (1980), Computability., Cambridge University Press, ISBN 0-521-29465-7 
  • Rogers, Hartley (1987) [1967], The Theory of Recursive Functions and Effective Computability, First MIT press paperback edition, ISBN 978-0-262-68052-3 
  • Michael Sipser (1997), "Decidability", Introduction to the Theory of Computation, PWS Publishing, pp. 151–170, ISBN 0-534-94728-X 
  • Soare, R. (1987), Recursively Enumerable Sets and Degrees, Berlin, New York: Springer-Verlag