Non-Deterministic Finite Automt http://users.comlb.ox.c.uk/luke. ong/teching/moc/nf2up.pdf 1
Nondeterministic Finite Automton (NFA) Alphbet ={} q1 q2 2
Alphbet ={} Two choices q1 q2 3
Alphbet ={} Two choices q1 q2 No trnsition No trnsition 4
First Choice q1 q2 5
First Choice q1 q2 6
First Choice q1 q2 7
First Choice All input is consumed q1 q2 ccept 8
Second Choice q1 q2 9
Second Choice q1 q2 10
Second Choice q1 q2 No trnsition: the utomton hngs 11
Second Choice Input cnnot be consumed q1 q2 reject 12
An NFA ccepts string: when there is computtion of the NFA tht ccepts the string There is computtion: ll the input is consumed nd the utomton is in n ccepting stte 13
Exmple is ccepted by the NFA: ccept q 1 q2 q 1 q2 becuse this computtion ccepts reject 14
Rejection exmple q1 q2 15
First Choice q1 q2 16
First Choice reject q1 q2 17
Second Choice q1 q2 18
Second Choice q1 q2 19
Second Choice q1 q2 reject 20
An NFA rejects string: when there is no computtion of the NFA tht ccepts the string. For ech computtion: All the input is consumed nd the utomton is in non finl stte OR The input cnnot be consumed 21
Exmple is rejected by the NFA: q 1 q2 reject q 1 q2 reject All possible computtions led to rejection 22
Rejection exmple q1 q2 23
First Choice q1 q2 24
First Choice q1 q2 No trnsition: the utomton hngs 25
First Choice Input cnnot be consumed q1 q2 reject 26
Second Choice q1 q2 27
Second Choice q1 q2 28
Second Choice q1 q2 No trnsition: the utomton hngs 29
Second Choice Input cnnot be consumed q1 q2 reject 30
is rejected by the NFA: reject q 1 q2 q 1 q2 reject All possible computtions led to rejection 31
Lnguge ccepted: L {} q1 q2 32
Lmbd Trnsitions q q3 q0 1 q2 33
q q3 q0 1 q2 34
q q3 q0 1 q2 35
(red hed does not move) q q3 q0 1 q2 36
q q3 q0 1 q2 37
ll input is consumed q q3 q0 1 q2 ccept String is ccepted 38
Rejection Exmple q q3 q0 1 q2 39
q q3 q0 1 q2 40
(red hed doesn t move) q q3 q0 1 q2 41
q q3 q0 1 q2 No trnsition: the utomton hngs 42
Input cnnot be consumed reject q q3 q0 1 q2 String is rejected 43
Lnguge ccepted: L {} q q3 q0 1 q2 44
Another NFA Exmple b q3 q0 1 q q2 45
b b q3 q0 1 q q2 46
b q b q2 q3 0 q 1 47
b q q b 1 q3 0 q 2 48
b q q b 1 q3 0 ccept q 2 49
Another String b b q b 0 q1 2 q q3 50
b b q b 0 q1 2 q q3 51
b b q b 0 q1 2 q q3 52
b b q b 0 q1 2 q q3 53
b b q b 0 q1 2 q q3 54
b b q b 0 q1 2 q q3 55
b b q b 0 q1 2 q q3 56
b b q b 0 ccept q1 2 q q3 57
Lnguge ccepted L b, bb, bbb,... b b q3 q0 1 q q2 58
Another NFA Exmple 0 q0 1 1,1 q2 59
Lnguge ccepted L(M ) = = { } λ, 10, { 10}* 1010, 101010,... 0 q0 1 1,1 q2 (redundnt stte) 60
Remrks: The symbol never ppers on the input tpe Simple utomt: M 1 M 2 L(M 1 ) = {} (M ) = {λ} L 2 61
NFAs re interesting becuse we cn express lnguges esier thn FAs NFA M 1 FA M 2 q 0 q1 q 2 q 1 L( M1) = { } L( M 2) = { } 62
Forml Definition of NFAs M Q,,, q0, F Q : Set of sttes, i.e. q0, q1, q 2 : Input plhbet, i.e., b : Trnsition function : Initil stte F : Accepting sttes 63
Trnsition Function q, q 0 1 1 0 q0 1 1,1 q2 64
( q1,0) { q0, q 2 } 0 1,1 1 q2 65
( q0, ) { q0, q 2 } 0 1,1 1 q2 66
( q 2,1) 0 1,1 1 q2 67
Extended Trnsition Function * * q q 0, 1 q 4 q 5 q 1 b q 2 68
* q q q 0, 4, 5 q 4 q 5 q 1 b q 2 69
* q q q q 0, b 2, 3, 0 q 4 q 5 q 1 b q 2 70
q j i, Formlly * q w : there is wlk from to with lbel w qi q j qi w q j w 1 2 k qi 1 2 k q j 71
The Lnguge of n NFA M F,q 5 q 4 q 5 q 1 b q 2 * q q q 0, 4, 5 L(M ) F 72
F,q 5 q 4 q 5 q 1 b q 2 * q q q q 0, b 2, 3, 0 F b L M 73
F,q 5 q 4 q 5 q 1 b q 2 * q q q 0, b 4, 5 F b L(M ) 74
F,q 5 q 4 q 5 q 1 b q 2 * q b q 0, 1 b L M F 75
q 4 q 5 q 1 b q 2 L M b * { } 76
Formlly The lnguge ccepted by NFA M is: L M w1, w2, w3,... where *(, w ) { q, q,..., q, } m i j k nd there is some q k F (ccepting stte) 77
w L M *(, w) w q i q0 w qk q k F w q j 78