Search code examples
computer-sciencediscrete-mathematicsregular-languageformal-languages

Why is the complement of a regular language still a regular language?


According to my textbook, the complement of L1 = A* - L1 is a regular language as long as L1 is a regular language.
Doesn't A* also include Context Free languages, Context Sensitive languages, and Recursively Enumerable languages? A*-L1 would include all of them too, wouldn't it? How can it be regular then?
Under the representation of a Finite State Machine I understand why the complement is still a regular language. However, I can't understand the theory behind it.

Also, A* - L1 = A* intersection complement(L1) . Isn't defining a complement with something defined by the complement a tautology? I don't really understand how that can be valid.

Thanks.


Solution

  • I think where you are confused is that when you say "Doesn't A* also include Context Free languages, Context Sensitive languages, and Recursively Enumerable languages?" you are confusing A*, which is a set of strings, with Powerset(A*), which is a set of languages.

    It is true that Powerset(A*) - {L1} is a set containing "Context Free languages, Context Sensitive languages, and Recursively Enumerable languages" but it actually isn't relevant to the theorem which just says: given any regular language L (a set of strings), then the language A*-L, also a set of strings, is also a regular language.

    TL;DR there's a confusion between levels in your question: sets of strings vs. sets of languages. Any two-partition of A* into L and A*-L in which L is regular must also have A*-L regular. A* does not and cannot "contain languages" because it is a set of strings.

    To your second question:

    Also, A* - L1 = A* intersection complement(L1) . Isn't defining a complement with something defined by the complement a tautology?

    Nice question. I suspect if this is presented as a definition, that is just defining operator -. It is not defining the "complement function" as far as I can tell. Perhaps "complement" was already defined, and your book is now trying to define the subtraction operator. Or else this is a theorem rather than a definition.