Glushkov's construction algorithm

In computer science theory – particularly formal language theory – the Glushkov Construction Algorithm (GCA) transforms a given regular expression into an equivalent nondeterministic finite automaton (NFA). Thus, it forms a bridge between regular expressions and nondeterministic finite automata: two abstract representations of formal languages.

The NFA format is better suited for execution on a computer when regular expressions are used. These expressions may be used to describe advanced search patterns in "find and replace"-like operations of text processing utilities. This algorithm can be considered a compiler from a regular expression to an NFA, which is why this algorithm is of practical interest. Furthermore, the automaton is small by nature, as the number of states is equal to the number of letters of the regular expression, plus one.

Thus, an automaton can be made deterministic by the powerset construction and then be minimized to get an optimal automaton corresponding to the given regular expression.

From another, more theoretical point of view, this algorithm is a part of the proof that they both accept exactly the same languages; that is, the regular languages. The converse of Glushkov's algorithm is Kleene's algorithm, which transforms a finite automaton into a regular expression. The automaton obtained by Glushkov's construction is the same as the one obtained by Thompson's construction algorithm, once their ε-transition is removed.

Construction

Given a regular expression , the Glushkov Construction Algorithm creates a non-deterministic automaton that accepts the language accepted by .[1] The construction uses four steps:

1. Linearisation of the expression. Each letter of the alphabet appearing in the expression is renamed, so that each letter occurs at most once in the new expression. Let be the old alphabet and let be the new one.

2a. Computation of the sets , , and , where is the linearity version of . The first, , is the set of letters which occurs as first letter of a word of . The second, , is the set of letters which can ends a letter of . The last one is the set of pairs of letters which can occur in words of , which is the set of factors of length two of the words of . Those sets are mathematically defined by

,
,
.

They are computed by induction over the structure of the expression, as explained below, but they are a function of the language and not of the expression.

2b. Computation of the set which contains the empty-word if this word belongs to , and is the empty-set otherwise. Formally, this is , where is the empty-word.

3. Computation of the local language, as defined by , , , and . By definition, the local language defined by the sets , , and is the set of words which begin with a letter of , end by a letter of , and whose factors of length 2 belong to ; that is, it is the language:

,

potentially with the empty word.

The computation of the automaton for the local language denoted by this linearised expression is formally known as Glushkov's construction. The construction of the automaton can be done using classical construction operations: concatenation, intersection and itering an automaton.

4. Erasing the delineation, giving to each letter of the letter of it used to be.

Example

Automaton constructed by Glushkov's algorithm – linear version
Automaton constructed by Glushkov's algorithm - final version

Consider[1] the rational expression .

1. The linearized version is

.

The letters have been linearized by appending an index to them.

2. The sets , , and of the first letters, last letters, and factors of length 2 for the linear expression are respectively

,
,
.

The empty word belongs to the language, hence .

3. The automaton of the local language

contains an initial state, denoted 1, and a state for each of the five letters of the alphabet

.

There is a transition from 1 to the two states of , a transition from to if is in , and the three states of are final, and such is the state 1. All transitions to a letter have as label the letter .

4. Obtain the automaton for by deleting the indices.

Computation of the set of letters

The computation of the sets , , , and is done inductively over the expression. One must give the values for 0, 1 (the symbols for the empty language and the singleton language containing the empty-word), the letters, and the results of the operations .

1. For , one has

,
,
.

for all letters , then

and then

2. For , one has

and

for each letter , then

and finally .

The same formulas are also correct for , apart from the product where

.

3. For the set of factors of length 2, one has

for all letters , then

,

and finally .

The most costly operations are the products of sets for the computation of .

Properties

The obtained automaton is non-deterministic, and it has as many states as the number of letters of the rational expression, plus one. Furthermore, it has been shown [2] that Glushkov's automaton is the same as Thompson's automaton when the ε-transitions are removed.

Applications and deterministic expressions

The computation of the automaton by the expression occurs often; it has been systematically used in search functions, in particular by the Unix grep command. Similarly, XML's specification also uses such constructions; for more efficiency, regular expressions of a certain kind, called deterministic expressions, have been studied.[2][3]

Notes and references

  1. 1 2 (Pin 2010).
  2. 1 2 (Sakarovitch 2003, p. 215).
  3. Brüggemann-Klein, Anne (1993). "Regular Expressions into Finite Automata". Theoretical Computer Science. 12 (2): 197–213. doi:10.1016/0304-3975(93)90287-4..

External links

A Unified Construction of the Glushkov, Follow, and Antimirov Automata

Algorithms and Computation: 14th International Symposium, ISAAC

This article is issued from Wikipedia - version of the 11/16/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.