Week 1: an Overview of Circuit Complexity 1 Welcome 2
Total Page:16
File Type:pdf, Size:1020Kb
Topics in Circuit Complexity (CS354, Fall’11) Week 1: An Overview of Circuit Complexity Lecture Notes for 9/27 and 9/29 Ryan Williams 1 Welcome The area of circuit complexity has a long history, starting in the 1940’s. It is full of open problems and frontiers that seem insurmountable, yet the literature on circuit complexity is fairly large. There is much that we do know, although it is scattered across several textbooks and academic papers. I think now is a good time to look again at circuit complexity with fresh eyes, and try to see what can be done. 2 Preliminaries An n-bit Boolean function has domain f0; 1gn and co-domain f0; 1g. At a high level, the basic question asked in circuit complexity is: given a collection of “simple functions” and a target Boolean function f, how efficiently can f be computed (on all inputs) using the simple functions? Of course, efficiency can be measured in many ways. The most natural measure is that of the “size” of computation: how many copies of these simple functions are necessary to compute f? Let B be a set of Boolean functions, which we call a basis set. The fan-in of a function g 2 B is the number of inputs that g takes. (Typical choices are fan-in 2, or unbounded fan-in, meaning that g can take any number of inputs.) We define a circuit C with n inputs and size s over a basis B, as follows. C consists of a directed acyclic graph (DAG) of s + n + 2 nodes, with n sources and one sink (the sth node in some fixed topological order on the nodes). The nodes are often called gates. For i = 1; : : : ; n, the ith gate in topological order is a source associated with the ith input bit. (These nodes are often called input gates.) The gates numbered j = n + 1; : : : ; s in topological order are each labeled with a function fj from B. Each function fj has fan-in equal to the indegree of j. We’ll sometimes call such a C a B-circuit, for short. n Evaluating a circuit C on an n-bit input x = (x1; : : : ; xn) 2 f0; 1g is done as follows. The value on x of the ith gate is defined to be xi. For j = n + 1; : : : ; s, the value on x of the jth 1 gate is vj = fj(vi1 ; : : : ; vik ), where i1; : : : ; ik < j are those nodes with edges to node j (listed in topological order), vi` is the value of node i`, and fj is the function assigned to node j. The output of C is the value of the sth gate on x. We often write C(x) to refer to the output of C on x. A circuit computes a function f : f0; 1gn ! f0; 1g if for all n-bit strings x, f(x) = C(x). An essentially analogous circuit definition also places the constants 0 and 1 in the circuit: we may add two more sources v0 and v1 to the DAG, which are defined to always take the values 0 and 1 (respectively). These values can then be fed into the other gates in an arbitrary way. When the basis B can simulate OR, AND, and NOT, these constants can be easily simulated by having a gate computing the function ZERO = (x ^ :x) and a gate computing ONE = (x _:x) for an arbitrary input x. So for all the basis sets we’ll consider, the difference in circuit size between the two models is only an additive factor. 2.1 Complexity Measures We sometimes use size(C) to refer to the size s of C. Size roughly measures the amount of time that would be needed to evaluate the circuit, if we used a single processor for circuit evaluation. However, if we could devote arbitrarily many processors for evaluating a circuit, then size is not the bottleneck for running time. The depth of a circuit is the longest path from any source to the sink. This measure would be more appropriate in measuring the time efficiency of a circuit which is being evaluated over many processors. Another interesting measure of complexity is the wire-complexity of a circuit, which is the total number of edges in the DAG. Note that as long as the indegree of each node is bounded by a constant (i.e., the fan-in of each gate is constant), the wire-complexity and the size are related by constant factors. (For indegree at most d, the wire-complexity is at most d times the size.) So in most cases we’ll study, the wire complexity is approximately the circuit size. But sometimes we will study circuits where the gates have unbounded fan-in, and there it is easy to have complex circuits with few gates and many wires. 2.2 An Example P Consider the MOD3 function on 4 bits: MOD3(x1; x2; x3; x4) = 1 () i xi = 0 (mod 3). The function is 1 when the sum of bits is either 3 or 0. Here is an optimal size circuit for computing MOD3 on 4 bits where the circuit is over all 2-bit functions, where ⊕ is the XOR of two bits and ≡ is the negation of XOR (the EQUALS function): 2 The circuit was found by Kojevnikov, Kulikov, Yaroslavtsev 2009 using a SAT solver, and the solver verified that there is no smaller circuit computing this function. Pretty awesome. 2.3 Circuit Complexity Given a Boolean function f and a basis set B, we define CB(f) to be the minimum size over all B-circuits that compute f. The quantity CB(f) is called the circuit complexity of f over B. What possible B’s are interesting? For circuits with bounded fan-in, there are two which are generally studied. (For circuits with unbounded fan-in, there are many more, as we’ll see.) 22 One basis used often is B2, the set of all 2 = 16 Boolean functions on two bits. (In general, k Bk refers to the set of all functions f : f0; 1g ! f0; 1g.) This makes the circuit complexity problem very natural: how efficiently can we build a given f 2 Bn from functions in B2? The next most popular basis is U2, which informally speaking, uses only AND, OR, and NOT gates, where NOT gates are “for free” (NOT gates are not counted towards size). More formally, for a variable x, define x1 = x and x0 = :x. Define the set b1 b2 b3 U2 = ff(x; y) = (x ^ y ) j b1; b2; b3 2 f0; 1gg: U2 consists of 8 different functions. When we have constants 0 and 1 built-in to the circuit, we can get more functions out of U2 without any trouble. By plugging constants into functions from U2, we can obtain f(x; y) = x, f(x; y) = :x, f(x; y) = y, f(x; y) = :y, f(x; y) = 0, 3 and f(x; y) = 1. That’s six more functions, so we’re up to 14. The only two functions we’re missing from B2 is XOR(x; y) = (x ^ :y) _ (:x ^ y) and its complement, EQUALS(x; y) = :XOR(x; y). Clearly for every f, CB2(f) ≤ CU2(f), because B2 only contains more functions than U2. From the above discussion, we also have: Proposition 1. For all f, CU2 (f) = CB2−{XOR;EQUALSg(f). Proof. Because every function from U2 is in B2 − fXOR; EQUALSg, we have CU2 (f) ≥ CB2−{XOR;EQUALSg(f). Every function from B2 − fXOR; EQUALSg can be simulated with a function from U2 (using built-in constants), so CU2 (f) ≤ CB2−{XOR;EQUALSg(f): given a minimum size circuit over B2 − fXOR; EQUALSg we can get a circuit of the same size over U2. Proposition 2. For all f, CU2 (f) ≤ 3CB2 (f). Proof. To get a U2-circuit from a B2-circuit, we only have to replace the XOR and NOT(XOR) gates with U2 functions. As EQUALS(x; y) = (x ^ y) _ (:x ^ :y); hence we can simulate EQUALS with 3 gates from U2. Taking the negation of this we also get XOR. The above shows that caring about whether you use U2 or B2 only makes sense if you care about constant leading factors, since the two circuit complexities within (small) constant factors of each other. Such linear factors could make a difference though, if the circuit complexity were only a linear function in n, i.e. CB2 = cn. (For many functions, this is unfortunately the best we know!) A more general result can be shown. A basis B is defined to be complete if for every Boolean function, there exists a Boolean circuit over B that computes f. (For example B = fANDg is not a basis, while B = fNORg is a basis.) We can see that B2 and U2 are complete, because we can write any function f in disjunctive normal form (DNF), as a huge OR of O(2n) ANDs, where each AND outputs 1 on exactly one input of f. So writing f as a “tree” of up to 2n ORs, where each leaf has n ANDs of variables and their negations, we can get a circuit for f over n U2 with size O(n2 ). Theorem 2.1. Let B be any complete basis of Boolean functions with constant fan-in. Then for all Boolean functions f, CB(f) = Θ(CU2 (f)) = Θ(CB2 (f)). 4 Here the constant factors depend on B.