SlideShare a Scribd company logo
1 of 75
Formal Languages
NFAs Accept the Regular
Languages
Prof. Charbel Boustany
Msc Systems Engineering
PHD Genetic Algorithms (current)
IEEE Member
EQUIVALENCE OF MACHINES
 Definition:
 Machine is equivalent to machine
 if

2
1
M 2
M
   
2
1 M
L
M
L 
EXAMPLE OF EQUIVALENT MACHINES

3
0
q 1
q
0
1
0
q 1
q 2
q
0
1
1
0
1
,
0
NFA
FA
  *
}
10
{
1 
M
L
  *
}
10
{
2 
M
L
1
M
2
M
4
We will prove:
Languages
accepted
by NFAs
Regular
Languages

NFAs and FAs have the
same computation power
Languages
accepted
by FAs
5
Languages
accepted
by NFAs
Regular
Languages

Languages
accepted
by NFAs
Regular
Languages

We will show:
6
Languages
accepted
by NFAs
Regular
Languages

Proof-Step 1
Proof?
7
Languages
accepted
by NFAs
Regular
Languages

Proof-Step 1
Proof: Every FA is trivially an NFA
Any language accepted by a FA
is also accepted by an NFA
L
8
Languages
accepted
by NFAs
Regular
Languages

Proof-Step 2
Proof: Any NFA can be converted to an
equivalent FA
Any language accepted by an NFA
is also accepted by a FA
L
CONVERT NFA TO FA

9
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q
M
M 
CONVERT NFA TO FA

10
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q  
2
1,q
q
a
M
M 
CONVERT NFA TO FA

11
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q  
2
1,q
q
a

b
M
M 
CONVERT NFA TO FA

12
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q  
2
1,q
q
a

b
a
M
M 
CONVERT NFA TO FA

13
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q  
2
1,q
q
a

b
a
b
M
M 
CONVERT NFA TO FA

14
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q  
2
1,q
q
a

b
a
b
b
a,
M
M 
CONVERT NFA TO FA

15
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q  
2
1,q
q
a

b
a
b
b
a,
M
M 
  )
(M
L
M
L 

NFA TO FA CONVERSION
 We are given an NFA
 We want to convert it
 to an equivalent FA
 With
16
M
M 
  )
(M
L
M
L 

WHAT WE NEED TO CONSTRUCT
 Finite Automaton (FA)
17
 
F
q
Q
M ,
,
,
, 0



Q


0
q
F
: set of states
: input alphabet
: transition function
: initial state
: set of accepting states
 If the NFA has states
 the FA has states in the power set

18
,...
,
, 2
1
0 q
q
q
    ,....
,
,
,
,
,
,
, 7
4
3
2
1
1
0 q
q
q
q
q
q
q

PROCEDURE NFA TO FA

1. Initial state of NFA:

 Initial state of FA:
19
0
q
 
0
q
EXAMPLE

20
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q
M
M 
PROCEDURE NFA TO FA
 2. For every FA’s state
 Compute in the NFA

 Add transition to FA
21
}
,...,
,
{ m
j
i q
q
q
 
 
...
,
,
*
,
,
*
a
q
a
q
j
i


}
,...,
,
{ m
j
i q
q
q 


  }
,...,
,
{
},
,...,
,
{ m
j
i
m
j
i q
q
q
a
q
q
q 





EXAMPLE

22
a
b
a

0
q 1
q 2
q
NFA
 
0
q  
2
1,q
q
a
FA
}
,
{
)
,
(
* 2
1
0 q
q
a
q 

 
   
2
1
0 ,
, q
q
a
q 

M
M 
PROCEDURE NFA TO FA
 Repeat Step 2 for all letters in alphabet,
 until
 no more transitions can be added.
23
EXAMPLE

24
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q  
2
1,q
q
a

b
a
b
b
a,
M
M 
Done?
PROCEDURE NFA TO FA
 3. For any FA state
 If is accepting state in NFA
 Then,
 is accepting state in FA
25
}
,...,
,
{ m
j
i q
q
q
j
q
}
,...,
,
{ m
j
i q
q
q
EXAMPLE

26
a
b
a

0
q 1
q 2
q
NFA
FA
 
0
q  
2
1,q
q
a

b
a
b
b
a,
F
q 
1
  F
q
q 

2
1,
M
M 
THEOREM

27
Take NFA M
Apply procedure to obtain FA M 
Then and are equivalent :
M M 
   
M
L
M
L 

28
Proof (slide 28 – 40) (reading recommended)
   
M
L
M
L 

   
M
L
M
L 
    
M
L
M
L 

AND
29
   
M
L
M
L 

First we show:
)
(M
L
w
Take arbitrary:
We will prove: )
(M
L
w 

30
)
(M
L
w
w
k
w 

 
2
1

0
q f
q
:
M
:
M 0
q f
q
1
 2
 k

31
i

i

 
denotes

i
q j
q
i
q j
q
32
0
q f
q
k
w 

 
2
1

1
 2
 k

:
M
}
{ 0
q
1
 2
 k

:
M
}
,
{ 
f
q
)
(M
L
w
)
(M
L
w 

We will show that if
then
33
0
q m
q
n
a
a
a
v 
2
1

1
a 2
a n
a
:
M
}
{ 0
q
1
a 2
a n
a
:
M
}
,
{ 
i
q
i
q j
q l
q
}
,
{ 
j
q }
,
{ 
l
q }
,
{ 
m
q
More generally, we will show that if in :
M
(arbitrary string)
then
34
0
q 1
a
:
M
}
{ 0
q
1
a
:
M
}
,
{ 
i
q
i
q
Proof by induction on
Induction Basis: 1
a
v 
|
| v
Is true by construction of :
M
35
Induction hypothesis: k
v 
 |
|
1
0
q d
q
1
a 2
a k
a
:
M i
q j
q c
q
}
{ 0
q
1
a 2
a k
a
:
M
}
,
{ 
i
q }
,
{ 
j
q }
,
{ 
c
q }
,
{ 
d
q
k
a
a
a
v 
2
1

36
Induction Step: 1
|
| 
 k
v
0
q d
q
1
a 2
a k
a
:
M i
q j
q c
q
}
{ 0
q
1
a 2
a k
a
:
M
}
,
{ 
i
q }
,
{ 
j
q }
,
{ 
c
q }
,
{ 
d
q
1
1
2
1 




 k
k
v
k a
v
a
a
a
a
v






v
v
37
Induction Step: 1
|
| 
 k
v
0
q d
q
1
a 2
a k
a
:
M i
q j
q c
q
}
{ 0
q
1
a 2
a k
a
:
M
}
,
{ 
i
q }
,
{ 
j
q }
,
{ 
c
q }
,
{ 
d
q
1
1
2
1 




 k
k
v
k a
v
a
a
a
a
v






v
v
e
q
1

k
a
1

k
a
}
,
{ 
e
q
38
0
q f
q
k
w 

 
2
1

1
 2
 k

:
M
}
{ 0
q
1
 2
 k

:
M
}
,
{ 
f
q
)
(M
L
w
)
(M
L
w 

Therefore if
then
39
We have shown:    
M
L
M
L 

We also need to show:    
M
L
M
L 

(proof is similar)
40
Induction Step: 1
|
| 
 k
v
0
q d
q
1
a 2
a k
a
:
M i
q j
q c
q
}
{ 0
q
1
a 2
a k
a
:
M
}
,
{ 
i
q }
,
{ 
j
q }
,
{ 
c
q }
,
{ 
d
q
1
1
2
1 




 k
k
v
k a
v
a
a
a
a
v






v
v
e
q
1

k
a
1

k
a
}
,
{ 
e
q
All cases covered?
SINGLE ACCEPTING
STATE FOR NFAS
41
 Any NFA can be converted
 to an equivalent NFA
 with a single accepting state
42
43
a
b
b
a NFA
Equivalent NFA
with single
accepting state?
Example
44
a
b
b
a NFA
Equivalent NFA


a
b
b
a
Example
45
NFA
In General
Equivalent NFA
Single
accepting
state



46
Extreme Case
NFA without accepting state
Add an accepting state
without transitions
PROPERTIES OF
REGULAR LANGUAGES
47
48
1
L 2
L
2
1L
L
Concatenation:
*
1
L
Star:
2
1 L
L 
Union:
Are regular
Languages
For regular languages and
we will prove that:
1
L
2
1 L
L 
Complement:
Intersection:
R
L1
Reversal:
49
We say: Regular languages are closed under
2
1L
L
Concatenation:
*
1
L
Star:
2
1 L
L 
Union:
1
L
2
1 L
L 
Complement:
Intersection:
R
L1
Reversal:
50
1
L
Regular language
  1
1 L
M
L 
1
M
Single accepting state
NFA 2
M
2
L
Single accepting state
  2
2 L
M
L 
Regular language
NFA
EXAMPLE
51
}
{
1 b
a
L n

a
b
1
M
 
ba
L 
2
a
b
2
M
0

n
UNION
 NFA for
52
1
M
2
M
2
1 L
L 


EXAMPLE

53
a
b
a
b


}
{
1 b
a
L n

}
{
2 ba
L 
}
{
}
{
2
1 ba
b
a
L
L n



NFA for
CONCATENATION
 NFA for
54
2
1L
L
1
M 2
M
 
EXAMPLE

 NFA for
55
a
b a
b
}
{
1 b
a
L n

}
{
2 ba
L 
}
{
}
}{
{
2
1 bba
a
ba
b
a
L
L n
n


 
56
How do we construct automata for the
remaining operations?
2
1L
L
Concatenation:
*
1
L
Star:
2
1 L
L 
Union:
1
L
2
1 L
L 
Complement:
Intersection:
R
L1
Reversal:
STAR OPERATION
 NFA for
57
*
1
L
1
M


*
1
L


 
EXAMPLE
 NFA for
58
*
}
{
*
1 b
a
L n

a
b
}
{
1 b
a
L n





1
2
1
L
w
w
w
w
w
i
k

 
REVERSE
59
R
L1
1
M
NFA for

1
M
1. Reverse all transitions
2. Make initial state accepting state
and vice versa
1
L
60
Example
}
{
1 b
a
L n

a
b
1
M
}
{
1
n
R
ba
L 
a
b

1
M
61
Complement
1. Take the FA that accepts 1
L
1
M
1
L 
1
M
1
L
2. Make final states non-final,
and vice-versa
Why not NFA?
62
Example
}
{
1 b
a
L n

a
b
1
M
b
a,
b
a,
}
{
*
}
,
{
1 b
a
b
a
L n

 a
b

1
M
b
a,
b
a,
INTERSECTION
63
1
L regular
2
L regular
We show 2
1 L
L 
regular
64
DeMorgan’s Law: 2
1
2
1 L
L
L
L 


2
1 , L
L regular
2
1 , L
L regular
2
1 L
L  regular
2
1 L
L  regular
2
1 L
L  regular
65
Example
}
{
1 b
a
L n

}
,
{
2 ba
ab
L 
regular
regular
}
{
2
1 ab
L
L 

regular
66
1
L
for for 2
L
FA
1
M
FA
2
M
Construct a new FA that accepts
Machine Machine
M 2
1 L
L 
M simulates in parallel and
1
M 2
M
Another Proof for Intersection Closure
67
States in M
j
i p
q ,
1
M 2
M
State in State in
68
1
M 2
M
1
q 2
q
a
transition
1
p 2
p
a
transition
FA FA
1
1, p
q a
transition
M
FA
2
2, p
q
69
0
q
initial state
0
p
initial state
Initial state
0
0, p
q
1
M 2
M
FA FA
M
FA
70
i
q
accept state
j
p
accept states
accept states
j
i p
q ,
k
p
k
i p
q ,
1
M 2
M
FA FA
M
FA
Both constituents must be accepting states
71
M simulates in parallel and
1
M 2
M
M accepts string w if and only if
accepts string and
w
1
M
accepts string w
2
M
)
(
)
(
)
( 2
1 M
L
M
L
M
L 

72
Example: what are the DFAs for the
Following:
}
{
1 b
a
L n

a
b
1
M
0

n
}
{
2
n
ab
L 
b
b
2
M
0
q 1
q 0
p 1
p
0

n
2
q 2
p
a
a
b
a, b
a,
b
a,
73
Construct machine for intersection
74
0
0, p
q
Automaton for intersection
}
{
}
{
}
{ ab
ab
b
a
L n
n



1
0, p
q
a
2
1, p
q
b
a
b 1
1, p
q
2
0, p
q
a
1
2, p
q
2
2, p
q
b
b
a,
a
b
b
a,
b
a
75
under union, star, concatenation with
NFAs. Would be much harder with
DFAs.

More Related Content

Similar to class4.ppt

@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
FariyaTasneem1
 
015 canonical tranformation ii
015 canonical tranformation ii015 canonical tranformation ii
015 canonical tranformation ii
dwyphy
 
Dce 4th sem syllabus (1)
Dce 4th sem syllabus (1)Dce 4th sem syllabus (1)
Dce 4th sem syllabus (1)
CIVIL0051
 
Single elctron transisto PHASE 2.pptx
Single elctron transisto PHASE 2.pptxSingle elctron transisto PHASE 2.pptx
Single elctron transisto PHASE 2.pptx
ssuser1580e5
 
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdfPreparatory_questions_final_exam_DigitalElectronics1 (1).pdf
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
rdjo
 
On Resolution Proofs for Combinational Equivalence
On Resolution Proofs for Combinational EquivalenceOn Resolution Proofs for Combinational Equivalence
On Resolution Proofs for Combinational Equivalence
satrajit
 

Similar to class4.ppt (15)

@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata
 
015 canonical tranformation ii
015 canonical tranformation ii015 canonical tranformation ii
015 canonical tranformation ii
 
Dce 4th sem syllabus (1)
Dce 4th sem syllabus (1)Dce 4th sem syllabus (1)
Dce 4th sem syllabus (1)
 
Single elctron transisto PHASE 2.pptx
Single elctron transisto PHASE 2.pptxSingle elctron transisto PHASE 2.pptx
Single elctron transisto PHASE 2.pptx
 
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdfPreparatory_questions_final_exam_DigitalElectronics1 (1).pdf
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
 
1413570.ppt
1413570.ppt1413570.ppt
1413570.ppt
 
1. finite_automata_new.ppt
1. finite_automata_new.ppt1. finite_automata_new.ppt
1. finite_automata_new.ppt
 
On Resolution Proofs for Combinational Equivalence
On Resolution Proofs for Combinational EquivalenceOn Resolution Proofs for Combinational Equivalence
On Resolution Proofs for Combinational Equivalence
 
NFA DFA Equivalence theorem
NFA DFA Equivalence theorem NFA DFA Equivalence theorem
NFA DFA Equivalence theorem
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTES
 
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

class4.ppt