Pumping Lemma Game: Refuting Regularity
A game for practicing the pumping lemma for regular languages: choose a word, let the adversary split it, and see whether you can pump it out of the language.
Last updated:
Which word makes the adversary lose?
The pumping lemma is a necessary condition that every regular language satisfies.
Using it to refute regularity is a game with alternating moves:
To refute regularity you play against that claim:
- The adversary announces the number . You do not know it, so your word must be written as a formula in .
- You choose a word with .
- The adversary chooses a split with and , the hardest one for you.
- You choose so that .
You win if your word beats every split the adversary may choose.
Then the assumption that is regular leads to a contradiction.
Play
Choose a language, type a word in mathematical notation, and predict the result before you check.
The word may contain only letters of the language’s alphabet and the pumping length (inside exponents).
The adversary chooses , so you do not. A word that beats the page’s tests is strong evidence, not a proof.
The proof is the written argument, which works for every at once.
What the page tests
The page tests your word for many values of , from 3 up to 1,000,000, because a good word must work for every .
For each it tries the exponents on the splits:
all of them for small , and for large every split near the place where one run of equal letters ends and the next begins (for example between the ‘s and the ‘s) plus a random sample.
How to write the word
Write the word with the letters of the alphabet, side by side, and use only in exponents.
An exponent is written after ^: a number, N, or an expression in braces.
Spaces are ignored.
a^N b^N:a^{N+1} b^N:a^{2N},a^{N^2}: ,(ab)^N: the word repeated timesε: the empty word
The game needs JavaScript. Use the questions below instead.
Try to win on every language in the list.
Build the proof
In an exam you must write the proof, not only find a good word.
Here the proof is built step by step. Each step has a field, the page checks it, and when all the steps are right the page writes the proof for you.
Steps 1 and 2 are always the same, steps 3 to 5 are yours. Note that here you choose one that works for every split; in general the lemma allows to depend on the split, so this is a simplified format that suits words like .
This part needs JavaScript. Use the written proof below the game.
- Step 1. Assume, for contradiction, that the language L is regular.
- Step 2. Then the pumping lemma holds for some number N. You do not know it, so everything below is written in terms of N.
- Step 3. Choose a word w ∈ L with |w| ≥ N, written in terms of N.
- Step 5. Choose the number of repetitions i (from 0 to 4) that takes xyiz out of L for every split.
- Step 6. The word xyiz is not in L, which contradicts the lemma, so L is not regular. The page writes this step for you.
Questions
Question 1. In the language with the word , why can contain only ‘s?
Hint
Which part of the word do the first letters cover, and what does the condition say about where ends?
Answer
The first letters of are all ‘s, and lies inside them because .
So with , and pumping changes only the number of ‘s.
Question 2. For the language of words with equally many ‘s and ‘s, why does the word not beat the adversary?
Hint
Look for a split where itself contains equally many ‘s and ‘s.
Answer
Take and . Pumping gives , which always has equally many ‘s and ‘s, so it stays in the language for every .
The adversary wins with this split. (This needs so that . If the lemma gives , any larger number also works as the pumping length, so we may assume .)
Question 3. Can you refute the regularity of with the pumping lemma?
Answer
No, because this language is regular: a deterministic finite automaton with three states (one of them a trap state) recognizes it.
The pumping lemma is only a necessary condition, and a regular language satisfies it, so no choice of word can defeat the adversary.
A written proof for
Assume, for contradiction, that is regular. Then the pumping lemma holds for some .
Choose with . For every split with and , we have for some , because and the first letters of are all ‘s.
For the word has more ‘s than ‘s, so it is not in .
This contradicts the lemma, so is not regular.
Back to Combining Automata: Complement and Product, or see the glossary.