This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: ECS 120 Lesson 3 – Finite State Machines, Pt. 2 Oliver Kreylos Wednesday, April 4th, 2001 1 Formal Definition of Finite State Machines As can be seen from the first two examples of Finite State Machines, we have to specify several parts when trying to give a formal definition of one: • How many and which states does the automaton have? • What characters can the automaton read? • How does the automaton move from state to state? • Which state does the automaton start in? • Which states are final states? These five questions lead directly to the formal definition: A Finite State Machine M is a 5tuple M = ( Q, Σ , δ, q , F ), where • Q is a finite set of states . • Σ is the input alphabet . • δ : Q × Σ → Q is the transition function . • q ∈ Q is the initial state . • F ⊂ Q is the set of final states or accepting states . 1 As an example, here is the formal definition for the pushbutton automaton shown last lecture: PB = { On , Off } , { PUSH } , { (On , PUSH ) 7→ Off , (Off , PUSH ) 7→ On } , Off , { On } The transfer functions of more complicated automata are usually given in tabular form. Here is the formal definition for the doorlock automaton shown last time. For brevity, let us denote the states “idle,” “3 seen,” “31 seen,” “314 seen,” “3141 seen” and “wrong key” by q , q 1 , q 2 , q 3 , q 4 and q 5 , respec tively: DL = { q , q 1 , q 2 , q 3 , q 4 , q 5 } , { , 1 , . . . , 9 } , δ, q , { q 4 } where δ = 1 2 3 4 5 6 7 8 9 q q 5 q 5 q 5 q 1 q 5 q 5 q 5 q 5 q 5 q 5 q 1 q 5 q 2 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 2 q 5 q 5 q 5 q 5 q 3 q 5 q 5 q 5 q 5 q 5 q 3 q 5 q 4 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 4 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 q 5 As another example, let us consider an automaton that reads an integer in binary notation (as a word over the alphabet { , 1 } ) and has to decide whether that integer is divisible by three. In other words, we consider an automaton D3 that accepts the language L (D3) = w ∈ { , 1 } * The integer represented by w is divisible by 3 . Figure 1 shows the automaton as a state diagram. Here is the formal description of the automaton: D3 = { q , q 1 , q 2 } , { , 1 } , δ, q , { q } where δ = 1 q q q 1 q 1 q 2 q q 2 q 1 q 2 How did we come up with this automaton? First, we have to look at the problem from an automaton’s point of view. As programmers, we tendthe problem from an automaton’s point of view....
View
Full Document
 Spring '07
 Filkov
 Division, Remainder, Natural number

Click to edit the document details