Non-Deterministic Finite Automata

Slides:



Advertisements
Similar presentations
Regular operations Sipser 1.1 (pages 44 – 47). CS 311 Fall Building languages If L is a language, then its complement is L’ = {w | w ∉ L} Let A.
Advertisements

CS 3240: Languages and Computation
CS2303-THEORY OF COMPUTATION
4b Lexical analysis Finite Automata
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)
Introduction to Computability Theory
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 Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
Finite Automata and Non Determinism
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.
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)
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)
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.
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.
CHAPTER 1 Regular Languages
CMSC 330: Organization of Programming Languages Finite Automata NFAs  DFAs.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
using Deterministic Finite Automata & Nondeterministic Finite Automata
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
Deterministic Finite Automata Nondeterministic Finite Automata.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
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.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Lexical analysis Finite Automata
Non Deterministic Automata
FORMAL LANGUAGES AND AUTOMATA THEORY
Nondeterministic Finite Automata
Chapter 2 FINITE AUTOMATA.
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Nondeterministic Finite Automata
Non Deterministic Automata
Finite Automata.
4b Lexical analysis Finite Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
4b Lexical analysis Finite Automata
CSCI 2670 Introduction to Theory of Computing
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
CSE 105 theory of computation
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CSE 105 theory of computation
CSCI 2670 Introduction to Theory of Computing
Part Two : Nondeterministic Finite Automata
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

Non-Deterministic Finite Automata

HM2 samples Question ID 74: Examine the following DFA: 1. 1.   Question ID 74: Examine the following DFA:                                                                      Identify in the list below the string that this automaton accepts. Details   2.   Question ID 75: The finite automaton below: accepts no word of length zero, no word of length one, and only two words of length two (01 and 10). There is a fairly simple recurrence equation for the number N(k) of words of length k that this automaton accepts. Discover this recurrence and demonstrate your understanding by identifying the correct value of N(k) for some particular k. Note: the recurrence does not have an easy-to-use closed form, so you will have to compute the first few values by hand. You do not have to compute N(k) for any k greater than 14.

HM2 Samples Question ID 77: Which automata define the same language? 4.   Question ID 77: Which automata define the same language?                                                                                                                                                        Note: (b) and (d) use transitions on strings. You may assume that there are nonaccepting intermediate states, not shown, that are in the middle of these transitions, or just accept the extension to the conventional finite automaton that allows strings on transitions and, like the conventional FA accepts strings that are the concatenation of labels along any path from the start state to an accepting state. Details   5.   Question ID 78: Convert the following nondeterministic finite automaton:                                                                           to a DFA, including the dead state, if necessary. Which of the following sets of NFA states is not a state of the DFA that is accessible from the start state of the DFA?

Formal Definition of DFA A DFA consists of: Alphabet  A set of states Q A transition function δ : Q  Q One start state q0 One or more accepting states F  Q Language accepted by a DFA is the set of strings such that DFA ends at an accepting state Each string is c1c2…cn with ci   States are qi = δ(qi-1,ci ) for i=1…n qn is an accepting state

NFA and -NFA Nondeterministic Finite Automata  Same input may produce multiple paths Allows transition with an empty string or transition from one state to different states given a character q1 q2 1 q3 nondeterministic transition q1 q2  empty string transition

The Language Accepted by a NFA

EXAMPLE

Another Example Accept strings containing a 1 in the third position from the back 1 2 3 4 0,1 0, 1

RECAP: How does NFA work? Start in start state Read a symbol, clone a machine for each matching transition If a symbol is read and there is no way to exit from a state, then that machine dies At end of input if any machine accepts then accept

RECAP Definition: NFA An NFA is defined by a 5-tuple, with Alphabet  A set of states Q A transition function δ : Q Σ P(Q) One start state q0 One or more accepting states F  Q Notation: P(Q) is power set of Q What is the difference from DFA?

RECAP Nondeterministic Transition The function δ : Q Σ P(Q) is the key difference! When reading symbol `a’ while in state q, it may go to one of the states in δ(q,a)Q. Can δ(q,a) map to empty set?

RECAP Languages Language accepted by a NFA is the set of strings such that NFA ends at an accepting state Each string of language is c1c2…cn with ciΣ (possibly with ε) States are qi  δ(qi-1,ci) for i=1…n qn is an accepting state

RECAP DFA = NFA Theorem: For every language L accepted by an NFA, there is a DFA that accepts L. In other words, DFA and NFA are equivalent computational models. Proof idea: When keeping track of nondeterministic computation of NFA N, use many ‘fingers’ to point at the set of states of N that can be reached on a given input string. We can simulate this computation with a DFA M with state space P(Q).

Proof of DNA=NFA More formal proof: Let A be the language recognized by the NFA N = (Q,Σ,δ,q0,F). Define the DFA M = (Q’,Σ,δ’,q’0,F’) by Q’ = P(Q) δ’(R,a) = { qQ | qδ(r,a) for an rR } q’0 = { q0 } F’ = {RQ’ | R contains an accept state of N} 1 2 3 4 0,1 0, 1

How does NFA work? Start in start state If any  transitions, clone a machine for each  transition Read a symbol, clone a machine for each matching transition If a symbol is read and there is no way to exit from a state, then that machine dies At end of input if any machine accepts then accept

Example Accept strings containing either 101 or 11 as a substring 1 2 3 4 0,1 0, 

Example: Read: 010110 How would this NFA work? 1 2 3 4 0,1 0, 

Read: 010110 1 2 3 4

Definition: εNFA An NFA is defined by a 5-tuple, with Alphabet  A set of states Q A transition function δ : Q Σε P(Q) One start state q0 One or more accepting states F  Q Notation: Σε = Σ{ε}; P(Q) is power set of Q What is the difference from DFA?

Nondeterministic Transition The function δ : Q Σε P(Q) is the key difference! When reading symbol `a’ while in state q, it may go to one of the states in δ(q,a)Q. ε in Σε allows empty-string transitions Can δ(q,a) map to empty set?

Languages Language accepted by a NFA is the set of strings such that NFA ends at an accepting state Each string of language is c1c2…cn with ciΣε (possibly with ε) States are qi  δ(qi-1,ci) for i=1…n qn is an accepting state

The Golden Chain εNFA  NFA  DFA REGEX

EpsilonNFA NFA  DFA

Regular Expressions