CS 181 Lecture 10 -- Fall 2026, UCLA
Overview
Eli Jaffe develops the pumping lemma as a method for proving that languages such as majority, equal numbers of 0s and 1s, and unary strings of square length are not regular, then proves the lemma using repeated DFA states and a loop. He introduces the Myhill-Nerode equivalence relation and its basic state lower-bound result, applying it to show that counting ones modulo 1,000 requires 1,000 DFA states and that checking the 10th bit from the end requires at least 1,024.
Key takeaways
- The pumping lemma uses a pumping length p: every accepted string of length at least p must have a nonempty segment B within its first p symbols that can be repeated or removed without changing acceptance.
- For majority and equal-count languages, the challenge string 1^p0^p forces every permissible B to contain only 1s, so removing B breaks the required bit-count condition.
- The unary perfect-square language is not regular because pumping 1^p² once adds between 1 and p symbols, producing a length strictly between p² and (p + 1)².
- A DFA with p states processing at least p symbols visits at least p + 1 states including its initial state, so a repeated state creates the loop that proves the pumping lemma.
- Myhill-Nerode equivalence groups prefixes that produce identical outputs after every shared suffix; k pairwise inequivalent prefixes require at least k DFA states.
- Counting 1s modulo 1,000 needs exactly 1,000 DFA states, while recognizing whether the 10th bit from the end is 1 needs at least 1,024 states, as shown by all length-10 prefixes.
Chapters
- Eli Jaffe recaps the equivalence of regular expressions, NFAs, and DFAs: all compute exactly the regular languages.
- The lecture shifts from model equivalence to identifying which functions, including majority, finite automata cannot compute.
- The pumping lemma and the Myhill-Nerode theorem are introduced as tools for proving non-regularity and analyzing DFA size.
- Homework 2 grades have been released, exam 1 is expected to be graded by the following week, and homework 3 is due November 9 at 9:59 p.m.
- Jaffe describes the midcourse feedback form as a way to improve the course while it is still underway.
- The pumping lemma is framed as a shared property of every regular language, analogous to using monotonicity to rule out a set of Boolean gates.
- For a regular language, there is a pumping length p such that every accepted string x with length at least p can be split into ABC.
- The split must satisfy |B| > 0 and |AB| ≤ p, placing the pumpable substring B within the first p symbols.
- For every repetition count i ≥ 0, the string AB^iC must remain accepted.
- In Jaffe's challenge-game analogy, Alice first chooses p to support regularity.
- Bob then supplies any accepted string x of length at least p, and Alice must find a valid ABC split.
- To prove a language non-regular, the proof must work for every proposed p by constructing a string that defeats every permissible split.
- The majority function returns 1 when an input has at least as many 1s as 0s, and 0 otherwise.
- Assuming majority is regular gives a pumping length p by the pumping lemma.
- A counterexample string must be accepted, have length at least p, and lose acceptance under a permitted pump.
- An alternating string can fail as a challenge because a substring B containing one 1 and one 0 preserves the balance when removed or repeated.
- The stronger choice x = 1^p0^p is accepted by majority and places the first p symbols entirely in the block of 1s.
- Since |AB| ≤ p, every valid B consists only of one or more 1s; pumping down removes 1s and makes the number of 0s larger.
- For x = 1^p0^p, removing B changes the output from 1 to 0, contradicting the pumping lemma and proving majority is not regular.
- Jaffe emphasizes that the key creative step is designing a challenge string in terms of the arbitrary pumping length p.
- The next example defines EQ to accept strings with exactly as many 1s as 0s.
- Assume EQ is regular and let p be its pumping length.
- Choose x = 1^p0^p, an accepted string with equal counts of each bit.
- Because B lies within the first p symbols, it contains only 1s; deleting or adding copies of B breaks the balance, so EQ is not regular.
- The language L contains strings of only 1s whose lengths are perfect squares, such as 1, 4, 9, 16, and 25.
- Assuming regularity, choose the accepted string x = 1^(p²); the pumping constraints imply 0 < |B| ≤ p.
- Pumping B once produces length p² + |B|, which is greater than p² but less than (p + 1)², so the result is not a square length.
- The majority, equality, and square-length examples all use proof by contradiction: assume regularity, apply the pumping lemma, and force a violation.
- Jaffe transitions from practicing the lemma to proving why every regular language must satisfy it.
- The proof reduces the claim to a structural fact about a DFA processing an input longer than its state set.
- Assume a DFA computes the language and choose p equal to the DFA's number of states.
- For an accepted input x of length n ≥ p, track the sequence of states visited after reading each symbol.
- The final state is accepting, and the first p input symbols generate p + 1 visited states when the initial state is included.
- A DFA with p states cannot assign distinct states to all p + 1 positions reached while reading the first p symbols.
- By the pigeonhole principle, some states S_i and S_j repeat, with i < j.
- The repeated state identifies a nonempty segment of input that returns the DFA to the same state.
- Split the input into A, B, and C at the repeated-state positions: B labels the path from S_i back to S_j.
- Because S_i = S_j, the DFA can skip B or traverse it any number of times and then process C as before.
- The loop has positive length, and it occurs within the first p symbols, giving |B| > 0 and |AB| ≤ p.
- During the break discussion, Jaffe clarifies that reading p symbols visits p + 1 states because the initial state counts as the first visit.
- The square-length contradiction depends on starting with p² ones and adding at most p more when B is pumped once.
- Since p² + p < (p + 1)², the pumped string cannot reach the next perfect-square length.
- A non-regularity proof must use a general pumping length p, not a convenient fixed value such as 3.
- The proof's central design task is choosing an accepted challenge string that prevents every valid B from preserving membership.
- Trying a candidate and seeing how an accepting split could succeed helps reveal how to improve the construction.
- For a function f, strings x and y are equivalent when f(xz) = f(yz) for every appended string z.
- Choosing z as the empty string shows equivalent strings must already have the same output, though later suffixes may change both outputs together.
- Strings are inequivalent if at least one suffix z makes their resulting outputs differ.
- Consider f that accepts when the number of 1s is 0 modulo 3.
- The strings 11 and 111111 are equivalent because both contain a number of 1s congruent to 0 modulo 3.
- Appending the same suffix changes their modulo-3 count in the same way, so their outputs always remain equal.
- If a function has k strings that are pairwise inequivalent under its suffix relation, every DFA computing it needs at least k states.
- The result connects distinguishable input prefixes to states: a DFA cannot merge prefixes that some suffix makes behave differently.
- Unlike the pumping lemma's standard use, this statement directly proves lower bounds on the number of DFA states.
- The function accepts when its input contains a number of 1s divisible by 1,000; a cycle of 1,000 states tracks the count modulo 1,000.
- Use the 1,000 prefixes 1^1 through 1^1000 as candidate pairwise inequivalent strings.
- For i < j, appending 1^(1000 - i) makes 1^i reach a multiple of 1,000 while 1^j does not, distinguishing the prefixes.
- The lower bound matches the 1,000-state construction, proving that this DFA size is optimal.
- The function f10 returns 1 exactly when the 10th bit from the end is 1.
- An NFA guesses where the final 10-bit segment begins, then checks the bit and counts the remaining positions.
- The general subset construction yields 2^11 = 2,048 possible DFA states from the NFA's 11 states.
- Take every binary string of length 10, giving 2^10 = 1,024 candidate prefixes.
- Any two distinct prefixes differ at some position k counted from the right; appending 10 - k zeros moves that differing bit into the 10th-from-end position.
- The resulting outputs of f10 differ, so the prefixes are pairwise inequivalent and every DFA needs at least 1,024 states.
- The lower bound shows the subset construction's 2,048-state result can be improved by a factor of two, but not below 1,024.
- If a function has arbitrarily large sets of pairwise inequivalent prefixes, no fixed finite-state DFA can compute it.
- For majority, prefixes 0^i and 0^j with i < j are distinguished by appending 1^i.
- The string 0^i1^i is accepted by majority, but 0^j1^i is rejected because it has more 0s than 1s.
- Jaffe closes by pointing ahead to continuing the Myhill-Nerode theorem, including its proof, in the next lecture.
Transcript excerpt
0:02 Okey dokie. Uh hello everybody. Welcome back. Um maybe some other people will filter in. If not, it'll be a nice relaxed intimate lecture. Um just to recontextualize us since Monday, where are we at? We are mid exploration of finite automatha and reg regular expressions which now we understand are basically the same thing. Actually we're approaching the tail end of our exploration. We finally established that regular expressions, NFAs, DFAS can all compute the exact same class of functions which we call regular
0:51 functions or regular languages. uh we found via that equivalence some somewhat surprising efficient practical algorithms for computing regular expressions and we saw some applications of that in the DNA sequencing world. Uh and then the last thing that we did last class was we finally asked this big elephant in the room question of well okay what can we actually compute we've proven this equivalency now what functions are on the table and we provided some motivation towards that end we brought up the majority function and we said seems like this is not going to work for DFAS NFAs regular expressions what have you and I teased you guys towards a proof of that fact
1:39 via this magical statement called the pumping lema. And we saw the statement of the pumping lema and that was about it. So today we are going to do a little bit more work towards understanding this pumping lema. see some examples of it in action, how we use it, and then once we get a feel for how it works, look at a surprisingly simple proof that this is actually true. And then we will use that to effectively prove instead of just have this loose motivational argument that there are certain functions that are not regular
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.