♯P
In computational complexity theory, the complexity class #P is the set of the counting problems associated with the decision problems in the set NP. More formally, #P is the class of function problems of the form "compute f", where f is the number of accepting paths of a nondeterministic Turing machine running in polynomial time. Unlike most well-known complexity classes, it is not a class of decision problems but a class of function problems. The most difficult, representative problems of this class are #P-complete.
Relation to decision problems
An NP decision problem can often be stated in the form "Are there any solutions that satisfy certain constraints?" For example:- Are there any subsets of a list of integers that add up to zero?
- Are there any Hamiltonian cycles in a given graph with cost less than 100?
- Are there any variable assignments that satisfy a given CNF formula?
- Does a univariate real polynomial have any positive roots?
- How many subsets of a list of integers add up to zero?
- How many Hamiltonian cycles in a given graph have cost less than 100?
- How many variable assignments satisfy a given CNF formula?
- How many roots of a univariate real polynomial are positive?
Related complexity classes
One consequence of Toda's theorem is that a polynomial-time machine with a #P oracle can solve all problems in PH, the entire polynomial hierarchy. In fact, the polynomial-time machine only needs to make one #P query to solve any problem in PH. This is an indication of the extreme difficulty of solving #P-complete problems exactly.
Surprisingly, some #P problems that are believed to be difficult correspond to easy P problems. For more information on this, see #P-complete.
The closest decision problem class to #P is PP, which asks whether a majority of the computation paths accept. This finds the most significant bit in the #P problem answer. The decision problem class ⊕P instead asks for the least significant bit of the #P answer.
Formal definitions
#P is formally defined as follows:#P can also be equivalently defined in terms of a verifer. A decision problem is in NP if there exists a polynomial-time checkable certificate to a given problem instance—that is, NP asks whether there exists a proof of membership for the input that can be checked for correctness in polynomial time. Questions in #P ask how many certificates there exist for a problem instance that can be checked for correctness in polynomial time. In this context, #P is defined as follows:
History
The complexity class #P was first defined by Leslie Valiant in a 1979 article on the computation of the permanent of a square matrix, in which he proved that permanent is #P-complete.Larry Stockmeyer has proved that for every #P problem there exists a randomized algorithm using an oracle for SAT, which given an instance of and returns with high probability a number such that. The runtime of the algorithm is polynomial in and. The algorithm is based on the leftover hash lemma.