Operations on Regular Languages#
Lets take the following two languages:
 2024-09-24 19.48.23.excalidraw.png)
 2024-09-24 19.51.35.excalidraw.png)
However, what if I gave the set . Is it possible to construct a DFA for from the DFAs for and ? Let us call this DFA . What state should maintain?
In some way, we want to simultaneously execute both and on its input. What if we were to store the state of M as some sort of tuple, like (state of , state of )? This way, we can essentially simulate two DFAs, where we have a state , and for a processed letter, we go to the states that each DFA would have individually gone to, giving us .
For the previous DFA, that would look like this:

This is the DFA , that accepts a string iff it is accepted by and .
Formal Definition#
Given two DFAs:
For where , is defined as the following:
-
- Note: this is cartesian product
This method, however, creates a large number of states. Specifically, it creates the states, where and are the number of states of their respective DFAs. However, it is proven that this is the optimal solution.
Closure Under Intersection#
Theorem: The class of regular languages is closed under intersection
Proof: Consider two regular languages and . By definition of regular languages, there must exist DFAs and that define the two languages. Using the product construction just defined, we can construct , which will define . This proves that is regular.
Union#
Theorem: The class of regular languages is closed under union
Proof: Consider two regular languages and . By definition of regular languages, there must exist DFAs and that define the two languages. Is there a way we can modify the product/intersection construction to create a DFA that works on the union of these two languages?
It is actually very simple to do this. Currently, the above construction simulates both DFAs. However, the set of accepting states for it is only the cartesian product of the set of accepting states for both DFAs. That is to say, if and only if . If we were to change that to be that the set of accepting states was whether or , then this would be a valid DFA for the union of the languages, since a string is accepting if and only if it is accepted by or .
Formal Definition#
Given two DFAs:
For where , is defined as the following:
-
- Note: this is cartesian product
This also proves the above theorem.
Closure Under Complementation#
The complement of a language is simply the set of strings that are not in the language.
If we know to be regular, then can we conclude is also regular?
Yes. All we need to do is toggle the role of accepting and rejecting states. If was an accepting state in , then it is now a rejecting state in and vice versa.
Formal Definition#
Given two DFAs:
For where , is defined as the following:
-
- Note: this is cartesian product
Language Concatenation#
The concatenation of strings and is defined as . The concatenation of two languages and is defined as . That is, a string is in if it can be split into two (not necessarily equal) strings such that the first part is in and the second part is in .
Example
- Let be the set of strings that end with
- Let be the set of strings containing only
- Then, is the set of strings that has an that is followed by only
Theorem: The class of regular languages is closed under concatenation
Proof: Consider two regular languages and . By definition of regular languages, there must exist DFAs and that define the two languages. We can construct a DFA that defines where
To construct this, however, we need another important concept
NFAs with -Transitions#
An -Transition is a transition in which the state may change without consuming any input. In the execution tree, this is basically creating two threads without actually consuming a letter. Remember that a string is accepted as long as some execution path succeeds.
Consider the following -NFA
 2024-09-24 21.33.10.excalidraw.png)
If you try, you can see that this accepts , but does not accept .
The transition function now takes the structure of . The empty transitions do not increase expressiveness: an -NFA can still be compiled into an equivalent DFA just by modifying the subset construction.
Towards Concatenation Construction#
Given an input , needs to check that it is possible to split it into two parts such that each are accepted by and respectively. Intuitively, should first act like , and then when is in a final state, start acting like for the remainder of the string. The challenge comes with when deciding to switch or and try with a different partition of substrings.
However, using an -NFA, we can get a pretty easy solution to this. When we are a final state for , we can simply put a -transition to the initial state of . This way, will continue running on its own thread for the entire string. However, for every substring for which is satisfied, we will be at a final state, so we will start a new thread at the beginning of for the remaining of the string in that instance. This way, we will be able to test every partition for which the first substring is valid under .

Formal Definition#
Given two DFAs:
For where , is defined as the following -NFA:
This also proves the above theorem that regular languages are closed under construction.
Extra Operations#
Prefix Operation A string is defined as a prefix of if for some string .
Theorem: Regular languages are closed under the prefix operation
Shuffle Operation A string is a shuffle of if it can be obtained by permuting(shuffling) the characters in .
Theorem: Regular languages are not closed under the shuffle operation
To recap, regular languages are closed under union, intersection, complementation, concatenation, prefix, but not shuffle.