The clone membership problem, asking whether a given function is expressible by means of a given list of initial functions, is a basic problem in universal algebra, where it can be phrased as whether a given operation is term-definable in a given algebra, in logic, where we ask if a given truth function (in a possibly multi-valued logic) is definable by a formula over a given set of connectives, and in computer science, where we ask if a given function is computable by a circuit over a given basis of gates.
From the point of view of computational complexity, several variants of the problem were studied in the literature. The most straightforward representation of the input functions is by tables of values. In this setting, Kozen  proved that the membership problem for clones of unary functions on arbitrary finite domains is -complete. The general clone membership problem for arbitrary functions on finite domains is -complete. This result is credited in  to an unpublished manuscript of H. Friedman, but the first published proof is due to Bergman, Juedes, and Slutzki ; a mistake in their paper was corrected by Mašulović . As shown by Kozik , there even exists a fixed finitely generated clone on a finite domain whose membership problem is -complete.
The high complexity of the problem on arbitrary finite domains is related to the complicated structure of clones on domains of size . In contrast, the lattice of clones on the Boolean (two-element) domain is quite simple, and it has been explicitly described by Post . As a result, the Boolean clone membership problem is computationally much easier than the general case: it was shown to be in by Bergman and Slutzki , while Vollmer  proved that it was in quasipolynomial , which implies it is not -hard (or even -hard).
The representation of functions by tables is quite inefficient, as it always has size exponential in the number of variables. A viable alternative, especially in the Boolean case, is to represent functions by expressions (circuits or formulas) over some canonically chosen functionally complete basis, say, the De Morgan basis . In this setting, Böhler and Schnoor  studied the complexity of membership problems for fixed Boolean clones : they proved that all such problems are -complete with a few exceptions that are in . More generally, they studied variants of the problem where is not given by a circuit over a functionally complete basis, but over an arbitrary (but fixed) basis. They classified most such problems as being -complete or in .
The full Boolean clone membership problem in the circuit representation (denoted CMP in this paper) was considered by Vollmer , who claimed it was also -complete. However, he did not provide much in the way of proof for the upper bound,111Essentially just stating that it follows from a criterion similar to our þ3.2 below, despite that it involves both positive and negative occurrences of the preservation relation. and as we will see shortly, this claim is wrong.
A characterization of clone membership in terms of preservation of relational invariants easily implies that CMP is computable in —more precisely, in the class . The main goal of this paper is to prove that CMP is in fact -complete. As a warm-up, we consider a restriction of CMP dual to Böhler and Schnoor’s results: we prove that for a fixed target Boolean function , the clone membership problem is -complete in all nontrivial cases (i.e., unless is a projection function, or a nullary function if we allow them). This already shows that CMP cannot be -complete unless . We then go on to prove that CMP is -complete; our main technical tool is a characterization of clones generated by threshold functions. We also discuss some variants of our results, such as using formulas instead of circuits for representation of functions, or allowing nullary functions.
In the second part of the paper, we investigate the complexity of restricted versions of CMP, denoted -CMP, where the input functions are given by circuits or formulas over an arbitrary (but fixed) finite basis instead of the De Morgan basis. We show that -CMP remains -complete, albeit using randomized reductions, when the clone generated by has infinitely many subclones, and includes some non-monotone functions; we rely on a randomized construction of formulas for threshold functions using fixed threshold functions as gates, following the method of Valiant . On the other hand, if has only finitely many subclones, we classify the complexity of -CMP as either -complete or in . The complexity of -CMP remains open when has infinitely many subclones, but consists of monotone functions only.
We will assume basic familiarity with the theory of Boolean clones; this is described in many places, for example Lau . We will summarize the most important points below to fix our terminology and notation.
Let . An -ary Boolean function (or operation) is a mapping . We denote the set of -ary Boolean functions by , and the set of all Boolean functions by . (Following the tradition in literature on Boolean clones, we disallow nullary functions; we will comment later on how this affects our results.)
We will use common connectives such as to denote specific Boolean functions; by abuse of notation, and denote the constant functions of arbitrary arity. If , the projection function is defined by . For any and , the threshold function is defined by
Notice that , , , , and is the identity function. We recall that threshold functions have uniformly constructible polynomial-size circuits, and indeed, uniformly constructible -depth formulas.
Given functions and , their composition is the function defined by
A set of Boolean functions is a clone if it contains all projections and is closed under composition. The intersection of an arbitrary collection of clones is again a clone (where the empty intersection is understood as ), thus the poset of clones under inclusion forms a complete lattice, and it yields an (algebraic) closure operator ; that is, for any , denotes the clone generated by .
The Boolean clone membership problem CMP is the following decision problem:
Input: A finite set of functions and a function , all given by Boolean circuits over the De Morgan basis .
Output: YES if , otherwise NO.
For any clone , the membership problem is the special case of CMP where is fixed:
Input: A function , given by a Boolean circuit over the De Morgan basis.
Output: YES if , otherwise NO.
Dually, for a fixed function , denotes the following special case of CMP:
Input: A finite set of functions , given by Boolean circuits over the De Morgan basis.
Output: YES if , otherwise NO.
Notice that whenever , as the output condition can be stated as .
A -ary Boolean relation is . The set of -ary Boolean relations is denoted by , and the set of all relations by . (Here, it will not make any difference if we allow nullary relations or not; the reader is welcome to make the choice.) A function preserves a relation , written as , if , considered as a mapping of the relational structures , is a homomorphism. Explicitly, iff the following implication holds for every matrix :
If and , we write if for all and . The set of invariants of and the set of polymorphisms of are defined by
The mappings and form an (antitone) Galois connection. The Galois-closed subsets of are exactly the clones: that is, is a clone for any , each clone can be described as for some , and for any .
If we allowed nullary functions, then Galois-closed subsets of would be exactly the coclones: subsets that are closed under definitions by primitive positive formulas, i.e., first-order formulas of the form , where each is an atomic formula (an instance of a relation , or of equality). Under our restriction to non-nullary functions, Galois-closed subsets of are only the coclones that contain the empty relation .
The lattice of Boolean clones was completely described by Post . In particular, we will make use of the following characterization, fixing our naming of basic clones and their invariants along the way. Here, for any , denotes the graph of .
þ Every Boolean clone is an intersection of a family of completely meet-irreducible clones, which are:
The clone of monotone functions, where denotes the relation .
The clone of affine functions, where denotes addition in , and .
The clone of self-dual functions.
The clone of conjunctive functions.
The clone of disjunctive functions.
The clone of essentially unary functions, where .
For each , the clones and , where , and the relations are defined by
Since , this includes as a special case the clones and of -preserving and -preserving functions (respectively).
We will denote intersection of named clones by juxtaposition, so that, e.g., . For convenience, we also put and . We have and . We will denote the top and bottom of the lattice of clones by and , i.e., , and . We define
for each , and .
The Hasse diagram of the lattice of Boolean clones (called Post’s lattice) is depicted in Fig. 1. (In fact, Post  did not work with the modern definition of clones, but with a slightly weaker concept of iterative classes, which do not necessarily contain all projections. Thus, his original lattice has four more classes.)
We assume the reader is familiar with basic notions of complexity theory, including the classes , , and . The class , introduced by Wagner , is defined as : the class of languages computable in polynomial time using queries to an oracle. It has several other equivalent characterizations, see Buss and Hay . In particular, (languages computable in polynomial time with non-adaptive access to an oracle).
If is a complexity class, we say that a language is -hard if for every , there exists a many-one (uniform) reduction from to ; if, moreover, , then is -complete. We chose reductions because they strike the right balance for our purposes. On the one hand, they are fairly restrictive: not only they are stricter than log-space or poly-time reductions that are often used to define -completeness, but they also have less power than our other classes of our interest, and , hence they give rise to a sensible notion of -completeness. On the other hand, is powerful enough to support the kind of syntactic manipulations that we will use to define our reductions, such as substituting one formula into another. We believe that the bulk of our completeness results actually hold under more restricted notions of reductions, such as dlogtime reductions, but the extra effort needed to get there would distract us from the main point of this paper.
3 The complexity of Cmp
Using þ2.1, we may restrict attention to , but this is still an infinite number of invariants, hence we need an efficient bound on how far up in the hierarchy we need to go.
þ Let , , and . The following are equivalent:
There is such that for all , where , .
a vectorsuch that and . Then the matrix witnesses that : if, say, , we have for each , but .
þ If and , then
Proof: The left-to-right implication is clear. For the right-to-left implication, if , then one of the completely meet-irreducible clones as given in þ2.1 satisfies and . Moreover, if for some and , then also by þ3.1. Thus, we may assume for some , i.e., and .
þ If and are given by Boolean circuits, we can test if in .
Proof: Straight from the definition, we have that iff there exists a matrix (which is a polynomial-size object) such that for each , and
These properties of can be checked in polynomial time.
for each clone .
for each .
(i): Given and of arity , we can determine if in by evaluating (1): there are relations in , and they can be described by efficiently constructible Boolean circuits. Thus, in view of þ3.3, we can ask the oracle if and if for each in parallel, and read the answer off of the oracle responses.
(ii): We use þ3.2 again, but since is fixed, we can test in deterministic polynomial time: is a finite set, and for each , is a downward-closed subset of , i.e., either all of , or a finite set. Thus, (1) can be evaluated in .
We now turn to lower bounds which will show that þ3.4 is mostly optimal, with a few exception in (ii) and (iii). We start with and , where we can prove -hardness by simple reductions from Boolean satisfiability.
Theorem 3.5 (Böhler and Schnoor )
þ Let be a Boolean clone.
If , then . More precisely, is trivial, and is -complete for .
Otherwise (i.e., if , , , , or ), is -complete.
(i): iff , which can be checked in polynomial time. In fact, it is easy to see that testing membership in , , or is equivalent to the -complete problem of evaluation of Boolean circuits.
(ii): That is included in , , , , or follows by inspection of Post’s lattice (Fig. 1). We have by þ3.4. In order to show -hardness, we will provide a reduction from UnSat; it will even be independent of .
Given a formula in variables , let
thus . Moreover,
þ Let .
If is a projection (i.e., ), then is trivial.
Otherwise, is -complete.
hence is a reduction from Sat to whenever . Likewise, the reduction works whenever , and works whenever . This covers all cases where is not a projection.
þ unless .
It will take more work to establish the true complexity of CMP. Notice first that the only way it can get as hard as is by interaction of and deep inside one of the infinite arms of Post’s lattice: otherwise (1) holds with a constant , in which case the criterion can be evaluated in , i.e., in the Boolean hierarchy (cf. þ4.2).
A convenient supply of functions on the infinite arms of Post’s lattice is given by threshold functions, hence our first task will be to describe exactly what clones they generate. For completeness, the lemma below is stated including various cases that we will not actually need.
þ Let and . Then
Proof: The cases with , , or are straightforward.
Notice that the dual of is . Thus, if (which implies
is odd), then. By Fig. 1, is a minimal clone, hence unless is a projection, which only happens when .
Assume that . Clearly, . Since has two disjoint subsets of size , . Also, implies that is not bounded below by a variable, i.e., by þ3.1. By inspection of Post’s lattice, it follows that for some . Now, for any , we have iff can be covered by subsets of size iff , thus
and consequently .
Finally, assume that . The dual of is , where satisfies . Thus, by the case that we just proved, with
and is its dual, .
In order to prove the -completeness of CMP, we will need a convenient -complete language to reduce from. In fact, the statement below effectively gives a -complete promise problem rather than a language. It is essentially due to Wagner [18, Cor. 6.4] and Buss and Hay [5, Thm. 8] (see also [12, L. 2.1]).
þ Let be any language such that . Then there exists a -function (where each is a CNF) with the following property: for every , there exists such that for all ,
and we have
is computable by a polynomial-time Turing machinethat makes parallel (non-adaptive) queries to an oracle. Given a , put ; for any , let be a CNF whose satisfiability is equivalent to the property “at least queries made by have positive answers”, a CNF expressing “there is an accepting run of with positive answers to queries, all of which are correct”, and a CNF equivalent to . If is the true number of positively answered queries made by , then is satisfiable iff or depending on if .
þ There exists a -function , and for each , a sequence of integers , with the following property: whenever is a sequence of formulas, we have , where .
Proof: For a given , fix (to be specified later) and . We may assume that the formulas use pairwise disjoint sets of variables that are also disjoint from . Put
When is unsatisfiable, we have . Thus, renumbering w.l.o.g. the s so that each , , is satisfiable,
On the one hand, by þ3.1, thus . On the other hand, for each , we may choose a satisfying assignment to , substitute for each variable made by , and substitute for each variable made by . (By our assumptions on variables, we can do this independently for each , and it will not affect the variables.) Under this substitution, becomes equivalent to , and becomes . Thus,
using þ3.8, where
as long as , i.e., . In order to satisfy the constraint , it suffices to ensure that
for all , i.e., . This holds if we choose .
þ CMP is -complete.
Proof: We have by þ3.4. In order to show that it is -hard, fix .
where are as in þ3.10. It follows that
Thus, is a reduction from to CMP.
þ We followed the tradition in the study of Boolean clones—going back to Post—of considering only functions of positive arity, even though the general theory of clones and coclones works more smoothly if nullary functions are also allowed. Let us see now what changes if we include nullary functions into consideration.
First, the number of Boolean clones increases—namely, each non-nullary clone that includes at least one constant function (i.e., or ) splits into two: one consisting only of non-nullary functions as before, and one that also includes nullary functions corresponding to all constant functions of . In þ2.1, we understand the given definitions of meet-irreducible clones so that they include all applicable nullary functions; moreover, there is a new meet-irreducible clone of all non-nullary functions, where . Consequently, we include in for each . Note that and .
Since the set is no longer functionally complete, we read the definition of CMP and derived problems so that the input is given in the form of circuits over the basis , where and denote nullary constants.
The upper bounds in þ3.4 continue to hold unchanged.
In þ3.5, the main dichotomy still holds: if , and is -complete otherwise. The difference is that now there are more clones , namely , , , , , , and . is trivial, and is -complete for . The problem amounts to testing if the given Boolean circuit has a nonzero number of input variables: the exact mechanics of this test will depend on syntactic details of the representation of input, but it can be done in under any reasonable respresentation.
The statement of þ3.6 changes so that is -complete if is neither a projection nor a nullary function. If is a nullary function, then is -complete: if is a nullary constant, we have that iff either , or contains the dual constant and .
All named clones in þLABEL:lem:thr,lem:th-seq need to be intersected with , so that, e.g., the conclusion of þ3.10 reads .
The main þ3.11 still holds.
þ We defined CMP and related problems so that the input functions are represented by Boolean circuits, which is the natural thing to do in a computational context. However, in the context of logic or algebra, it is more natural to represent Boolean functions by Boolean formulas, or equivalently, Boolean terms.
Fortunately, this has negligible effect on our results. First, all upper bounds hold also for the formula representation, because formulas are special cases of circuits. On the other hand, our main lower bounds continue to hold in this setting as well: we used reductions from Boolean satisfiability (that already works with formulas), and the most complicated tools we employed were threshold functions, which can be written with uniform polynomial-size formulas just as well as circuits.
The only exceptions are problems that we proved -complete by reductions from evaluation of Boolean circuits: namely, for (þ3.5), and for a nullary function (þ3.6 as modified in þ3.12). If we change the input representation to formulas, then all these problems become -complete, which is the complexity of evaluation of Boolean formulas (Buss ).
4 Restricted input bases
The problems CMP, , and are defined so that the input functions are given by circuits over a fixed functionally complete basis. This is reasonable if we consider these circuits to be just a computing device. However, if we view the problem as “given a circuit over the De Morgan basis, can we rewrite it as a circuit over a given basis ?”, it makes perfect sense to also consider the case where the input circuits are expressed in a different basis. That is, for any finite , let -CMP be the following problem:
Input: A finite set of functions and a function , all given by circuits over the basis .
Output: YES if , otherwise NO.
(We will refer to -circuits for short instead of circuits over basis , and likewise for -formulas.) Similarly, we define the problems - and -.
The complexity of - was thoroughly investigated by Böhler and Schnoor , who denote the problem as , and its formula version as . For most combinations of and , they were able to show that and are both -complete, or both in .
We will not make any effort to classify the complexity of the problems -, as the number of cases is prohibitively large, hence we consider it out of scope of this paper. (The problem has two clone parameters, analogously to -, which took Böhler and Schnoor a whole paper to understand, and even then their classification is incomplete.)
We will not obtain a complete classification of the complexity of -CMP either, nevertheless we present a number of partial results, summarized in þ4.15 at the end of the section.
Unless stated otherwise, the complexity results below also hold for variants of -CMP where the input functions are represented by formulas. To be precise, we consider formulas as strings: if consists of at most binary functions, we may write them in the common infix notation, but in general, it is perhaps best to settle on the prefix (Polish) notation.
For simplicity, we disallow nullary functions in this section, but the results below can be easily adapted to a setup where they are included.
Our results will be stated for arbitrary bases, but we will often need to express specific functions. Thus, it is useful to observe that we can more-or-less freely convert circuits and formulas to different bases. Notice that CNFs and other constant-depth formulas using unbounded fan-in , gates can be written as -depth bounded fan-in formulas.
þ Let be finite such that .
Given a -circuit, we can construct as equivalent -circuit by a function.
Given a -formula of depth , we can construct as equivalent -formula by a function.
(i): For each , we fix an expression of in terms of , and replace with it all -gates in the circuit.
(ii): Starting from a -formula of depth , the construction above produces a -circuit of depth , which can be unwinded into a -formula of depth , and consequently of size . One can check that the whole procedure can be implemented in .
For the rest of this section, is a finite subset of .
We start with the following simple observation. Recall that the Boolean hierarchy is defined as the closure of under (finitary) intersections, unions, and complements. Alternatively, it can be characterized as . The Boolean hierarchy is stratified into levels; the bottom level consists of and , and the next level of the classes
þ If , , , , , or , then .
Proof: By inspection of Post’s lattice, we see that there are only finitely many clones below . Thus, if and are given by -circuits, we have
for some constant , which gives a algorithm in view of þ3.3.
In fact, we can characterize the complexity of -CMP for as in þ4.2 more precisely.
First, the tractable cases. The theorem below mostly follows from results of Böhler and Schnoor : the given clones have only finitely many subclones, hence - iff - for each clone . However, we give a self-contained proof, which also confirms that the complexity drops down to for formulas.
þ If , , , , , or , then . If we represent the input by formulas rather than circuits, .
Proof: Assume that . The set of -ary functions in is very limited: it consists only of and the functions for (including ). Given a -circuit, we can determine which of these functions it computes by evaluating it on the assignment , which detects the function, and for each , on (with at position ), which detects if .
Once we know the function, it is trivial to determine which of the finitely many subclones of it generates, and if we know the clones generated by and by each element of , we can find out if . This gives a polynomial-time algorithm. Moreover, since the algorithm just evaluates the input functions on polynomially many assignments in parallel, and then does