CS181 Lecture 2 -- Fall 2026, UCLA
Overview
Eli Jaffe establishes that Boolean circuits using AND, OR, and NOT have the same computational power as circuits made solely of NAND gates, then proves that every finite Boolean function has a circuit. For an n-bit input and one-bit output, the truth-table construction uses O(n·2^n) gates; the lecture also contrasts this general upper bound with more efficient circuits, circuit-size lower bounds, and the idea of encoding circuits as data.
Key takeaways
- NAND is functionally complete: NOT, AND, and OR can all be constructed from NAND gates, so NAND circuits compute exactly the same functions as Boolean circuits.
- XOR-2 circuits are strictly weaker than Boolean circuits because XOR gates can implement parity but cannot implement AND, regardless of how many XOR gates are available.
- For any n-input, one-output Boolean function, testing each satisfying input with an E_α indicator circuit and ORing the results gives a circuit of O(n·2^n) gates.
- The truth-table construction can be highly inefficient: it gives an exponential-size construction for OR, even though a chain of n−1 OR gates computes that function.
- Claude Shannon's 1949 lower-bound result shows that some n-input Boolean functions need on the order of 2^n/n gates, matching the scale of the improved universal upper bound.
- Encoding circuits as bit-string data makes universal circuits possible: a fixed computational system can simulate circuits supplied as input rather than having each circuit preinstalled.
Chapters
- Eli Jaffe recaps encoding finite data as bit strings and defining computation with Boolean circuits.
- Homework 1 is available on Gradescope and is due Monday, October 12, at 9:59 p.m.
- The lecture introduces NAND circuits, model equivalence, and a construction for computing every Boolean function.
- A Boolean circuit has n inputs, m outputs, and S gates, with AND, OR, and NOT as its allowed gate types.
- NAND is presented as an alternative primitive gate, prompting the question of whether it can match Boolean circuits' computational power.
- For input bits A and B, NAND(A, B) = NOT(A AND B).
- The NAND gate is drawn like an AND gate with an output bubble indicating negation.
- An N-input, M-output, S-gate NAND circuit is a directed acyclic graph whose computational gates are all NAND gates.
- Choosing M gate nodes as outputs defines the circuit's output bits.
- A circuit computes a function when its outputs match that function on every input, distinguishing implementation from specification.
- Jaffe claims that a function is computable by a Boolean circuit if and only if it is computable by a NAND circuit.
- The proof must establish both directions: simulate NAND gates with Boolean gates and simulate Boolean gates with NAND gates.
- The claim concerns which functions can be computed, not whether the two circuit types have identical sizes.
- A Boolean circuit implements NAND(A, B) by feeding A and B into an AND gate and negating its output.
- Replacing every NAND gate this way converts a NAND circuit into a Boolean circuit.
- NOT A is computed with one NAND gate by connecting A to both of its inputs.
- AND(A, B) is computed by sending NAND(A, B) through a NAND-based NOT gate.
- The constructions show that NAND can reproduce two of the three Boolean circuit primitives.
- The OR construction negates A and B separately, then feeds those values into a NAND gate.
- By De Morgan's law, NAND(NOT A, NOT B) equals A OR B.
- Replacing each Boolean gate with its NAND construction uses at most three NAND gates per original gate, establishing equivalence in computational power.
- An XOR-2 gate outputs 1 exactly when one of its two input bits is 1, and Boolean gates can implement XOR-2.
- The reverse simulation fails: XOR-2 circuits cannot implement AND, even with arbitrarily many XOR gates.
- Thus XOR-2 circuits are strictly weaker than Boolean circuits, unlike NAND circuits.
- The universality theorem states that every function from n input bits to m output bits can be computed by a Boolean circuit.
- The stated general size bound is O(m·n·2^n), while the lecture focuses its proof on a single output bit.
- For one output bit, the truth-table construction will use O(n·2^n) gates.
- An n-bit function has 2^n possible input strings, each with a specified output in its truth table.
- The construction identifies which input strings produce output 1, then combines tests for those strings.
- This general method is deliberately simple and may be much less efficient than a specialized circuit.
- For each n-bit string α, the indicator function E_α(x) outputs 1 exactly when x = α and 0 otherwise.
- For example, E_11(x₀, x₁) is 1 only when both input bits are 1.
- These equality tests will serve as subcircuits for reconstructing arbitrary truth tables.
- E_11…1(x) is computed by ANDing all n input bits, so the output is 1 only when every bit is 1.
- A chain of two-input AND gates implements the n-input test using n−1 gates.
- This chained construction avoids assuming a single gate can accept n inputs.
- To recognize an arbitrary α, negate each input bit whose corresponding bit in α is 0, then AND all adjusted bits.
- The resulting E_α circuit uses at most n−1 AND gates and n NOT gates, for a total of 2n−1 gates.
- The same pattern works for every n-bit target string.
- The satisfying set SAT(f) contains exactly the input strings α for which f(α) = 1.
- A function can be represented as the OR of E_α(x) over all α in SAT(f).
- This translates the truth table into equality-test subcircuits combined with OR gates.
- If SAT(f) contains k strings, the construction uses k indicator circuits and k−1 OR gates.
- Since k is at most 2^n and each indicator uses at most 2n−1 gates, the total is O(n·2^n).
- Repeating the construction for each output bit gives the lecture's general multi-output bound.
- For n-input OR, nearly all 2^n strings satisfy the function, so the general construction creates an indicator circuit for each one.
- A direct chain of OR gates computes the same function with only n−1 gates.
- Finding the smallest circuit for a specified function is called the minimum circuit size problem, abbreviated MCS.
- Jaffe notes an unproved improvement: every n-input, one-output Boolean function has a circuit of size O(2^n/n).
- This improves on the earlier O(n·2^n) construction but remains exponential in n.
- The lecture distinguishes upper bounds, which guarantee a circuit no larger than a stated size, from lower bounds on hard functions.
- A 1949 result attributed to Claude Shannon establishes that some Boolean functions require exponentially many gates, on the order of 2^n/n.
- Together with the improved upper bound, this gives matching exponential scale up to constant factors.
- Jaffe connects hard-to-compute functions to cryptography, where one-way functions provide a basis for security.
- A circuit can itself be encoded as a Boolean string, extending the earlier idea that finite data has bit-string representations.
- Universal circuits can take a program description as input and simulate the described computation, much like a general-purpose CPU runs downloaded software.
- Jaffe identifies this model-as-data perspective as a foundation for upcoming discussions of Shannon's theorem, universal circuits, and Turing machines.
Transcript excerpt
0:03 Thank you. All right. Good to see everybody. Welcome to hell. It is really hot here. Uh I tried to fix the thermostat and it's literally popped out of the wall from everybody else trying to fix it over the course of the day. So, please bear with me. Um but welcome to lecture three, week two. um today. So a little bit of recap last class what did we do? We finished our talk about data representation. So we decided that everything we sort of reasonably care about encoding can be encoded as a finding a bit string so that from now on we don't have to worry about what format our data is going to be in. just know that it can be
0:50 represented as some bit string and we can figure out what it is other than the obvious exception of like real numbers which we showed we can't but we're going to be operating over only like finite data so that's fine. Um we also talked about what it means to solve a problem in the sense of designing a circuit that computes the functionality and we talked about the details of the boolean circuit model. So what formally it means to represent a boolean circuit. How do we arrange the gates? What do they mean? Uh and today we are going to talk about our first equivalence of models. So we're going to introduce a new circuit model using different kinds of gates and we are going to do our first example of showing that two computational models equivalent and that
1:40 is going to be a recurring theme in this class. We're going to be exploring a lot of different computational models and this act of showing well everything that you can compute in this one you can also
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Eli Jaffe.