Presentation is loading. Please wait.

Presentation is loading. Please wait.

Closure Properties of Regular Languages

Similar presentations


Presentation on theme: "Closure Properties of Regular Languages"— Presentation transcript:

1 Closure Properties of Regular Languages
Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, 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, RLs are closed under union

4 Closure Under Concatenation and Kleene 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 A and B be DFA’s whose languages are L and M, respectively. Construct C = p-DFA of A and B States of C are distinct pairs [q(A),r(B)] Start state is pair [start(A), start(B)] δ([q(A),r(B)],a) = [δA(q,a), δB(r,a)] Make the accepting states of C be the pairs consisting of accepting states of both A and B.

6 Product DFA for Intersection
B 1 0, 1 P-DFA(L  M ) L [A,C] [A,D] 1 1 1 1 C D [B,C] [B,D] 1 M Which state of p-DFA do we choose for the accepting state?

7 Product DFA for Intersection
B 1 0, 1 P-DFA(L  M ) L [A,C] [A,D] 1 1 1 1 C D [B,C] [B,D] 1 M String w accepted by p-DFA iff it is accepted by both DFA(L) and DFA(M). P-DFA 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 A and B be DFA’s whose languages are L and M, respectively. Construct C = p-DFA of A and B. Make the accepting states of C be the pairs where A-state is accepting but B-state is not. p-DFA defines the RL of L-M.

9 Product DFA for Difference L-M
B 1 0, 1 p-DFA(L-M) L [A,C] [A,D] 1 1 1 C D 1 [B,C] [B,D] 1 M Which state do we choose as the accepting state?

10 Product DFA for Difference
B 1 0, 1 p-DFA(L-M) L [A,C] [A,D] 1 1 1 C D 1 [B,C] [B,D] 1 M p-DFA(L-M) is the empty language in this case, why?

11 Closure Under Complementation: Recall Σ
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 language's.

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 provide 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 = GRFR If E=F*, then ER = (FR)*. Example find ER of 0(10)* + 10*. Show all steps except basis

14 Example: Reversal of a RE
Let E = 0(10)* + 10*. ER = (0(10)*)R + (10*)R (union rule) = (01*)R 0+ (0*)R1 (concat. rule + basis = ((10)R)*0 + 0*1 (closure rule + basis) = (01)*0 + 0*1. (concat + basis)

15 Homomorphisms A homomorphism on an alphabet is a function that assigns a string to every symbol in that alphabet Example on S={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 is h(L).

17 Exercise: find the RE of h(L) and simplify
h(0) = ab; h(1) = ε. L is the language of RE = 01* + 10* Find the RE of h(L) and simplify

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) is read “inverse homomorphism of w w’=h-1(w), iff h(w’)=w Given h(w), to answer the question “Is w’ an inverse homomorphism of w?’, apply h(w) to every character in w’ If the result is w then w’=h-1(w)

20 Inverse homomorphisms of a language
Let h be a homomorphism defined on S Let h(L) be a homomorphism defined on L with alphabet S Let h-1(L) be the inverse homomorphism of L defined by h(L) h-1(L) ={w’| such that h(w’) is in L}

21 Finding h-1(L) Only practical if L contains just a few strings
Suppose L contains w1 and w2 Let h(L) be a homomorphism of L defined on S h-1(L) consist of all strings w’ that can be constructed from characters in S such that h-1(w’) is w1 or w2 Only practical if S contains just a few characters

22 Example of an h-1(L) problem
Let h(0) = ab; h(1) = ε. Let L = {abab, baba} Find h-1(L)

23 Solution of h-1(L) problem
Let h(0) = ab; h(1) = ε. Let 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

24 CptS 317 Fall 2019 Assignment 11, Due Exercises (a), (c) and (e) text p 147 a) Homomorphism of a string c) Homomorphism of a language defined by RE e) Inverse homomorphism of a language L has a single string h-1(L) has a finite number of strings

25 Closure of RLs under Inverse Homomorphism Proof by construction
Start with a DFA(L) = A and h(a) homomorphism on alphabet of L Construct the ih-DFA = B for h-1(L) with: The same set of states. The same start state. The same final states. Input alphabet = the symbols to which homomorphism h applies Transition function δB(q, a) = δA(q, h(a)) δ means delta-hat

26 Example of ih-DFA Construction
Given h(0)=ab, h(1)=e and DFA defined on {a,b} Find ih-DFA a ih-DFA has following properties States A, B, and C Start state = A Accepting state = C δB(q, a) = δA(q, h(a)) q = A, B, or C a = {0,1} B a A b b b C a

27 Example of ih-DFA Construction
ih-DFA defined on {0,1} DFA defined on {a,b} 1 Since h(1) = ε a B C B A , 0 Since h(0) = ab a A b b b C a δB(q, a) = δA(q, h(a))

28 Using Closure to prove non-regular
L1 is language in question L2 is language known to be non-regular O is an operation under which regular languages are closed. L2 = O L1 If L1 were regular, then L2 would be regular, but it isn’t. Therefore L1 is not regular

29 Using Closure to prove non-regular
Example: p149 Prove L1={0i1j|i>0,j>0,i not = j} is not regular

30 Using Closure to prove non-regular
Example: p149 Prove L1={0i1j|i>0,j>0,i not = j} is not regular Assume L1 is regular Find an operations under which RLs are closed that converts L1 to a language known to be not regular L2={0n1n|n>0} is not regular L2= 0*1*-L1 implies that L2 is regular because RLs are closed under *, concatenation and difference. Since L2 is not regular, assumption that L1 is regular must be false.

31 Quiz #4: 11/4/19 Text: Chapter 4 Lecture slides: regular languages 1 and 2 Assignments: 9-11 HW9: pumping lemma HW10: minimum-state DFA HW11: Homomorphisms


Download ppt "Closure Properties of Regular Languages"

Similar presentations


Ads by Google