Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.

Slides:



Advertisements
Similar presentations
Lecture # 11 Theory Of Automata By Dr. MM Alam 1.
Advertisements

Lecture 9,10 Theory of AUTOMATA
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.
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.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
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.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
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.
Finite-State Machines with No Output
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Kleene’s Theorem Group No. 3 Presented To Mam Amina Presented By Roll No Roll No Roll No Roll No Group No. 3 Presented To Mam.
CHAPTER 1 Regular Languages
1 Recap lecture 27 Pumping lemma version II, proof, examples, Myhill Nerode theorem, examples.
Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}
Lecture 4 Theory of AUTOMATA
Lecture 04: Theory of Automata:08 Transition Graphs.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
1 Recap lecture 28 Examples of Myhill Nerode theorem, Quotient of a language, examples, Pseudo theorem: Quotient of a language is regular, prefixes of.
Lecture 09: Theory of Automata:2014 Asif NawazUIIT, PMAS-Arid Agriclture University Rawalpindi. Kleene’s Theorem and NFA.
L ECTURE 3 T HEORY OF AUTOMATA. E QUIVALENT R EGULAR E XPRESSIONS Definition Two regular expressions are said to be equivalent if they generate the same.
Lecture 2 Compiler Design Lexical Analysis By lecturer Noor Dhia
Lecture # 8 (Transition Graphs). Example Consider the language L of strings, defined over Σ={a, b}, having (containing) triple a or triple b. Consider.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Lecture # 16. Applications of Incrementing and Complementing machines 1’s complementing and incrementing machines which are basically Mealy machines are.
Lecture 15: Theory of Automata:2014 Finite Automata with Output.
Recap lecture 5 Different notations of transition diagrams, languages of strings of even length, Odd length, starting with b, ending in a (with different.
Kleene’s Theorem and NFA
Non Deterministic Automata
Pushdown Automata.
Lecture 9 Theory of AUTOMATA
Chapter 2 FINITE AUTOMATA.
Non-deterministic Finite Automata (NFA)
Recap lecture 29 Example of prefixes of a language, Theorem: pref(Q in R) is regular, proof, example, Decidablity, deciding whether two languages are equivalent.
Non-Deterministic Finite Automata
Kleene’s Theorem Muhammad Arif 12/6/2018.
NFAs and Transition Graphs
Recap lecture 6 Language of strings, beginning with and ending in different letters, Accepting all strings, accepting non-empty strings, accepting no string,
Recap Lecture 16 Examples of Kleene’s theorem part III (method 3), NFA, examples, avoiding loop using NFA, example, converting FA to NFA, examples, applying.
Lecture 5 Theory of AUTOMATA
Recap lecture 10 Definition of GTG, examples of GTG accepting the languages of strings:containing aa or bb, beginning with and ending in same letters,
CSC312 Automata Theory Transition Graphs Lecture # 9
Recap lecture 37 New format for FAs, input TAPE, START, ACCEPT , REJECT, READ states Examples of New Format of FAs, PUSHDOWN STACK , PUSH and POP states,
Lecture # 13.
Recap Lecture 17 converting NFA to FA (method 3), example, NFA and Kleene’s theorem method 1, examples, NFA and Kleene’s theorem method 2 , NFA corresponding.
Recap lecture 11 Proof of Kleene’s theorem part II (method with different steps), particular examples of TGs to determine corresponding REs.
Recap lecture 25 Intersection of two regular languages is regular, examples, non regular languages, example.
Recap lecture 19 NFA corresponding to Closure of FA, Examples, Memory required to recognize a language, Example, Distinguishing one string from another,
RECAP Lecture 7 FA of EVEN EVEN, FA corresponding to finite languages(using both methods), Transition graphs.
Recap lecture 23 Mealy machines in terms of sequential circuit.
Recap Lecture 15 Examples of Kleene’s theorem part III (method 3), NFA, examples, avoiding loop using NFA, example, converting FA to NFA, examples, applying.
Recap lecture 40 Recap of example of PDA corresponding to CFG, CFG corresponding to PDA. Theorem, HERE state, Definition of Conversion form, different.
NFAs and Transition Graphs
Recap Lecture 4 Regular expression of EVEN-EVEN language, Difference between a* + b* and (a+b)*, Equivalent regular expressions; sum, product and closure.
Recap Lecture 3 RE, Recursive definition of RE, defining languages by RE, { x}*, { x}+, {a+b}*, Language of strings having exactly one aa, Language of.
LECTURE # 07.
Mealy and Moore Machines
Presentation transcript:

Lecture # 12

Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label of transitions. An NFA is a collection of three things Definition: An NFA is a TG with a unique start state and a property of having single letter as label of transitions. An NFA is a collection of three things 1) Finite many states with one initial and some final states 1) Finite many states with one initial and some final states 2) Finite set of input letters, say, Σ ={a, b, c} 2) Finite set of input letters, say, Σ ={a, b, c} 3) Finite set of transitions, showing where to move if a letter is input at certain state (Λ is not a valid transition), there may be more than one transition for certain letters and there may not be any transition for certain letters. 3) Finite set of transitions, showing where to move if a letter is input at certain state (Λ is not a valid transition), there may be more than one transition for certain letters and there may not be any transition for certain letters.

Observations It may be observed, from the definition of NFA, that the string is supposed to be accepted, if there exists at least one successful path, otherwise rejected. It may be observed, from the definition of NFA, that the string is supposed to be accepted, if there exists at least one successful path, otherwise rejected. It is to be noted that an NFA can be considered to be an intermediate structure between FA and TG. It is to be noted that an NFA can be considered to be an intermediate structure between FA and TG. The examples of NFAs can be found in the following The examples of NFAs can be found in the following

Example It is to be noted that the above NFA accepts the language consisting of a and ab. It is to be noted that the above NFA accepts the language consisting of a and ab.

Example It is to be noted that the above NFA accepts the language of strings, defined over Σ = {a, b}, containing aa. It is to be noted that the above NFA accepts the language of strings, defined over Σ = {a, b}, containing aa.

Note It is to be noted that NFA helps to eliminate a loop at certain state of an FA. It is to be noted that NFA helps to eliminate a loop at certain state of an FA. This process is done converting the loop into a circuit. But during this process the FA remains no longer FA and is converted to a corresponding NFA, which is shown in the following example. This process is done converting the loop into a circuit. But during this process the FA remains no longer FA and is converted to a corresponding NFA, which is shown in the following example.

Example Consider a part of the following FA with an alphabet Σ={a,b,c,d} Consider a part of the following FA with an alphabet Σ={a,b,c,d} To eliminate the loop at state 7, the corresponding NFA may be as follows To eliminate the loop at state 7, the corresponding NFA may be as follows

Example continued...

Converting an FA to an equivalent NFA It is to be noted that according to the Kleene’s theorem, if a language can be accepted by an FA, then there exists a TG accepting that language. Since, an NFA is a TG as well, therefore there exists an NFA accepting the language accepted by the given FA. It is to be noted that according to the Kleene’s theorem, if a language can be accepted by an FA, then there exists a TG accepting that language. Since, an NFA is a TG as well, therefore there exists an NFA accepting the language accepted by the given FA. In this case these FA and NFA are said to be equivalent to each others. Following are the examples of FAs to be converted to the equivalent NFAs In this case these FA and NFA are said to be equivalent to each others. Following are the examples of FAs to be converted to the equivalent NFAs

Example Consider the following FA corresponding to (a+b)*b Consider the following FA corresponding to (a+b)*b The above FA may be equivalent to the following NFA The above FA may be equivalent to the following NFA Can the structure of above NFA be compared with the corresponding RE ? Can the structure of above NFA be compared with the corresponding RE ?

Example Consider the following FA Consider the following FA The above FA may be equivalent to the following NFA The above FA may be equivalent to the following NFA Can the structure of above NFA be compared with the corresponding RE ? Can the structure of above NFA be compared with the corresponding RE ?

Task Build an NFA equivalent to the following FA Build an NFA equivalent to the following FA

Note It is to be noted that every FA can be considered to be an NFA as well, but the converse may not true. It is to be noted that every FA can be considered to be an NFA as well, but the converse may not true. It may also be noted that every NFA can be considered to be a TG as well, but the converse may not true. It may also be noted that every NFA can be considered to be a TG as well, but the converse may not true. It may be observed that if the transition of null string is also allowed at any state of an NFA then what will be the behavior in the new structure. This structure is defined in the following It may be observed that if the transition of null string is also allowed at any state of an NFA then what will be the behavior in the new structure. This structure is defined in the following

NFA with Null String Definition: If in an NFA, Λ is allowed to be a label of an edge then the NFA is called NFA with Λ (NFA- Λ ). An NFA- Λ is a collection of three things Definition: If in an NFA, Λ is allowed to be a label of an edge then the NFA is called NFA with Λ (NFA- Λ ). An NFA- Λ is a collection of three things (1) Finite many states with one initial and some final states. (1) Finite many states with one initial and some final states. (2) Finite set of input letters, say, Σ ={a, b, c}. (2) Finite set of input letters, say, Σ ={a, b, c}. (3) Finite set of transitions, showing where to move if a letter is input at certain state. There may be more than one transitions for certain letter and there may not be any transition for a certain letter. The transition of Λ is also allowed at any state. (3) Finite set of transitions, showing where to move if a letter is input at certain state. There may be more than one transitions for certain letter and there may not be any transition for a certain letter. The transition of Λ is also allowed at any state.

Example Consider the following NFA with Null string Consider the following NFA with Null string The above NFA with Null string accepts the language of strings, defined over Σ = {a, b}, ending in b. The above NFA with Null string accepts the language of strings, defined over Σ = {a, b}, ending in b.

Example Consider the following NFA with Null string Consider the following NFA with Null string The above NFA with Null string accepts the language of strings, defined over Σ = {a, b}, ending in a. The above NFA with Null string accepts the language of strings, defined over Σ = {a, b}, ending in a.

Task Determine the regular expression of the following NFA-Λ Determine the regular expression of the following NFA-Λ

Note It is to be noted that every FA may be considered to be an NFA- Λ as well, but the converse may not true. It is to be noted that every FA may be considered to be an NFA- Λ as well, but the converse may not true. Similarly every NFA- Λ may be considered to be a TG as well, but the converse may not true. Similarly every NFA- Λ may be considered to be a TG as well, but the converse may not true.

NFA to FA Two methods are discussed in this regard. Two methods are discussed in this regard. Method 1: Since an NFA can be considered to be a TG as well, so a RE corresponding to the given NFA can be determined (using Kleene’s theorem). Again using the methods discussed in the proof of Kleene’s theorem, an FA can be built corresponding to that RE. Hence for a given NFA, an FA can be built equivalent to the NFA. Examples have, indirectly, been discussed earlier.

NFA to FA continued … Method 2: Since in an NFA, there more than one transition for a certain letter and there may not be any transition for certain letter, so starting from the initial state corresponding to the initial state of given NFA, the transition diagram of the corresponding FA, can be built introducing an empty state for a letter having no transition at certain state and a state corresponding to the combination of states, for a letter having more than one transitions. Following are the examples Method 2: Since in an NFA, there more than one transition for a certain letter and there may not be any transition for certain letter, so starting from the initial state corresponding to the initial state of given NFA, the transition diagram of the corresponding FA, can be built introducing an empty state for a letter having no transition at certain state and a state corresponding to the combination of states, for a letter having more than one transitions. Following are the examples

Example Consider the following NFA Consider the following NFA Using the method discussed earlier, the above NFA may be equivalent to the following FA Using the method discussed earlier, the above NFA may be equivalent to the following FA

Example Continued...

Example A simple NFA that accepts the language of strings defined over Σ ={a,b}, consists of bb and bbb A simple NFA that accepts the language of strings defined over Σ ={a,b}, consists of bb and bbb The above NFA can be converted to the following FA The above NFA can be converted to the following FA

Example Continued...

NFA to FA continued … Method 3: As discussed earlier that in an NFA, there may be more than one transition for a certain letter and there may not be any transition for certain letter, so starting from the initial state corresponding to the initial state of given NFA, the transition table along with new labels of states, of the corresponding FA, can be built introducing an empty state for a letter having no transition at certain state and a state corresponding to the combination of states, for a letter having more than one transitions. Following are the examples Method 3: As discussed earlier that in an NFA, there may be more than one transition for a certain letter and there may not be any transition for certain letter, so starting from the initial state corresponding to the initial state of given NFA, the transition table along with new labels of states, of the corresponding FA, can be built introducing an empty state for a letter having no transition at certain state and a state corresponding to the combination of states, for a letter having more than one transitions. Following are the examples

Example

Example continued … The corresponding transition diagram follows as The corresponding transition diagram follows as Old states New states after reading ab Z 1 _  x 1 x1  z1x1  z1x1  z1x1  z1 (x 1, x 2 )  z 2 z 2  (x 1, x 2 ) (x 1, Λ)  x 1  z 1 (x 1, x 2, x 3 )  z 3 z 3 +  (x 1, x 2, x 3 ) (x 1,x 3 )  z 4 (x 1,x 2,x 3 )  z 3 z 4 +  (x 1,x 3 ) (x 1,x 3 )  z 4 (x 1,x 2,x 3 )  z 3

Example continued …