Loading in 5 sec....

Regular Languages, Regular Operations, ClosurePowerPoint Presentation

Regular Languages, Regular Operations, Closure

- By
**kiral** - Follow User

- 146 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Regular Languages, Regular Operations, Closure' - kiral

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

Presentation Transcript

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

- 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

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

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

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.

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.

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

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

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

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.

Proof idea

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

q01

qF1

abb

s= abb

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

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

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)

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

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

Download Presentation

Connecting to Server..