際際滷

際際滷Share a Scribd company logo
息 2020 Wael Badawy
1
Non-Deterministic Finite Automata
1
DISCLAIMER:
This video is optimized for HD large display using
patented and patent-pending Nile Codec, the first
Egyptian Video Codec for more information,
PLEASE check https://NileCodec.com
Also available as a PodCast
息 2020 Wael Badawy
Copyright 息 2020 Wael Badawy. All rights reserved
 This video is subject to copyright owned by Wael Badawy WB. Any
reproduction or republication of all or part of this video is expressly prohibited
unless WB has explicitly granted its prior written consent. All other rights
reserved.
 This video is intended for education and information only and is offered AS IS,
without any warranty of the accuracy or the quality of the content. Any other
use is strictly prohibited. The viewer is fully responsible to verify the accuracy
of the contents received without any claims of costs or liability arising .
 The names, trademarks service marked as logos of WB or the sponsors
appearing in this video may not be used in any any product or service,
without prior express written permission from WB and the video sponsors
 Neither WB nor any party involved in creating, producing or delivering
information and material via this video shall be liable for any direction,
incidental, consequential, indirect of punitive damages arising out of access
to, use or inability to use this content or any errors or omissions in the
content thereof.
 If you will continue to watch this video, you agree to the terms above and
other terms that may be available on http://nu.edu.eg & https://caiwave.net
2
息 2020 Wael Badawy
息 2020 Wael Badawy
4
1q 2q
3q
a
a
a
0q
}{aAlphabet =
Nondeterministic Finite Automaton (NFA)
息 2020 Wael Badawy
5
No transition
1q 2q
3q
a
a
a
0q
Two choices
No transition
}{aAlphabet =
息 2020 Wael Badawy
6
a a
0q
1q 2q
3q
a
a
First Choice
a
息 2020 Wael Badawy
7
a a
0q
1q 2q
3q
a
a
a
First Choice
息 2020 Wael Badawy
8
a a
0q
1q 2q
3q
a
a
a accept
First Choice
All input is consumed
息 2020 Wael Badawy
9
a a
0q
1q 2q
3q
a
a
Second Choice
a
息 2020 Wael Badawy
10
a a
0q
1q 2q
a
a
a
3q
Second Choice
reject
Input cannot be consumed
Automaton Halts
息 2020 Wael Badawy
11
A NFA accepts a string:
if there is a computation path of the NFA
that accepts the string
all the symbols of input string are processed
and
the last is an accepting state
息 2020 Wael Badawy
12
aa is accepted by the NFA:
0q
1q 2q
3q
a
a
a
accept
0q
1q 2q
a
a
a
3q reject
because this
computation
accepts aa
this computation
is ignored
息 2020 Wael Badawy
13
a
0q
1q 2q
3q
a
a
Rejection example
a
息 2020 Wael Badawy
14
a
0q
1q 2q
3q
a
a
a
First Choice
reject
息 2020 Wael Badawy
15
Second Choice
a
0q
1q 2q
3q
a
a
a
息 2020 Wael Badawy
16
Second Choice
a
0q
1q 2q
a
a
a
3q reject
息 2020 Wael Badawy
17
Another Rejection example
a a
0q
1q 2q
3q
a
a
a
a
息 2020 Wael Badawy
18
a a
0q
1q 2q
3q
a
a
a
First Choice
a
息 2020 Wael Badawy
19
a a
0q
1q 2q
3q
a
a
a reject
First Choice
a
Input cannot be consumed
Automaton halts
息 2020 Wael Badawy
20
a a
0q
1q 2q
3q
a
a
Second Choice
a
a
息 2020 Wael Badawy
21
a a
0q
1q 2q
a
a
a
3q
Second Choice
reject
a
Input cannot be consumed
Automaton halts
息 2020 Wael Badawy
22
A NFA rejects a string:
if there is no computation of the NFA
that accepts the string.
 All the input is consumed and the
automaton is in a non accepting state
 The input cannot be consumed
OR
For each possible computation path:
息 2020 Wael Badawy
23
a is rejected by the NFA:
0q
1q 2q
a
a
a
3q reject
0q
1q 2q
a
a
a
3q
reject
All possible computations lead to rejection
息 2020 Wael Badawy
24
aaa is rejected by the NFA:
0q
1q 2q
3q
a
a
a
reject
0q
1q 2q
a
a
a
3q reject
All possible computations lead to rejection
息 2020 Wael Badawy
25
1q 2q
3q
a
a
a
0q
Language accepted: }{aaL
息 2020 Wael Badawy
Epsilon Transitions
26
1q 3qa
0q  2q a
息 2020 Wael Badawy
27
a a
1q 3qa
0q 2q a
息 2020 Wael Badawy
28
a a
1q 3qa
0q 2q a
息 2020 Wael Badawy
29
a a
1q 3qa
0q 2q a
input tape head does not move
Automaton changes state
息 2020 Wael Badawy
30
a a
1q 3qa
0q 2q a
accept
String is acceptedaa
all input is consumed
息 2020 Wael Badawy
31
a a
1q 3qa
0q 2q a
Rejection Example
a
息 2020 Wael Badawy
32
a a
1q 3qa
0q 2q a
a
息 2020 Wael Badawy
33
a a
1q 3qa
0q 2q a
(read head doesnt move)
a
息 2020 Wael Badawy
34
a a
1q 3qa
0q 2q a
reject
String is rejectedaaa
a
Input cannot be consumed
Automaton halts
息 2020 Wael Badawy
35
Language accepted: }{aaL 
1q 3qa
0q 2q a
息 2020 Wael Badawy
36
Another NFA Example
0q 1q 2qa b 3q
息 2020 Wael Badawy
37
a b
0q 1q 2qa b 3q
息 2020 Wael Badawy
38
0q 2qa b 3q
a b
1q
息 2020 Wael Badawy
39
a b
0q 1qa b 3q2q
accept
息 2020 Wael Badawy
40
0q a b
a b
Another String
a b
1q 2q 3q
息 2020 Wael Badawy
41
0q a b
a b a b
1q 2q 3q
息 2020 Wael Badawy
42
0q a b
a b a b
1q 2q 3q
息 2020 Wael Badawy
43
0q a b
a b a b
1q 2q 3q
息 2020 Wael Badawy
44
0q a b
a b a b
1q 2q 3q
息 2020 Wael Badawy
45
0q a b
a b a b
1q 2q 3q
息 2020 Wael Badawy
46
a b a b
0q a b
1q 2q 3q
accept
息 2020 Wael Badawy
47
 
 緒 *
...,,,
abab
ababababababL


Language accepted
0q 1q 2qa b 3q
息 2020 Wael Badawy
Another NFA Example
48
0q 1q 2q
0
1
1,0
息 2020 Wael Badawy
49
 
 *
10
...,101010,1010,10,

 L
0q 1q 2q
0
1
1,0
Language accepted
(redundant
state)
息 2020 Wael Badawy
50
Simple Automata
0q
2M
0q
1M
{})( 1 ML }{)( 2 ワML
息 2020 Wael Badawy
51
0q
2q
1qa
a
a
0q 1qa
}{=)( 1 aML
2M1MNFA DFA
NFAs are interesting because we can
express languages easier than DFAs
}{)( 2 aML
息 2020 Wael Badawy
Formal Definition of NFAs
52
 FqQM ,,,, 0わ
:Q
:
:0q
:F
Set of states, i.e.  210 ,, qqq
: Input aplhabet, i.e.  ba,
Transition function
Initial state
Accepting states
息 2020 Wael Badawy
53
   kqqqxq ,,,, 21 緒
Transition Function 
q
1q
2q
kq
x
x
x
resulting states reached
by following one transition
with input symbol x
息 2020 Wael Badawy
54
   10 1, qq 緒
0
1
1,0
0q 1q 2q
States reachable from scanning0q 1
息 2020 Wael Badawy
55
0q
0
1
1,0
},{)0,( 201 qqq 緒
1q 2q
States reachable from scanning1q 0
息 2020 Wael Badawy
56
0q
0
1
1,0
1q 2q
}{),( 20 qq 緒ワ
States reachable from with one transition
scanning no input symbol
0q
息 2020 Wael Badawy
57
0q
0
1
1,0
1q 2q
)1,( 2q
States reachable from scanning2q 1
息 2020 Wael Badawy
Extended Transition Function
58
*

0q
5q4q
3q2q1qa
aa
b
   10
*
, qaq 緒
Similar with but applied on strings
息 2020 Wael Badawy
59
   540
*
,, qqaaq 緒
5q4q
3q2q1qa
aa
b
States reachable from scanning0q aa
0q
息 2020 Wael Badawy
60
   0320
*
,,, qqqabq 緒
0q
5q4q
3q2q1qa
aa
b
States reachable from scanning0q ab
息 2020 Wael Badawy
61
Special case:
 ワ ,*
qq
for any state q
息 2020 Wael Badawy
62
 wqq ij ,*
わ : there is a walk from to
with label
iq jq
w
iq jq
w
kw 鰹鰹 21
1 2 k
iq jq
In general
息 2020 Wael Badawy
The Language of an NFA
The language accepted by is:
Where for each
and there is some
63
M
M
   nwwwML ,...,, 21
},,,...,{),( 0
*
jkim qqqwq 緒
Fqk  (accepting state)
mw
息 2020 Wael Badawy
64
0q kq
mw
),( 0
*
mwq
 MLwm 
Fqk 
iq
jq
mw
mw
息 2020 Wael Badawy
65
0q
5q4q
3q2q1qa
aa
b 
   540
*
,, qqaaq 緒 )(MLaa
 50,qqF 
F
息 2020 Wael Badawy
66
0q
5q4q
3q2q1qa
aa
b
   0320
*
,,, qqqabq 緒  MLab
 50,qqF 
F
息 2020 Wael Badawy
67
0q
5q4q
3q2q1qa
aa
b
 50,qqF 
   540
*
,, qqabaaq 緒 )(MLabaa 
F
息 2020 Wael Badawy
68
0q
5q4q
3q2q1qa
aa
b
 50,qqF 
   10
*
, qabaq 緒  MLaba
F
息 2020 Wael Badawy
69
0q
5q4q
3q2q1qa
aa
b
      }{
**
aaababML
70
NFAs accept the Regular
Languages
70
息 2020 Wael Badawy
Equivalence of Machines
Definition:
Machine is equivalent to machine
if
71
1M 2M
   21 MLML
息 2020 Wael Badawy
72
0q 1q
0
1
0q 1q 2q
0
1
1
0
1,0
NFA
DFA
  *}10{1 ML
  *}10{2 ML
1M
2M
Example of equivalent machines
息 2020 Wael Badawy
73
Theorem:
Languages
accepted
by NFAs
Regular
Languages
NFAs and DFAs have the same computation power,
namely, they accept the same set of languages
Languages
accepted
by DFAs
息 2020 Wael Badawy
74
Languages
accepted
by NFAs
Regular
Languages

Languages
accepted
by NFAs
Regular
Languages

we need to showProof:
AND
息 2020 Wael Badawy
75
Languages
accepted
by NFAs
Regular
Languages

Proof-Step 1
Every DFA is trivially a NFA
Any language accepted by a DFA
is also accepted by a NFA
L
息 2020 Wael Badawy
76
Languages
accepted
by NFAs
Regular
Languages

Proof-Step 2
Any NFA can be converted to an
equivalent DFA
Any language accepted by a NFA
is also accepted by a DFA
L
息 2020 Wael Badawy
Conversion of NFA to DFA
77
a
b
a

0q 1q 2q
NFA
DFA
 0q
M
M
息 2020 Wael Badawy
78
a
b
a
0q 1q 2q
NFA
DFA
 0q  21,qq
a
M
M
},{),( 210
*
qqaq 緒
息 2020 Wael Badawy
79
a
b
a
0q 1q 2q
NFA
DFA
 0q  21,qq
a

b
M
M
),( 0
*
bq empty set
trap state
息 2020 Wael Badawy
80
a
b
a
0q 1q 2q
NFA
DFA
 0q  21,qq
a

b
a
M
M
},{),( 211
*
qqaq 緒
),( 2
*
aq
 21,qq
union
息 2020 Wael Badawy
81
a
b
a
0q 1q 2q
NFA
DFA
 0q  21,qq
a

b
ab
M
M
}{),( 01
*
qbq 緒
}{),( 02
*
qbq 緒
 0q
union
息 2020 Wael Badawy
82
a
b
a
0q 1q 2q
NFA
DFA
 0q  21,qq
a

b
ab
ba,
M
M
trap state
息 2020 Wael Badawy
83
a
b
a
0q 1q 2q
NFA
DFA
 0q  21,qq
a

b
a
b
ba,
M
M
END OF CONSTRUCTION
Fq 1
  Fqq 21,
息 2020 Wael Badawy
General Conversion Procedure
Input: an NFA
Output: an equivalent DFA
with
84
M
M
  )(MLML
息 2020 Wael Badawy
The NFA has states
The DFA has states from the power set
85
,...,, 210 qqq
        ....,,,,,,,, 3211010 qqqqqqq
息 2020 Wael Badawy
1. Initial state of NFA:
Initial state of DFA:
86
0q
   緒,, 00
*
qq 緒ワ
Conversion Procedure Steps
step
 緒,0q
息 2020 Wael Badawy
87
a
b
a
0q 1q 2q
NFA
DFA
 0q
M
M
Example
   00
*
, qq 緒ワ
息 2020 Wael Badawy
2. For every DFAs state
compute in the NFA
add transition to DFA
88
},...,,{ mji qqq
 
 
 aq
aq
aq
m
j
i
,*
...
,*
,*





},...,,{ nlk qqq 
  },...,,{},,...,,{ nlkmji qqqaqqq 緒

Union
step
息 2020 Wael Badawy
89
a
b
a
0q 1q 2q
NFA
 0q  21,qq
a
DFA
},{),(* 210 qqaq 緒
 緒   210 ,, qqaq 緒
M
M
Example
息 2020 Wael Badawy
3. Repeat Step 2 for every state in DFA and
symbols in alphabet until no more states can be
added in the DFA
90
step
息 2020 Wael Badawy
91
a
b
a
0q 1q 2q
NFA
DFA
 0q  21,qq
a

b
ab
ba,
M
M
Example
息 2020 Wael Badawy
4. For any DFA state
if some is accepting state in NFA
Then,
is accepting state in DFA
92
},...,,{ mji qqq
jq
},...,,{ mji qqq
step
息 2020 Wael Badawy
93
a
b
a
0q 1q 2q
NFA
DFA
 0q  21,qq
a

b
a
b
ba,
Fq 1
  Fqq 21,
M
M
Example
息 2020 Wael Badawy
94
If we convert NFA to DFA
then the two automata are equivalent:
M
   MLML 
M
Lemma:
Proof:
   MLML 
   MLML 
AND
We need to show:
息 2020 Wael Badawy
95
   MLML First we show:
)(MLw
We only need to prove:
)(MLw
息 2020 Wael Badawy
96
)(MLw
w
kaaaw 21
0q fq
0q fq1a 2a ka
symbols
Consider
NFA
息 2020 Wael Badawy
97
ia
ia
denotes a possible sub-path like
iq jq
iq jq
symbol
symbol
息 2020 Wael Badawy
98
0q fq
raaaw 21
1a 2a ra
:M
},{ 0 q
1a 2a ra
:M
},{ fq
)(MLw
)(MLw 
We will show that if
then
NFA
DFA
state
label
state
label
息 2020 Wael Badawy
99
0q mq
rnaaav n o 21
1a 2a na
:M
1a 2a na
:M
},{ iq
iq jq lq
},{ jq },{ lq },{ mq
More generally, we will show that if in :M
(arbitrary prefix)
then
NFA
DFA
},{ 0 q
息 2020 Wael Badawy
100
0q 1a
:M
1a
:M
},{ iq
iq
Proof by induction on
Induction Basis: 1av 
|| v
is true by construction of M
NFA
DFA
1|| v
},{ 0 q
息 2020 Wael Badawy
101
Induction hypothesis: kv o ||1
0q dq1a 2a ka
:M iq jq cq
1a 2a ka
:M
},{ iq },{ jq },{ cq },{ dq
kaaav 21
NFA
DFA
Suppose that the following hold
},{ 0 q
息 2020 Wael Badawy
102
Induction Step: 1||  kv
0q dq1a 2a ka
:M iq jq cq
1a 2a ka
:M
},{ iq },{ jq },{ cq },{ dq
1121 

緒 kk
v
k avaaaav
器鰹 駕

v
v
eq1ka
1ka
},{ eq
NFA
DFA
Then this is true by construction of M
},{ 0 q
息 2020 Wael Badawy
103
0q fq
raaaw 21
1a 2a ra
:M
:M
},{ fq
)(MLw
)(MLw 
Therefore if
NFA
DFA
then
},{ 0 q
1a 2a ra
息 2020 Wael Badawy
104
We have shown:    MLML 
With a similar proof
we can show:    MLML 
END OF PROOF
   MLML Therefore:

More Related Content

N F A - Non Deterministic Finite Automata

  • 1. 息 2020 Wael Badawy 1 Non-Deterministic Finite Automata 1 DISCLAIMER: This video is optimized for HD large display using patented and patent-pending Nile Codec, the first Egyptian Video Codec for more information, PLEASE check https://NileCodec.com Also available as a PodCast
  • 2. 息 2020 Wael Badawy Copyright 息 2020 Wael Badawy. All rights reserved This video is subject to copyright owned by Wael Badawy WB. Any reproduction or republication of all or part of this video is expressly prohibited unless WB has explicitly granted its prior written consent. All other rights reserved. This video is intended for education and information only and is offered AS IS, without any warranty of the accuracy or the quality of the content. Any other use is strictly prohibited. The viewer is fully responsible to verify the accuracy of the contents received without any claims of costs or liability arising . The names, trademarks service marked as logos of WB or the sponsors appearing in this video may not be used in any any product or service, without prior express written permission from WB and the video sponsors Neither WB nor any party involved in creating, producing or delivering information and material via this video shall be liable for any direction, incidental, consequential, indirect of punitive damages arising out of access to, use or inability to use this content or any errors or omissions in the content thereof. If you will continue to watch this video, you agree to the terms above and other terms that may be available on http://nu.edu.eg & https://caiwave.net 2
  • 3. 息 2020 Wael Badawy
  • 4. 息 2020 Wael Badawy 4 1q 2q 3q a a a 0q }{aAlphabet = Nondeterministic Finite Automaton (NFA)
  • 5. 息 2020 Wael Badawy 5 No transition 1q 2q 3q a a a 0q Two choices No transition }{aAlphabet =
  • 6. 息 2020 Wael Badawy 6 a a 0q 1q 2q 3q a a First Choice a
  • 7. 息 2020 Wael Badawy 7 a a 0q 1q 2q 3q a a a First Choice
  • 8. 息 2020 Wael Badawy 8 a a 0q 1q 2q 3q a a a accept First Choice All input is consumed
  • 9. 息 2020 Wael Badawy 9 a a 0q 1q 2q 3q a a Second Choice a
  • 10. 息 2020 Wael Badawy 10 a a 0q 1q 2q a a a 3q Second Choice reject Input cannot be consumed Automaton Halts
  • 11. 息 2020 Wael Badawy 11 A NFA accepts a string: if there is a computation path of the NFA that accepts the string all the symbols of input string are processed and the last is an accepting state
  • 12. 息 2020 Wael Badawy 12 aa is accepted by the NFA: 0q 1q 2q 3q a a a accept 0q 1q 2q a a a 3q reject because this computation accepts aa this computation is ignored
  • 13. 息 2020 Wael Badawy 13 a 0q 1q 2q 3q a a Rejection example a
  • 14. 息 2020 Wael Badawy 14 a 0q 1q 2q 3q a a a First Choice reject
  • 15. 息 2020 Wael Badawy 15 Second Choice a 0q 1q 2q 3q a a a
  • 16. 息 2020 Wael Badawy 16 Second Choice a 0q 1q 2q a a a 3q reject
  • 17. 息 2020 Wael Badawy 17 Another Rejection example a a 0q 1q 2q 3q a a a a
  • 18. 息 2020 Wael Badawy 18 a a 0q 1q 2q 3q a a a First Choice a
  • 19. 息 2020 Wael Badawy 19 a a 0q 1q 2q 3q a a a reject First Choice a Input cannot be consumed Automaton halts
  • 20. 息 2020 Wael Badawy 20 a a 0q 1q 2q 3q a a Second Choice a a
  • 21. 息 2020 Wael Badawy 21 a a 0q 1q 2q a a a 3q Second Choice reject a Input cannot be consumed Automaton halts
  • 22. 息 2020 Wael Badawy 22 A NFA rejects a string: if there is no computation of the NFA that accepts the string. All the input is consumed and the automaton is in a non accepting state The input cannot be consumed OR For each possible computation path:
  • 23. 息 2020 Wael Badawy 23 a is rejected by the NFA: 0q 1q 2q a a a 3q reject 0q 1q 2q a a a 3q reject All possible computations lead to rejection
  • 24. 息 2020 Wael Badawy 24 aaa is rejected by the NFA: 0q 1q 2q 3q a a a reject 0q 1q 2q a a a 3q reject All possible computations lead to rejection
  • 25. 息 2020 Wael Badawy 25 1q 2q 3q a a a 0q Language accepted: }{aaL
  • 26. 息 2020 Wael Badawy Epsilon Transitions 26 1q 3qa 0q 2q a
  • 27. 息 2020 Wael Badawy 27 a a 1q 3qa 0q 2q a
  • 28. 息 2020 Wael Badawy 28 a a 1q 3qa 0q 2q a
  • 29. 息 2020 Wael Badawy 29 a a 1q 3qa 0q 2q a input tape head does not move Automaton changes state
  • 30. 息 2020 Wael Badawy 30 a a 1q 3qa 0q 2q a accept String is acceptedaa all input is consumed
  • 31. 息 2020 Wael Badawy 31 a a 1q 3qa 0q 2q a Rejection Example a
  • 32. 息 2020 Wael Badawy 32 a a 1q 3qa 0q 2q a a
  • 33. 息 2020 Wael Badawy 33 a a 1q 3qa 0q 2q a (read head doesnt move) a
  • 34. 息 2020 Wael Badawy 34 a a 1q 3qa 0q 2q a reject String is rejectedaaa a Input cannot be consumed Automaton halts
  • 35. 息 2020 Wael Badawy 35 Language accepted: }{aaL 1q 3qa 0q 2q a
  • 36. 息 2020 Wael Badawy 36 Another NFA Example 0q 1q 2qa b 3q
  • 37. 息 2020 Wael Badawy 37 a b 0q 1q 2qa b 3q
  • 38. 息 2020 Wael Badawy 38 0q 2qa b 3q a b 1q
  • 39. 息 2020 Wael Badawy 39 a b 0q 1qa b 3q2q accept
  • 40. 息 2020 Wael Badawy 40 0q a b a b Another String a b 1q 2q 3q
  • 41. 息 2020 Wael Badawy 41 0q a b a b a b 1q 2q 3q
  • 42. 息 2020 Wael Badawy 42 0q a b a b a b 1q 2q 3q
  • 43. 息 2020 Wael Badawy 43 0q a b a b a b 1q 2q 3q
  • 44. 息 2020 Wael Badawy 44 0q a b a b a b 1q 2q 3q
  • 45. 息 2020 Wael Badawy 45 0q a b a b a b 1q 2q 3q
  • 46. 息 2020 Wael Badawy 46 a b a b 0q a b 1q 2q 3q accept
  • 47. 息 2020 Wael Badawy 47 緒 * ...,,, abab ababababababL Language accepted 0q 1q 2qa b 3q
  • 48. 息 2020 Wael Badawy Another NFA Example 48 0q 1q 2q 0 1 1,0
  • 49. 息 2020 Wael Badawy 49 * 10 ...,101010,1010,10, L 0q 1q 2q 0 1 1,0 Language accepted (redundant state)
  • 50. 息 2020 Wael Badawy 50 Simple Automata 0q 2M 0q 1M {})( 1 ML }{)( 2 ワML
  • 51. 息 2020 Wael Badawy 51 0q 2q 1qa a a 0q 1qa }{=)( 1 aML 2M1MNFA DFA NFAs are interesting because we can express languages easier than DFAs }{)( 2 aML
  • 52. 息 2020 Wael Badawy Formal Definition of NFAs 52 FqQM ,,,, 0わ :Q : :0q :F Set of states, i.e. 210 ,, qqq : Input aplhabet, i.e. ba, Transition function Initial state Accepting states
  • 53. 息 2020 Wael Badawy 53 kqqqxq ,,,, 21 緒 Transition Function q 1q 2q kq x x x resulting states reached by following one transition with input symbol x
  • 54. 息 2020 Wael Badawy 54 10 1, qq 緒 0 1 1,0 0q 1q 2q States reachable from scanning0q 1
  • 55. 息 2020 Wael Badawy 55 0q 0 1 1,0 },{)0,( 201 qqq 緒 1q 2q States reachable from scanning1q 0
  • 56. 息 2020 Wael Badawy 56 0q 0 1 1,0 1q 2q }{),( 20 qq 緒ワ States reachable from with one transition scanning no input symbol 0q
  • 57. 息 2020 Wael Badawy 57 0q 0 1 1,0 1q 2q )1,( 2q States reachable from scanning2q 1
  • 58. 息 2020 Wael Badawy Extended Transition Function 58 * 0q 5q4q 3q2q1qa aa b 10 * , qaq 緒 Similar with but applied on strings
  • 59. 息 2020 Wael Badawy 59 540 * ,, qqaaq 緒 5q4q 3q2q1qa aa b States reachable from scanning0q aa 0q
  • 60. 息 2020 Wael Badawy 60 0320 * ,,, qqqabq 緒 0q 5q4q 3q2q1qa aa b States reachable from scanning0q ab
  • 61. 息 2020 Wael Badawy 61 Special case: ワ ,* qq for any state q
  • 62. 息 2020 Wael Badawy 62 wqq ij ,* わ : there is a walk from to with label iq jq w iq jq w kw 鰹鰹 21 1 2 k iq jq In general
  • 63. 息 2020 Wael Badawy The Language of an NFA The language accepted by is: Where for each and there is some 63 M M nwwwML ,...,, 21 },,,...,{),( 0 * jkim qqqwq 緒 Fqk (accepting state) mw
  • 64. 息 2020 Wael Badawy 64 0q kq mw ),( 0 * mwq MLwm Fqk iq jq mw mw
  • 65. 息 2020 Wael Badawy 65 0q 5q4q 3q2q1qa aa b 540 * ,, qqaaq 緒 )(MLaa 50,qqF F
  • 66. 息 2020 Wael Badawy 66 0q 5q4q 3q2q1qa aa b 0320 * ,,, qqqabq 緒 MLab 50,qqF F
  • 67. 息 2020 Wael Badawy 67 0q 5q4q 3q2q1qa aa b 50,qqF 540 * ,, qqabaaq 緒 )(MLabaa F
  • 68. 息 2020 Wael Badawy 68 0q 5q4q 3q2q1qa aa b 50,qqF 10 * , qabaq 緒 MLaba F
  • 69. 息 2020 Wael Badawy 69 0q 5q4q 3q2q1qa aa b }{ ** aaababML
  • 70. 70 NFAs accept the Regular Languages 70
  • 71. 息 2020 Wael Badawy Equivalence of Machines Definition: Machine is equivalent to machine if 71 1M 2M 21 MLML
  • 72. 息 2020 Wael Badawy 72 0q 1q 0 1 0q 1q 2q 0 1 1 0 1,0 NFA DFA *}10{1 ML *}10{2 ML 1M 2M Example of equivalent machines
  • 73. 息 2020 Wael Badawy 73 Theorem: Languages accepted by NFAs Regular Languages NFAs and DFAs have the same computation power, namely, they accept the same set of languages Languages accepted by DFAs
  • 74. 息 2020 Wael Badawy 74 Languages accepted by NFAs Regular Languages Languages accepted by NFAs Regular Languages we need to showProof: AND
  • 75. 息 2020 Wael Badawy 75 Languages accepted by NFAs Regular Languages Proof-Step 1 Every DFA is trivially a NFA Any language accepted by a DFA is also accepted by a NFA L
  • 76. 息 2020 Wael Badawy 76 Languages accepted by NFAs Regular Languages Proof-Step 2 Any NFA can be converted to an equivalent DFA Any language accepted by a NFA is also accepted by a DFA L
  • 77. 息 2020 Wael Badawy Conversion of NFA to DFA 77 a b a 0q 1q 2q NFA DFA 0q M M
  • 78. 息 2020 Wael Badawy 78 a b a 0q 1q 2q NFA DFA 0q 21,qq a M M },{),( 210 * qqaq 緒
  • 79. 息 2020 Wael Badawy 79 a b a 0q 1q 2q NFA DFA 0q 21,qq a b M M ),( 0 * bq empty set trap state
  • 80. 息 2020 Wael Badawy 80 a b a 0q 1q 2q NFA DFA 0q 21,qq a b a M M },{),( 211 * qqaq 緒 ),( 2 * aq 21,qq union
  • 81. 息 2020 Wael Badawy 81 a b a 0q 1q 2q NFA DFA 0q 21,qq a b ab M M }{),( 01 * qbq 緒 }{),( 02 * qbq 緒 0q union
  • 82. 息 2020 Wael Badawy 82 a b a 0q 1q 2q NFA DFA 0q 21,qq a b ab ba, M M trap state
  • 83. 息 2020 Wael Badawy 83 a b a 0q 1q 2q NFA DFA 0q 21,qq a b a b ba, M M END OF CONSTRUCTION Fq 1 Fqq 21,
  • 84. 息 2020 Wael Badawy General Conversion Procedure Input: an NFA Output: an equivalent DFA with 84 M M )(MLML
  • 85. 息 2020 Wael Badawy The NFA has states The DFA has states from the power set 85 ,...,, 210 qqq ....,,,,,,,, 3211010 qqqqqqq
  • 86. 息 2020 Wael Badawy 1. Initial state of NFA: Initial state of DFA: 86 0q 緒,, 00 * qq 緒ワ Conversion Procedure Steps step 緒,0q
  • 87. 息 2020 Wael Badawy 87 a b a 0q 1q 2q NFA DFA 0q M M Example 00 * , qq 緒ワ
  • 88. 息 2020 Wael Badawy 2. For every DFAs state compute in the NFA add transition to DFA 88 },...,,{ mji qqq aq aq aq m j i ,* ... ,* ,* },...,,{ nlk qqq },...,,{},,...,,{ nlkmji qqqaqqq 緒 Union step
  • 89. 息 2020 Wael Badawy 89 a b a 0q 1q 2q NFA 0q 21,qq a DFA },{),(* 210 qqaq 緒 緒 210 ,, qqaq 緒 M M Example
  • 90. 息 2020 Wael Badawy 3. Repeat Step 2 for every state in DFA and symbols in alphabet until no more states can be added in the DFA 90 step
  • 91. 息 2020 Wael Badawy 91 a b a 0q 1q 2q NFA DFA 0q 21,qq a b ab ba, M M Example
  • 92. 息 2020 Wael Badawy 4. For any DFA state if some is accepting state in NFA Then, is accepting state in DFA 92 },...,,{ mji qqq jq },...,,{ mji qqq step
  • 93. 息 2020 Wael Badawy 93 a b a 0q 1q 2q NFA DFA 0q 21,qq a b a b ba, Fq 1 Fqq 21, M M Example
  • 94. 息 2020 Wael Badawy 94 If we convert NFA to DFA then the two automata are equivalent: M MLML M Lemma: Proof: MLML MLML AND We need to show:
  • 95. 息 2020 Wael Badawy 95 MLML First we show: )(MLw We only need to prove: )(MLw
  • 96. 息 2020 Wael Badawy 96 )(MLw w kaaaw 21 0q fq 0q fq1a 2a ka symbols Consider NFA
  • 97. 息 2020 Wael Badawy 97 ia ia denotes a possible sub-path like iq jq iq jq symbol symbol
  • 98. 息 2020 Wael Badawy 98 0q fq raaaw 21 1a 2a ra :M },{ 0 q 1a 2a ra :M },{ fq )(MLw )(MLw We will show that if then NFA DFA state label state label
  • 99. 息 2020 Wael Badawy 99 0q mq rnaaav n o 21 1a 2a na :M 1a 2a na :M },{ iq iq jq lq },{ jq },{ lq },{ mq More generally, we will show that if in :M (arbitrary prefix) then NFA DFA },{ 0 q
  • 100. 息 2020 Wael Badawy 100 0q 1a :M 1a :M },{ iq iq Proof by induction on Induction Basis: 1av || v is true by construction of M NFA DFA 1|| v },{ 0 q
  • 101. 息 2020 Wael Badawy 101 Induction hypothesis: kv o ||1 0q dq1a 2a ka :M iq jq cq 1a 2a ka :M },{ iq },{ jq },{ cq },{ dq kaaav 21 NFA DFA Suppose that the following hold },{ 0 q
  • 102. 息 2020 Wael Badawy 102 Induction Step: 1|| kv 0q dq1a 2a ka :M iq jq cq 1a 2a ka :M },{ iq },{ jq },{ cq },{ dq 1121 緒 kk v k avaaaav 器鰹 駕 v v eq1ka 1ka },{ eq NFA DFA Then this is true by construction of M },{ 0 q
  • 103. 息 2020 Wael Badawy 103 0q fq raaaw 21 1a 2a ra :M :M },{ fq )(MLw )(MLw Therefore if NFA DFA then },{ 0 q 1a 2a ra
  • 104. 息 2020 Wael Badawy 104 We have shown: MLML With a similar proof we can show: MLML END OF PROOF MLML Therefore:

Editor's Notes