CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.

Slides:



Advertisements
Similar presentations
CSE 311 Foundations of Computing I
Advertisements

4b Lexical analysis Finite Automata
CMPS 3223 Theory of Computation
Finite Automata CPSC 388 Ellen Walker Hiram College.
CSE 311: Foundations of Computing Fall 2013 Lecture 23: Finite state machines and minimization.
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.
Compiler Construction
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Discussion1: Non-Deterministic Finite Automatons 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.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
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.
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
Rosen 5th ed., ch. 11 Ref: Wikipedia
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.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
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.
CHAPTER 1 Regular Languages
CSE 311 Foundations of Computing I Lecture 24 Finite State Machines Autumn 2012 CSE 3111.
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
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:
1 Lexical Analysis Uses formalism of Regular Languages Uses formalism of Regular Languages Regular Expressions Regular Expressions Deterministic Finite.
Theory of Computation Automata Theory Dr. Ayman Srour.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
Deterministic Finite Automata Nondeterministic Finite Automata.
CS412/413 Introduction to Compilers Radu Rugina Lecture 3: Finite Automata 25 Jan 02.
1 Finite Automata. 2 Introductory Example An automaton that accepts all legal Pascal identifiers: Letter Digit Letter or Digit "yes" "no" 2.
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
NFAε - NFA - DFA equivalence
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.
Non-Deterministic Finite Automata
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 I
Chapter 1 Regular Language
Presentation transcript:

CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs

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 that have even # of 1’s or contain the substring 111