SlideShare a Scribd company logo
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

PDF
AI Lesson 14
PDF
Free Ebooks Download ! Edhole
PDF
C4 discontinuities
PDF
PDF
Chapter 13.1.2
PPTX
Data structure
PPT
Admissions in India 2015
PPTX
1.7. eqivalence of nfa and dfa
AI Lesson 14
Free Ebooks Download ! Edhole
C4 discontinuities
Chapter 13.1.2
Data structure
Admissions in India 2015
1.7. eqivalence of nfa and dfa

What's hot (12)

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

Viewers also liked (8)

PPT
Chapter Eight(2)
PPT
Chapter Eight(1)
PPTX
Intermediate code generation1
PPT
Interm codegen
PPTX
Three address code In Compiler Design
PPTX
Code generation
Chapter Eight(2)
Chapter Eight(1)
Intermediate code generation1
Interm codegen
Three address code In Compiler Design
Code generation
Ad

Similar to Chapter 2 2 1 2 (20)

DOC
Chapter 2 2 1 1
PDF
Hwsoln03 toc
PDF
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
PDF
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
PPTX
Theory of automataghsyshsgeedhdhduudydhdhdgdhdhdhdy
PDF
Lecture4 lexical analysis2
DOC
Compiler Design Material 2
DOC
Principles of Compiler Design
DOC
PCD ?s(MCA)
DOC
Pcd(Mca)
DOC
Pcd(Mca)
PPT
finite_automata.ppt
PPT
Finite automata(For college Seminars)
PDF
Regular Expression to Non-Deterministic Finite Automata Converter
PPTX
Compiler Design_Lexical Analysis phase.pptx
PDF
PDF
Lecture 17- F19.pdf
PPTX
LECTURE 2 Converting NFA ( b) to DFA.pptx
PDF
TCS GOLDEN NOTES THEORY OF COMPUTATION .pdf
PDF
Nondeterministic Finite Automata AFN.pdf
Chapter 2 2 1 1
Hwsoln03 toc
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Theory of automataghsyshsgeedhdhduudydhdhdgdhdhdhdy
Lecture4 lexical analysis2
Compiler Design Material 2
Principles of Compiler Design
PCD ?s(MCA)
Pcd(Mca)
Pcd(Mca)
finite_automata.ppt
Finite automata(For college Seminars)
Regular Expression to Non-Deterministic Finite Automata Converter
Compiler Design_Lexical Analysis phase.pptx
Lecture 17- F19.pdf
LECTURE 2 Converting NFA ( b) to DFA.pptx
TCS GOLDEN NOTES THEORY OF COMPUTATION .pdf
Nondeterministic Finite Automata AFN.pdf

More from bolovv (9)

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

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
Encapsulation theory and applications.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Monthly Chronicles - July 2025
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Modernizing your data center with Dell and AMD
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Cloud computing and distributed systems.
KodekX | Application Modernization Development
Encapsulation theory and applications.pdf
cuic standard and advanced reporting.pdf
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
NewMind AI Monthly Chronicles - July 2025
The AUB Centre for AI in Media Proposal.docx
Digital-Transformation-Roadmap-for-Companies.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Unlocking AI with Model Context Protocol (MCP)
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
Modernizing your data center with Dell and AMD
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
Cloud computing and distributed systems.

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