4.6.7 · D3Theory of Computation

Worked examples — Pumping lemma for regular languages — proof and using to show non-regularity

3,814 words17 min readBack to topic

This page is a catalogue of cases. The parent note gave you the skeleton; here we walk every kind of non-regularity proof you can meet, so no exam string surprises you. Prerequisites we lean on: Finite Automata (DFA NFA), Pigeonhole Principle, and the pumping lemma statement itself.


The scenario matrix

Read this as: "what makes fall out of ?" — the mechanism of the contradiction.

Cell Case class Trap mechanism Which Example
A Equal-count pumping changes one block's count only Ex 1
B Symmetry / palindrome pumping breaks front–back mirror Ex 2
C Sparse lengths (, , primes) pumped length lands in a forbidden gap Ex 3
D Multi-block relation () $ xy \le py$ to leftmost block
E Degenerate / edge string (, tiny ) show the method still works at boundaries Ex 5
F Non-regular but PASSES the lemma (must NOT conclude regular) pumping cannot fail — lemma gives no info any Ex 6
G Real-world word problem (balanced brackets) same as equal-count in disguise Ex 7
H Exam twist: complement / intersection pump the derived language, or use closure Ex 8

Every cell A–H below gets a full worked example. Cells that are geometric-on-the-automaton get a figure.


Example 1 — Cell A: the classic equal-count

Figure — Pumping lemma for regular languages — proof and using to show non-regularity

Example 2 — Cell B: palindromes (pump down)


Example 3 — Cell C: sparse lengths (the gap argument)

Figure — Pumping lemma for regular languages — proof and using to show non-regularity

Example 4 — Cell D: three blocks with a relation

Figure — Pumping lemma for regular languages — proof and using to show non-regularity

Example 5 — Cell E: degenerate & boundary care


Example 6 — Cell F: non-regular yet PASSES the lemma (do NOT conclude regular)


Example 7 — Cell G: real-world word problem (balanced brackets)


Example 8 — Cell H: exam twist via closure


Recap of the mechanisms

The diagram below (readable in words) shows the shared spine of every attack: you pick depending on → the constraint pins → then one of four traps fires (equal-count pumps up at ; palindrome pumps down at ; sparse-length uses the gap argument; multi-block breaks the relation) → each yields contradiction, so is not regular. A separate branch shows the Cell-F escape hatch: when pumping does not fail, you must instead use closure or Myhill–Nerode.

you pick w depending on p

xy leq p pins y

equal-count: pump up i=2

palindrome: pump down i=0

sparse lengths: gap argument

multi-block: relation breaks

xy^i z not in L

contradiction so L not regular

pumping does not fail

use closure or Myhill-Nerode


Active Recall

Recall In Example 3, why does

matter rather than where sits? The string is all 's, so we cannot pin the location of ; but the leash bounds its size , and the gap between consecutive squares at is , so the pumped length can't reach the next square.

Recall Example 6 passes the pumping lemma. What did we conclude and why?

Nothing about regularity from the lemma (passing is not sufficient). We proved non-regularity separately using intersection with the regular set to isolate , then closure under intersection.

Recall Example 8's trick in one line.

Complement turns "" into ""; attack the equal-count complement with pumping, then use closure under complement to transfer non-regularity back.

Recall Why is

never a problem for our proofs? Because we always choose ourselves with , so our witness is never the empty string; and condition 1 () forbids an empty loop, so the adversary can't hand us as the pumped piece either.