Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

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.
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.
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 Lecture3: Regular Expressions Prof. Amos Israeli.
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.
1 Introduction to Computability Theory Lecture4: Regular Expressions 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.
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
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.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
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.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
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.
CSCI 2670 Introduction to Theory of Computing August 24, 2005.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Theory of Languages and Automata
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
1 Chapter 2 Finite Automata (part b) Windmills in Holland.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Regular Expressions Hopcroft, Motawi, Ullman, Chap 3.
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
Deterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.2)
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
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.
Lecture Notes 
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Scribing K SAMPATH KUMAR 11CS10022 scribing. Definition of a Regular Expression R is a regular expression if it is: 1.a for some a in the alphabet ,
Regular Expressions CS 130: Theory of Computation HMU textbook, Chapter 3.
CSCI 2670 Introduction to Theory of Computing September 11, 2007.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Theory of Computation Automata Theory Dr. Ayman Srour.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
Theory of Computation Automata Theory Dr. Ayman Srour.
Nondeterminism Subset Construction ε -Transitions.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
CIS Automata and Formal Languages – Pei Wang
Lexical analysis Finite Automata
Nondeterministic Finite Automata
Jaya Krishna, M.Tech, Assistant Professor
Non-Determinism 12CS45 Finite Automata.
Non-Deterministic Finite Automata
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Non Deterministic Automata
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
Chapter 1 Regular Language
Presentation transcript:

Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)

NFAs: Nondeterministic Finite Automata Same as a DFA, except: On input a, state q may have more than one transition out, implying the possibility of multiple choices when processing an input symbol On input a, state q may have no transition out, implying the possibility of “being stuck” A string w is acceptable as long as there exists an admissible state sequence for w

NFAs A nondeterministic finite automaton M is a five-tuple M = (Q, , , q 0, F), where: Q is a finite set of states of M  is the finite input alphabet of M  : Q    power set of Q, is the state transition function mapping a state-symbol pair to a subset of Q q 0 is the start state of M F  Q is the set of accepting states or final states of M

Example NFA NFA that recognizes the language of strings that end in 01 q0q0 q2q2 0,1 0 1 q1q1 note:  (q 0,0) = {q 0,q 1 }  (q 1,0) = {} Exercise: draw the complete transition table for this NFA

 ^ definition for an NFA  ^: Q X  *  power set of Q  ^(q,  ) = {q}  ^(q, w), w = xa (where x is a string and a is a symbol) is defined as follows: Let  ^(q, x) = {p 1,p 2,…p k } Then,  ^(q, w) =   (p i, a)

Language recognized by an NFA A string w is accepted by an NFA M if  ^(q 0, w)  F is non-empty Note that  ^(q 0, w) represents a subset of states since the automaton is nondeterministic Equivalent definition: there exists an admissible state sequence for w in M The language L(M) recognized by an NFA is the set of strings accepted by M L(M) ={ w |  ^(q 0, w)  F is non-empty }

Converting NFAs to DFAs Given a NFA, M = (Q, , , q 0, F), build a DFA, M’ = (Q’, ,  ’, {q 0 }, F’) as follows. Q’ contains all subsets S of states in Q. The initial state of M’ is the set containing q 0 F’ is the set of all subsets of Q that contain at least one element in F (equivalently, the subset contains at least one final state)

Converting NFAs to DFAs  ’ is determined by putting together, for each state in the subset and each symbol, all states that may result from a transition:  ’(S, a) =   (q, a) q  S May remove “unreachable” states in Q’

Example conversion NFA DFA q0q0 q2q2 0,1 0 1 q1q1 {q 0 } {q 0,q 1 } {q 0,q 2 } 0 0 1

NFA with  -transitions NFA that allows the transition of an empty string from a state Jumping to a state is possible even without input Revision on NFA definition simply allows the  “symbol” for 

NFA with  -transitions A nondeterministic finite automaton with  - transitions (or  -NFA) is a five-tuple M = (Q, , , q 0, F), where: Q is a finite set of states of M  is the finite input alphabet of M  : Q  (  +  )  power set of Q, is the state transition function mapping a state-symbol pair to a subset of Q q 0 is the start state of M F  Q is the set of accepting states or final states of M

Converting  -NFAs to NFAs Task: Given an  -NFA M = (Q, , , q 0, F), build a NFA M’ = (Q, ,  ’, q 0, F’) Need to eliminate  -transitions Need epsilon closure concept Add transitions to enable transitions previously allowed by the  -transitions Note: the conversion process in the textbook instead builds a DFA from an  -NFA The conversion described in these slides is simpler

Epsilon closure In an NFA M, let q  Q ECLOSE(q) represents all states r that can be reached from q using only  -transitions Recursive definition for ECLOSE If  (q,  ) is empty, ECLOSE(q) = {q} Else, Let  (q,  ) = {r 1, r 2,…, r n }. ECLOSE(q) =  ECLOSE(r i )  {q} Note: check out constructive definition in the textbook

Additional transitions Suppose ECLOSE(q) = {r 1, r 2,…, r n }. For each transition from state r i to state s j on (non-epsilon) symbol a, add a transition from q to s j on symbol a That is,  ’(q, s) =  (q, s)  states resulting from the additional transitions Initially set F’ = F. If  (q,  ) includes a state in F’, add q to F’

Equivalence of Finite Automata Conversion processes between DFAs, NFAs, and  -NFAs show that no additional expressive capacity (except convenience) is introduced by non- determinism or  -transitions All models represent regular languages Note: possible exponential explosion of states when converting from NFA to DFA

Closure of Regular Languages under certain operations UnionL1  L2 ComplementationL1 IntersectionL1  L2 ConcatenationL1L2 Goal: ensure a FA can be produced from the FAs of the “operand” languages

Finite Automata with Output Moore Machines Output symbol for each state encountered Mealy Machines Output symbol for each transition encountered Exercise: formally define Moore and Mealy machines

Next: Regular Expressions Defines languages in terms of symbols and operations Example (01)* + (10)* defines all even-length strings of alternating 0s and 1s Regular expressions also model regular languages and we will demonstrate equivalence with finite automata