1 / 21

Regular Languages, Regular Operations, Closure

Regular Languages, Regular Operations, Closure. Regular Languages. We say that a language L is regular iff there is a DFA that accepts L. The regular languages is the set of languages that dfas accept. Regular Operations. The regular operations are the following: Union (U)

kiral
Download Presentation

Regular Languages, Regular Operations, Closure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Regular Languages, Regular Operations, Closure

  2. Regular Languages • We say that a language L is regular iff there is a DFA that accepts L. • The regular languages is the set of languages that dfas accept.

  3. Regular Operations The regular operations are the following: • Union (U) • Concatenation (o) • Star (*)

  4. Regular Operations • L1 U L2 = {x|x L1 or x L2} • L1o L2 = {xy|x L1 and y L2} • Lk = L o L o … o L, k times , L0 = {ε} • L* = Lk for any k ≥ 0 • L+ = Lk for any k > 0

  5. Regular Operations Examples L1 = {a, b}, L2 = {b, c} • L1 U L2= {a, b, c} • L1 oL2 = {ab, ac, bb, bc} • L1 2= {aa, ab, ba, bb} • L1* = {ε, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, bab, bba, bbb, aaaa, aaab, aaba, …} • Σ*is the set of all possible strings of an alphabet Σ.

  6. Closure To show that a set is closed under an operation we should prove that, if we apply the operation on members of the set then the result belongs in the set. Example: The set of natural numbers N is closed under +, because if we add any two numbers in N the result is still in N. However, N is not closed under -, since 3-5 = -2 which is not in N. Question: Is Z closed under -? What about / ?

  7. Regular Languages are closed under union. • We should prove that if L1 and L2 are regular then L = L1 L2 is also regular. • Since L1 and L2 are regular there exist DFAs M1 and M2 that accept them. • It suffices to show that there exist a DFA M that accepts L. • We construct a DFA that accepts L.

  8. Proof idea • I want to construct a DFA M that will simulate both M1 and M2 running in parallel.This machine should keep track of what happened to either machine after following a symbol a of the alphabet.

  9. Proof idea • Start from q01 in M1 and q02 in M2. After following a symbol a the first machine will be in state q1 and the second in q2. q01 a q1 q02 q2 a

  10. Proof idea • I want the new machine to remember both states that can be reached after following a. Thus I am going to create a new state containing a pair of both states . q01 a q1 q01 q02 q1 q2 q02 q2 a

  11. Proof idea • Starting from (q01, q02) after following a,Mwill be in state (q1, q2). q01 a q1 q01 q02 q1 q2 a q02 q2 a

  12. Proof idea • Now it is left to find which of these pairs of states will be the accepting ones. • I want to construct a DFA M that accepts the union L1 U L2, that is all the strings which are accepted by either of the DFAs M1, M2.

  13. Proof idea • Machine M1 accepts a string s if after consuming sit is in an accepting state qF1. q01 qF1 abb s= abb

  14. Proof idea • Thus any pair (qF1,q2) that contains qF1 should be an accepting state in M. q01 qF1 abb q01 q02 qF1 q2 abb abb q02 q2 s= abb

  15. Proof idea • Same for M2. If qF2 is an accepting state, any state (q1, qF2) should be an accepting state of M. q01 q1 aba q01 q02 q1 qF2 aba aba q02 qF2 s= aba

  16. A DFA that accepts L1 U L2 Assume that M1 = {Q1, Σ ,δ1 ,q01 ,F1} and M2 = {Q2, Σ ,δ2 ,q02 ,F2}. Then M = {Q, Σ, δ, q0, F}, where • Q = Q1 x Q2 • δ((q1,q2), a) = (δ1(q1, a), δ2(q2, a)) • q0 = (q01, q02) • F = (Q1 x F2) (F1 x Q2)

  17. Example • Construct a DFA that accepts the language L = L1 U L2, where : • L1 = {s|s contains an odd number of 1} and • L2 = {s|s contains an even number of 0}.

  18. Example • L1 = {s|s contains an odd number of 1} 1 0 q01 q11 1 0

  19. Example • L2 = {s|s contains an even number of 0} 1 0 q00 q10 1 0

  20. Example • L = L1 U L2 1 0 q00 q11 0 q01 q11 1 1 1 0 0 q00 q01 q10q11 0 1 1 0 q00 q10 0 q10q01 1 1 0

  21. Question • What if I would like to construct a DFA that accepts the intersection of two regular languages? (in other words show that the regular languages are closed under the intersection).

More Related