Lect 05
Lect 05
Lect 05
Finite Automata
Complement: L1
Intersection: L1 L2
Based on slides by Costas Busch 2
We say Regular languages are closed under
Union: L1 L2
Concatenation: L1L2
*
Star: L1
Reversal: LR
1
Complement: L1
Intersection: L1 L2
Based on slides by Costas Busch 3
A useful transformation: use one accept state
NFA
a
b 2 accept states
a
b
Equivalent
NFA
a
1 accept state
a b
b
Based on slides by Costas Busch 4
In General
NFA
Equivalent NFA
Single
accepting
state
Based on slides by Costas Busch 5
Extreme case
L(M1 ) = L1 L(M 2 ) = L2
NFA M1 NFA M2
M1
n0
a
L1 = {a b} n
b
M2
L2 = ba b a
M2
w L1 L2 w L1 or w L2
Based on slides by Costas Busch 9
Example
L1 = {a b}n
a
b
L2 = {ba}
b a
Based on slides by Costas Busch 10
Concatenation
NFA for L1L2
change to
regular state
M1 M2
w L1 L2 w = w1w2 : w1 L1 and w2 L2
L1 = {a b} n
a L2 = {ba}
b b a
w = w1w2 wk : wi L
w L *
or w =
Based on slides by Costas Busch 13
Example
L1 = {a b}
n
a
b
Based on slides by Costas Busch 14
Reverse
R
NFA for L
M M
L( M ) = L L( M ) = LR
M1
a
L1 = {a b} n
b
M 1
a
L = {ba }
R
1
n
b
M M
L( M ) = L L( M ) = L
M1
a a, b
L1 = {a b} n b a, b
M 1
a a, b
L1 = {a, b} − {a b} * n
b a, b
NFA M NFA M
L( M ) = {} L( M ) = { } L( M )
it is not the
L( M ) = = {a, b}
* *
complement
L( M ) = {} L( M ) = {a, b}* = L( M )
it is the
L( M ) = = {a, b}
* *
complement
L1 regular
we show L1 L2
L2 regular regular
L1 , L2 regular, regular
L1 , L2 regular, regular
L1 L2 regular
L1 L2 regular
L1 L2 regular
Based on slides by Costas Busch 22
Example
L1 = {a b} n regular
L1 L2 = {ab}
L2 = {ab, ba} regular regular
Machine M1 Machine M2
DFA for L1 DFA for L2
qi , p j
State in M1 State in M2
q1 a q2 p1 a p2
transition transition
DFA M
q1, p1 a q2 , p2
New transition
Based on slides by Costas Busch 26
DFA M1 DFA M2
q0 p0
initial state initial state
DFA M
q0 , p0
New initial state
Based on slides by Costas Busch 27
DFA M1 DFA M2
qi pj pk
DFA M
qi , p j qi , pk
n0 m0
L1 = {a b} n
L2 = {ab } m
M1 M2
a b
q0 b q1 p0 a p1
a, b b a
q2 p2
a, b a, b
Based on slides by Costas Busch 29
DFA M for intersection
L( M ) = {a b} {ab } = {ab}
n m
a, b
q0 , p0 a q0 , p1 b q1, p1 a q2 , p2
b a b a
q1, p2 b q0 , p2 q2 , p1
a b
a, b
Based on slides by Costas Busch 30
Construction procedure for intersection
L = {a b} {ab } = {ab}
n m
q0 , p0
initial state
L = {a b} {ab } = {ab}
n m
q0 , p0 a q0 , p1
add transition and new state
for symbol a M1 M2
q0 a q0 p0 a p1
q0 , p0 a q0 , p1
L = {a b} {ab } = {ab}
n m
q0 , p0 a q0 , p1
b M1 M2
q0 b q1 p0 b p2
q1, p2
L = {a b} {ab } = {ab}
n m
q0 , p0 a q0 , p1 b q1, p1 a q2 , p2
b a b a
q1, p2 b q0 , p2 q2 , p1
a b
a, b
L = {a b} {ab } = {ab}
n m
q0 , p0 a q0 , p1 b q1, p1 a q2 , p2
b a b a
q1, p2 b q0 , p2 q2 , p1
a b
a, b
M1 accepts string w
and M2 accepts string w
L ( M ) = L ( M1 ) L ( M 2 )
Based on slides by Costas Busch 37
Follow-Up / Further Reading
• Read Chapter 1.2 of Sipser
• Read Chapter 2.5 of Wilson