<s>
reading	O
an	O
input	O
symbol	O
is	O
required	O
for	O
each	O
state	B-Application
transition	I-Application
.	O
</s>
<s>
A	O
nondeterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
(	O
NFA	O
)	O
,	O
or	O
nondeterministic	B-General_Concept
finite-state	I-General_Concept
machine	I-General_Concept
,	O
does	O
not	O
need	O
to	O
obey	O
these	O
restrictions	O
.	O
</s>
<s>
In	O
particular	O
,	O
every	O
DFA	B-General_Concept
is	O
also	O
an	O
NFA	O
.	O
</s>
<s>
Sometimes	O
the	O
term	O
NFA	O
is	O
used	O
in	O
a	O
narrower	O
sense	O
,	O
referring	O
to	O
an	O
NFA	O
that	O
is	O
not	O
a	O
DFA	B-General_Concept
,	O
but	O
not	O
in	O
this	O
article	O
.	O
</s>
<s>
Using	O
the	O
subset	B-General_Concept
construction	I-General_Concept
algorithm	I-General_Concept
,	O
each	O
NFA	O
can	O
be	O
translated	O
to	O
an	O
equivalent	O
DFA	B-General_Concept
;	O
i.e.	O
,	O
a	O
DFA	B-General_Concept
recognizing	O
the	O
same	O
formal	O
language	O
.	O
</s>
<s>
Like	O
DFAs	B-General_Concept
,	O
NFAs	O
only	O
recognize	O
regular	B-General_Concept
languages	I-General_Concept
.	O
</s>
<s>
NFAs	O
were	O
introduced	O
in	O
1959	O
by	O
Michael	O
O	O
.	O
Rabin	O
and	O
Dana	O
Scott	O
,	O
who	O
also	O
showed	O
their	O
equivalence	O
to	O
DFAs	B-General_Concept
.	O
</s>
<s>
NFAs	O
are	O
used	O
in	O
the	O
implementation	O
of	O
regular	B-Language
expressions	I-Language
:	O
Thompson	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
is	O
an	O
algorithm	O
for	O
compiling	O
a	O
regular	B-Language
expression	I-Language
to	O
an	O
NFA	O
that	O
can	O
efficiently	O
perform	O
pattern	O
matching	O
on	O
strings	O
.	O
</s>
<s>
Conversely	O
,	O
Kleene	B-General_Concept
's	I-General_Concept
algorithm	I-General_Concept
can	O
be	O
used	O
to	O
convert	O
an	O
NFA	O
into	O
a	O
regular	B-Language
expression	I-Language
(	O
whose	O
size	O
is	O
generally	O
exponential	O
in	O
the	O
input	O
automaton	O
)	O
.	O
</s>
<s>
NFAs	O
have	O
been	O
generalized	O
in	O
multiple	O
ways	O
,	O
e.g.	O
,	O
nondeterministic	B-General_Concept
finite	I-General_Concept
automata	I-General_Concept
with	O
ε-moves	O
,	O
finite-state	B-Architecture
transducers	I-Architecture
,	O
pushdown	B-Application
automata	I-Application
,	O
alternating	B-General_Concept
automata	I-General_Concept
,	O
ω-automata	B-General_Concept
,	O
and	O
probabilistic	B-General_Concept
automata	I-General_Concept
.	O
</s>
<s>
and	O
self-verifying	B-General_Concept
finite	I-General_Concept
automata	I-General_Concept
(	O
SVFA	O
)	O
.	O
</s>
<s>
some	O
sequence	O
of	O
choices	O
leading	O
to	O
an	O
accepting	B-Architecture
state	I-Architecture
after	O
completely	O
consuming	O
the	O
input	O
,	O
it	O
is	O
accepted	O
.	O
</s>
<s>
if	O
no	O
choice	O
sequence	O
at	O
all	O
can	O
consume	O
all	O
the	O
input	O
and	O
lead	O
to	O
an	O
accepting	B-Architecture
state	I-Architecture
,	O
the	O
input	O
is	O
rejected	O
.	O
</s>
<s>
If	O
,	O
after	O
consuming	O
the	O
complete	O
input	O
,	O
any	O
of	O
the	O
copies	O
is	O
in	O
an	O
accept	B-Architecture
state	I-Architecture
,	O
the	O
input	O
is	O
accepted	O
,	O
else	O
,	O
it	O
is	O
rejected	O
.	O
</s>
<s>
For	O
a	O
more	O
elementary	O
introduction	O
of	O
the	O
formal	O
definition	O
,	O
see	O
automata	B-Application
theory	I-Application
.	O
</s>
<s>
An	O
NFA	O
is	O
represented	O
formally	O
by	O
a	O
5-tuple	O
,	O
</s>
<s>
a	O
finite	O
set	O
of	O
states	B-Application
.	O
</s>
<s>
a	O
set	O
of	O
states	B-Application
distinguished	O
as	O
accepting	O
(	O
or	O
final	O
)	O
states	B-Application
.	O
</s>
<s>
is	O
accepted	O
if	O
a	O
sequence	O
of	O
states	B-Application
,	O
,	O
exists	O
in	O
such	O
that	O
:	O
</s>
<s>
In	O
words	O
,	O
the	O
first	O
condition	O
says	O
that	O
the	O
machine	O
starts	O
in	O
the	O
start	B-Architecture
state	I-Architecture
.	O
</s>
<s>
The	O
last	O
condition	O
says	O
that	O
the	O
machine	O
accepts	O
if	O
the	O
last	O
input	O
of	O
causes	O
the	O
machine	O
to	O
halt	O
in	O
one	O
of	O
the	O
accepting	B-Architecture
states	I-Architecture
.	O
</s>
<s>
In	O
order	O
for	O
to	O
be	O
accepted	O
by	O
,	O
it	O
is	O
not	O
required	O
that	O
every	O
state	O
sequence	O
ends	O
in	O
an	O
accepting	B-Architecture
state	I-Architecture
,	O
it	O
is	O
sufficient	O
if	O
one	O
does	O
.	O
</s>
<s>
In	O
words	O
,	O
is	O
the	O
set	O
of	O
all	O
states	B-Application
reachable	O
from	O
state	O
by	O
consuming	O
the	O
string	O
.	O
</s>
<s>
The	O
string	O
is	O
accepted	O
if	O
some	O
accepting	B-Architecture
state	I-Architecture
in	O
can	O
be	O
reached	O
from	O
the	O
start	B-Architecture
state	I-Architecture
by	O
consuming	O
.	O
</s>
<s>
Sometimes	O
,	O
NFAs	O
are	O
defined	O
with	O
a	O
set	O
of	O
initial	O
states	B-Application
.	O
</s>
<s>
There	O
is	O
an	O
easy	O
construction	O
that	O
translates	O
an	O
NFA	O
with	O
multiple	O
initial	O
states	B-Application
to	O
an	O
NFA	O
with	O
a	O
single	O
initial	O
state	O
,	O
which	O
provides	O
a	O
convenient	O
notation	O
.	O
</s>
<s>
thumb|250px|The	O
state	B-Application
diagram	I-Application
for	O
M	O
.	O
It	O
is	O
not	O
deterministic	O
since	O
in	O
state	O
p	O
reading	O
a	O
1	O
can	O
lead	O
to	O
p	O
or	O
to	O
q	O
.	O
thumb|250px|All	O
possible	O
runs	O
of	O
M	O
on	O
input	O
string	O
"	O
10	O
"	O
.	O
</s>
<s>
thumb|530px|All	O
possible	O
runs	O
of	O
M	O
on	O
input	O
string	O
"	O
1011	O
"	O
.Arc	O
label	O
:	O
input	O
symbol	O
,	O
node	O
label	O
:	O
state	O
,	O
:	O
start	B-Architecture
state	I-Architecture
,	O
:	O
accepting	O
state(s )	O
.	O
</s>
<s>
the	O
transition	O
function	O
can	O
be	O
defined	O
by	O
this	O
state	B-Application
transition	I-Application
table	I-Application
(	O
cf	O
.	O
</s>
<s>
The	O
language	O
of	O
can	O
be	O
described	O
by	O
the	O
regular	B-General_Concept
language	I-General_Concept
given	O
by	O
the	O
regular	B-Language
expression	I-Language
(	O
0|1	O
)	O
*	O
1	O
.	O
</s>
<s>
In	O
contrast	O
,	O
the	O
string	O
"	O
10	O
"	O
is	O
rejected	O
by	O
(	O
all	O
possible	O
state	O
sequences	O
for	O
that	O
input	O
are	O
shown	O
in	O
the	O
upper	O
right	O
picture	O
)	O
,	O
since	O
there	O
is	O
no	O
way	O
to	O
reach	O
the	O
only	O
accepting	B-Architecture
state	I-Architecture
,	O
,	O
by	O
reading	O
the	O
final	O
0	O
symbol	O
.	O
</s>
<s>
A	O
deterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
(	O
DFA	B-General_Concept
)	O
can	O
be	O
seen	O
as	O
a	O
special	O
kind	O
of	O
NFA	O
,	O
in	O
which	O
for	O
each	O
state	O
and	O
symbol	O
,	O
the	O
transition	O
function	O
has	O
exactly	O
one	O
state	O
.	O
</s>
<s>
Thus	O
,	O
it	O
is	O
clear	O
that	O
every	O
formal	O
language	O
that	O
can	O
be	O
recognized	O
by	O
a	O
DFA	B-General_Concept
can	O
be	O
recognized	O
by	O
an	O
NFA	O
.	O
</s>
<s>
Conversely	O
,	O
for	O
each	O
NFA	O
,	O
there	O
is	O
a	O
DFA	B-General_Concept
such	O
that	O
it	O
recognizes	O
the	O
same	O
formal	O
language	O
.	O
</s>
<s>
The	O
DFA	B-General_Concept
can	O
be	O
constructed	O
using	O
the	O
powerset	B-General_Concept
construction	I-General_Concept
.	O
</s>
<s>
This	O
result	O
shows	O
that	O
NFAs	O
,	O
despite	O
their	O
additional	O
flexibility	O
,	O
are	O
unable	O
to	O
recognize	O
languages	O
that	O
cannot	O
be	O
recognized	O
by	O
some	O
DFA	B-General_Concept
.	O
</s>
<s>
It	O
is	O
also	O
important	O
in	O
practice	O
for	O
converting	O
easier-to-construct	O
NFAs	O
into	O
more	O
efficiently	O
executable	O
DFAs	B-General_Concept
.	O
</s>
<s>
However	O
,	O
if	O
the	O
NFA	O
has	O
n	O
states	B-Application
,	O
the	O
resulting	O
DFA	B-General_Concept
may	O
have	O
up	O
to	O
2n	O
states	B-Application
,	O
which	O
sometimes	O
makes	O
the	O
construction	O
impractical	O
for	O
large	O
NFAs	O
.	O
</s>
<s>
Nondeterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
with	O
ε-moves	O
(	O
NFA-ε	O
)	O
is	O
a	O
further	O
generalization	O
to	O
NFA	O
.	O
</s>
<s>
A	O
transition	O
without	O
consuming	O
an	O
input	O
symbol	O
is	O
called	O
an	O
ε-transition	O
and	O
is	O
represented	O
in	O
state	B-Application
diagrams	I-Application
by	O
an	O
arrow	O
labeled	O
"	O
ε	O
"	O
.	O
</s>
<s>
ε-transitions	O
provide	O
a	O
convenient	O
way	O
of	O
modeling	O
systems	O
whose	O
current	O
states	B-Application
are	O
not	O
precisely	O
known	O
:	O
i.e.	O
,	O
if	O
we	O
are	O
modeling	O
a	O
system	O
and	O
it	O
is	O
not	O
clear	O
whether	O
the	O
current	O
state	O
(	O
after	O
processing	O
some	O
input	O
string	O
)	O
should	O
be	O
q	O
or	O
q	O
 '	O
,	O
then	O
we	O
can	O
add	O
an	O
ε-transition	O
between	O
these	O
two	O
states	B-Application
,	O
thus	O
putting	O
the	O
automaton	O
in	O
both	O
states	B-Application
simultaneously	O
.	O
</s>
<s>
a	O
set	O
of	O
states	B-Application
distinguished	O
as	O
accepting	O
(	O
or	O
final	O
)	O
states	B-Application
.	O
</s>
<s>
For	O
a	O
state	O
,	O
let	O
denote	O
the	O
set	O
of	O
states	B-Application
that	O
are	O
reachable	O
from	O
by	O
following	O
ε-transitions	O
in	O
the	O
transition	O
function	O
,	O
i.e.	O
,	O
</s>
<s>
The	O
ε-closure	O
of	O
a	O
set	O
of	O
states	B-Application
of	O
an	O
NFA	O
is	O
defined	O
as	O
the	O
set	O
of	O
states	B-Application
reachable	O
from	O
any	O
state	O
in	O
following	O
ε-transitions	O
.	O
</s>
<s>
the	O
transition	O
relation	O
can	O
be	O
defined	O
by	O
this	O
state	B-Application
transition	I-Application
table	I-Application
:	O
</s>
<s>
can	O
be	O
viewed	O
as	O
the	O
union	O
of	O
two	O
DFAs	B-General_Concept
:	O
one	O
with	O
states	B-Application
and	O
the	O
other	O
with	O
states	B-Application
.	O
</s>
<s>
The	O
language	O
of	O
can	O
be	O
described	O
by	O
the	O
regular	B-General_Concept
language	I-General_Concept
given	O
by	O
this	O
regular	B-Language
expression	I-Language
.	O
</s>
<s>
Since	O
NFA	O
is	O
equivalent	O
to	O
DFA	B-General_Concept
,	O
NFA-ε	O
is	O
also	O
equivalent	O
to	O
DFA	B-General_Concept
.	O
</s>
<s>
These	O
closure	O
operations	O
are	O
used	O
in	O
Thompson	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
algorithm	I-General_Concept
,	O
which	O
constructs	O
an	O
NFA	O
from	O
any	O
regular	B-Language
expression	I-Language
.	O
</s>
<s>
They	O
can	O
also	O
be	O
used	O
to	O
prove	O
that	O
NFAs	O
recognize	O
exactly	O
the	O
regular	B-General_Concept
languages	I-General_Concept
.	O
</s>
<s>
Since	O
NFAs	O
are	O
equivalent	O
to	O
nondeterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
with	O
ε-moves	O
(	O
NFA-ε	O
)	O
,	O
the	O
above	O
closures	O
are	O
proved	O
using	O
closure	O
properties	O
of	O
NFA-ε	O
.	O
</s>
<s>
The	O
automaton	O
uses	O
the	O
state	B-Architecture
transition	I-Architecture
function	I-Architecture
Δ	O
to	O
determine	O
the	O
next	O
state	O
using	O
the	O
current	O
state	O
,	O
and	O
the	O
symbol	O
just	O
read	O
or	O
the	O
empty	O
string	O
.	O
</s>
<s>
If	O
,	O
when	O
the	O
automaton	O
has	O
finished	O
reading	O
,	O
it	O
is	O
in	O
an	O
accepting	B-Architecture
state	I-Architecture
,	O
the	O
NFA	O
is	O
said	O
to	O
accept	O
the	O
string	O
,	O
otherwise	O
it	O
is	O
said	O
to	O
reject	O
the	O
string	O
.	O
</s>
<s>
This	O
language	O
is	O
a	O
regular	B-General_Concept
language	I-General_Concept
.	O
</s>
<s>
For	O
every	O
NFA	O
a	O
deterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
(	O
DFA	B-General_Concept
)	O
can	O
be	O
found	O
that	O
accepts	O
the	O
same	O
language	O
.	O
</s>
<s>
Therefore	O
,	O
it	O
is	O
possible	O
to	O
convert	O
an	O
existing	O
NFA	O
into	O
a	O
DFA	B-General_Concept
for	O
the	O
purpose	O
of	O
implementing	O
a	O
(	O
perhaps	O
)	O
simpler	O
machine	O
.	O
</s>
<s>
This	O
can	O
be	O
performed	O
using	O
the	O
powerset	B-General_Concept
construction	I-General_Concept
,	O
which	O
may	O
lead	O
to	O
an	O
exponential	O
rise	O
in	O
the	O
number	O
of	O
necessary	O
states	B-Application
.	O
</s>
<s>
For	O
a	O
formal	O
proof	O
of	O
the	O
powerset	B-General_Concept
construction	I-General_Concept
,	O
please	O
see	O
the	O
Powerset	B-General_Concept
construction	I-General_Concept
article	O
.	O
</s>
<s>
Convert	O
to	O
the	O
equivalent	O
DFA	B-General_Concept
.	O
</s>
<s>
In	O
some	O
cases	O
this	O
may	O
cause	O
exponential	O
blowup	O
in	O
the	O
number	O
of	O
states	B-Application
.	O
</s>
<s>
Keep	O
a	O
set	O
data	O
structure	O
of	O
all	O
states	B-Application
which	O
the	O
NFA	O
might	O
currently	O
be	O
in	O
.	O
</s>
<s>
On	O
the	O
consumption	O
of	O
an	O
input	O
symbol	O
,	O
unite	O
the	O
results	O
of	O
the	O
transition	O
function	O
applied	O
to	O
all	O
current	O
states	B-Application
to	O
get	O
the	O
set	O
of	O
next	O
states	B-Application
;	O
if	O
ε-moves	O
are	O
allowed	O
,	O
include	O
all	O
states	B-Application
reachable	O
by	O
such	O
a	O
move	O
(ε-	O
closure	O
)	O
.	O
</s>
<s>
Each	O
step	O
requires	O
at	O
most	O
s2	O
computations	O
,	O
where	O
s	O
is	O
the	O
number	O
of	O
states	B-Application
of	O
the	O
NFA	O
.	O
</s>
<s>
On	O
the	O
consumption	O
of	O
the	O
last	O
input	O
symbol	O
,	O
if	O
one	O
of	O
the	O
current	O
states	B-Application
is	O
a	O
final	O
state	O
,	O
the	O
machine	O
accepts	O
the	O
string	O
.	O
</s>
<s>
If	O
,	O
upon	O
consuming	O
the	O
last	O
input	O
symbol	O
,	O
at	O
least	O
one	O
copy	O
of	O
the	O
NFA	O
is	O
in	O
the	O
accepting	B-Architecture
state	I-Architecture
,	O
the	O
NFA	O
will	O
accept	O
.	O
</s>
<s>
(	O
This	O
,	O
too	O
,	O
requires	O
linear	O
storage	O
with	O
respect	O
to	O
the	O
number	O
of	O
NFA	O
states	B-Application
,	O
as	O
there	O
can	O
be	O
one	O
machine	O
for	O
every	O
NFA	O
state	O
.	O
)	O
</s>
<s>
NFAs	O
and	O
DFAs	B-General_Concept
are	O
equivalent	O
in	O
that	O
if	O
a	O
language	O
is	O
recognized	O
by	O
an	O
NFA	O
,	O
it	O
is	O
also	O
recognized	O
by	O
a	O
DFA	B-General_Concept
and	O
vice	O
versa	O
.	O
</s>
<s>
It	O
is	O
useful	O
because	O
constructing	O
an	O
NFA	O
to	O
recognize	O
a	O
given	O
language	O
is	O
sometimes	O
much	O
easier	O
than	O
constructing	O
a	O
DFA	B-General_Concept
for	O
that	O
language	O
.	O
</s>
<s>
For	O
example	O
,	O
it	O
is	O
much	O
easier	O
to	O
prove	O
closure	O
properties	O
of	O
regular	B-General_Concept
languages	I-General_Concept
using	O
NFAs	O
than	O
DFAs	B-General_Concept
.	O
</s>
