Circuits and Lower Bounds

Almost every function needs an enormous circuit, yet nobody can name one that does. Count gates, find the smallest circuit for every small function, and watch parity defeat shallow circuits

Circuits and Lower Bounds

Forget Turing machines. A circuit is AND, OR and NOT gates wired together, and “how many gates does this function need?” is a question of pure combinatorics. Prove that some problem in NP needs more than polynomially many, and P ≠ NP follows. It looked like the easy road. It was not.

Most Functions Are Hard

Slide n and watch where the circuits run out. Then draw random functions, or tap the truth table to design your own, and see how many gates each one needs.

1.2 × 10⁷⁷
functions of 8 inputs
23
gates that some function must need, at least
32.0
Shannon’s rate 2n/n
< 2−141
share of functions that 11 gates can reach
With 8 inputs there are more functions than there are circuits with 22 gates, so at least one function cannot be computed with 22 or fewer. Nothing was said about which one. The crossing sits at 0.69 of Shannon’s 2n/n, and the two stay in step as n grows.

Both curves are on a log scale: the height is the number of binary digits in the count. Rose is the number of functions, 2 to the power 2n. Sky is the exact number of ways to write down a circuit with s gates when each gate may be any of the 16 two-input operations applied to two earlier wires; that is an upper bound on how many functions s gates can compute, with reuse of gates allowed. The amber mark is 2n/n.

Building formulas with 1 gate…10 of 65,536 functions · 0 pairs combined
Your function: tap a row to flip its output
…
gates in its smallest formula
…
of all functions are cheaper
…
gates for the hardest function
The search has not reached this function yet.
The search builds every formula with 1 gate, then 2, and so on, keeping the first formula found for each function.

The census counts formulas, not circuits: every gate’s output is used once, the gates are two-input AND and OR, and NOT is free. It is exact, because every pair of smaller formulas is combined. Circuits may reuse a gate’s output, so they can be smaller (see Circuit Golf below). Rows of the truth table are labelled by the inputs x₁x₂…; the amber frame and arrow mark your function’s bar. Majority of 4 means at least 3 of 4. The search stops at 4 inputs because 5 inputs have about 4 billion functions.

Go deeper:Shannon’s Counting Argument, and the Class P/poly

A function of n bits is a truth table with 2n rows, so there are 2 to the power 2n of them. A circuit with s gates is a short description: each gate names an operation and two earlier wires, about 2 log s bits apiece. There are simply not enough short descriptions to go round. Claude Shannon made this precise in 1949: almost every function of n variables needs a circuit of size about 2n/n. In 1958 Oleg Lupanov showed the count is tight: every function has a circuit of about that size.

The argument is non-constructive. It proves that hard functions exist, and even that nearly all functions are hard, without exhibiting a single one. The census in the demo finds the hard ones by exhaustion, which works for 4 inputs and is hopeless soon after. The difficulty in this lesson is the gap between “almost every function is hard” and “this particular function is hard”.

The link to P versus NP is the class P/poly: the problems that can be solved, for each input length n, by a circuit whose size is polynomial in n. A polynomial-time algorithm can be unrolled into such a family of circuits, so P ⊆ P/poly. To prove P ≠ NP it would therefore be enough to show that one problem in NP, satisfiability say, has no polynomial-size circuits. Nobody expects it to have them: Richard Karp and Richard Lipton proved in 1980 that if NP ⊆ P/poly then the polynomial hierarchy collapses to its second level, which most researchers consider unlikely. But that is a conditional theorem, not a lower bound.

Two measures appear on this page and they are not the same. In a formula each gate’s output is used once, so a shared subcomputation has to be built again each time it is needed. In a circuit an output may fan out to many gates. Circuits are never larger than formulas and can be much smaller. The counting chart counts circuits over all 16 two-input operations; the census counts formulas over AND and OR with free NOT.

Circuit Golf

Place gates and tap wires to build each target in as few gates as you can. Then slide n under the chart below to see how far proof has reached.

abPlace a gate to begin.
Place
True when exactly one of the two inputs is true. Press AND or OR to place a gate, then tap the two wires it should read. Par is 3.
aba ⊕ byours
000·
101·
011·
110·
0
gates placed
3
par: fewest gates in any circuit
3
fewest gates if no output may be reused

Only two-input gates count; NOT is free, drawn as an amber bubble on the input it negates. A gate reads the inputs and gates placed before it, and one gate’s output may feed many others: that reuse is what separates a circuit from a formula. The truth table compares each target with the complete gate that comes closest to it. Par comes from an exhaustive search of every circuit with fewer gates over the chosen gate set (it skips only circuits that repeat a wire, waste a gate, or list the same gates in another order). Up to 10 gates.

620
gates: the best proved bound, 3.1n
40,000
n2
8,000,000
n3
8.0 × 10⁵⁷
2n/n: what almost every function needs
YearProved lower boundProved by
19742nSchnorr
19772.5nPaul; Stockmeyer
19843nBlum
2016(3 + 1/86)nFind, Golovnev, Hirsch and Kulikov
20223.1nLi and Yang
Exhaustive search settled the small cases above. For large n nobody can search, and proof has to take over. The emerald line is everything proof has delivered in fifty years for an explicit function: a constant times n, with the constant creeping from 2 to 3.1. Showing that a problem in NP is outside P by this road needs a bound above n2, above n3, above every polynomial.

Emerald: the best proved lower bound on the number of gates for some explicit function of n inputs, for circuits whose gates may be any two-input operation, ignoring lower-order terms. Dashed: polynomials, for scale. The vertical axis is logarithmic, which is why the steps from 2n to 3.1n are almost invisible. The rose arrow points to where the counting argument puts almost every function, far above the chart.

Go deeper:Why Nobody Can Beat Par, and Why That Does Not Scale

For a function of three inputs, a lower bound can be proved by brute force. There are finitely many circuits with five gates; try them all, and if none computes parity then parity needs six. That is how every par in the demo was obtained, and it is a genuine proof. The pars are for circuits, with reuse allowed, over the gate set chosen: AND and OR with free NOT, or the same with XOR added.

The method dies quickly. The number of circuits with s gates grows roughly like s to the power 2s, and the number of functions to keep track of is doubly exponential in n. Exhaustive search has settled the exact circuit size of functions of a handful of inputs and will never reach n = 100.

For general n, proof has to replace search, and here the record is humbling. For circuits over all two-input gates, the best lower bound proved for any explicit function rose from 2n (Claus Schnorr, 1974) to 2.5n (Wolfgang Paul, 1977; Larry Stockmeyer, 1977), to 3n (Norbert Blum, 1984), and then stood still for three decades until Magnus Find, Alexander Golovnev, Edward Hirsch and Alexander Kulikov reached (3 + 1/86)n in 2016. Jiatu Li and Tianqi Yang improved it to 3.1n in 2022. Each of these is a linear bound. Counting says almost every function needs exponentially many gates, and yet for functions anyone can write down, including every problem in NP, nothing better than a small multiple of n is known.

This is why attention moved, in the 1980s, to restricted circuits: limit the depth or forbid negation, and real lower bounds can be proved. The third demo is about the most famous of them.

Parity against Shallow Circuits

Slide n to see parity’s depth-2 circuit double each time. Then press Play to fix variables at random, and compare what is left of a narrow DNF with what is left of parity.

8
terms: Parity
4
terms: Majority
4
terms: OR
1
terms: AND
The smallest DNF of Parity on 4 inputs: an OR of these 8 terms
x₁¬x₂¬x₃¬x₄¬x₁x₂¬x₃¬x₄¬x₁¬x₂x₃¬x₄x₁x₂x₃¬x₄¬x₁¬x₂¬x₃x₄x₁x₂¬x₃x₄x₁¬x₂x₃x₄¬x₁x₂x₃x₄

A DNF is a circuit of depth 2: one OR gate fed by AND gates, each AND reading as many inputs as it likes. The counts are exact, found by listing every prime implicant and searching for the smallest set of them that covers the function. Parity’s terms cannot merge: flip any one input and the answer changes, so each term has to name all n variables and covers a single row of the truth table.

6
variables left free
true
a term came true: the DNF is the constant 1
0
queries needed to evaluate what is left of the DNF
6
queries needed for what is left of parity
The DNF has collapsed to the constant 1: one term had every literal made true. Nothing is left to ask. Parity is still parity on all 6 free variables.
0 of 2,000 restrictions
0.00
mean depth left in the DNF
0.00
mean depth left in parity
0%
of restrictions make the DNF constant
3.2
free variables expected, pn
Depth at least tt = 1t = 2t = 3t = 4t = 5
DNF, measured0%0%0%0%0%
Lemma’s bound, (5pk)t—————
Parity, measured0%0%0%0%0%
With p = 0.20 and k = 3, 5pk = 3.00 is above 1, so the lemma promises nothing here; lower p below 0.067 to bring its bound into play. The collapse is plain to see all the same. Parity keeps a depth equal to the number of free variables in every single trial.

Sky is the DNF, rose is parity, indigo marks free variables. Decision-tree depth is the number of variables an adaptive questioner must read in the worst case to learn the function’s value; it is computed exactly here, by dynamic programming over every subcube. This is a simulation on 16 variables illustrating what the switching lemma says. It is not a proof, and the real argument needs n large and one round of restriction for each layer of the circuit.

What has been proved since, one restricted kind of circuit at a time
  1. AC⁰
    lower bound proved
    Constant depth; AND, OR and NOT gates with any number of inputs.
    Cannot compute parity with polynomially many gates.
    Furst, Saxe and Sipser, 1981; Ajtai, 1983; optimal bounds by Håstad, 1986
  2. Monotone circuits
    lower bound proved
    Any depth, but AND and OR gates only: no NOT.
    Clique needs more than polynomially many gates.
    Razborov, 1985
  3. AC⁰ with mod-p gates
    lower bound proved
    AC⁰ plus gates that count their inputs modulo a prime p.
    Cannot count modulo a different prime q.
    Razborov, 1987; Smolensky, 1987
  4. ACC⁰
    lower bound proved
    AC⁰ plus counting gates modulo any fixed numbers.
    Does not contain NEXP, nondeterministic exponential time: a class far larger than NP.
    Ryan Williams, 2011
  5. TC⁰
    open
    Constant depth with threshold (majority) gates.
    Almost nothing: no bound beyond polynomial is known for general threshold circuits, even of depth 2.
  6. P/poly
    open
    All circuits of polynomial size.
    A bound beyond polynomial for a problem in NP would prove P ≠ NP. The best known is 3.1n gates.
Go deeper:The Switching Lemma, and Where the Climb Stalled

AC⁰ is the class of problems solved by circuits of constant depth and polynomial size, built from NOT gates and AND and OR gates with any number of inputs. Such circuits can add two numbers. They cannot compute parity: Merrick Furst, James Saxe and Michael Sipser proved it in 1981 and Miklós Ajtai independently in 1983, and in 1986 Johan Håstad gave bounds that are essentially optimal.

Håstad’s tool is the switching lemma. Take a DNF whose terms each have at most k literals, and apply a random restriction that leaves each variable free with probability p. Then the probability that what remains needs a decision tree of depth t or more is at most (5pk)t, no matter how many terms the DNF has. A function with a shallow decision tree can be rewritten as a CNF with short clauses, so an OR of ANDs has been switched into an AND of ORs. In a layered circuit that lets two adjacent layers merge, and the depth drops by one.

Repeat for each layer. After d − 2 rounds a small circuit of depth d has become a circuit of depth 2 with narrow gates, on the variables still free. But parity restricted is still parity, and the first panel shows what parity demands at depth 2. Working through the numbers, a depth-d circuit for parity of n bits must have size exp(Ω(n1/(d−1))). The second panel is a simulation with 12 to 16 variables that illustrates the lemma’s statement; it is not a proof of anything.

The hope in the 1980s was to climb from AC⁰ one class at a time until the bounds reached P/poly. The ladder in the demo records how far that went. Progress slowed sharply around 1990, and the leading explanation is itself a theorem: the natural proofs barrier. See also: The Barriers.

Key Takeaways

  • Counting shows almost every function of n inputs needs about 2n/n gates (Shannon, 1949), without naming one that does.
  • A polynomial-time algorithm gives polynomial-size circuits, so a large enough circuit lower bound for a problem in NP would prove P ≠ NP.
  • For unrestricted circuits the best published bound for an explicit function is 3.1n gates (Li and Yang, 2022); a preprint by Mishra and Santhanam, posted in October 2026 and not yet reviewed, claims about 4n.
  • Restricted circuits can be beaten: parity is not in AC⁰, because random restrictions flatten shallow circuits and leave parity intact.

Spot a mistake or have an idea?

Search