CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.

Slides:



Advertisements
Similar presentations
CSE 311 Foundations of Computing I
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.
Lecture 6 Nondeterministic Finite Automata (NFA)
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 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.
Finite Automata Section 1.1 CSC 4170 Theory of Computation.
Introduction to Computability Theory
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata 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
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
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.
Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Fall 2008.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
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)
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 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA minimization.
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.
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.
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.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
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.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NFA to DFA.
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
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NFA to.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
Lecture Notes 
CS 154 Formal Languages and Computability February 9 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
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
1 Lexical Analysis Uses formalism of Regular Languages Uses formalism of Regular Languages Regular Expressions Regular Expressions Deterministic Finite.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
1 Finite Automata. 2 Introductory Example An automaton that accepts all legal Pascal identifiers: Letter Digit Letter or Digit "yes" "no" 2.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Computation Automata Theory Dr. Ayman Srour.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Nondeterminism The Chinese University of Hong Kong Fall 2011
Non Deterministic Automata
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
More on DFA minimization and DFA equivalence
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Nondeterministic Finite Automata
Non Deterministic Automata
CSE 311: Foundations of Computing
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
Nondeterminism The Chinese University of Hong Kong Fall 2010
Presentation transcript:

CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism Fall 2008

Example from last time 0 1 … … … … qq qq qq q  q  q  q  q  q  q  q  Construct a DFA over alphabet {0, 1} that accepts those strings that end in 101 Sketch of answer:

Would be easier if… Suppose we could guess when the string we are reading has only 3 symbols left Then we could simply look for the sequence 101 and accept if we see it q die symbols left This is not a DFA!

Nondeterminism Nondeterminism is the ability to make guesses, which we can later verify Informal nondeterministic algorithm for language of strings that end in 101 : 1.Guess if you are approaching end of input 2.If guess is yes, look for 101 and accept if you see it 3.If guess is no, read one more symbol and go to step 1

Nondeterministic finite automaton This is a kind of automaton that allows you to make guesses Each state can have zero, one, or more transitions out labeled by the same symbol , 1 qq qq qq qq

Semantics of guessing , 1 qq qq qq qq State q 0 has two transitions labeled 1 Upon reading 1, we have the choice of staying in q 0 or moving to q 1

Semantics of guessing , 1 qq qq qq qq State q 1 has no transition labeled 1 Upon reading 1 in q 1, we die; upon reading 0, we continue to q 2

Semantics of guessing , 1 qq qq qq qq State q 3 has no transition going out Upon reading anything in q 3, we die

Meaning of automaton , 1 qq qq qq qq Guess if you are 3 symbols away from end of input If so, guess you will see the pattern 101 Check that you are at the end of input

Formal definition A nondeterministic finite automaton (NFA) is a 5-tuple (Q, , , q 0, F) where – Q is a finite set of states –  is an alphabet –  : Q ×  → subsets of Q is a transition function – q 0  Q is the initial state – F  Q is a set of accepting states (or final states). Only difference from DFA is that output of  is a set of states

Example , 1 qq qq qq qq alphabet  = {0, 1} start state Q = {q 0, q 1, q 2, q 3 } initial state q 0 accepting states F = {q 3 } states inputs 0 1 q0q0 q1q1 q2q2 {q 0, q 1 } transition function  q3q3 {q 0 } {q 2 }    {q 3 } 

Language of an NFA The language of an NFA is the set of all strings for which there is some path that, starting from the initial state, leads to an accepting state as the string is read left to right , 1 qq qq qq qq Example –1101 is accepted, but 0110 is not

NFAs are as powerful as DFAs Obviously, an NFA can do everything a DFA can do But can it do more?

NFAs are as powerful as DFAs Obviously, an NFA can do everything a DFA can do But can it do more? Theorem A language L is accepted by some DFA if and only if it is accepted by some NFA. NO!

Proof of theorem To prove the theorem, we have to show that for every NFA there is a DFA that accepts the same language We will give a general method for simulating any NFA by a DFA Let’s do an example first

Simulation example 1 0 0, 1 qq qq qq NFA: DFA: 1 qq q 0 or q 1 1 q 0 or q

General method NFADFA states q 0, q 1, …, q n  q 0 }, {q 1 }, {q 0,q 1 }, …, {q 0,…,q n } one for each subset of states in the NFA initial state q0q0 q0}q0} transitions  ’({q i1,…,q ik }, a) =  (q i1, a) ∪ … ∪  (q ik, a) accepting states F  Q F’ = {S: S contains some state in F}

Proof of correctness Lemma Proof by induction on n At the end, the DFA accepts iff it is in a state that contains some accepting state of NFA By lemma, this is true iff the NFA can reach an accepting state After reading n symbols, the DFA is in state {q i1,…,q ik } if and only if the NFA is in one of the states q i1,…,q ik

Exercises Construct NFAs for the following languages over the alphabet {a, b, …, z} : –All strings that contain eat or sea or easy –All strings that contain both sea and tea –All strings that do not contain fool