The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Finite State Machine Minimization Next: Longest Common Substring Up: Set and String Problems Previous: Cryptography Finite State Machine Minimization Input description: A deterministic finite automaton M. Problem description: The smallest deterministic finite automaton M' such that M' behaves identically to M. Discussion: Problems associated with constructing and minimizing finite state machines arise repeatedly in software and hardware design applications. Finite state machines are best thought of as pattern recognizers, and minimum-size machines correspond to recognizers that require less time and space. Complicated control systems and compilers are often built using finite state machines to encode the current state and associated actions, as well as the set of possible transitions to other states. Minimizing the size of this machine minimizes its cost. Finite state machines are best thought of as edge-labeled directed graphs, where each vertex represents one of n states and each edge a transition from one state to the other on receipt of the alphabet symbol that labels the edge. The automaton above analyzes a given sequence of coin tosses, with the dark states signifying that an even number of heads have been observed. Automata can be represented using any graph data structure (see Section ), or by using an transition matrix, where is the size of the alphabet. file:///E|/BOOK/BOOK5/NODE207.HTM (1 of 4) [19/1/2003 1:32:15]
Finite State Machine Minimization Finite state machines are often used to specify search patterns in the guise of regular expressions, which are patterns formed by and-ing, or-ing, and looping over smaller regular expressions. For example, the regular expression matches any string on (a,b,c) that begins and ends with an a (including a itself). The best way to test whether a string is described by a given regular expression (especially if many strings will be tested) is to construct the equivalent finite automaton and then simulate the machine on the string. See Section for alternative approaches to string matching. We consider three different problems on finite automata: ● Minimizing deterministic finite state machines - Transition matrices for finite automata quickly become prohibitively large for sophisticated machines, thus fueling the need for tighter encodings. The most direct approach is to eliminate redundant states in the automaton. As the example above illustrates, automata of widely varying sizes can compute the same function. Algorithms for minimizing the number of states in a deterministic finite automaton (DFA) appear in any book on automata theory. The basic approach works by partitioning the states into gross equivalence classes and then refining the partition. Initially, the states are partitioned into accepting, rejecting, and other classes. The transitions from each node branch to a given class on a given symbol. Whenever two states , t in the same class C branch to elements of different classes, the class C must be partitioned into two subclasses, one containing , the other containing t. This algorithm makes a sweep though all the classes looking for a new partition, and repeating the process from scratch if it finds one. This yields an algorithm, since at most n-1 sweeps need ever be performed. The final equivalence classes correspond to the states in the minimum automaton. In fact, a more efficient, algorithm is known with available implementations discussed below. ● Constructing deterministic machines from nondeterministic machines - DFAs are simple to understand and work with, because the machine is always in exactly one state at any given time. Nondeterministic automata (NFAs) can be in more than one state at a time, so its current ``state'' represents a subset of all possible machine states. In fact, any NFA can be mechanically converted to an equivalent DFA, which can then be minimized as above. However, converting an NFA to a DFA can cause an exponential blowup in the 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. file:///E|/BOOK/BOOK5/NODE207.HTM (2 of 4) [19/1/2003 1:32:15]
- Page 593 and 594: Medial-Axis Transformation Next: Po
- Page 595 and 596: Medial-Axis Transformation Implemen
- Page 597 and 598: Polygon Partitioning number of piec
- Page 599 and 600: Simplifying Polygons Next: Shape Si
- Page 601 and 602: Simplifying Polygons vertices and o
- Page 603 and 604: Shape Similarity Next: Motion Plann
- Page 605 and 606: Shape Similarity or how close it is
- Page 607 and 608: Motion Planning There is a wide ran
- Page 609 and 610: Motion Planning often arise in the
- Page 611 and 612: Maintaining Line Arrangements Think
- Page 613 and 614: Maintaining Line Arrangements Next:
- Page 615 and 616: Minkowski Sum where x+y is the vect
- Page 617 and 618: Set and String Problems Next: Set C
- Page 619 and 620: Set Cover Next: Set Packing Up: Set
- Page 621 and 622: Set Cover Figure: Hitting set is du
- Page 623 and 624: Set Packing Next: String Matching U
- Page 625 and 626: Set Packing Notes: An excellent exp
- Page 627 and 628: String Matching shouldn't try. Furt
- Page 629 and 630: String Matching and texts, I recomm
- Page 631 and 632: Approximate String Matching This sa
- Page 633 and 634: Approximate String Matching http://
- Page 635 and 636: Text Compression Next: Cryptography
- Page 637 and 638: Text Compression code string. ASCII
- Page 639 and 640: Cryptography Next: Finite State Mac
- Page 641 and 642: Cryptography ● How can I validate
- Page 643: Cryptography MD5 [Riv92] is the sec
- Page 647 and 648: Finite State Machine Minimization S
- Page 649 and 650: Longest Common Substring than edit
- Page 651 and 652: Longest Common Substring include [A
- Page 653 and 654: Shortest Common Superstring Finding
- Page 655 and 656: Software systems Next: LEDA Up: Alg
- Page 657 and 658: LEDA Next: Netlib Up: Software syst
- Page 659 and 660: Netlib Algorithms Mon Jun 2 23:33:5
- Page 661 and 662: The Stanford GraphBase Next: Combin
- Page 663 and 664: Algorithm Animations with XTango Ne
- Page 665 and 666: Programs from Books Next: Discrete
- Page 667 and 668: Handbook of Data Structures and Alg
- Page 669 and 670: Algorithms from P to NP Next: Compu
- Page 671 and 672: Algorithms in C++ Next: Data Source
- Page 673 and 674: Textbooks Next: On-Line Resources U
- Page 675 and 676: On-Line Resources Next: Literature
- Page 677 and 678: People Next: Software Up: On-Line R
- Page 679 and 680: Professional Consulting Services Ne
- Page 681 and 682: Index A Up: Index - All Index: A ab
- Page 683 and 684: Index A artists steal ASA ASCII asp
- Page 685 and 686: Index B binary representation - sub
- Page 687 and 688: Index C Up: Index - All Index: C C+
- Page 689 and 690: Index C clustering , , co-NP coding
- Page 691 and 692: Index C consulting services , conta
- Page 693 and 694: Index D Up: Index - All Index: D DA
Finite State Machine Minimization<br />
Finite state machines are often used to specify search patterns in the guise of regular expressions, which<br />
are patterns formed by and-ing, or-ing, and looping over smaller regular expressions. For example, the<br />
regular expression matches any string on (a,b,c) that begins and ends with an a<br />
(including a itself). <strong>The</strong> best way to test whether a string is described by a given regular expression<br />
(especially if many strings will be tested) is to construct the equivalent finite automaton and then<br />
simulate the machine on the string. See Section for alternative approaches to string matching.<br />
We consider three different problems on finite automata:<br />
● Minimizing deterministic finite state machines - Transition matrices for finite automata quickly<br />
become prohibitively large for sophisticated machines, thus fueling the need for tighter encodings.<br />
<strong>The</strong> most direct approach is to eliminate redundant states in the automaton. As the example above<br />
illustrates, automata of widely varying sizes can compute the same function.<br />
<strong>Algorithm</strong>s for minimizing the number of states in a deterministic finite automaton (DFA) appear<br />
in any book on automata theory. <strong>The</strong> basic approach works by partitioning the states into gross<br />
equivalence classes and then refining the partition. Initially, the states are partitioned into<br />
accepting, rejecting, and other classes. <strong>The</strong> transitions from each node branch to a given class on a<br />
given symbol. Whenever two states , t in the same class C branch to elements of different classes,<br />
the class C must be partitioned into two subclasses, one containing , the other containing t.<br />
This algorithm makes a sweep though all the classes looking for a new partition, and repeating the<br />
process from scratch if it finds one. This yields an algorithm, since at most n-1 sweeps need<br />
ever be performed. <strong>The</strong> final equivalence classes correspond to the states in the minimum<br />
automaton. In fact, a more efficient, algorithm is known with available implementations<br />
discussed below.<br />
● Constructing deterministic machines from nondeterministic machines - DFAs are simple to<br />
understand and work with, because the machine is always in exactly one state at any given time.<br />
Nondeterministic automata (NFAs) can be in more than one state at a time, so its current ``state''<br />
represents a subset of all possible machine states.<br />
In fact, any NFA can be mechanically converted to an equivalent DFA, which can then be<br />
minimized as above. However, converting an NFA to a DFA can cause an exponential blowup in<br />
the number of states, which perversely might later be eliminated in the minimization. This<br />
exponential blowup makes automaton minimization problems NP-hard whenever you do not start<br />
with a DFA.<br />
<strong>The</strong> proofs of equivalence between NFAs, DFAs, and regular expressions are elementary enough<br />
to be covered in undergraduate automata theory classes. However, they are surprisingly nasty to<br />
implement, for reasons including but not limited to the exponential blowup of states.<br />
Implementations are discussed below.<br />
file:///E|/BOOK/BOOK5/NODE207.HTM (2 of 4) [19/1/2003 1:32:15]