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