SlideShare a Scribd company logo
 
Compiler conversion of regular expression regular expression NFA NFA DFA DFA DFA MIN by Thompson's construction by subset construction by minimisation algorithm input parser
Deterministic Computation Non-Deterministic Computation accept or reject accept reject
Formal Definition of NFAs Set of states,  i.e. Input aphabet, i.e. Transition function Initial state Final states
 
Nondeterministic Automata vs Deterministic Automata We learned that NFA is a convenient model for showing the relationships among regular grammars, FA, and regular expressions, and designing them.  However, we know that an NFA is a conceptual model that cannot  directly be built because of the nondeterministic transition. Then what about all the NFA that appear in the examples and proofs? Are those nondeterministic automata remain as theoretical model that cannot bring down to the real world? For context-free languages, there are languages that can only be recognized by NPDA, for example {xx R  | x  {a, b} *  }. As far as PDA are concerned, NPDA are strictly more powerful than DPDA. For LBA, it is open problem. (Looks like the space restriction is too much for a DLBA to do the same computation as an NLBA does.) For TM, any problem that can be solved by an NTM can also be solved by a DTM by tracing every possible transition of an NTM computation using its unlimited space available.
Fortunately, for NFA there is a straightforward way to transform them into DFA. (Actually it is based on the same idea that we used to eliminate   -transitions.) The basic idea is to consider the set of states that can be reachable by a transition as a single state in deterministic transition. The following example will be enough to understand the technique. (We assume that the automaton has no   -transitions.)  Notice that the state with label {0, 1, 2} is from the set of states given by the nondeterministic transition   (0, a) = {0, 1, 2}. Also notice that any state whose label contains an accepting state is defined as an accepting state in the deterministic machine. b a,b,c (a) An NFA a 1 2 a 0 b,c c start {0,1,2} {2} a a {1,2} b c b c c (b) Converted DFA 0 start b,c
Minimization Technique for DFA The number of states of an automaton has direct affect to the size of the machine realizing the automaton. Hence, it is very important to reduce the number of states, if possible. For PDA, LBA and TM, it is very difficult problem to reduce the number of states. However, for DFA there is very efficient algorithm for minimizing the number of states of a given DFA.  Figure (a) below is a part of the state transition graph of a DFA  M = ( Q ,    ,    , q 0 , F ), where    = { a, b }. Clearly, for every w        * ,   ( q 3  , w ) is in an accepting state if and only if   ( q 4  , w )   is. Hence, we can merge q 3  and q 4  into a single state as shown in Figure (b) without affecting the language of the machine. b a a b b a a a b q 4 b q 3 q 1 q 2 Figure (a) q 34 q 1 q 2 Figure (b) b
State Reduction by Partitioning We say two states  p  and   q  are  equivalent  (or indistinguishable), if, for every string w        *  , transition   (  p   , w )   ends in an accepting state if and only if   (  q   , w) does. In the preceding slide states q 3  and   q 4  are equivalent.  There are efficient algorithms available for  computing the sets of equivalent states of a given DFA.  The following example shows a procedure using the set partitioning technique. The technique is similar to one that they use for partitioning people into groups (each having certain preferences) based on their responses to questionnaire. The following two slides show the detailed steps for computing equivalent state sets of the DFA in Figure (a) and constructing the reduced DFA shown in Figure (b). b b a b b a a b a b a 4 3 1 2 a 5 0 Figure (a)  A DFA b a a, b 3 1,2 a b 4,5 0 a, b Figure (b) Reduced DFA
Step 0: Partition the states according to accepting/non-accepting.     P 1   P 2       { 3, 4, 5 }   { 0, 1, 2 }  Figure (a) Initial partition For a state q and symbol t, let P i   be the response of q on t , if   (q, t) enters a state in P i . Step 1: Get the response of each state for each input symbol. Notice that States 3 and 0 show different responses from the ones of the other states in the same set. P 1     P 2 p 1 p 1 p 1 p 2 p 1 p 1 a     a       {3, 4, 5 }   {0, 1, 2 } b     b     p 2 p 1 p 1 p 2 p 1 p 1 Figure (b) Record responses for each input symbol State Reduction by Partitioning(cont’ed)
Step 2: Partition the sets according to the responses, and go to Step 1 until no partition occurs.   P 11 P 12 P 21 P 22 p 11   p 11 p 12   p 12 a      a      {4,  5} {3} {1,  2} {0} b      b      p 11   p 11 p 11   p 11 Figure (c) Partition the set, and record responses for each input symbol No further partition is possible for the sets  P 11   and  P 21   . So the final partition results are   as follows.   {4,  5} {3}  {1,  2} {0} (d) Final partition

More Related Content

PDF
8086 String Instructions.pdf
PPT
NFA or Non deterministic finite automata
PPT
POST’s CORRESPONDENCE PROBLEM
PPTX
Chomsky Normal Form
PPT
Regular expressions-Theory of computation
PPTX
Theory of automata and formal languages Unit 4
PPTX
Ambiguous & Unambiguous Grammar
PPTX
NFA & DFA
8086 String Instructions.pdf
NFA or Non deterministic finite automata
POST’s CORRESPONDENCE PROBLEM
Chomsky Normal Form
Regular expressions-Theory of computation
Theory of automata and formal languages Unit 4
Ambiguous & Unambiguous Grammar
NFA & DFA

What's hot (20)

PDF
Automata theory
PPTX
Moore machine (automata)
PPTX
Introduction to Turing Machine
PPTX
RECURSIVE DESCENT PARSING
PPTX
1.7. eqivalence of nfa and dfa
PPTX
Genetic Algorithm by Example
PPTX
Turing Machine
PDF
NFA to DFA
PPTX
Bellman ford algorithm
PPTX
Ai 8 puzzle problem
PDF
Unit iii
PPTX
Turing machine by_deep
PPT
Jumps in Assembly Language.
PPTX
1.9. minimization of dfa
PPTX
Turing machine-TOC
PPT
Turing Machine
PPTX
Artificial Intelligence Notes Unit 4
PDF
Genetic Algorithm (GA) Optimization - Step-by-Step Example
PPTX
1.3.1 deterministic finite automaton
PPTX
Arithmatic pipline
Automata theory
Moore machine (automata)
Introduction to Turing Machine
RECURSIVE DESCENT PARSING
1.7. eqivalence of nfa and dfa
Genetic Algorithm by Example
Turing Machine
NFA to DFA
Bellman ford algorithm
Ai 8 puzzle problem
Unit iii
Turing machine by_deep
Jumps in Assembly Language.
1.9. minimization of dfa
Turing machine-TOC
Turing Machine
Artificial Intelligence Notes Unit 4
Genetic Algorithm (GA) Optimization - Step-by-Step Example
1.3.1 deterministic finite automaton
Arithmatic pipline
Ad

Viewers also liked (19)

PPTX
Lexical analysis - Compiler Design
PPT
Dfa vs nfa
PPTX
Optimization of dfa
PPT
Lexical Analysis
PPT
Bottom - Up Parsing
PPT
Minimization of DFA
PPT
DFA Minimization
PPTX
optimization of DFA
PPTX
Programming languages,compiler,interpreter,softwares
PPTX
Programming Languages / Translators
PPTX
Compiler Chapter 1
PPTX
Phases of Compiler
PPTX
Intermediate code- generation
PPTX
Translators(Compiler, Assembler) and interpreter
PPT
Intermediate code generation
PPT
Language translator
PPT
Lexical analyzer
PPTX
Lexical analyzer
PPTX
Code generation
Lexical analysis - Compiler Design
Dfa vs nfa
Optimization of dfa
Lexical Analysis
Bottom - Up Parsing
Minimization of DFA
DFA Minimization
optimization of DFA
Programming languages,compiler,interpreter,softwares
Programming Languages / Translators
Compiler Chapter 1
Phases of Compiler
Intermediate code- generation
Translators(Compiler, Assembler) and interpreter
Intermediate code generation
Language translator
Lexical analyzer
Lexical analyzer
Code generation
Ad

Similar to Nfa vs dfa (20)

PDF
IRJET- Partition Method for DFA Minimization
PDF
deterministicfiniteautomatondfa-181008145215 (1).pdf
PPTX
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
PPTX
03-FiniteAutomata.pptx
PDF
flat unit1
PDF
TCS GOLDEN NOTES THEORY OF COMPUTATION .pdf
PDF
Formal Languages and Automata Theory Unit 1
PDF
Finite Automata
PPTX
chapter 1 automata and complexity theory lecture note.pptx
PDF
Finite automata
PPTX
ATFL_MATFL_MMATFL_MMATFL_MMATFL_MMATFL_MMATFL_MMATFL_MMATFL_MMM.pptx
PPTX
INTRODUTION Formal Language and Automatic Theory.pptx
PPTX
AUTOMATA THEORY AUTOMATA THEORYAutomata3Chapter2.pptx
PPTX
TCS MUBAI UNIVERSITY ATHARVA COLLEGE OF ENGINEERING.pptx
PPT
Finite automata examples
PPT
Finite automata examples
PPT
Finite Automata
PPT
Lecture 1 CSE 322 LPU By 5th SEM .ppt Good
PPTX
DIU_BD_AvaGandu_SE-234-Lecture-02-DFA.pptx
IRJET- Partition Method for DFA Minimization
deterministicfiniteautomatondfa-181008145215 (1).pdf
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
03-FiniteAutomata.pptx
flat unit1
TCS GOLDEN NOTES THEORY OF COMPUTATION .pdf
Formal Languages and Automata Theory Unit 1
Finite Automata
chapter 1 automata and complexity theory lecture note.pptx
Finite automata
ATFL_MATFL_MMATFL_MMATFL_MMATFL_MMATFL_MMATFL_MMATFL_MMATFL_MMM.pptx
INTRODUTION Formal Language and Automatic Theory.pptx
AUTOMATA THEORY AUTOMATA THEORYAutomata3Chapter2.pptx
TCS MUBAI UNIVERSITY ATHARVA COLLEGE OF ENGINEERING.pptx
Finite automata examples
Finite automata examples
Finite Automata
Lecture 1 CSE 322 LPU By 5th SEM .ppt Good
DIU_BD_AvaGandu_SE-234-Lecture-02-DFA.pptx

Nfa vs dfa

  • 1.  
  • 2. Compiler conversion of regular expression regular expression NFA NFA DFA DFA DFA MIN by Thompson's construction by subset construction by minimisation algorithm input parser
  • 3. Deterministic Computation Non-Deterministic Computation accept or reject accept reject
  • 4. Formal Definition of NFAs Set of states, i.e. Input aphabet, i.e. Transition function Initial state Final states
  • 5.  
  • 6. Nondeterministic Automata vs Deterministic Automata We learned that NFA is a convenient model for showing the relationships among regular grammars, FA, and regular expressions, and designing them. However, we know that an NFA is a conceptual model that cannot directly be built because of the nondeterministic transition. Then what about all the NFA that appear in the examples and proofs? Are those nondeterministic automata remain as theoretical model that cannot bring down to the real world? For context-free languages, there are languages that can only be recognized by NPDA, for example {xx R | x  {a, b} * }. As far as PDA are concerned, NPDA are strictly more powerful than DPDA. For LBA, it is open problem. (Looks like the space restriction is too much for a DLBA to do the same computation as an NLBA does.) For TM, any problem that can be solved by an NTM can also be solved by a DTM by tracing every possible transition of an NTM computation using its unlimited space available.
  • 7. Fortunately, for NFA there is a straightforward way to transform them into DFA. (Actually it is based on the same idea that we used to eliminate  -transitions.) The basic idea is to consider the set of states that can be reachable by a transition as a single state in deterministic transition. The following example will be enough to understand the technique. (We assume that the automaton has no  -transitions.) Notice that the state with label {0, 1, 2} is from the set of states given by the nondeterministic transition  (0, a) = {0, 1, 2}. Also notice that any state whose label contains an accepting state is defined as an accepting state in the deterministic machine. b a,b,c (a) An NFA a 1 2 a 0 b,c c start {0,1,2} {2} a a {1,2} b c b c c (b) Converted DFA 0 start b,c
  • 8. Minimization Technique for DFA The number of states of an automaton has direct affect to the size of the machine realizing the automaton. Hence, it is very important to reduce the number of states, if possible. For PDA, LBA and TM, it is very difficult problem to reduce the number of states. However, for DFA there is very efficient algorithm for minimizing the number of states of a given DFA. Figure (a) below is a part of the state transition graph of a DFA M = ( Q ,  ,  , q 0 , F ), where  = { a, b }. Clearly, for every w   * ,  ( q 3 , w ) is in an accepting state if and only if  ( q 4 , w ) is. Hence, we can merge q 3 and q 4 into a single state as shown in Figure (b) without affecting the language of the machine. b a a b b a a a b q 4 b q 3 q 1 q 2 Figure (a) q 34 q 1 q 2 Figure (b) b
  • 9. State Reduction by Partitioning We say two states p and q are equivalent (or indistinguishable), if, for every string w   * , transition  ( p , w ) ends in an accepting state if and only if  ( q , w) does. In the preceding slide states q 3 and q 4 are equivalent. There are efficient algorithms available for computing the sets of equivalent states of a given DFA. The following example shows a procedure using the set partitioning technique. The technique is similar to one that they use for partitioning people into groups (each having certain preferences) based on their responses to questionnaire. The following two slides show the detailed steps for computing equivalent state sets of the DFA in Figure (a) and constructing the reduced DFA shown in Figure (b). b b a b b a a b a b a 4 3 1 2 a 5 0 Figure (a) A DFA b a a, b 3 1,2 a b 4,5 0 a, b Figure (b) Reduced DFA
  • 10. Step 0: Partition the states according to accepting/non-accepting. P 1 P 2 { 3, 4, 5 } { 0, 1, 2 } Figure (a) Initial partition For a state q and symbol t, let P i be the response of q on t , if  (q, t) enters a state in P i . Step 1: Get the response of each state for each input symbol. Notice that States 3 and 0 show different responses from the ones of the other states in the same set. P 1 P 2 p 1 p 1 p 1 p 2 p 1 p 1 a     a     {3, 4, 5 } {0, 1, 2 } b     b     p 2 p 1 p 1 p 2 p 1 p 1 Figure (b) Record responses for each input symbol State Reduction by Partitioning(cont’ed)
  • 11. Step 2: Partition the sets according to the responses, and go to Step 1 until no partition occurs. P 11 P 12 P 21 P 22 p 11 p 11 p 12 p 12 a    a    {4, 5} {3} {1, 2} {0} b    b    p 11 p 11 p 11 p 11 Figure (c) Partition the set, and record responses for each input symbol No further partition is possible for the sets P 11 and P 21 . So the final partition results are as follows. {4, 5} {3} {1, 2} {0} (d) Final partition