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.

Slides:



Advertisements
Similar presentations
NFAε - NFA - DFA equivalence
Advertisements

CSE 311 Foundations of Computing I
4b Lexical analysis Finite Automata
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)
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.
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.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
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.
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.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
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.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
Lecture Notes 
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
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.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
Nondeterminism The Chinese University of Hong Kong Fall 2011
NFAε - NFA - DFA equivalence
Lexical analysis Finite Automata
Non Deterministic Automata
Theory of Computation Lecture # 9-10.
Nondeterministic Finite Automata
Chapter 2 FINITE AUTOMATA.
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Non-Deterministic Finite Automata
Principles of Computing – UFCFA3-30-1
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Nondeterministic Finite Automata
Non Deterministic Automata
CSE 311: Foundations of Computing
NFA TO DFA.
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
CS21 Decidability and Tractability
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
CSE 311 Foundations of Computing I
Chapter 1 Regular Language
CHAPTER 1 Regular Languages
Non Deterministic Automata
Nondeterminism The Chinese University of Hong Kong Fall 2010
Part Two : Nondeterministic Finite Automata
Presentation transcript:

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. From q 0 with 1 we can be either in q 0 or q 1. No outgoing arrows under 0 or 1 from q 1. q0q0 q1q1 1 0,1

What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol. A DFA is by definition an NFA (each state has exactly one outgoing arrow under each symbol). q0q0 q1q1 1 0,1

What is an NFA ε An NFA ε is an NFA that might have ε-moves. In an ε-move we can transport from one state to the other without having any symbols. From q 0 with 1 we can be either in q 0 or q 2. q0q0 q1q1 1 ε q2q2 1

What is an NFA ε An NFA ε is an NFA that might have ε-moves. In an ε-move we can transport from one state to the other without having any symbols. An NFA is by definition an NFA ε (but with no ε- moves). q0q0 q1q1 1 ε q2q2 1

NFA – NFA ε computation An Non-Deterministic FA can have choices. If there are two possible transitions under a specific symbol, it can choose either of them and follow it. Given some input string, there might be more than one paths to follow. Some of them might fail but, in order to accept, it suffices to find one that succeeds.

NFA – NFA ε computation An Non-Deterministic Finite Automaton accepts an input string s if there exists a path following transitions under the symbols of s consecutively, that leads to an accepting state.

Example This automaton accepts the string 1110 because there is a path under 1110 that takes us to an accepting state (the path q 0 → 1 q 0 → 1 q 0 → 1 q 0 → 0 q 1 ). q0q0 q1q , 1

Example This automaton accepts the string 1110 because there is a path under 1110 that takes us to an accepting state (the path q 0 → 1 q 0 → 1 q 0 → 1 q 0 → 0 q 1 ). q0q0 q1q , 1

Example This automaton accepts the string 1110 because there is a path under 1110 that takes us to an accepting state (the path q 0 → 1 q 0 → 1 q 0 → 1 q 0 → 0 q 1 ). q0q0 q1q , 1

Example This automaton accepts the string 1110 because there is a path under 1110 that takes us to an accepting state (the path q 0 → 1 q 0 → 1 q 0 → 1 q 0 → 0 q 1 ). q0q0 q1q , 1

Example This automaton accepts the string 1110 because there is a path under 1110 that takes us to an accepting state (the path q 0 → 1 q 0 → 1 q 0 → 1 q 0 → 0 q 1 ). q0q0 q1q , 1

Example And that is so despite the fact that there are some other paths under 1110 which do not lead to an accepting state (for example the path q 0 → 1 q 0 → 1 q 0 ). q0q0 q1q , 1

Example And that is so despite the fact that there are some other paths under 1110 which do not lead to an accepting state (for example the path q 0 → 1 q 0 → 1 q 0 ). q0q0 q1q , 1

Example And that is so despite the fact that there are some other paths under 1110 which do not lead to an accepting state (for example the path q 0 → 1 q 0 → 1 q 0 ). q0q0 q1q , 1

Example However it doesn’t accept the string 00 because there are no paths under 00 to take us to q 1. (only possible path is q 0 → 0 q 1 → 0 q 0 ). q0q0 q1q , 1

Example However it doesn’t accept the string 00 because there are no paths under 00 to take us to q 1. (only possible path is q 0 → 0 q 1 → 0 q 0 ). q0q0 q1q , 1

Example However it doesn’t accept the string 00 because there are no paths under 00 to take us to q 1. (only possible path is q 0 → 0 q 1 → 0 q 0 ). q0q0 q1q , 1

NFA - NFA ε acceptance The language that a Non–Deterministic FA recognizes is the set of strings which accepts. To see whether a string can get accepted or not, it suffices to find the set of all possible states in which the automaton can be following all possible transitions suggested by this string as an input and see if a final state is contained in this set.

NFA acceptance Whenever an arrow is followed, there is a set of possible following states that the NFA can be. This set of states is a subset of Q. For example with input being 0010 I have the following sequence of sets of states: q0q0 q1q1 1 0,1 0 q2q2 0

Is NFA more powerful than DFA? Designing an NFA is sometimes mush easier than constructing a DFA. For example, the following NFA recognizes the language of all binary strings that end with 010. q0q0 q1q1 q2q2 q3q3 0 0,1 01

NFA – DFA equivalence It is obvious that a DFA is also an NFA. Somebody would expect the NFA to be more powerful. We will see that this is not the case!

NFA – DFA equivalence An NFA might have more than one or no transitions under some symbol of the alphabet. q q’ q’’ a a

NFA – DFA equivalence An NFA might have more than one or no transitions under some symbol of the alphabet. I can simulate all possible transitions in one new state. This state should contain all the reachable states under the same symbol. q q’ q’’ a a q q’ q’’ a

NFA – DFA equivalence The new DFA can possibly contain one state for each subset of states of the NFA. Since all the subsets of Q are 2 |Q| in total, this should be a finite (≤ 2 |Q| ) number of subsets! The NFA accepts if there is at least one path that takes us to an accepting state. Thus, each subset-state of the DFA containing an accepting state of the NFA should be an accepting one.

NFA → DFA Suppose that you want to find an equivalent DFA for an NFA. The algorithm is the following: Starting from the start state and for each symbol in the alphabet, find the subset of states that can be reached after following this symbol and create a new state for each subset.

NFA → DFA Suppose that you want to find an equivalent DFA for an NFA. The algorithm is the following: Repeat the same process for every new subset-state that you are creating…

NFA → DFA Suppose that you want to find an equivalent DFA for an NFA. The algorithm is the following: Repeat the same process for every new subset-state that you are creating… … until no new subset-state can be created.

NFA – DFA equivalence (example) To find an equivalent DFA to the NFA of the figure we complete the following table: 01 q0q0 {q 1 }{q 0, q 1 } {q 1 }{q 0, q 2 } {q 0, q 1 }{q 0, q 1, q 2 }{q 0, q 1 } {q 0, q 2 }{q 1 }{q 0, q 1 } {q 0, q 1, q 2 } {q 0, q 1 } q0q0 q1q1 1 0,1 0 q2q2 0

q 01 q 02 q0q0 q1q1 q ,1 0 1 NFA – DFA equivalence (example) So the DFA is: 01 q0q0 {q 1 }{q 0, q 1 } {q 1 }{q 0, q 2 } {q 0, q 1 }{q 0, q 1, q 2 }{q 0, q 1 } {q 0, q 2 }{q 1 }{q 0, q 1 } {q 0, q 1, q 2 } {q 0, q 1 }

NFA ε – NFA equivalence An NFA ε is an NFA which might have ε-moves. Again, somebody would think that this attribute can make NFA ε more powerful than NFA. This is not the case since I can get rid of the ε-moves.

NFA ε – NFA equivalence Suppose that I have an ε-move like the one shown in the figure. Since an ε-move is like teleporting from q 1 to q 2, I can remove the ε-move and add transitions from q 1 directly to every neighbor of q 2. q1q1 q2q2 q4q4 q5q5 q3q3 q1q1 q4q4 q5q5 q3q3 q2q2 1 ε

NFA ε – NFA equivalence If an ε-move takes me from q 1 to q 2 and q 2 is an accepting state, then, when removing the ε-move, I should convert q 1 to an accepting state. q1q1 q2q2 ε q4q4 0 q1q1 0 q2q2 q4q4 0

Example q1q1 q2q2 q0q0 q3q3 1,ε 0,ε 1 1 q4q4 1 0

Example q1q1 q2q2 q0q0 q3q3 1,ε 0,ε 1 1 q4q4 1 0

Example q1q1 q2q2 q0q0 q3q3 1,ε 0,ε 1 1 q4q4 1 0 q1q1

Example q2q2 q4q4 q0q0 q3q ,ε q1q1

Example q1q1 q2q2 q4q4 q0q0 q3q ,ε

Example q1q1 q2q2 q4q4 q0q0 q3q ,ε ,10,1

Example q1q1 q2q2 q4q4 q0q0 q3q ,ε ,1

Example q1q1 q2q2 q4q4 q0q0 q3q ,10, ,1

Example q1q1 q2q2 q4q4 q0q0 q3q ,