Concatenation of regular languages
Let L1, L2 be two regular languages. We will prove that their concatenation L = L1 ∘ L2 is also a regular language.
What concatenation is
Concatenating the two strings “010” and “1111” gives the string “0101111”. Concatenating languages therefore produces a new language, which we build by concatenating every string from one language with every string from the other. We denote the concatenation of two strings or two languages with a small circle: ∘. We can then define the concatenation of the languages L1 and L2 as follows:
Idea of the proof
We have two regular languages L1, L2 and two automata that accept these languages:
We construct a non-deterministic automaton A = ⟨Q, Σ, δ, q, F⟩ that will “contain” both automata A1 and A2. The basic idea is that we start reading the string with the automaton A1, and when A1 reaches an accepting state, we try to accept the rest of the string with the automaton A2. If this automaton accepts that part of the string too, then the automaton A accepts the string.
Example
Let A1 be this automaton, which accepts non-empty strings made up only of zeros, and strings made up of a 1 followed only by zeros (1, 10, 100, …):
and let A2 be this automaton, which accepts strings that end in 01:
We join the automata by adding epsilon transitions from all the accepting states of A1 to the start state of A2, and then turning the accepting states of A1 into ordinary states. The start state of the whole new automaton will be the start state of A1:
How will the automaton work? We start by simulating the automaton A1. If we move to a former accepting state q1 or q2, we know that A1 accepts part of this string. For the whole string to belong to the language L1 ∘ L2, the rest of the string must still be accepted by the second automaton A2 – that is why epsilon transitions lead from all the former accepting states to the original start state of A2.
As an example, take the string 0001. It belongs to the concatenation of both languages, because the string can be formed by concatenating the strings 00 ∘ 01. But it can equally be formed by concatenating the strings 0 ∘ 001. In our automaton we can simulate both ways. The automaton can follow this path:
On this path the automaton first “accepts” the part 00 of the string and then the part 01. Or it can follow this path:
and the automaton would first “accept” the part 0 and then the part 001. In both cases we of course end up in the accepting state p2.
Formal construction
Once more: we have two regular languages L1, L2 and two automata that accept these languages:
We construct a non-deterministic automaton A = ⟨Q, Σ, δ, q, F⟩ for which the following holds:
- Q = Q1 ∪ Q2 (we also assume that Q1 ∩ Q2 = ∅)
- Σ= Σ1 ∪ Σ2
- q = q0
- F = F2
We build the transition function δ step by step:
Sources
Chapters: Closure of regular languages, Union of regular languages, Intersection of regular languages, Difference of regular languages, Complement of a regular language, Concatenation of regular languages, Kleene closure of a regular language