Lesson 18 supplies the tool for proving that a language has no context-free grammar. It shows how Chomsky normal form bounds the height of a parse tree, so that a long string forces a repeated variable somewhere on a root-to-leaf path, then gives the five-piece statement with its three conditions and the crucial difference from the regular case: the short window may sit anywhere rather than at the front. It proves the lemma and points out where minimality of the parse tree is used, then works proofs for three matched counts, a block written twice, and nested inequalities, with explicit case analysis over the window positions. It covers closure arguments using a regular helper and why a context-free helper proves nothing, and ends by comparing the two pumping lemmas.
Subject: Theory of Computation · 114 slides · symbolic lesson
Open the interactive version of this deck · Homework for this lesson
Title
Theory of Computation · Lesson 18
A long string forces a tall parse tree, a tall tree repeats a variable, and a repeated variable can be pumped — in two places at once.
Objectives
Lessons 13 to 17 built two equivalent ways to show a language is context-free. Neither can show one is not. This lesson supplies the missing tool. By the end you can:
Warm-up
Discussion prompt
Before we open The Pumping Lemma for CFLs: without looking back, what was the main idea of Equivalence of PDAs & CFGs, and what could you do by the end of it that you could not do before?
Hint: One sentence for the idea, one for the skill. If the second one is blank, that is the part to revisit.
Answer:
Lesson 17 proves that the generator and the recognizer describe the same class. It starts from the key observation that a leftmost sentential form splits into matched input and stack contents, then gives the three-state grammar-to-machine construction with its expansion and matching transitions and the push-order trap, the correctness proof by invariant, and why the stack forces leftmost derivations. It shows how to recover a parse tree from a computation, then gives the triple-variable encoding for the reverse direction with its never-dips-below condition, machine normalization, and the three rule schemas. It ends with the consequences: choosing whichever formalism makes a closure proof easier, cubic-time parsing via Chomsky normal form, and what is still missing before Lesson 18.
Section
Section 1
Concept
Two formalisms now prove membership by exhibition: write a grammar, or build a machine. Neither can prove non-membership.
Showing no grammar exists means ruling out infinitely many grammars, and no amount of failed attempts settles it. A universal claim needs a property forced on every context-free language.
\[ \text{not context-free} : \lnot\exists G \equiv \forall G \lnot(\cdots) \]
This is exactly the situation Lesson 10 faced for the regular languages, and the solution has the same shape — but the mechanism forcing the property is different.
Counterexample
Discussion prompt
Two formalisms now prove membership by exhibition: write a grammar, or build a machine. Neither can prove non-membership.
That is stated as though it always holds. Do one of two things: produce a case where it fails, or say precisely what rules such a case out. "It just does" is not on the menu.
Hint: Hunt at the extremes first — zero, one, negative, empty, equal. If every extreme survives, the reason they survive is the proof.
Answer:
Showing no grammar exists means ruling out infinitely many grammars, and no amount of failed attempts settles it. A universal claim needs a property forced on every context-free language.
Intuition
For finite automata the pigeonhole applied to states along a run. Here there are no states to count, so something else must be bounded.
Chomsky normal form supplies it. Every rule has at most two symbols on the right, so a parse tree is binary — and a binary tree with many leaves must be tall.
\[ |w| \le 2^{h} \;\Rightarrow\; h \ge \log_2|w| \]
A tall tree has a long root-to-leaf path, and a long path through finitely many variables must repeat one. That repetition is what gets pumped.
Analogy
Discussion prompt
Explain Where the forced property comes from now by analogy to something with no Theory of Computation in it at all — a queue, a recipe, a map, a bank balance, whatever fits. Then say where your analogy breaks.
Hint: An analogy that never breaks is not an analogy, it is the same idea wearing a hat. Find the seam — that is the part that is actually new.
Answer:
For finite automata the pigeonhole applied to states along a run. Here there are no states to count, so something else must be bounded.
Concept
Suppose some variable appears twice on one root-to-leaf path. Then one occurrence sits inside the subtree of the other.
The outer subtree derives some string; the inner subtree derives a shorter one. Because both are rooted at the same variable, either subtree may be substituted for the other.
\[ A \Longrightarrow^{*} vAy \qquad\text{and}\qquad A \Longrightarrow^{*} x \]
Repeating the outer derivation any number of times gives a family of strings, all in the language. That is the pumping, and note it inserts material in two places at once — which is the essential difference from Lesson 10.
\[ A \Longrightarrow^{*} v^{i}xy^{i} \]
Explain it
Discussion prompt
Explain What a repeated variable gives you to a student a year behind you. No notation, no jargon they have not met — and it still has to be true.
Hint: If your explanation needs a symbol they have never seen, you are describing the notation rather than the idea.
Answer:
Suppose some variable appears twice on one root-to-leaf path. Then one occurrence sits inside the subtree of the other.
Ranking
Put in order
Put the moves of Watch a repeated variable pump into the order they have to happen.
Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. Applying the recursive rule twice puts the start variable inside its own subtree.
Worked example
Make the mechanism concrete on a grammar where the repetition is visible.
\[ S \to aSb \;\mid\; ab \]
Derive a string with a repeated variable
Why: Applying the recursive rule twice puts the start variable inside its own subtree.
\[ S \Longrightarrow aSb \Longrightarrow aaSbb \Longrightarrow aaabbb \]
Identify the two occurrences
Why: The outer one is the root; the inner one is two levels down. Between them the derivation produced one a on the left and one b on the right.
\[ S \Longrightarrow^{*} a\,S\,b \]
Substitute the inner subtree for the outer
Why: Replacing the outer occurrence's subtree by the inner one removes one a and one b, giving a shorter member.
\[ aabb \in L \]
Substitute the outer for the inner
Why: Repeating the outer stretch inside itself adds one a and one b, giving a longer member.
\[ aaaabbbb \in L \]
Verify every substitution stays in the language
Why: Each repetition adds exactly one a on the left and one b on the right, so the counts stay equal and every result is a member. The two insertion points move together, which is precisely the structure the lemma will describe.
\[ a^{n}b^{n} \in L \;\text{ for every } n \ge 1 \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Watch a repeated variable pump", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Each repetition adds exactly one a on the left and one b on the right, so the counts stay equal and every result is a member. The two insertion points move together, which is precisely the structure the lemma will describe.
Concept
The single most important structural difference from the regular case, and the source of every complication ahead.
| Regular | Context-free | |
|---|---|---|
| string splits into | three pieces | five pieces |
| pumped pieces | one, in the middle | two, on either side of a centre |
| what forces the repeat | a repeated state in a run | a repeated variable on a path |
| case analysis needed | usually none | usually two or three cases |
The two pumped pieces must be inserted together and in matching numbers. That coupling is exactly what a stack can enforce, and it is why the lemma cannot rule out matched counts.
Comparison
Comparison matrix
From Two insertion points, not one: refill the Regular column from what you know. The rest of the table is as it appeared.
| Regular | Context-free | |
|---|---|---|
| string splits into | three pieces | five pieces |
| pumped pieces | one, in the middle | two, on either side of a centre |
| what forces the repeat | a repeated state in a run | a repeated variable on a path |
| case analysis needed | usually none | usually two or three cases |
Intuition
Knowing in advance which languages are vulnerable saves a great deal of wasted effort.
Pumping inserts material at two points. A language whose condition ties two positions together survives, because the two insertions can maintain the tie. A language tying three positions together does not.
| Language | Positions tied | Context-free? |
|---|---|---|
| matched counts | two | yes |
| palindromes | two | yes |
| three matched counts | three | no |
| a block written twice | two, but in the same order | no |
Discrimination
Sort into buckets
Sort these by Positions tied, from memory, without looking back at What the lemma can and cannot rule out. Telling them apart on the spot is the skill; the table is only where the answer happens to be written down.
Concept
The bound from Lesson 15 is the engine of this lemma, so it is worth having in front of you in the form the proof uses.
In Chomsky normal form every internal node has at most two children, so a tree of height h yields at most two to the h symbols.
\[ |\mathrm{yield}(T)| \le 2^{h} \]
Contrapositively, a long yield forces a tall tree. And a tall tree has a long root-to-leaf path, which is where the pigeonhole is applied.
\[ |w| > 2^{h} \;\Rightarrow\; \text{height} > h \]
Step zero
Discussion prompt
Trace the bound from string length to repeated variable — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.
Hint: It starts with: Fix a grammar in normal form
Answer:
Worked example
Follow the chain of implications once, so the choice of pumping length later makes sense.
Fix a grammar in normal form
Why: Say it has four variables. Every parse tree it produces is binary.
\[ |V| = 4 \]
Choose a string long enough
Why: Take a string of at least thirty-two symbols, which exceeds two raised to the variable count.
\[ |w| \ge 2^{5} = 32 \]
Force the height
Why: A binary tree of height four yields at most sixteen symbols, so this tree has height at least five.
Apply the pigeonhole to a longest path
Why: That path has at least five internal nodes, each labelled by one of four variables, so some variable appears twice.
\[ 5 > 4 \;\Rightarrow\; \text{a variable repeats} \]
Verify the choice of pumping length was forced
Why: The argument needed the yield to exceed two raised to the variable count, which is exactly why the proof sets the pumping length to two raised to the variable count plus one. Any smaller value would leave short trees possible and no repeat guaranteed.
\[ p = 2^{|V|+1} \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Trace the bound from string length to repeated variable", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: The argument needed the yield to exceed two raised to the variable count, which is exactly why the proof sets the pumping length to two raised to the variable count plus one. Any smaller value would leave short trees possible and no repeat guaranteed.
Intuition
A variable appearing twice in a tree is not enough. The two occurrences must lie on a single root-to-leaf path, and that requirement does real work.
Only then does one occurrence sit inside the other's subtree, so that one subtree can be substituted for the other. Two occurrences in sibling subtrees are unrelated and nothing can be swapped.
\[ \text{one inside the other} \;\Rightarrow\; \text{substitutable} \]
That is why the proof examines a longest path rather than counting occurrences across the whole tree. The pigeonhole is applied along the path, not to the tree.
Ranking
Put in order
These are the steps of Deciding whether this tool applies, scrambled. Put them back in order before the next slide shows you.
Why: This is the order the recipe itself gives. Recalling the sequence without the slide in front of you is the difference between recognising the method and being able to run it — most of what goes wrong in practice is a step done out of turn.
Pattern
Classify before proving, exactly as in Lesson 11.
The second and third lines cover almost every standard example, and both are visible from the language's description without any proof.
Elimination
Eliminate the wrong options
Why does a sufficiently long string force a repeated variable on some root-to-leaf path?
3 of these 4 are wrong. Strike them one at a time, and say what rules each one out before you strike the next. The survivor is the answer.
Survives elimination: A
Why: Chomsky normal form makes every internal node have at most two children, so a tree with many leaves cannot be short. A path longer than the number of variables must visit some variable twice, by the pigeonhole principle.
Check
Think about what bounds the tree.
Check your understanding
Why does a sufficiently long string force a repeated variable on some root-to-leaf path?
Answer: A
Why: Chomsky normal form makes every internal node have at most two children, so a tree with many leaves cannot be short. A path longer than the number of variables must visit some variable twice, by the pigeonhole principle.
Section
Section 2
Concept
The five-piece version, with the quantifiers in the order that matters.
pumping lemma for context-free languages — If a language is context-free, then there is a length p such that every string in the language of length at least p can be split into five parts, with the two pumped parts not both empty and the middle three parts short, so that repeating the two pumped parts together any number of times keeps the string in the language.
\[ L \text{ context-free} \;\Longrightarrow\; \exists p \; \forall s \in L, |s| \ge p \; \exists u,v,x,y,z \]
The three conditions on the split come next, and each does specific work in the proofs.
Concept
Given the split into five parts, the lemma guarantees all three of these.
\[ s = u\,v\,x\,y\,z \]
| Condition | Written | Why it holds |
|---|---|---|
| pumping works | every joint repetition stays in the language | the repeated variable's derivation can be reused |
| the pumped parts are not both empty | the two together have positive length | the two occurrences are distinct nodes |
| the middle is short | the three central parts total at most p | the repeat is found near the bottom of the tree |
\[ u\,v^{i}\,x\,y^{i}\,z \in L \;\forall i \ge 0, \qquad |vy| > 0, \qquad |vxy| \le p \]
Trade off
Comparison matrix
From The three conditions: every row here is a choice with a cost. Fill the Why it holds column, then say which row you would actually pick and what you give up for it.
| Condition | Written | Why it holds |
|---|---|---|
| pumping works | every joint repetition stays in the language | the repeated variable's derivation can be reused |
| the pumped parts are not both empty | the two together have positive length | the two occurrences are distinct nodes |
| the middle is short | the three central parts total at most p | the repeat is found near the bottom of the tree |
Intuition
The two side conditions are what make proofs possible, and each is used differently from its Lesson 10 counterpart.
Not both empty stops the adversary offering a split that pumps nothing. Note it permits one of the two to be empty, which is a case the proofs must handle.
The middle is short confines the three central parts to a window of length at most p. So the two pumped parts sit close together, and a string designed with widely separated blocks forces them into at most two adjacent blocks.
\[ |vxy| \le p \;\Rightarrow\; v \text{ and } y \text{ lie within a window of length } p \]
That window condition replaces the early-split condition of Lesson 10, and it is what every proof in Section 4 exploits.
Concept
The condition says the two pumped parts are not both empty. That permits one of them to be empty, and proofs must allow for it.
| Case | Effect of pumping |
|---|---|
| both nonempty | material inserted at two separate points |
| only the first nonempty | material inserted at one point, to the left of the centre |
| only the second nonempty | material inserted at one point, to the right of the centre |
| both empty | forbidden by the condition |
The middle two rows behave much like the regular pumping lemma, inserting at a single point. A proof that assumes both parts are nonempty has an unhandled case, though in practice it is usually the easy one.
Estimation
Predict first
Check the easy case explicitly, on the three-matched-counts proof.
Commit before you compute: what does Handle the case where one pumped part is empty come out to? A rough magnitude and the right form is enough — the point is to have something concrete to be wrong about.
Correct: Verify the case genuinely needed no new idea
Why: A prediction you can defend turns the computation into a check rather than a leap of faith — and an answer that contradicts it is caught on the spot. One insertion point is a special case of two, with the second contributing nothing.
Worked example
Check the easy case explicitly, on the three-matched-counts proof.
\[ s = a^{p}b^{p}c^{p} \]
Suppose the second pumped part is empty
Why: Then all the inserted material comes from the first, at a single position within the window.
Ask which blocks that position can lie in
Why: The window is at most p long and each block is exactly p long, so the single insertion point lies within one block, or straddles two adjacent ones.
Pump up
Why: The count of one or two symbols increases; the remaining count is untouched, since the window cannot reach all three blocks.
\[ \#_a \text{ or } \#_b \text{ grows}, \quad \#_c \text{ fixed} \]
Read off the contradiction
Why: The three counts are no longer equal, so the pumped string leaves the language — the same conclusion as the general case.
Verify the case genuinely needed no new idea
Why: One insertion point is a special case of two, with the second contributing nothing. The block argument bounds the reach identically, so the same contradiction follows. That is why proofs usually treat the cases together, but naming them shows the gap has been considered.
\[ |y| = 0 \;\Rightarrow\; \text{same contradiction} \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Handle the case where one pumped part is empty", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: One insertion point is a special case of two, with the second contributing nothing. The block argument bounds the reach identically, so the same contradiction follows. That is why proofs usually treat the cases together, but naming them shows the gap has been considered.
Concept
One difference from the regular case is easy to miss and causes most incorrect proofs.
In Lesson 10 the pumped part was confined to the first p symbols of the string. Here the window of length p may sit anywhere in the string — the lemma says only that it is short, not where it is.
\[ \text{regular: } |xy| \le p \;\text{ (a prefix)} \qquad \text{context-free: } |vxy| \le p \;\text{ (anywhere)} \]
So a proof cannot assume the pumped parts lie in the first block. It must consider every position the window could occupy, which is why case analysis is unavoidable here.
Missing information
Discussion prompt
Check the lemma holds somewhere it must, before turning it against a language.
What do you need to know — or decide — before the first line can be written? List everything the problem has to hand you.
Hint: Anything you would have to invent to get started is a thing the problem must supply.
Answer:
Use the matched-counts language with its two-rule grammar.
Worked example
Check the lemma holds somewhere it must, before turning it against a language.
Take a context-free language and a grammar
Why: Use the matched-counts language with its two-rule grammar.
\[ S \to aSb \;\mid\; \varepsilon \]
Take a long string and find a repeated variable
Why: Any string with enough symbols has a derivation using the recursive rule twice, so the start variable repeats on the path.
\[ s = a^{3}b^{3} \]
Read off the five pieces
Why: The outer stretch contributes one a before and one b after; the inner subtree contributes the rest.
\[ u = aa, \; v = a, \; x = \varepsilon, \; y = b, \; z = bb \]
Check the three conditions
Why: The two pumped parts are one symbol each, so not both empty. The three central parts total two symbols, comfortably short.
Verify pumping keeps every result in the language
Why: Taking zero copies gives the two-symbol member, one copy gives the original, and two copies give the four-symbol member. Each adds one a and one b together, so the counts stay equal and every result is a member — as the lemma promises for a context-free language.
\[ a^{2}b^{2},\ a^{3}b^{3},\ a^{4}b^{4} \in L \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Read the statement on a context-free language", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: The two pumped parts are one symbol each, so not both empty. The three central parts total two symbols, comfortably short.
Anomaly
Predict first
A student writes this, and it looks reasonable:
Prove that the language of three matched counts is not context-free.
It is wrong. Say what breaks — and say it before you turn the page.
Correct: Take p of each symbol. Since the window has length at most p, assume it lies inside the leading block of a's.
Prove that the language of three matched counts is not context-free.
Why: Take p of each symbol. Since the window has length at most p, assume it lies inside the leading block of a's.
Trap
Prove that the language of three matched counts is not context-free.
Choose a string and assume the window is at the front
Why: Take p of each symbol. Since the window has length at most p, assume it lies inside the leading block of a's.
\[ s = a^{p}b^{p}c^{p}, \quad v,y \text{ assumed inside } a^{p} \]
Pump and declare the contradiction
Why: Pumping adds a's only, so the counts differ and the string leaves the language.
Notice the gap
Why: Nothing forces the window to the front. The adversary may place it straddling the b's and c's, and that case has not been handled.
\[ |vxy| \le p \;\text{ says short, not leading} \]
Prove that the language of three matched counts is not context-free.
Choose the string and enumerate the window's possible positions
Why: The window has length at most p and the string has three blocks of length p, so it can meet at most two adjacent blocks — never all three.
\[ |vxy| \le p \;\Rightarrow\; vxy \text{ meets at most two blocks} \]
Handle each case
Why: If the window misses the c's, pumping changes the a or b counts and leaves the c count alone. If it misses the a's, pumping leaves the a count alone. Either way some count changes and another does not.
Conclude
Why: In every case the three counts can no longer be equal, so the pumped string leaves the language. The proof now covers every position the adversary could choose.
\[ \text{some count changes, another does not} \;\Rightarrow\; \text{not in } L \ \checkmark \]
Notation
Annotate
From Trap: assuming the pumped parts are adjacent to the… — read this one piece at a time. What is each part doing?
On: \( s = a^{p}b^{p}c^{p}, \quad v,y \text{ assumed inside } a^{p} \)
Pattern
The same four moves as Lesson 10, with one extra obligation on your final move.
Step four is where the extra work lives. Designing the string so that only two or three window positions are possible is the whole skill.
Prediction
Predict first
What does the condition bounding the middle three parts by p tell you?
Answer it in your own words, now, with nothing to choose from. The options are on the next slide — and picking the right one off a list is an easier skill than producing it.
Correct: The two pumped parts lie within a window of length at most p, positioned anywhere
Why: The bound is on the total length of the three central parts, which contain both pumped parts and everything between them. It constrains how far apart they can be, but says nothing about where in the string that window sits.
Check
Compare the window condition with its regular-language counterpart.
Check your understanding
What does the condition bounding the middle three parts by p tell you?
Answer: A
Why: The bound is on the total length of the three central parts, which contain both pumped parts and everything between them. It constrains how far apart they can be, but says nothing about where in the string that window sits.
Section
Section 3
Concept
The proof begins by choosing p from the grammar, and the choice is what makes everything else work.
Convert the grammar to Chomsky normal form, so every tree is binary. Let the number of variables be some count, and set the pumping length to two raised to that count plus one.
\[ p = 2^{|V|+1} \]
The exponent is chosen so that a string of length at least p forces a path longer than the number of variables — which is exactly what the pigeonhole needs.
Step zero
Discussion prompt
Prove the lemma — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.
Hint: It starts with: Take a long string and its smallest parse tree
Answer:
Worked example
The full argument, in five steps.
Take a long string and its smallest parse tree
Why: Let the string be in the language with length at least p, and take a parse tree for it with as few nodes as possible.
Force a tall tree
Why: A binary tree of height h yields at most two to the h symbols. Since the string is longer than that bound allows for short trees, the height exceeds the number of variables.
\[ |s| \ge p = 2^{|V|+1} \;\Rightarrow\; h \ge |V|+1 \]
Find a repeated variable
Why: Take a longest root-to-leaf path. It has more than the number of variables among its internal nodes, so some variable appears twice. Choose the two lowest such occurrences.
Read off the five pieces
Why: The upper occurrence's subtree yields the middle three parts; the lower occurrence's subtree yields the centre. What lies outside the upper subtree gives the first and last parts.
\[ A \Longrightarrow^{*} vAy, \qquad A \Longrightarrow^{*} x \]
Verify the three conditions and conclude
Why: Substituting the upper derivation into itself any number of times gives the pumped strings, all derivable. The two pumped parts cannot both be empty, or replacing the upper subtree by the lower would give a smaller tree for the same string, contradicting minimality. And choosing the two lowest occurrences bounds the upper subtree's height, hence the length of the middle three parts.
\[ u\,v^{i}\,x\,y^{i}\,z \in L \;\forall i, \quad |vy|>0, \quad |vxy| \le p \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Prove the lemma", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Substituting the upper derivation into itself any number of times gives the pumped strings, all derivable. The two pumped parts cannot both be empty, or replacing the upper subtree by the lower would give a smaller tree for the same string, contradicting minimality. And choosing the two lowest occurrences bounds the upper subtree's height, hence the length of the middle three parts.
Intuition
The proof used a smallest tree, and that hypothesis did exactly one job.
It ruled out the degenerate case where both pumped parts are empty. If they were, the upper subtree and the lower would yield the same string, so the lower could replace the upper — giving a strictly smaller tree for the same string.
\[ |vy| = 0 \;\Rightarrow\; \text{a smaller tree exists} \]
Choosing the tree minimal in advance makes that impossible, so the condition holds. Without minimality the lemma would be true but vacuous, since an empty pumping changes nothing.
Sorting
Sort into buckets
These are the pieces of The Pumping Lemma for CFLs, out of order. Put each one back under the part of the lesson it belongs to.
Concept
The proof picked a specific pair of occurrences, and that choice is what delivers the third condition.
Taking the two lowest repeated occurrences on the path bounds the height of the upper subtree: below the upper occurrence there is no further repetition, so that stretch of path is at most as long as the variable count.
\[ \text{height of the upper subtree} \le |V|+1 \]
A bounded height bounds the yield, and the upper subtree's yield is exactly the three central parts. So those parts total at most the pumping length.
\[ |vxy| \le 2^{|V|+1} = p \]
Estimation
Predict first
See what breaks if the highest repeated pair is taken instead of the lowest.
Commit before you compute: what does Show a different choice loses the third condition come out to? A rough magnitude and the right form is enough — the point is to have something concrete to be wrong about.
Correct: Verify the condition is restored
Why: A prediction you can defend turns the computation into a check rather than a leap of faith — and an answer that contradicts it is caught on the spot. With the bounded yield, the three central parts total at most p, which is exactly the third condition.
Worked example
See what breaks if the highest repeated pair is taken instead of the lowest.
Take a tall tree with several repetitions
Why: Suppose a variable appears at the root and again near the leaves, with other repetitions in between.
Choose the highest pair
Why: The upper occurrence is the root, so its subtree is the whole tree and its yield is the entire string.
See the third condition fail
Why: The three central parts would then be the whole string, whose length is unbounded — so no useful window bound is available.
\[ |vxy| = |s| \;\;\text{— no bound} \]
Choose the lowest pair instead
Why: Now the upper subtree contains no further repetition below it, so its height is bounded by the variable count and its yield by the pumping length.
Verify the condition is restored
Why: With the bounded yield, the three central parts total at most p, which is exactly the third condition. The choice of the lowest pair is therefore not a stylistic preference but the source of the condition every proof relies on.
\[ \text{lowest pair} \;\Rightarrow\; |vxy| \le p \ \checkmark \]
Notation
Annotate
From Show a different choice loses the third condition — read this one piece at a time. What is each part doing?
On: \( \text{lowest pair} \;\Rightarrow\; |vxy| \le p \ \checkmark \)
Concept
Tracing the three conditions back to the proof makes them memorable and shows why none can be strengthened.
| Condition | Source |
|---|---|
| pumping preserves membership | both occurrences are the same variable, so their subtrees are interchangeable |
| the pumped parts are not both empty | minimality of the chosen tree |
| the middle three parts are short | the two occurrences chosen are the lowest on the path |
Notice what is not claimed: nothing says both pumped parts are nonempty, nothing says they are adjacent, and nothing locates the window in the string. All three would be false.
Check
Recall which hypothesis rules out the degenerate split.
Check your understanding
In the proof, why is the parse tree chosen to be as small as possible?
Answer: A
Why: If both pumped parts were empty, the lower occurrence's subtree would yield the same string as the upper one, so substituting it would give a strictly smaller tree for the same string — contradicting minimality. That is the only place the hypothesis is used.
Section
Section 4
Ranking
Put in order
Put the moves of Three matched counts into the order they have to happen.
Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. Suppose the language were context-free; the lemma provides a length p whose value is unknown.
Worked example
The canonical example, and the one every later proof imitates.
\[ L = \{\, a^{n}b^{n}c^{n} : n \ge 0 \,\} \]
Assume context-freeness and take the pumping length
Why: Suppose the language were context-free; the lemma provides a length p whose value is unknown.
Choose the string
Why: Take p of each symbol, in order. It is in the language and its length exceeds p.
\[ s = a^{p}b^{p}c^{p} \]
Bound where the window can be
Why: The three central parts total at most p symbols, and each block has length p. So the window meets at most two adjacent blocks and never all three.
Handle the two cases
Why: If the window avoids the c's, pumping changes the a or b count while the c count is fixed. If it avoids the a's, pumping leaves the a count fixed while another changes.
\[ \text{some count changes, at least one does not} \]
Verify the contradiction covers every legal split
Why: Since the two pumped parts are not both empty, at least one count strictly changes; and since the window misses at least one block, at least one count is unchanged. The three can no longer be equal, whatever split the adversary chose.
\[ a^{p}b^{p}c^{p} \text{ pumped} \notin L \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Three matched counts", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Since the two pumped parts are not both empty, at least one count strictly changes; and since the window misses at least one block, at least one count is unchanged. The three can no longer be equal, whatever split the adversary chose.
Hypothesis
Predict first
A block written twice is about to be worked. State your hypothesis first: which rule or definition decides this one, and what is the first move it forces? Then watch whether the example agrees with you.
Correct: Choose the string carefully
Why: A naive choice fails. Take p a's, p b's, then p a's, p b's again — so the string is a block written twice, with four blocks of length p.
A hypothesis you wrote down is falsifiable; a vague sense of how it will go is not. If the example opens somewhere else, that gap is the thing worth chasing.
Worked example
The language a stack cannot handle because the comparison is in the same order, not reversed.
\[ L = \{\, ww : w \in \{a,b\}^{*} \,\} \]
Choose the string carefully
Why: A naive choice fails. Take p a's, p b's, then p a's, p b's again — so the string is a block written twice, with four blocks of length p.
\[ s = a^{p}b^{p}a^{p}b^{p} \]
Bound the window
Why: It has length at most p, so it meets at most two adjacent blocks out of the four.
See what pumping does
Why: Pumping changes the length of one or two adjacent blocks while leaving the others alone. The string's two halves then have different block structures.
Check the halves can no longer match
Why: For the result to be in the language its first half must equal its second. Changing one block's length in only one half breaks that equality, and the window cannot reach the corresponding block in the other half.
Verify the string choice was necessary
Why: Had the string been p a's followed by p a's, pumping inside the a's would give a longer run of a's — still a block written twice, and no contradiction. The four-block choice is what makes every window position fatal.
\[ a^{p}b^{p}a^{p}b^{p} \text{ pumped} \notin L \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "A block written twice", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: For the result to be in the language its first half must equal its second. Changing one block's length in only one half breaks that equality, and the window cannot reach the corresponding block in the other half.
Intuition
In Lesson 10 a uniform prefix sufficed. Here the string must also control where the window can be, which takes more design.
The technique is to build the string from several equal blocks, long enough that a window of length p cannot span more than two of them. Then every window position leaves some block untouched, and the untouched block is the contradiction.
\[ \text{blocks of length } p \;+\; |vxy| \le p \;\Rightarrow\; \text{at most two blocks touched} \]
Getting this wrong produces a proof that handles one case and silently ignores the others — the commonest error in these arguments, and the subject of the trap in Section 2.
Step zero
Discussion prompt
Equal counts in the same positions — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.
Hint: It starts with: Choose the string on the boundary
Answer:
Worked example
A variant showing the technique transfers to conditions other than counting.
\[ L = \{\, a^{i}b^{j}c^{k} : i \le j \le k \,\} \]
Choose the string on the boundary
Why: Take p of each, so both inequalities hold with equality — the tightest possible margin.
\[ s = a^{p}b^{p}c^{p} \]
Bound the window and enumerate cases
Why: As before it meets at most two adjacent blocks, so at most two of the three counts can change.
Handle the case where the window misses the c's
Why: Pumping up increases the a count or the b count without increasing the c count. If the a count grows past the b count, or the b count past the c count, an inequality fails.
Handle the case where the window misses the a's
Why: Pumping down, taking zero copies, decreases the b count or the c count while the a count is fixed. Either the first or the second inequality then fails.
Verify both cases needed a different repetition count
Why: The first case used two copies and the second used zero. That is normal here: unlike Lesson 10, different window positions often need different pumping directions, and a complete proof must say which is used in each case.
\[ \text{case 1: } i = 2; \quad \text{case 2: } i = 0 \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Equal counts in the same positions", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: The first case used two copies and the second used zero. That is normal here: unlike Lesson 10, different window positions often need different pumping directions, and a complete proof must say which is used in each case.
Missing information
Discussion prompt
A fourth application, where the condition is arithmetic rather than a plain count.
What do you need to know — or decide — before the first line can be written? List everything the problem has to hand you.
Hint: Anything you would have to invent to get started is a thing the problem must supply.
Answer:
Take p a's and p squared b's, so the relationship holds exactly.
Worked example
A fourth application, where the condition is arithmetic rather than a plain count.
\[ L = \{\, a^{n}b^{m} : m = n^{2} \,\} \]
Choose the string on the condition
Why: Take p a's and p squared b's, so the relationship holds exactly.
\[ s = a^{p}b^{p^{2}} \]
Bound the window
Why: It has length at most p, so it lies inside the a-block, inside the b-block, or straddles the boundary.
Handle the case inside the a-block
Why: Pumping changes the a count by at least one while the b count is fixed. The required square then changes by at least twice p plus one, but the b count did not move.
\[ (p+k)^{2} \ge p^{2} + 2p + 1 > p^{2} \]
Handle the remaining cases
Why: If the window touches only b's, the b count changes while the a count is fixed, so the square no longer matches. If it straddles, both change, but the a count changes by at most p while the b count changes by at most p — far too little to keep pace with the square.
Verify the arithmetic gap in the straddling case
Why: Increasing the a count by k requires the b count to increase by at least twice p, since consecutive squares differ by that much. But the window contributes at most p symbols in total, so the b count cannot keep up and the condition fails.
\[ 2p+1 > p \;\Rightarrow\; \text{the square outruns the window} \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "A language of matched exponents", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Increasing the a count by k requires the b count to increase by at least twice p, since consecutive squares differ by that much. But the window contributes at most p symbols in total, so the b count cannot keep up and the condition fails.
Intuition
The last proof reused the technique from Lesson 11's perfect-squares example, and the reuse is not a coincidence.
When the condition relates two quantities by a fast-growing function, pumping changes both by a bounded amount, while the function's required change grows without bound. The gap between them is the contradiction.
\[ \text{window contributes} \le p \quad\text{but the condition demands} \ge 2p+1 \]
So the same three arithmetic tools transfer: land in a gap between consecutive values, force a factorization, or show one side outgrows the other. Only the string design changes, because the window may now sit anywhere.
Constraint
Discussion prompt
Run Writing a non-context-free proof with this step confiscated:
Invoke the lemma to get a five-part split with the two side conditions.
Is it still possible? If it is, say what takes its place and what it costs you. If it is not, say exactly what that step was providing that nothing else does.
Hint: A step you can drop for free was never load-bearing. If you cannot drop it, name the thing that goes wrong the moment it is gone.
Answer:
Pattern
The template, with the extra obligation the five-piece split imposes.
Step four is the one that distinguishes a complete proof from a plausible one. Naming the cases explicitly — 'the window meets only the first two blocks', and so on — is what makes it checkable.
Edge cases
Discussion prompt
Writing a non-context-free proof works on the cases you have just seen. Push it to the edge: what is the most degenerate input it still handles — empty, zero, one item, everything equal — and what is the first case where it stops being true? Name the case, not just "it breaks".
Hint: Try the smallest legal input, then the largest, then the one where two things collide. Methods are specified at their edges; the middle takes care of itself.
Answer:
The template, with the extra obligation the five-piece split imposes.
Commit first
Predict first
Why is the string with p of each of three symbols a good choice for proving three matched counts is not context-free?
Commit to an answer, then rate it — certain, fairly sure, or guessing — and write the rating down before you turn the page.
Correct: A window of length at most p cannot meet all three blocks, so one count is always untouched
Why: Each block has length p and the window is at most p long, so it can straddle at most two adjacent blocks. Whatever position it takes, some block is untouched, and pumping then breaks the equality between that count and the ones that changed.
The rating matters as much as the answer: confident-and-wrong is the combination that survives revision, because nothing about it feels like it needs revisiting.
Check
Think about how many blocks a window of length p can span.
Check your understanding
Why is the string with p of each of three symbols a good choice for proving three matched counts is not context-free?
Answer: A
Why: Each block has length p and the window is at most p long, so it can straddle at most two adjacent blocks. Whatever position it takes, some block is untouched, and pumping then breaks the equality between that count and the ones that changed.
Section
Section 5
Concept
As in Lesson 11, once one non-context-free language is known, closure properties multiply it cheaply.
The context-free languages are not closed under intersection, but they are closed under intersection with a regular language — a fact Lesson 19 proves. That mixed closure is exactly what these arguments use.
\[ L \text{ context-free}, \; R \text{ regular} \;\Rightarrow\; L \cap R \text{ context-free} \]
So assuming a candidate is context-free and intersecting it with a simple regular pattern must yield a context-free language. Exhibiting a known non-context-free result gives the contradiction.
Estimation
Predict first
A candidate where a direct pumping proof is fiddly and a closure argument is three lines.
Commit before you compute: what does Prove a language non-context-free by closure come out to? A rough magnitude and the right form is enough — the point is to have something concrete to be wrong about.
Correct: Verify the intersection equality in both directions
Why: A prediction you can defend turns the computation into a check rather than a leap of faith — and an answer that contradicts it is caught on the spot. Every string in the intersection has equal counts and the right order, so it has the matched form; and every matched string has equal counts and the right order.
Worked example
A candidate where a direct pumping proof is fiddly and a closure argument is three lines.
\[ L = \{\, w : \#_a(w) = \#_b(w) = \#_c(w) \,\} \]
Assume the candidate is context-free
Why: For contradiction, suppose some grammar generates it.
Choose a regular helper
Why: Take the strings with all a's, then all b's, then all c's. A four-state machine recognizes it, so it is regular.
\[ R = a^{*}b^{*}c^{*} \]
Compute the intersection
Why: A string with all three counts equal whose symbols appear in that order is exactly a three-matched-counts string.
\[ L \cap R = \{\, a^{n}b^{n}c^{n} \,\} \]
Invoke the mixed closure and conclude
Why: Intersecting a context-free language with a regular one gives a context-free language. But the result is not context-free, by Section 4. Contradiction.
Verify the intersection equality in both directions
Why: Every string in the intersection has equal counts and the right order, so it has the matched form; and every matched string has equal counts and the right order. Both inclusions hold, so the identification is exact and the argument closes.
\[ L \cap R = \{a^{n}b^{n}c^{n}\} \;\Rightarrow\; L \text{ not context-free} \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Prove a language non-context-free by closure", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Every string in the intersection has equal counts and the right order, so it has the matched form; and every matched string has equal counts and the right order. Both inclusions hold, so the identification is exact and the argument closes.
Concept
A crucial difference from Lesson 11, and forgetting it invalidates the argument.
The regular languages were closed under intersection outright, so any regular helper could be used. The context-free languages are not closed under intersection with another context-free language, so the helper must be regular.
\[ L_1, L_2 \text{ context-free} \;\not\Rightarrow\; L_1 \cap L_2 \text{ context-free} \]
Using a context-free helper produces an argument that proves nothing, since the intersection need not be context-free whether or not the candidate is. Lesson 19 gives the counterexample.
Concept
Exactly as in Lesson 10, the implication runs in one direction only.
Context-free implies pumpable. Pumpable does not imply context-free — there are non-context-free languages satisfying the condition, so exhibiting a valid split proves nothing.
\[ \text{context-free} \;\Rightarrow\; \text{pumpable}, \quad \text{not conversely} \]
When the lemma is silent, stronger tools exist: Ogden's lemma, which lets you mark positions the window must include, and the interchange lemma. Both are beyond this course, but knowing they exist explains why a failed pumping proof is not a dead end.
Explain it
Discussion prompt
Explain The lemma is one-way here too to a student a year behind you. No notation, no jargon they have not met — and it still has to be true.
Hint: If your explanation needs a symbol they have never seen, you are describing the notation rather than the idea.
Answer:
Exactly as in Lesson 10, the implication runs in one direction only.
Intuition
Collected, so the choice is automatic — and note the middle row differs from Lesson 11.
| Tool | Use when | Cost |
|---|---|---|
| closure with a regular helper | a known non-context-free language is one intersection away | three lines |
| the pumping lemma | a fresh case with blocks you can control | a template plus case analysis |
| Ogden's lemma | pumping is silent because the window keeps landing harmlessly | beyond this course |
Try them in that order. The closure route is shortest whenever it applies, and after Section 4 there are several known non-context-free languages to reach for.
Comparison
Comparison matrix
From Three tools, in order of preference: refill the Cost column from what you know. The rest of the table is as it appeared.
| Tool | Use when | Cost |
|---|---|---|
| closure with a regular helper | a known non-context-free language is one intersection away | three lines |
| the pumping lemma | a fresh case with blocks you can control | a template plus case analysis |
| Ogden's lemma | pumping is silent because the window keeps landing harmlessly | beyond this course |
Step zero
Discussion prompt
Diagnose a failed attempt — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.
Hint: It starts with: Try a poor string
Answer:
Worked example
Repair a proof that will not close, using the diagnostic habits from Lesson 11.
Try a poor string
Why: To prove a block written twice is not context-free, take p a's followed by p a's. It is in the language.
\[ s = a^{p}a^{p} \]
Watch it fail
Why: Pumping inside the a's gives a longer run of a's. Any even-length run of a's is a block written twice, so the result is still in the language.
Diagnose
Why: The string is too uniform: its structure is invisible, so changing lengths cannot break the condition. The same failure as Lesson 11's uniform-string trap.
Repair with blocks
Why: Use four alternating blocks of length p, so that changing one block's length is visible and unmatched in the other half.
\[ s = a^{p}b^{p}a^{p}b^{p} \]
Verify the repaired string engages the condition
Why: Now every window position touches at most two adjacent blocks, and the corresponding block in the other half is out of reach. So the two halves must differ after pumping, and the proof closes for every case.
\[ \text{four blocks} \;\Rightarrow\; \text{every window leaves a half unmatched} \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Diagnose a failed attempt", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Now every window position touches at most two adjacent blocks, and the corresponding block in the other half is out of reach. So the two halves must differ after pumping, and the proof closes for every case.
Prediction
Predict first
In a closure argument showing a language is not context-free, what must the helper language be?
Answer it in your own words, now, with nothing to choose from. The options are on the next slide — and picking the right one off a list is an easier skill than producing it.
Correct: Regular — the class is closed under intersection with a regular language only
Why: The context-free languages are not closed under intersection with each other, so a context-free helper licenses no conclusion. They are closed under intersection with a regular language, which is exactly the closure these arguments invoke.
Check
Recall which intersection is available for this class.
Check your understanding
In a closure argument showing a language is not context-free, what must the helper language be?
Answer: A
Why: The context-free languages are not closed under intersection with each other, so a context-free helper licenses no conclusion. They are closed under intersection with a regular language, which is exactly the closure these arguments invoke.
Section
Section 6
Concept
Both lessons proved a property forced by finiteness. Comparing them makes each easier to recall.
| Lesson 10 | This lesson | |
|---|---|---|
| forced by | finitely many states | finitely many variables |
| mechanism | a repeated state in a run | a repeated variable on a path |
| pieces | three | five |
| pumped | one piece | two, jointly |
| window condition | within the first p symbols | any window of length p |
| typical proof | one case | two or three cases |
The last two rows are where the extra difficulty lives, and both come from the same source: the pumped material is inserted in two places that must move together.
Trade off
Comparison matrix
From The two pumping lemmas side by side: every row here is a choice with a cost. Fill the This lesson column, then say which row you would actually pick and what you give up for it.
| Lesson 10 | This lesson | |
|---|---|---|
| forced by | finitely many states | finitely many variables |
| mechanism | a repeated state in a run | a repeated variable on a path |
| pieces | three | five |
| pumped | one piece | two, jointly |
| window condition | within the first p symbols | any window of length p |
| typical proof | one case | two or three cases |
Intuition
Each class so far has been defeated by a language needing one more simultaneous pairing than the model can maintain.
The answer is the machine of Lesson 20, which has unrestricted read-write memory and no such limitation. That model turns out to be the last one — and the rest of the course is about what even it cannot do.
\[ \text{regular} \subsetneq \text{context-free} \subsetneq \cdots \]
Analogy
Discussion prompt
Explain Why the hierarchy keeps going by analogy to something with no Theory of Computation in it at all — a queue, a recipe, a map, a bank balance, whatever fits. Then say where your analogy breaks.
Hint: An analogy that never breaks is not an analogy, it is the same idea wearing a hat. Find the seam — that is the part that is actually new.
Answer:
Each class so far has been defeated by a language needing one more simultaneous pairing than the model can maintain.
Concept
Collecting the examples gives a rule of thumb that predicts most classifications without any proof.
| Requirement | Context-free? | Reason |
|---|---|---|
| one count matched against one other | yes | one stack suffices |
| one count matched against two others | no | the count is consumed by the first check |
| a block compared with its reversal | yes | a stack returns symbols reversed |
| a block compared with a copy | no | the order is wrong for a stack |
| nesting to any depth | yes | the stack depth tracks it |
| two independent nestings | no | one stack cannot interleave them |
Every row follows from the stack's discipline described in Lesson 16. The pumping lemma is how those intuitions are turned into proofs.
Discrimination
Sort into buckets
Sort these by Context-free?, from memory, without looking back at What the class can and cannot pair. Telling them apart on the spot is the skill; the table is only where the answer happens to be written down.
Ranking
Put in order
Put the moves of Classify four languages by inspection into the order they have to happen.
Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. One pairing, between the a's and the b's; the c's are unconstrained.
Worked example
Practise the rule of thumb before reaching for any proof.
Take the strings of equal a's and b's followed by any c's
Why: One pairing, between the a's and the b's; the c's are unconstrained. One stack suffices, so this is context-free.
\[ \{a^{n}b^{n}c^{m}\} \;: \text{ context-free} \]
Take the strings of a's, b's and c's with the a's matching the c's
Why: Still one pairing, though the paired blocks are separated. A stack can push through the b's without consuming anything, so this is context-free too.
\[ \{a^{n}b^{m}c^{n}\} \;: \text{ context-free} \]
Take the strings where the a's match the b's and the b's match the c's
Why: Two pairings sharing the middle block. The b count would have to be checked twice, which one stack cannot do, so this is not context-free.
\[ \{a^{n}b^{n}c^{n}\} \;: \text{ not context-free} \]
Take the strings that are some block followed by the same block
Why: One pairing, but in the same order rather than reversed. A stack returns symbols backwards, so this is not context-free.
\[ \{ww\} \;: \text{ not context-free} \]
Verify the classifications against the proofs
Why: The first two have easy grammars, which settles them positively. The last two were proved negatively in this section, by exactly the block-and-window technique. The rule of thumb predicted all four correctly.
\[ \text{count the pairings, check the order} \ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Classify four languages by inspection", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: The first two have easy grammars, which settles them positively. The last two were proved negatively in this section, by exactly the block-and-window technique. The rule of thumb predicted all four correctly.
Elimination
Eliminate the wrong options
Which of these languages is context-free?
3 of these 4 are wrong. Strike them one at a time, and say what rules each one out before you strike the next. The survivor is the answer.
Survives elimination: A
Why: Only one pairing is required, between the first and last blocks. A machine pushes for each a, ignores the b's without touching the stack, then pops for each c — one stack, one comparison.
Check
Count the simultaneous pairings each language demands.
Check your understanding
Which of these languages is context-free?
Answer: A
Why: Only one pairing is required, between the first and last blocks. A machine pushes for each a, ignores the b's without touching the stack, then pops for each c — one stack, one comparison.
Concept
The standard non-context-free languages, with the string that proves each.
| Language | String to choose | Why it works |
|---|---|---|
| three matched counts | p of each symbol | the window misses a block |
| a block written twice | four alternating blocks of length p | the matching block is out of reach |
| equal counts, any order | closure with an ordered regular helper | reduces to three matched counts |
| nested inequalities | p of each, on the boundary | two cases, pumping up and down |
Every entry uses blocks of length p, so that the window's reach is bounded by construction. That single design principle covers the whole catalogue.
Comparison
Comparison matrix
From The catalogue: refill the String to choose column from what you know. The rest of the table is as it appeared.
| Language | String to choose | Why it works |
|---|---|---|
| three matched counts | p of each symbol | the window misses a block |
| a block written twice | four alternating blocks of length p | the matching block is out of reach |
| equal counts, any order | closure with an ordered regular helper | reduces to three matched counts |
| nested inequalities | p of each, on the boundary | two cases, pumping up and down |
Intuition
Two questions look as though this lemma should answer them, and it answers neither.
It cannot show a language is context-free, since the implication runs one way. And it cannot distinguish the deterministic subclass of Lesson 16, because deterministic and general context-free languages satisfy the same pumping condition.
\[ \text{pumpable} \;\not\Rightarrow\; \text{context-free} \;\not\Rightarrow\; \text{deterministic} \]
For the first, exhibit a grammar. For the second, the standard route is the complement closure from Lesson 16: a language whose complement is not context-free cannot be deterministic.
Counterexample
Discussion prompt
Two questions look as though this lemma should answer them, and it answers neither.
That is stated as though it always holds. Do one of two things: produce a case where it fails, or say precisely what rules such a case out. "It just does" is not on the menu.
Hint: Hunt at the extremes first — zero, one, negative, empty, equal. If every extreme survives, the reason they survive is the proof.
Answer:
For the first, exhibit a grammar. For the second, the standard route is the complement closure from Lesson 16: a language whose complement is not context-free cannot be deterministic.
Ranking
Put in order
These are the steps of The complete procedure, scrambled. Put them back in order before the next slide shows you.
Why: This is the order the recipe itself gives. Recalling the sequence without the slide in front of you is the difference between recognising the method and being able to run it — most of what goes wrong in practice is a step done out of turn.
Pattern
Everything from this lesson, collected as one routine.
If no string can be found where every window position is fatal, the language may pump despite being outside the class, and a stronger lemma is needed.
Real world
Discussion prompt
Outside this lesson: where does The Pumping Lemma for CFLs actually turn up? Name one concrete situation — a job, a piece of software someone ships, a decision somebody has to make — and say which part of The complete procedure is doing the work in it.
Hint: Vague is the failure mode here. "Engineering" is not a situation; "deciding whether this build is fast enough to ship" is.
Answer:
Lesson 18 supplies the tool for proving that a language has no context-free grammar. It shows how Chomsky normal form bounds the height of a parse tree, so that a long string forces a repeated variable somewhere on a root-to-leaf path, then gives the five-piece statement with its three conditions and the crucial difference from the regular case: the short window may sit anywhere rather than at the front. It proves the lemma and points out where minimality of the parse tree is used, then works proofs for three matched counts, a block written twice, and nested inequalities, with explicit case analysis over the window positions. It covers closure arguments using a regular helper and why a context-free helper proves nothing, and ends by comparing the two pumping lemmas.
Connect it up
Draw it
One page, no notation unless you need it: draw how these connect — Why a New Tool · The Statement · Proving the Lemma · Applications · Alternatives and Limits · Perspective. Put an arrow wherever one of them is what makes another possible, and label the arrow with why.
Recap
You can prove languages beyond the context-free class, completing the picture for the second level of the hierarchy.
| Situation | Move |
|---|---|
| three quantities must match | p of each, enumerate the window positions |
| a block must repeat in the same order | four alternating blocks of length p |
| a known case is one intersection away | closure with a regular helper |
| the window keeps landing harmlessly | redesign the string with more blocks |
| nothing works | the language may pump anyway — a stronger lemma is needed |
Lesson 19 works out the closure properties of this class, including the failures of intersection and complement that this lesson has already leaned on.
Want this taught 1-on-1? Alexander tutors Theory of Computation — $55/session, free consultation.