CSE 311 Foundations of Computing I

Slides:



Advertisements
Similar presentations
NFAε - NFA - DFA equivalence
Advertisements

CSE 311 Foundations of Computing I
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.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Fall 2006Costas Busch - RPI1 Regular Expressions.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
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.
Automating Construction of Lexers. Example in javacc TOKEN: { ( | | "_")* > | ( )* > | } SKIP: { " " | "\n" | "\t" } --> get automatically generated code.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
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
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
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 21 Finite State Machines Autumn 2011 CSE 3111.
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.
CSE 311 Foundations of Computing I Lecture 24 FSM Limits, Pattern Matching Autumn 2011 CSE 3111.
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
CS412/413 Introduction to Compilers Radu Rugina Lecture 3: Finite Automata 25 Jan 02.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
Theory of Computation Automata Theory Dr. Ayman Srour.
NFAε - NFA - DFA equivalence
Non Deterministic Automata
CSE 105 theory of computation
PROPERTIES OF REGULAR LANGUAGES
CSE 311 Foundations of Computing I
Single Final State for NFA
Chapter 2 FINITE AUTOMATA.
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Hierarchy of languages
CSE 311 Foundations of Computing I
COSC 3340: Introduction to Theory of Computation
4. Properties of Regular Languages
Non-Deterministic Finite Automata
Non Deterministic Automata
CSE 311: Foundations of Computing
Finite Automata.
Discrete Math II Howon Kim
CSE 105 theory of computation
4b Lexical analysis Finite Automata
CSCI 2670 Introduction to Theory of Computing
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
Finite-State Machines with No Output
CSCI 2670 Introduction to Theory of Computing
CSE 105 theory of computation
CHAPTER 1 Regular Languages
Lexical Analysis Uses formalism of Regular Languages
CSE 105 theory of computation
Presentation transcript:

CSE 311 Foundations of Computing I Lecture 23 NFAs, Regular Expressions, and Equivalence with DFAs 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 New homework out later today won’t be due until Friday Dec 2. Autumn 2011 CSE 311

Last lecture highlights Finite State Machines with output at states State minimization 2 1 3 S0 [1] S2 [1] S4 [1] S1 [0] S3 S5 2 1 3 1,2 S0 [1] S2 [1] S1 [0] S3 1,3 ⇒ Autumn 2011 CSE 311

Last lecture highlights Lemma: The language recognized by a DFA is the set of strings x that label some path from its start state to one of its final states 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: The language recognized by an NFA is the set of strings x that label some path from its start state to one of its final states s0 s2 s3 s1 1 0,1 Autumn 2011 CSE 311

Three ways of thinking about NFAs Outside observer: Is there a path labeled by x from the start state to some final state? Perfect guesser: The NFA has input x and whenever there is a choice of what to do it magically guesses a good one (if one exists) Parallel exploration: The NFA computation runs all possible computations on x step-by-step at the same time in parallel 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

NFAs and Regular Expressions Theorem: For any set of strings (language) A described by a regular expression, there is an NFA that recognizes A. Proof idea: Structural induction based on the recursive definition of regular expressions... Note: One can also find a regular expression to describe the language recognized by any NFA but we won’t prove that fact Autumn 2011 CSE 311

Regular expressions over  Basis: ,  are regular expressions a is a regular expression for any a   Recursive step: If A and B are regular expressions then so are: (A  B) (AB) A*

Basis Case : Case : Case a: Autumn 2011 CSE 311

Basis Case : Case : Case a: a Autumn 2011 CSE 311

Inductive Hypothesis Suppose that for some regular expressions A and B there exist NFAs NA and NB such that NA recognizes the language given by A and NB recognizes the language given by B NA NB Autumn 2011 CSE 311

Inductive Step Case (A  B): NA NB Autumn 2011 CSE 311

Inductive Step Case (A  B): λ NA λ NB Autumn 2011 CSE 311

Inductive Step Case (AB): NB NA Autumn 2011 CSE 311

Inductive Step Case (AB): λ λ NB NA Autumn 2011 CSE 311

Inductive Step Case A* NA Autumn 2011 CSE 311

Inductive Step Case A* λ λ NA λ Autumn 2011 CSE 311

NFAs and DFAs Every DFA is an NFA DFAs have requirements that NFAs don’t have Can NFAs recognize more languages? No! Theorem: For every NFA there is a DFA that recognizes exactly the same language Autumn 2011 CSE 311

Conversion of NFAs to a DFAs Proof Idea: The DFA keeps track of ALL the states that the part of the input string read so far can reach in the NFA There will be one state in the DFA for each subset of states of the NFA that can be reached by some string Autumn 2011 CSE 311

Conversion of NFAs to a DFAs New start state for DFA The set of all states reachable from the start state of the NFA using only edges labeled  f e b a  a,b,e,f DFA NFA Autumn 2011 CSE 311

Conversion of NFAs to a DFAs For each state of the DFA corresponding to a set S of states of the NFA and each symbol s Add an edge labeled s to state corresponding to T, the set of states of the NFA reached by starting from some state in S, then following one edge labeled by s, and then following some number of edges labeled by  T will be  if no edges from S labeled s exist 1 f e b  c d g  1 1 b,e,f c,d,e,g 1 Autumn 2011 1 CSE 311

Conversion of NFAs to a DFAs Final states for the DFA All states whose set contain some final state of the NFA c e b a a,b,c,e DFA NFA Autumn 2011 CSE 311

Example: NFA to DFA c a b  0,1 1 NFA DFA Autumn 2011 CSE 311

Example: NFA to DFA a,b c a b  0,1 1 NFA DFA Autumn 2011 CSE 311

Example: NFA to DFA a,b c a b  0,1 1 1 c NFA DFA Autumn 2011 CSE 311

Example: NFA to DFA a,b a c b c b,c b 1  1 1 0,1 NFA DFA Autumn 2011 a,b c a b  0,1 1 1 1 c b b,c NFA DFA Autumn 2011 CSE 311

Example: NFA to DFA  a,b a c b c b,c b 1 1  1 1 0,1 NFA DFA  a,b c a b  0,1 1 1 1 1 c b b,c NFA DFA Autumn 2011 CSE 311

Example: NFA to DFA  a,b a c b c b,c b 0,1 1 1  1 1 0,1 NFA DFA  a,b c a b  0,1 1 1 1 1 c b b,c NFA DFA Autumn 2011 CSE 311

Example: NFA to DFA  a,b a c b c b,c a,b,c b 0,1 1 1  1 1 1 0,1 NFA  a,b c a b  0,1 1 1 1 1 c b 1 b,c a,b,c NFA DFA Autumn 2011 CSE 311

Example: NFA to DFA  a,b a c b c b,c a,b,c b 0,1 1 1  1 1 1 0,1 1  a,b c a b  0,1 1 1 1 1 c b 1 1 b,c a,b,c NFA DFA Autumn 2011 CSE 311

Exponential blow-up in simulating nondeterminism In general the DFA might need a state for every subset of states of the NFA Power set of the set of states of the NFA n-state NFA yields DFA with at most 2n states We saw an example where roughly 2n is necessary Is the 10th char from the end a 1? The famous “P=NP?” question asks whether a similar blow-up is always necessary to get rid of nondeterminism for polynomial-time algorithms Autumn 2011 CSE 311