Nondeterminism The Chinese University of Hong Kong Fall 2010

Slides:



Advertisements
Similar presentations
NFAε - NFA - DFA equivalence
Advertisements

CS 3240: Languages and Computation
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 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.
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.
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.
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.
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.
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.
Finite Automata Costas Busch - RPI.
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.
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.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NFA to DFA.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Finite Automata – Definition and Examples Lecture 6 Section 1.1 Mon, Sep 3, 2007.
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.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA minimization.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Lecture Notes 
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Deterministic Finite Automata Nondeterministic Finite Automata.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
Theory of Computation Automata Theory Dr. Ayman Srour.
  An alphabet is any finite set of symbols.  Examples: ASCII, Unicode, {0,1} ( binary alphabet ), {a,b,c}. Alphabets.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Languages and Automata By: Mojtaba Khezrian.
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.
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
NFAε - NFA - DFA equivalence
More variants of Turing Machines
Non Deterministic Automata
G. Pullaiah College of Engineering and Technology
Nondeterministic Finite Automata
Finite Automata & Regular Languages
Chapter 2 FINITE AUTOMATA.
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
More on DFA minimization and DFA equivalence
Non-Deterministic Finite Automata
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Nondeterministic Finite Automata
Non Deterministic Automata
Finite Automata.
NFAs, DFAs, and regular expressions
Chapter Five: Nondeterministic Finite Automata
CS21 Decidability and Tractability
NFA to DFA conversion and regular expressions
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
Pushdown automata The Chinese University of Hong Kong Fall 2011
Formal Languages and Automata Theory BODDEDA HARITHA LAKSHMI,
Non Deterministic Automata
Lexical Analysis Uses formalism of Regular Languages
Presentation transcript:

Nondeterminism The Chinese University of Hong Kong Fall 2010 CSC 3130: Formal languages and automata theory Nondeterminism Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130

Example Construct a DFA over alphabet {0, 1} that accepts those strings that end in 101 Sketch of answer: q000 1 q00 1 q001 q0 1 … q01 … qe 1 q101 q10 … 1 q1 … 1 q11 1 q111 1

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 1 1 3 symbols left 1 qdie This is not a DFA!

Nondeterminism Nondeterminism is the ability to make guesses, which we can later verify How a nondeterministic automaton for strings that end in 101 works: Guess if you are approaching end of input If guess is yes, look for 101 and accept if you see it 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 outgoing transitions labeled by the same symbol 0, 1 1 1 q0 q1 q2 q3

The ability to make choices 0, 1 1 1 q0 q1 q2 q3 State q0 has two transitions labeled 1 Upon reading 1, we have the choice of staying in q0 or moving to q1

The ability to make choices 0, 1 1 1 q0 q1 q2 q3 State q1 has no transition labeled 1 Upon reading 1 in q1, we die; upon reading 0, we continue to q2

The ability to make choices 0, 1 1 1 q0 q1 q2 q3 State q3 has no transition going out Upon reading 0 or 1 in q3, we die

Meaning of NFA Guess if you are 3 symbols away from end of input 0, 1 1 1 q0 q1 q2 q3 If so, guess you will see the pattern 101 Check that you are at the end of input

The NFA can have several active states How to run an NFA , 1 1 1 q0 q1 q2 q3 input: 1 1 1 The NFA can have several active states at the same time

Example Construct an NFA over alphabet {0, 1} that accepts those strings that contain the pattern 001

Example Construct an NFA over alphabet {0, 1} that accepts those strings that contain the pattern 001 somewhere Answer 0, 1 0, 1 1 q0 q1 q2 q3

Definition A nondeterministic finite automaton (NFA) is a 5-tuple (Q, S, d, q0, F) where Q is a finite set of states S is an alphabet d: Q × (S ∪ {e}) → subsets of Q is a transition function q0 Î Q is the initial state F Í Q is a set of accepting states (or final states). Differences from DFA: transition function d can go into several states It allows e-transitions

Language of an NFA The language of an NFA is the set of all strings for which there is some path that, starting from q0, leads to an accepting state as the string is read left to right (and e-transitions are taken for free). Example e, 00, 001, 101 are accepted, but 11, 0110 are not , 1  q0 q1 q2

Example table of transition function d: alphabet S = {0, 1} , 1  q0 q1 q2 table of transition function d: alphabet S = {0, 1} states Q = {q0, q1, q2} initial state q0 accepting states F = {q2} inputs 1  q0 Æ {q1} {q1} q1 {q0, q1} Æ {q2} states q2 Æ Æ Æ

Examples e 00 or or , 1  q0 q1 q2 , 1  q0 q1 q2 , 1  q0 q1 q2 , 1 1 e  2 q0 q1 q2 2 3 , 1 1 00  q0 q1 4 q2 2 , 1 1 4 or  q0 q1 5 q2 3 , 1 1 3 or  q0 q1 5 q2 2 4

Examples 001 101 11  , 1  q0 q1 q2 , 1  q0 q1 q2 , 1  q0 q1 q2  , 1 1 4 001  5 q0 q1 q2 3 , 1 1 3  101 q0 q1 4 q2 2 , 1 1  11 q0 q1 q2 STOP , 1 1  q0 q1 2 q2 STOP

Example of e-transitions Construct an NFA that accepts all strings with an even number of 0s or an odd number of 1s r0 r1 1 even number of 0s q0  e-transitions s0 s1 1 odd number of 1s can be taken for free (without reading input)