Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 311 Foundations of Computing I Lecture 23 Finite State Machines Autumn 2012 CSE 3111.

Similar presentations


Presentation on theme: "CSE 311 Foundations of Computing I Lecture 23 Finite State Machines Autumn 2012 CSE 3111."— Presentation transcript:

1 CSE 311 Foundations of Computing I Lecture 23 Finite State Machines Autumn 2012 CSE 3111

2 Announcements Reading assignments – 7 th Edition, Sections 13.3 and 13.4 – 6 th Edition, Section 12.3 and 12.4 – 5 th Edition, Section 11.3 and 11.4 Autumn 2012CSE 3112

3 Lecture highlights: Database and relations ID_NumberCourse 328012098CSE311 328012098CSE351 481080220CSE311 238082388CSE312 238082388CSE344 238082388CSE351 1727017CSE312 348882811CSE311 348882811CSE312 348882811CSE344 348882811CSE351 2921938CSE351 Databases consist of collection of n-ary relations Student_NameID_NumberOfficeGPA Knuth3280120980224.00 Von Neuman4810802205553.78 Russell2380823880223.85 Einstein2380019200222.11 Newton17270173333.61 Karp3488828110223.98 Bernoulli29219380223.21 STUDENT TAKES

4 Relational Databases: Keys An attribute is a key if all its values in the database are always distinct Autumn 2012CSE 3114 Which attribute is the key? Why is Student_Name not a key? Student_NameID_NumberOfficeGPA Knuth3280120980224.00 Von Neuman4810802205553.78 Russell2380823880223.85 Einstein2380019200222.11 Newton17270173333.61 Karp3488828110223.98 Bernoulli29219380223.21

5 Relational Databases: Relationships Autumn 2012CSE 3115 WORKS_ON is a relationship between students and project Student_NameID_NumberOffice Knuth328012098022 Von Neuman481080220555 Russell238082388022 Einstein238001920022 Newton1727017333 Karp348882811022 Bernoulli2921938022 PRJ_IDProject_NameDue_date P331“Flying cyphers”11/2012 P004“Virtual induction”12/2012 P901“Binary bots”12/2012 STUDENT PROJECT ID_NumberPRJ_ID 2921938P004 2921938P901 1727017P901 Who works on what?

6 Types of Relationships in Relational Databases one-one: many-one many-many 123123 abcdabcd 123123 abcdabcd 123123 abcdabcd Autumn 2012CSE 3116 What type is WORKS_ON? ID_NumberPRJ_ID 2921938P004 2921938P901 1727017P901

7 Finite state machines States Transitions on inputs Start state and final states The language recognized by a machine is the set of strings that reach a final state Autumn 2012 CSE 311 7 s0s0 s2s2 s3s3 s1s1 111 0,1 0 0 0 State01 s0s0 s0s0 s1s1 s1s1 s0s0 s2s2 s2s2 s0s0 s3s3 s3s3 s3s3 s3s3

8 Applications of Finite State Machines (a.k.a. Finite Automata) Implementation of regular expression matching in programs like grep Control structures for sequential logic in digital circuits Algorithms for communication and cache- coherence protocols – Each agent runs its own FSM Design specifications for reactive systems – Components are communicating FSMs Autumn 2012CSE 3118

9 Applications of Finite State Machines (a.k.a. Finite Automata) Formal verification of systems – Is an unsafe state reachable? Computer games – FSMs provide worlds to explore Minimization algorithms for FSMs can be extended to more general models used in – Text prediction – Speech recognition Autumn 2012CSE 3119

10 What language does this machine recognize? Autumn 2012CSE 31110 s0s0 s2s2 s3s3 s1s1 1 1 1 1 0 0 0 0

11 3 Bit Shift register Autumn 2012CSE 31111 001 011 111 110 101010 000 100 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 0

12 Autumn 2012CSE 31112 001 011 111110 101010 000 100 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 0 1000011011 1 1 1 0 0 0 0000 1 1 1 1

13 Design a DFA that accepts strings with a 1 three positions from the end Autumn 2012CSE 31113

14 Autumn 2012CSE 31114 How does the size of a DFA to recognize “10 th character is a 1” compare with the size of a DFA to recognize “10 th character from the end is 1”?

15 Strings over {0, 1, 2}* M 1 : Strings with an even number of 2’s M 2 : Strings where the sum of digits mod 3 is 0 Autumn 2012CSE 31115 s0s0 s1s1 t0t0 t2t2 t1t1

16 Recognize strings with an even number of 2’s and a mod 3 sum of 0 Autumn 2012CSE 31116 s0t0s0t0 s1t0s1t0 s1t2s1t2 s0t1s0t1 s0t2s0t2 s1t1s1t1

17 State machines with output Autumn 2012CSE 31117 InputOutput StateLR s1s1 s1s1 s2s2 Beep s2s2 s1s1 s3s3 s3s3 s2s2 s4s4 s4s4 s3s3 s4s4 S3S3 S4S4 S1S1 S2S2 R L R L R L L R “Tug-of-war”

18 Vending Machine Autumn 2012CSE 31118 Enter 15 cents in dimes or nickels Press S or B for a candy bar

19 Vending Machine, Version 1 05 1015 DD N N N, D B, S Basic transitions on N (nickel), D (dime), B (butterfinger), S (snickers)

20 Vending Machine, Version 2 0’ B 5 10 15 Adding output to states: N – Nickel, S – Snickers, B – Butterfinger 15’ N 0 0” S N N N N N B D D D D DB S S

21 Vending Machine, Final Version 0’ B 5 10 15 Adding additional “unexpected” transitions 15’ N 0 0” S N N N N N B D D D D D B S S 15” D S B B,S N N N D D D


Download ppt "CSE 311 Foundations of Computing I Lecture 23 Finite State Machines Autumn 2012 CSE 3111."

Similar presentations


Ads by Google