Professional Documents
Culture Documents
Specifications and Notations: Classification Finite State Machines
Specifications and Notations: Classification Finite State Machines
Introduction
Classification
Finite State Machines
Specification
• An overloaded term
– Although we all agree that "specification must precede
implementation"
• (e.g. specification for functional abstractions and data abstractions =
pre/post conditions on the operations, etc.)
• In general
– specification = definition of a contract between a producer
and a consumer of a service
product
• Behavior of a lamp
Push switch
On Off
Push switch
High-pressure alarm
High-temperature alarm
On Off
Restart
Successful Unsuccessful
recovery recovery
Normal Off
Successful Unsuccessful
recovery recovery
Temperature
Temperature signal action Pressure signal
• FSM as recognizers
– introduce the notion of final state and of acceptance of a
string
• FSM as transducers
– introduce the notion of output
• Deterministic/nondeterministic
<digit>
<letter>
<letter>
q0 q1 q2
_
<letter> <digit>
Legend:
a q2
q1
a
q3
a, b, # # # a, b, #
q0 q1 q2 q3 qF
a, b, #
• Finite memory
• State explosion
– Given a number of FSMs with k1, k2, … kn states, their
composition is a FSM with k1 * k2 *… * kn.
This growth is exponential with the number of FSMs, not
linear (we would like it to be k1 + k2 +… + kn )
p1 p2 c1 c2
deposit consume
0 1 2
get get
Specification Notations: FSM 19
How to combine them into an FSM?
States = Cartesian product of states
get get
get
0,p1,c2 1,p1,c2 2,p1,c2
get
consume produce
produce produce
deposit deposit
0,p2,c2 consume 1,p2,c2 consume 2,p2,c2
• Statecharts
– cooperating finite state machines
– used in UML as state diagrams
• Petri nets
– Suitable for modeling concurrent systems
RecoverySuccess AnomalyDetection
Recovery
Recovery
Identification
Press Temp
Done Done
RecoveryFailure
Pressure Temperature
Action Action
GenSwitchOn
Command Lamp H
push
On Off
GenSwitchOff push
start stop
ConcurrentWork
deposit 1
P1 deposit C1
get
produce 0 get
deposit get consume
P2 2 C2