8 Regular Properties
8 Regular Properties
Regular Languages
For regular languages L1 and L2
we will prove that:
Union: L1 L2
Concatenation: L1L2
Complement: L1
Intersection: L1 L2
We say: Regular languages are closed under
Union: L1 L2
Concatenation: L1L2
Star: L1 *
Reversal: L R
1
Complement: L1
Intersection: L1 L2
A useful transformation: use one accept state
NFA
a
b 2 accept states
a
b
Equivalent
NFA
a
1 accept state
a b
b
In General
NFA
Equivalent NFA
Single
accepting
state
Extreme case
L M 1 L1 L M 2 L2
NFA M1 NFA M 2
M1
n0
a
n
L1 {a b} b
M2
L2 ba b a
Union
NFA for L1 L2
M1
M2
Example
n
NFA for L1 L2 {a b} {ba}
n
L1 {a b}
a
b
L2 {ba}
b a
Concatenation
M1 M2
Example
n n
NFA for L1L2 {a b}{ba} {a bba }
n
L1 {a b}
a
L2 {ba}
b b a
Star Operation
NFA for L1 * w w1w2 wk
wi L1
M1
L1 *
Example
n
NFA for L1* {a b} *
n
L1 {a b}
a
b
Reverse
R
NFA for L1
L1 M1 M1
M1
a
n
L1 {a b} b
M1
a
R n
L1 {ba } b
Complement
L1 M1 L1 M1
M1
a a, b
n
L1 {a b} b a, b
M1
n a a, b
L1 {a , b} * {a b}
b a, b
Intersection
L1 regular
We show L1 L2
L2 regular regular
DeMorgan’s Law: L1 L2 L1 L2
L1 , L2 regular
L1 , L2 regular
L1 L2 regular
L1 L2 regular
L1 L2 regular
Example
n
L1 {a b} regular
L1 L2 {ab}
L2 {ab , ba} regular regular
Another Proof for Intersection Closure
Machine M 1 Machine M 2
DFA for L1 DFA for L2
qi , p j
State in M 1 State in M 2
DFA M 1 DFA M 2
q1 a q2 p1 a p2
transition transition
DFA M
q1 , p1 a q2 , p2
New transition
DFA M 1 DFA M 2
q0 p0
initial state initial state
DFA M
q0 , p0
New initial state
DFA M 1 DFA M 2
qi pj pk
DFA M
qi , p j qi , pk
n0 m0
n m
L1 {a b} L2 {ab }
M1 M2
a b
q0 b q1 p0 a p1
a, b b a
q2 p2
a, b a, b
Automaton for intersection
L {a nb} {ab n } {ab}
a, b
q0 , p0 a q0 , p1 b q1, p1 a q2 , p2
b a b a
q1, p2 b q0 , p 2 q2 , p1
a b
a, b
M simulates in parallel M 1 and M 2