Boolean Circuits & Formulas

Still in preparation. Please check the references at the end of the document.

A boolean circuit is a directed acyclic graph (DAG) with the following properties:

  • each vertex corresponds to a gate, and there are 4 types of gates: input gates, AND gates, OR gates, and NOT gates.
    • an input gate has no incoming edges and it is labeled by a (boolean) variable.
    • an AND gate (also known as a conjunction, denoted by ) has two incoming edges, and outputs 1 iff both inputs are 1.
    • an OR gate (also known as a disjunction, denoted by ) has two incoming edges, and outputs 1 iff at least one input is 1.
    • a NOT gate (also known as a negation, denoted by ¬) has exactly one incoming edge, and outputs 1 iff the input is 0.

Each gate in the circuit computes a boolean function in the natural way. Given a boolean function f:{0,1}n{0,1} and a circuit C, we say that C computes f if there is a gate of C that computes f. In this case, we say that this gate is the output gate of C. (However, note that we could have multiple output gates in a circuit, in the event we want to compute functions over large codomains.)

For simplicity, when talking about boolean functions, given any circuit C, we will select one of the gates as the output gate and say that C computes the function computed by this gate.

A boolean formula is simply a boolean circuit where the underlying (undirected) graph is a tree.

There are two important complexity measures associated with boolean circuits and formulas:

  • the size of a circuit is the number of gates in the circuit.
  • the depth of a circuit is the length of the longest path from an input gate to an output gate.

Remark: given any boolean circuit C, the number of input gates is determined by the circuit (the gates with in-degree 0), and hence, if C has n input gates, then C computes a function fC:{0,1}n{0,1}. This is the function computed by the output gate of C.


Definition 1: A circuit family is a sequence of circuits C:={Cn}nN such that Cn has n input gates. We say that C decides a language L{0,1} if for every nN, we have xL{0,1}nfCn(x)=1.

The size of a circuit family C is the function sC:NN defined by sC(n):=size(Cn). The depth of a circuit family C is the function dC:NN defined by dC(n):=depth(Cn).

The circuit (size) complexity of a language L is the smallest size of a circuit family that decides L. The depth complexity of a language L is the smallest depth of a circuit family that decides L.


Shannon’s Theorem

A basic result in circuit complexity is Shannon’s Theorem, which states that any boolean function f:{0,1}n{0,1} can be computed by a boolean circuit (of size at most n(2n+1+1)).


Theorem 1 (Shannon’s Theorem): For every boolean function f:{0,1}n{0,1}, there exists a boolean circuit C of size at most n(2n+1+1) that computes f.


Proof: Note that any boolean function can be represented by its truth table, which has 2n rows, as in the following example for the parity function on 3 bits:

x1 x2 x3 (x1,x2,x3)
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1

Consider the following circuit C.

  • The input gates are the variables x1,,xn.
  • add NOT gates computing ¬x1,,¬xn.
  • to each row of the truth table for which the function value is 1, add an AND gate that takes as input the variables xi or ¬xi according to the value of f(x1,,xn) in that row.
  • add an OR gate that takes as input the outputs of the AND gates.

Note that the above construction has ANDs and ORs with more than 2 inputs, but we can always convert them to 2-input gates by adding additional gates (of the same kind). Note that an AND (equivalently OR) gate with k input wires is equivalent to a sequence of k1 input AND (equivalently OR) gates with 2 inputs each.

Thus, the size of the circuit C is upper bounded by the number of wires in the above circuit, which is at most n+2n(n1)+2n (the number of NOT gates, plus the number of AND gates, plus the number of OR gates).


Remark: Note that in the above proof, we constructed a DNF (disjunctive normal form) formula for the function f. One can similarly construct a CNF (conjunctive normal form) formula for f.

Acknowledgements & References

This lecture was based on these resources:

Previous
Next