1 91.304 Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.2: NFA’s) David Martin With some modifications.

Slides:



Advertisements
Similar presentations
CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Advertisements

Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.2: Variants of Turing Machines) David Martin With.
Introduction to Computability Theory
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
Finite Automata and Non Determinism
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (more on Section 1.4) David Martin This work is licensed under.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
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.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.1: Decidable Languages) David Martin With modifications.
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.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.1: DFA’s) David Martin With some modifications.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
CS Chapter 2. LanguageMachineGrammar RegularFinite AutomatonRegular Expression, Regular Grammar Context-FreePushdown AutomatonContext-Free Grammar.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.4: Nonregular Languages) David Martin With some.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Great Theoretical Ideas in Computer Science.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Theory of Languages and Automata
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CHAPTER 1 Regular Languages
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.1: Turing Machines) David Martin With some modifications.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Foundations of (Theoretical) Computer Science
Modeling Computation: Finite State Machines without Output
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Finite Automata & Regular Languages Sipser, Chapter 1.
CS 154 Formal Languages and Computability February 9 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
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:
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
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.
Chapter 2 FINITE AUTOMATA.
Non Deterministic Automata
Chapter Five: Nondeterministic Finite Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Chapter 1 Regular Language
CHAPTER 1 Regular Languages
Presentation transcript:

Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.2: NFA’s) David Martin With some modifications by Prof. Karen Daniels, Fall 2009 Slides also added from in some places. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit sa/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

2 Nondeterministic Finite Automata  Will relax two of these DFA rules: 1.Each (state, char) input must produce exactly one (state) output 2.Must consume one character in order to advance state  The NFA accepts the input if there exists any way of reading the input that winds up in an accepting state at the end of the string Otherwise it rejects the input

3 Example: NFA N 2 q3q3 q1q1 q2q2 0,1 1 0,  q4q4 0,1 Let language A consist of all strings over {0,1} containing a 1 in the third position from the end. N 2 recognizes A. Later we show a DFA equivalent to this NFA using construction of Thm variation on

4 Nondetermistic Finite Automata  A nondeterministic finite automaton can be different from a deterministic one in that for any input symbol, nondeterministic one can transit to more than one states. epsilon transition (), which “consumes” no input symbols  NFA and DFA stand for nondeterministic finite automaton and deterministic finite automaton, respectively. variation on

5 NFA N 1 q3q3 q1q1 q2q2 0,1 1 0,  q4q4 0,1 1 variation on

6 Ways to think of NFAs  NFAs want to accept inputs and will always take the most advantageous alternative(s) Because they will accept if there exists any way to get to an accepting state at the end of the string The quickest way there may be just one of many ways, but it doesn’t matter

7 Ways to think of NFAs  fork() model Input string is in a variable fork() at every nondeterministic choice point  subprocess 1 (parent) follows first transition  subprocess 2 (child) follows second  subprocess 3 (child) follows third (if any), etc. A process that can’t follow any transition calls exit() -- and gives up its ability to accept A process that makes it through the whole string and is in an accepting state prints out “ACCEPT”  A single ACCEPT is enough a a a

8 Parallel world and NFA... accept variation on reject

9 Syntax of DFA (repeat)  A deterministic finite automaton (DFA) is a 5-tuple (Q,,delta,q 0,F) such that 1.Q is a finite set of states 2.  is an alphabet 3. :Q £  ! Q is the transition function 4.q 0 2 Q is the start state 5.F µ Q is the set of accepting states Usually these names are used, but others are possible as long as the role is clear

10 Syntax of NFA  A nondeterministic finite automaton (NFA) is a 5-tuple (Q,, ,q 0,F) such that 1.Q is a finite set of states 2.  is an alphabet 3. :Q £ ( [ {}) !P (Q) is the transition function 4.q 0 2 Q is the start state 5.F µ Q is the set of accepting states Usually these names are used, but others are possible as long as the role is clear Note:  =  U {}

11 NFA N 1 (again) q3q3 q1q1 q2q2 0,1 1 0,  q4q4 0,1 1 variation on Note the use of sets here in contrast to DFA. Board work: Resolve transition table with Figure 1.29.

12 The Subset Construction Theorem 1.39 For every NFA M 1 there exists a DFA M 2 such that L(M 1 ) = L(M 2 ). Corollary 1.40 A language is REGular if and only if some nondeterministic finite automaton recognizes it.

13 The Subset Construction Proof: Let M 1 =(Q 1,, 1,init 1,F 1 ) be the NFA and define the DFA M 2 =(Q 2,, 2,init 2,F 2 ) as follows: 1.Q 2 = P (Q 1 ).  Each state of the DFA records the set of states that the NFA can simultaneously be in  Can compare DFA states for equality but also look "inside" the state name to find a set of NFA state names 2.Define  2 : Q 2 £  ! Q 2  2 : P (Q 1 ) £  ! P (Q 1 ) by  2 (S,a) = E 1 ( 1 (S,a)) Go to whatever states are reachable from the states in S and reading the character a Remember: in an NFA,   : Q 1 £   ! P (Q 1 ) from def  1 : P (Q 1 ) £   ! P (Q 1 ) extend to sets E 1 : P (Q 1 ) !P (Q 1 ) -closure

14 The Subset Construction 3.init 2 = E(init 1 ) 4.F 2 ={q 2 Q 2 | q Å F 1  ; }, in other words F 2 ={S µ Q 1 | S Å F 1  ; } The effect is that the DFA knows all states that are reachable in the NFA after reading the string so far. If any one of them is accepting, then the current DFA state is accepting too, otherwise it's not. If you believe this then that's all it takes to see that the construction is correct. So, convince yourself with an example. QED

15 Example: NFA N 2 (again) q3q3 q1q1 q2q2 0,1 1 0,  q4q4 0,1 Let language A consist of all strings over {0,1} containing a 1 in the third position from the end. N 2 recognizes A. No  ’s in this example. variation on

16 A DFA equivalent to N 2 q 010 q 000 q q 110 q 011 q 001 q 101  q Variation on Board work: Start with all states, including unreachables.

17 Example 1.21 NFA N 4 to DFA a b a,b  a variation on

18 The state diagram of D variation on  {1} {2} {1,2} {3} {1,3} {2,3} {1,2,3} a,b a a a a a a b b b b b b unreachable

19 Subset construction conclusion  Adding nondeterminism makes programs shorter but not able to do new things  Remember: regular languages are defined to be those "recognized by a DFA"  We now have a result that says that every language that is recognized by an NFA is regular too So if you are asked to show that a language is regular, you can exhibit a DFA or NFA for it and rely on the subset construction theorem Sometimes questions are specifically about DFAs or NFAs, though... pay attention to the precise wording

20 Closure properties  The presence or absence of closure properties says something about how well a set tolerates an operation  Definition. Let S µ U be a set in some universe U and ¯ be an operation on elements of U. We say that S is closed under ¯ if applying ¯ to element(s) of S produces another element of S. For example, if ¯ is a binary operation ¯ :U £ U ! U, then we're saying that ( 8 x 2 S and y 2 S) x ¯ y 2 S

21 Closure properties illustrated S U Applying the ¯ operation to elements of S never takes you ouside of S. S is closed with respect to ¯ This example shows unary operations ¯ ¯ ¯ ¯ ¯ ~ Not closed under ~

22 More examples  L 1 ={x 2 { 0,1 } * : |x| is a multiple of 3 } is closed under string reversal and concatenation  L 3 ={x 2 {0,1} * | the binary number x is a multiple of 3 } is also closed under string reversal and concatenation, harder to see though  L 4 ={x 2 {a,b} * | x contains an odd # of ‘b’s and an even # of ‘a’s} is closed under string reversal is not closed under string concatenation

23 Closure: higher abstraction  We will usually be concerned with closure of language classes under language operations Previous examples were closure of sets containing non-set elements under various familiar operations We consider DFAs and NFAs to be programs and we want assurance that their outputs can be combined in desired ways just by manipulating their programs (like using one as a subroutine for the other) Representative question: is REG closed under (language) concatenation?

24 The regular operations  The regular operations on languages are [ (union) ¢ (concatenation) ¤ (Kleene star)  The name "regular operations" is not that important Too bad we use the word "regular" for so much  REG is closed under these regular operations That's why they're called "regular" operations This does not mean that each regular language is closed under each of these operations!

25 The regular operations  REG is closed under union: Theorem 1.25 (using DFAs), Theorem 1.45 (using NFAs)  REG is closed under concatenation: Theorem 1.47 (NFAs)  REG is closed under ¤ : Theorem 1.49 (NFAs)  Study these constructions!!  REG is also closed under complement and reversal (not in book)

26 Theorem 1.45 The class of regular languages is closed under the union operation. N1N1 N2N2 N   variation on

27 Theorem 1.47 The class of regular languages is closed under the concatenation operation. N1N1 N2N2 N   variation on

28 Theorem 1.24 The class of regular languages is closed under the star operation. N1N1 N   