State Diagrams. Margaret M. Fleck. 14 November 2011

Similar documents
15.12 Applications of Suffix Trees

Nonreversibility of Multiple Unicast Networks

Chapter 3 Church-Turing Thesis. CS 341: Foundations of CS II

CMSC 451: Lecture 9 Greedy Approximation: Set Cover Thursday, Sep 28, 2017

Intermediate Math Circles November 18, 2009 Solving Linear Diophantine Equations

Overview. Regular Expressions and Finite-State. Motivation. Regular expressions. RE syntax Additional functions. Regular languages Properties

Sequence Analysis, WS 14/15, D. Huson & R. Neher (this part by D. Huson & J. Fischer) January 21,

The Laws of Acceleration

Relativistic Dynamics

General Equilibrium. What happens to cause a reaction to come to equilibrium?

Complexity of Regularization RBF Networks

Math 151 Introduction to Eigenvectors

Searching All Approximate Covers and Their Distance using Finite Automata

Hankel Optimal Model Order Reduction 1

Maximum Entropy and Exponential Families

Aharonov-Bohm effect. Dan Solomon.

Relative Maxima and Minima sections 4.3

Branch and Price for Multi-Agent Plan Recognition

Modes are solutions, of Maxwell s equation applied to a specific device.

Control Theory association of mathematics and engineering

Q2. [40 points] Bishop-Hill Model: Calculation of Taylor Factors for Multiple Slip

Millennium Relativity Acceleration Composition. The Relativistic Relationship between Acceleration and Uniform Motion

Probabilistic Graphical Models

3 Tidal systems modelling: ASMITA model

Convergence of reinforcement learning with general function approximators

FREQUENCY DOMAIN FEEDFORWARD COMPENSATION. F.J. Pérez Castelo and R. Ferreiro Garcia

EECS 120 Signals & Systems University of California, Berkeley: Fall 2005 Gastpar November 16, Solutions to Exam 2

Advanced Computational Fluid Dynamics AA215A Lecture 4

max min z i i=1 x j k s.t. j=1 x j j:i T j

Product Policy in Markets with Word-of-Mouth Communication. Technical Appendix

Lecture 3 - Lorentz Transformations

Supplementary Materials

Algorithms for Supervisory Control

We will show that: that sends the element in π 1 (P {z 1, z 2, z 3, z 4 }) represented by l j to g j G.

Adaptive neuro-fuzzy inference system-based controllers for smart material actuator modelling

arxiv: v1 [cs.cc] 27 Jul 2014

arxiv:math/ v1 [math.ca] 27 Nov 2003

arxiv: v2 [math.pr] 9 Dec 2016

Evaluation of effect of blade internal modes on sensitivity of Advanced LIGO

Chapter Two: Finite Automata

Experiment 03: Work and Energy

Sufficient Conditions for a Flexible Manufacturing System to be Deadlocked

Lecture 7: Sampling/Projections for Least-squares Approximation, Cont. 7 Sampling/Projections for Least-squares Approximation, Cont.

7 Max-Flow Problems. Business Computing and Operations Research 608

Physical Laws, Absolutes, Relative Absolutes and Relativistic Time Phenomena

Estimating the probability law of the codelength as a function of the approximation error in image compression

2 The Bayesian Perspective of Distributions Viewed as Information

A Queueing Model for Call Blending in Call Centers

Weighted K-Nearest Neighbor Revisited

Wavetech, LLC. Ultrafast Pulses and GVD. John O Hara Created: Dec. 6, 2013

Relativity in Classical Physics

A NETWORK SIMPLEX ALGORITHM FOR THE MINIMUM COST-BENEFIT NETWORK FLOW PROBLEM

Chapter 15 Equilibrium. Reversible Reactions & Equilibrium. Reversible Reactions & Equilibrium. Reversible Reactions & Equilibrium 5/27/2014

Measuring & Inducing Neural Activity Using Extracellular Fields I: Inverse systems approach

Packing Plane Spanning Trees into a Point Set

23.1 Tuning controllers, in the large view Quoting from Section 16.7:

Some Properties on Nano Topology Induced by Graphs

A Spatiotemporal Approach to Passive Sound Source Localization

Lightpath routing for maximum reliability in optical mesh networks

Tight bounds for selfish and greedy load balancing

Lecture Notes 4 MORE DYNAMICS OF NEWTONIAN COSMOLOGY

Subject: Introduction to Component Matching and Off-Design Operation % % ( (1) R T % (

9 Geophysics and Radio-Astronomy: VLBI VeryLongBaseInterferometry

Assessing the Performance of a BCI: A Task-Oriented Approach

Arithmetic Circuits. Comp 120, Spring 05 2/10 Lecture. Today s BIG Picture Reading: Study Chapter 3. (Chapter 4 in old book)

Are You Ready? Ratios

The Hanging Chain. John McCuan. January 19, 2006

Geometry of Transformations of Random Variables

Computer Science 786S - Statistical Methods in Natural Language Processing and Data Analysis Page 1

Quantum secret sharing without entanglement

Simplified Modeling, Analysis and Simulation of Permanent Magnet Brushless Direct Current Motors for Sensorless Operation

MAC Calculus II Summer All you need to know on partial fractions and more

General Closed-form Analytical Expressions of Air-gap Inductances for Surfacemounted Permanent Magnet and Induction Machines

SOA/CAS MAY 2003 COURSE 1 EXAM SOLUTIONS

Average Rate Speed Scaling

EE 321 Project Spring 2018

Modelling and Simulation. Study Support. Zora Jančíková

( x vt) m (0.80)(3 10 m/s)( s) 1200 m m/s m/s m s 330 s c. 3.

An Adaptive Optimization Approach to Active Cancellation of Repeated Transient Vibration Disturbances

Counting Idempotent Relations

Sampler-A. Secondary Mathematics Assessment. Sampler 521-A

5.1 Composite Functions

Quantum Mechanics: Wheeler: Physics 6210

A model for measurement of the states in a coupled-dot qubit

Chapter 15 Equilibrium. Reversible Reactions & Equilibrium. Reversible Reactions & Equilibrium. Reversible Reactions & Equilibrium 2/3/2014

Fig Review of Granta-gravel

Relativistic Addition of Velocities *

arxiv:cond-mat/ v1 [cond-mat.str-el] 3 Aug 2006

Determination of the reaction order

An Integrated Architecture of Adaptive Neural Network Control for Dynamic Systems

Does P=NP? Karlen G. Gharibyan. SPIRIT OF SOFT LLC, 4-th lane 5 Vratsakan 45, 0051, Yerevan, Armenia

A Characterization of Wavelet Convergence in Sobolev Spaces

Modal Horn Logics Have Interpolation

Optimization of replica exchange molecular dynamics by fast mimicking

A new method of measuring similarity between two neutrosophic soft sets and its application in pattern recognition problems

A NONLILEAR CONTROLLER FOR SHIP AUTOPILOTS

FORMAL METHODS LECTURE VI BINARY DECISION DIAGRAMS (BDD S)

Advances in Radio Science

Mixed constraint satisfaction: a framework for decision problems under incomplete knowledge

Pushdown Specifications

Transcription:

State Diagrams Margaret M. Flek 14 November 2011 These notes over state diagrams. 1 Introdution State diagrams are a type of direted graph, in whih the graph nodes represent states and labels on the graph edges represent ations. For example, here is a state diagram representing the life yle of a hiken: grow hik hiken hath lay egg ook omelet The label on the edge from state A to state B indiates what ation happens as the system moves from state A to state B. In many appliations, all the transitions involve one basi type of ation, suh as reading a harater or going though a doorway. In that ase, the diagram might simply indiate the details of this ation. For example, the following diagram for a multiroom omputer game shows only the diretion of motion on eah edge. 1

dining rm west entry north east south east east hall study east barn ferry west west down down up ellar east Walks (and therefore paths and yles) in state diagrams must follow the arrow diretions. So, for example, there is no path from the ferry to the study. Seond, an ation an result in no hange of state, e.g. attempting to go east from the ellar. Finally, two different ations may get you to the same new state, e.g. going either west or north from the hall gets you to the dining room. Remember that the full speifiation of a walk in a graph ontains both a sequene of nodes and a sequene of edges. For state diagrams, these orrespond to a sequene of states and a sequene of ations. It s often important to inlude both sequenes, both to avoid ambiguity and beause the states and ations may be important to the end user. For example, for one walk from the hall to the barn, the full state and ation sequenes look like: states: hall dining room hall ellar barn ations: west south down up 2

2 Wolf-goat-abbage puzzle State diagrams are often used to model puzzles or games. For example, one famous puzzle involves a farmer taking a wolf, a goat, and a abbage to market. To do this, he must ross from the east to the west side of a river using a boat that an only arry him plus one of his three possessions. He annot leave the wolf and goat together unsupervised, nor the goat and the abbage, beause one will eat the other. We an represent eah state of this system by listing the objets that are on the east bank: w is the wolf, g is the goat, is the abbage, and b is the boat. States like w and wgb are legal, but wg would not be a legal state. The diagram of legal states then looks as follows: gb wgb w wb g gb w wgb In this diagram, ations aren t marked on the edges: you re left to infer the ation from the hange in state. The starting state (wgb) is marked by showing an error leading into it. The goal state ( ) where nothing is left on the east bank is marked with a double ring. In this diagram, it is possible for a (direted) walk to loop bak on itself, repeating states. So there are an infinite number of solutions to this puzzle. 3 Phone latties Another standard appliation for state diagrams is in modelling pronuniations of words for speeh reognition. In these diagrams, known as phone latties, eah edge represents the ation of reading a single sound (a phone) from the input speeh stream. To make our examples easy to read, we ll pretend that English is spelled phonetially, i.e. eah letter of English rep- 3

resents exatly one sound/phone. 1 For example, we ould model the set of words {hat, hop, hip} using the diagram: o 5 i 1 2 h 3 a 4 p t 7 6 As in the wolf-goat-abbage puzzle, we have a learly defined start state (state 1, marked with an inoming arrow) and some learly defined final states (6 and 7) marked with double rings. Another phone lattie might represent the set of words {at, ot, ab, ob}. a t 1 8 o 9 b 10 We an ombine these two phone latties into one large diagram, representing the union of these two sets of words: 1 o 5 i 2 h 3 a 4 a t 8 o 9 b 10 p t 7 6 Notie that there are two edges leading from state 1, both marked with the phone. This indiates that the user (e.g. a speeh understanding 1 This is, of ourse, totally wrong. But the essential ideas stay the same when you swith to a phoneti spelling of English. 4

program) has two options for how to handle a on the input stream. If this was inonvenient for our appliation, it ould be eliminated by merging states 2 and 8. Many state diagrams are passive representations of a set of possibilities. For example, a room layout for a omputer game merely shows what walkss are possible; the player makes the deisions about whih walk to take. Phone latties are often used in a more ative manner, as a very simple sort of omputer alled a finite automaton. The automaton reads an input sequene of haraters, following the edges in the phone lattie. At the end of the input, it reports whether it has or hasn t suessfully reahed a final state. 4 Representing funtions To understand how state diagrams might be represented mathematially and/or stored in a omputer, let s first look in more detail at how funtions are represented. A funtion f : A B assoiates eah input value from A with an output value from B. So we an represent f mathematially as a set of input/output pairs (x, y), where x omes from A and y omes from B. For example, one partiular funtion from {a, b, } to {1, 2, 3, 4} might be represented as {(a, 4), (b, 1), (, 4)} In a omputer, this information might be stored as a linked list of pairs. Eah pair might be a short list, or an objet or struture. However, finding a pair in suh a list requires time proportional to the length of the list. This an be very slow if the list is long i.e. if the domain of the funtion is large. Another option is to onvert input values to small integers. For example, in C, lowerase integer values (as in the set A above) an be onverted to small integers by subtrating 97 (the ASCII ode for a). We an then store the funtion s input/output pairs using an array. Eah array position represents an input value. Eah array ell ontains the orresponding output value. 5 Transition funtions Formally, we an define a state diagram to onsist of a set of states S, a set of ations A, and a transition funtion δ that maps out the edges of the graph, 5

i.e. shows how ations result in state hanges. Eah edge of the state diagram shows what happens when you are in a partiular state s and exeute some ation a, i.e. whih new state(s) ould you be in. So an input to δ is a pair (s, a) of a state and an ation. Some state/ation pairs lead to a single new state. But a state/ation pair doesn t always produe a new state, beause it might not be possible to exeute that ation from that state. (E.g. you an t go up from the study in our room layout example.) And, as we saw in the phone lattie example, it is sometimes onvenient to allow the user or the omputer system several hoies for the new state. To support these possibilities, eah output of δ will be a set of states. So we have δ : S A P(S). The hard part of implementing state diagrams in a omputer program is storing the transition funtion. We ould build a 2D array, whose ells represent all the pairs (s, a). Eah ell would then ontain a list of output states. This wouldn t be very effiient, however, beause state diagrams tend to be sparse: most state/ation pairs don t produe any new state. ne better approah is to build a 1D array of states. The ell for eah state ontains a list of ations possible from that state, together with the new states for eah ation. For example, in our final phone lattie, the entry for state 1 would be ((, (2, 8))) and the entry for state 3 would be ((o, (5)), (i, (5)), (a, (4))). This adjaeny list style of storage is muh more ompat, beause we are no longer wasting spae representing the large number of impossible ations. Another approah is to build a funtion, alled a hash funtion that maps eah state/ation pair to a small integer. We then alloate a 1D array with one position for eah state/ation pair. Eah array ell then ontains a list of new states for this state/ation pair. The details of hash funtions are beyond the sope of this lass. However, modern programming languages often inlude built-in hash table or ditionary objets that handle the details for you. 6 Shared states Suppose that eah word in our ditionary had its own phone lattie, and we then merge these individual latties to form latties representing sets of words. We might get a lattie like the following one, whih represents the set of words {op, ap, ops, aps}. 6

13 o 14 p 15 o p 9 10 11 s 12 1 a p 5 6 7 s 8 2 a 3 p 4 Although this lattie enodes the right set of words, it uses a lot more states than neessary. We an represent the same information using the following, muh more ompat, phone lattie. a p s 1 2 o 3 4 5 State merger is even more important when states are generated dynamially. For example, suppose that we are trying to find an optimal strategy for playing a game like ti-ta-toe. Blindly enumerating sequenes of moves might reate state diagrams suh as: Searhing through the same sequene of moves twie wastes time as well as spae. If we build an index of states we ve already generated, we an detet when we get to the same state a seond time. We an then use the results of our previous work, rather than repeating it. This trik, alled dynami programming, an signifiantly improve the running time of algorithms. 7

We an also use state diagrams to model what happens when omputer programs run. Consider the following piee of ode yli() y = 0 x = 0 while (y < 100) x = remainder(x+1,4) y = 2x We an represent the state of this mahine by giving the values of x and y. We an then draw its state diagram as shown below. By reognizing that we return to the same state after four iterations, we not only keep the diagram ompat but also apture the fat that the ode goes into an infinite loop. x=0,y=0 x=1,y=2 x=2,y=4 x=3,y=6 7 Counting states The size of state diagrams varies dramatially with the appliation. For example, the wolf-goat-abbage problem has only 2 4 = 16 possible states, beause we have two hoies for the position of eah of the four key objets (wolf, goat, abbage, boat). f these, six aren t legal beause they leave a 8

hungry animal next to its food with the boat on the other side of the river. For this appliation, we have no trouble onstruting the full state diagram. Many appliations, however, generate quite big state diagrams. For example, a urrent speeh understanding system might need to store tens of thousands of words and millions of short phrases. This amount of data an be paked into omputer memory only by using high-powered storage and ompression triks. Eventually, the number of states beomes large enough that it simply isn t possible to store them expliitly. For example, the board game Go is played on a 19 by 19 grid of positions. Eah position an be empty, filled with a blak stone, or filled with a white stone. So, to a first approximation, we have 3 361 possible game positions. Some of these are forbidden by the rules of the game, but not enough to make the size of the state spae tratable. Some games and theoretial models of omputation use an unbounded amount of memory, so that their state spae beomes infinite. For example, Conway s Game of Life runs on an 2D grid of ells, in whih eah ell has 8 neighbors. The game starts with an initial onfiguration, in whih some set of ells is marked as live, and the rest are marked as dead. At eah time step, the set of live ells is updated using the rules: A live ell stays live if it 2 or 3 neighbors. therwise it beomes dead. A dead ell with exatly 3 neighbors beomes live. For some initial onfigurations, the system goes into a stable state or osillates between several onfigurations. However, even if the initial set of live ells is finite, the set of live ells an grow without bound as time moves forwards. So, for some initial onfigurations, the system has infinitely many states. When a system has an intratably large number of states, whether finite or infinite, we obviously aren t going to build its state spae expliitly. Analysis of suh systems requires tehniques like omputing high-level properties of states, generating states in a smart way, and using heuristis to deide whether a state is likely to lead to a final solution. 8 Variation in notation State diagrams of various sorts, and onstruts very similar to state diagrams, are used in a wide range of appliations. Therefore, there are many different 9

sets of terminology for equivalent and/or subtly different variations on this idea. In partiular, when a state diagram is viewed as an ative devie, i.e. as a type of mahine or omputer, it is often alled a state transition or an automaton. 10