CS181 Lecture 5 -- Fall 2026, UCLA
Overview
Eli Jaffe closes the circuit unit by reviewing Shannon’s lower bound, which shows that some functions on n bits require at least 2^n/(24n) gates, and introduces a meta-evaluator that can simulate circuits with O(S log S) gates. He then identifies circuits’ central limitation, their fixed input length, and begins the DFA unit with a formal definition and examples for parity, counting modulo 3, checking the last bit, comparing the first and last bits, and detecting alternating bits.
Key takeaways
- Shannon’s counting argument shows that some Boolean functions on n bits require at least 2^n/(24n) NAND gates, while a sharper general upper bound of 10·2^n/n places those hard functions at order 2^n/n.
- An efficient universal circuit can simulate circuits of size S with O(S log S) gates, adding only logarithmic overhead under the lecture’s assumption that S exceeds the input count.
- Circuits have fixed input width, whereas a DFA can process strings of arbitrary length by reading one bit at a time and updating a finite state.
- A DFA is specified by a transition function T(state, bit) and an accepting-state set; changing the accepting set can change the computed predicate without changing the transitions.
- State meanings provide a design method: track parity with two states, count ones modulo 3 with three states, or remember the latest bit with two states.
- A dead state captures irreversible failure: once an alternating-bits DFA reads 00 or 11, no later bits can make the whole string alternating.
Chapters
- Eli Jaffe opens CS181 Lecture 5 by checking the microphone, recording, and HDMI connection.
- He begins reviewing circuits as the course’s first model of computation and recalls that Shannon’s theorem establishes exponential circuit lower bounds.
- A technical interruption pauses the lecture; the discussion resumes at about 14:36.
- The reviewed theorem says some functions on n input bits require at least 2^n/(24n) NAND gates.
- The proof encodes circuits with n inputs, m outputs, and s gates as bit strings of length O((n+s) log(n+s)).
- Counting those encodings against the much larger number of Boolean functions shows that some functions cannot have small circuits.
- A truth-table construction gives every n-bit Boolean function a circuit using at most 2n·2^n gates.
- A sharper stated upper bound is 10·2^n/n gates, while Shannon’s theorem gives a lower bound of 2^n/(24n) for some functions.
- Both bounds have order 2^n/n, so the hardest functions have a tightly bounded exponential circuit size.
- Jaffe recalls an encoding E for circuits with n inputs, m outputs, and s gates, bounded by 12(n+s) log₂(n+s) bits.
- The encoding describes circuit dimensions, wire labels, and the inputs to each NAND gate.
- A meta-evaluator will take that circuit description together with an n-bit input and return the circuit’s m-bit output.
- The evaluator is written evalₙ,ₘ,ₛ and takes a circuit encoding plus an input x of length n.
- For a valid description, evalₙ,ₘ,ₛ must return C(x); for an invalid description, the specified fallback is an all-zero output.
- The evaluator is itself a Boolean function, so the earlier result that every Boolean function has a circuit proves that an evaluator circuit exists.
- A more efficient universal-circuit result gives a NAND circuit for evalₙ,ₘ,ₛ of size O(S log S), assuming the emulated circuit’s gate count S exceeds its input count.
- The logarithmic overhead lets one circuit simulate any circuit up to the supported size.
- For circuits of up to 2^20 gates, the example meta-evaluator has about 20·2^20 gates; the lecture notes that the textbook gives an O(S log² S) construction.
- A universal circuit separates a program’s description from the hardware that evaluates it, enabling programmable hardware.
- Jaffe relates ordinary code to a text description supplied to an evaluator, rather than a dedicated circuit for every program.
- He also names cryptography as an application of meta-evaluation.
- Boolean circuits can be physically implemented using devices such as transistors to realize AND, OR, and NOT gates.
- Circuits are universal for fixed-size Boolean functions, and some functions require exponentially many gates.
- Efficient meta-evaluators provide a way to simulate described circuits; Jaffe presents these properties as benchmarks for later computation models.
- The physical extended Church-Turing thesis informally claims that a computation using S physical resources can be represented by a Boolean circuit of about S gates.
- Jaffe emphasizes that “physical resources” makes the statement non-mathematical and that it is a thesis, not a theorem.
- He notes that quantum computers challenge the thesis as stated, while adding quantum gates changes the model being compared.
- A circuit has a fixed, or bounded, number of input wires; supporting a longer input requires a different circuit.
- The arbitrary-length XOR function outputs 1 when the input contains an odd number of ones and 0 otherwise.
- A short loop can compute XOR for an input of any length, motivating a model that processes input bits sequentially.
- Jaffe introduces deterministic finite automata, also called finite-state machines, as the next model of computation.
- The XOR DFA uses two states to track whether the number of ones read so far is even or odd.
- It reads each bit once, transitions between states, and determines its output from the state reached at the end.
- A DFA over the binary alphabet has C states labeled 0 through C−1.
- Its transition function T maps a current state and an input bit to a next state.
- A set S of accepting states determines the output: the DFA returns 1 if its final state is in S and 0 otherwise.
- Evaluation starts in state 0 and processes input x from x₀ through xₗₑₙ₍ₓ₎₋₁.
- At each step, the next state is T(current state, current input bit), so the DFA needs only its state and the next bit.
- A DFA computes a function when its output agrees with that function for every input string.
- For the two-state XOR DFA, reading 0 leaves the current state unchanged and reading 1 switches between states 0 and 1.
- State 0 represents an even number of ones so far; state 1 represents an odd number.
- The accepting set contains state 1, giving a two-state implementation of parity over strings of any length.
- A three-state DFA cycles through states 0, 1, and 2 whenever it reads a 1, while a 0 leaves the state unchanged.
- Each state records the number of ones seen so far modulo 3.
- With state 0 as the only accepting state, the DFA outputs 1 exactly when the number of ones is divisible by 3.
- The same three-state transition structure can compute a different predicate without changing any arrows.
- To accept strings whose number of ones is 2 modulo 3, the accepting set becomes the singleton containing state 2.
- This illustrates how the interpretation of states and the choice of accepting states jointly specify the output.
- The two states represent whether the most recently read bit is 0 or 1.
- On either input bit, the DFA moves to the state matching that bit, so the final state records the last bit.
- State 1 is accepting, which makes the DFA return 1 exactly for strings ending in 1.
- The first-and-last-bit predicate requires the DFA to retain information about the first bit while continuing to read the string.
- The construction branches after reading the first bit, with separate state groups for inputs that began with 0 or 1.
- Within each branch, states track the latest bit, and the accepting state is chosen to match the remembered first bit.
- The first-and-last-bit DFA should accept a one-bit string because its first and last bits are the same.
- Jaffe recommends checking small inputs to catch mistakes in how the branches and accepting states are drawn.
- Under the lecture’s convention, the empty string ε is included in {0,1}* and is treated as having matching first and last bits, so the start state is also accepting.
- The alternating-bits DFA tracks whether the last bit was 0 or 1, and sends repeated adjacent bits such as 00 or 11 to a dead state.
- Once reached, the dead state loops on both input bits because no continuation can repair an already repeated pair.
- The states for valid alternating prefixes are accepting; the empty string is also accepted under the stated convention.
- DFA processing is one-pass and stores information only through its finite state, which makes some input patterns require many states.
- Jaffe previews questions about whether DFAs can represent every function and how the required number of states changes.
- The next lecture will examine nondeterministic finite automata and use nondeterminism to study DFA properties.
Transcript excerpt
0:05 Okay. Is my mic on? Can you people hear me? >> Yeah. >> All right. Welcome back. Attendance is waning. People are getting picked off like a horror movie. Please remind your friends that the videos are a luxury and not something to be relied on. But for those of you who showed up, thank you for being here. Um we are going to be continuing today from where we left off. Uh and today is exciting because we are going to wrap up our discussion of circuits. So circuits were our first model of computation. We are going to So maybe as a reminder, right, last class what did we do?
0:57 Oh, you don't see anything. Right. That's because I didn't plug in the HDMI cable. >> Did you start the >> I did start the recording. Thank you for reminding me. Please remind me every time. Also I it didn't make the big recording started announcements uh because I hadn't turned on my volume yet. But okay. That looks better. Uh last class uh what did we do? Well, we talked about the limitations of circuits. So this was uh our big theorem, Shannon's lower bound theorem. We talked about how there are some functions that take an exponential amount of gates to actually compute, which is pretty bad. We don't want to use an exponential
1:44 amount of work to compute functions, right? Uh so what did we say? We said some functions require lots of gate >> Okay.
14:38 I think we should be back. Voila. Okay. So, hopefully everybody had an awesome uh 10-minute long discussion. So, while we were facing our technical difficulties, uh as a reminder, we were in the middle of our recap. Last class we did limitations of circuits uh and to talk about that lower bound, we talked
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.