Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism.

Similar presentations


Presentation on theme: "1 Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism."— Presentation transcript:

1 1 Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism

2 2 Closure Properties uRecall 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. uFor regular languages, we can use any of its representations to prove a closure property.

3 3 Closure Under Union uIf L and M are regular languages, so is L  M. uProof: Let L and M be the languages of regular expressions R and S, respectively. uThen R+S is a regular expression whose language is L  M.

4 4 Closure Under Concatenation and Kleene Closure uSame idea: wRS is a regular expression whose language is LM. wR* is a regular expression whose language is L*.

5 5 Closure Under Complementation  The complement of a language L (with respect to an alphabet Σ such that Σ * contains L) is Σ * – L. uProof: if A is DFA for L then A¯ is DFA that accepted states  unaccepted states and unaccepted states  accepted states.

6 6 Closure Under Intersection uIf L and M are regular languages, then so is L  M. uProof: L and M are regular so L¯ and M ¯ are regular. So L¯  M ¯ is regular. uDemorgan Rule: (L¯  M ¯ ) ¯ = L  M is regular.

7 7 Closure Under Difference uIf L and M are regular languages, then so is L – M = strings in L but not M. uProof: L – M = L  M ¯

8 8 Closure Under Reversal u If L is regular Language then L R is regular. uProof: if A is DFA for L then A R is DFA that : w1) q 0 is final state. w2) q f is start state. w3) Reverse all transitions.

9 9 Closure Under Reversal – (2) uGiven language L, L R is the set of strings whose reversal is in L. uExample: L = {0, 01, 100}; L R = {0, 10, 001}. uProof: Let E be a regular expression for L. uWe show how to reverse E, to provide a regular expression E R for L R.

10 10 Reversal of a Regular Expression  Basis: If E is a symbol a, ε, or ∅, then E R = E. uInduction: If E is wF+G, then E R = F R + G R. wFG, then E R = G R F R wF*, then E R = (F R )*.

11 11 Example: Reversal of a RE uLet E = 01* + 10*. uE R = (01* + 10*) R = (01*) R + (10*) R u= (1*) R 0 R + (0*) R 1 R u= (1 R )*0 + (0 R )*1 u= 1*0 + 0*1.

12 12 Homomorphisms uA homomorphism on an alphabet is a function that gives a string for each symbol in that alphabet.  Example: h(0) = ab; h(1) = ε. uExtend to strings by h(a 1 …a n ) = h(a 1 )…h(a n ). uExample: h(01010) = ababab.

13 13 Closure Under Homomorphism uIf 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. uProof: Let E be a regular expression for L. uApply h to each symbol in E. uLanguage of resulting RE is h(L).

14 14 Example: Closure under Homomorphism  Let h(0) = ab; h(1) = ε. uLet L be the language of regular expression 01* + 10*.  Then h(L) is the language of regular expression ab ε * + ε (ab)*. Note: use parentheses to enforce the proper grouping.

15 15 Example – Continued  ab ε * + ε (ab)* can be simplified.  ε * = ε, so ab ε * = ab ε.  ε is the identity under concatenation.  That is, ε E = E ε = E for any RE E.  Thus, ab ε * + ε (ab)* = ab ε + ε (ab)* = ab + (ab)*. uFinally, L(ab) is contained in L((ab)*), so a RE for h(L) is (ab)*.


Download ppt "1 Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism."

Similar presentations


Ads by Google