All Topics  
State diagram

 

   Email Print
   Bookmark   Link






 

State diagram



 
 
A state diagram is a type of diagram
Diagram

A diagram is a 2D geometric model symbolic representation of information according to some visualization technique. Sometimes, the technique uses a Three-dimensional space visualization which is then graphical projection onto the 2D surface....
 used in computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
 and related fields to describe the behavior of systems. State diagrams require that the system described is composed of a finite number of state
State (computer science)

In computer science and automata theory, a state is a unique configuration of information in a program or machine. It is a concept that occasionally extends into some forms of systems programming such as Lexical analysiss and parsers....
s; sometimes, this is indeed the case, while at other times this is a reasonable abstraction
Abstraction

Abstraction is the process or result of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose....
. There are many forms of state diagrams, which differ slightly and have different semantics
Semantics

Semantics is the study of meaning in communication. The word is derived from the Greek language word s??a?t???? , "significant", from s??a??? , "to signify, to indicate" and that from s??a , "sign, mark, token"....
.

e diagrams are used to describe the behavior
Behavior

Behavior or behaviour refers to the action s or reactions of an object or organism, usually in Relational theory to the environment. Behavior can be conscious or Unconscious mind, overt or covert, and voluntary or involuntary....
 of a system
System

System is a set of interacting or interdependent entities, real or abstract, forming an integrated whole.The concept of an "integrated whole" can also be stated in terms of a system embodying a set of relationships which are differentiated from relationships of the set to other elements, and from relationships between an element of the se...
.






Discussion
Ask a question about 'State diagram'
Start a new discussion about 'State diagram'
Answer questions from other users
Full Discussion Forum



Recent Posts









Encyclopedia


A state diagram is a type of diagram
Diagram

A diagram is a 2D geometric model symbolic representation of information according to some visualization technique. Sometimes, the technique uses a Three-dimensional space visualization which is then graphical projection onto the 2D surface....
 used in computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
 and related fields to describe the behavior of systems. State diagrams require that the system described is composed of a finite number of state
State (computer science)

In computer science and automata theory, a state is a unique configuration of information in a program or machine. It is a concept that occasionally extends into some forms of systems programming such as Lexical analysiss and parsers....
s; sometimes, this is indeed the case, while at other times this is a reasonable abstraction
Abstraction

Abstraction is the process or result of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose....
. There are many forms of state diagrams, which differ slightly and have different semantics
Semantics

Semantics is the study of meaning in communication. The word is derived from the Greek language word s??a?t???? , "significant", from s??a??? , "to signify, to indicate" and that from s??a , "sign, mark, token"....
.

Overview

State diagrams are used to describe the behavior
Behavior

Behavior or behaviour refers to the action s or reactions of an object or organism, usually in Relational theory to the environment. Behavior can be conscious or Unconscious mind, overt or covert, and voluntary or involuntary....
 of a system
System

System is a set of interacting or interdependent entities, real or abstract, forming an integrated whole.The concept of an "integrated whole" can also be stated in terms of a system embodying a set of relationships which are differentiated from relationships of the set to other elements, and from relationships between an element of the se...
. State diagrams can describe the possible states of an object as events occur. Each diagram usually represents objects of a single class and track the different states of its objects through the system.

State diagram can be used to graphically represent finite state machine
Finite state machine

A finite state machine or finite state automaton or simply a state machine, is a model of behavior composed of a finite number of state s, transitions between those states, and actions....
s. This was introduced by Taylor Booth
Taylor Booth

Taylor L. Booth was a mathematician known for his work in automata theory.One of his fundamental works is Sequential Machines and Automata Theory ....
 in his 1967 book "Sequential Machines and Automata Theory". Another possible representation is the State transition table
State transition table

In automata theory and sequential logic, a state transition table is a table showing what state a finite semiautomaton or finite state machine will move to, based on the current state and other inputs....
.

Directed graph

Directed
A classic form of a state diagram for a finite state machine
Finite state machine

A finite state machine or finite state automaton or simply a state machine, is a model of behavior composed of a finite number of state s, transitions between those states, and actions....
 is a directed graph
Directed graph

A directed graph or digraph is a pair G= of:* a Set V, whose element are called vertices or nodes,* a set A of ordered pairs of vertices, called arcs, directed edges, or arrows....
 with the following elements


  • States Q: a finite set of vertices normally represented by circles and labelled with unique designator symbols or words written inside them;
  • Input symbols S: 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 ? : S × Q? Z.

  • Edges d: 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 d : S × Q ? Z
  • 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, 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.


For a deterministic finite state machine
Deterministic finite state machine

In the theory of computation, a deterministic automaton finite state machine is a finite state machine where for each pair of state and input symbol there is one and only one transition to a next state....
 (DFA), nondeterministic finite state machine
Nondeterministic finite state machine

In the theory of computation, a nondeterministic finite state machine or nondeterministic finite automaton is a finite state machine where for each pair of state and input symbol there may be several possible next states....
 (NFA), generalized nondeterministic finite state machine
Generalized nondeterministic finite state machine

In the theory of computation, a generalized nondeterministic finite state machine or generalized nondeterministic finite automaton is a nondeterministic finite state machine where each transition may be labeled with any regular expression....
 (GNFA), or Moore machine
Moore machine

In the theory of computation, a Moore machine is a finite state transducer where the outputs are determined by the current state alone . The state diagram for a Moore machine will include an output signal for each state....
, the input is denoted on each edge. For a Mealy machine
Mealy machine

In the theory of computation, a Mealy machine is a finite state transducer that generates an output based on its current state and an input....
, input and output are signified on each edge, separated with a slash "/": "1/0" denotes the state change upon encountering the symbol "1" causing the symbol "0" to be output. For a Moore machine
Moore machine

In the theory of computation, a Moore machine is a finite state transducer where the outputs are determined by the current state alone . The state diagram for a Moore machine will include an output signal for each state....
 the state's output is usually written inside the state's circle, also separated from the state's designator with a slash "/". There are also variants that combine these two notations.

For example, if a state has a number of outputs (e.g. "a= motor counter-clockwise=1, b= caution light inactive=0") the diagram should reflect this : e.g. "q5/1,0" designates state q5 with outputs a=1, b=0. This designator will be written inside the state's circle.

Example: DFA, NFA, GNFA, or Moore machine

S1 and S2 are states and S1 is an accepting state. Each edge is labeled with the input. This example shows an acceptor for strings over that contain an even number of zeros.
Dfaexample

Example: Mealy machine

S0, S1, and S2 are states. Each edge is labeled with "j / k" where j is the input and k is the output.
Mealymachine Jaredwf

Harel statechart


Harel
David Harel

David Harel is a professor of computer science at the Weizmann Institute of Science in Israel. Born in London, England, he was Dean of the Faculty of Mathematics and Computer Science at the institute for seven years....
 statecharts are gaining widespread usage since a variant has become part of the Unified Modeling Language
Unified Modeling Language

Unified Modeling Language is a standardized general-purpose modeling language in the field of software engineering.UML includes a set of graphical notation techniques to create abstract models of specific systems....
. The diagram type allows the modeling of superstates, concurrent states, and activities as part of a state.

Classic state diagrams require the creation of distinct nodes for every valid combination of parameters that define the state. This can lead to a very large number of nodes and transitions between nodes for all but the simplest of systems. This complexity reduces the readability of the state diagram. With Harel statecharts it is possible to model multiple cross-functional state diagrams within the statechart. Each of these cross-functional state machines can transition internally without affecting the other state machines in the statechart. The current state of each cross-functional state machine in the statechart defines the state of the system. The Harel statechart equivalent to a state diagram but it improves the readability of the resulting diagram.

UML state diagram

Uml State Diagram
The Unified Modeling Language
Unified Modeling Language

Unified Modeling Language is a standardized general-purpose modeling language in the field of software engineering.UML includes a set of graphical notation techniques to create abstract models of specific systems....
 (UML) state diagram is essentially a Harel statechart with standardized notation, 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 (computing)
    Guard (computing)

    In computer programming, a guard is a Boolean datatype expression that must evaluate to true if the program execution is to continue in the branch in question....
     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, the only predefined guard condition is ELSE. No other examples are provided within that publication.

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
Petri net

A Petri net is one of several mathematical modeling languages for the description of discrete distributed systems. A Petri net is a directed bipartite graph, in which the nodes represent transitions , places , and directed arcs ....
.

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.

See also

  • SCXML
    SCXML

    SCXML stands for State Chart XML: State Machine Notation for Control Abstraction. It is an XML-based markup language which provides a generic state-machine based execution environment based on Statechart#Harel statechart....
     an XML language that provides a generic state-machine based execution environment based on Harel statecharts.
  • David Harel
    David Harel

    David Harel is a professor of computer science at the Weizmann Institute of Science in Israel. Born in London, England, he was Dean of the Faculty of Mathematics and Computer Science at the institute for seven years....


External links

  • - StateWizard: a ClassWizard-like round-trip UML dynamic modeling/development framework and tool running in popular IDEs.
  • by Scott W. Ambler
  • by Scott W. Ambler
  • - video introduction to state charts and thinking in hierarchical states.