# Complement (complexity)

In computational complexity theory, the **complement** of a decision problem is the decision problem resulting from reversing the *yes* and *no* answers.[1] Equivalently, if we define decision problems as sets of finite strings, then the complement of this set over some fixed domain is its complement problem.[2]

For example, one important problem is whether a number is a prime number. Its complement is to determine whether a number is a composite number (a number which is not prime). Here the domain of the complement is the set of all integers exceeding one.[3]

There is a Turing reduction from every problem to its complement problem.[4] The complement operation is an involution, meaning it "undoes itself", or the complement of the complement is the original problem.

One can generalize this to the complement of a complexity class, called the **complement class**, which is the set of complements of every problem in the class.[5] If a class is called **C**, its complement is conventionally labelled **co-C**. Notice that this is *not* the complement of the complexity class itself as a set of problems, which would contain a great deal more problems.

A class is said to be *closed under complement* if the complement of any problem in the class is still in the class.[6] Because there are Turing reductions from every problem to its complement, any class which is closed under Turing reductions is closed under complement. Any class which is closed under complement is equal to its complement class. However, under many-one reductions, many important classes, especially NP, are believed to be distinct from their complement classes (although this has not been proven).[7]

The closure of any complexity class under Turing reductions is a superset of that class which is closed under complement. The closure under complement is the smallest such class. If a class is intersected with its complement, we obtain a (possibly empty) subset which is closed under complement.

Every deterministic complexity class (**DSPACE**(f(n)), **DTIME**(f(n)) for all f(n)) is closed under complement,[8] because one can simply add a last step to the algorithm which reverses the answer. This doesn't work for nondeterministic complexity classes, because if there exist both computation paths which accept and paths which reject, and all the paths reverse their answer, there will still be paths which accept and paths which reject — consequently, the machine accepts in both cases.

Some of the most surprising complexity results shown to date showed that the complexity classes NL and SL are in fact closed under complement, whereas before it was widely believed they were not (see Immerman–Szelepcsényi theorem). The latter has become less surprising now that we know **SL** equals **L**, which is a deterministic class.

Every class which is low for itself is closed under complement.

## References

- Itô, Kiyosi (1993),
*Encyclopedic Dictionary of Mathematics, Volume 1*, MIT Press, p. 269, ISBN 9780262590204. - Schrijver, Alexander (1998),
*Theory of Linear and Integer Programming*, Wiley Series in Discrete Mathematics & Optimization, John Wiley & Sons, p. 19, ISBN 9780471982326. - Homer, Steven; Selman, Alan L. (2011),
*Computability and Complexity Theory*, Texts in Computer Science, Springer, ISBN 9781461406815. - Singh, Arindama (2009),
*Elements of Computation Theory*, Texts in Computer Science, Springer, Exercise 9.10, p. 287, ISBN 9781848824973. - Bovet, Daniele; Crescenzi, Pierluigi (1994),
*Introduction to the Theory of Complexity*, Prentice Hall International Series in Computer Science, Prentice Hall, pp. 133–134, ISBN 9780139153808. - Vollmer, Heribert (1999),
*Introduction to Circuit Complexity: A Uniform Approach*, Texts in Theoretical Computer Science. An EATCS Series, Springer, p. 113, ISBN 9783540643104. - Pruim, R.; Wegener, Ingo (2005),
*Complexity Theory: Exploring the Limits of Efficient Algorithms*, Springer, p. 66, ISBN 9783540274773. - Ausiello, Giorgio (1999),
*Complexity and Approximation: Combinatorial Optimization Problems and Their Approximability Properties*, Springer, p. 189, ISBN 9783540654315.