In our previous lesson, we established the formal vocabulary of alphabets, strings, and languages. This provided us with a mathematical framework for describing sets of sequences, which in turn represent computational problems. Now, we will build upon that foundation by learning how to construct new, more complex languages from existing ones.
This lesson focuses on the three fundamental operations on languages: union, concatenation, and the Kleene star. These operations form a powerful toolkit for defining and manipulating languages. Mastering them is essential, as they are the building blocks for regular expressions and are intrinsically linked to the capabilities of the finite automata we will begin studying in the next lesson.
From String to Language Operations
Before we operate on entire languages (which are sets of strings), let's first formalize the most basic operation between individual strings: concatenation.
Definition: String Concatenation
Given two strings and over an alphabet , their concatenation, written as , is the string formed by appending to the end of .
Given your background in mathematics, a more formal definition will be satisfying. If we define a string of length as a function and a string of length as a function , their concatenation is a new string of length defined as:
This definition precisely captures the idea of placing the symbols of immediately after the symbols of . Key properties of string concatenation include:
- Associativity: for any strings .
- Identity Element: The empty string is the identity for concatenation: for any string .
With this string-level operation in hand, we can now "lift" it to the level of languages and introduce the other core operations.
The Regular Operations
The three operations of union, concatenation, and Kleene star are so fundamental to this field that they are collectively known as the regular operations.
Regular operations and regular expressions
This document from the University of Waterloo provides concise, formal definitions for the three regular operations on languages.
Please read the definitions for Union and Concatenation. Then, read the definition for Kleene star. Focus on understanding how each operation produces a new language (a set of strings) from one or two input languages.
Let's examine each of these operations in more detail, with examples to solidify your understanding.
1. Union
As you've already seen from your set theory background, the union of two languages and , written , is simply the set of all strings that are in , or in , or in both.
For example, if and , then .
2. Concatenation
Language concatenation builds directly on string concatenation. The concatenation of two languages and , written , is the set of all strings that can be formed by taking any string from and concatenating it with any string from .
Crucially, the order matters. The string from must come first. This means that, in general, . Concatenation is not commutative.
The image below gives a clear visual summary for the concatenation of two sets of strings, A and B.

Let's watch a short video that walks through a concrete example of both union and concatenation.
Operations on Regular Languages
This video from Neso Academy clearly demonstrates how to perform these operations on two finite languages.
Watch the segment from perform Union, where the presenter calculates A U B and A concatenated with B for specific sets A and B.
3. Kleene Star (or Kleene Closure)
The Kleene star is perhaps the most powerful of the three operations. The star of a language , written , is the set of all strings that can be formed by taking any number of strings from (including zero) and concatenating them together.
The formal definition can be expressed as an infinite union:
Here, represents the language formed by concatenating strings from .
- (the concatenation of zero strings is defined as the empty string).
- ...and so on.
A critical consequence of this definition is that for any language , the empty string is always an element of , because it is always in .
The visual summary you saw earlier also provides a clear definition of the Kleene Closure. Note the summation-style notation which is equivalent to the infinite union.
A related operation is the positive closure, denoted , which is the set of strings formed by concatenating one or more strings from .
The relationship between the two is straightforward:
Now, let's see an example of the Kleene star operation.
Operations on Regular Languages
Continuing with the same video, let's see the star operation applied.
Watch the segment from a star. Pay close attention to how strings are formed by choosing elements from the set A multiple times and in different orders, and note the inclusion of \epsilon.
Practice Exercise
To put these definitions into practice, consider the following languages over the alphabet :
Determine the elements of the following languages. Take a moment to write them down before revealing the solution.
- (List at least 8 distinct strings)
Solution
-
: This is the set of all strings present in either language.
-
: We take each string from and append each string from .
afrom +abfromaabafrom +bafromababfrom +abfrombabbfrom +bafrombba
-
: We take each string from and append each string from . Notice this demonstrates non-commutativity.
abfrom +afromabaabfrom +bfromabbbafrom +afrombaabafrom +bfrombab
(Note: )
-
: The set of all strings made by concatenating zero or more strings from .
- Zero strings:
- One string:
- Two strings:
- Three strings:
...and so on. In fact, is the set of all possible strings over the alphabet , which we previously denoted as .
A sample of strings in is:
Conclusion
In this lesson, we have defined and practiced the three regular operationsāunion, concatenation, and Kleene starāwhich allow us to combine and construct languages in powerful ways.
Here are the key takeaways:
- Union () combines the strings from two languages into a single larger language, just like set union.
- Concatenation () creates a new language by appending each string of to each string of . The order is crucial, and the operation is not commutative.
- Kleene Star () generates an infinite language containing all possible strings formed by concatenating zero or more strings from . The empty string, , is always a member of .
These operations are not just abstract definitions. They form the algebraic basis for regular expressions, a powerful text-matching tool you may have encountered in programming. More importantly for this course, they exactly characterize the descriptive power of our first class of computational models.
In the next lesson, we will formally define the Deterministic Finite Automaton (DFA). We will see that the set of all languages that can be recognized by a DFAāthe "regular languages"āis precisely the set of languages that can be built up from simple starting blocks using these three operations.