SlideShare a Scribd company logo
1 of 5
Example 2.16: consider the NFA of Figure 2.8




M                     ε-closure of M (S)       S′a   S′b
1                   1,2,6                      3,7
3,7                 3,4,7,8                          5
5                   5,8

                             a                   b




                                        1
Example 2.17: consider the NFA of Figure 2.9 (regular expression letter(letter|digit)*)




    M                    ε-closure of M (S)      S′letter           S′digit
    1                 1                          2
    2                 2,3,4,5,7,10               6                  8
    6                 4,5,6,7,9,10               6                  8
    8                 4,5,7,8,9,10               6                  8



                                                                                  le tte r




                                            2
2.4.3 Simulating an NFA using the subset construction

      As mentioned at section 2.3.
      NFAs can be implemented in similar ways to DFAs, except that since NFAs are
nondeterministic, there are potentially many different sequences of transitions that
must be tried.
      A program that simulates an NFA must store up transitions that have not yet been
tried and backtrack to them on failure.

    An other way of simulating an NFA is to use the subset construction, but instead
of constructing all the states of the associated DFA, we construct only the state at each
point that is indicated by the next input character.

    The advantage: we may not need to construct the entire DFA.

             In example 2.16, the input string consisting of the single character a.
                               a                           b




    The disadvantage: a state may be constructed many times, if the path contains loops.
           In example 2.17, given the input string r2d3




2.4.4 Minimizing the number of states in a DFA
    The process we have described of deriving a DFA algorithmically from a regular
expression has the unfortunate property that the resulting DFA may be more complex
than necessary.

    For example 2.15 we derived the DFA for the regular expression a*:




whereas the DFA will do as well.

                                                       a




                                                3
An important result from automata theory states that,
     given any DFA, there is an equivalent DFA containing a minimum number of
states,
     and, that this minimum-state DFA is unique (except for renaming of states).

 It is also possible to directly obtain this minimum-state DFA from any given DFA.

  Given the algorithm as follow:
   (1) It begins with the most optimistic assumption possible.
        It creates two sets, one consisting of all the accepting states and the other
   consisting of all the non-accepting states.

   (2) Given this partition of the states of the original DFA, consider the transitions on
      each character a of the alphabet.
        If all accepting states have transitions on a to accepting states, then this
           defines an a-transition from the new accepting state (the set of all the old
           accepting states) to itself.
        If all accepting states have transitions on a to non-accepting states, then this
           defines an a-transition from the new accepting state to the new non-
           accepting state (the set of all the old non-accepting stales).
        On the other hand, if there are two accepting states s and t that have
           transitions on a that land in different sets, then no a-transition can be
           defined for this grouping of the states. We say that a distinguishes the states
           s and t
        We must also consider error transitions to an error state that is non-
           accepting. If there are accepting states s and t such that s has an a-transition
           to another accepting state, while t has no a-transition at all (i.e., an error
           transition), then a distinguishes s and t.

   (3) If any further sets are split, we must return and repeat the process from the
       beginning. This process continues until either all sets contain only one element
       (in which case, we have shown the original DFA to be minimal) or until no
       further splitting of sets occurs.




                                           4
le tte r




Example 2.18: The regular expression letter(letter|digit)*




      The accepting sets                {2,3,4,5,7,10},{4,5,6,7,9,10},{4,5,7,8,9,10}
      The nonaccepting sets             {1}
 The following minimum-state DFA :
                                                              letter




                                                              digit



    Example 2.19: the regular expression (a| ε)b*




    The accepting sets                         {1,2,3}
    The non-accepting sets

     state 1 has an a-transition to an accepting state, while states 2 .and 3 have no
a-transition (or, rather, an error transition on a to the error nonaccepting state).
     Thus, a distinguishes state 1 from states 2 and 3,
     and we must repartition the states into the sets {1} and {2,3}.
     Now we begin over. The set {1} cannot be split further, so we no longer consider it.
Now the states 2 and 3 cannot be distinguished by either a or b.




                                           5

More Related Content

What's hot

HOMOGENEOUS LINEAR PDE
HOMOGENEOUS LINEAR PDEHOMOGENEOUS LINEAR PDE
HOMOGENEOUS LINEAR PDEKomathiJ
 
14 pro resolution
14 pro resolution14 pro resolution
14 pro resolutionTianlu Wang
 
1.9. minimization of dfa
1.9. minimization of dfa1.9. minimization of dfa
1.9. minimization of dfaSampath Kumar S
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
Design of a Pseudo-Random Binary Code Generator via a Developed Simulation Model
Design of a Pseudo-Random Binary Code Generator via a Developed Simulation ModelDesign of a Pseudo-Random Binary Code Generator via a Developed Simulation Model
Design of a Pseudo-Random Binary Code Generator via a Developed Simulation ModelIDES Editor
 
NFA DFA Equivalence theorem
NFA DFA Equivalence theorem NFA DFA Equivalence theorem
NFA DFA Equivalence theorem niveditJain
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++Muhammad Hammad Waseem
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingSaranyaK68
 

What's hot (12)

HOMOGENEOUS LINEAR PDE
HOMOGENEOUS LINEAR PDEHOMOGENEOUS LINEAR PDE
HOMOGENEOUS LINEAR PDE
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
14 pro resolution
14 pro resolution14 pro resolution
14 pro resolution
 
1.9. minimization of dfa
1.9. minimization of dfa1.9. minimization of dfa
1.9. minimization of dfa
 
05 dataflow
05 dataflow05 dataflow
05 dataflow
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
Design of a Pseudo-Random Binary Code Generator via a Developed Simulation Model
Design of a Pseudo-Random Binary Code Generator via a Developed Simulation ModelDesign of a Pseudo-Random Binary Code Generator via a Developed Simulation Model
Design of a Pseudo-Random Binary Code Generator via a Developed Simulation Model
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
NFA DFA Equivalence theorem
NFA DFA Equivalence theorem NFA DFA Equivalence theorem
NFA DFA Equivalence theorem
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
 
Lec39
Lec39Lec39
Lec39
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 

Viewers also liked

Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)bolovv
 
Chapter Eight(1)
Chapter Eight(1)Chapter Eight(1)
Chapter Eight(1)bolovv
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1Shashwat Shriparv
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler DesignShine Raj
 

Viewers also liked (8)

Ch8a
Ch8aCh8a
Ch8a
 
Ch8b
Ch8bCh8b
Ch8b
 
Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)
 
Chapter Eight(1)
Chapter Eight(1)Chapter Eight(1)
Chapter Eight(1)
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
Interm codegen
Interm codegenInterm codegen
Interm codegen
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler Design
 
Code generation
Code generationCode generation
Code generation
 

Similar to Chapter 2 2 1 2

CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...parmeet834
 
Chapter 2 2 1 1
Chapter 2 2 1 1Chapter 2 2 1 1
Chapter 2 2 1 1bolovv
 
Lecture 17- F19.pdf
Lecture 17- F19.pdfLecture 17- F19.pdf
Lecture 17- F19.pdfAbrar11535
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design FileArchita Misra
 
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...venkatapranaykumarGa
 
A class of boundary value methods for the complex delay differential equation
A class of boundary value methods for the complex delay differential equationA class of boundary value methods for the complex delay differential equation
A class of boundary value methods for the complex delay differential equationijscmcj
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysisIffat Anjum
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionHazrat Bilal
 
aho corasick paper study note
 aho corasick paper study note aho corasick paper study note
aho corasick paper study noteYi-Jun Zheng
 
finite_automata.ppt
finite_automata.pptfinite_automata.ppt
finite_automata.pptAkhlasHashim
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysisraosir123
 
Comparative Report Ed098
Comparative Report Ed098Comparative Report Ed098
Comparative Report Ed098mikebrowl
 

Similar to Chapter 2 2 1 2 (17)

CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
 
Hwsoln03 toc
Hwsoln03 tocHwsoln03 toc
Hwsoln03 toc
 
Chapter 2 2 1 1
Chapter 2 2 1 1Chapter 2 2 1 1
Chapter 2 2 1 1
 
Nfa vs dfa
Nfa vs dfaNfa vs dfa
Nfa vs dfa
 
Lecture 17- F19.pdf
Lecture 17- F19.pdfLecture 17- F19.pdf
Lecture 17- F19.pdf
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design File
 
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
 
optimization of DFA
optimization of DFAoptimization of DFA
optimization of DFA
 
A class of boundary value methods for the complex delay differential equation
A class of boundary value methods for the complex delay differential equationA class of boundary value methods for the complex delay differential equation
A class of boundary value methods for the complex delay differential equation
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
 
aho corasick paper study note
 aho corasick paper study note aho corasick paper study note
aho corasick paper study note
 
Laplace
LaplaceLaplace
Laplace
 
finite_automata.ppt
finite_automata.pptfinite_automata.ppt
finite_automata.ppt
 
1406
14061406
1406
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
Comparative Report Ed098
Comparative Report Ed098Comparative Report Ed098
Comparative Report Ed098
 

More from bolovv

Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)bolovv
 
Chapter Three(1)
Chapter Three(1)Chapter Three(1)
Chapter Three(1)bolovv
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)bolovv
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)bolovv
 
Chapter Five(2)
Chapter Five(2)Chapter Five(2)
Chapter Five(2)bolovv
 
Chapter One
Chapter OneChapter One
Chapter Onebolovv
 
Chapter Seven(1)
Chapter Seven(1)Chapter Seven(1)
Chapter Seven(1)bolovv
 
Chapter Two(1)
Chapter Two(1)Chapter Two(1)
Chapter Two(1)bolovv
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1bolovv
 

More from bolovv (9)

Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
 
Chapter Three(1)
Chapter Three(1)Chapter Three(1)
Chapter Three(1)
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
 
Chapter Five(2)
Chapter Five(2)Chapter Five(2)
Chapter Five(2)
 
Chapter One
Chapter OneChapter One
Chapter One
 
Chapter Seven(1)
Chapter Seven(1)Chapter Seven(1)
Chapter Seven(1)
 
Chapter Two(1)
Chapter Two(1)Chapter Two(1)
Chapter Two(1)
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

Chapter 2 2 1 2

  • 1. Example 2.16: consider the NFA of Figure 2.8 M ε-closure of M (S) S′a S′b 1 1,2,6 3,7 3,7 3,4,7,8 5 5 5,8 a b 1
  • 2. Example 2.17: consider the NFA of Figure 2.9 (regular expression letter(letter|digit)*) M ε-closure of M (S) S′letter S′digit 1 1 2 2 2,3,4,5,7,10 6 8 6 4,5,6,7,9,10 6 8 8 4,5,7,8,9,10 6 8 le tte r 2
  • 3. 2.4.3 Simulating an NFA using the subset construction As mentioned at section 2.3. NFAs can be implemented in similar ways to DFAs, except that since NFAs are nondeterministic, there are potentially many different sequences of transitions that must be tried. A program that simulates an NFA must store up transitions that have not yet been tried and backtrack to them on failure. An other way of simulating an NFA is to use the subset construction, but instead of constructing all the states of the associated DFA, we construct only the state at each point that is indicated by the next input character. The advantage: we may not need to construct the entire DFA. In example 2.16, the input string consisting of the single character a. a b The disadvantage: a state may be constructed many times, if the path contains loops. In example 2.17, given the input string r2d3 2.4.4 Minimizing the number of states in a DFA The process we have described of deriving a DFA algorithmically from a regular expression has the unfortunate property that the resulting DFA may be more complex than necessary. For example 2.15 we derived the DFA for the regular expression a*: whereas the DFA will do as well. a 3
  • 4. An important result from automata theory states that, given any DFA, there is an equivalent DFA containing a minimum number of states, and, that this minimum-state DFA is unique (except for renaming of states). It is also possible to directly obtain this minimum-state DFA from any given DFA. Given the algorithm as follow: (1) It begins with the most optimistic assumption possible. It creates two sets, one consisting of all the accepting states and the other consisting of all the non-accepting states. (2) Given this partition of the states of the original DFA, consider the transitions on each character a of the alphabet.  If all accepting states have transitions on a to accepting states, then this defines an a-transition from the new accepting state (the set of all the old accepting states) to itself.  If all accepting states have transitions on a to non-accepting states, then this defines an a-transition from the new accepting state to the new non- accepting state (the set of all the old non-accepting stales).  On the other hand, if there are two accepting states s and t that have transitions on a that land in different sets, then no a-transition can be defined for this grouping of the states. We say that a distinguishes the states s and t  We must also consider error transitions to an error state that is non- accepting. If there are accepting states s and t such that s has an a-transition to another accepting state, while t has no a-transition at all (i.e., an error transition), then a distinguishes s and t. (3) If any further sets are split, we must return and repeat the process from the beginning. This process continues until either all sets contain only one element (in which case, we have shown the original DFA to be minimal) or until no further splitting of sets occurs. 4
  • 5. le tte r Example 2.18: The regular expression letter(letter|digit)* The accepting sets {2,3,4,5,7,10},{4,5,6,7,9,10},{4,5,7,8,9,10} The nonaccepting sets {1} The following minimum-state DFA : letter digit Example 2.19: the regular expression (a| ε)b* The accepting sets {1,2,3} The non-accepting sets state 1 has an a-transition to an accepting state, while states 2 .and 3 have no a-transition (or, rather, an error transition on a to the error nonaccepting state). Thus, a distinguishes state 1 from states 2 and 3, and we must repartition the states into the sets {1} and {2,3}. Now we begin over. The set {1} cannot be split further, so we no longer consider it. Now the states 2 and 3 cannot be distinguished by either a or b. 5