Pumping Lemma
3–5 pts · every exam · Usually Q4/Q5 · Word is given to you

FIRST DECISION — Read this before writing anything

Can the proof be finished, or not? This determines your entire answer and your max score.

CAN finish
Every valid split leads to a contradiction
CAN'T finish
At least one valid split survives all pumping
Your answer: Enumerate all possible splits. For each, find an i that breaks membership. Write “Contradiction for all splits, so L is not regular. □” Your answer: Identify the surviving split. Show xyiz ∈ L for all i ≥ 0. Explain why this word choice fails and what word would work instead.
Full marks available (3–5 pts) Full marks available (4 pts). But if you wrongly try to finish it → max 2/4.

How to detect: Look at the first p characters of w. If y can consist of two different symbols whose counts are linked in the language condition (e.g. b and c where the condition is ca+cb=cc), pumping may preserve the balance → suspect CAN'T finish. If the first p characters are all one symbol, or all cases break the condition → likely CAN finish.

All Past Exam Instances
Exam Q# Language Word given Finish? Points
Endterm 23–24 Q5 L = {w ∈ {a,b,c}* | starts with a, ca+cb = cc} w = (ac)(b)p(c)p CAN'T 4
Resit 23–24 Q4 L = {anbm | 0 ≤ n ≤ m} w = a⌈p/2⌉b⌈p/2⌉ CAN 5
Endterm 24–25 Q4 L = {an | n is prime} w = aq (smallest prime > p) CAN 3
Resit 24–25 Q4 L = {ambnaq | m·q ≥ n} w = abpap CAN 3
Pattern: 3 out of 4 exams = CAN finish. 1 out of 4 = CAN'T finish.

The CAN'T case appeared on the endterm (not the resit). The CAN'T case was worth the most points (4 pts) and had the harshest penalty for getting it wrong: max 2/4 if you failed to recognize the word was bad. Points range from 3–5 across exams.

The Pumping Lemma (cheatsheet)

If L is regular, then there exists a pumping length p such that:

For all w ∈ L with |w| ≥ p, there exists a split w = xyz where:

  1. |xy| ≤ p — x and y are within the first p characters
  2. |y| ≥ 1 — y is nonempty
  3. xyiz ∈ L for all i ≥ 0 — pumping preserves membership

Contrapositive (what proofs use): If no such p exists → L is not regular.

Exam Format

The exam gives you:

  1. A language L (claimed non-regular)
  2. The beginning of a proof by contradiction: “Suppose L is regular, let p be the pumping length, consider w = [specific word]”
  3. Your job: FINISH the proof, OR explain why this particular word choice CAN’T work

You do not choose the word. The setup is done. You write the punchline.

Grading Rubrics (all 4 exams)

Endterm 23–24 Q5 (4 pts) — CAN'T FINISH

L = {w ∈ {a,b,c}* | starts with a, ca+cb=cc}. Word: w = (ac)(b)p(c)p

1 pt Give a split. Write down explicit x, y, z (e.g. x = a, y = cb, z = bp−1cp).
1 pt Give the split without a contradiction. The split must be one where pumping doesn’t break membership.
1 pt Explain why the equality holds for any i. Show ca(xyiz) + cb(xyiz) = cc(xyiz) for all i ≥ 0.
1 pt Explain why the word starts with a for any i. Verify xyiz still begins with a for all i ≥ 0.

If you wrongly tried to finish the proof instead:

Max 2/4 if you miss that the proof can’t be finished. Recognizing the failed word is worth double.

Resit 23–24 Q4 (5 pts) — CAN FINISH

L = {anbm | 0 ≤ n ≤ m}. Word: w = a⌈p/2⌉b⌈p/2⌉

1 pt For giving at least one group of splits (e.g. all splits where y is only a’s).
1 pt For all groups of splits (y = only a’s, y = a’s and b’s, y = only b’s).
1 pt Contradiction where y = only a’s (i > 1 causes too many a’s).
1 pt Contradiction where y = a’s and b’s (i > 1 causes wrong form, not a*b*).
1 pt Contradiction where y = only b’s (i = 0 causes too few b’s).

Endterm 24–25 Q4 (3 pts) — CAN FINISH

L = {an | n is prime}. Word: w = aq (smallest prime > p)

1 pt For giving the correct group of splits (y = aβ with β > 0).
1 pt For trying to find an i which makes the word not in the language.
1 pt For a correct i (i = q+1 gives length q(1+β), which is composite).

Resit 24–25 Q4 (3 pts) — CAN FINISH

L = {ambnaq | m·q ≥ n}. Word: w = abpap

1 pt For giving the correct groups of splits (two cases: x is non-empty vs empty).
1 pt Correct i and explanation when x is not empty (y = bβ, pump i=2: too many b’s).
1 pt Correct i and explanation when x is empty (y = abα, pump i=0: m=0 so m·q=0 < n).
The Mechanic (step by step)

Step 1 — What must y consist of?

|xy| ≤ p forces xy into the first p characters of w.
|y| ≥ 1 means y is nonempty.

Therefore y consists entirely of whatever symbols appear in the first p positions of w. Enumerate all possible compositions of y.

Example: if w = apbp, the first p characters are all a’s, so y = ak for some k ≥ 1. Only one case.
If w = abpcp, the first p characters are a, b, b, …, b — so y could be ak, ajbk, or bk. Multiple cases to check.

Step 2 — For each possible y, try pumping

For each case of y, compute xyiz and find an i that breaks membership in L.

Best values to try:

Step 3 — Does pumping break ALL valid splits?

CAN finish — for every valid split (every possible y), you found an i that breaks membership.

Write out each case, show the contradiction for each. Proof complete. □

CAN’T finish — there exists some valid split where pumping preserves membership for all i.

Identify that split. Show xyiz ∈ L for all i. Explain why this word choice fails.

The exam trap

The “CAN’T finish” case is the trap. Most students assume every pumping lemma question ends with a contradiction. But if the exam gives you a bad word choice, one surviving split is enough to make the proof unfixable. You must recognize it, name the split, and explain why it survives.

Worked Example — CAN finish (Resit 24–25 Q4)

L = {ambnaq | m·q ≥ n}, Σ = {a, b}

Word given: w = abpap (so m=1, n=p, q=p, and 1·p = p ≥ p ✓)

Step 1 — What must y be?

First p characters of w = abpap are: a, b, b, …, b (1 ‘a’ then p−1 ‘b’s).

Two possible compositions:

Case 1: y = bβ (pure b’s)

Split: x = abα, y = bβ, z = bp−α−βap. With α ≥ 0, β ≥ 1, α + β ≤ p − 1.

Pump with i = 2: xy2z = abp+βap. Check: m·q = 1·p = p < p+β = n. Not in L.

Case 2: y = abα (starts with a)

Split: x = ε, y = abα, z = bp−αap. With 0 ≤ α < p.

Pump with i = 0: xz = bp−αap = a0bp−αap. Check: m·q = 0·p = 0 < p−α = n. Not in L.

Both cases give contradictions. Proof complete.

CAN finish. Every valid split leads to a contradiction when pumped.
Worked Example — CAN finish (Endterm 24–25 Q4)

L = {an | n is prime}, Σ = {a}

Word given: w = aq where q is the smallest prime > p.

Step 1 — What must y be?

Unary alphabet → only one possibility: y = ak for some 1 ≤ k ≤ p.

Step 2 — Pump and check

xyiz = aq+(i−1)k. Need to find i where q + (i−1)k is not prime.

Take i = q + 1: length = q + q·k = q(1+k).

Since k ≥ 1, we have 1+k ≥ 2. Since q ≥ 3 (prime > p ≥ 1), q(1+k) is a product of two factors both ≥ 2 → composite. Not in L.

Only one case for y, and it gives a contradiction. Proof complete.

CAN finish. Pump with i = q+1. Length becomes q(1+k), which is composite.
Worked Example — CAN’T finish (Endterm 23–24 Q5)

L = {w ∈ {a,b,c}* | w starts with a and ca(w) + cb(w) = cc(w)}

Word given: w = acbpcp

Verify w ∈ L

Starts with a ✓. Counts: ca = 1, cb = p, cc = p+1. Check: 1 + p = p+1 ✓

Step 1 — What must y be?

First p characters of acbpcp: a, c, b, b, …, b. So |xy| ≤ p means y is within “acbb…b”.

Possible compositions of y include: pure b’s, strings containing c and b, strings containing a, c, and b.

Step 2 — Try the split x = a, y = cb

This is valid: |xy| = 3 ≤ p (for p ≥ 3), |y| = 2 ≥ 1.

Pumped string: xyiz = a(cb)ibp−1cp

Starts with a ✓ for all i. So xyiz ∈ L for every i ≥ 0.

Why it fails: y = cb adds one b and one c simultaneously. The condition ca + cb = cc stays balanced no matter how many copies of “cb” you pump in or out. One surviving split is enough — the proof cannot be finished.

CAN'T finish. The split x=a, y=cb survives all pumping — adding copies of “cb” preserves the balance ca + cb = cc.

A better word choice would force y into only one symbol type. For example w = abpcp+1, where the first p characters are all in {a, b} — then pumping y can only change the b-count, breaking the balance.

Worked Example — CAN finish (Resit 23–24 Q4)

L = {anbm | 0 ≤ n ≤ m}, Σ = {a, b}

Word given: w = a⌈p/2⌉b⌈p/2⌉ (note: n = m = ⌈p/2⌉, so 0 ≤ n ≤ m ✓)

Step 1 — What must y be?

First p characters of w: a⌈p/2⌉ followed by b⌊p/2⌋. Three possible compositions for y:

Case 1: y = aβ (only a’s, β > 0)

Split: x = aα, y = aβ, z = ap/2 − α − βbp/2.

Pump with i = 2: ap/2 + βbp/2. Now n = p/2 + β > p/2 = m. Not in L (n > m). ✓

Case 2: y = aαbβ (mix of a’s and b’s, both ≥ 1)

Pump with i = 2: xy2z = a...b...aαb.... The string is not of the form a*b* (a’s appear after b’s). Not in L.

Case 3: y = bβ (only b’s, β > 0)

Split: x = ap/2bα, y = bβ, z = bp/2 − α − β.

Pump with i = 0: ap/2bp/2 − β. Now m = p/2 − β < p/2 = n. Not in L (n > m). ✓

All three cases give contradictions. Proof complete.

CAN finish. This is the most involved exam instance with 3 separate split groups (5 pts total). Each group needs its own contradiction argument.
Practice Problems
Q1 — Classic

L = {anbn | n ≥ 0}. Word: w = apbp. Can you finish?

Solution

Yes. y = ak (since |xy| ≤ p, y is all a’s). Pump with i=2: ap+kbp. Since k ≥ 1, p+k > p, so the number of a’s exceeds the number of b’s. Not in L. ✓

Q2 — Doubles

L = {ww | w ∈ {a,b}*}. Word: w = apbapb. Can you finish?

Solution

Yes. y = ak (first half only, since |xy| ≤ p means y is within the initial ap block). Pump with i=0: ap−kbapb. The first half is shorter than the second half — can’t be of form ww. (More precisely: |xy0z| = 2p+2−k which is even only if k is even, but even then the two halves differ.) ✓

Q3 — Unequal (tricky)

L = {ambn | m ≠ n}. Word: w = apbp+p!. Can you finish?

Solution

Yes. y = ak. Pump with i = p!/k + 1: number of a’s = p + (p!/k)·k = p + p!. Total = ap+p!bp+p!. Equal! Not in L.

(p!/k is an integer because 1 ≤ k ≤ p, so k divides p!.) ✓

Q4 — Matching ends

L = {anbmcn | n, m ≥ 0}. Word: w = apcp. Can you finish?

Solution

Yes. y = ak. Pump with i=0: ap−kcp. Now the a-count is p−k and the c-count is still p. Since m=0 (no b’s), we need equal a’s and c’s: p−k ≠ p. Not in L. ✓