Using Closure Properties to Show Nonregularity
Learn how to use closure properties to show that a language is not regular.
We'll cover the following
Proving languages are not regular using closure properties
Using our knowledge of a few nonregular languages, we can conclude that other languages are nonregular merely by using the closure properties of regular languages. For example, the language NOTPRIME ( where is not prime) is not regular. If it were, then its complement, PRIME ( where is prime), would also be, but we know that PRIME is not regular, so NOTPRIME can’t be regular since regular languages are closed under complement.
It is fruitless to attempt to use the pumping theorem on a language like this, defined with a negative (e.g., using “not”). Instead, we show its complement is not regular. Depending on the language, other closure properties can be used to show that a language is not regular.
We can also show that the language EQUAL, defined as (i.e., strings where the number of ’s and ’s are equal, but the letters can appear in any order), is not regular by applying the pumping theorem to the string (remember, we can choose any qualifying string in the language). But we can use the closure properties of regular languages to avoid having to use the pumping theorem. Consider the set of strings formed by the intersection EQUAL . This is the set of strings of ’s and ’s where the number of each letter is equal, but also where the ’s must precede the ’s. But this is also the language , which we already know is not regular. Since represents a regular language, then EQUAL must not be regular because regular languages are closed under intersection.
The language is not regular (notice the , which implies a “not”). Since we don’t get to choose the size of , it is possible that pumping will leave the number of ’s unequal to the number of ’s. In general, we can’t prove a negative with any theorem directly. This language is not the complement of , by the way, because also includes strings that aren’t necessarily a run of ’s followed by a run of ’s, no matter the number of occurrences of each character (strings like , as well as strings like , and ). However, does include all the strings in , which are run of ’s followed by a run of ’s, so we can compute the following difference:
Get hands-on with 1400+ tech skills courses.