4.6.12 · D1Theory of Computation

Foundations — Pumping lemma for CFLs

2,972 words14 min readBack to topic

This page assumes you have read the parent Pumping Lemma for CFLs note and got stuck on the notation. Here we build every symbol from the ground up, in an order where each idea leans only on the ones before it. Two symbols the parent leans on heavily — the pumping length and the variable count — are only named here; both are fully defined in Section 5 once we have the tree picture to explain them.


1. Alphabet, symbol, string — the raw material

Picture it as beads on a wire: each bead is a symbol, the wire read left-to-right is the string.

Figure s01 — what it shows: the string drawn as five coloured beads on a horizontal wire, with its length called out. It defines string and length visually so "counting beads" becomes literal.

Figure — Pumping lemma for CFLs

Why we need this: the pumping lemma constantly says things like "" (the string is at least beads long — we define the pumping length in Section 5) and "" (at least one bead among these pieces). Every one of those is just counting beads.


2. Concatenation and the pieces

When the parent note writes , it is saying: cut the string into five consecutive pieces named and glue them back — nothing is added or lost, they are just labels for five stretches of the same wire.

Figure s02 — what it shows: the wire cut into five coloured blocks in order, with the two pump pieces and flagged by arrows. It defines the five-piece split and marks which pieces get spun.

Figure — Pumping lemma for CFLs

3. Language, and "context-free"

Picture a big bag; only the allowed strings are dropped inside. "" means the string is in the bag; "" means it is not.

See Context-Free Grammars for the full machinery. A context-free language is any language some CFG can generate.


4. Derivation arrows and

Why the topic needs it: the loop is written , i.e. "starting from , after several steps you reach a string that still contains , with on its left and on its right." That is a picture of a variable reproducing itself with extra material around it — the spinnable engine.


5. Parse trees — turning a derivation into a picture

Figure s03 — what it shows: a parse tree with root , the outer pieces , then the same variable appearing twice on one downward path, with below. It pictures the repeated-variable loop that pumping exploits.

Figure — Pumping lemma for CFLs

Picture doubling: 1 root, up to 2 at the next level, 4, 8, … so height reaches at most leaves.

Figure s04 — what it shows: three levels of a binary tree with node counts labelled per level, illustrating the doubling that gives "at most leaves at height ". It justifies why long strings force tall trees.

Figure — Pumping lemma for CFLs

Why the topic needs it: "Long string () more than leaves tall tree a variable must repeat" is the entire skeleton, and it rides on this doubling bound.


6. Chomsky Normal Form — why we tidy the grammar first

Why it matters here: "" gives exactly two children, so the parse tree becomes binary — that is what unlocks the clean leaf bound in Section 5, and it also guarantees the upper subtree is strictly bigger than the lower one (giving ).


7. The Pigeonhole Principle — why a repeat is forced


8. Supporting cast (used but not central)


Prerequisite map

The diagram below renders (in any Mermaid-aware Obsidian view) as a flowchart whose boxes are the foundations of Sections 1–7 and whose arrows mean "you need the lower idea before the higher one makes sense." Read it bottom-up, following arrows into the final "Pumping Lemma" box; it is literally the reading order of this page. Trace one path at a time: raw strings feed grammars, grammars draw parse trees, CNF makes those trees binary so the doubling bound bites, and pigeonhole then forces the repeat that is the pumping lemma. If any box looks unfamiliar, jump back to its section before reading the parent proof.

Alphabet symbol string

Concatenation and pieces u v x y z

Language a set of strings

Context-Free Grammar

Derivation arrows

Parse Trees

Chomsky Normal Form

Binary tree height and leaves

Pigeonhole forces a repeat

Pumping Lemma for CFLs

Pushdown Automata

If your viewer does not render Mermaid, read the arrow list as plain prerequisites: alphabet/stringpieces and → languagegrammarderivation arrowsparse trees; separately grammarChomsky Normal Formbinary-tree height/leaves; then parse trees and CNF both feed binary-tree height/leavespigeonholePumping Lemma, with pieces and pushdown automata also feeding the final lemma.


Equipment checklist

Test yourself — each line is prompt ::: answer.

What does measure?
The number of symbols (beads) in the string .
What is and its length?
The empty string, with .
Write as an explicit string.
(the empty string).
In , what do mean?
Counts of letters: the 's, the 's, the 's — identical roles for different letters.
What does mean operationally?
Cut into five consecutive pieces and glue them back — just labels for five stretches.
What is the middle window and its bound?
The consecutive pieces glued together; the lemma requires , so the pumped region is at most consecutive beads.
Why five pieces for CFLs but three for regular languages?
Grammars branch, dropping repeated material on both left () and right (); regular DFAs repeat only one middle piece.
What is a language ?
A set of strings; means is a valid string of .
What makes a grammar context-free?
Every rule replaces a single variable, independent of surrounding context.
What is the meta-string ?
A placeholder for any string of mixed terminals and variables (a derivation snapshot).
Difference between and ?
is one rule step; is zero or more steps chained.
How do you read the generated string off a parse tree?
Take the leaves (childless bottom nodes) in left-to-right order; that sequence is the string.
Max leaves of a binary tree of height , and how is height counted?
At most leaves; height = number of edges on the longest root-to-leaf path (a lone node has height 0).
What are and ?
is the number of distinct variables; is the pumping length.
What two rule shapes are allowed in CNF (plus the one exception)?
and ; the only exception is for the start symbol when is in the language.
Why convert to CNF before the proof?
It makes the parse tree binary, unlocking the clean leaf bound and a strict left/right split.
State the Pigeonhole Principle in one line.
More items than boxes forces some box to hold at least two.
In the lemma, what plays "items" and "boxes"?
Items = variable nodes on a long path; boxes = the distinct variable names.
Recall Ready check

If you can answer every line above without peeking, you are ready for the parent note's derivation. If any felt shaky, reread that section before tackling .