Regular Languages’ Closure Properties, Take 2 CS
Description: Regular Languages Closure Properties, Take 2 CS 154, Omer Reingold Reverse Theorem for Regular Languages Theorem: The reverse of a regular language is also a regular language If a language can be recognized by a DFA that reads strings from
Related Topics
Download Presentation
"Regular Languages’ Closure Properties, Take 2 CS" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Presentation Transcript
slide1. Regular Languages’
Closure Properties,Take 2 CS 154, Omer Reingold<br>
slide2. Reverse Theorem for Regular Languages Theorem: The reverse of a regular language is also a regular language If a language can be recognized by a DFA that reads strings from right to left,
then there is an “normal” DFA that accepts the same language Proof? Given a DFA for a language L, “reverse” its arrows and flip its start and accept states, getting an NFA.
Convert that NFA back to a DFA!<br>
slide3. Using NFAs in place of DFAs can make proofs about regular languages much easier! Remember this on homework/exams!<br>
slide4. Union Theorem using NFAs?<br>
slide5. Regular Languages are closed under concatenation Given DFAs M1 and M2, connect the accept states of M1 to the start states of M2 Concatenation: A B = { vw | v A and w B } ε ε L(N) = L(M1) L(M2)<br>
slide6. Regular Languages are closed under star Let M be a DFA, and let L = L(M) We can construct an NFA N that recognizes L* A* = { s1 … sk | k ≥ 0 and each si A } ε ε ε<br>
slide7. Formally, the construction is: Input: DFA M = (Q, Σ, , q1, F) Output: NFA N = (Q, Σ, , q0, F) Q = Q {q0} F = F {q0} (q,a) = {(q,a)} {q1} {q1} if q Q and a ≠ ε if q F and a = ε if q = q0 and a = ε if q = q0 and a ≠ ε else<br>
slide8. How would we prove that this NFA construction works?
Want to show: L(N) = L*
L(N) L*
L(N) L* Regular Languages are Closed Under Star<br>
slide9. 1. L(N) L* Assume w = w1…wk is in L* where w1,…,wk L We show N accepts w by induction on k Base Cases: k = 0 k = 1 Inductive Step: Assume N accepts all strings v = v1…vk L*, vi L
Let u = u1…ukuk+1 L* , uj L Since N accepts u1…uk (by induction) and
M accepts uk+1, N also accepts u (by construction) (w = ε) (w L)<br>
slide10. Assume w is accepted by N; we want to show w L* If w = ε, then w L* I.H. N accepts u and takes at most k ε-transitions u L* uL* vL 2. L(N) L* By I.H. w = uv L* uL(N), so Let w be accepted by N with k+1 ε-transitions.
Write w as w=uv,
where v is the substring read after the last ε-transition accept ε ε u v<br>
slide11. Closure Properties for Regular Languages Union: A B = { w | w A or w B } Intersection: A B = { w | w A and w B } Complement: A = { w Σ* | w A } Reverse: AR = { w1 …wk | wk …w1 A, wi Σ} Concatenation: A B = { vw | v A and w B } Star: A* = { s1 … sk | k ≥ 0 and each si A } Theorem: if A and B are regular then so are: A B, A B, A, AR , A B, and A* <br>
Closure Properties,Take 2 CS 154, Omer Reingold<br>
slide2. Reverse Theorem for Regular Languages Theorem: The reverse of a regular language is also a regular language If a language can be recognized by a DFA that reads strings from right to left,
then there is an “normal” DFA that accepts the same language Proof? Given a DFA for a language L, “reverse” its arrows and flip its start and accept states, getting an NFA.
Convert that NFA back to a DFA!<br>
slide3. Using NFAs in place of DFAs can make proofs about regular languages much easier! Remember this on homework/exams!<br>
slide4. Union Theorem using NFAs?<br>
slide5. Regular Languages are closed under concatenation Given DFAs M1 and M2, connect the accept states of M1 to the start states of M2 Concatenation: A B = { vw | v A and w B } ε ε L(N) = L(M1) L(M2)<br>
slide6. Regular Languages are closed under star Let M be a DFA, and let L = L(M) We can construct an NFA N that recognizes L* A* = { s1 … sk | k ≥ 0 and each si A } ε ε ε<br>
slide7. Formally, the construction is: Input: DFA M = (Q, Σ, , q1, F) Output: NFA N = (Q, Σ, , q0, F) Q = Q {q0} F = F {q0} (q,a) = {(q,a)} {q1} {q1} if q Q and a ≠ ε if q F and a = ε if q = q0 and a = ε if q = q0 and a ≠ ε else<br>
slide8. How would we prove that this NFA construction works?
Want to show: L(N) = L*
L(N) L*
L(N) L* Regular Languages are Closed Under Star<br>
slide9. 1. L(N) L* Assume w = w1…wk is in L* where w1,…,wk L We show N accepts w by induction on k Base Cases: k = 0 k = 1 Inductive Step: Assume N accepts all strings v = v1…vk L*, vi L
Let u = u1…ukuk+1 L* , uj L Since N accepts u1…uk (by induction) and
M accepts uk+1, N also accepts u (by construction) (w = ε) (w L)<br>
slide10. Assume w is accepted by N; we want to show w L* If w = ε, then w L* I.H. N accepts u and takes at most k ε-transitions u L* uL* vL 2. L(N) L* By I.H. w = uv L* uL(N), so Let w be accepted by N with k+1 ε-transitions.
Write w as w=uv,
where v is the substring read after the last ε-transition accept ε ε u v<br>
slide11. Closure Properties for Regular Languages Union: A B = { w | w A or w B } Intersection: A B = { w | w A and w B } Complement: A = { w Σ* | w A } Reverse: AR = { w1 …wk | wk …w1 A, wi Σ} Concatenation: A B = { vw | v A and w B } Star: A* = { s1 … sk | k ≥ 0 and each si A } Theorem: if A and B are regular then so are: A B, A B, A, AR , A B, and A* <br>