Berry-Sethi method

from Wikipedia, the free encyclopedia

The Berry-Sethi method (after Gérard Berry and Ravi Sethi ; also Glushkov construction , after Viktor Michailowitsch Gluschkow ) is an algorithm for converting a regular expression into a nondeterministic finite automaton .

First, the regular expression is transferred to a tree structure . The nodes correspond to the rules of the regular expression (concatenation , transitory closure and union ). The leaves represent the elements of the input alphabet in the regular expression, i.e. exactly the characters from which valid words can be composed. All further calculations take place with the help of this form of representation.

If one imagines a point before the beginning at the root of the syntax tree to the tree wandering , so all words can the regular expression are generated successively. With the help of this point the finite automaton is constructed. The time complexity of the procedure is .

method

  1. Find empty [r] for all nodes r of the tree. This is a post-order possible DFS (DFS: depth-first search, depth-first search ).
  2. Find first [r] for all nodes r of the tree. This is possible with a post-order DFS.
  3. Find next [r] for all nodes r of the tree. This is possible with a pre-order DFS.
  4. Find last [r] for all nodes r of the tree. This is possible with a post-order DFS.
  5. Integration:
    1. The states of the machine are:
    2. The start status of the machine is:
    3. The final states of the machine are:
      1. if and
      2. if
    4. The transitions of the machine are:
      1. , if and is labeled with , and
      2. , if and is labeled with .

The symbol marks the point that wanders around the tree. The resulting finite automaton is generally nondeterministic and can therefore still be made deterministic by the power set construction.

literature

  • Gérard Berry, Ravi Sethi: From regular expressions to deterministic automata. In: Theoretical Computer Science. 48, 1986, ISSN  0304-3975 , pp. 117-126.
  • Viktor M. Glushkov: The abstract theory of automata. In: Russian Mathematical Surveys. 16, 1961, ISSN  0036-0279 , pp. 1-53.
  • Anne Brüggemann-Klein : Regular expressions into finite automata . In: Theoretical Computer Science 120, 1993, pp. 197-213. doi : 10.1016 / 0304-3975 (93) 90287-4