Loading in 5 sec....

Regular Languages, Regular Operations, ClosurePowerPoint Presentation

Regular Languages, Regular Operations, Closure

- 112 Views
- Uploaded on
- Presentation posted in: General

Regular Languages, Regular Operations, Closure

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Regular Languages, Regular Operations, Closure

- 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.

The regular operations are the following:

- Union (U)
- Concatenation (o)
- Star (*)

- 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

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 Σ.

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 / ?

- 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.

- 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.

- 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

- 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

- Starting from (q01, q02) after following a,Mwill be in state (q1, q2).

q01

a

q1

q01 q02

q1 q2

a

q02

q2

a

- 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.

- Machine M1 accepts a string s if after consuming sit is in an accepting state qF1.

q01

qF1

abb

s= abb

- 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

- 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

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)

- 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}.

- L1 = {s|s contains an odd number of 1}

1

0

q01

q11

1

0

- L2 = {s|s contains an even number of 0}

1

0

q00

q10

1

0

- 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

- 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).