Let be the diagonal halting set, which is undecidable. The pumping argument below actually holds for every subset ; nonregularity needs the stated convention, or at least a set of exponents whose unary language is nonregular.
The pumping lemma for regular languages holds with pumping length one. For an accepted nonempty word, pump its first symbol. A word containing only s remains in even if that symbol is deleted. If there is a zero and a nonempty prefix before its last zero, pumping the first symbol leaves the last zero and its following ones unchanged. If the word is , pumping its initial zero produces ; this is accepted for , and for it belongs to . In every case the pumped substring is nonempty and lies in the first position.
If were a regular language, closure under intersection would make
regular. A finite-state automaton for this intersection would decide membership of in the diagonal halting set by reading , a contradiction. Thus satisfies the pumping lemma but is not regular, under the usual meaning of . If were arbitrary, the printed conclusion would be false, for example for .
The pumping lemma for context-free languages states that every context-free language has a pumping length such that every with can be written
with , , and for every integer .
This language is not context-free. Let be a proposed pumping length and choose with . In any pumping decomposition of the unary word , pumping once more increases its length by an integer with . But
so the pumped length is not a power of three, contrary to the pumping lemma for context-free languages. This is also an instance of the fact that a unary context-free language is regular, whereas the powers of three are not ultimately periodic.
Let
Intersect it with the regular language
Every word of contains exactly two copies of . If it is a proper power, its exponent must therefore be two and its root must contain one . Hence
This language is not regular: if were a pumping length, pumping any nonempty substring among the first copies of in would change only its first -block. Since regular languages are closed under intersection,
This is the proper-power language is not regular.
The language is not context-free. Suppose it had pumping length in the pumping lemma for context-free languages, and apply the lemma to . Write with , , and for every .
Let and be the respective numbers of s and s in . If , pumping with or destroys equality of the two block lengths. Hence a valid decomposition would require . Pumping with would then produce , where . But
so is not a square number. This contradiction proves the square-count language is not context-free.