Presentation is loading. Please wait.

Presentation is loading. Please wait.

§12.2 – Finite State Machines with Output. Giving credit where credit is due: Most slides based on lecture notes created byMost slides based on lecture.

Similar presentations


Presentation on theme: "§12.2 – Finite State Machines with Output. Giving credit where credit is due: Most slides based on lecture notes created byMost slides based on lecture."— Presentation transcript:

1 §12.2 – Finite State Machines with Output

2 Giving credit where credit is due: Most slides based on lecture notes created byMost slides based on lecture notes created by –Michael P. Frank, University of Florida –Longin Jan Latecki, Temple University –Carla Gomes, Cornell University

3 Remember the general picture of a computer as being a transition function T:S×I→S×O?Remember the general picture of a computer as being a transition function T:S×I→S×O? –If the state set S is finite (not infinite), we call this system a finite state machine. If the domain S×I is reasonably small, then we can specify T explicitly by writing out its complete graph.If the domain S×I is reasonably small, then we can specify T explicitly by writing out its complete graph. –However, this is practical only for machines that have a very small information capacity. Modeling Computation

4 Applications Finite-State Machines are used in a variety of applications.Finite-State Machines are used in a variety of applications. –Spell checking programs –Grammar checking –Indexing and searching large text files –Speech/Language recognition –Network Protocols

5 Types of Finite-State Machines Finite-State Machines with OutputFinite-State Machines with Output –Mealy: Output determined by state and input –Moore: Output determined by state alone Finite-State Machines with No OutputFinite-State Machines with No Output –Also known as finite-state automata –There are two types of finite-state automata Deterministic: Each state-input pair dictates a unique transition into another stateDeterministic: Each state-input pair dictates a unique transition into another state Non-deterministic: Each state-input pair can lead to several possible statesNon-deterministic: Each state-input pair can lead to several possible states

6 Vending Machine Example Suppose a certain vending machine accepts nickels, dimes, and quarters.Suppose a certain vending machine accepts nickels, dimes, and quarters. –If >30¢ is deposited, change is immediately returned. If the “ coke ” button is pressed, the machine drops a coke.If the “ coke ” button is pressed, the machine drops a coke. –It can then accept a new payment. Ignore any other buttons, bills, out of change, etc.

7 Modeling the Machine Input symbol set: I = {nickel, dime, quarter, button}Input symbol set: I = {nickel, dime, quarter, button} –We could add “ nothing ” or  as an additional input symbol if we want. Representing “ no input at a given time. ”Representing “ no input at a given time. ” Output symbol set: O = { , 5¢, 10¢, 15¢, 20¢, 25¢, coke}.Output symbol set: O = { , 5¢, 10¢, 15¢, 20¢, 25¢, coke}. State set: S = {0, 5, 10, 15, 20, 25, 30}.State set: S = {0, 5, 10, 15, 20, 25, 30}. –Representing how much money has been taken.

8 Transition Function Table Old state Input New state Output 0n5 0d10 0q25 0b0 5n10 5d15 5q30 5b5 Old state Input New state Output10n15 10d20 10q30 5¢5¢5¢5¢ 10b10 15n20 15d25 15q30 10¢ 15b15

9 Transition Function Table cont. Old state Input New state Output 20n25 20d30 20q30 15¢ 20b20 25n30 25d305¢ 25q3020¢ 25b25 Old state Input New state Output30n30 5¢5¢5¢5¢ 30d30 10¢ 30q30 25¢ 30b0coke

10 Another Format: State Table Old state Input Symbol ndqb 0 5,  10,  25,  0,  5 10,  15,  30,  5,  10 15,  20,  30,5¢ 10,  15 20,  25,  30,10¢ 15,  20 25,  30,  30,15¢ 20,  25 30,  30,5¢ 30,20¢ 25,  30 30,5¢ 30,10¢ 30,25¢ 0,coke Each pair shows new state, output symbol

11 Directed-Graph State Diagram As you can see, these can get kind of busy.As you can see, these can get kind of busy. 051015202530 q,5¢ nnn d q d q bbbbbb n nn q,25¢ d,10¢ n,5¢ d d,5¢ q,20¢ q,15¢ q,10¢ b,coke

12 Formalizing FSMs Just like the general transition-function definition from earlier, but with the output function separated from the transition function, and with the various sets added in, along with an initial state.Just like the general transition-function definition from earlier, but with the output function separated from the transition function, and with the various sets added in, along with an initial state. A finite-state machine M=(S, I, O, f, g, s 0 )A finite-state machine M=(S, I, O, f, g, s 0 ) –S is the state set. –I is the alphabet (vocabulary) of input symbols –O is the alphabet (vocabulary) of output symbols –f is the state transition function –g is the output function –s 0 is the initial state. Our transition function from before is T = (f,g).Our transition function from before is T = (f,g).

13 Examples


Download ppt "§12.2 – Finite State Machines with Output. Giving credit where credit is due: Most slides based on lecture notes created byMost slides based on lecture."

Similar presentations


Ads by Google