<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
Thompson	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
algorithm	I-General_Concept
,	O
also	O
called	O
the	O
McNaughton	B-General_Concept
–	I-General_Concept
Yamada	I-General_Concept
–	I-General_Concept
Thompson	I-General_Concept
algorithm	I-General_Concept
,	O
is	O
a	O
method	O
of	O
transforming	O
a	O
regular	B-Language
expression	I-Language
into	O
an	O
equivalent	O
nondeterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
(	O
NFA	O
)	O
.	O
</s>
<s>
This	O
NFA	O
can	O
be	O
used	O
to	O
match	B-Language
strings	I-Language
against	O
the	O
regular	B-Language
expression	I-Language
.	O
</s>
<s>
Regular	B-Language
expressions	I-Language
and	O
nondeterministic	B-General_Concept
finite	I-General_Concept
automata	I-General_Concept
are	O
two	O
representations	O
of	O
formal	O
languages	O
.	O
</s>
<s>
For	O
instance	O
,	O
text	B-Device
processing	I-Device
utilities	O
use	O
regular	B-Language
expressions	I-Language
to	O
describe	O
advanced	O
search	O
patterns	O
,	O
but	O
NFAs	O
are	O
better	O
suited	O
for	O
execution	O
on	O
a	O
computer	O
.	O
</s>
<s>
Hence	O
,	O
this	O
algorithm	O
is	O
of	O
practical	O
interest	O
,	O
since	O
it	O
can	O
compile	B-Language
regular	B-Language
expressions	I-Language
into	O
NFAs	O
.	O
</s>
<s>
From	O
a	O
theoretical	O
point	O
of	O
view	O
,	O
this	O
algorithm	O
is	O
a	O
part	O
of	O
the	O
proof	O
that	O
they	O
both	O
accept	O
exactly	O
the	O
same	O
languages	O
,	O
that	O
is	O
,	O
the	O
regular	B-General_Concept
languages	I-General_Concept
.	O
</s>
<s>
An	O
NFA	O
can	O
be	O
made	O
deterministic	O
by	O
the	O
powerset	B-General_Concept
construction	I-General_Concept
and	O
then	O
be	O
minimized	B-General_Concept
to	O
get	O
an	O
optimal	O
automaton	O
corresponding	O
to	O
the	O
given	O
regular	B-Language
expression	I-Language
.	O
</s>
<s>
To	O
decide	O
whether	O
two	O
given	O
regular	B-Language
expressions	I-Language
describe	O
the	O
same	O
language	O
,	O
each	O
can	O
be	O
converted	O
into	O
an	O
equivalent	O
minimal	O
deterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
via	O
Thompson	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
,	O
powerset	B-General_Concept
construction	I-General_Concept
,	O
and	O
DFA	B-General_Concept
minimization	I-General_Concept
.	O
</s>
<s>
If	O
,	O
and	O
only	O
if	O
,	O
the	O
resulting	O
automata	O
agree	O
up	O
to	O
renaming	O
of	O
states	O
,	O
the	O
regular	B-Language
expressions	I-Language
 '	O
languages	O
agree	O
.	O
</s>
<s>
More	O
precisely	O
,	O
from	O
a	O
regular	B-Language
expression	I-Language
,	O
the	O
obtained	O
automaton	O
with	O
the	O
transition	O
function	O
respects	O
the	O
following	O
properties	O
:	O
</s>
<s>
Let	O
be	O
the	O
number	O
of	O
concatenation	O
of	O
the	O
regular	B-Language
expression	I-Language
and	O
let	O
be	O
the	O
number	O
of	O
symbols	O
apart	O
from	O
parentheses	O
—	O
that	O
is	O
,	O
,	O
,	O
and	O
.	O
</s>
<s>
Since	O
an	O
NFA	O
of	O
states	O
and	O
at	O
most	O
transitions	O
from	O
each	O
state	O
can	O
match	O
a	O
string	O
of	O
length	O
in	O
time	O
,	O
a	O
Thompson	B-General_Concept
NFA	I-General_Concept
can	O
do	O
pattern	B-Language
matching	I-Language
in	O
linear	O
time	O
,	O
assuming	O
a	O
fixed-size	O
alphabet	O
.	O
</s>
<s>
With	O
these	O
rules	O
,	O
using	O
the	O
empty	O
expression	O
and	O
symbol	O
rules	O
as	O
base	O
cases	O
,	O
it	O
is	O
possible	O
to	O
prove	O
with	O
mathematical	B-Algorithm
induction	I-Algorithm
that	O
any	O
regular	B-Language
expression	I-Language
may	O
be	O
converted	O
into	O
an	O
equivalent	O
NFA	O
.	O
</s>
<s>
The	O
picture	O
below	O
shows	O
the	O
result	O
of	O
Thompson	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
on	O
( ε|a*b	O
)	O
.	O
</s>
<s>
As	O
an	O
example	O
,	O
the	O
picture	O
shows	O
the	O
result	O
of	O
Thompson	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
algorithm	I-General_Concept
on	O
the	O
regular	B-Language
expression	I-Language
(	O
0|( 1( 01*( 00	O
)	O
*	O
0	O
)	O
*	O
1	O
)	O
*	O
)	O
*	O
that	O
denotes	O
the	O
set	O
of	O
binary	O
numbers	O
that	O
are	O
multiples	O
of	O
3	O
:	O
</s>
<s>
The	O
left	O
part	O
shows	O
the	O
nondeterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
resulting	O
from	O
Thompson	O
's	O
algorithm	O
,	O
with	O
the	O
and	O
state	O
of	O
each	O
subexpression	O
colored	O
in	O
and	O
,	O
respectively	O
.	O
</s>
<s>
Thompson	O
's	O
is	O
one	O
of	O
several	O
algorithms	O
for	O
constructing	O
NFAs	O
from	O
regular	B-Language
expressions	I-Language
;	O
an	O
earlier	O
algorithm	O
was	O
given	O
by	O
McNaughton	O
and	O
Yamada	O
.	O
</s>
<s>
Converse	O
to	O
Thompson	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
,	O
Kleene	B-General_Concept
's	I-General_Concept
algorithm	I-General_Concept
transforms	O
a	O
finite	O
automaton	O
into	O
a	O
regular	B-Language
expression	I-Language
.	O
</s>
<s>
Glushkov	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
algorithm	I-General_Concept
is	O
similar	O
to	O
Thompson	B-General_Concept
's	I-General_Concept
construction	I-General_Concept
,	O
once	O
the	O
ε-transitions	O
are	O
removed	O
.	O
</s>
