CM0081 Closure Properties of Regular Languages

Automata and Formal Languages - CM0081
Closure Properties of Regular Languages
Andrés Sicard-Ramírez
EAFIT University
Semester 2017-1
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
2/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
3/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Intersection: 𝐿 ∩ 𝑀
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
4/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Intersection: 𝐿 ∩ 𝑀
Complement: 𝐿
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
5/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Intersection: 𝐿 ∩ 𝑀
Complement: 𝐿
Difference: 𝐿 βˆ’ 𝑀
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
6/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Intersection: 𝐿 ∩ 𝑀
Complement: 𝐿
Difference: 𝐿 βˆ’ 𝑀
Reversal: 𝐿𝑅 = {π‘€π‘Ÿ ∈ Ξ£βˆ— ∣ 𝑀 ∈ 𝐿}
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
7/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Intersection: 𝐿 ∩ 𝑀
Complement: 𝐿
Difference: 𝐿 βˆ’ 𝑀
Reversal: 𝐿𝑅 = {π‘€π‘Ÿ ∈ Ξ£βˆ— ∣ 𝑀 ∈ 𝐿}
Closure: πΏβˆ—
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
8/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Intersection: 𝐿 ∩ 𝑀
Complement: 𝐿
Difference: 𝐿 βˆ’ 𝑀
Reversal: 𝐿𝑅 = {π‘€π‘Ÿ ∈ Ξ£βˆ— ∣ 𝑀 ∈ 𝐿}
Closure: πΏβˆ—
Concatenation: 𝐿𝑀
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
9/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Intersection: 𝐿 ∩ 𝑀
Complement: 𝐿
Difference: 𝐿 βˆ’ 𝑀
Reversal: 𝐿𝑅 = {π‘€π‘Ÿ ∈ Ξ£βˆ— ∣ 𝑀 ∈ 𝐿}
Closure: πΏβˆ—
Concatenation: 𝐿𝑀
Homomorphism: β„Ž(𝐿) = {β„Ž(𝑀) ∣ 𝑀 ∈ 𝐿 and β„Ž is a homomorphism}
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
10/67
Introduction
Let 𝐿 and 𝑀 be regular languages. The following languages are regular:
Union: 𝐿 βˆͺ 𝑀
Intersection: 𝐿 ∩ 𝑀
Complement: 𝐿
Difference: 𝐿 βˆ’ 𝑀
Reversal: 𝐿𝑅 = {π‘€π‘Ÿ ∈ Ξ£βˆ— ∣ 𝑀 ∈ 𝐿}
Closure: πΏβˆ—
Concatenation: 𝐿𝑀
Homomorphism: β„Ž(𝐿) = {β„Ž(𝑀) ∣ 𝑀 ∈ 𝐿 and β„Ž is a homomorphism}
Inverse homomorphism:
β„Žβˆ’1 (𝐿) = {𝑀 ∈ Ξ£ ∣ β„Ž(𝑀) ∈ 𝐿 and β„Ž is a homomorphism}
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
11/67
Closure Under Union and Complementation
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.4)
If 𝐿 and 𝑀 are regular languages, then so is 𝐿 βˆͺ 𝑀 .
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
12/67
Closure Under Union and Complementation
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.4)
If 𝐿 and 𝑀 are regular languages, then so is 𝐿 βˆͺ 𝑀 .
Proof
(Using regular expressions)
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
13/67
Closure Under Union and Complementation
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.5)
Let 𝐿 = Ξ£βˆ— βˆ’πΏ be the complement of a language 𝐿. If 𝐿 is regular language,
then so is 𝐿.
βˆ—
Hopcroft, J. E., Motwani, R. and Ullman, J. D. (2007). Introduction to Automata
theory, Languages, and Computation, p. 136.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
14/67
Closure Under Union and Complementation
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.5)
Let 𝐿 = Ξ£βˆ— βˆ’πΏ be the complement of a language 𝐿. If 𝐿 is regular language,
then so is 𝐿.
Proof.
Let 𝐴 = (𝑄, Ξ£, 𝛿, π‘ž0 , 𝐹 ) be a DFA such that 𝐿(𝐴) = 𝐿. Then 𝐡 =
(𝑄, Ξ£, 𝛿, π‘ž0 , 𝑄 βˆ’ 𝐹 ) is a DFA such 𝐿(𝐡) = 𝐿.
βˆ—
Hopcroft, J. E., Motwani, R. and Ullman, J. D. (2007). Introduction to Automata
theory, Languages, and Computation, p. 136.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
15/67
Closure Under Union and Complementation
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.5)
Let 𝐿 = Ξ£βˆ— βˆ’πΏ be the complement of a language 𝐿. If 𝐿 is regular language,
then so is 𝐿.
Proof.
Let 𝐴 = (𝑄, Ξ£, 𝛿, π‘ž0 , 𝐹 ) be a DFA such that 𝐿(𝐴) = 𝐿. Then 𝐡 =
(𝑄, Ξ£, 𝛿, π‘ž0 , 𝑄 βˆ’ 𝐹 ) is a DFA such 𝐿(𝐡) = 𝐿.
Question: β€œDo you see how to take a regular expression and change it into
one that defines the complement language?β€βˆ—
βˆ—
Hopcroft, J. E., Motwani, R. and Ullman, J. D. (2007). Introduction to Automata
theory, Languages, and Computation, p. 136.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
16/67
Closure Under Union and Complementation
Using the closure properties we can prove that a language is not regular.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
17/67
Closure Under Union and Complementation
Using the closure properties we can prove that a language is not regular.
Example
Given that
𝐿= = {𝑀 ∈ {0, 1}βˆ— ∣ 𝑀 has an equal numbers of 0’s and 1’s}
is a language not regular. Prove that
𝐿≠ = {𝑀 ∈ {0, 1}βˆ— ∣ 𝑀 has an unequal numbers of 0’s and 1’s}
is a language not regular.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
18/67
Closure Under Union and Complementation
Using the closure properties we can prove that a language is not regular.
Example
Given that
𝐿= = {𝑀 ∈ {0, 1}βˆ— ∣ 𝑀 has an equal numbers of 0’s and 1’s}
is a language not regular. Prove that
𝐿≠ = {𝑀 ∈ {0, 1}βˆ— ∣ 𝑀 has an unequal numbers of 0’s and 1’s}
is a language not regular.
Proof
Whiteboard.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
19/67
Product Construction
Let 𝐴𝐿 , 𝐴𝑀 and 𝐴 be DFAs given by
𝐴𝐿 = (𝑄𝐿 , Ξ£, 𝛿𝐿 , π‘žπΏ , 𝐹𝐿 ),
𝐴𝑀 = (𝑄𝑀 , Ξ£, 𝛿𝑀 , π‘žπ‘€ , 𝐹𝑀 ),
𝐴 = (𝑄𝐿 × π‘„π‘€ , Ξ£, 𝛿, (π‘žπΏ , π‘žπ‘€ ), 𝐹𝐿 × πΉπ‘€ ),
where 𝛿((𝑝, π‘ž), π‘Ž) = (𝛿𝐿 (𝑝, π‘Ž), 𝛿𝑀 (π‘ž, π‘Ž)).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
20/67
Product Construction
Let 𝐴𝐿 , 𝐴𝑀 and 𝐴 be DFAs given by
𝐴𝐿 = (𝑄𝐿 , Ξ£, 𝛿𝐿 , π‘žπΏ , 𝐹𝐿 ),
𝐴𝑀 = (𝑄𝑀 , Ξ£, 𝛿𝑀 , π‘žπ‘€ , 𝐹𝑀 ),
𝐴 = (𝑄𝐿 × π‘„π‘€ , Ξ£, 𝛿, (π‘žπΏ , π‘žπ‘€ ), 𝐹𝐿 × πΉπ‘€ ),
where 𝛿((𝑝, π‘ž), π‘Ž) = (𝛿𝐿 (𝑝, π‘Ž), 𝛿𝑀 (π‘ž, π‘Ž)).
Theorem (Hopcroft, Motwani and Ullman [2007], Exercise 4.2.15)
For all 𝑀 ∈ Ξ£βˆ— ,
Μ‚
Μ‚
Μ‚
𝛿((π‘ž
𝐿 , π‘žπ‘€ ), 𝑀) = (𝛿𝐿 (π‘žπΏ , 𝑀), 𝛿𝑀 (π‘žπ‘€ , 𝑀)).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
21/67
Product Construction
Proof by induction on 𝑀.
1. Basis step
Μ‚
𝛿((π‘ž
𝐿 , π‘žπ‘€ ), πœ€) = (π‘žπΏ , π‘žπ‘€ )
Μ‚ (π‘ž , πœ€), 𝛿 Μ‚ (π‘ž , πœ€))
= (𝛿𝐿
𝐿
𝑀 𝑀
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
(def. of 𝛿)Μ‚
Μ‚ and 𝛿 Μ‚ )
(def. of 𝛿𝐿
𝑀
22/67
Product Construction
Proof by induction on 𝑀.
1. Basis step
Μ‚
𝛿((π‘ž
𝐿 , π‘žπ‘€ ), πœ€) = (π‘žπΏ , π‘žπ‘€ )
Μ‚ (π‘ž , πœ€), 𝛿 Μ‚ (π‘ž , πœ€))
= (𝛿𝐿
𝐿
𝑀 𝑀
(def. of 𝛿)Μ‚
Μ‚ and 𝛿 Μ‚ )
(def. of 𝛿𝐿
𝑀
2. Inductive step
Μ‚
𝛿((π‘ž
𝐿 , π‘žπ‘€ ), π‘₯π‘Ž)
Μ‚
= 𝛿(𝛿((π‘ž
, π‘ž ), π‘₯), π‘Ž)
𝐿
𝑀
Μ‚ (π‘ž , π‘₯), 𝛿 Μ‚ (π‘ž , π‘₯)), π‘Ž)
= 𝛿((𝛿𝐿
𝐿
𝑀 𝑀
Μ‚
Μ‚ (π‘ž , π‘₯), π‘Ž))
= (𝛿𝐿 (𝛿𝐿 (π‘žπΏ , π‘₯), π‘Ž), 𝛿𝑀 (𝛿𝑀
𝑀
Μ‚
Μ‚
= (𝛿 (π‘ž , π‘₯π‘Ž), 𝛿 (π‘ž , π‘₯π‘Ž))
𝐿
𝐿
𝑀
𝑀
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
(def. of 𝛿)Μ‚
(by IH)
(def. of 𝛿)
(def. of 𝛿𝐿̂ and 𝛿𝐿̂ )
23/67
Closure Under Intersection
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.8)
If 𝐿 and 𝑀 are regular languages, then so is 𝐿 ∩ 𝑀 .
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
24/67
Closure Under Intersection
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.8)
If 𝐿 and 𝑀 are regular languages, then so is 𝐿 ∩ 𝑀 .
Proof.
Let 𝐴𝐿 and 𝐴𝑀 be DFAs accepting 𝐿 and 𝑀 . The product construction
of 𝐴𝐿 and 𝐴𝑀 accepts 𝐿 ∩ 𝑀 .
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
25/67
Closure Under Intersection
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.8)
If 𝐿 and 𝑀 are regular languages, then so is 𝐿 ∩ 𝑀 .
Proof.
Let 𝐴𝐿 and 𝐴𝑀 be DFAs accepting 𝐿 and 𝑀 . The product construction
of 𝐴𝐿 and 𝐴𝑀 accepts 𝐿 ∩ 𝑀 .
Different proof.
The regular languages are closure under union and complement, and
𝐿 ∩ 𝑀 = 𝐿 βˆͺ 𝑀.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
26/67
Closure Under Reversal
Definition (Reversal of a language)
If 𝑀 = π‘Ž1 π‘Ž2 β‹― π‘Žπ‘› then the reversal of 𝑀 is defined by 𝑀𝑅 = π‘Žπ‘› π‘Žπ‘›βˆ’1 β‹― π‘Ž1 .
𝐿𝑅 = {𝑀𝑅 ∈ Ξ£βˆ— ∣ 𝑀 ∈ 𝐿} is the reversal of the language 𝐿 on the
alphabet Ξ£.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
27/67
Closure Under Reversal
Definition (Reversal of a language)
If 𝑀 = π‘Ž1 π‘Ž2 β‹― π‘Žπ‘› then the reversal of 𝑀 is defined by 𝑀𝑅 = π‘Žπ‘› π‘Žπ‘›βˆ’1 β‹― π‘Ž1 .
𝐿𝑅 = {𝑀𝑅 ∈ Ξ£βˆ— ∣ 𝑀 ∈ 𝐿} is the reversal of the language 𝐿 on the
alphabet Ξ£.
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.11)
If 𝐿 is regular language, then so is 𝐿𝑅 (proof using automata or regular
expressions).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
28/67
Closure Under Reversal
Proof using automata.
Let 𝐿 be recognized by a finite automaton 𝐴. Turn 𝐴 into finite automaton
for 𝐿𝑅 , by
1. Reversing all arcs.
2. Make the start state of 𝐴 be the only accepting state.
3. Create a new start state 𝑝0 with transitions 𝛿(𝑝0 , πœ€) = 𝑓,
where 𝑓 ∈ 𝐹 are the accepting states of 𝐴.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
29/67
Closure Under Reversal
Example
A NFA accepting all the binary strings that end in 01.
0, 1
start
π‘ž0
0
π‘ž1
1
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
π‘ž2
30/67
Closure Under Reversal
Example
A NFA accepting all the binary strings that end in 01.
0, 1
0
π‘ž0
start
1
π‘ž1
π‘ž2
A NFA accepting all the binary strings that start with 10.
0, 1
π‘ž0
0
π‘ž1
1
π‘ž2
πœ€
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
𝑝0
start
31/67
Homomorphisms
Definition (Algebraic structure)
An algebraic structure on a set 𝐴 β‰  βˆ… is essentially a collection of 𝑛-ary
operations on 𝐴 [Cohn 1981, p. 41].
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
32/67
Homomorphisms
Definition (Algebraic structure)
An algebraic structure on a set 𝐴 β‰  βˆ… is essentially a collection of 𝑛-ary
operations on 𝐴 [Cohn 1981, p. 41].
Example (Semigroup)
A semigroup (𝑆, βˆ—) is a set 𝑆 with an associative binary operation
βˆ— ∢ 𝑆 × π‘† β†’ 𝑆.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
33/67
Homomorphisms
Definition (Algebraic structure)
An algebraic structure on a set 𝐴 β‰  βˆ… is essentially a collection of 𝑛-ary
operations on 𝐴 [Cohn 1981, p. 41].
Example (Semigroup)
A semigroup (𝑆, βˆ—) is a set 𝑆 with an associative binary operation
βˆ— ∢ 𝑆 × π‘† β†’ 𝑆.
Example (Monoid)
A monoid (𝑀 , βˆ—, πœ€) is a semigroup (𝑀 , βˆ—) with an element πœ€ ∈ 𝑀 which is
an unit for βˆ—, i.e. βˆ€π‘₯. π‘₯ βˆ— πœ€ = πœ€ βˆ— π‘₯ = π‘₯.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
34/67
Homomorphisms
Definition (homomorphism)
A homomorphism is a structure-preserving map between two algebraic structures.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
35/67
Homomorphisms
Definition (homomorphism)
A homomorphism is a structure-preserving map between two algebraic structures.
Example
A homomorphism between two semigroups (𝑆, βˆ—) and (𝑆 β€² , βˆ—β€² ) is a function
𝑓 ∢ 𝑆 β†’ 𝑆 β€² such that:
βˆ€π‘₯ 𝑦. 𝑓(π‘₯ βˆ— 𝑦) = 𝑓(π‘₯) βˆ—β€² 𝑓(π‘₯).
Graphically (see whiteboard).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
36/67
Homomorphisms
Example
A homomorphism between two monoids (𝑀 , βˆ—, πœ€) and (𝑀 β€² , βˆ—β€² , πœ€β€² ) is a
function 𝑓 ∢ 𝑀 β†’ 𝑀 β€² such that:
βˆ€π‘₯ 𝑦. 𝑓(π‘₯ βˆ— 𝑦) = 𝑓(π‘₯) βˆ—β€² 𝑓(π‘₯),
𝑓(πœ€) = πœ€β€² .
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
37/67
Homomorphisms
A homomorphism between two algebraic structures is a:
Monomorphism if 𝑓 is an injection
Epimorphism if 𝑓 is an surjection
Isomorphism if 𝑓 is bijection
Endomorphism if the homomorphism is from an algebraic structure to
itself
Automorphism if the homomorphism is a bijective endomorphism
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
38/67
Closure Under Homomorphism
Definition
Let Ξ£ and Ξ“ be two alphabets. A homomorphism between (Ξ£βˆ— , ·, πœ€) and
(Ξ“βˆ— , ·, πœ€) is a function
β„Ž ∢ Ξ£βˆ— β†’ Ξ“ βˆ—
π‘Ž1 π‘Ž2 β‹― π‘Žπ‘› ↦ β„Ž(π‘Ž1 )β„Ž(π‘Ž2 ) β‹― β„Ž(π‘Žπ‘› )
πœ€β†¦πœ€
Note: For this reason the textbook talk about a homomorphism β„Ž ∢ Ξ£ β†’ Ξ“βˆ— .
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
39/67
Closure Under Homomorphism
Example
Let β„Ž ∢ {0, 1}βˆ— β†’ {π‘Ž, 𝑏}βˆ— be a homomorphism defined by
β„Ž(0) = π‘Žπ‘,
β„Ž(1) = πœ€.
Then
β„Ž(0011) = β„Ž(0)β„Ž(0)β„Ž(1)β„Ž(1)
= π‘Žπ‘π‘Žπ‘.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
40/67
Closure Under Homomorphism
Inverse Homomorphism
Definition (Application of a homomorphism to a language)
If 𝐿 is a language
alphabet
Ξ£ and β„Ž isLet
a homomorphism
on Ξ£,
βˆ— be a homom.
Let h :over
Ξ£βˆ— the
β†’ Θ
L βŠ† Ξ˜βˆ— ,
thenβˆ—
and define
β„Ž(𝐿) = {β„Ž(𝑀) ∣ 𝑀 ∈ 𝐿}.
hβˆ’1(L) = {w ∈ Ξ£βˆ— : h(w) ∈ L}
L
h
h(L)
(a)
βˆ—
-1
(L)
h
Hopcroft, Motwani and Ullmanh [2007,
Fig. 4.5a].L
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
41/67
Closure Under Homomorphism
Example
Let β„Ž ∢ {0, 1}βˆ— β†’ {π‘Ž, 𝑏}βˆ— be a homomorphism defined by
β„Ž(0) = π‘Žπ‘,
β„Ž(1) = πœ€.
If 𝐿 = 𝐿(10βˆ— 1), then β„Ž(𝐿) = 𝐿((ab)βˆ— ).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
42/67
Closure Under Homomorphism
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.14)
If 𝐿 is a regular language over the alphabet Ξ£ and β„Ž is a homomorphism
on Ξ£, then β„Ž(𝐿) is also regular.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
43/67
Closure Under Homomorphism
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.14)
If 𝐿 is a regular language over the alphabet Ξ£ and β„Ž is a homomorphism
on Ξ£, then β„Ž(𝐿) is also regular.
Proof plan
Let 𝐸 be a regular expression such 𝐿 = 𝐿(𝐸).
Let β„Ž(𝐸) be the regular expression replacing each symbol π‘Ž ∈ Ξ£
by β„Ž(π‘Ž) in the regular expression 𝐸.
We need to prove that 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸)).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
44/67
Closure Under Homomorphism
Proving 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸)).
Basis step
𝐸 is πœ€ or βˆ….
1. β„Ž(𝐸) = 𝐸 (β„Ž does not affect 𝐸)
2. β„Ž(𝐿(𝐸)) = 𝐿(𝐸) (𝐿(𝐸) is empty or only contains πœ€)
3. 𝐿(β„Ž(𝐸)) = 𝐿(𝐸) = β„Ž(𝐿(𝐸)) (by 1 and 2)
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
45/67
Closure Under Homomorphism
Proving 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸)).
Basis step
𝐸 is πœ€ or βˆ….
1. β„Ž(𝐸) = 𝐸 (β„Ž does not affect 𝐸)
2. β„Ž(𝐿(𝐸)) = 𝐿(𝐸) (𝐿(𝐸) is empty or only contains πœ€)
3. 𝐿(β„Ž(𝐸)) = 𝐿(𝐸) = β„Ž(𝐿(𝐸)) (by 1 and 2)
𝐸=a
1. 𝐿(𝐸) = {π‘Ž}
2. β„Ž(𝐿(𝐸)) = {β„Ž(π‘Ž)}
3. β„Ž(𝐸) is the regular expression that is the string of symbols β„Ž(π‘Ž)
4. 𝐿(β„Ž(𝐸)) = {β„Ž(π‘Ž)}
5. 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸)) (by transitivity between 2 and 4)
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
46/67
Closure Under Homomorphism
Proving 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸)).
Inductive step
𝐸 =𝐹 +𝐺
1. 𝐿(𝐸) = 𝐿(𝐹 ) βˆͺ 𝐿(𝐺) (def. of +)
2. β„Ž(𝐸) = β„Ž(𝐹 + 𝐺) = β„Ž(𝐹 ) + β„Ž(𝐺) (def. of β„Ž(𝐸))
3. 𝐿(β„Ž(𝐸)) = 𝐿(β„Ž(𝐹 ) + β„Ž(𝐺)) = 𝐿(β„Ž(𝐹 )) βˆͺ 𝐿(β„Ž(𝐺)) (def. of +)
4. β„Ž(𝐿(𝐸)) = β„Ž(𝐿(𝐹 ) βˆͺ 𝐿(𝐺)) = β„Ž(𝐿(𝐹 )) βˆͺ β„Ž(𝐿(𝐺)) (β„Ž is applied
to a language by application to each of its strings)
5. 𝐿(β„Ž(𝐹 )) = β„Ž(𝐿(𝐹 ) and 𝐿(β„Ž(𝐺)) = β„Ž(𝐿(𝐺) (IH)
6. 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸))
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
47/67
Closure Under Homomorphism
Proving 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸)).
Inductive step (cont.)
𝐸 = 𝐹 𝐺 (similar to the previous case)
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
48/67
Closure Under Homomorphism
Proving 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸)).
Inductive step (cont.)
𝐸 = 𝐹 𝐺 (similar to the previous case)
𝐸 = 𝐹 βˆ— (similar to the previous case)
1. 𝐿(𝐸) = (𝐿(𝐹 ))βˆ— (def. of βˆ— )
2. β„Ž(𝐸) = β„Ž(𝐹 βˆ— ) = (β„Ž(𝐹 ))βˆ— (def. of β„Ž(𝐸))
3. 𝐿(β„Ž(𝐸)) = 𝐿((β„Ž(𝐹 ))βˆ— ) = (𝐿(β„Ž(𝐹 )))βˆ— (def. of βˆ— )
4. β„Ž(𝐿(𝐸)) = β„Ž((𝐿(𝐹 ))βˆ— ) = (β„Ž(𝐿(𝐹 )))βˆ— (β„Ž is applied to a language
by application to each of its strings)
5. 𝐿(β„Ž(𝐹 )) = β„Ž(𝐿(𝐹 )) (IH)
6. 𝐿(β„Ž(𝐸)) = β„Ž(𝐿(𝐸))
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
49/67
Closure Under Homomorphism
Example
Prove that
𝐿 = {0𝑖 1𝑗 2π‘˜ ∣ 𝑖, 𝑗, π‘˜ ∈ β„€+ and 𝑖 β‰  𝑗 β‰  π‘˜}
is a language not regular.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
50/67
Closure Under Homomorphism
Example
Prove that
𝐿 = {0𝑖 1𝑗 2π‘˜ ∣ 𝑖, 𝑗, π‘˜ ∈ β„€+ and 𝑖 β‰  𝑗 β‰  π‘˜}
is a language not regular.
Proof.
1. We define the homomorphism
β„Ž(0) = 0,
β„Ž(1) = 1,
β„Ž(2) = πœ€.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
51/67
Closure Under Homomorphism
Example
Prove that
𝐿 = {0𝑖 1𝑗 2π‘˜ ∣ 𝑖, 𝑗, π‘˜ ∈ β„€+ and 𝑖 β‰  𝑗 β‰  π‘˜}
is a language not regular.
Proof.
1. We define the homomorphism
β„Ž(0) = 0,
β„Ž(1) = 1,
β„Ž(2) = πœ€.
2. The homomorphism β„Ž removes the 2π‘˜ s, so
β„Ž(𝐿) = {0𝑖 1𝑗 ∣ 𝑖, 𝑗 ∈ β„€+ and 𝑖 β‰  𝑗}.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
52/67
Closure Under Homomorphism
Example
Prove that
𝐿 = {0𝑖 1𝑗 2π‘˜ ∣ 𝑖, 𝑗, π‘˜ ∈ β„€+ and 𝑖 β‰  𝑗 β‰  π‘˜}
is a language not regular.
Proof.
1. We define the homomorphism
β„Ž(0) = 0,
β„Ž(1) = 1,
β„Ž(2) = πœ€.
2. The homomorphism β„Ž removes the 2π‘˜ s, so
β„Ž(𝐿) = {0𝑖 1𝑗 ∣ 𝑖, 𝑗 ∈ β„€+ and 𝑖 β‰  𝑗}.
3. We know that β„Ž(𝐿) is not regular, so 𝐿 is not regular.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
53/67
Closure Under Homomorphism
Example
Let 𝐿 be a regular language and β„Ž a homomorphism on 𝐿. Define β„Žβˆ— (𝐿) by
β„Žβˆ— (𝐿) = 𝐿 βˆͺ β„Ž(𝐿) βˆͺ β„Ž(β„Ž(𝐿)) βˆͺ β„Ž(β„Ž(β„Ž(𝐿))) βˆͺ …
Is β„Žβˆ— (𝐿) necessarily regular?
βˆ—
From somewhere in Internet (I don’t remember).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
54/67
Closure Under Homomorphism
Example
Let 𝐿 be a regular language and β„Ž a homomorphism on 𝐿. Define β„Žβˆ— (𝐿) by
β„Žβˆ— (𝐿) = 𝐿 βˆͺ β„Ž(𝐿) βˆͺ β„Ž(β„Ž(𝐿)) βˆͺ β„Ž(β„Ž(β„Ž(𝐿))) βˆͺ …
Is β„Žβˆ— (𝐿) necessarily regular?
No. Let 𝐿 = {01} and β„Ž defined as β„Ž(0) = 00 and β„Ž(1) = 11. Then
β„Žβˆ— (𝐿) = {01, 0011, 00001111, … }
= {0𝑛 1𝑛 ∣ 𝑛 = 2π‘˜ for π‘˜ β‰₯ 0},
which is a language not regular.βˆ—
βˆ—
From somewhere in Internet (I don’t remember).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
55/67
hβˆ’1(L) = {w ∈ Ξ£βˆ— : h(w) ∈ L}
Closure Under Inverse Homomorphism
Definition
L
h and 𝐿h(L)
Let β„Ž ∢ Ξ£βˆ— β†’ Ξ“βˆ— be a homomorphism
βŠ† Ξ“βˆ— a language, thenβˆ—
β„Žβˆ’1 (𝐿) = {𝑀 ∈ Ξ£βˆ— ∣ β„Ž(𝑀) ∈ 𝐿}.
(a)
h-1 (L)
h
L
(b)
110
βˆ—
Hopcroft, Motwani and Ullman [2007, Fig. 4.5b].
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
56/67
Closure Under Inverse Homomorphism
Example
Let β„Ž ∢ {π‘Ž, 𝑏} β†’ {0, 1}βˆ— a homomorphism defined by
β„Ž(π‘Ž) = 01,
β„Ž(𝑏) = 10.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
57/67
Closure Under Inverse Homomorphism
Example
Let β„Ž ∢ {π‘Ž, 𝑏} β†’ {0, 1}βˆ— a homomorphism defined by
β„Ž(π‘Ž) = 01,
β„Ž(𝑏) = 10.
If 𝐿 = 𝐿((00 + 1)βˆ— ), then β„Žβˆ’1 (𝐿) = 𝐿((ba)βˆ— )
(It is necessary to prove β„Ž(𝑀) ∈ 𝐿 ⇔ 𝑀 = π‘π‘Žπ‘π‘Ž β‹― π‘π‘Ž).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
58/67
Closure Under Inverse Homomorphism
Theorem (Hopcroft, Motwani and Ullman [2007], Theorem 4.16)
Let β„Ž ∢ Ξ£βˆ— β†’ Ξ“βˆ— be a homomorphism and 𝐿 βŠ† Ξ“βˆ— a regular language. Then
β„Žβˆ’1 (𝐿) is regular (proof using automata).
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
59/67
Closure Under Inverse Homomorphism
Example
Prove that 𝐿 = {0𝑛 12𝑛 ∣ 𝑛 β‰₯ 0} is a language not regular.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
60/67
Closure Under Inverse Homomorphism
Example
Prove that 𝐿 = {0𝑛 12𝑛 ∣ 𝑛 β‰₯ 0} is a language not regular.
Proof.
1. Given the homomorphism
β„Ž(0) = 0,
β„Ž(1) = 11,
then β„Žβˆ’1 (𝐿) = {0𝑛 1𝑛 ∣ 𝑛 β‰₯ 0}.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
61/67
Closure Under Inverse Homomorphism
Example
Prove that 𝐿 = {0𝑛 12𝑛 ∣ 𝑛 β‰₯ 0} is a language not regular.
Proof.
1. Given the homomorphism
β„Ž(0) = 0,
β„Ž(1) = 11,
then β„Žβˆ’1 (𝐿) = {0𝑛 1𝑛 ∣ 𝑛 β‰₯ 0}.
2. Since β„Žβˆ’1 (𝐿) is not regular, then 𝐿 is not regular.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
62/67
Closure Properties
Exercise (Hopcroft, Motwani and Ullman [2007], Exercise 4.2.2)
If 𝐿 is a language, and π‘Ž is a symbol, then 𝐿/π‘Ž, the quotient of 𝐿 and π‘Ž, is
the set of strings 𝑀 such that π‘€π‘Ž is in 𝐿. For example, if 𝐿 = {π‘Ž, π‘Žπ‘Žπ‘, π‘π‘Žπ‘Ž},
then 𝐿/π‘Ž = {πœ€, π‘π‘Ž}. Prove that if 𝐿 is regular, so is 𝐿/π‘Ž. Hint: Start with
a DFA for 𝐿 and consider the set of accepting states.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
63/67
Closure Properties
Exercise (Hopcroft, Motwani and Ullman [2007], Exercise 4.2.2)
If 𝐿 is a language, and π‘Ž is a symbol, then 𝐿/π‘Ž, the quotient of 𝐿 and π‘Ž, is
the set of strings 𝑀 such that π‘€π‘Ž is in 𝐿. For example, if 𝐿 = {π‘Ž, π‘Žπ‘Žπ‘, π‘π‘Žπ‘Ž},
then 𝐿/π‘Ž = {πœ€, π‘π‘Ž}. Prove that if 𝐿 is regular, so is 𝐿/π‘Ž. Hint: Start with
a DFA for 𝐿 and consider the set of accepting states.
Proof (Hopcroft, Motwani and Ullman [2007] solution).
Start with a DFA 𝐴 for 𝐿. Construct a new DFA 𝐡, that is exactly the same
as 𝐴, except that state π‘ž is an accepting state of 𝐡 if and only if 𝛿(π‘ž, π‘Ž)
is an accepting state of 𝐴. Then 𝐡 accepts input string 𝑀 if and only if 𝐴
accepts π‘€π‘Ž; that is, 𝐿(𝐡) = 𝐿/π‘Ž.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
64/67
Closure Properties
Exercise (Hopcroft, Motwani and Ullman [2007], Exercise 4.2.3)
If 𝐿 is a language, and π‘Ž is a symbol, then π‘Ž\𝐿 is the set of strings 𝑀 such
that π‘Žπ‘€ is in 𝐿. For example, if 𝐿 = {π‘Ž, π‘Žπ‘Žπ‘, π‘π‘Žπ‘Ž}, then π‘Ž\𝐿 = {πœ€, π‘Žπ‘}.
Prove that if 𝐿 is regular, so is π‘Ž\𝐿. Hint: Start with a DFA for 𝐿 and
consider its start state.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
65/67
Closure Properties
Exercise (Hopcroft, Motwani and Ullman [2007], Exercise 4.2.3)
If 𝐿 is a language, and π‘Ž is a symbol, then π‘Ž\𝐿 is the set of strings 𝑀 such
that π‘Žπ‘€ is in 𝐿. For example, if 𝐿 = {π‘Ž, π‘Žπ‘Žπ‘, π‘π‘Žπ‘Ž}, then π‘Ž\𝐿 = {πœ€, π‘Žπ‘}.
Prove that if 𝐿 is regular, so is π‘Ž\𝐿. Hint: Start with a DFA for 𝐿 and
consider its start state.
Proof (Hopcroft, Motwani and Ullman [2007] solution).
Start with a DFA 𝐴 for 𝐿. Construct a new DFA 𝐡, that is exactly the
same as 𝐴, except that its start state is 𝛿(π‘ž0 , π‘Ž) where π‘ž0 is the start state
of 𝐴. Then 𝐡 accepts input string 𝑀 if and only if 𝐴 accepts π‘Žπ‘€; that is,
𝐿(𝐡) = 𝐿\π‘Ž.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
66/67
References
Cohn, P. M. (1981). Universal Algebra. Revised edition. D. Reidel Publishing
Company.
Hopcroft, J. E., Motwani, R. and Ullman, J. D. (2007). Introduction to Automata
theory, Languages, and Computation. 3rd ed. Pearson Education.
Automata and Formal Languages - CM0081. Closure Properties of Regular Languages
67/67