CSE 311 Foundations of Computing I

Slides:



Advertisements
Similar presentations
Modeling Computation Chapter 13.
Advertisements

Theory of Computing Lecture 23 MAS 714 Hartmut Klauck.
CSE 311 Foundations of Computing I
4b Lexical analysis Finite Automata
CMPS 3223 Theory of Computation
CSE 311: Foundations of Computing Fall 2013 Lecture 23: Finite state machines and minimization.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
Automating Construction of Lexers. Example in javacc TOKEN: { ( | | "_")* > | ( )* > | } SKIP: { " " | "\n" | "\t" } --> get automatically generated code.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Finite State Machines Data Structures and Algorithms for Information Processing 1.
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Rosen 5th ed., ch. 11 Ref: Wikipedia
The Golden Chain εNFA  NFA  DFA  REGEX. Regular Expressions.
NFA ε - NFA - DFA equivalence. What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
CSE 311 Foundations of Computing I Lecture 23 Finite State Machines Autumn 2012 CSE 3111.
CSE 311 Foundations of Computing I Lecture 21 Finite State Machines Autumn 2011 CSE 3111.
CSE 311 Foundations of Computing I Lecture 21 Finite State Machines Spring
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CSE 311 Foundations of Computing I Lecture 27 FSM Limits, Pattern Matching Autumn 2012 CSE
CSE 311 Foundations of Computing I Lecture 24 Finite State Machines Autumn 2012 CSE 3111.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CSE 311 Foundations of Computing I Lecture 20 Relations, Graphs, Finite State Machines Autumn 2011 CSE 3111 TexPoint fonts used in EMF. Read the TexPoint.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
using Deterministic Finite Automata & Nondeterministic Finite Automata
CSE 311 Foundations of Computing I Lecture 24 FSM Limits, Pattern Matching Autumn 2011 CSE 3111.
LECTURE 5 Scanning. SYNTAX ANALYSIS We know from our previous lectures that the process of verifying the syntax of the program is performed in two stages:
Deterministic Finite Automata Nondeterministic Finite Automata.
Finite-State Machines (FSM) Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth Rosen.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
NFAε - NFA - DFA equivalence
Kleene’s Theorem and NFA
Lexical analysis Finite Automata
Lecture2 Regular Language
Non Deterministic Automata
PROPERTIES OF REGULAR LANGUAGES
Pushdown Automata.
Nondeterministic Finite Automata
Chapter 2 FINITE AUTOMATA.
CSE322 Finite Automata Lecture #2.
CSE 311 Foundations of Computing I
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
Properties of Regular Languages
COSC 3340: Introduction to Theory of Computation
4. Properties of Regular Languages
Non-Deterministic Finite Automata
Minimal DFA Among the many DFAs accepting the same regular language L, there is exactly one (up to renaming of states) which has the smallest possible.
Non Deterministic Automata
CSE 311: Foundations of Computing
Finite Automata.
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
CSE 311: Foundations of Computing
CSE 311 Foundations of Computing I
Chapter 1 Regular Language
Lecture 5 Scanning.
Lexical Analysis Uses formalism of Regular Languages
Presentation transcript:

CSE 311 Foundations of Computing I Lecture 22 Finite State Machines: Output and Minimization Autumn 2011 Autumn 2011 CSE 311

Announcements Reading assignments 7th Edition, Sections 13.3 and 13.4 6th Edition, Section 12.3 and 12.4 5th Edition, Section 11.3 and 11.4 Autumn 2011 CSE 311

Last lecture highlights Finite state machines States, transitions, start state, final states Languages recognized by FSMs s0 s2 s3 s1 1 0,1 001 011 111 110 101 010 000 100 1 Autumn 2011 CSE 311

Last lecture highlights Combining FSMs to check two properties at once New states record states of both FSMs s0 s1 0,1 2 s0t0 s1t0 s1t2 s0t1 s0t2 s1t1 2 1 t0 t2 t1 2 1 Autumn 2011 CSE 311

State Machines with Output Vending Machine Enter 15 cents in dimes or nickels Press S or B for a candy bar Autumn 2011 CSE 311

Vending Machine, Version 1 N 5 N 10 N, D 15 B, S Basic transitions on N (nickel), D (dime), B (butterfinger), S (snickers) Autumn 2011 CSE 311

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

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

State Minimization Many different FSMs (DFAs) for the same problem Take a given FSM and try to reduce its state set by combining states Algorithm will always produce the unique minimal equivalent machine (up to renaming of states) but we won’t prove this Autumn 2011 CSE 311

State minimization algorithm Put states into groups based on their outputs (or whether they are final states or not) Repeat the following until no change happens If there is a symbol s so that not all states in a group G agree on which group s leads to, split G into smaller groups based on which group the states go to on s G2 G1 G3 Autumn 2011 CSE 311

State Minimization Example present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S5 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 state transition table Put states into groups based on their outputs (or whether they are final states or not) Autumn 2011 CSE 311

State Minimization Example present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S5 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 state transition table Put states into groups based on their outputs (or whether they are final states or not) Autumn 2011 CSE 311

State Minimization Example present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S5 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 state transition table Put states into groups based on their outputs (or whether they are final states or not) If there is a symbol s so that not all states in a group G agree on which group s leads to, split G based on which group the states go to on s Autumn 2011 CSE 311

State Minimization Example present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S5 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 state transition table Put states into groups based on their outputs (or whether they are final states or not) If there is a symbol s so that not all states in a group G agree on which group s leads to, split G based on which group the states go to on s Autumn 2011 CSE 311

State Minimization Example present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S5 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 state transition table Put states into groups based on their outputs (or whether they are final states or not) If there is a symbol s so that not all states in a group G agree on which group s leads to, split G based on which group the states go to on s Autumn 2011 CSE 311

State Minimization Example present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S5 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 state transition table Put states into groups based on their outputs (or whether they are final states or not) If there is a symbol s so that not all states in a group G agree on which group s leads to, split G based on which group the states go to on s Autumn 2011 CSE 311

State Minimization Example present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S5 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 state transition table Put states into groups based on their outputs (or whether they are final states or not) If there is a symbol s so that not all states in a group G agree on which group s leads to, split G based on which group the states go to on s Autumn 2011 CSE 311

State Minimization Example present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S5 0 S2 S1 S3 S2 S4 1 S3 S1 S0 S4 S5 0 S4 S0 S1 S2 S5 1 S5 S1 S4 S0 S5 0 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 state transition table Can combine states S0-S4 and S3-S5. In table replace all S4 with S0 and all S5 with S3 Autumn 2011 CSE 311

state transition table Minimized Machine present next state output state 0 1 2 3 S0 S0 S1 S2 S3 1 S1 S0 S3 S1 S3 0 S2 S1 S3 S2 S0 1 S3 S1 S0 S0 S3 0 2 S0 [1] S1 [0] 1 2 3 1,3 3 1,2 state transition table S2 [1] S3 [0] 1 2 3 Autumn 2011 CSE 311

Another way to look at DFAs Definition: The label of a path in a DFA is the concatenation of all the labels on its edges in order Lemma: x is in the language recognized by a DFA iff x labels a path from the start state to some final state s0 s2 s3 s1 1 0,1 Autumn 2011 CSE 311

Nondeterministic Finite Automaton (NFA) Graph with start state, final states, edges labeled by symbols (like DFA) but Not required to have exactly 1 edge out of each state labeled by each symbol - can have 0 or >1 Also can have edges labeled by empty string  Definition: x is in the language recognized by an NFA iff x labels a path from the start state to some final state s0 s2 s3 s1 1 0,1 Autumn 2011 CSE 311

Design an NFA to recognize the set of binary strings that contain 111 or have an even # of 1’s Autumn 2011 CSE 311