UNIHIVE

Study Hub UNIPORT CSC 396

CSC 396 · Automata theory, Computability and Formal Languages

Non-regular languages and the pumping lemma

Why finite memory has limits, the pumping lemma for regular languages, and proving languages are not regular.

Our notes

2 min read

The limit of finite memory

A DFA with k states cannot count beyond k. A language that needs unbounded counting, like {aⁿbⁿ}, cannot be regular: after reading enough a's the machine must confuse two different counts.

The pumping lemma

If L is regular, there is a number p (the pumping length, at most the number of DFA states) such that every string w in L with |w| ≥ p can be split w = xyz with:

  1. |xy| ≤ p,
  2. |y| ≥ 1,
  3. xyⁱz is in L for every i ≥ 0.

Reason: reading p symbols visits p + 1 states, so some state repeats (pigeonhole principle); the loop between the repeats (y) can be taken any number of times.

Using it to prove non-regularity (a game)

  1. Assume L is regular, with pumping length p.
  2. Choose a string w in L with |w| ≥ p (you choose cleverly).
  3. Consider every split xyz allowed by conditions 1 and 2.
  4. Show some i gives xyⁱz not in L. Contradiction.

Worked example: {aⁿbⁿ : n ≥ 0}

Choose w = aᵖbᵖ. Since |xy| ≤ p, x and y are all a's, and y = aᵏ with k ≥ 1. Pump i = 2: xy²z = aᵖ⁺ᵏbᵖ, which has more a's than b's: not in L. So L is not regular.

Worked example: balanced brackets

Brackets ((( ))) behave like aⁿbⁿ with a = ( and b = ): choose (ᵖ)ᵖ; pumping adds left brackets only. Not regular. This is why compilers need grammars, not just regular expressions, to check nesting.

Other non-regular languages

  • Palindromes over {a, b}.
  • {aⁿ : n is a perfect square} and {aⁿ : n is prime}.
  • {w : equal numbers of 0s and 1s}.

Using closure instead

If L ∩ (a regular language) is non-regular, L is non-regular. Equal 0s and 1s intersected with 0*1* gives {0ⁿ1ⁿ}: non-regular, so the original is too.

What the lemma cannot do

It can prove a language is not regular; it can never prove one is regular (some non-regular languages also satisfy it). To show regularity, build an automaton or expression.

Exams usually ask

  • State the pumping lemma for regular languages and explain why it holds.
  • Prove a given language is not regular.
  • Explain why balanced brackets need more than a finite automaton.

Common mistake

Choosing one convenient split xyz. You must show that every allowed split fails; only the string w is yours to choose.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

No reading links here yet

Our team adds free books, videos and practice for each topic, and opens every link before it goes up.

All CSC 396 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.