<s>
A	O
state	B-Application
diagram	I-Application
is	O
a	O
type	O
of	O
diagram	O
used	O
in	O
computer	B-General_Concept
science	I-General_Concept
and	O
related	O
fields	O
to	O
describe	O
the	O
behavior	O
of	O
systems	O
.	O
</s>
<s>
State	B-Application
diagrams	I-Application
require	O
that	O
the	O
system	O
described	O
is	O
composed	O
of	O
a	O
finite	O
number	O
of	O
states	O
;	O
sometimes	O
,	O
this	O
is	O
indeed	O
the	O
case	O
,	O
while	O
at	O
other	O
times	O
this	O
is	O
a	O
reasonable	O
abstraction	B-Application
.	O
</s>
<s>
Many	O
forms	O
of	O
state	B-Application
diagrams	I-Application
exist	O
,	O
which	O
differ	O
slightly	O
and	O
have	O
different	O
semantics	O
.	O
</s>
<s>
State	B-Application
diagrams	I-Application
are	O
used	O
to	O
give	O
an	O
abstract	O
description	O
of	O
the	O
behavior	O
of	O
a	O
system	O
.	O
</s>
<s>
State	B-Application
diagrams	I-Application
can	O
be	O
used	O
to	O
graphically	O
represent	O
finite-state	B-Architecture
machines	I-Architecture
(	O
also	O
called	O
finite	B-Architecture
automata	I-Architecture
)	O
.	O
</s>
<s>
Another	O
possible	O
representation	O
is	O
the	O
state-transition	B-Application
table	I-Application
.	O
</s>
<s>
A	O
classic	O
form	O
of	O
state	B-Application
diagram	I-Application
for	O
a	O
finite	B-Architecture
automaton	I-Architecture
(	O
FA	O
)	O
is	O
a	O
directed	O
graph	O
with	O
the	O
following	O
elements	O
(	O
Q	O
,	O
Σ	O
,	O
Z	O
,	O
δ	O
,	O
q0	O
,	O
F	O
)	O
:	O
</s>
<s>
Edges	O
δ	O
:	O
represent	O
transitions	O
from	O
one	O
state	B-Application
to	O
another	O
as	O
caused	O
by	O
the	O
input	O
(	O
identified	O
by	O
their	O
symbols	O
drawn	O
on	O
the	O
edges	O
)	O
.	O
</s>
<s>
An	O
edge	O
is	O
usually	O
drawn	O
as	O
an	O
arrow	O
directed	O
from	O
the	O
present	O
state	B-Application
to	O
the	O
next	O
state	B-Application
.	O
</s>
<s>
This	O
mapping	O
describes	O
the	O
state	B-Application
transition	I-Application
that	O
is	O
to	O
occur	O
on	O
input	O
of	O
a	O
particular	O
symbol	O
.	O
</s>
<s>
Item	O
δ(q, a )	O
=	O
p	O
in	O
the	O
definition	O
of	O
the	O
FA	O
means	O
that	O
from	O
the	O
state	B-Application
named	O
q	O
under	O
input	O
symbol	O
a	O
,	O
the	O
transition	O
to	O
the	O
state	B-Application
p	O
occurs	O
in	O
this	O
machine	O
.	O
</s>
<s>
Start	B-Architecture
state	I-Architecture
q0	O
:	O
(	O
not	O
shown	O
in	O
the	O
examples	O
below	O
)	O
.	O
</s>
<s>
The	O
start	B-Architecture
state	I-Architecture
q0	O
∈	O
Q	O
is	O
usually	O
represented	O
by	O
an	O
arrow	O
with	O
no	O
origin	O
pointing	O
to	O
the	O
state	B-Application
.	O
</s>
<s>
In	O
older	O
texts	O
,	O
the	O
start	B-Architecture
state	I-Architecture
is	O
not	O
shown	O
and	O
must	O
be	O
inferred	O
from	O
the	O
text	O
.	O
</s>
<s>
Accepting	O
state(s )	O
F	O
:	O
If	O
used	O
,	O
for	O
example	O
for	O
accepting	O
automata	O
,	O
F	O
∈	O
Q	O
is	O
the	O
accepting	B-Architecture
state	I-Architecture
.	O
</s>
<s>
For	O
a	O
deterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
(	O
DFA	B-General_Concept
)	O
,	O
nondeterministic	B-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
(	O
NFA	O
)	O
,	O
generalized	B-General_Concept
nondeterministic	I-General_Concept
finite	I-General_Concept
automaton	I-General_Concept
(	O
GNFA	B-General_Concept
)	O
,	O
or	O
Moore	B-General_Concept
machine	I-General_Concept
,	O
the	O
input	O
is	O
denoted	O
on	O
each	O
edge	O
.	O
</s>
<s>
For	O
a	O
Mealy	B-General_Concept
machine	I-General_Concept
,	O
input	O
and	O
output	O
are	O
signified	O
on	O
each	O
edge	O
,	O
separated	O
with	O
a	O
slash	O
"	O
/	O
"	O
:	O
"	O
1/0	O
"	O
denotes	O
the	O
state	B-Application
change	O
upon	O
encountering	O
the	O
symbol	O
"	O
1	O
"	O
causing	O
the	O
symbol	O
"	O
0	O
"	O
to	O
be	O
output	O
.	O
</s>
<s>
For	O
a	O
Moore	B-General_Concept
machine	I-General_Concept
the	O
state	B-Application
's	O
output	O
is	O
usually	O
written	O
inside	O
the	O
state	B-Application
's	O
circle	O
,	O
also	O
separated	O
from	O
the	O
state	B-Application
's	O
designator	O
with	O
a	O
slash	O
"	O
/	O
"	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
a	O
state	B-Application
has	O
a	O
number	O
of	O
outputs	O
(	O
e.g.	O
</s>
<s>
"	O
q5/1	O
,	O
0	O
"	O
designates	O
state	B-Application
q5	O
with	O
outputs	O
a	O
=	O
1	O
,	O
b	O
=	O
0	O
.	O
</s>
<s>
This	O
designator	O
will	O
be	O
written	O
inside	O
the	O
state	B-Application
's	O
circle	O
.	O
</s>
<s>
S1	O
and	O
S2	O
are	O
states	O
and	O
S1	O
is	O
an	O
accepting	B-Architecture
state	I-Architecture
or	O
a	O
final	O
state	B-Application
.	O
</s>
<s>
Harel	O
statecharts	B-Application
,	O
invented	O
by	O
computer	O
scientist	O
David	O
Harel	O
,	O
are	O
gaining	O
widespread	O
usage	O
since	O
a	O
variant	O
has	O
become	O
part	O
of	O
the	O
Unified	B-Language
Modeling	I-Language
Language	I-Language
(	O
UML	B-Language
)	O
.	O
</s>
<s>
The	O
diagram	O
type	O
allows	O
the	O
modeling	O
of	O
superstates	O
,	O
orthogonal	O
regions	O
,	O
and	O
activities	O
as	O
part	O
of	O
a	O
state	B-Application
.	O
</s>
<s>
Classic	O
state	B-Application
diagrams	I-Application
require	O
the	O
creation	O
of	O
distinct	O
nodes	O
for	O
every	O
valid	O
combination	O
of	O
parameters	O
that	O
define	O
the	O
state	B-Application
.	O
</s>
<s>
This	O
can	O
lead	O
to	O
a	O
very	O
large	O
number	O
of	O
nodes	O
and	O
transitions	O
between	O
nodes	O
for	O
all	O
but	O
the	O
simplest	O
of	O
systems	O
(	O
state	B-Application
and	O
transition	O
explosion	O
)	O
.	O
</s>
<s>
This	O
complexity	O
reduces	O
the	O
readability	O
of	O
the	O
state	B-Application
diagram	I-Application
.	O
</s>
<s>
With	O
Harel	O
statecharts	B-Application
it	O
is	O
possible	O
to	O
model	O
multiple	O
cross-functional	O
state	B-Application
diagrams	I-Application
within	O
the	O
statechart	B-Application
.	O
</s>
<s>
Each	O
of	O
these	O
cross-functional	O
state	B-Architecture
machines	I-Architecture
can	O
transition	O
internally	O
without	O
affecting	O
the	O
other	O
state	B-Architecture
machines	I-Architecture
in	O
the	O
statechart	B-Application
.	O
</s>
<s>
The	O
current	O
state	B-Application
of	O
each	O
cross-functional	O
state	B-Architecture
machine	I-Architecture
in	O
the	O
statechart	B-Application
defines	O
the	O
state	B-Application
of	O
the	O
system	O
.	O
</s>
<s>
The	O
Harel	O
statechart	B-Application
is	O
equivalent	O
to	O
a	O
state	B-Application
diagram	I-Application
but	O
it	O
improves	O
the	O
readability	O
of	O
the	O
resulting	O
diagram	O
.	O
</s>
<s>
There	O
are	O
other	O
sets	O
of	O
semantics	O
available	O
to	O
represent	O
state	B-Application
diagrams	I-Application
.	O
</s>
<s>
These	O
diagrams	O
,	O
like	O
Harel	O
's	O
original	O
state	B-Architecture
machines	I-Architecture
,	O
support	O
hierarchically	O
nested	O
states	O
,	O
orthogonal	O
regions	O
,	O
state	B-Application
actions	O
,	O
and	O
transition	O
actions	O
.	O
</s>
<s>
Newcomers	O
to	O
the	O
state	B-Architecture
machine	I-Architecture
formalism	O
often	O
confuse	O
state	B-Application
diagrams	I-Application
with	O
flowcharts	B-Language
.	O
</s>
<s>
The	O
figure	O
below	O
shows	O
a	O
comparison	O
of	O
a	O
state	B-Application
diagram	I-Application
with	O
a	O
flowchart	B-Language
.	O
</s>
<s>
A	O
state	B-Architecture
machine	I-Architecture
(	O
panel	O
(	O
a	O
)	O
)	O
performs	O
actions	O
in	O
response	O
to	O
explicit	O
events	O
.	O
</s>
<s>
In	O
contrast	O
,	O
the	O
flowchart	B-Language
(	O
panel	O
(	O
b	O
)	O
)	O
does	O
not	O
need	O
explicit	O
events	O
but	O
rather	O
transitions	O
from	O
node	O
to	O
node	O
in	O
its	O
graph	O
automatically	O
upon	O
completion	O
of	O
activities	O
.	O
</s>
<s>
Nodes	O
of	O
flowcharts	B-Language
are	O
edges	O
in	O
the	O
induced	O
graph	O
of	O
states	O
.	O
</s>
<s>
The	O
reason	O
is	O
that	O
each	O
node	O
in	O
a	O
flowchart	B-Language
represents	O
a	O
program	O
command	O
.	O
</s>
<s>
So	O
it	O
is	O
not	O
a	O
state	B-Application
,	O
but	O
when	O
applied	O
to	O
the	O
program	O
's	O
state	B-Application
,	O
it	O
results	O
in	O
a	O
transition	O
to	O
another	O
state	B-Application
.	O
</s>
<s>
Executing	O
the	O
program	O
graph	O
(	O
parsing	O
and	O
interpreting	O
)	O
results	O
in	O
a	O
state	B-Application
graph	I-Application
.	O
</s>
<s>
So	O
each	O
program	O
graph	O
induces	O
a	O
state	B-Application
graph	I-Application
.	O
</s>
<s>
Conversion	O
of	O
the	O
program	O
graph	O
to	O
its	O
associated	O
state	B-Application
graph	I-Application
is	O
called	O
"	O
unfolding	O
"	O
of	O
the	O
program	O
graph	O
.	O
</s>
<s>
If	O
no	O
variables	O
exist	O
,	O
then	O
the	O
state	B-Application
consists	O
only	O
of	O
the	O
program	O
counter	O
,	O
which	O
keeps	O
track	O
of	O
where	O
in	O
the	O
program	O
we	O
are	O
during	O
execution	O
(	O
what	O
is	O
the	O
next	O
command	O
to	O
be	O
applied	O
)	O
.	O
</s>
<s>
In	O
this	O
case	O
before	O
executing	O
a	O
command	O
the	O
program	O
counter	O
is	O
at	O
some	O
position	O
(	O
state	B-Application
before	O
the	O
command	O
is	O
executed	O
)	O
.	O
</s>
<s>
Since	O
the	O
program	O
counter	O
is	O
the	O
whole	O
state	B-Application
,	O
it	O
follows	O
that	O
executing	O
the	O
command	O
changed	O
the	O
state	B-Application
.	O
</s>
<s>
in	O
a	O
loop	O
)	O
,	O
this	O
does	O
n't	O
imply	O
the	O
program	O
is	O
in	O
the	O
same	O
state	B-Application
.	O
</s>
<s>
In	O
the	O
previous	O
case	O
,	O
the	O
program	O
would	O
be	O
in	O
the	O
same	O
state	B-Application
,	O
because	O
the	O
whole	O
state	B-Application
is	O
just	O
the	O
program	O
counter	O
,	O
so	O
if	O
the	O
program	O
counterpoints	O
to	O
the	O
same	O
position	O
(	O
next	O
command	O
)	O
it	O
suffices	O
to	O
specify	O
that	O
we	O
are	O
in	O
the	O
same	O
state	B-Application
.	O
</s>
<s>
However	O
,	O
if	O
the	O
state	B-Application
includes	O
variables	O
,	O
then	O
if	O
those	O
change	O
value	O
,	O
we	O
can	O
be	O
at	O
the	O
same	O
program	O
location	O
with	O
different	O
variable	O
values	O
,	O
meaning	O
in	O
a	O
different	O
state	B-Application
in	O
the	O
program	O
's	O
state	B-Application
space	O
.	O
</s>
<s>
The	O
term	O
"	O
unfolding	O
"	O
originates	O
from	O
this	O
multiplication	O
of	O
locations	O
when	O
producing	O
the	O
state	B-Application
graph	I-Application
from	O
the	O
program	O
graph	O
.	O
</s>
<s>
A	O
self	O
transition	O
is	O
a	O
transition	O
where	O
the	O
initial	O
and	O
the	O
final	O
state	B-Application
are	O
the	O
same	O
.	O
</s>
<s>
Although	O
the	O
do	O
loop	O
executes	O
the	O
same	O
increment	O
command	O
iteratively	O
,	O
so	O
the	O
program	O
graph	O
executes	O
a	O
cycle	O
,	O
in	O
its	O
state	B-Application
space	O
is	O
not	O
a	O
cycle	O
,	O
but	O
a	O
line	O
.	O
</s>
<s>
This	O
results	O
from	O
the	O
state	B-Application
being	O
the	O
program	O
location	O
(	O
here	O
cycling	O
)	O
combined	O
with	O
the	O
counter	O
value	O
,	O
which	O
is	O
strictly	O
increasing	O
(	O
until	O
the	O
overflow	O
)	O
,	O
so	O
different	O
states	O
are	O
visited	O
in	O
sequence	O
,	O
until	O
the	O
overflow	O
.	O
</s>
<s>
After	O
the	O
overflow	O
the	O
counter	O
becomes	O
0	O
again	O
,	O
so	O
the	O
initial	O
state	B-Application
is	O
revisited	O
in	O
the	O
state	B-Application
space	O
,	O
closing	O
a	O
cycle	O
in	O
the	O
state	B-Application
space	O
(	O
assuming	O
the	O
counter	O
was	O
initialized	O
to	O
0	O
)	O
.	O
</s>
<s>
The	O
figure	O
above	O
attempts	O
to	O
show	O
that	O
reversal	O
of	O
roles	O
by	O
aligning	O
the	O
arcs	O
of	O
the	O
state	B-Application
diagrams	I-Application
with	O
the	O
processing	O
stages	O
of	O
the	O
flowchart	B-Language
.	O
</s>
<s>
You	O
can	O
compare	O
a	O
flowchart	B-Language
to	O
an	O
assembly	O
line	O
in	O
manufacturing	O
because	O
the	O
flowchart	B-Language
describes	O
the	O
progression	O
of	O
some	O
task	O
from	O
beginning	O
to	O
end	O
(	O
e.g.	O
,	O
transforming	O
source	O
code	O
input	O
into	O
object	O
code	O
output	O
by	O
a	O
compiler	O
)	O
.	O
</s>
<s>
A	O
state	B-Architecture
machine	I-Architecture
generally	O
has	O
no	O
notion	O
of	O
such	O
a	O
progression	O
.	O
</s>
<s>
The	O
door	O
state	B-Architecture
machine	I-Architecture
shown	O
at	O
the	O
top	O
of	O
this	O
article	O
,	O
for	O
example	O
,	O
is	O
not	O
in	O
a	O
more	O
advanced	O
stage	O
when	O
it	O
is	O
in	O
the	O
"	O
closed	O
"	O
state	B-Application
,	O
compared	O
to	O
being	O
in	O
the	O
"	O
opened	O
"	O
state	B-Application
;	O
it	O
simply	O
reacts	O
differently	O
to	O
the	O
open/close	O
events	O
.	O
</s>
<s>
A	O
state	B-Application
in	O
a	O
state	B-Architecture
machine	I-Architecture
is	O
an	O
efficient	O
way	O
of	O
specifying	O
a	O
particular	O
behavior	O
,	O
rather	O
than	O
a	O
stage	O
of	O
processing	O
.	O
</s>
<s>
This	O
only	O
makes	O
sense	O
if	O
the	O
system	O
is	O
allowed	O
to	O
be	O
in	O
multiple	O
states	O
at	O
once	O
,	O
which	O
implies	O
that	O
an	O
individual	O
state	B-Application
only	O
describes	O
a	O
condition	O
or	O
other	O
partial	O
aspect	O
of	O
the	O
overall	O
,	O
global	O
state	B-Application
.	O
</s>
<s>
The	O
resulting	O
formalism	O
is	O
known	O
as	O
a	O
Petri	B-Operating_System
net	I-Operating_System
.	O
</s>
<s>
Another	O
extension	O
allows	O
the	O
integration	O
of	O
flowcharts	B-Language
within	O
Harel	O
statecharts	B-Application
.	O
</s>
