SlideShare a Scribd company logo
1
Closure Properties of
Regular Languages
Union, Concatenation, Closure,
Intersection, Difference, Reversal,
Homomorphism, and Inverse
Homomorphism
2
Review Closure Properties
A closure property is a statement that a
certain operation on languages, when
applied to languages in a class (e.g.,
the regular languages), produces a
result that is also in that class.
3
Closure Under Union
If L and M are regular languages, so is L 
M.
Proof: Let R and S be the REs that define L
and M.
Then R+S is a regular expression whose
regular language is L  M.
Therefore, regular languages are closed
under union
4
Closure Under
Concatenation and Closure
Same idea:
RS is a regular expression whose language
is LM; therefore LM is regular.
R* is a regular expression whose language
is L*; therefore L* is regular
5
Closure Under Intersection
If L and M are regular languages, then LM is
regular.
Proof: Let L and M be DFA’s whose languages
are L and M, respectively.
Construct C = p-DFA of L and M
Make the accepting states of C be the pairs
consisting of accepting states of both L and
M.
String w accepted by p-DFA iff it is accepted
by both DFA(L) and DFA(M)
6
Product DFA for Intersection
A B
0
1
0, 1
1
C D
1
0
0
[A,C] [A,D]
0
[B,C]
1
0
1
0
1
[B,D]
0
1
L
M
P-DFA(L  M )
Which state of p-DFA do we
choose for the accepting state?
7
Product DFA for Intersection
A B
0
1
0, 1
1
C D
1
0
0
[A,C] [A,D]
0
[B,C]
1
0
1
0
1
[B,D]
0
1
L
M
P-DFA(L  M )
String 11 accepted by p-
DFA. P-DFA not empty and
defines
(LM ), which is regular.
8
Closure Under Difference
L– M = strings in L but not M. If L and M are
regular languages, then so is L-M
Proof: Let L and M be DFA’s whose
languages are L and M, respectively.
Construct C = p-DFA of L and M.
Make the accepting states of C be the pairs
where L-state is accepting but M-state is not.
p-DFA defines the RL of L-M.
9
Product DFA for Difference L-
M
A B
0
1
0, 1
C D
1
1
0
0
[A,C] [A,D]
0
[B,C]
1
0
1
0
1
[B,D]
0
1
Which state do we choose as
the accepting state?
L
M
p-DFA(L-M)
10
Product DFA for Difference
A B
0
1
0, 1
C D
1
1
0
0
[A,C] [A,D]
0
[B,C]
1
0
1
0
1
[B,D]
0
1
p-DFA(L-M) is the empty language
in this case. Proof still valid.
We used the same p-DFA to show
that L=M. L-M is RL with no strings
L
M
p-DFA(L-M)
11
Closure Under Complementation: Recall Σ* denotes
all string that can be formed from alphabet Σ.
The complement of a language L (with respect
to an alphabet Σ such that Σ* contains L) is Σ* –
L.
Since Σ* is regular, the complement of a
regular language is regular because it is the
difference of regular languages.
12
Closure Under Reversal
Given language L, LR
is the set of strings whose
reversal is in L.
Example: L = {0, 01, 100}; LR
= {0, 10, 001}.
Reversal of all sting in LR
are in L
Prove that RLs are closed under reversal:
Let E be a regular expression for L.
We show how to reverse E, to obtain a regular
expression ER
for LR
.
13
Reversal of a Regular Expression
Basis: If E = a, ε, or ∅, then ER
= E.
Induction:
If E=F+G, then ER
= FR
+ GR
.
If E=FG, then ER
= GR
FR
If E=F*, then ER
= (FR
)*.
Example find ER
of 0(10)* + 10*
14
Example: Reversal of a RE
Let E = 0(10)* + 10*.
ER
= (0(10)*)R
+ (10*)R
(union rule)
= ((10)*)R
0R
+ (0*)R
1R
(concat. rule)
= ((10)*)R
0+ (0*)R
1 (basis)
= ((0R
1R
)*0 + (0R
)*1 (closure rules)
= (01)*0 + 0*1 (basis)
15
Homomorphisms
A homomorphism on an alphabet is a function
that assigns a string to every symbol in that
alphabet
Example on ={0,1}
Define h(0) = ab h(1) = ε
Extend to strings by h(a1…an) = h(a1)…h(an)
example: h(01010) = ababab
h(L)={h(w)|w is in L}=homomorphism of L
Language formed by applying h to every string in
L
16
Closure Under
Homomorphism
If L is a regular language, and h is a
homomorphism on its alphabet, then
h(L)= {h(w)|w is in L} is also a regular
language.
Proof: Let E be a regular expression for L.
Apply h to each symbol in E.
Language of resulting RE, h(L), is regular
17
h(0) = ab; h(1) = ε.
L is the language of RE = 01* + 10*
Find the RE of h(L) and simplify
Do on board
Exercise:
18
h(0) = ab; h(1) = ε.
L is the language of RE = 01* + 10*
RE of h(L)=abε* + ε(ab)*
ε* = ε
ε is the identity under concatenation.
abε*+ε(ab)*=abε+ε(ab)*=ab+(ab)*.
ab is contained in (ab)*
RE for h(L) is (ab)*
19
Inverse Homomorphism of a string
h-1
(w) notation for inverse homomorphism of
w
w’=h-1
(w), iff h(w’)=w
Given h, to answer the question
“Is w’ an inverse homomorphism of w?”,
apply h to every character in w’
If the result is w, then w’=h-1
(w)
20
Inverse homomorphisms of
a language
Let  be the alphabet of L
Let h be a homomorphism defined on 
Let h(L) be a homomorphism defined on
L Let h-1
(L) be an inverse homomorphism
of L defined by h(L)
h-1
(L) ={w’ in | such that h(w’) is in h(L)}
21
Finding h-1
(L)
Only practical if h(L) contains just a few strings
Suppose h(L) contains w1 and w2
Let h(L) be a homomorphism of L defined on 
h-1
(L) consist of all strings w’ that can be
constructed from characters in  such that h(w’) is
w1 or w2
Only practical if  contains just a few characters
22
Example of an h-1
(L) problem
Let h(0) = ab; h(1) = ε.
Let h(L) = {abab, baba}
Find h-1
(L)
23
Solution of h-1
(L) problem
={0,1}
h(0) = ab; h(1) = ε.
h(L) = {abab, baba}
h-1
(L) = {all w defined on {0,1} such that h(w) is
either abab or baba}
No w such that h(w) = baba.
h-1
(L) = any w with two 0’s and any number of
1’s because h(w)=abab
All 1’s become ε that is identity of concat.

More Related Content

PPT
Closure Properties of Regular Languages.ppt
PPTX
Unit-2. Regular Expressions and Languages.pptx
PDF
Unit ii
PPT
3-regular_expressions_and_languages (1).ppt
PPT
3-regular_expressions_and_languages (1).ppt
PPT
3-regular_expressions_and_languages.ppt 1
PDF
Prove that is L is regular and h is a homomorphism, then h(L) is.pdf
PPTX
L_2_apl.pptx
Closure Properties of Regular Languages.ppt
Unit-2. Regular Expressions and Languages.pptx
Unit ii
3-regular_expressions_and_languages (1).ppt
3-regular_expressions_and_languages (1).ppt
3-regular_expressions_and_languages.ppt 1
Prove that is L is regular and h is a homomorphism, then h(L) is.pdf
L_2_apl.pptx

Similar to Closure Properties of Regular Languages.ppt (20)

PPT
Regular expression with DFA
PPTX
AUTOMATA AUTOMATA Automata4Chapter3.pptx
PPTX
Unit2 Toc.pptx
PDF
PPT
RegularExpressions-theory of computation and formal language
PPT
PPT
re1.ppt
PPT
Re1 (3)
PPT
regular expression smmlmmmmmmmmmmmmm.ppt
PPT
regular expression to automata toc flat,
PPTX
Mod 2_RegularExpressions.pptx
PDF
RegularExpressions.pdf
PDF
Lecture: Regular Expressions and Regular Languages
PPTX
RegularLanguage.pptx
PPTX
Ch2 automata.pptx
DOCX
Regular Expression .docx
PPT
rs1.ppt
PPT
1LECTURE 8 Regular_Expressions.ppt
PDF
Flat unit 2
Regular expression with DFA
AUTOMATA AUTOMATA Automata4Chapter3.pptx
Unit2 Toc.pptx
RegularExpressions-theory of computation and formal language
re1.ppt
Re1 (3)
regular expression smmlmmmmmmmmmmmmm.ppt
regular expression to automata toc flat,
Mod 2_RegularExpressions.pptx
RegularExpressions.pdf
Lecture: Regular Expressions and Regular Languages
RegularLanguage.pptx
Ch2 automata.pptx
Regular Expression .docx
rs1.ppt
1LECTURE 8 Regular_Expressions.ppt
Flat unit 2
Ad

Recently uploaded (20)

PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Internet of Things (IOT) - A guide to understanding
DOCX
573137875-Attendance-Management-System-original
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Artificial Intelligence
PPTX
Geodesy 1.pptx...............................................
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
PPT on Performance Review to get promotions
PDF
composite construction of structures.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Current and future trends in Computer Vision.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
Automation-in-Manufacturing-Chapter-Introduction.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Lecture Notes Electrical Wiring System Components
Internet of Things (IOT) - A guide to understanding
573137875-Attendance-Management-System-original
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Artificial Intelligence
Geodesy 1.pptx...............................................
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
bas. eng. economics group 4 presentation 1.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPT on Performance Review to get promotions
composite construction of structures.pdf
Foundation to blockchain - A guide to Blockchain Tech
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Current and future trends in Computer Vision.pptx
R24 SURVEYING LAB MANUAL for civil enggi
Ad

Closure Properties of Regular Languages.ppt

  • 1. 1 Closure Properties of Regular Languages Union, Concatenation, Closure, Intersection, Difference, Reversal, Homomorphism, and Inverse Homomorphism
  • 2. 2 Review Closure Properties A closure property is a statement that a certain operation on languages, when applied to languages in a class (e.g., the regular languages), produces a result that is also in that class.
  • 3. 3 Closure Under Union If L and M are regular languages, so is L  M. Proof: Let R and S be the REs that define L and M. Then R+S is a regular expression whose regular language is L  M. Therefore, regular languages are closed under union
  • 4. 4 Closure Under Concatenation and Closure Same idea: RS is a regular expression whose language is LM; therefore LM is regular. R* is a regular expression whose language is L*; therefore L* is regular
  • 5. 5 Closure Under Intersection If L and M are regular languages, then LM is regular. Proof: Let L and M be DFA’s whose languages are L and M, respectively. Construct C = p-DFA of L and M Make the accepting states of C be the pairs consisting of accepting states of both L and M. String w accepted by p-DFA iff it is accepted by both DFA(L) and DFA(M)
  • 6. 6 Product DFA for Intersection A B 0 1 0, 1 1 C D 1 0 0 [A,C] [A,D] 0 [B,C] 1 0 1 0 1 [B,D] 0 1 L M P-DFA(L  M ) Which state of p-DFA do we choose for the accepting state?
  • 7. 7 Product DFA for Intersection A B 0 1 0, 1 1 C D 1 0 0 [A,C] [A,D] 0 [B,C] 1 0 1 0 1 [B,D] 0 1 L M P-DFA(L  M ) String 11 accepted by p- DFA. P-DFA not empty and defines (LM ), which is regular.
  • 8. 8 Closure Under Difference L– M = strings in L but not M. If L and M are regular languages, then so is L-M Proof: Let L and M be DFA’s whose languages are L and M, respectively. Construct C = p-DFA of L and M. Make the accepting states of C be the pairs where L-state is accepting but M-state is not. p-DFA defines the RL of L-M.
  • 9. 9 Product DFA for Difference L- M A B 0 1 0, 1 C D 1 1 0 0 [A,C] [A,D] 0 [B,C] 1 0 1 0 1 [B,D] 0 1 Which state do we choose as the accepting state? L M p-DFA(L-M)
  • 10. 10 Product DFA for Difference A B 0 1 0, 1 C D 1 1 0 0 [A,C] [A,D] 0 [B,C] 1 0 1 0 1 [B,D] 0 1 p-DFA(L-M) is the empty language in this case. Proof still valid. We used the same p-DFA to show that L=M. L-M is RL with no strings L M p-DFA(L-M)
  • 11. 11 Closure Under Complementation: Recall Σ* denotes all string that can be formed from alphabet Σ. The complement of a language L (with respect to an alphabet Σ such that Σ* contains L) is Σ* – L. Since Σ* is regular, the complement of a regular language is regular because it is the difference of regular languages.
  • 12. 12 Closure Under Reversal Given language L, LR is the set of strings whose reversal is in L. Example: L = {0, 01, 100}; LR = {0, 10, 001}. Reversal of all sting in LR are in L Prove that RLs are closed under reversal: Let E be a regular expression for L. We show how to reverse E, to obtain a regular expression ER for LR .
  • 13. 13 Reversal of a Regular Expression Basis: If E = a, ε, or ∅, then ER = E. Induction: If E=F+G, then ER = FR + GR . If E=FG, then ER = GR FR If E=F*, then ER = (FR )*. Example find ER of 0(10)* + 10*
  • 14. 14 Example: Reversal of a RE Let E = 0(10)* + 10*. ER = (0(10)*)R + (10*)R (union rule) = ((10)*)R 0R + (0*)R 1R (concat. rule) = ((10)*)R 0+ (0*)R 1 (basis) = ((0R 1R )*0 + (0R )*1 (closure rules) = (01)*0 + 0*1 (basis)
  • 15. 15 Homomorphisms A homomorphism on an alphabet is a function that assigns a string to every symbol in that alphabet Example on ={0,1} Define h(0) = ab h(1) = ε Extend to strings by h(a1…an) = h(a1)…h(an) example: h(01010) = ababab h(L)={h(w)|w is in L}=homomorphism of L Language formed by applying h to every string in L
  • 16. 16 Closure Under Homomorphism If L is a regular language, and h is a homomorphism on its alphabet, then h(L)= {h(w)|w is in L} is also a regular language. Proof: Let E be a regular expression for L. Apply h to each symbol in E. Language of resulting RE, h(L), is regular
  • 17. 17 h(0) = ab; h(1) = ε. L is the language of RE = 01* + 10* Find the RE of h(L) and simplify Do on board Exercise:
  • 18. 18 h(0) = ab; h(1) = ε. L is the language of RE = 01* + 10* RE of h(L)=abε* + ε(ab)* ε* = ε ε is the identity under concatenation. abε*+ε(ab)*=abε+ε(ab)*=ab+(ab)*. ab is contained in (ab)* RE for h(L) is (ab)*
  • 19. 19 Inverse Homomorphism of a string h-1 (w) notation for inverse homomorphism of w w’=h-1 (w), iff h(w’)=w Given h, to answer the question “Is w’ an inverse homomorphism of w?”, apply h to every character in w’ If the result is w, then w’=h-1 (w)
  • 20. 20 Inverse homomorphisms of a language Let  be the alphabet of L Let h be a homomorphism defined on  Let h(L) be a homomorphism defined on L Let h-1 (L) be an inverse homomorphism of L defined by h(L) h-1 (L) ={w’ in | such that h(w’) is in h(L)}
  • 21. 21 Finding h-1 (L) Only practical if h(L) contains just a few strings Suppose h(L) contains w1 and w2 Let h(L) be a homomorphism of L defined on  h-1 (L) consist of all strings w’ that can be constructed from characters in  such that h(w’) is w1 or w2 Only practical if  contains just a few characters
  • 22. 22 Example of an h-1 (L) problem Let h(0) = ab; h(1) = ε. Let h(L) = {abab, baba} Find h-1 (L)
  • 23. 23 Solution of h-1 (L) problem ={0,1} h(0) = ab; h(1) = ε. h(L) = {abab, baba} h-1 (L) = {all w defined on {0,1} such that h(w) is either abab or baba} No w such that h(w) = baba. h-1 (L) = any w with two 0’s and any number of 1’s because h(w)=abab All 1’s become ε that is identity of concat.