4 Pages

lec2

Course: CS 322, Fall 2009
School: Washington
Rating:
 
 
 
 
 

Word Count: 2851

Document Preview

322 CSE - Introduction to Formal Methods in Computer Science Formal Definition of a Deterministic Finite Automata Dave Bacon Department of Computer Science & Engineering, University of Washington I. EXAMPLE FROM MY YOUTH AND MY OLD AGE Back in the old days, you know, before the Earth cooled, there were these games which we used to play called Text Adventure games. In these games, you would be confronted...

Register Now

Unformatted Document Excerpt

Coursehero >> Washington >> Washington >> CS 322

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
322 CSE - Introduction to Formal Methods in Computer Science Formal Definition of a Deterministic Finite Automata Dave Bacon Department of Computer Science & Engineering, University of Washington I. EXAMPLE FROM MY YOUTH AND MY OLD AGE Back in the old days, you know, before the Earth cooled, there were these games which we used to play called Text Adventure games. In these games, you would be confronted with a text prompt and could type in command like "GO NORTH" and the computer would reply "YOU CAN'T GO NORTH BECAUSE THERE IS A WALL THERE." So you might type "GO SOUTH" and the computer would reply "YOU ENTER A DARK DUNGEON WHERE PRISONERS HAVE RECENTLY BEEN TORTURED. THERE IS A KEY ON THE GROUND." So then you might type "GET KEY" and the computer would tell you "YOU PICKUP THE KEY, BUT DISCOVER TOO LATE THAT THE KEY IS ATTACHED TO A STRING WHICH PULLS A LEVER AND RELEASES A BOULDER WHICH SMASHES YOU FLAT. YOU ARE DEAD. PLAY AGAIN Y/N?" Now you make think that such a silly game would not suck you in and make you addicted to it, but I can tell you quite personally, that this is not true and these games can suck away large portions of your life. N,S,W,E N,E QQQ Fremont Troll o QQQ y QQQ QQQ QQQ N,S,W N QQQ Q@ E G Queen Anne Ave o Villa Sophia o iRRR W y RRR RRR N S RRR W R Space Needle o y N S G o UW Northlake Pizza W W W y rrV r E rrr r r rr N S N S rrr r rr rrr r S xrr E E G G o Capital Hill Lake Union W W y mmT m E mmm m mm mmm m N S mm mS m mm m mmm mm E vmmm G llS REI W lll ll l Ellll ll l l ll lll ll l lll ll S ll ul Gas Works Park o y N N E G E Pike's Place Market W,S FIG. 1: Adventure: Seattle version. Ah, the good old days of texted based adventure games. Long live Zork! Now for simple versions of these games you would often make up a little map of the dungeon or world you were exploring. The simplest such map might be a diagram like the one if Figure 1. This is for the game called "Get Dave to UW in the Morning" (alpha version.) The goal of this game, as the name implies, is to get from Dave's home "Villa Sophia" to that mysterious mystical place of higher education, "UW." Of course there are dreadful dangers in this trip. For example, if Dave encounters the "Fremont Troll" he gets stuck there staring at the tourists passing by and now matter what you do you cannot get Dave away from the troll! Now we all know, informally, how to use the map in Figure 1. If we are at a given node, then depending on what we type into the computer, it will tell us where to go next: simply follow the arrow. Thus if we are at "Villa Sophia" and type N we go to the "Fremont Troll" (oh noes!) For any sequence of inputs to the computer, like for instance, ESSN, along with knowing where we currently are, we will can figure out where this will take us. For example if we input ESSN from the location "Gas Works," we follow the path "Gas Works""Northlake Pizza""Capital Hill""REI""Lake Union." Notice that we have listed the string we input ESSN from left to right in the order in which we input this string. Thus this means follow E first, then S, then S, and finally N . Finally note that on this map we have two special things appearing. One is an arrow coming from no-where. This is an arrow to indicate for our game where we are to begin the game. And finally we note that "UW" is enclosed in a double frame. This is to indicate that if we reach "UW" we win (yipee!) 2 Let's now get a little form about this game and begin by introducing the notions of alphabets and strings. Notice that the inputs you can enter into this game are drawn only from the set {N, E, W, S}. This set is the alphabet for our game. We often denote alphabets by the symbol , so in this case we would say our alphabet is = {N, E, W, S}. What can you do with an alphabet? Well write strings, of course! A string from an alphabet is a deterministic finite sequence of symbols from that alphabet. Thus for instance N N EEW W SS is a string from our . Given a string w, we denote the length of this string by |w|. Thus |N N EEW W SS| = 8. The empty string, i.e. the string made up of no elements of the alphabet, is denoted by . If w is of length n we write w = w1 w2 w3 . . . wn , where wi . String z is a substring of w if z appears consecutively within w. Thus EW is a substring of N N EEW W SS, but EW S is not a substring. Another concept which will be important for us will be the concatenation of two strings. The concatenation of x and y, written xy is the string by appending y on to the end of x. In other words if x = x1 x2 . . . xm and y = y1 y2 . . . yn , then xy = x1 x2 . . . xm y1 y2 . . . yn and is a string of length n + m. A final concept which we will need is that of a language. A language, simply, is a set of strings. Thus a language over our alphabet might be {N ES, SN ES} (that's the Nintendo language folks.) So now we have described the possible inputs which we feed into the "Get Dave to UW in the Morning" game, we can move on to the reason for introducing this game. In particular the reason we have introduced this game is that this game can be played by a very simple controller which instantiates a deterministic finite automaton. The controller for this game, as we can guess from the above diagram only needs to keep a few bits in memory to store where you are on the map. In particular since there are 11 locations in the above map, we can use 4 bits (24 = 16 which is greater than 11) to store the location. The control thus keeps your current location in these four bits of memory, and then, depending on your next input, an element from the alphabet = {N, E, W, S}, possibly changes these four bits to indicate your new location. Thus the controller is an example of a deterministic finite automaton, a machine with a limited memory, that can make transitions dependent on input and the current state of the limited memory. Okay, so now lets talk a little bit about the map we've drawn above. This map is an example of a state diagram for a deterministic finite automaton (for now ignore that "determnistic" qualifier.) A state diagram is roughly defined as follows. It is a direct graph, a digraph (thus edges have directions.) Each of the nodes is labeled. These labels are called the states of the deterministic finite automaton. For our map game, the state is the location we are currently at. Further each directed edge, which are called transitions, is labeled. These labels are taken from an element of some alphabet. In our case the edges are labeled by an element of the set = {N, E, W, S}. Further a state diagram has a special state, called the start state, which is indicated by having a directed edge pointing at in it from nowhere. Finally, a state diagram has accept states. These are denoted by doubling the frame of the box (or circle) for the state. For example, the "UW" state is an accept state in our above map. So given a state diagram, we can now see how it can represent the action of a simple machine, a deterministic finite automaton, which processes some input and produces and output. The input is a string, like say, EEN E, and the output is either accept or reject. (For now we will work with just this simple binary output: generalizations are, of course possible.) The automaton receives input from the string right to left one at a time. Being in a particular state, the deterministic finite automaton transitions along the edge labeled by the next input being received. If, after processing the entire string, the automaton is in a state which is an accept state, then we say that the automaton accepts this string. If, after processing the entire string, the automaton is in a state which is not an accept state, then we say the automaton rejects string. this Just to be pedantic, lets work a simple example for the state diagram in Figure 1. Suppose that the input to the deterministic finite automaton represented by this state diagram is EEN E. The automaton then proceeds as follows. 1. The start state is denoted by the state with an arrow coming from nowhere. In this case the start state is "Villa Sophia." 2. Read E, follow the transition from "Villa Sophia" to "Lake Union." 3. Read E, follow the transition from "Lake Union" to "Capital Hill." 4. Read N , follow the transition from "Capital Hill" to "Northlake Pizza." (mmm) 5. Read E, follow the transition from "Northlake Pizza" to "UW." 6. Accept because "UW" is an an accept state and we are at the end of the computation. Finally you can see that for the above state diagram, for any string, the deterministic finite automaton will make transitions among states and end up in either an accept or reject state. We can then consider the set of strings for which the above machine ends up in the accept state of the deterministic finite automaton. We will call this the language of this particular deterministic finite automaton. 3 II. FORMAL DEFINITION OF A DETERMINISTIC FINITE AUTOMATON State diagrams are easy to grasp intuitively, but this is a theory course, so we want to be more precise and give a formal definition of a deterministic finite automaton. This will remove any ambiguity we might have about deterministic finite automata and, even better, provide a nice clean language for talking about deterministic finite automata. A good notation will help clarify your thinking and lead you to much much less frustrated in life (believe me.) (On the other hand, rigor to the point of mortis is a trap you should also avoid falling into.) The formal definition of a deterministic finite automaton has five parts. These five parts are the states, the alphabet, a transition function, the start state and the set of accept states. Why don't we just dive in and give the definition A deterministic finite automaton is a 5-tuple (Q, , , q0 , F ), where 1. Q is a deterministic finite set called the states. 2. is a deterministic finite set called the alphabet. 3. is a function from Q to Q, called a transition function. 4. q0 Q is the start state 5. F Q is the set of accept states. Everything in this formal definition should make sense to you, with the possible exception, of the transition function. First of all you need to recall what the Cartesian product of two sets is. If S1 and S2 are deterministic finite sets then the Cartesian product of these two sets, denoted S1 S2 is the set of all pairs where the first element is from S1 and the second element is from S2 . I.e. S1 S2 = {(x, y)|x S1 , y S2 }. For example if S1 = {A, B} and S2 = {0, 1, 2}, then S1 S2 = {(A, 0), (A, 1), (A, 2), (B, 0), (B, 1), (B, 2)}. Back to that transition function. As you can read from the definition the transition function is a function from Q to Q. In other words it is a function which takes two inputs, the first from Q and the second from and which outputs an element of Q. Given the formal definition of a deterministic finite automaton, we already sort of know, from our intuitive picture, what each of the things in the definition is, with, again, perhaps, the transition function. The transition function encapsulates the transitions arrows in the state diagram. In particular we recall that a transition was a directed labeled edge, with the label being an element of the alphabet, . In other words, given a node in the state diagram, i.e. a state, and an element of the alphabet , a transition will give you a new state, which is the state and end of the appropriate transition edge for the given state. Thus, for example, if we look back at Figure 1, we will find that for the transition function for this deterministic finite automaton, ("Villa Sophia , N ) = "Fremont Troll . The formal definition of a deterministic finite automaton puts to rest a few questions which you might have had about deterministic finite automata. For example, you might wonder if it is allowed to have a deterministic finite automaton which has no accept states. We see from the above definition, this is possible, because we could set F = . You might also wonder if for every state, there must be at least one transition for every element of the alphabet. Indeed this is true because we have specified that is a function defined for every state and alphabet element. A. Some simple examples of deterministic finite automaton to cut your teeth on Okay lets give some simple deterministic finite automata to cut our teeth on. Consider the deterministic f...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Regular Operations on LanguagesDave BaconDepartment of Computer Science & Engineering, University of WashingtonI.A QUESTIONNow that we have defined deterministic finite automata, we
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Nondeterministic Finite AutomataDave BaconDepartment of Computer Science & Engineering, University of WashingtonToday we are going to talk about nondeterministic finite automata. Our mo
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Equivalence of DFAs and NFAsDave BaconDepartment of Computer Science & Engineering, University of WashingtonLast time we defined nondeterministic finite automata. Our motivation for doi
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Regular ExpressionsDave BaconDepartment of Computer Science & Engineering, University of WashingtonHaving just put behind us our first major theoretical result, that the class of langua
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Converting DFAs to Regular ExpressionsDave BaconDepartment of Computer Science & Engineering, University of WashingtonLast time we saw how, given a regular expression, we could take thi
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science The Pumping Lemma for Regular LanguagesDave BaconDepartment of Computer Science & Engineering, University of WashingtonSo far we have talked about regular languages and showed that they
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science String MatchingDave BaconDepartment of Computer Science & Engineering, University of WashingtonSuppose that you are given a short pattern and a long text and you wish to determine if th
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science The Myhill-Nerode TheoremDave BaconDepartment of Computer Science & Engineering, University of WashingtonThe pumping lemma for regular languages is nice, but it has one fatal drawback,
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Minimizing DFAsDave BaconDepartment of Computer Science & Engineering, University of WashingtonLast time we discussed the Myhill-Nerode theorem: Myhill-Nerode Theorem A is regular if an
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Introduction to Context-Free GrammarsDave BaconDepartment of Computer Science & Engineering, University of WashingtonIn the last few lectures we finished up talking about regular langua
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Chomsky Normal FormDave BaconDepartment of Computer Science & Engineering, University of WashingtonA useful form for dealing with context free grammars is the Chomksy normal form. This
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Pushdown AutomataDave BaconDepartment of Computer Science & Engineering, University of WashingtonOkay now that we've talked a little about context free grammars, a natural question to a
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Pushdown Automata And Context-Free LanguagesDave BaconDepartment of Computer Science & Engineering, University of WashingtonHaving introduced pushdown automata, we will now show that pu
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Closure Properties of Context-Free LanguagesDave BaconDepartment of Computer Science & Engineering, University of WashingtonPreviously we showed how regular operations were closed under
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science Turing MachinesDave BaconDepartment of Computer Science & Engineering, University of WashingtonToday we finally make it up to.computers! Well at least to the model which best captures w
Washington - CS - 322
CSE 322 - Introduction to Formal Methods in Computer Science DecidabilityDave BaconDepartment of Computer Science & Engineering, University of WashingtonIn the last lecture we introduced the Turing machine. We talked about how it worked, and show
Washington - CS - 322
CSE 322: Formal Models in Computer ScienceMidterm TopicsThe midterm will be Friday, May 9th in class. It will be 50 minutes in length and will be closed book. The midterm will cover everything covered in class up to and including the first half o
Washington - CS - 322
CSE 322: Formal Models in Computer ScienceFinal TopicsThe nal will be Monday, June 9 from 2:30-4:20 in EEB 045. It will be 110 minutes in length and will be closed book. It will cover everything in the class with slightly more coming from the mat
Washington - CS - 322
CSE322: Formal Models in Computer Science Partial Solutions to Sample FinalSpring 2006This handout has (partial) solutions to some of the problems in the sample final exam that was handed out in class on Friday, May 26. I have not given solutions
Washington - CS - 322
1 CSE 322: Formal Models in Computer Science April 2, 2008 HandoutN,S,W,ENNN,EQQQ Fremont Troll o QQQ y QQQ QQQ QQQ N,S,W N QQQ Q@ E G Queen Anne Ave o Villa Sophia o W iRRR y RRR RRR N S RRR W R Space Needle o yNWGas Works Park o
Washington - CS - 322
CSE 322 Introduction to Formal Models in Computer ScienceDefining from In the definition of DFAs, the transition function explicitly describes, for each character a , the name of the state reached on a when started at state q. This is precisely
Washington - CS - 322
Washington - CS - 322
CSE 322: Formal Models in Computer Science Website: http:/www.cs.washington.edu/322 Lecture Times: MWF 1:30-2:30 in EE 045 (in the dungeon of EE.) Instructor: Dave Bacon Office: CSE 460 Email: dabacon@cs.washington.edu Phone: 206-221-6503 Office hour
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Winter 2005 Course InformationInstructor: TAs:Anna R. Karlin Neva Cherniavsky Ning ChenPGA 594 PGA 378 PGA 310karlin@cs.washington.edu nchernia@cs.washington.edu ning@cs.washington.edu543-9344 685-
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #0 January 3, 2005 Due: Wednesday, January 5Reading Assignment: Kleinberg and Tardos, Chapters 1 and 4 Questions: 1. For each of the following topics, indicate your level of comfort on a scale o
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #1 January 5, 2005 Due: Wednesday, January 12Reading Assignment: Kleinberg and Tardos, Chapters 1 and 4 Problems:1. Gale and Shapley published their paper on the stable marriage problem in 196
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #2 January 12, 2005 Due: Wednesday, January 19 Reading Assignment: K&T, Section 5.1, 5.2, 5.4, 5.6, 5.7, 5.9 Questions: 1. (Kleinberg and Tardos, Chapter 4, Problem 5) Let's consider a long, quiet
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #4 January 27, 2005 Due: Wednesday, February 2Reading Assignment: Kleinberg and Tardos, Network Flow, handout on linear programming, section 11.6 in new book. Problems:1. Let G = (V, E) be a g
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #5 February 2, 2005 Due: Wednesday, February 9Reading Assignment: Kleinberg and Tardos, Network Flow, handout on linear programming Problems: 1. Your friends have written a very fast piece of ma
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #6 Due: Wednesday, February 16Reading Assignment: Linear programming handouts, chapter on randomized algorithms, other randomized algorithms handouts (we'll send out mail about them.) Problems:
Washington - CS - 521
CSE 521: Design and Analysis of Algorithms Assignment #7 Due: Wednesday, Feb 23Problems:1. QuickSelect is the following simple algorithm for finding the k-th smallest element in an unsorted set S. QuickSelect(S, k): (a) Pick a pivot element p uni