You are on page 1of 31

Properties of

Regular Languages
For regular languages L1 and L2
we will prove that:

Union: L1  L2
Concatenation: L1L2
Star: L1 * Are regular
Languages
R
Reversal: L1
Complement: L1
Intersection: L1  L2
Courtesy Costas Busch - RPI 2
A useful transformation: use one accept state

Any NFA can be converted

to an equivalent NFA

with a single final state

Courtesy Costas Busch - RPI 3


Example
a
NFA
a b

a Equivalent NFA

a b

b 

Courtesy Costas Busch - RPI 4
In General
NFA

Equivalent NFA

 Single
 final state
Courtesy Costas Busch - RPI 5
Extreme Case

NFA without final state

Add a final state


Without transitions

Courtesy Costas Busch - RPI 6


We say: Regular languages are closed under

Union: L1  L2
Concatenation: L1L2
Star: L1 *
R
Reversal: L1
Complement: L1
Intersection: L1  L2
Courtesy Costas Busch - RPI 7
Let us take two languages

Regular language L1 Regular language L2

LM1   L1 LM 2   L2

NFA M1 NFA M2

Single final state Single final state


Courtesy Costas Busch - RPI 8
Example
M1
n0
a
n
L1  {a b} b

M2
b a
L2  ba

Courtesy Costas Busch - RPI 9


Show Regular languages are closed under

Union: L1  L2
Concatenation: L1L2
Star: L1 *
HOW?
R
Reversal: L1
Complement: L1
Intersection: L1  L2
Courtesy Costas Busch - RPI 10
Union
NFA for L1  L2
M1

 

 M2 

Courtesy Costas Busch - RPI 11


Example
n
NFA for L1  L2  {a b}  {ba}
n
L1  {a b}
a
b
 

 L2  {ba} 
b a
Courtesy Costas Busch - RPI 12
Show Regular languages are closed under

Union: L1  L2
Concatenation: L1L2
Star: L1 *
HOW?
R
Reversal: L1
Complement: L1
Intersection: L1  L2
Courtesy Costas Busch - RPI 13
Concatenation

NFA for L1L2

M1 M2
 

Courtesy Costas Busch - RPI 14


Example

n n
NFA for L1L2  {a b}{ba}  {a bba}

n
L1  {a b}
a L2  {ba}
b  b a 

Courtesy Costas Busch - RPI 15


Show Regular languages are closed under

Union: L1  L2
Concatenation: L1L2
Star: L1 *
HOW?
R
Reversal: L1
Complement: L1
Intersection: L1  L2
Courtesy Costas Busch - RPI 16
Star Operation
NFA for L1 *

  L1 *
M1
 


Courtesy Costas Busch - RPI 17
Example

n w  w1w2  wk
NFA for L1*  {a b} * wi  L1

n
L1  {a b}
a
 b 


Courtesy Costas Busch - RPI 18
Show Regular languages are closed under

Union: L1  L2
Concatenation: L1L2
Star: L1 *
HOW?
R
Reversal: L1
Complement: L1
Intersection: L1  L2
Courtesy Costas Busch - RPI 19
Reverse
R
NFA for L1
L1 M1 M1

1. Reverse all transitions

2. Make initial state final state


and vice versa
Courtesy Costas Busch - RPI 20
Example

M1
a
n
L1  {a b} b

M1
a
R n
L1  {ba } b

Courtesy Costas Busch - RPI 21


Courtesy Costas Busch - RPI 22
Show Regular languages are closed under

Union: L1  L2
Concatenation: L1L2
Star: L1 *
HOW?
R
Reversal: L1
Complement: L1
Intersection: L1  L2
Courtesy Costas Busch - RPI 23
Complement

L1 M1 L1 M1

1. Take the DFA that accepts L1

2. Make final states non-final,


and vice-versa
Courtesy Costas Busch - RPI 24
Example
M1
a a, b
n b a, b
L1  {a b}

M1
n a a, b
L1  {a, b} * {a b}
b a, b

Courtesy Costas Busch - RPI 25


Show Regular languages are closed under

Union: L1  L2
Concatenation: L1L2
Star: L1 *
HOW?
R
Reversal: L1
Complement: L1
Intersection: L1  L2
Courtesy Costas Busch - RPI 26
Intersection

L1 regular
We L1  L2
show
L2 regular regular

Courtesy Costas Busch - RPI 27


Proof for Intersection Closure

Machine M1 Machine M2
DFA for L1 DFA for L2

Construct a new DFA M that accepts L1  L2

M simulates in parallel M1 and M 2


Courtesy Costas Busch - RPI 28
M simulates in parallel M1 and M 2

M accepts string w if and only if:


M1 accepts string w
and M 2 accepts string w

L ( M )  L ( M1 )  L ( M 2 )
Courtesy Costas Busch - RPI 29
Another Proof for Intersection Closure
DeMorgan’s Law: L1  L2  L1  L2
L1 , L2 regular
L1 , L2 regular
L1  L2 regular
L1  L2 regular
L1  L2 regular
Courtesy Costas Busch - RPI 30
Example

n
L1  {a b} regular
L1  L2  {ab}
L2  {ab, ba} regular regular

Courtesy Costas Busch - RPI 31

You might also like