- State diagram
State diagrams is a
diagram used in the field ofcomputer science , representing the behavior of a system, which is composed of a finite number of states. There are many forms of state diagrams, which differ slightly and have different semantics.Overview
State diagrams are used to describe the
behavior of asystem . 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. [ [http://atlas.kennesaw.edu/~dbraun/csis4650/A&D/UML_tutorial/state.htm State Diagrams] . Retrieved 11 August 2008.]State diagram can be used to graphically represent
finite state machine s. This was introduced byTaylor Booth in his 1967 book "Sequential Machines and Automata Theory". Another possible representation is theState transition table .Directed graph
A classic form of a state diagram for a
finite state machine is adirected graph with the following elementsTaylor Booth (1967) "Sequential Machines and Automata Theory", John Wiley and Sons, New York.]John Hopcroft andJeffrey Ullman (1979) "Introduction to Automata Theory, Languages, and Computation ", Addison-Wesley Publishing Company, Reading Mass, ISBN 0-201-02988-X] :*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 ω : Σ × Q→ Z.
*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 δ : Σ × 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 textsEdward J. McClusky , Introduction to the Theory of Switching Circuits, McGraw-Hill, 1965] , 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 (DFA),nondeterministic finite state machine (NFA),generalized nondeterministic finite state machine (GNFA), orMoore machine , the input is denoted on each edge. For aMealy machine , 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 aMoore machine 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 {0,1} that contain an even number of zeros.:
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.:
Harel statechart
Harel statecharts
David Harel , [http://www.wisdom.weizmann.ac.il/~dharel/SCANNED.PAPERS/Statecharts.pdf Statecharts: A visual formalism for complex systems. Science of Computer Programming] , 8(3):231--274, June 1987.] are gaining widespread usage since a variant has become part of theUnified 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.
UML state diagram
Wikimedia Foundation. 2010.