Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CS3518 Exercises CS3518 Finite State Automata 1. Questions about FSAs that accept a language Describe in words the languages accepted by each of the following FSAs: 1 0 1 1 0 1 0 (i ) Answer (i): strings of 0's and 1's with an even number of 0's Answer (ii): strings of 0's and 1's, starting with a 10, and no pairs of 0's Answer (iii): strings of 0's and 1's with either a pair of 0's or a pair of 1's 1 (i i) CS3518 2. Exercises Give a formal definition for the FSAs which define the following languages (i.e. specify Q, I, F, T, E): Answer: (I show the diagram, but you can easily convert to QIFTE) a a a,b b a,b b a a b a b a (ii) 3. b b (iii) Give a formal definition for a FSA accepting the infinite set of strings representing numbers divisible by 2. (i.e. 0,2,4,6,8,10,12,….) Answer: Just check the last digit, make sure it’s even (need two states) Let E=0,2,4,6,8 Let O=1,3,5,7,9 Then QIFTE=({1,2},{1},{2},{O,E},{(1,O,1),(1,E,2),(2,O,1),(2,E,2)}) 4. Give a formal definition for a FSA accepting the infinite set of strings representing numbers divisible by 3. (this one is tricky, try (on paper) doing a division of 3 into some large number x, and see if the process you are using to deal with each new digit of x could be automated by a machine.) Answer: (rough definition) 3 states 0,1,2 from 0 to 0: label 0,3,6,9 from 0 to 1: label 1,4,7 from 0 to 2: label 2,5,8 from 1 to 0: label 2,5,8 from 1 to 1: label 0,3,6,9 from 1 to 2: label 1,4,7 from 2 to 0: label 1,4,7 from 2 to 1: label 2,5,8 from 2 to 2: label 0,3,6,9 CS3518 5. Exercises Give a formal definition for a FSA accepting the set of strings over {a, b} which contain an even number of a's and an even number of b's. (this one is tricky, try doing it manually for some random string of a’s and b’s. What do you need to remember as you’re going through the string? How many states will the FSA need, to remember this?) Answer: 6. Specification of a suitable Mealy Machine (a diagram can capture the same information): Q = {q0,q1,q2,q3} I = q0 T = {a,b} E = {(q0,a,q1), (q0,b,q0), (q1,a,q2), (q1,b,q0), (q2,a,q2), (q2,b,q3), (q3,a,q1), (q3,b,q0)} Gamma = {1} (or any alphabet containing 1 as one of its symbols) O = The function that assigns the empty string to every combination of a state and an input symbol, with one exception, namely: (q2,b,1). Some things to note: -- q2 is the state in which the automaton has just read aa -- In q2, when reading a, loop back onto q2 (think of an input such as aaaab) -- In q3, when reading a, go back to q1 (the state that remembers that one a has been read) 7. Specification of a suitable Moore Machine (a diagram can capture the same information): Q={q0,q1,q2,q3} I=q0 T={0,1} E={(q0,0,q1),(q0,1,q2),(q1,0,q3),(q1,1,q1),(q2,0,q1),(q2,1,q2),(q3,0,q3),(q3,1,q1)} Gamma={0,1} O={(q0,lambda),(q1,1),(q2,0),(q3,0),} 8. Yes, this does make sense. Moore Machine: Q,I,T,E as for NDFSAs (hence possibly several initial states in I; E may be a relation that’s not functional in its first two arguments). One might even allow O to be a relation that’s not functional. Mealy Machine: Q,I,T,E as for NDFSAs. One might even allow O to be a relation that’s not functional in its first two arguments. 9. Moore and Mealy Machines can handle the empty input in slightly different ways: Moore Machine: In most examples, the initial state q0 will have empty output, but suppose we have (q0,b), where b is a symbol of T. This will cause the machine to output b when confronted with the empty string. Mealy Machine: Since output in Mealy Machines is associated with an input symbol, and Mealy Machines do not allow the empty string as an input (check the definition!) they are unable to output b. CS3518 Exercises Notice how the notion of equivalence (between Moore Machines and Mealy Machines) in the slides discounts this difference between the two kinds of machines. 10. Have a browse. One standard example is a vending machine, where a given sequence of coins is associated with a product coming out of the machine (and maybe change as well). 11. (Optional.) Have a browse. Among the web pages that you may find instructive are http://en.wikipedia.org/wiki/Hidden_Markov_model http://mlg.eng.cam.ac.uk/zoubin/papers/ijprai.pdf Once again, this is optional..