Characterizations and approximability of hard counting classes below #P

An important objective of research in counting complexity is to understand which counting problems are approximable. In this quest, the complexity class TotP, a hard subclass of #P, is of key importance, as it contains self-reducible counting problems with easy decision version, thus eligible to be approximable. Indeed, most problems known so far to admit an fpras fall into this class. An open question raised recently by the community of descriptive complexity is to find a logical characterization of TotP and of robust subclasses of TotP. In this work we define two subclasses of TotP, in terms of descriptive complexity, both of which are robust in the sense that they have natural complete problems, which are defined in terms of satisfiability of Boolean formulae. We then explore the relationship between the class of approximable counting problems and TotP. We prove that TotP ⊈ FPRAS if and only if NP ≠ RP and FPRAS ⊈ TotP unless RP = P. To this end we introduce two ancillary classes that can both be seen as counting versions of RP. We further show that FPRAS lies between one of these classes and a counting version of BPP. Finally, we provide a complete picture of inclusions among all the classes defined or discussed in this paper with respect to different conjectures about the NP vs. RP vs. P questions.



There are no comments yet.


page 1

page 2

page 3

page 4


On randomized counting versus randomised decision

We study the question of which counting problems admit f.p.r.a.s., under...

Parameterised Counting Classes with Bounded Nondeterminism

Stockhusen and Tantau (IPEC 2013) introduced the operators paraW and par...

Gaps, Ambiguity, and Establishing Complexity-Class Containments via Iterative Constant-Setting

Cai and Hemachandra used iterative constant-setting to prove that Few ⊆ ...

Parameterized Valiant's Classes

We define a theory of parameterized algebraic complexity classes in anal...

On the complexity of counting feedback arc sets

In this note we study the computational complexity of feedback arc set c...

Descriptive Complexity for Counting Complexity Classes

Descriptive Complexity has been very successful in characterizing comple...

Counting Problems over Incomplete Databases

We study the complexity of various fundamental counting problems that ar...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

The class  [22] is the class of functions that count the number of solutions to problems in , e.g. #Sat is the function that on input a formula returns the number of satisfying assignments of

Equivalently, functions in  count accepting paths of non-deterministic polynomial time Turing machines (NPTMs).

-complete problems are hard to count, but it is not the case that problems in  are easy to count as well. When we consider counting, non-trivial facts hold. First of all there exist -complete problems, that have decision version in , e.g. #Dnf. Moreover, some of them can be approximated, e.g. the Permanent [12] and #Dnf [14], while others cannot, e.g. #Is [13]. The class of problems in  with decision version in  is called , and a subclass of  is , which contains all self-reducible problems in  [17]. Their significance will be apparent in what follows.

Since many counting problems cannot be exactly computed in polynomial time, the interest of the community has turned to the complexity of approximating them. On one side, there is an enormous literature on approximation algorithms and inapproximability results for individual problems in  [13, 9, 12, 14, 22]

. On the other hand, there have been attempts to classify counting problems with respect to their approximability 

[2, 3, 8, 19].

1.0.1 Related work.

From a unifying point of view, the most important results regarding approximability are the following. Every function in  either admits an fpras, or does not admit any polynomial approximation ratio [20]; we will therefore call the latter inapproximable. For self-reducible problems in , fpras is equivalent to almost uniform sampling [20]. With respect to approximation preserving reductions, there are three main classes of functions in  [8]: (a) the class of functions that admit an fpras, (b) the class of functions that are interreducible with #Sat, and (c) the class of problems that are interreducible with #Bis. Problems in the second class do not admit an fpras unless =, while the approximability status of problems in the third class is unknown and the conjecture is that they are neither interreducible with #Sat, nor they admit an fpras. We will denote  the class of  problems that admit an fpras.

Several works have attempted to provide a structural characterization that exactly captures , in terms of path counting [4, 17], interval size functions [5], or descriptive complexity [3]. Since counting problems with -complete decision version are inapproximable unless  [8], those that admit fpras should be found among those with easy decision version (i.e., in  or even in ). Even more specifically, in search of a logical characterization of a class that exactly captures , Arenas et al. [3] show that subclasses of  are contained in , and they implicitly propose to study subclasses of  with certain additional properties in order to come up with approximable problems. Notably, most problems proven so far to admit an fpras belong to , and several counting complexity classes proven to admit an fpras, namely ,  [19], ,  [3] and  [2], are subclasses of .

Counting problems in  have also been studied in terms of descriptive complexity [3, 6, 7, 8, 19]. Arenas et al. [3] raised the question of defining classes in terms of descriptive complexity that capture either  or robust subclasses of ,  as one of the most important open questions in the area. A robust class of counting problems needs either to have a natural complete problem or to be closed under addition, multiplication and subtraction by one [3]. In particular,  satisfies both of the above properties [3, 4].

1.0.2 Our contribution.

In the first part of the paper we focus on the exploration of the structure of  through descriptive complexity. In particular, we define two subclasses of , namely and , via logical characterizations; for both these classes we show robustness by providing natural complete problems for them. Namely, we prove that the problem #Disj2Sat of computing the number of satisfying assignments to disjunctions of 2SAT formulae is complete for under parsimonious reductions. This reveals that problems hard for under parsimonious reductions cannot admit an fpras unless . We also prove that #MonotoneSat is complete for under product reductions. Our result is the first completeness result for #MonotoneSat under reductions stronger than Turing. Notably, the complexity of #MonotoneSat has been investigated in [11, 5] and it is still open whether it is complete for , or for a subclass of  under reductions for which the class is downwards closed. Although, is not known to be downwards closed under product reductions, our result is a step towards understanding the exact complexity of #MonotoneSat.

Figure 1: Relation of  to counting classes below .

In the second part of this paper we examine the relationship between the class  and . As we already mentioned, most (if not all) problems proven so far to admit fpras belong to , so we would like to examine whether . Of course, problems in  have decision version in  [10], so if we assume

this is probably not the case. Therefore, a more realistic goal is to determine assumptions under which the conjecture

might be true. The world so far is depicted in Figure 1, where  denotes the class of problems in  with decision version in .

In this work we refine this picture by proving that (a) unless =, which means that proving would be at least as hard as proving , (b) if and only if , (c)  lies between two classes that can be seen as counting versions of  and , and (d) , which is the subclass of  with zero error probability when the function value is zero, lies between two classes that we introduce here, that can both be seen as counting versions of , and which surprisingly do not coincide unless =. Finally, we give a complete picture of inclusions among all the classes defined or discussed in this paper with respect to different conjectures about the  vs.  vs.  questions.

2 Two robust subclasses of

In this section we give the logical characterization of two robust subclasses of . Each one of them has a natural complete problem. Two kinds of reductions will be used for the completeness results; parsimonious and product reductions. Note that both of them preserve approximations of multiplicative error [8, 19].

Definition 1

Let , be two counting functions.

(a) We say that there is a parsimonious (or Karp) reduction from to , symb. , if there is a polynomial-time computable function , such that for every it holds that .

(b) We say that there is a product reduction from to , symb. , if there are polynomial-time computable functions such that for every it holds that .

The formal definitions of the classes , ,  and  follow.

Definition 2

(a) [22]  is the class of functions for which there exists a polynomial-time decidable binary relation and a polynomial such that for all , .

Equivalently, .

(b)  is the class of functions in  that are computable in polynomial time.

(c) [17] , where is the decision version of the function .

(d) [17] , where all computation paths of on input .

2.1 The class

In order to define the first class we make use of the framework of Quantitative Second-Order Logics (QSO) defined in [3].

Given a relational vocabulary , the set of First-Order logic formulae over is given by the grammar:

where are first-order variables, , is a tuple of first order variables, represents a tautology, and represents the negation of a tautology.

We define a literal to be either of the form or , where is a second-order variable and is a tuple of first-order variables. A 2SAT clause over is a formula of the form , where each of the ’s, , can be either a literal or a first-order formula over . In addition, at least one of them is a first-order formula. The set of -2SAT formulae over are given by:

where are tuples of first-order variables, and are 2SAT clauses for every .

The set of formulae over is given by the following grammar:

where is a -2SAT formula, , is a first-order variable and is a second-order variable. The syntax of formulae includes the counting operators of addition , , . Specifically, , are called first-order and second-order quantitative quantifiers respectively.


Table 1: The semantics of formulae

Let be a relational vocabulary, a -structure with universe , a first-order assignment for and a second-order assignment for . Then the evaluation of a formula over is defined as a function that on input returns a number in . The function is recursively defined in Table 1. A formula is said to be a sentence if it does not have any free variable, that is, every variable in is under the scope of a usual quantifier (, ) or a quantitative quantifier. It is important to notice that if is a sentence over a vocabulary , then for every -structure , first-order assignments , for and second-order assignments , for , it holds that . Thus, in such a case we use the term to denote for some arbitrary first-order assignment and some arbitrary second-order assignment for .

At this point it is clear that for any formula , a function is defined. In the rest of the paper we will use the same notation, namely , both for the set of formulae and the set of corresponding counting functions.111Moreover, we will use the terms ‘(counting) problem’ and ‘(counting) function’ interchangeably throughout the paper.

The following inclusion holds between the class  [8] and the class defined presently.

Proposition 1


A function is in the class if it can be expressed in the form , where is an unquantified CNF formula in which each clause has at most one occurrence of an unnegated variable from , and at most one occurrence of a negated variable from . Alternatively, the function can be expressed in the form The Restricted-Horn formula is also a 2SAT formula.

Therefore, .

The class contains problems that are tractable, such as #2Col, which is known to be computable in polynomial time [9]. It also contains all the problems in , such as #Bis, #1P1NSat, #Downsets [8]. These three problems are complete for under approximation preserving reductions and are not believed to have an fpras. At last, the problem #Is [8], which is interriducible with #Sat under approximation preserving reductions, belongs to as well.

We next show that a generalization of #2Sat, which we will call #Disj2Sat, is complete for under parsimonious reductions.

2.1.1 Membership of #Disj2Sat in

In propositional logic, a 2SAT formula is a conjunction of clauses that contain at most two literals. Suppose we are given a propositional formula , which is a disjunction of 2SAT formulae, then #Disj2Sat on input equals the number of satisfying assignments of .

In this subsection we assume that 2SAT formulae consist of clauses which contain exactly two literals since we can rewrite a clause of the form as , for any literal .

Theorem 2.1


Consider the vocabulary where , , are ternary relations and is a binary relation. This vocabulary can encode any formula which is a disjunction of 2SAT formulae. More precisely, iff clause is of the form , iff is , iff is , iff is and iff clause appears in the “disjunct” .

Let be an input to #Disj2Sat encoded by an ordered -structure , where the universe consists of elements representing variables, clauses and “disjuncts”. Then, it holds that the number of satisfying assignments of is equal to , where

Thus, is defined by which is in .

2.1.2 Hardness of #Disj2Sat

Suppose we have a formula in and an input structure over a vocabulary . We describe a polynomial-time reduction that given and , it returns a propositional formula which is a disjunction of 2SAT formulae and it holds that . The reduction is a parsimonious reduction, i.e. it preserves the values of the functions involved.

Theorem 2.2

#Disj2Sat is hard for under parsimonious reductions.


By Proposition 5.1 of [3], can be written in the form
, where each is a sequence of second-order variables and each is a 2SAT clause. Each term of the sum can be replaced by where is the union of all . Now we have expressed in the following form
The next step is to expand the first-order quantifiers and sum operators and replace their variables with first-order constants from the universe .

In this way, we obtain . Each first-order subformula of has no free-variables and is either satisfied or not satisfied by , so we can replace it by or respectively. Also, after grouping the sums and the conjunctions, we get . The formulae are conjunctions of clauses that consist of , and at most two literals of the form or for some second-order variable and some tuple of first-order constants . We can eliminate the clauses that contain a and remove from the clauses that contain it. After this simplification, some combinations of variable-constants may not appear in the remaining formula. For any such combination , we add a clause , since can have any truth value.

So, we have reformulated the above formula and we get . After replacing every appearance of by a propositional variable , the part becomes a disjunction of 2SAT formulae. Finally, we introduce new propositional variables and define
. The formula is a disjunction of 2SAT formulae and the number of its satisfying assignments is equal to . Moreover, every transformation we made requires polynomial time in the size of the input structure .

It is known that #2Sat has no fpras unless , since it is equivalent to counting all independent sets in a graph [8]. Thus, problems hard for under parsimonious reductions also cannot admit an fpras unless .

2.1.3 Inclusion of in

Several problems in , like #1P1NSat, #Is, #2Col, and #2Sat, are also in . We next prove that this is not a coincidence.

Theorem 2.3


Since is exactly the Karp closure of self-reducible functions of  [17], it suffices to show that the -complete problem #Disj2Sat is such a function.

First of all, Disj2Sat belongs to . Thus #Disj2Sat .

Secondly, every counting function associated with the problem of counting satisfying assignments for a propositional formula is self-reducible 222 contains all self-reducible problems in , with decision version in . Intuitively, self-reducibility means that counting the number of solutions to an instance of a problem, can be performed recursively by computing the number of solutions to some other instances of the same problem. For example, #Sat is self-reducible: the number of satisfying assignments of a formula is equal to the sum of the number of satisfying assignments of and , where is with its first variable fixed to .. So #Disj2Sat has this property as well.

Therefore, any formula defines a function that belongs to .

Corollary 1

2.2 The class

To define the second class , we make use of the framework presented in [19].

We say that a counting problem belongs to the class if for any ordered structure over a vocabulary , which is an input to , it holds that . The formula is of the form , where is a first-order formula over and is a positive appearance of a second-order variable. We call the formula a variable, since it contains only one second-order variable. Moreover, we allow counting only the assignments to the second-order variable under which the structure satisfies .

Proposition 2

, where #Vc is the problem of counting the vertex covers of all sizes in a graph.


An input graph to #Vc can be encoded as a finite structure using the vocabulary , where is the edge relation and is a binary relation. The universe is the set of all vertices and all edges. iff vertex is an endpoint of edge . Then, . Therefore, .

2.2.1 Completeness of #MonotoneSat for

Given a propositional formula in conjunctive normal form, where all the literals are positive, #MonotoneSat on input equals the number of satisfying assignments of .

Theorem 2.4


Consider the vocabulary with the binary relation to indicate that the variable appears in the clause . Given a -structure that encodes a formula , which is an input to #MonotoneSat, it holds that #MonotoneSat=.

Therefore, #MonotoneSat .

Theorem 2.5

#MonotoneSat is hard for under product reductions.


We show that there is a polynomial-time product reduction from any to #MonotoneSat. This means that there are polynomial-time computable functions and , such that for every -strucrure that is an input to we have .

Suppose we have a problem and a -structure . Then, there exists a formula of the form such that .

The formula can be written in the form

By substituting first-order subformulae by or and simplifying, we obtain , where each is a tuple of first-order constants. To define , we have simplified the subformulae containing and . As a result, there may be some combinations of the second-order variable and first-order constants that do not appear in . Let be the number of these combinations. The last transformation consists of replacing every with a propositional variable , so we get the output of the function , which is . This formula has no negated variables, so it can be an input to #MonotoneSat. Finally, since the missing variables can have any truth value, we have .

2.2.2 Inclusion of in

Theorem 2.6


It is easy to prove that and that  is closed under product reductions. Thus, the above results imply that every counting problem in belongs to .

3 On  vs.

In this section we study the relationship between the classes  and . First of all we give some definitions and facts that will be needed.

Theorem 3.1

[17] (a)    . The inclusions are proper unless .

(b)  is the Karp closure of self-reducible functions.

We consider  to be the class of functions in  that admit fpras, and we also introduce an ancillary class . Formally:

Definition 3

A function belongs to  if and there exists a randomized algorithm that on input returns a value such that

in time poly().

We further say that a function belongs to  if whenever the returned value equals with probability 1.

We begin with the following observation.333The following theorem is probably well-known among counting complexity researchers. However, since we have not been able to find a proof in the literature we provide one here for the sake of completeness.

Theorem 3.2

if and only if =.


For the one direction we observe that if  then there are functions in , that are not in . For example, #Is belongs to , and does not admit an fpras unless = [13].

The other direction derives from a Stockmeyer’s well known theorem [21]. By Stockmeyer’s theorem there exists an fpras, with access to a oracle, for any problem in . If = then  [23]. Finally it is easy to see that an fpras with access to a  oracle, can be replaced by another fpras, that simulates the oracle calls itself.

Corollary 2

if and only if if and only if .


iff = is an immediate corollary of the proof of Theorem 3.2 along with the observations that and .

We prove that iff . Suppose that and let be a function in . Then . Now we can modify the fpras for so that it returns the correct value of with probability 1 if . We can do this since we can decide if in polynomial time. So, .

The other direction is trivial by the inclusion .

Now we examine the opposite inclusion, i.e. whether  is a subset of . To this end we introduce two classes that contain counting problems with decision in .

Recall that if a counting function admits an fpras, then its decision version, i.e. deciding whether , is in . In a similar way, if a counting function belongs to , then its decision version is in . So we need to define the subclass of  with decision in . Clearly, if for a problem in  the corresponding counting machine has an  behavior (i.e., either a majority of paths are accepting or all paths are rejecting) then the decision version is naturally in . However, this seems to be a quite restrictive requirement. Therefore we will examine two subclasses of .

For that we need the following definition of the set of Turing Machines associated to problems in .

Definition 4

Let be an NPTM. We denote by the polynomial such that on inputs of size , makes non-deterministic choices.
either or

Definition 5


Definition 6


Note that , although restrictive, contains counting versions of some of the most representative problems in , for which no deterministic algorithms are known. For example consider the polynomial identity testing problem (Pit 444Determining the computational complexity of polynomial identity testing is considered one of the most important open problems in the mathematical field of Algebraic Computing Complexity.): Given an arithmetic circuit of degree that computes a polynomial in a field, determine whether the polynomial is not equal to the zero polynomial. A probabilistic solution to it is to evaluate it on a random point (from a sufficiently large subset of the field). If the polynomial is zero then all points will be evaluated to else the probability of getting is at most . A counting analogue of Pit is to count the number of elements in that evaluate to non-zero values; clearly this problem belongs to . Another problem in  is to count the number of compositeness witnesses (as defined by the Miller-Rabin primality test) on input an integer ; although in this case the decision problem is in  (a prime number has no such witnesses and this can be checked deterministically by AKS algorithm [1]), for a composite number at least half of the integers in are Miller-Rabin witnesses, hence there exists a NPTM that has as many accepting paths as the number of witnesses.

 contains natural counting problems as well. Two examples in  are #Exact Matchings and #Blue-Red Matchings, which are counting versions of Exact Matching [18] and Blue-Red Matching [16], respectively, both of which belong to RP (in fact in RNC) as shown in [15, 16]; however, it is still open so far whether they can be solved in polynomial time. Therefore it is also open whether #Exact Matchings and #Blue-Red Matchings belong to .

We will now focus on relationships among the aforementioned classes. We start by presenting some unconditional inclusions and then we explore possible inclusions under the condition that either or holds.

The results are summarized in Figures 3 and 3.

Figure 2: Unconditional inclusions.



Figure 3: Conditional inclusions. The following notation is used: denotes , denotes , and denotes .

3.1 Unconditional inclusions

Theorem 3.3

. Also .


Let . We will show that . We will construct an NPTM s.t. on input , . Let . We construct that computes and then it computes s.t. . makes non-deterministic choices . Each such determines a path, in particular, corresponds to the -st path (since is the first path). returns yes iff , so . Since

The other inclusions are immediate by definitions.

Theorem 3.4


For the first inclusion, let Let . There exists an s.t. , Let be the number of non-deterministic choices of Let

. We can compute an estimate

of by choosing paths uniformly at random. Then we can compute .

To proceed with the proof we need the following lemma.

Lemma 1

(Unbiased estimator.) Let

be two finite sets, and let . Suppose we take samples from uniformly at random, and let a be the number of them that belong to . Then is an unbiased estimator of , and it suffices in order to have

If , then so by the unbiased estimator of lemma 1, satisfies the definition of fpras. If then , so the estimated value is with probability 1.

For the second inclusion, let , we will show that the decision version of , i.e. deciding if , is in . On input we run the fpras for with e.g. We return yes iff

By the definition of , if then the fpras returns , so we return yes with probability . If , then with probability at least , so we return yes with the same probability.

Corollary 3


Corollary 4

If then =.


If   , then   , and then for all , . So if via then , and thus . Thus =.

Corollary 5

If  then =.


If = then they are both equal to , thus   . Therefore, = by Corollary 2.

Theorems 3.3 and 3.4 together with Theorem 3.1 are summarised in Figure 3.

3.2 Conditional inclusions / Possible worlds

Now we will explore further relationships between the above mentioned classes, and we will present two possible worlds inside , with respect to  vs.  vs. .

Theorem 3.5

The inclusions depicted in Figure 3 hold under the corresponding assumptions on top of each subfigure.


First note that intersections between any of the above classes are non-empty, because  is a subclass of all of them. For the rest of the inclusions, we have the following.

  • In the case of .

    • By definitions,    =. Therefore,

    • By Theorem 3.1, the inclusions