finite state machines
play

Finite State Machines Murray Cole Finite State Machines 1 - PowerPoint PPT Presentation

I V N E U R S E I H T Y T O H F G R E U D I B N Finite State Machines Murray Cole Finite State Machines 1 Embedded Systems Already 10s of processor chips per person in the world There will


  1. I V N E U R S E I H T Y T O H F G R E U D I B N Finite State Machines Murray Cole Finite State Machines

  2. � � � � 1 Embedded Systems Already 10’s of processor chips per person in the world There will “soon” be 100’s or 1000’s Most of these are not in “computers” but are embedded in everyday real world systems (cars, TVs, vending machines, watches, (people?!)) These often implement quite simple reactive systems Finite State Machines

  3. � � � 2 Reactive Systems Wait to receive an input Respond with an output Response may depend upon finite history ( i.e. not just the most recent input) Finite State Machines

  4. � � � � 3 Finite State Machines (Automata) A conceptual tool for modelling reactive systems Pre-date “Computer Science” Force us to make precise definitions (unlike natural language) Can then implement in hardware or software or both Finite State Machines

  5. � � � � ✁ � ✂ 4 FSM - Formal Definition An input alphabet, (“sigma”), which is a set of symbols, one for each distinct possible input ( e.g. buttons, coin slots, ...) An output alphabet, (“lambda”), which is another set of symbols, one for each distinct possible output ( e.g. lights, can dispensed, ...) Some named states, each capturing some state of the system ( e.g. “coin inserted but no can dispensed”), drawn as circles, one indicated as the start state with an arrow A collection of transitions, each an arrow between two states, labelled with the input which activates it and the output which results (or (“epsilon”) indicating no input or output respectively) Finite State Machines

  6. ✠ � ✂ � � ✠ ✡ ✁ � ✁ � � � 5 An FSM for a Simple Ticket Machine m/ m/ 1 2 t/p r/d t/ r/ for insert money, request ticket, request refund ✁✄✂ ☎✝✆ ☎✟✞ for print ticket, deliver refund ☎✝☛ for convenience, label the same arrow with several i/o pairs for convenience, just write as a blank Finite State Machines

  7. ✆ ✍ ✁ ✂ � ✍ ✞ ✁ ✍ ☞ ✆ ☎ ✄ ✝ ✁ ✍ ☎ ✁ ✍ ✍ ✄ � ✍ ✁ ✍ ☞ ☛ ✁ ☎ ✠ � ✁ ✂ ✆ ✆ ☎ ✁ ☛ ✠ ✆ ✁ ✄ ☛ ✆ ☎ 6 FSM Traces For some FSM called , a trace describes one possible sequence of activities and is 1. A finite sequence of alternating states and transition labels starting and ending with a state: . ☎ ✡✠ ☛✌☞ ✝✟✞ ☎ ☎✄ ✝✟✞ 2. The first state, , is the start state of . 3. For each state, label, state sequence appearing in the ✝✟✞ sequence, there must be a transition in from state to labelled . Finite State Machines

  8. ☎ ☎ ☎ � ☎ ✁ ☎ � ☎ � ☎ ☎ ✁ ☎ ☎ ☎ � ☎ � ☎ 7 m/ m/ 1 2 t/p r/d t/ r/ For the ticket machine m/ m/ m/ r/d ☎ ✂✁ ☎ ✂✁ is a trace, but m/ m/ m/ r/d ☎ ✂✁ isn’t. The overall behaviour of a FSM is the set of all its possible traces. Finite State Machines

  9. � ✂ � 8 Acceptors Acceptors are FSMs with empty output alphabet (all outputs are ) some states marked as “accepting” (double circle) Input sequence is accepted if it can generate a trace from the start state to an accepting state. The language accepted by an (acceptor) FSM is the set of all input sequences which it accepts. Finite State Machines

  10. 9 Acceptors 0 0 A B C 1 1 0 1 D 1,0 Accepts strings of 0 s and 1 s in which the number of 0 s so far never exceeds the number of 1 s so far by more than one and vice versa Finite State Machines

  11. � � � � 10 Determinism FSMs in which for every state, there is at most one transition leaving the state for each input symbol are called determinstic. Other FSMs are called non-deterministic Sometimes easier to define non-deterministic FSMs Can always convert a non-deterministic FSM into an equivalent deterministic FSM Finite State Machines

  12. � � � 11 What FSMs can’t do FSM states do not have any memory inside The FSM “remembers” simply being in a given state, so that “Have seen three 0’s” and “Have seen four 0’s” must be two different states, not one state with a counter variable inside Consequently, FSMs can’t “count” arbitrarily large histories – accept all strings including 287 0 ’s - possible – accept all strings with equal numbers of 0 ’s and 1 ’s - not possible Finite State Machines

  13. � � � � � � 12 Summary Embedded and reactive systems Finite State Machines to model these FSM traces Acceptors and Transducers Determinism Limits to FSM power Finite State Machines

Recommend


More recommend