State diagram

From Wikipedia, the free encyclopedia

State diagrams are used to graphically represent finite state machines. State transition tables are another possible representation.

There are many forms of state diagrams, which differ slightly and have different semantics.

Contents

[edit] Directed graph

A classic form of a state diagram for a finite state machine is a directed graph with the following elements[1] [2]:

States Q: a finite set of vertices normally represented by circles and labelled with unique designator symbols or words written inside them;

Input symbols Σ: a finite collection of input symbols or designators;

Output symbols Z: a finite collection of output symbols or designators;

The output function ω represents the mapping of input symbols into output symbols, denoted mathematically as ω : Σ × QZ.

Edges δ: represent the "transitions" between two states as caused by the input (identified by their symbols drawn on the "edges"). An 'edge' is usually drawn as an arrow directed from the present-state toward the next-state. This mapping describes the state transitions that is to occur on input of a particular symbol. This is written mathematically as δ : Σ × QZ

Start state q0: (not shown in the examples below). The start state q0 ∈ Q is usually represented by an arrow with no origin pointing to the state. In older texts[1][3], the start state is not shown and must be inferred from the text.

Accepting state(s) F: If used, for example for accepting automata, F ∈ Q is the accepting state. It is usually drawn as a double circle. Sometimes the accept state(s) function as "Final" (halt, trapped) states[2] are gaining widespread usage since a variant has become part of the Unified Modeling Language. The diagram type allows the modeling of superstates, concurrent states, and activities as part of a state.

Classic state diagrams are "or" (disjunctive) diagrams, because the machine can only be in one of all the possible states. With Harel statecharts it is possible to model "and" machines, where a machine can be in two or more states concurrently. This is due in part to the modelling of superstates and in part to the modelling of concurrent machines.

[edit] UML state diagram

Example UML State diagram.
Example UML State diagram.

The Unified Modeling Language (UML) state diagram is essentially a Harel statechart with standardized notation[4], which can describe many systems, from computer programs to business processes. The following are the basic notational elements that can be used to make up a diagram:

  • Filled circle, pointing to the initial state
  • Hollow circle containing a smaller filled circle, indicating the final state (if any)
  • Rounded rectangle, denoting a state. Top of the rectangle contains a name of the state. Can contain a horizontal line in the middle, below which the activities that are done in that state are indicated
  • Arrow, denoting transition. The name of the event (if any) causing this transition labels the arrow body. A guard expression may be added before a "/" and enclosed in square-brackets ( eventName[guardExpression] ), denoting that this expression must be true for the transition to take place. If an action is performed during this transition, it is added to the label following a "/" ( eventName[guardExpression]/action ).
  • Thick horizontal line with either x>1 lines entering and 1 line leaving or 1 line entering and x>1 lines leaving. These denote join/fork, respectively.

According to Pilone[5], the only predefined guard condition is ELSE. No other examples are provided within that publication.


[edit] Other extensions

An interesting extension is to allow arcs to flow from any number of states to any number of states. This only makes sense if the system is allowed to be in multiple states at once, which implies that an individual state only describes a condition or other partial aspect of the overall, global state. The resulting formalism is known as a Petri net.

Another extension allows the integration of flowcharts within Harel statecharts. This extension supports the development of software that is both event driven and workflow driven.


[edit] References

[edit] Notes

  1. ^ a b Taylor Booth (1967) Sequential Machines and Automata Theory, John Wiley and Sons, New York.
  2. ^ a b John Hopcroft and Jeffrey Ullman (1979) Introduction to Automata Theory, Languages, and Computation, Addison-Wesley Publishing Company, Reading Mass, ISBN 0-201-02988-X
  3. ^ Edward J. McClusky, Introduction to the Theory of Switching Circuits, McGraw-Hill, 1965
  4. ^ D. Drusinsky, Modelling and verification using UML statecharts, Elsevier, 2006
  5. ^ Don Pilone, UML 2.0 Pocket Reference, O'Reilly, 2006
Unified Modeling Language (UML) (category)view  talk  edit )
Background

Organizations: Object Management Group (OMG) • UML Partners

Persons: Grady Booch • Ivar Jacobson • James Rumbaugh 

Concepts

Object oriented: programming (OOP) • analysis and design (OOAD)

Structure: Actor • Attribute • Class • Component • Interface • Object • Package 

Behavior: Activity • Event • Message • Method • Operation • State • Use case 

Relationships: Aggregation • Association • Composition • Dependency • Generalization (or Inheritance

Extensibility: Profile • Constraint • Stereotype • Tagged values 

Other concepts: Multiplicity • Role 

Diagrams

Structure diagrams
Class diagram • Component diagram • Composite structure diagram • Deployment diagram • Object diagram • Package diagram 

Behavior diagrams
Activity diagram • State Machine diagram • Use case diagram • Communication diagram • Interaction overview diagram • Sequence diagram • Timing diagram 

Topics

Compared to relational database model (ERD) • Glossary of UML terms • Systems Modeling Language (SysML) • UML colors:

Role Moment, Interval Description Party, place, thing
Tools(category) and Processes

List of UML tools • Rational Unified Process (RUP)