Hello! Welcome back to our study of the theory of computation.
In our last lesson, we explored the limitations of regular languages using the Pumping Lemma. We developed a formal method to prove that certain languages, like , are not regular because they require memory and counting abilities that finite automata lack.
Today, we will pivot from the limitations of regular languages to their strengths and robustness. We will investigate their closure properties. A class of languages is "closed" under an operation if applying that operation to languages in the class yields a new language that is also in the same class. For example, the integers are closed under addition because adding any two integers results in another integer.
This lesson addresses the learning outcome: Prove the closure properties of regular languages (union, intersection, complement, concatenation, Kleene star) using automata-based constructions. We will show that if you take one or more regular languages, you can combine them using these fundamental operations, and the result is always another regular language.
1. Closure Under Complement, Union, and Intersection
We'll begin with three operations that can be proven using a clever, deterministic construction on DFAs. The core idea is to build a new machine that simulates two (or more) DFAs in parallel.
Closure Under Complement
The complement of a language over an alphabet , denoted , is the set of all strings in that are not in .
If is regular, is also regular? Yes, and the construction is surprisingly simple.
Construction:
- Start with a DFA that accepts .
- Crucially, ensure is complete: for every state, there must be an outgoing transition for every symbol in the alphabet. If not, add a non-final "trap state" and direct all missing transitions there.
- Create a new DFA, , which is identical to except that you swap the final and non-final states. Every state that was an accepting state in is now a non-accepting state in , and vice-versa.
This new machine accepts a string if and only if the original machine did not end in a final state after processing . Therefore, accepts , proving that the class of regular languages is closed under complementation.
Properties of Regular Languages
The following lecture slide provides a concise visual for this construction.
Please review slide 24, titled 'RLs are closed under complementation'. It shows exactly how the final and non-final states are swapped to create the DFA for the complement language.
Closure Under Union and Intersection (The Product Construction)
To prove closure under union () and intersection (), we use a powerful technique called the product construction (or cross-product).
The intuition is to build a single DFA that runs two DFAs, and , simultaneously on the same input string. To do this, the state of our new machine will be a pair of states , where is the current state of and is the current state of . This is conceptually similar to running two concurrent processes and tracking the state of both.
The following video provides an excellent, step-by-step walkthrough of building a product automaton from scratch for the union of two example languages.
Regular Languages Closed Under Union/Intersection (Product Construction)
This video from Easy Theory will show you how to build a product automaton. Pay close attention to how the new states are created as pairs and how the transitions are defined based on the original machines.
Watch from 03:10 to 12:58. The video first defines two simple languages and their DFAs. It then builds the product machine state-by-state. The key moment is at 11:23, where it explains how the choice of final states determines whether the machine accepts the union or the intersection.
Let's formalize the construction seen in the video. Given two DFAs, for language and for , we construct a new DFA :
- States : The Cartesian product of the original state sets: . Each state is a pair where and .
- Start State : The pair of the original start states: .
- Transition Function : On reading symbol from state , the new machine transitions to the pair of states that the original machines would have transitioned to:
- Final States : This is where union and intersection differ.
- For Intersection (): The new machine accepts if both original machines accept. So, a state is final if and .
- For Union (): The new machine accepts if either of the original machines accepts. So, a state is final if or .
- For Intersection (): The new machine accepts if both original machines accept. So, a state is final if and .
Since we can construct a DFA for both the union and intersection, the class of regular languages is closed under these operations.
DFA's, NFA's, Regular Languages
For a more formal, mathematical summary of the product construction, refer to these lecture notes.
Read Section 3.2, 'The "Cross-product" Construction' (pages 68-72). This text formalizes the construction we just saw, clearly defining the 5-tuple for the new DFA and proving its correctness for intersection, union, and even set difference.
Test your understanding!
Using the logic of the product construction, how would you define the set of final states for the set difference operation ? (This operation includes all strings that are in but not in ).
Show answer
For a string to be in , it must be accepted by AND rejected by . Therefore, the final states in the product automaton must be those where is a final state in and is a non-final state in .
Formally: .
2. Closure Under Concatenation and Kleene Star
While the product construction is elegant for DFAs, it doesn't easily extend to concatenation and Kleene star. The problem is that a DFA must decide where one string ends and the next begins, but it has no way to "look ahead." This requires a form of guessing, which is precisely the power that Nondeterministic Finite Automata (NFAs) provide. Using NFAs with -transitions makes these proofs remarkably intuitive.
The following video shows how the challenge of proving closure for concatenation motivates the use of nondeterminism and then demonstrates the simple, elegant constructions for union, concatenation, and Kleene star using NFAs.
2. Nondeterminism, Closure Properties, Conversion of Regular Expressions to FA
This MIT OpenCourseWare lecture provides the key constructions for proving closure under union, concatenation, and Kleene star using the power of nondeterminism.
Please watch the following segments: Union (36:00 - 40:34): See how an NFA with ε-transitions provides a much simpler construction for union than the product construction. Concatenation (40:34 - 44:11): This is the core of this section. Watch how ε-transitions are used to 'jump' from the end of the first machine to the start of the second, perfectly solving the 'guessing the split point' problem. Kleene Star (44:11 - 51:34): Observe how ε-transitions are used to create loops for repetition and to handle the empty string case.
Let's summarize these powerful NFA-based constructions.
Union ()
Given two NFAs, and , create a new NFA by:
- Creating a new start state.
- Adding -transitions from the new start state to the original start states of and .
The machine nondeterministically "chooses" which path to follow. If either path leads to acceptance, the whole machine accepts.
Concatenation ()
Given and , create a new NFA where:
- The start state of is the start state of .
- The final states of are the final states of .
- Add -transitions from every final state of to the start state of .
When the machine reaches a final state in , it can nondeterministically jump to the start of to process the rest of the string.
Kleene Star ()
Given an NFA , create a new NFA by:
- Creating a new start state that is also a final state (to accept ).
- Adding an -transition from the new start state to the original start state of .
- Adding -transitions from every original final state of back to the original start state of . This creates the "zero or more" repetition loop.
The image below provides a clean visual summary of these three NFA constructions.

Since we can construct an NFA for each of these operations, and we know from a previous lesson that every NFA can be converted to an equivalent DFA, we have proven that the class of regular languages is also closed under union, concatenation, and Kleene star.
Conclusion
Today, we established the remarkable robustness of the class of regular languages. They are a self-contained family, closed under all the fundamental operations of set theory and string manipulation.
Key Takeaways:
- Closure Property: A class of languages is closed under an operation if applying that operation to languages in the class produces a language that is also in the class.
- Regular Languages are Closed Under:
- Union, Intersection, Complement: These can be proven using the product construction on DFAs, which simulates two machines in parallel. The definition of final states determines the specific operation.
- Concatenation and Kleene Star: These are proven most easily using NFA constructions with -transitions. Nondeterminism elegantly solves the problem of guessing where one part of a string ends and another begins.
Preview of the Next Lesson:
Our closure constructions, particularly the product construction and NFA-to-DFA conversion, can result in automata with a very large number of states. This raises a practical question: is this the smallest machine possible? In the next lesson, we will address this by learning how to minimize DFAs. We will learn an algorithm to find and merge indistinguishable states, resulting in a unique minimal DFA for any given regular language.