Non-Deterministic Finite Automata (NFA)
Non-Deterministic Finite Automata (NFA)
Non-Deterministic Finite Automata (NFA)
Models of Computation
This is not necessarily so in an NFA. At any state, an NFA may have multiple -transitions, or none.
We may think of the non-determinism as a kind of parallel computation wherein several processes can be running concurrently. When the NFA splits to follow several choices, that corresponds to a process forking into several children, each proceeding separately. If at least one of these accepts, then the entire computation accepts.
Models of Computation
such that
; in an NFA, they
NFAs are more compact - they generally require fewer states to recognize a language.
Models of Computation 3
Example:
is a multiple of 2 or 3
Using -transitions and non-determinism, a language dened by an NFA can be easier to understand.
Models of Computation
888 77B4
588 97B4
8 58 69B4
88 5 7A@4
8 55 6764
58 5 9664
558 79B4
555 7764
DFA:
0 0
4
1 3) 0
1 2) 0
0 ) )
NFA:
Denition: NFA
Models of Computation
Models of Computation
c e e hdD x rre
cb dD
For
where each
c h&D
-transitions in
from
to
C D qpi
iff
or there is a sequence
h rre e e
cg &D e f
where
W V I T I S I I GE XAUB66RQPHFD
Fix an NFA
i$w
For
we dene
G HE
GfvWWiuhgf E G
G tlk
r se
Note:
G lk
hdD c
W C `9E
cb T dD B
(v)
G e yXS
(iv)
W G XHE j
W E ighgf
G T iB
(iii)
(ii)
(i)
is a nite set of states is a nite alphabet is the start state is the transition function
W V I T I S I I G dAU6AQHE
where
Models of Computation
Observation. Every DFA is an NFA! Say two automata are equivalent if they accept the same language. Theorem(Determinization). Every NFA has an equivalent DFA. Proof. Fix an NFA DFA , we construct an equivalent
Models of Computation
in
iff
in
D W C `E
such that
W uC j E
c e e e e e dD rrrrre B
c E &D 9$Xe D
W z AI z 6I z AI z QI z HFD V S GE W ~A{6}6X|QX{HFD C z V I z I z S I z I z GE
c dD u
c dD r
hdD c
e pn z 2X qoD m
C j
z pn | qoD m
x 6BrrrI u I e e e
exist
such that
cb dD
u x e e e u D 3yArrwpa
Exercise. Writing
cb dD
that
).
qpDWaI9 S E $a
G d
Note: In case
and
, there is a unique
$a
cb e G &D 2F ~9 S D W a I E
, for
symbols in
cb &D
Intuitively
. such
z
z V
z
C j
C j
z V ~ x
c e e e e e &D rrBrre
. Suppose
c &D u
c &D r
z
sequence of
W uC j E Y
z 3e D z W`E C Y k W C v`E Y
1 3)
5 B64 ) 0 ) 1 8 5 @r4 64 ) 0 8 B4 ( 5 64 C ) 0 C j
DFA
8 @r4 0
NFA
Note. State
T Urq
Models of Computation
Suppose
Proof of
Example. All words that begin with a string of 0s followed by a string of 1s.
is redundant.
. Then
for some
. Hence
z &
z V{ h&D c
c h&D z
and so,
x rre u p e e D
Since
is deterministic, feeding
x I e e e I u y6rrr
-transitions
e e e e e rrBrre
z C j
where
-transitions
i.e.
in
W `C
in
W uC
D D
& u
By denition of
. . .
, and so
e e rre $
,
u $ u
z S
Models of Computation
. Then there is a
10
Proof of Suppose
. Hence
i.e. with
, by denition of in
, there is some
build up a sequence of
, and hence
Models of Computation
Using nondeterminism makes some proofs much easier. Theorem. Regular languages are closed under union.
Models of Computation
u C
start state of
and
and
to each
W E C
W u E C
Dene
that accepts
u wC
Take NFAs
and
by
W`CE $ Y u &D c z
D w
h&D c
. Then
i.e.
V x z B
V x z i
, and hence
because
, or
11
12
of
Models of Computation
accepts
Models of Computation
u C
Obtain
u C W u V I u I u S I I u GE D u QA6r6RQHFwC
Take an NFA
that
. Construct
that accepts .
from
e e e rr$ u u u D u
C C
of
are those
u C
state of
u C
the start
u C W E C
e W u E C
An NFA
that accepts
u C
Take NFAs
and
can and
13 14
( 8 (
( ( 0 )
E.g.
W u E C Y 9F D W E E 9FD W t9E
which is not in
( 0 )
The above construction gives the NFA
u C
that accepts
vlUe
But
accepts
The NFA
accepts
accepts
W u C AwE
Models of Computation
Take an NFA
W u AI u 6I u 6RQI u hFD u C V S I GE
Dene
where
C C
).
that accepts
and
u V
and
D
and
D
and
D
and
D
T D Bpi D T pi u V d u V d u d G u &
Models of Computation
16 15
u {