ArticleslgStudy

computer science

Counting problem (complexity)

Counting problem (complexity) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Counting problem (complexity) rather than just read about it. In short: 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?".

Key takeaways

  • Counting problem (complexity) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Counting problem (complexity) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Counting problem (complexity) from memory before moving on to harder problems.

Reference excerpt

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.

Worked examples

Example 1 — a first encounter with Counting problem (complexity)

Start with the simplest possible case. Write down what Counting problem (complexity) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Counting problem (complexity) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Counting problem (complexity) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Counting problem (complexity)

In research
Counting problem (complexity) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Counting problem (complexity) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Counting problem (complexity) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computability theory, Computational problems, so understanding it makes those chapters shorter.
In everyday life
Look for Counting problem (complexity) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Counting problem (complexity)” →

How to study Counting problem (complexity) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Counting problem (complexity) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Counting problem (complexity) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Counting problem (complexity) in simple terms?

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?".

Why does Counting problem (complexity) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Counting problem (complexity)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Counting problem (complexity).

Tags

  • Computability theory
  • Computational problems

Keep exploring