Modelcore
Boolean circuit
Also called logic circuit, combinational circuit.
Directed acyclic graph of AND, OR and NOT gates; the non-uniform model for size and depth.
A Boolean circuit is a directed acyclic graph whose sources are the input bits and whose other nodes are gates that compute AND, OR or NOT. It computes a function from to for one fixed , so a program for inputs of all sizes is a family of circuits, one for each . The cost of a circuit is its size (the number of gates) and its depth (the length of the longest path). The model is non-uniform, and it is the model in which one proves that most functions are hard: Shannon showed by counting that most functions of bits need circuits of size about .
The machine
A Boolean circuit with inputs and outputs is a directed acyclic graph with these parts.
- There are input nodes with no incoming edge. They are labeled .
- Each other node is a gate. It is labeled AND, OR or NOT. A NOT gate has one incoming edge. An AND or OR gate has two incoming edges (bounded fan-in) or any number (unbounded fan-in).
- There are output nodes, each one an input node or a gate.
The edges leaving a node can go to any number of gates (the fan-out is not limited). On an input , each input node takes its bit, and each gate takes the AND, OR or NOT of the values on its incoming edges. The value of the circuit is the vector of the values of the output nodes. This defines a function . Because the graph has no cycle, the values are defined by induction along a topological order.
A formula is a circuit in which each gate has fan-out at most 1. The leaves are labeled by variables, and one variable may label many leaves, so the graph is a tree (a forest when there are several outputs).
Circuit families. A circuit works for one input length. To decide a language , one uses a family , where has inputs and one output, and exactly when .
Uniformity. A family is uniform when a fixed algorithm builds from . For example, a family is log-space uniform if a Turing machine with a work tape of cells, given , writes down a description of . A family is non-uniform when there is no such requirement: each can be chosen without a rule that connects it to .
What it counts
- Size : the number of gates. Some texts count the edges instead. With fan-in at most 2, each edge enters a gate and each gate has one or two incoming edges, so the number of edges is between the number of gates and twice that number.
- Depth: the number of edges on a longest path from an input node to an output node. This is the time of the circuit in the model of parallel computation, in which all gates of one layer work at the same time.
- Fan-in: bounded (2) or unbounded. A gate of fan-in is replaced by a tree of gates of fan-in 2, which has gates and depth . So the size grows to at most the number of edges of the original circuit, which is a factor of at most the largest fan-in in gates, and the depth is multiplied by at most , where is the largest fan-in. Measured in edges, the size changes by a constant factor. For a polynomial-size circuit, the size stays polynomial.
- The basis is the set of gate types. AND, OR and NOT is the standard one. With another finite complete basis of bounded fan-in, such as NAND alone, the size and the depth change by a constant factor, because each gate of one basis is a function of a bounded number of inputs and a circuit of constant size computes it in the other basis.
For a function on bits, is the least size of a circuit that computes . For a family, the size is a function of .
Relation to other models
- Turing machine. A Turing machine that decides in time gives a circuit family for of size polynomial in . This is the basis of the proof that and of the circuit value problem being complete for (Arora and Barak, Chapter 6). The other direction fails without uniformity.
- Non-uniformity gives more power. A family of circuits of size can decide an undecidable language. Let be the set of the numbers such that the -th Turing machine halts on the empty input, and let . This language is undecidable (see the halting problem). Leave out the empty string and take . Let be an AND of its inputs if (with gates), and the constant 0 otherwise (the two gates and ). The family decides with at most gates in . No algorithm needs to find the . This is why the uniformity condition is part of the definition of a circuit family that stands for an algorithm.
- P/poly. The class is the set of languages that have a family of circuits of polynomial size, with no uniformity. It contains , and the languages of are exactly those that have a polynomial-size family that is log-space uniform, or polynomial-time uniform (Arora and Barak, Chapter 6). See non-uniform computation and circuit complexity.
- Parallel time. Circuits of polynomial size and depth with bounded fan-in define the class . The same with unbounded fan-in defines . These classes are usually defined with log-space uniform families. Without uniformity one gets the non-uniform versions, which contain undecidable languages by the example above. See NC and AC0.
- Formulas. A circuit of depth and fan-in 2 becomes a formula by copying, for each gate, the subcircuit below it, once for each of its outgoing edges. The formula has at most nodes for each output, so depth gives a formula of polynomial size. Conversely, every formula of size can be rebalanced to depth (Spira, 1971), so the languages with polynomial-size formulas are those with circuits of depth .
- Branching programs are another non-uniform model. A branching program of size can be simulated by a circuit of depth , and branching programs of width 5 and polynomial size decide exactly the languages in (Barrington, 1989).
- Problems. Circuit-SAT asks if a given circuit has an input with output 1. It is NP-complete.
Known results in the model
Examples
The XOR of two bits is . It has 4 gates (an OR, an AND, a NOT and an AND) and depth 3. The table of the four inputs gives , , and .
The parity of bits is the XOR of all inputs. Combine the bits in pairs, then the results in pairs, and so on. This takes XOR blocks and levels. With the block above, the size is and the depth is . For the size is 28 and the depth is 9.
The AND of bits has gates and depth with fan-in 2, and 1 gate and depth 1 with unbounded fan-in.
Any function has a circuit of size . Write the function as an OR of the terms for the inputs with . Each term is an AND of literals. There are at most terms, each with at most AND gates. The OR of the terms uses at most gates. The NOT gates for the inputs add gates. If is identically 0, the gate computes it with 2 gates.
Addition of two -bit numbers has a circuit of size (the ripple-carry adder) and depth . A circuit of depth and size exists too (see the carry-lookahead adder and the Brent-Kung adder).
Non-example. A directed graph with a cycle, such as a gate that takes its own output as an input, is not a Boolean circuit. A cycle makes the value of a gate depend on itself, and the evaluation by induction fails.
Shannon's counting bound
Theorem 1 (Shannon, counting part). Let and . The number of functions that have a circuit over with at most gates, with fan-in at most 2, is less than . So fewer than a fraction of all functions have such a circuit. In particular, for each some function needs more than gates, and almost all of them do.
Proof. We count circuits of size at most with one output, and show that this number is less than . There are functions, and each function that has such a circuit is computed by at least one of the counted circuits.
Step 1: the circuit as a code. Take a circuit with at most gates. Add unused gates until it has exactly gates. This does not change the function. Order the gates so that each gate has its inputs among the input nodes and the earlier gates (a topological order). This is possible because the graph has no cycle. The circuit is described by these choices.
- The type of each gate , one of three: AND, OR, NOT.
- The two nodes that reads, each one among the nodes (the inputs and the gates). A NOT gate ignores the second.
- The output node, one among the nodes.
Step 2: the count. There are at most choices for one gate. So the number of descriptions is at most . Each circuit with at most gates has at least one description. So the number of functions with such a circuit is at most this number.
Step 3: the estimate. For we have ( at , and the left side doubles when grows by 1, while the right side grows by a factor less than 2). So , and since is an integer, . This gives . Then the number of descriptions is at most . Take . Then . Now gives , and for , and . So the sum is less than . Since ,
where the second inequality uses . So the number of descriptions is less than . Divide by to get the fraction. ∎
The proof counts only. It does not show one hard function. It shows that one exists, and that a function chosen at random is hard with probability above . This is an example of the counting argument.
What is known about the size. Shannon (1949) proved the counting lower bound for switching circuits: almost all functions of variables need about contacts. The bound is tight for the basis : every function of variables has a circuit of size (Lupanov, 1958). So the size of the hardest function is . Compare this with the simple bound above. The constants in Theorem 1 are not the best possible.
Explicit functions. The counting argument does not give a function with a short description that is hard. For an explicit function in NP, the best lower bounds on the size of circuits that are known are linear in . For restricted circuits, strong lower bounds are known: for each constant depth, a circuit with unbounded fan-in that computes parity needs exponential size (Furst, Saxe and Sipser 1984; Ajtai 1983; Hastad 1986). So parity is not in . See AC0. A proof that some language of NP is not in would show , and it is an open problem. See circuit complexity and the Karp-Lipton theorem.
References
- Sanjeev Arora and Boaz Barak, Computational Complexity: A Modern Approach, Chapter 6, Boolean circuits
- Michael Sipser, Introduction to the Theory of Computation, third edition, Section 9.3, Circuit complexity
- Claude E. Shannon, The synthesis of two-terminal switching circuits, Bell System Technical Journal 28(1) (1949), pages 59 to 98
- Philip M. Spira, On time-hardware complexity tradeoffs for Boolean functions, Proceedings of the 4th Hawaii Symposium on System Sciences, 1971
- David A. Barrington, Bounded-width polynomial-size branching programs recognize exactly those languages in NC1, Journal of Computer and System Sciences 38(1) (1989)
- Johan Hastad, Almost optimal lower bounds for small depth circuits, STOC 1986
- Merrick Furst, James B. Saxe and Michael Sipser, Parity, circuits, and the polynomial-time hierarchy, Mathematical Systems Theory 17 (1984)
- O. B. Lupanov, On a method of circuit synthesis, Izvestiya VUZ, Radiofizika 1 (1958)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag F2PHTH Edit this page History Report an error Markdown JSON