0% found this document useful (0 votes)
78 views11 pages

Deterministic Finite Automata (DFSA) : Often Representing As A Diagram

This document discusses deterministic finite automata (DFAs) and their minimization. It defines the key components of a DFA, provides an example of a DFA diagram, and discusses how some states in a DFA can be redundant. It then introduces the task of DFA minimization to automatically transform a DFA into a state-minimized DFA with no redundant states. An algorithm for DFA minimization is described that works by grouping states that cannot be distinguished based on their transitions. Two examples of applying the algorithm are provided.

Uploaded by

pisces145
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
78 views11 pages

Deterministic Finite Automata (DFSA) : Often Representing As A Diagram

This document discusses deterministic finite automata (DFAs) and their minimization. It defines the key components of a DFA, provides an example of a DFA diagram, and discusses how some states in a DFA can be redundant. It then introduces the task of DFA minimization to automatically transform a DFA into a state-minimized DFA with no redundant states. An algorithm for DFA minimization is described that works by grouping states that cannot be distinguished based on their transitions. Two examples of applying the algorithm are provided.

Uploaded by

pisces145
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 11

DFA

 Deterministic Finite Automata (DFSA)


 (Q, Σ, δ, q0, F)
 Q – (finite) set of states
 Σ – alphabet – (finite) set of input symbols
 δ – transition function
 q0 – start state
 F – set of final / accepting states

DFA
 Often representing as a diagram:
DFA
 Often representing as a diagram:

DFA Minimization
 Some states can be redundant:
 The following DFA accepts (a|b)+
 State s1 is not necessary
DFA Minimization
 This is a state-minimized (or just minimized)
DFA
 Every remaining state is necessary
DFA Minimization
 The task of DFA minimization, then, is to
automatically transform a given DFA into a
state-minimized DFA
 Several algorithms and variants are known
 Note that this also in effect can minimize an NFA
(since we know algorithm to convert NFA to DFA)

DFA Minimization Algorithm


 Recall that a DFA M=(Q, Σ, δ, q0, F)

 Two states p and q are distinct if


 p in F and q not in F or vice versa, or
 for some α in Σ, δ(p, α) and δ(q, α) are distinct

 Using this inductive definition, we can


calculate which states are distinct
DFA Minimization Algorithm
 Create lower-triangular table DISTINCT, initially
blank
 For every pair of states (p,q):
 If p is final and q is not, or vice versa
 DISTINCT(p,q) = ε

 Loop until no change for an iteration:


 For every pair of states (p,q) and each symbol α
 If DISTINCT(p,q) is blank and
DISTINCT( δ(p,α), δ(q,α) ) is not blank
 DISTINCT(p,q) = α
 Combine all states that are not distinct
Very Simple Example

s0
s1
s2
s0 s1 s2

Very Simple Example

s0
s1 ε
s2 ε
s0 s1 s2

Label pairs with ε where one is a final state and the other is not

Finite Automata

Minimization of DFA

One important result on finite automata, both theoretically and practically, is that for any regular
language there is a unique DFA having the smallest number of states that accepts it. Let M = < Q
, , q0 , , A > be a DFA that accepts a language L. Then the following algorithm produces the
DFA, denote it by M1, that has the smallest number of states amomg the DFAs that accept L.

Minimization Algorithm for DFA

Construct a partition = { A, Q - A } of the set of states Q ;


new := new_partition( };

while ( new )
        := new ;
        new := new_partition( )
final := ;

function new_partition( )
for each set S of do
        partition S into subsets such that two states p and q of S are in the same subset of S
        if and only if for each input symbol, p and q make a transition to (states of) the same set of
.

        The subsets thus formed are sets of the output partition in place of S.
        If S is not partitioned in this process, S remains in the output partition.
end

Minimum DFA M1 is constructed from final as follows:

 Select one state in each set of the partition final as the representative for the set. These
representatives are states of minimum DFA M1.
 Let p and q be representatives i.e. states of minimum DFA M1. Let us also denote by p
and q the sets of states of the original DFA M represented by p and q, respectively. Let s
be a state in p and t a state in q. If a transition from s to t on symbol a exists in M, then
the minimum DFA M1 has a transition from p to q on symbol a.
 The start state of M1 is the representative which contains the start state of M.
 The accepting states of M1 are representatives that are in A.
Note that the sets of final are either a subset of A or disjoint from A.

Remove from M1 the dead states and the states not reachable from the start state, if there are any.
Any transitions to a dead state become undefined.
A state is a dead state if it is not an accepting state and has no out-going transitions except to
itself.

Example 1 :
Let us try to minimize the number of states of the following DFA.

  

Initially = { { 1 , 5 } , { 2 , 3 , 4 } }.

new_partition is applied to .
Since on b state 2 goes to state 1, state 3 goes to state 4 and 1 and 4 are in different sets in ,
states 2 and 3 are going to be separated from each other in new .
Also since on a sate 4 goes to sate 4, state 3 goes to state 5 and 4 and 5 are in different sets in ,
states 3 and 4 are going to be separated from each other in new.
Further, since on b 2 goes to 1, 4 goes to 4 and 1 and 4 are in different sets in , 2 and 4 are
separated from each other in new.
On the other hand 1 and 5 make the same transitions. So they are not going to be split.

Thus the new partition is { { 1 , 5 } , { 2 } , { 3 } , { 4 ] }. This becomes the in the second


iteration.

When new_partition is applied to this new , since 1 and 5 do the same transitions, remains
unchanged.
Thus final = { { 1 , 5 } , { 2 } , { 3 } , { 4 ] }.

Select 1 as the representative for { 1 , 5 }. Since the rest are singletons, they have the obvious
representatives.
Note here that state 4 is a dead state because the only transitionout of it is to itself.
Thus the set of states for the minimized DFA is { 1 , 2 , 3 }.
For the transitions, since 1 goes to 3 on a, and to 2 on b in the original DFA, in the minimized
DFA transitions are added from 1 to 3 on a, and 1 to 2 on b. Also since 2 goes to 1 on b, and 3
goes to 1 on a in the original DFA, in the minimized DFA transitions are added from 2 to 1 on b,
and from 3 to 1 on a.
Since the rest of the states are singletons, all transitions between them are inherited for the
minimized DFA.

Thus the minimized DFA is as given in the following figure:

  

Example 2 :
Let us try to minimize the number of states of the following DFA.
  

Initially = { { 3 } , { 1 , 2 , 4 , 5 , 6 } }.
By applying new_partition to this , new = { { 3 } , { 1 , 4 , 5 } , { 2 , 6 } } is obtained.
Applyting new_partition to this , new = { { 3 } , { 1 , 4 } , { 5 } , { 2 } , { 6 } } is obtained.
Applyting new_partition again, new = { { 1 } , { 2 } , { 3 } , { 4 } , { 5 } , { 6 } } is obtained.
Thus the number of states of the given DFA is already minimum and it can not be reduced any
further.

Test Your Understanding of Minimization of DFA

Indicate which of the following statements are correct and which are not.
Click True or Fals , then Submit.
Next -- Application of FA

Back to Study Schedule

Back to Table of Contents

You might also like