CS2303-THEORY OF COMPUTATION Closure Properties of Regular Languages www.nskinfo.com && www.nsksofttch.com Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Closure Properties of Regular Languages
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. For regular languages, we can use any of its representations to prove a closure property.
Closure Property …. Resultant languages obtained by performing some operations on regular languages are also regular Union Intersection Complement Difference Kleene’s star Concatenation Reversal Homomorphism Inverse Homomorphism
Closure of Regular languages under boolean operations Or : Let L and M be languages over alphabet ∑. Then L ᴜ M is the language that contains all strings that are are in either or both of L and M. And: Let L and M be languages over alphabet ∑. Then L ∩ M is the language that contains all strings that are both in L and M. * : Let L be a language over alphabet ∑. Then L’, the complement of L, is the set of strings in ∑* that are not in L.
Closure Under Union If L and M are regular languages, so is L M. Proof: Let L and M be the languages of regular expressions R and S, respectively. Then R+S is a regular expression whose language is L M.
Closure Under Concatenation and Kleene Closure Same idea: RS is a regular expression whose language is LM. R* is a regular expression whose language is L*.
Closure under Complement Operator Represented by L’ or Lᶜ. Denoted by L’ = ∑* - L Introduce a new state called “Dead ” state and transitions are added from the states to the dead state on left out input symbols Accepting states are made as non accepting and vice versa
Closure of regular languages under Intersection operator The intersection of two sets is the set of elements that are not in the complement of either set. Using Demorgans Law
Closure of regular languages under Intersection …… If L and M are regular languages, then so is L M. Proof: Let A and B be DFA’s whose languages are L and M, respectively. Construct C, the product automaton of A and B. Make the final states of C be the pairs consisting of final states of both A and B.
Example: Product DFA for Intersection 1 [A,C] [A,D] A B 1 0, 1 1 1 1 [B,C] [B,D] 1 C D 1
Closure under Difference Operator L-M is the difference of L and M, is the set of strings that are in language L but not in language M. L – M = L ∩ M’ Property of the language and set theory Since regular languages are closed under complement and intersection operators it may be concluded that L1 – L2 is also regular
Closure under Difference ….. Proof: Let A and B be DFA’s whose languages are L and M, respectively. Construct C, the product automaton of A and B. Make the final states of C be the pairs where A-state is final but B-state is not.
Example: Product DFA for Difference 1 [A,C] [A,D] A B 1 0, 1 1 1 1 [B,C] [B,D] 1 C D Notice: difference is the empty language 1
Reversal of a language Reversal of a string w with symbols a1 a2….an is a string represented as WR with symbols ana n-1….a1 For example if W =110110 then WR = 011011.
Closure under Reversal of a language Given language L, LR is the set of strings whose reversal is in L. Example: L = {0, 01, 100}; LR = {0, 10, 001}. Proof: Let E be a regular expression for L. We show how to reverse E, to provide a regular expression ER for LR.
Reversal of a Regular Expression Basis: If E is a symbol a, ε, or ∅, then ER = E. Induction: If E is F+G, then ER = FR + GR. FG, then ER = GRFR F*, then ER = (FR)*.
Set of states in M2 are same as that of M1 Initial state is a new state with transitions to all accepting states of M1 Final state is only one state and that is the initial state of M1 Reverse all transitions (i.e.) (p, a) = q, are rewritten as (q, a) = p
All the transitions are reversed
Homomorphism Substitute a particular string for each symbol. Denoted by h(L) Ex: h(0) =ab h(1)=Є if the string w=0011 then h(w)=h(0)h(0)h(1)h(1) =abab Theorem: If L is a regular language over alphabet ∑ and h is a homomorphism on ∑, then h(L) is also regular language.
Inverse Homomorphism Let L be the language over alphabet T. Then h-1(L) is the set of string w in ∑ * such that h(w) is in L. h-1(L) = {w | h(w) is in L}. Ex: r=(010)* h(0) =a h(1)=bb h-1(L) =(abba)* Theorem: If h is a homomorphism from alphabet ∑ to alphabet T, and L is a regular language over T, then h-1(L) the inverse homomorphism of the language L is also a regular language.