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
For simplicity, when talking about boolean functions, given any circuit
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
Definition 1: A circuit family is a sequence of circuits
The size of a circuit family
The circuit (size) complexity of a language
Shannon’s Theorem
A basic result in circuit complexity is Shannon’s Theorem, which states that any boolean function
Theorem 1 (Shannon’s Theorem): For every boolean function
Proof: Note that any boolean function can be represented by its truth table, which has
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
- The input gates are the variables
. - add NOT gates computing
. - to each row of the truth table for which the function value is
, add an AND gate that takes as input the variables or according to the value of 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
Thus, the size of the circuit
Remark: Note that in the above proof, we constructed a DNF (disjunctive normal form) formula for the function
Acknowledgements & References
This lecture was based on these resources:
- Lecture notes by Prof. Eric Blais.
- [S13, Chapter 9.3]