ABSTRACT
The problem of converting a regular expression to NFA is a fundamental problem that has been well studied. However, the two basic construction algorithms: (1) Thompson, (2) McNaughton-Yamada and Glushkov, does not yield the best solution in terms of the number of states and transitions. In this paper, we show: For a regular expression with l literals, we can construct an NFA with 2l states and 4l transitions in the worst case. Our algorithm runs in linear time with respect to the length of the regular expression. This improves the construction algorithm given by Chang in [5], which constructs an NFA with 5l=2 states and (10l -- 5)/2 transitions in the worst case. The method presented here is much simpler and easier to understand, as we use only naive ideas: divide and conquer.
- A. Aho. Pattern matching in strings. In Formal Language Theory(R. Book ed). Academic Press, 1980.Google Scholar
- V. Antimirov. Partial derivatives of regular expressions and finite automata construction. Theoretical Computer Science, 155:291--319, 1996. Google ScholarDigital Library
- J. H. A. Aho and J. Ullman. The Design and Analysis of Computer Algorithms. Addison-Wesley, Reading, Mass., 1974. Google ScholarDigital Library
- G. Berry and R. Sethi. From regular expressions to deterministic automata. Theoretical Computer Science, 48:117--126, 1986. Google ScholarDigital Library
- C. Chang. Ph.D Thesis. Department of Computer Science, Courant Institute, New York, 1992.Google Scholar
- G. C. C. Clark. On the use of regular expressions for searching text. ACM Trans. on Programming Languages and Systems, 19(3):413--426, 1997. Google ScholarDigital Library
- V. Glushkov. The abstract theory of automata. Russian Math. Surveys, 16:1--53, 1961.Google ScholarCross Ref
- P. P. G. Apostolopoulos, V. Peris. L5: A self learning layer 5 switch. In Technical Report RC21461. IBM, T.J. Watson Research Center, 1999.Google Scholar
- R. McNaughton and H. Yamada. Regular expressions and state graphs for automata. Trans. IRS, EC(9):39--47, 1960.Google Scholar
- E. Meyer. A four-russians algorithm for regular expression pattern matching. Journal of ACM, 39(2):432--448, 1992. Google ScholarDigital Library
- K. Thompson. Regular expression search algorithm. Communications of the ACM, 11(6):410--422, 1968. Google ScholarDigital Library
- A simple way to construct NFA with fewer states and transitions
Recommendations
Mergible states in large NFA
Insightful theoryQuite often, trivial problems stated for deterministic finite automata (DFA) are surprisingly difficult for the non-deterministic case (NFA). In any non-minimal DFA for a given regular language, we can find two equivalent states which can be "merged" ...
A Two-Way Automaton with Fewer States than Any Equivalent One-Way Automaton
This correspondence presents an example of a two-way automaton which has significantly fewer states than any one-way automaton accepting the same set of tapes. Thus, in this particular case, memory space can be saved by using a two-way automaton. This ...
Results on Transforming NFA into DFCA
Contagious Creativity - In Honor of the 80th Birthday of Professor Solomon MarcusIn this paper we consider the transformation from (minimal) non-deterministic finite automata (NFAs) to deterministic finite cover automata (DFCAs). We want to compare the two equivalent accepting devices with respect to their number of states; this ...
Comments