Properties of Regular Languages Fall 2006 Costas Busch - RPI For regular languages we will prove that: Union: Concatenation: L1 and L1 L2 L1L2 Star: L1 * Reversal: R L1 Complement: L1 Intersection: L1 L2 Fall 2006 L2 Costas Busch.
Download
Report
Transcript Properties of Regular Languages Fall 2006 Costas Busch - RPI For regular languages we will prove that: Union: Concatenation: L1 and L1 L2 L1L2 Star: L1 * Reversal: R L1 Complement: L1 Intersection: L1 L2 Fall 2006 L2 Costas Busch.
Properties of
Regular Languages
Fall 2006
Costas Busch - RPI
1
For regular languages
we will prove that:
Union:
Concatenation:
L1
and
L1 L2
L1L2
Star:
L1 *
Reversal:
R
L1
Complement:
L1
Intersection:
L1 L2
Fall 2006
L2
Costas Busch - RPI
Are regular
Languages
2
We say: Regular languages are closed under
Union:
Concatenation:
L1 L2
L1L2
Star:
L1 *
Reversal:
R
L1
Complement:
L1
Intersection:
L1 L2
Fall 2006
Costas Busch - RPI
3
A useful transformation: use one accept state
NFA
a
2 accept states
b
a
b
Equivalent
NFA
a
b
Fall 2006
1 accept state
a
b
Costas Busch - RPI
4
NFA
In General
Equivalent NFA
Fall 2006
Costas Busch - RPI
Single
accepting
state
5
Extreme case
NFA without accepting state
Add an accepting state
without transitions
Fall 2006
Costas Busch - RPI
6
Take two languages
Regular language
L1
Regular language
LM1 L1
NFA
Fall 2006
LM 2 L2
NFA
M1
Single accepting state
L2
M2
Single accepting state
Costas Busch - RPI
7
Example
n0
L1 {a b}
n
M1
a
b
M2
L2 ba
Fall 2006
b
Costas Busch - RPI
a
8
NFA for
L1 L2
Union
M1
Fall 2006
M2
Costas Busch - RPI
9
NFA for
Example
n
L1 L2 {a b} {ba}
L1 {a b}
n
a
b
L2 {ba}
b
Fall 2006
a
Costas Busch - RPI
10
Concatenation
NFA for
L1L2
M1
M2
Fall 2006
Costas Busch - RPI
11
Example
NFA for
L1L2 {a b}{ba} {a bba}
n
L1 {a b}
n
n
L2 {ba}
a
b
Fall 2006
b
Costas Busch - RPI
a
12
Star Operation
NFA for L1 *
w w1w2 wk
wi L1
M1
L1 *
Fall 2006
Costas Busch - RPI
13
Example
NFA for
L1* {a b} *
n
L1 {a b}
n
a
b
Fall 2006
Costas Busch - RPI
14
Reverse
R
NFA for L1
L1
M1
M1
1. Reverse all transitions
2. Make initial state accepting state
and vice versa
Fall 2006
Costas Busch - RPI
15
Example
M1
a
L1 {a b}
n
b
a
R
L1
Fall 2006
{ba }
n
M1
b
Costas Busch - RPI
16
Complement
L1
M1
L1
1. Take the DFA that accepts
M1
L1
2. Make accepting states non-final,
and vice-versa
Fall 2006
Costas Busch - RPI
17
Example
M1
a, b
a
L1 {a b}
n
b
L1 {a, b} * {a b}
n
M1
a, b
a
b
Fall 2006
a, b
Costas Busch - RPI
a, b
18
Intersection
L1
regular
We show
L2
Fall 2006
regular
L1 L2
regular
Costas Busch - RPI
19
DeMorgan’s Law:
Fall 2006
L1 L2 L1 L2
L1 , L2
regular
L1 , L2
regular
L1 L2
regular
L1 L2
regular
L1 L2
regular
Costas Busch - RPI
20
Example
L1 {a b} regular
n
L2 {ab, ba} regular
Fall 2006
Costas Busch - RPI
L1 L2 {ab}
regular
21
Another 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
Fall 2006
Costas Busch - RPI
22
States in M
qi , p j
State in
Fall 2006
M1
State in
Costas Busch - RPI
M2
23
DFA
q1
DFA
M1
a
q2
a
p1
transition
M2
p2
transition
DFA
q1, p1
M
a
q2 , p2
New transition
Fall 2006
Costas Busch - RPI
24
DFA
DFA
M1
M2
q0
p0
initial state
initial state
DFA
M
q0 , p0
New initial state
Fall 2006
Costas Busch - RPI
25
DFA M1
DFA
pj
qi
accept state
M2
pk
accept states
DFA
M
qi , p j
qi , pk
New accept states
Both constituents must be accepting states
Fall 2006
Costas Busch - RPI
26
Example:
n0
m0
L1 {a b}
L2 {ab }
M1
M2
n
a
q0
b
q2
m
q1
p0
a, b
b
a, b
Fall 2006
a
b
p1
a
p2
a, b
Costas Busch - RPI
27
Automaton for intersection
L {a nb} {ab n } {ab}
a, b
q0 , p0
a
b
q1, p2
q0 , p1
b
q1, p1
a
b
a
a
b
q0 , p2
q2 , p2
q2 , p1
a
b
a, b
Fall 2006
Costas Busch - RPI
28
M
simulates in parallel
M1
and
M2
M accepts string w if and only if:
and
M1
accepts string
w
M2
accepts string
w
L( M ) L( M1) L( M 2 )
Fall 2006
Costas Busch - RPI
29