Chapter 4: Properties of Regular
Languages
Quan Thanh Tho
Theorem 4.1
If L
1
and L
2
are regular, then so are L
1
∩L
2
, L
1
∪L
2
, L
1
L
2
,
L
1
,
L
1
*.
(The family of regular languages is closed under intersection, union,
concatenation, complement, and star-closure.)
Proof
•
L
1
= L(r
1
) L
2
= L(r
2
)
L(r
1
+
r
2
) = L(r
1
)∪L(r
2
)
L(r
1
. r
2
) = L(r
1
)L(r
2
)
L(r
1
*) = (L(r
1
))*
Proof (cont’d)
•
M = (Q, Σ, δ, q
0
, F) accepts L
1
.
M = (Q, Σ, δ, q
0
, Q – F) accepts L
1
.
Proof (cont’d)
M1 = (Q, Σ, δ1, q0, F1) accepts L1.
M2 = (P, Σ, δ2, p0, F2) accepts L2.
q
0
q
f
a
1
a
n
p
0
p
f
a
1
a
n
δ
2
(p
j
, a) = p
l
δ
1
(q
i
, a) = q
k
δ
1
((q
i
, p
j
), a) = (q
k
, p
l
)
Example 4.1
L
1
= {abn | n ≥ 0}
L
2
= {anb | n ≥ 0}
L
1
∩L
2
= {ab}
Example 4.2
Find intersection dfa of
L
1
={
a
2
nbm
:
n
,
m
≥ 0} and
L
2
={
a
3
nb
2
m
:
n
,
m
≥ 0}
p
1
p
0
p
2
p
3
a
a
a
b
b
b
L
2
p
4
q
1
p
1
q
0
p
0
q
2
p
4
q
1
p
2
q
2
p
3
q
0
p
2
q
0
p
1
q
1
p
0
a
a
a
a
a
a
b
b
b
L
1
∩ L
2
q
1
q
0
q
2
aa
b
L
1
b
Theorem 2
The family of regular languages is closed under reversal:
If L is regular, then so is LR.
Proof
?
Suppose Σ and Γ are alphabets.
h: Σ → Γ*
is called a homomorphism
Homomorphism
Homomorphism (cont’d)
Extended definition:
w = a
1
a
2
a
n
h(w) = h(a
1
)h(a
2
) h(a
n
)
Homomorphism (cont’d)
If L is a language on Σ, then its homomorphic image is defined as:
h(L) = {h(w): w ∈ L}
Example 4.3
Σ = {a, b}
Γ = {a, b, c}
h(a) = ab h(b) = bbc
h(aba) = abbbcab
L = {aa, aba} ⇒ h(L) = {abab, abbbcab}
Homomorphism (cont’d)
If r is a regular expression on Σ, then the regular expression h(r) is
obtained by applying the homomorphism to each Σ symbol of r.
Example 4.4
Σ = {a, b}
Γ = {b, c, d}
h(a) = dbcc h(b) = bdc
r = (a + b*)(aa)*
h(r) = (dbcc + (bdc)*)(dbccdbcc)*
Theorem 4.3
The family of regular languages is closed under homomorphism:
If L is regular, then so is h(L).
Proof
Let L(r) = L for some regular expression r.
Prove: h(L(r)) = L(h(r)).
Right Quotient
Let L
1
and L
2
be languages on the same alphabet.
Then the right quotient of L
1
with L
2
is defined as:
L
1
/L
2
= {x | xy ∈ L
1
and
y ∈ L
2
}
Example 4.5
L
1
= {anbm | n ≥ 1, m ≥ 0}∪{ba}
L
2
= {bm | m ≥ 1}
L
1
/L
2
= {anbm | n ≥ 1, m ≥ 0}
Example 4.5 (cont’d)
q
0
q
1
q
2
b
b
b
a
q
3
a
a, b
a
q
4
q
5
a, b
a
L1 = {anbm | n ≥ 1, m ≥ 0}∪{ba}
a, b
Example 4.5 (cont’d)
q
0
q
1
q
2
b
b
b
a
q
3
a
a, b
a
q
4
q
5
a, b
a
L
1
= {a
n
b
m
| n ≥ 1, m ≥ 0}∪{ba} L
2
= {b
m
| m ≥ 1}
δ
*
(q
0
, x) = q
i
δ
*
(q
i
, y) ∈ F and y ∈ L
2
a, b
Example 4.5 (cont’d)
L
1
= {a
n
b
m
| n ≥ 1, m ≥ 0}∪{ba} L
2
= {b
m
| m ≥ 1}
δ
*
(q
0
, x) = q
i
δ
*
(q
i
, y) ∈ F and y ∈ L
2
q
1
q
2
b
b
Theorem 4.4
The family of regular languages is closed under right quotient:
If L
1
and L
2
are regular, then so is L
1
/L
2
.
Proof
•
M = (Q, Σ, δ, q
0
, F) accepts L
1
.
M^ = (P, Σ, δ, q
0
, F^) accepts L
1
/L
2
.
If y ∈ L
2
and δ*(q
i
, y) ∈ F ⇒ add q
i
to F^
Example 4.6
L
1
= L(a*baa*)
L
2
= L(ab*)
L
1
/L
2
= ?