module #16 – finite state machines fall 20041 modeling computation rosen 5th ed., ch. 11 ref:...
TRANSCRIPT
![Page 1: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/1.jpg)
Fall 2004 1
Module #16 – Finite State Machines
Modeling Computation
Rosen 5th ed., ch. 11Ref: Wikipedia
![Page 2: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/2.jpg)
Fall 2004 2
Module #16 – Finite State MachinesFinite State Machines (FSM)
Model machines (or components in a computer) using a particular structureClassification FSM with no output: determine whether the
input is accepted (recognized) or not FSM with output: generate output from the
given input
Representations (p.752) State diagram State transition table
![Page 3: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/3.jpg)
Fall 2004 3
Module #16 – Finite State Machines
FSM with OutputDefinition: M = (S, I, O, f, g, s0) S: finite set of states I, O: input/output alphabets f: transition function, f: S I S g: output function s0: initial state
Mealy machine: g: SI OMoore machine:g: S OMealy machine: g: SI OMoore machine:g: S O
![Page 4: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/4.jpg)
Fall 2004 4
Module #16 – Finite State Machines
Simple Example (p.753)
![Page 5: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/5.jpg)
Fall 2004 5
Module #16 – Finite State Machines
Generating Output
Input string: x = x1x2…xk
s1 = f(s0, x1), s2 = f(s1, x2), …, sk = f(sk-1, xk) These state transition produces output y = y1y2…yk
y1 = g(s0, x1), y2 = g(s1, x2), …, yk = g(sk-1, xk)
![Page 6: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/6.jpg)
Fall 2004 6
Module #16 – Finite State Machines
Another Example
start
Input: 101011Output: 001000
![Page 7: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/7.jpg)
Fall 2004 7
Module #16 – Finite State Machines
Ex: vending machines
[description]State table
![Page 8: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/8.jpg)
Fall 2004 8
Module #16 – Finite State MachinesVending Machine: state diagram
![Page 9: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/9.jpg)
Fall 2004 9
Module #16 – Finite State Machines
Ex: Unit Delay Machine
Input: x1x2…xk; Output: 0x1x2…xk-1
state
f g
0 1 0 1
s0 s2 s1 0 0s1 s2 s1 1 1s2 s2 s1 0 0
Example & how the machine is designed (p.755)
![Page 10: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/10.jpg)
Fall 2004 10
Module #16 – Finite State Machines
Ex: FSM for Addition
Design: s0: to remember
that the previous carry is 0
s1: to remember that the previous carry is 1
[example]
![Page 11: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/11.jpg)
Fall 2004 11
Module #16 – Finite State Machines
FSM with No Output
Language recognition; design and implementation of compilers A string is recognized IFF it takes the
starting state to one of the final states
Def: Finite-state Automata: do not produce output, but have a set of final states
![Page 12: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/12.jpg)
Fall 2004 12
Module #16 – Finite State MachinesEx: automaton to recognize “nice”
![Page 13: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/13.jpg)
Fall 2004 13
Module #16 – Finite State Machines
Finite-State Automata
M = (S, I, f, s0, F) S: finite set of states I: input alphabets f: transition function, f: S I S s0: initial state F: final states, subset of S (indicated
by double circlesdouble circles)
![Page 14: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/14.jpg)
Fall 2004 14
Module #16 – Finite State MachinesExample: construct the state diagram
![Page 15: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/15.jpg)
Fall 2004 15
Module #16 – Finite State Machines
Recognizing Language
A string x is said to be recognized by the machine M = (S, I, f, s0, F) if f(s0, x) is a state in F
The language recognized (accepted) by the machine M, denoted by L(M), is the set of all strings accepted by M.
![Page 16: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/16.jpg)
Fall 2004 16
Module #16 – Finite State Machines
Example
The following example is of a DFA M, with a binary alphabet, which determines if the input contains an even number of 0s
Deterministic finite
automaton
Start
![Page 17: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/17.jpg)
Fall 2004 17
Module #16 – Finite State MachinesTransformations from/to State Diagram
It is possible to draw a state diagram from the table. Draw the circles to represent the states given. For each of the states, scan across the corresponding row and draw an arrow to the destination state(s). There can be multiple arrows for an input character if the automaton is an NFA. Designate a state as the start state. The start state is given in the formal definition of the automaton. Designate one or more states as accept state. This is also given in the formal definition.
![Page 18: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/18.jpg)
Fall 2004 18
Module #16 – Finite State Machines
Example
L(M1) = {1n | n = 0,1,2,…}
![Page 19: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/19.jpg)
Fall 2004 19
Module #16 – Finite State Machines
Example (cont)
L(M2) = {1, 01}
![Page 20: Module #16 – Finite State Machines Fall 20041 Modeling Computation Rosen 5th ed., ch. 11 Ref: WikipediaWikipedia](https://reader036.vdocuments.us/reader036/viewer/2022062516/56649e225503460f94b0ff6c/html5/thumbnails/20.jpg)
Fall 2004 20
Module #16 – Finite State Machines
Example (cont)
L(M3) = {0n,0n10x | n = 0,1,2,…, x is any string}