You are on page 1of 4

State Minimization: A Comprehensive

Summary
Abacan, Arjay M.
Batangas State University
Email: jcngs2497@yahoo.com

expression (especially if many strings will be


AbstractThis research paper aims to discuss tested) is to construct the equivalent finite
describe the nature of state machines and to give automaton and then simulate the machine on the
techniques on how to effectively minimize state string.
machines.

I. INTRODUCTION II. CONSIDERATIONS

Problems associated with constructing and Minimizing deterministic finite state


minimizing finite state machines arise repeatedly in machines - Transition matrices for finite automata
software and hardware design applications. Finite quickly become prohibitively large for
state machines are best thought of as pattern sophisticated machines, thus fueling the need for
recognizers, and minimum-size machines tighter encodings. The most direct approach is to
correspond to recognizers that require less time and eliminate redundant states in the automaton. As the
space. Complicated control systems and compilers example above illustrates, automata of widely
are often built using finite state machines to encode varying sizes can compute the same function.
the current state and associated actions, as well as
the set of possible transitions to other states. Algorithms for minimizing the number of
Minimizing the size of this machine minimizes its states in a deterministic finite automaton (DFA)
cost. appear in any book on automata theory. The basic
approach works by partitioning the states into gross
Finite state machines are best thought of as equivalence classes and then refining the partition.
edge-labeled directed graphs, where each vertex Initially, the states are partitioned into accepting,
represents one of n states and each edge a transition rejecting, and other classes. The transitions from
from one state to the other on receipt of the each node branch to a given class on a given
alphabet symbol that labels the edge. The symbol. Whenever two states , t in the same
automaton above analyzes a given sequence of coin class C branch to elements of different classes, the
tosses, with the dark states signifying that an even class C must be partitioned into two subclasses, one
number of heads have been observed. Automata containing , the other containing t.
can be represented using any graph data structure,
This algorithm makes a sweep though all the
or by using an transition matrix,
classes looking for a new partition, and repeating
where is the size of the alphabet.
the process from scratch if it finds one. This yields
an algorithm, since at most n-1 sweeps need
Finite state machines are often used to specify
ever be performed. The final equivalence classes
search patterns in the guise of regular expressions,
correspond to the states in the minimum
which are patterns formed by and-ing, or-ing, and
automaton. In fact, a more
looping over smaller regular expressions. For
efficient, algorithm is known with
example, the regular
available implementations discussed below.
expression matches any string on
(a,b,c) that begins and ends with
Constructing deterministic machines from
an a (including a itself). The best way to test
nondeterministic machines - DFAs are simple to
whether a string is described by a given regular
understand and work with, because the machine is
always in exactly one state at any given time. length m require states in any DFA
Nondeterministic automata (NFAs) can be in more implementing them, such
than one state at a time, so its current ``state'' as . There is no
represents a subset of all possible machine states. way to avoid this exponential blowup in the space
required. Note, however, that it takes linear time to
In fact, any NFA can be mechanically simulate an input string on any automaton,
converted to an equivalent DFA, which can then be regardless of the size of the automaton.
minimized as above. However, converting an NFA
to a DFA can cause an exponential blowup in the III. FSM OPTIMIZATION FLOW CHART
number of states, which perversely might later be
eliminated in the minimization. This exponential
blowup makes automaton minimization problems
NP-hard whenever you do not start with a DFA.

The proofs of equivalence between NFAs,


DFAs, and regular expressions are elementary
enough to be covered in undergraduate automata
theory classes. However, they are surprisingly
nasty to implement, for reasons including but not
limited to the exponential blowup of states.
Implementations are discussed below.

Constructing machines from regular


expressions - There are two approaches to
converting a regular expression to an equivalent
finite automaton, the difference being whether the
output automaton is to be a nondeterministic or
deterministic machine. The former is easier to
construct but less efficient to simulate.
The goal is to identify and combine states that
The nondeterministic construction uses - have equivalent behavior.
moves, which are optional transitions that require
no input to fire. On reaching a state with an - First is to identify and combine states that have
move, we must assume that the machine can be in equivalent behavior
either state. Using such -moves, it is
straightforward to construct an automaton from a Algorithm sketch
depth-first traversal of the parse tree of the regular
expression. This machine will have O(m) states, 1. place all states in one set
if m is the length of the regular expression. Further, 2. initially partition set based on the output
simulating this machine on a string of behavior
length n takes O(m n) time, since we need consider 3. successively partition the resulting subsets
each state/prefix pair only once. based on next state transitions
4. repeat (3) until no further partitioning is
The deterministic construction starts with the possible
parse tree for the regular expression, observing that
each leaf represents one of the alphabet symbols in states left in the same set are equivalent
the pattern. After recognizing a prefix of the text,
we can be left in some subset of these possible Si, Sj are compatible if for each input they
positions, which would correspond to a state in the have consistent outputs, and their successors are
finite automaton. The derivatives method builds up the same or compatible.
this automaton state by state as it is needed. Even
so, some regular expressions of
/pub/techreports/pi/watson.phd/. A greatly
improved commercial version is available from
www.RibbitSoft.com.

Grail is a C++ package for symbolic


computation with finite automata and regular
expressions, from Darrell Raymond and Derrick
Wood. Grail enables one to convert between
different machine representations and to minimize
Si, Sj are conditionally compatible if their automata. It can handle machines with 100,000
outputs and next states are consistent for some states and dictionaries of 20,000 words. All code
pairs of successors and documentation are accessible from the WWW
site http://www.csd.uwo.ca/research/grail, as well
IV. MINIMIZATION ALGORITHM as pointers to a variety of other automaton
packages. Commercial use of Grail is not allowed
1) Find all Find all pairs of compatible states, without approval, although it is freely available to
pairs of compatible states students and educators.

2) Calculate maximal sets of compatible states An implementation in C of a regular-


(MCC) states (MCC) expression matching algorithm appears in [BR95].
The source code for this program is printed in the
3) Select sets that satisfy the covering text and is available on disk for a modest fee. A
condition (a) and the closure condition (b): bare bones implementation in C of a regular-
expression pattern matching algorithm appears in
a) Each state must be in at least one class;
[GBY91].

b) For each input symbol all next states of each


FLAP (Formal Languages and Automata
class must be included into one class.
Package) is a tool by Susan Rodger for drawing
State minimization straight forward in fully- and simulating finite automata, pushdown
specified machines automata, and Turing machines. Using FLAP, one
can draw a graphical representation (transition
Find compatible states diagram) of an automaton, edit it, and simulate the
Define maximal compatibility class automaton on some input. FLAP was developed in
Select states that satisfy g covering and C++ for X-Windows.
closure condition
REFERENCES
V. IMPLEMENTATION
https://cseweb.ucsd.edu/classes/sp08/cse140/le
FIRE Engine is a finite automaton toolkit, ctures/wk6.pdf
written in C++ by Bruce Watson. It provides
production-quality implementations of finite http://www.cs.columbia.edu/~nowick/minimali
automata and regular expression algorithms. st/node9.html
Several finite automaton minimization algorithms
http://jjackson.eng.ua.edu/courses/ece380/lectu
have been implemented, including
res/LECT32.pdf
Hopcroft's algorithm. Both deterministic
and nondeterministic automata are supported. FIRE
https://courses.cs.washington.edu/courses/cse3
Engine has been used for compiler construction,
70/09wi/LectureSlides/22-
hardware modeling, and computational biology
Minimization.pdf
applications. It is strictly a computing engine and
does not provide a graphical user interface. FIRE https://www.tutorialspoint.com/automata_theor
Engine is available by anonymous ftp from y/dfa_minimization.htm
ftp.win.tue.nl in the directory

You might also like