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 PDE
KomathiJ
 
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
 

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 (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

Chapter 2 2 1 1
Chapter 2 2 1 1Chapter 2 2 1 1
Chapter 2 2 1 1
bolovv
 
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
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
raosir123
 
Comparative Report Ed098
Comparative Report Ed098Comparative Report Ed098
Comparative Report Ed098
mikebrowl
 

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 One
bolovv
 
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 1
bolovv
 

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

Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 

Recently uploaded (20)

The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 

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