Nondeterminism The Chinese University of Hong Kong Fall 2011

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.
Lecture 6 Nondeterministic Finite Automata (NFA)
Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
YES-NO machines Finite State Automata as language recognizers.
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.
61 Nondeterminism and Nodeterministic Automata. 62 The computational machine models that we learned in the class are deterministic in the sense that the.
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.
CSC 361Finite Automata1. CSC 361Finite Automata2 Formal Specification of Languages Generators Grammars Context-free Regular Regular Expressions Recognizers.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
Regular Expressions (RE) Empty set Φ A RE denotes the empty set Empty string λ A RE denotes the set {λ} Symbol a A RE denotes the set {a} Alternation M.
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.
Basics of automata theory
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.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Text search.
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.
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Theory of Computation Automata Theory Dr. Ayman Srour.
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.
NFAε - NFA - DFA equivalence
Non Deterministic Automata
Theory of Computation Lecture # 9-10.
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
Non Deterministic Automata
CS 350 — Fall 2018 gilray.org/classes/fall2018/cs350/
NFAs and Transition Graphs
Finite Automata.
NFAs, DFAs, and regular expressions
Chapter Five: Nondeterministic Finite Automata
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
Pushdown automata The Chinese University of Hong Kong Fall 2011
Text search and closure properties
NFAs and Transition Graphs
Non Deterministic Automata
Lexical Analysis Uses formalism of Regular Languages
Nondeterminism The Chinese University of Hong Kong Fall 2010
Presentation transcript:

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

Example from last time Construct a DFA over alphabet {0, 1} that accepts those strings that end in 101

Would be easier if… Suppose we could guess when the string we are reading has only 3 symbols left 1 1 3 symbols left 1 qdie This is not a DFA!

Nondeterministic finite automaton This is a machine that allows us 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

Choosing where to go State q0 has two transitions labeled 1 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

How to run an NFA input: 1 1 1 The NFA can have several active states , 1 1 1 q0 q1 q2 q3 input: 1 1 1 The NFA can have several active states at the same time It accepts if at the end, one of its active states is final

Example Construct an NFA over alphabet {0, 1} that accepts those strings that contain the pattern 001 somewhere 11001010, 001001, 111001 should be accepted e, 000, 010101 should not

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 NFA accepts string x Î S* if there is some path that, starting from q0, leads to an accepting state as the string is read left to right. The language of an NFA is the set of all strings that the NFA accepts.

e-transitions These can be taken for free: accepts:  q1 accepts:  a, b, aab, bab, aabab, … q0 a b rejects: a q2 , aa, ba, bb, …

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

Can you guess the language of this NFA? , 1  q0 q1 q2 Can you guess the language of this NFA?

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)