encyclopegia.org

Kleene's algorithm

In theoretical computer science, in particular in formal language theory, Kleene's algorithm transforms a given nondeterministic finite automaton (NFA) into a regular expression. Together with other conversion algorithms, it establishes the equivalence of several description formats for regular languages. Alternative presentations of the same method include the "elimination method" attributed to Brzozowski and McCluskey, the algorithm of McNaughton and Yamada, and the use of Arden's lemma.

In theoretical computer science, in particular in formal language theory, Kleene's algorithm transforms a given nondeterministic finite automaton (NFA) into a regular expression. Together with other conversion algorithms, it establishes the equivalence of several description formats for regular languages. Alternative presentations of the same method include the "elimination method" attributed to Brzozowski and McCluskey, the algorithm of McNaughton and Yamada, and the use of Arden's lemma. ==Algorithm description== According to Gross and Yellen (2004), the algorithm can be traced back to Kleene (1956). A presentation of the algorithm in the case of deterministic finite automata (DFAs) is given in Hopcroft and Ullman (1979). The presentation of the algorithm for NFAs below follows Gross and Yellen (2004). Given a nondeterministic finite automaton M = (Q, Σ, δ, q 0 , F), with Q = { q 0 ,...,q n } its set of states, the algorithm computes the sets R of all strings that take M from state q i to q j without going through any state numbered higher than k. Here, "going through a state" means entering and leaving it, so both i and j may be higher than k, but no intermediate state may. Each set R is represented by a regular expression; the algorithm computes them step by step for k = -1, 0, ..., n. Since there is no state numbered higher than n, the regular expression R represents the set of all strings that take M from its start state q 0 to q j . If F = { q 1 ,...,q f } is the set of accept states, the regular expression R | ... | R represents the language accepted by M. The initial regular expressions, for k = -1, are computed as follows for i≠j: R = a 1 | ... | a m       where q j ∈ δ(q i ,a 1 ), ..., q j ∈ δ(q i ,a m ) and as follows for i=j: R = a 1 | ... | a m | ε       where q i ∈ δ(q i ,a 1 ), ..., q i ∈ δ(q i ,a m ) In other words, R mentions all letters that label a transition from i to j, and we also include ε in the case where i=j. After that, in each step the expressions R are computed from the previous ones by R = R (R ) * R | R Another way to understand the operation of the algorithm is as an "elimination method", where the states from 0 to n are successively removed: when state k is removed, the regular expression R , which describes the words that label a path from state i>k to state j>k, is rewritten into R so as to take into account the possibility of going via the "eliminated" state k. By induction on k, it can be shown that the length of each expression R is at most (4 k+1 (6s+7) - 4) symbols, where s denotes the number of characters in Σ. Therefore, the length of the regular expression representing the language accepted by M is at most (4 n+1 (6s+7)f - f - 3) symbols, where f denotes the number of final states. This exponential blowup is inevitable, because there exist families of DFAs for which any equivalent regular expression must be of exponential size. In practice, the size of the regular expression obtained by running the algorithm can be very different depending on the order in which the states are considered by the procedure, i.e., the order in which they are numbered from 0 to n. ==Example== The automaton shown in the picture can be described as M = (Q, Σ, δ, q 0 , F) with the set of states Q = { q 0 , q 1 , q 2 }, the input alphabet Σ = { a, b }, the transition function δ with δ(q 0 ,a)=q 0 ,   δ(q 0 ,b)=q 1 ,   δ(q 1 ,a)=q 2 ,   δ(q 1 ,b)=q 1 ,   δ(q 2 ,a)=q 1 , and δ(q 2 ,b)=q 1 , the start state q 0 , and set of accept states F = { q 1 }. Kleene's algorithm computes the initial regular expressions as After that, the R are computed from the R step by step for k = 0, 1, 2. Kleene algebra equalities are used to simplify the regular expressions as much as possible. Step 0 Step 1 Step 2 Since q 0 is the start state and q 1 is the only accept state, the regular expression R denotes the set of all strings accepted by the automaton. ==See also== Floyd–Warshall algorithm — an algorithm on weighted graphs that can be implemented by Kleene's algorithm using a particular Kleene algebra Star height problem — what is the minimum stars' nesting depth of all regular expressions corresponding to a given DFA? Generalized star height problem — if a complement operator is allowed additionally in regular expressions, can the stars' nesting depth of Kleene's algorithm's output be limited to a fixed bound? Thompson's construction algorithm — transforms a regular expression to a finite automaton ==References==

References

  1. Regular Expressions and State Graphs for Automata · retrieved 2026-11-17 · rev 1315969572
    Cite this reference

    MLA "Regular Expressions and State Graphs for Automata." McNaughton, R. 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier). Accessed 25 November 2026.

    Chicago "Regular Expressions and State Graphs for Automata." McNaughton, R. 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier).

    APA McNaughton, R. (2026). Regular Expressions and State Graphs for Automata. Retrieved November 25, 2026, from https://en.wikipedia.org/wiki/Doi_(identifier)

  2. Representation of Events in Nerve Nets and Finite Automata · retrieved 2026-11-17 · rev 1315969572
    Cite this reference

    MLA "Representation of Events in Nerve Nets and Finite Automata." Kleene, Stephen C. 2026-11-17. http://www.dlsi.ua.es/~mlf/nnafmc/papers/kleene56representation.pdf. Accessed 25 November 2026.

    Chicago "Representation of Events in Nerve Nets and Finite Automata." Kleene, Stephen C. 2026-11-17. http://www.dlsi.ua.es/~mlf/nnafmc/papers/kleene56representation.pdf.

    APA Kleene, Stephen C. (2026). Representation of Events in Nerve Nets and Finite Automata. Retrieved November 25, 2026, from http://www.dlsi.ua.es/~mlf/nnafmc/papers/kleene56representation.pdf

  3. John E. Hopcroft, Jeffrey D. Ullman (1979). Introduction to Automata Theory, Languages, and Computation . Addison-Wesley. ISBN 0-201-02988-X . Here: Section 3.2.1 pages 91-96 Wikipedia revision 1315969572, retrieved 2026-11-18 · retrieved 2026-11-17 · rev 1315969572
    Cite this reference

    MLA "John E. Hopcroft, Jeffrey D. Ullman (1979). Introduction to Automata Theory, Languages, and Computation . Addison-Wesley. ISBN 0-201-02988-X . Here: Section 3.2.1 pages 91-96 Wikipedia revision 1315969572, retrieved 2026-11-18." John E. 2026-11-17. https://archive.org/details/introductiontoau00hopc. Accessed 25 November 2026.

    Chicago "John E. Hopcroft, Jeffrey D. Ullman (1979). Introduction to Automata Theory, Languages, and Computation . Addison-Wesley. ISBN 0-201-02988-X . Here: Section 3.2.1 pages 91-96 Wikipedia revision 1315969572, retrieved 2026-11-18." John E. 2026-11-17. https://archive.org/details/introductiontoau00hopc.

    APA John E. (2026). John E. Hopcroft, Jeffrey D. Ullman (1979). Introduction to Automata Theory, Languages, and Computation . Addison-Wesley. ISBN 0-201-02988-X . Here: Section 3.2.1 pages 91-96 Wikipedia revision 1315969572, retrieved 2026-11-18. Retrieved November 25, 2026, from https://archive.org/details/introductiontoau00hopc

  4. a i · retrieved 2026-11-17 · rev 1315969572
    Cite this reference

    MLA "a i." More precisely, the number of regular-expression symbols, " a i ", "ε", "|", " * ", "·"; not counting parentheses. 2026-11-17. https://en.wikipedia.org/w/index.php?oldid=1315969572. Accessed 25 November 2026.

    Chicago "a i." More precisely, the number of regular-expression symbols, " a i ", "ε", "|", " * ", "·"; not counting parentheses. 2026-11-17. https://en.wikipedia.org/w/index.php?oldid=1315969572.

    APA More precisely, the number of regular-expression symbols, " a i ", "ε", "|", " * ", "·"; not counting parentheses. (2026). a i. Retrieved November 25, 2026, from https://en.wikipedia.org/w/index.php?oldid=1315969572

  5. Finite Automata, Digraph Connectivity, and Regular Expression Size · retrieved 2026-11-17 · rev 1315969572
    Cite this reference

    MLA "Finite Automata, Digraph Connectivity, and Regular Expression Size." Gruber, Hermann; Holzer, Markus (2008). 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier). Accessed 25 November 2026.

    Chicago "Finite Automata, Digraph Connectivity, and Regular Expression Size." Gruber, Hermann; Holzer, Markus (2008). 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier).

    APA Gruber, Hermann; Holzer, Markus (2008). (2026). Finite Automata, Digraph Connectivity, and Regular Expression Size. Retrieved November 25, 2026, from https://en.wikipedia.org/wiki/Doi_(identifier)

  6. a b Jonathan L. Gross and Jay Yellen, ed. (2004). Handbook of Graph Theory . Discrete Mathematics and it Applications. CRC Press. ISBN 1-58488-090-2 . Here: sect.2.1, remark R13 on p.65 Wikipedia revision 1315969572, retrieved 2026-11-18 · retrieved 2026-11-17 · rev 1315969572
    Cite this reference

    MLA "a b Jonathan L. Gross and Jay Yellen, ed. (2004). Handbook of Graph Theory . Discrete Mathematics and it Applications. CRC Press. ISBN 1-58488-090-2 . Here: sect.2.1, remark R13 on p.65 Wikipedia revision 1315969572, retrieved 2026-11-18." a b Jonathan L. 2026-11-17. https://en.wikipedia.org/wiki/ISBN_(identifier). Accessed 25 November 2026.

    Chicago "a b Jonathan L. Gross and Jay Yellen, ed. (2004). Handbook of Graph Theory . Discrete Mathematics and it Applications. CRC Press. ISBN 1-58488-090-2 . Here: sect.2.1, remark R13 on p.65 Wikipedia revision 1315969572, retrieved 2026-11-18." a b Jonathan L. 2026-11-17. https://en.wikipedia.org/wiki/ISBN_(identifier).

    APA a b Jonathan L. (2026). a b Jonathan L. Gross and Jay Yellen, ed. (2004). Handbook of Graph Theory . Discrete Mathematics and it Applications. CRC Press. ISBN 1-58488-090-2 . Here: sect.2.1, remark R13 on p.65 Wikipedia revision 1315969572, retrieved 2026-11-18. Retrieved November 25, 2026, from https://en.wikipedia.org/wiki/ISBN_(identifier)

Cite this article

MLA

"Kleene's algorithm." encyclopegia.org, 2025, https://encyclopegia.org/wiki/kleene-s-algorithm. Accessed 25 November 2026.

Chicago

"Kleene's algorithm." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/kleene-s-algorithm.

APA

encyclopegia.org. (2025). Kleene's algorithm. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/kleene-s-algorithm

Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

μ-law algorithm

stub · references available

bitap algorithm

stub · references available

QR algorithm

stub · references available

Prim's algorithm

stub · references available

greedy algorithm

stub · references available

Apriori algorithm

stub · references available

Baum–Welch algorithm

stub · references available

Glushkov's construction algorithm

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1315969572 · 0.5 · snapshot enwiki-001315969572

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.