Transparency No. 3-1 Formal Language and Automata Theory Chapter 3 Nondeterministic Finite Automata (NFA) (include lecture 5 and 6)

Slides:



Advertisements
Similar presentations
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.
Advertisements

Lecture 24 MAS 714 Hartmut Klauck
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 Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions 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.
Transparency No. 2-1 Formal Language and Automata Theory Chapter 2 Deterministic Finite Automata (DFA) (include Lecture 3 and 4)
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.
Transparency No. P2C3-1 Formal Language and Automata Theory Chapter 3 Pushdown Automata and Context-Free Languages.
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
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.
Transparency No. P2C3-1 Formal Language and Automata Theory Chapter 3 Pushdown Automata and Context-Free Languages.
Transparency No. 4-1 Formal Language and Automata Theory Chapter 4 Patterns, Regular Expressions and Finite Automata (include lecture 7,8,9) Transparency.
Transparency No. P2C3-1 Formal Language and Automata Theory Chapter 3 Pushdown Automata and Context-Free Languages.
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.
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
Transparency No. ?-0 Formal Language and Automata Theory Chapter 6 Homomorphisms (lecture 10) Transparency No. 6-1.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
1 Non-Deterministic Automata Regular Expressions.
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.
Lecture 4UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 4.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
Transparency No. 8-1 Formal Language and Automata Theory Chapter 8 DFA state minimization (lecture 13, 14)
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,
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
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.
Transparency No. 3-1 Formal Language and Automata Theory Chapter 3 Nondeterministic Finite Automata (NFA)
1 Chapter 2 Finite Automata (part b) Windmills in Holland.
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.
NFA defined. NFA A Non-deterministic Finite-state Automata (NFA) is a language recognizing system similar to a DFA. It supports a level of non-determinism.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Transparency No. 4-1 Formal Language and Automata Theory Chapter 4 Patterns, Regular Expressions and Finite Automata (include lecture 7,8,9) Transparency.
Lecture Notes 
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
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.
Non Deterministic Automata
Chapter 2 Finite Automata
Chapter 2 FINITE AUTOMATA.
Hierarchy of languages
Principles of Computing – UFCFA3-30-1
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Finite Automata Reading: Chapter 2.
CSE 2001: Introduction to Theory of Computation Fall 2009
Instructor: Aaron Roth
Chapter 1 Regular Language
Finite-State Machines with No Output
Presentation transcript:

Transparency No. 3-1 Formal Language and Automata Theory Chapter 3 Nondeterministic Finite Automata (NFA) (include lecture 5 and 6)

Nondeterministic Finite Automata Transparency No. 3-2 Nondeterminism An important notions(or abstraction) in computer science refer to situations in which the next state of a computation is not uniquely determined by the current state. Ex: find a program to compute max(x,y): pr1: case x  y => print x; y  x => print y endcase; Then which branch will be executed when x = y ? ==> don't care nondeterminism Pr2: do-one-of { {if x < y fail; print x}, {if y < x fail, print y} }. ==>The program is powerful in that it will never choose branches that finally lead to ‘fail’ -- an unrealistic model. ==> don't know nondeterminism.

Nondeterministic Finite Automata Transparency No. 3-3 nondeterminism (cont'd) a nondeterministic sorting algorithm: nondet-sort(A, n) 1. for i = 1 to n do 2. nondeterministically let k := one of {i,..., n} ; 3. exchange A[i] and A[k] 4. endfor 5 for i = 1 to n-1 do if A[i] > A[i+1] then fail; 6. return(A). Notes: 1. Step 2 is magic in that it may produce many possible outcomes. However all incorrect results will be filtered out at step The program run in time NTIME O(n) cf: O(n lg n) is required for all sequential machines.

Nondeterministic Finite Automata Transparency No. 3-4 nondeterminism (cont'd) Causes of nodeterminism in real life: incomplete information about the state external forces affecting the course of the computation ex: the behavior of a process in a distributed system Nondeterministic programs cannot be executed directly but can be simulated by real machine. Nondeterminism can be used as a tool for the specification of problem solutions. an important tool in the design of efficient algorithms There are many problems with efficient nondeterministic algorithm but no known efficient deterministic one. the open problem NP = P ? How to make DFAs become nondeterministic ? ==> allow multiple transitions for each state-input-symbol pair ==> modify the transition function .

Nondeterministic Finite Automata Transparency No. 3-5 Formal Definition of NFAs A NFA is a five-tuple N = (Q, , ,S,F) where everything is the same as in a DFA, except: S  Q is a set of starting states, instead of a single state.  is the transition function  : Q x  -> 2 Q. For each state p and symbol a,  (p,a) is the set of all states that N is allowed to move from p in one step under input symbol a. diagrammatic notation: p --a--> q Note:  (p,a) can be the empty set The extended transition function  (multi-step version of  ) for NFA can be defined analogously to that of DFAs:  : 2 Q x  * -> 2 Q is defined inductively as follows: 1. Basis:  (A,  ) = ______ for every set of states A (6.1) 2. Ind. case:  (A, xa) = ____ for every x ∈  * and a ∈ . (6.2) Note: Intuitively q   (A,x) means q can be reached from some state  A after scanning input string x. pq a

Nondeterministic Finite Automata Transparency No. 3-6 Languages accepted by NFAs Note: Like DFAs, the extended transition function  on a NFA N is uniquely determined by N. pf: left as an exercise. N = (Q, , ,S,F) : a NFA;x: any string over  ;  : the extended transition function of N. 1. x is said to be accepted by N if  (S,x)  F  {} i.e., x is accepted if there is an accept state q  F such that q is reachable from a start state under input string x (i.e., q   (S,x)) 2. The set (or language) accepted by N, denoted L(N), is the set of all strings accepted by N. i.e., L(N) = def {x   * | N accepts x }. 3. Two finite automata (FAs, no matter deterministic or nondeterministic) M and N are said to be equivalent if L(M) = L(N).

Nondeterministic Finite Automata Transparency No. 3-7 Equivalence of FAs Note: under such definition, every DFA M = (Q, , ,s,F) is equivalent to an NFA N = (Q, ,  ',{s},F) where  '(p,a) = {  (p,a)} for every state p and input a. Problem: Does the converse hold as well ? i.e. For every NFA N there is a DFA M s.t. L(M) = L(N). Ans: ____

Nondeterministic Finite Automata Transparency No. 3-8 Some examples of NFAs Ex: Find a NFA accepting A = { x  {0,1}* | the fifth symbol from the right is 1 } = {010000, 11111,...}. Sol: 1. (in diagram form) 2: tabular form: 3. tuple form: (Q, , ,S,F) = (__,__,__,__,__). 1 0,1

Nondeterministic Finite Automata Transparency No. 3-9 Example of strings accepted by NFAs Note: there are many possible computations on the input string: , some of which reach the (only) final state (accepted or successful computation), some of which do not (fail). Since there exists an accepted computation, by definition, the string is accepted by the machine 1 0, (accept) (fail)

Nondeterministic Finite Automata Transparency No Some properties about the extended transition function  Lem 6.1:  (A,xy) =  (  (A,x),y). pf: by induciton on |y|: 1. |y| = 0 =>  (A,x  ) =  (A,x) =  (  (A,x),  ) -- (6.1). 2. y = zc =>  (A,xzc) = U q   (A,xz)  (q,c) -- (6.2) = U q  (  (A,x),z)  (q,c)-- ind. hyp. =  (  (A,x),zc)-- (6.2) Lem 6.2  commutes with set union: i.e.,  (U i  I A i,x) = U i  I  (A i,x). in particular,  (A,x) = U p  A  ({p},x) pf: by ind. on |x|. Let B = U i  I A i 1. |x|= 0 =>  (U i  I A i,  ) = U i  I A i = U i  I  (A i,  ) -- (6.1) 2. x = ya =>  (U i  I A i, ya) = U p   (B,y)  (p,a) -- (6.2) = U p  U i  I  (Ai,y)  (p,a) -- ind. hyp. = U i  I U p   (Ai,x)  (P,a) -- set theory = U i  I  (A i,ya) (6.2)

Nondeterministic Finite Automata Transparency No The subset construction N = (Q N, ,  N,S N,F N ) : a NFA. M = (Q M, ,  M,s M,F M ) (denoted 2 N ): a DFA where Q M = 2 Q N  M (A,a) =  N (A,a) ( = ⋃ q ∈ A  N (q,a) ) for every A  Q N. s M = S N and F M = {A  Q N | A  F N  {}}. note: States of M are subsets of states of N. Lem 6.3: for any A  Q N. and x in  *,  M (A,x) =  N (A,x). pf: by ind on |x|. if x =  =>  M (A,  ) = A =  N (A,  ). --(def) if x = ya =>  M (A,ya) =  M (  M (A,y),a) -- (def) =  M (  N (A,y),a) -- ind. hyp. =  N (  N (A,y),a) -- def of  M =  N (A, ya) -- lem 6.1 Theorem 6.4: M and N accept the same set. pf: x  L(M) iff  M (s M,x)  F M iff  N (S N,x)  F N  {} iff x  L(N).

Nondeterministic Finite Automata Transparency No Equivalence of NFAs and DFAs - an example 1. NFA N accepting A = { x  {0,1}* | the second symbol from the right is 1 } = {x1a | x  {0,1}* and a  {0,1} }. sol: 2. DFA M equivalent to N is given as : 3. some states of M are redundant in the sense that they are never reachable from the start state and hence can be removed from the machine w/o affecting the languages accepted. 10,1 pqr {}{}{} ->{p}{p}{p,q} {q}{r}{r} {r}F{}{} {p,q}{p,r}{p,q,r} {p,r}F{p}{p,q} {q,r}F{r}{r} {p,q,r}F {p,r}{p,q,r}

Nondeterministic Finite Automata Transparency No  -transition Another extension of FAs, useful but adds no more power. An  -transition is a transition with label , a label standing for the empty string . The FA can take such a transition anytime w/o reading an input symbol. Ex 6.5 : The set accepted by the FA is {b,bb,bbb}. Ex 6.6 : A NFA-  accepting the set {x ∈ {a}* | |x| is dividable by 3 or 5 }. real advantage of  -transition: convenient for specification add no extra power pq  s qp tu r b bb    Ex6.5

Nondeterministic Finite Automata Transparency No NFA-  N = (Q, , ,S,F) : a NFA- ,where Q, S, S and F are the same as NFA,  : Q x (  U {  }) -> 2 Q. The set Eclosure(A) is the set of ref. and transitive closure of the  -transition of A = { q ∈ Q | ∃  -path p – p 1 – p 2 … -p n with p ∈ A and p n = q } Note: Eclosure(A) (abbreviated as EC(A) ) = EC(EC(A)). The multistep version of  is modified as follows:  : 2 Q x  *  2 Q where, for all A ⊆ Q, y ∈  *, a ∈ A  (A,  ) = Eclosure(A)  (A, ya) = U p ∈  (A,y) Eclosure(  (p,a) ) L(N) = { x |  (S, x)  F  {} } // The language accepted by N = {x |  (EC(S), x)  F  {} }

Nondeterministic Finite Automata Transparency No E-closure Eclosure(A) is the set of states reachable from states of A without consuming any input symbols, (i.e., q ∈ Eclosure(A) iff ∃ p ∈ A s.t. q ∈  (p,  k ) for some k ≥ 0 ). Eclosure(A) can be computed as follows: 1. R=F={}; nF=A; //F: frontier; nF: new frontier 2. do { R = R U nF; F = nF; F={}; 3. For each q ∈ F do 4. nF  = nF U (  (q,  )- R) 5. }while nF ≠ {}; 6. return R Note:1. q ∈  (A,  k ) => q ∈ R after k-th iteration of the program. 2. We can precompute the matricx T* where T is the e-transition matrix of the NFA. and use the result to get Eclosure(A) for all required As.

Nondeterministic Finite Automata Transparency No The subset construction for NFA-  N = (Q N, ,  N,S N,F N ) : a NFA- .where  N : Q x (  U {  }) -> 2 Q. M = (Q M, ,  M,s M,F M ) (denoted 2 N ): a DFA where Q M = { EC(A) | A  Q N }  M (A,a) = ⋃ q ∈ Ec(A) EC(  N (q,a)) for every A ∈ Q M. s M = EC(S N ) and F M = {A  Q M | A  F N  {}}. note: States of M are subsets of states of N. Lem 6.3: for any A  Q N. and x ∈  *,  M (A,x) =  N (A,x). pf: by ind on |x|. if x =  =>  M (A,  ) = A =EC(A) =  N (A,  ). --(def) if x = ya =>  M (A,ya) =  M (  M (A,y),a) -- (def) =  M (  N (A,y),a) -- ind. hyp. = U q ∈  N(A,y) EC(  N (q,a)) -- def of  M =  N (A, ya) – def of  N Theorem 6.4: M and N accept the same set. pf: x  L(M) iff  M (s M,x)  F M iff  N (EC(S N ),x)  F N  {} iff x  L(N).

Nondeterministic Finite Automata Transparency No More closure properties If A and B are regular languages, then so are AB and A*. M = (Q 1, ,  1,S 1,F 1 ), N=(Q 2, ,  2,S 2,F 2 ) : two NFAs The machine M  N, which firstly executes M and then execute N, can be defined as follows: M  N = def (Q, , d, S, F) where Q = disjoint union of Q 1 and Q 2, S = S 1, F = F 2,  =  1 U  2 U { (p, , q ) | p  F 1 and q  S 2 } Lem: 1. x  L(M) and y  L(N) then xy  L(MN) 2. x  L(MN) =>  y,z s.t. x = yz and y  L(M) and z  L(N). Corollary: L(MN) = L(M) L(N)

Nondeterministic Finite Automata Transparency No M* machine M = (Q 1, ,  1,S 1,F 1 ) : a NFA The machine M*, which executes M a nondeterministic number of times, can be defined as follows: M* = def (Q, , , S, F) where Q = Q U {s,f}, where s and f are two new states  Q S = {s}, F = {f},  =  1 U {(s, , f)} U {(s, ,p) | p  S 1 } U {(q, ,s) | q  F 1 } Theorem: L(M*) = L(M)*     