Show that the following language L is not regular. L = {a^m b^p | p is not a multiple of m}. There are two methods to solve this problem. One is directly to use the pumping lemma. The other is to use closure properties followed by the pumping lemma. Let us look at each method. You will see that the second method is quite a bit easier, showing that it sometimes pays off to think a bit about closure properties when things start to look complicated. 1) Using pumping lemma. Let n be the pumping lemma constant. We have to pick a string w in the language. Let us pick w = a^{m} b^p, where m is a *prime* number larger than n. [Note that there are infinitely many primes, so there must be such a prime.] We will later have to decide what p should be, but p should not be a multiple of m for the string to be in the language. Now the adversary splits up the string into x,y,z such that. |xy| <= n, and |y| >=1. This means that x and y only contain a's. If y = a^k, then xy^iz = xyy^{i-1}z = a^{m+(i-1)k} b^p. To derive a contradiction, we should make p, a multiple of m+(i-1)k. But p should not be a multiple of m so that a^m b^p is in L. Pick p = m+n!. Note that p is now not a multiple of m. Why? Assume it is a multiple of m. So p-m = n! is also a multiple of m. But since m is a prime, it does not have any prime factors less than m. Since n! = 2.3....n, and n < m, it does not have m as a prime factor. So it is not a multiple of m. So p is not a multiple of m. Let us choose i by setting m+(i-1)k = p = m+n! So (i-1)k = n! and i = n!/k + 1. Since k <= n, it divides n! and so i is an integer. In other words, by setting p = m+n! and choosing i = n!/k + 1, we can derive a string a^{m+(i-1)k} b^p, where p = m+(i-1)k that should not be in the language, but according to pumping lemma it should be. So we have a contradiction. 2) Using closure properties. It is often easier to use closure properties whenever the condition of the language is "negative" as in this example. We proceed as follows. Let us assume that L is regular, and let L' be its complement. If L is regular so is L' by the closure theorems. L1 = L' \intersection a*b* = {a^m b^p | p is a multiple of m}. Since a*b* is regular, and L' is regular, L1 should be regular. We now show that L1 is *not* regular using Pumping Lemma. Let m be the pumping lemma constant. Choose w = a^m b^m. m is a multiple of m, so w is in L1. Let the adversary split w as xyz. Since |xy| <= m, x and y contain only a's. Set i = 2. w_i = a^{m+k} b^m. Since m cannot be a multiple of m+k (note k >= 1), we recahed a contradiction, and L1 cannot be regular. This in turn implies that L cannot be regular.