Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rosen 5th ed., ch. 11 Ref: Wikipedia

Similar presentations


Presentation on theme: "Rosen 5th ed., ch. 11 Ref: Wikipedia"— Presentation transcript:

1 Rosen 5th ed., ch. 11 Ref: Wikipedia
Modeling Computation Rosen 5th ed., ch. 11 Ref: Wikipedia Fall 2004

2 Finite State Machines (FSM)
Model machines (or components in a computer) using a particular structure Classification 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 Fall 2004

3 FSM with Output Definition: 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: SI O Moore machine:g: S O Fall 2004

4 Simple Example (p.753) Fall 2004

5 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) Fall 2004

6 Another Example start Input: Output: Fall 2004

7 Ex: vending machines [description] State table Fall 2004

8 Vending Machine: state diagram
Fall 2004

9 Ex: Unit Delay Machine Input: x1x2…xk; Output: 0x1x2…xk-1 f g 1 s0 s2
state f g 1 s0 s2 s1 Example & how the machine is designed (p.755) Fall 2004

10 Ex: FSM for Addition Design: [example]
s0: to remember that the previous carry is 0 s1: to remember that the previous carry is 1 [example] Fall 2004

11 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 Fall 2004

12 Ex: automaton to recognize “nice”
Fall 2004

13 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 circles) Fall 2004

14 Example: construct the state diagram
Fall 2004

15 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. Fall 2004

16 Deterministic finite automaton
Example Deterministic finite automaton The following example is of a DFA M, with a binary alphabet, which determines if the input contains an even number of 0s Start Fall 2004

17 Transformations 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. Fall 2004

18 Example L(M1) = {1n | n = 0,1,2,…} Fall 2004

19 Example (cont) L(M2) = {1, 01} Fall 2004

20 Example (cont) L(M3) = {0n,0n10x | n = 0,1,2,…, x is any string}
Fall 2004


Download ppt "Rosen 5th ed., ch. 11 Ref: Wikipedia"

Similar presentations


Ads by Google