CSE 311: Foundations of Computing Fall 2013 Lecture 23: Finite state machines and minimization.

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
Finite Automata CPSC 388 Ellen Walker Hiram College.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2005.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Introduction to Computability Theory
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.
Fall 2006Costas Busch - RPI1 Regular Expressions.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
1 Non-Deterministic Automata Regular Expressions.
Automating Construction of Lexers. Example in javacc TOKEN: { ( | | "_")* > | ( )* > | } SKIP: { " " | "\n" | "\t" } --> get automatically generated code.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Rosen 5th ed., ch. 11 Ref: Wikipedia
Elevator Controller We’re hired to design a digital elevator controller for a four-floor building st try: Design a counter that counts up.
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.
Finite-State Machines with Output
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
Fall 2006Costas Busch - RPI1 Deterministic Finite Automaton (DFA) Input Tape “Accept” or “Reject” String Finite Automaton Output.
Lexical Analysis Constructing a Scanner from Regular Expressions.
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 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.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
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:
Theory of Computation Automata Theory Dr. Ayman Srour.
Deterministic Finite Automata Nondeterministic Finite Automata.
NFAε - NFA - DFA equivalence
Lexical analysis Finite Automata
Non Deterministic Automata
CSE 311 Foundations of Computing I
Chapter 2 FINITE AUTOMATA.
CSE 311 Foundations of Computing I
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Non Deterministic Automata
CSE 311: Foundations of Computing
CSE322 Minimization of finite Automaton & REGULAR LANGUAGES
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
Presentation transcript:

CSE 311: Foundations of Computing Fall 2013 Lecture 23: Finite state machines and minimization

FSM highlights Finite state machines – States, transitions, start state, final states – Languages recognized by FSMs s0s0 s2s2 s3s3 s1s , s0s0 s2s2 A s1s1 1 R 0

FSM highlights Combining FSMs to check two properties at once New states record states of both FSMs s0s0 s1s1 0,1 2 2 t0t0 t2t2 t1t s0t0s0t0 s1t0s1t0 s1t2s1t2 s0t1s0t1 s0t2s0t2 s1t1s1t

state machines with output 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”

vending machine Enter 15 cents in dimes or nickels Press S or B for a candy bar

vending machine, v DD N N N, D B, S Basic transitions on N (nickel), D (dime), B (butterfinger), S (snickers)

vending machine, v ’ B 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

vending machine, v1.0 0’ B 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

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

state minimization algorithm 1.Put states into groups based on their outputs (or whether they are final states or not) 2.Repeat the following until no change happens a.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 G1G1 G2G2 G3G3 s s s s

state minimization example state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S50 S2S1S3S2S41 S3S1S0S4S50 S4S0S1S2S51 S5S1S4S0S S0 [1] S2 [1] S4 [1] S1 [0] S3 [0] S5 [0] 1 Put states into groups based on their outputs (or whether they are final states or not)

state minimization example state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S50 S2S1S3S2S41 S3S1S0S4S50 S4S0S1S2S51 S5S1S4S0S S0 [1] S2 [1] S4 [1] S1 [0] S3 [0] S5 [0] 1 Put states into groups based on their outputs (or whether they are final states or not)

state minimization example state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S50 S2S1S3S2S41 S3S1S0S4S50 S4S0S1S2S51 S5S1S4S0S S0 [1] S2 [1] S4 [1] S1 [0] S3 [0] S5 [0] 1 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

state minimization example state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S50 S2S1S3S2S41 S3S1S0S4S50 S4S0S1S2S51 S5S1S4S0S S0 [1] S2 [1] S4 [1] S1 [0] S3 [0] S5 [0] 1 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

state minimization example state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S50 S2S1S3S2S41 S3S1S0S4S50 S4S0S1S2S51 S5S1S4S0S S0 [1] S2 [1] S4 [1] S1 [0] S3 [0] S5 [0] 1 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

state minimization example state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S50 S2S1S3S2S41 S3S1S0S4S50 S4S0S1S2S51 S5S1S4S0S S0 [1] S2 [1] S4 [1] S1 [0] S3 [0] S5 [0] 1 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

state minimization example state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S50 S2S1S3S2S41 S3S1S0S4S50 S4S0S1S2S51 S5S1S4S0S S0 [1] S2 [1] S4 [1] S1 [0] S3 [0] S5 [0] 1 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

state minimization example state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S50 S2S1S3S2S41 S3S1S0S4S50 S4S0S1S2S51 S5S1S4S0S S0 [1] S2 [1] S4 [1] S1 [0] S3 [0] S5 [0] 1 Can combine states S0-S4 and S3-S5. In table replace all S4 with S0 and all S5 with S3

minimized machine state transition table present next state output state0123 S0S0S1S2S31 S1S0S3S1S30 S2S1S3S2S01 S3S1S0S0S ,2 S0 [1] S2 [1] S1 [0] S3 [0] 1,3

another way to look at DFAs s0s0 s2s2 s3s3 s1s , Lemma: x is in the language recognized by a DFA iff x labels a path from the start state to some final state Definition: The label of a path in a DFA is the concatenation of all the labels on its edges in order

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 if and only if x labels a path from the start state to some final state s0s0 s2s2 s3s3 s1s ,1

goal: NFA to recognize... binary strings with even # of 1’s that contain the substring 111