Reference articles on history, science, culture and more
Encyclopedia

♯P

Complexity class

In computational complexity theory, the complexity class #P (pronounced "sharp P" or, sometimes "number P" or "hash 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(x)", 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.

01Relation to decision problems

An NP decision problem can often be stated in the form "Are there any solutions that satisfy certain constraints?" For example:

Corresponding #P function problems ask "how many" rather than "are there any". For example:

  • 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?

03Formal definitions

#P is formally defined as follows:

#P is the set of all functions f:\{0,1\}^{*}\to \mathbb {N} such that there is a polynomial-time nondeterministic Turing machine M such that for all x\in \{0,1\}^{*}, f(x) equals the number of accepting branches in M's computation graph on x.

#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:

#P is the set of functions f:\{0,1\}^{*}\to \mathbb {N} such that there exists a polynomial p:\mathbb {N} \to \mathbb {N} and a polynomial-time deterministic Turing machine V, called the verifier, such that for every x\in \{0,1\}^{*}, f(x)={\Big |}{\big \{}y\in \{0,1\}^{p(|x|)}:V(x,y)=1{\big \}}{\Big |}. (In other words, f(x) equals the size of the set containing all of the polynomial-size certificates).

04History

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 P there exists a randomized algorithm using an oracle for SAT, which given an instance a of P and \epsilon >0 returns with high probability a number x such that (1-\epsilon )P(a)\leq x\leq (1+\epsilon )P(a). The runtime of the algorithm is polynomial in a and 1/\epsilon. The algorithm is based on the leftover hash lemma.

Watch videos about ♯PExplainers and documentaries on YouTube (opens in a new tab)

Sources and credits

This article is adapted from the Wikipedia article ♯P, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.

Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.