Download Finite Automata: Understanding States and Transitions and more Slides Theory of Automata in PDF only on Docsity! 1 Finite Automata Motivation An Example Docsity.com 2 Informal Explanation ļµFinite automata are finite collections of states with transition rules that take you from one state to another. ļµOriginal application was sequential switching circuits, where the āstateā was the settings of internal bits. ļµToday, several kinds of software can be modeled by FA. Docsity.com 5 Automata to Code ļµ In C/C++, make a piece of code for each state. This code: 1. Reads the next input. 2. Decides on the next state. 3. Jumps to the beginning of the code for that state. Docsity.com 6 Example: Automata to Code 2: /* i seen */ c = getNextInput(); if (c == ānā) goto 3; else if (c == āiā) goto 2; else goto 1; 3: /* āinā seen */ . . . Docsity.com 7 Automata to Code ā Thoughts ļµHow would you do this in Java, which has no goto? ļµYou donāt really write code like this. ļµRather, a code generator takes a āregular expressionā describing the pattern(s) you are looking for. ļ· Example: .*ing works in grep. Docsity.com 10 Strange Planet ā (2) ļµObservation: the number of individuals never changes. ļµThe planet fails if at some point all individuals are of the same species. ļ· Then, no more breeding can take place. ļµState = sequence of three integers ā the numbers of individuals of species a, b, and c. Docsity.com 11 Strange Planet ā Questions ļµIn a given state, must the planet eventually fail? ļµIn a given state, is it possible for the planet to fail, if the wrong breeding choices are made? Docsity.com 12 Questions ā (2) ļµThese questions mirror real ones about protocols. ļ· āCan the planet fail?ā is like asking whether a protocol can enter some undesired or error state. ļ· āMust the planet failā is like asking whether a protocol is guaranteed to terminate. ā¢ Here, āfailureā is really the good condition of termination. Docsity.com 15 Strange Planet with 3 Individuals 300 003030 111 a c b Notice: four states are āmust-failā states. The others are ācanāt-failā states. 102210 a c 201021 bb 012120 a c State 111 has several transitions. Docsity.com 16 Strange Planet with 4 Individuals Notice: states 400, etc. are must-fail states. All other states are āmight-failā states. 400 022 130103 211 a c b b c a 040 202 013310 121 b a c c a b 004 220 301031 112 c b a a b c Docsity.com 17 Taking Advantage of Symmetry ļµThe ability to fail depends only on the set of numbers of the three species, not on which species has which number. ļµLetās represent states by the list of counts, sorted by largest-first. ļµOnly one transition symbol, x. Docsity.com 20 6 Individuals 321 600 411 330 222 Notice: 600 is a must-fail state; 510, 420, and 321 are canāt-fail states; 411, 330, and 222 are āmight-failā states. 420 510 Docsity.com 21 7 Individuals 331 700 430 421 322 Notice: 700 is a must-fail state; All others are might-fail states. 511 520 610 Docsity.com 22 Questions for Thought 1. Without symmetry, how many states are there with n individuals? 2. What if we use symmetry? 3. For n individuals, how do you tell whether a state is āmust-fail,ā āmight- fail,ā or ācanāt-failā? Docsity.com