Intersection of regular languages
Let L1, L2 be two regular languages. We will prove that their intersection L = L1 ∩ L2 is also a regular language.
The idea of the proof
We have two regular languages L1 and L2 and we want to prove that their intersection L1 ∩ L2 is again a regular language. Since L1 and L2 are regular languages, there are finite automata A1 and A2 that accept the languages L1 and L2, so L(A1) = L1 and L(A2) = L2. We will now construct a finite automaton A that accepts the language L1 ∩ L2, which proves that the language L1 ∩ L2 is regular.
A string belongs to the intersection of the languages if it belongs to both L1 and L2. So the string must be accepted by the automaton A1 and at the same time by the automaton A2. We use exactly the same idea as we used for the union of regular languages; we only change the set of accepting states.
Formalisation of the procedure
We have two automata,
We construct an automaton A = ⟨Q, Σ, δ, q, F⟩ that accepts the language L(A1) ∩ L(A2). Here
- Q = Q1 × Q2
- Σ= Σ1 ∩ Σ2
- q = ⟨q0, p0⟩
- F = F1 × F2
For the transition function δ the following holds:
Example
Let us take this automaton A1, which accepts all strings that contain an even number of 1s:
and the automaton A2, which accepts strings containing an odd number of 0s:
We construct an automaton that accepts the intersection of these languages. The set of states of this automaton has the form Q = Q1 × Q2, the start state is ⟨q0, p0⟩ and the accepting states are F1 × F2:
Next we complete the transitions so that δ(⟨q,p⟩, a) = ⟨δ1(q, a), δ2(p, a)⟩:
In this automaton, for example, from the state ⟨q0, p0⟩ there is a transition on the symbol 0 to the state ⟨q0,p1⟩. This means that the automaton A1 has a transition on the symbol 0 from the state q0 back to q0. The automaton A2, in turn, has a transition on the symbol 0 from the state p0 to the state p1.
We can try the automaton out. It should accept strings such as 110 or 00000 (they contain an even number of 1s and at the same time an odd number of 0s), but it should not accept strings such as 11, 111, 1010.
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