In computational complexity theory and computability theory, a counting problem is a type of computational problem that is obtained by strengthening a decision problem. For example, the SAT problem asks: "Given a Boolean formula, is there a truth-value assignment such that it evaluates to True?". The corresponding counting problem, called #SAT, asks: "Given a Boolean formula, how many truth-value assignments are there such that it evaluates to True?". And in general, the counting problem corresponding to a decision problem X is called #X, where # is the number sign. Counting complexity techniques have significant applications in clarifying the relation between complexity classes of P, NP, PH, etc, in circuit complexity, and in interactive proof systems.
Definition Let R be a search problem, formalised as a binary relation R(x,y). That is, given a problem instance x, one can proposed solutions. R(x,y) is true iff y is an admissible solution to the problem instance. Let cR(x)=|{y∣R(x,y)}| be the counting function. That is, it counts the total number of admissible solutions. This is a function problem, not a decision problem. In order to conform to the standard format in computational complexity theory, we use the standard trick of converting a function problem to a decision problem, using the graph of the function. Let #R={(x,y)∣y≤cR(x)}. That is, it is the set of all points on or below the curve of cR(x). While it appears that computing cR(x) is harder than deciding whether some point (x,y) belongs to #R, in fact cR can be Cook-reduced to #R using binary search on the value of cR(x), provided that cR(x) is bounded by O(2𝗉𝗈𝗅𝗒(|x|)). Concretely, one tests with (x,0),(x,1),…,(x,2n),…,(x,2n2),… until one finds an element not in #R, then backtracks to pinpoint the exact value of cR(x). In particular, cR(x) must be bounded by O(2𝗉𝗈𝗅𝗒(|x|)) if it is FP, that is, computable in polynomial time by a Turing machine, since otherwise the machine will not have enough time to produce the full output. Throughout this article, we assume that cR(x) is FP. This then allows us to switch between the decision-formulation with #R and the function-formulation cR fluidly without further comment.
Classes
#P
The most important classes of counting problems is the #P class, the counting problems corresponding to the NP class of decision problems. An NP problem is a decision problem that asks, "Given a problem instance, is there at least one solution?", and furthermore, an NP problem comes with a solution-verifier Turing machine that runs in polynomial time. The corresponding #P problem then asks: "Given a problem instance, how many solutions are there?". More succinctly, #P counts accepting paths of an nondeterministic Turing machine running in polynomial time. Just as NP has NP-complete problems via many-one reductions, #P has #P-complete problems via polynomial-time parsimonious reductions. Given two search problems A,B, a polynomial-time parsimonious reduction from A to B is a function f, such that
f is computable in polynomial time. For any problem instance xA of A, it maps to a problem instance f(xA) of B, such that xA and f(xA) have the same number of solutions. This reduction is reflexive and transitive. Some problems are #P-complete under polynomial-time parsimonious counting reduction, such as the #3SAT problem. To show this, simply take the standard proof that 3SAT problem is NP-complete, and note that the reduction used in the proof is already parsimonious. More examples are given on the Parsimonious reduction page. The polynomial-time many-one counting reduction is another, more lenient form of reduction. Given two search problems A,B, a polynomial-time many-one reduction from A to B consists of two functions f,g, such that
f,g are computable in polynomial time. For any problem instance xA of A, f maps to a problem instance f(xA) of B, such that the number of solutions to xA is computed by mapping the number of solutions to f(xA) using g:cA(xA)=g(cB(f(xA))) Counting analogs of many natural NP-complete problems are #P-complete, but the opposite is not the case: Some decision problems correspond to #P-complete counting problems, even if they are in P, or even trivially decidable. For example, the 01-permanent counting problem is ♯P-complete under polynomial-time many-one counting reduction. This problem is equivalent to counting perfect matchings in a bipartite graph. Deciding whether perfect matchings exist in a bipartite graph is polynomial-time by the Hopcroft–Karp algorithm. There are some other problems that take polynomial time to decide, but are #P-complete to count:
Spanning trees of a graph. Eulerian cycles of a directed graph. Perfect matchings of a planar graph. There are some problems that are trivial to decide, but #P-complete to count:
Satisfying assignments to a monotone Boolean formula (one without negation symbol). There always exists at least one, by setting all variables to True. Non-cliques in a graph of size ⌈n/2⌉, where n is the number of vertices. If the whole graph has any pair of vertices not connected by an edge, then there exists such a non-clique. Spanning forests of a bipartite planar graph. There always exists at least one. Linear extensions to a partial ordering on a finite set. There always exists at least one. There are some counting problems known to be #P-hard, but possibly exceeding #P:
Given two graphs, count the number of graph isomorphisms between them. This is known to be computable in polynomial time given an NP-oracle. Given a graph, count the number of subgraphs that are Hamiltonian.
ModP ModkP asks: "Given a problem instance, is the number of solutions divisible by k?". For all k≥2, ModkP contains the graph isomorphism problem. Further, the graph isomorphism problem is low in ModkP. When k is prime, the set of languages low in ModkP is ModkP itself. ⊕P is defined to be Mod2P. It asks: "Given a problem instance, is the number of solutions even or odd?". It is low in itself: ⊕𝖯⊕𝖯=⊕𝖯.
PP
… excerpt ends here. Continue reading the full article.