Skip to content
Part IA Michaelmas, Lent Term

Closure Properties of Regular Languages

Overview

Regular languages are closed under many operations, meaning: applying the operation to regular languages yields another regular language.

This is proved using automata or regular expressions.

Union

Theorem: If L1L_1 and L2L_2 are regular, then L1L2L_1 \cup L_2 is regular.

Proof (NFA)

Given DFAs M1M_1 and M2M_2:

  1. Create new start state s0s_0
  2. Add ε\varepsilon-transitions to s1s_1 and s2s_2
  3. Accepting states: F1F2F_1 \cup F_2

Proof (Regex)

If Li=L(Ri)L_i = L(R_i), then L1L2=L(R1R2)L_1 \cup L_2 = L(R_1 | R_2).

Concatenation

Theorem: If L1L_1 and L2L_2 are regular, then L1L2L_1 \cdot L_2 is regular.

Proof (NFA)

Given NFAs M1,M2M_1, M_2:

  1. Add ε\varepsilon-transitions from F1F_1 to s2s_2
  2. Start: s1s_1
  3. Accepting: F2F_2

Proof (Regex)

If Li=L(Ri)L_i = L(R_i), then L1L2=L(R1R2)L_1 \cdot L_2 = L(R_1 R_2).

Kleene Star

Theorem: If LL is regular, then LL^* is regular.

Proof (NFA)

  1. Create new start/accept state q0q_0
  2. Add ε\varepsilon-transition q0sq_0 \to s
  3. Add ε\varepsilon-transitions from each fFf \in F to ss
  4. Add ε\varepsilon-transition from each fFf \in F to q0q_0
  5. Accepting: {q0}\{q_0\}

Proof (Regex)

If L=L(R)L = L(R), then L=L(R)L^* = L(R^*).

Complement

Theorem: If LL is regular, then Lˉ=ΣL\bar{L} = \Sigma^* \setminus L is regular.

Proof (DFA)

Given DFA M=(Q,Σ,δ,s,F)M = (Q, \Sigma, \delta, s, F):

Define Mˉ=(Q,Σ,δ,s,QF)\bar{M} = (Q, \Sigma, \delta, s, Q \setminus F).

Swap accepting and non-accepting states.

Note: Requires complete DFA (all transitions defined).

Intersection

Theorem: If L1L_1 and L2L_2 are regular, then L1L2L_1 \cap L_2 is regular.

Proof (DFA Product Construction)

Given DFAs M1=(Q1,Σ,δ1,s1,F1)M_1 = (Q_1, \Sigma, \delta_1, s_1, F_1) and M2=(Q2,Σ,δ2,s2,F2)M_2 = (Q_2, \Sigma, \delta_2, s_2, F_2):

Define product DFA M=(Q,Σ,δ,s,F)M = (Q, \Sigma, \delta, s, F):

  • Q=Q1×Q2Q = Q_1 \times Q_2
  • δ((q1,q2),a)=(δ1(q1,a),δ2(q2,a))\delta((q_1, q_2), a) = (\delta_1(q_1, a), \delta_2(q_2, a))
  • s=(s1,s2)s = (s_1, s_2)
  • F=F1×F2F = F_1 \times F_2

Product accepts iff both components are accepting.

Proof (De Morgan)

L1L2=Lˉ1Lˉ2L_1 \cap L_2 = \overline{\bar{L}_1 \cup \bar{L}_2}

Use closure under complement and union.

Difference

Theorem: If L1L_1 and L2L_2 are regular, then L1L2L_1 \setminus L_2 is regular.

Proof

L1L2=L1Lˉ2L_1 \setminus L_2 = L_1 \cap \bar{L}_2

Use intersection and complement.

Homomorphism

Theorem: If LL is regular and h:ΣΓh : \Sigma^* \to \Gamma^* is a homomorphism, then h(L)h(L) is regular.

Proof (Regex)

Apply hh to each symbol in the regex.

Inverse Homomorphism

Theorem: If LΓL \subseteq \Gamma^* is regular and h:ΣΓh : \Sigma^* \to \Gamma^* is a homomorphism, then h1(L)h^{-1}(L) is regular.

Proof (DFA)

Given DFA MM for LL, construct MM' where:

δ(q,a)=δ^(q,h(a))\delta'(q, a) = \hat{\delta}(q, h(a))

Run MM on the image of each input symbol.

Reversal

Theorem: If LL is regular, then LR={wR:wL}L^R = \{w^R : w \in L\} is regular.

Proof

Reverse all transitions in an NFA, swap start and accept, convert to DFA.

Properties Summary

OperationConstructionNotes
UnionNFA with ε\varepsilon-edgesEasy
ConcatenationNFA with ε\varepsilon-edgesEasy
StarNFA with loop backEasy
ComplementSwap accept/non-accept in DFANeeds complete DFA
IntersectionProduct DFAQuadratic states
DifferenceL1Lˉ2L_1 \cap \bar{L}_2Via intersection and complement
ReversalReverse NFASwap start/accept
HomomorphismApply to regexSymbol-wise
Inverse homomorphismDFA transformationEfficient

Summary

  • Regular languages are closed under: \cup, \cdot, *, ˉ\bar{\cdot}, \cap, \setminus, reversal
  • Union/concat/star: easy with NFAs
  • Complement: easy with DFAs, hard with NFAs
  • Intersection: product construction or complement + union