For numbered states of a finite-state automaton, is a regular expression describing paths from to whose internal states have numbers at most . Splitting a path at its visits to state gives . At stage zero use individual edge labels and an empty-word option when the endpoints coincide. This proves the automaton-to-expression direction of Kleene theorem.
Generalized finite automaton Created 2026-10-05 Updated 2026-10-06
A finite directed automaton whose edge labels are regular expressions rather than individual letters. A path accepts concatenations of words in its successive labels, with choices over all accepting paths combined by union.
Kleene theorem Created 2026-09-24 Updated 2026-09-29
Kleene's theorem states that a language is denoted by a regular expression exactly when it is accepted by a finite automaton.
Fix a finite alphabet . A regular expression is built recursively from , , and the letters , using union, concatenation, and Kleene star. Its interpretation is a formal language: the basic expressions denote , , and , while , , and denote , , and all finite concatenations of members of , including the empty concatenation. In particular, and are different expressions with different meanings.
Kleene theorem identifies exactly the languages described by regular expressions with those recognized by finite-state automata. Start with a deterministic finite automaton (DFA) having states , initial state , accepting set , and transition function . Let describe paths from to whose internal states lie among . At stage zero use the union of letters labelling direct transitions from to , with added if ; use if there are no such possibilities. Define the finite-state path expressions recursively by
A path either avoids internally or decomposes at its visits to : an initial piece into , any number of return pieces at , and a final piece out. Each piece has no internal occurrence of . This proves the recursion by induction, including paths with or , where empty pieces are permitted. Thus
is a regular expression for the DFA's accepted formal language. An empty accepting set gives the expression . This is the path form of state elimination for finite automata.
A nondeterministic finite automaton (NFA) replaces a single successor state by a set of possible successors. It accepts if there exists an accepting run with and . Rejection means that no accepting run exists, rather than that some run rejects. For an Epsilon-NFA, transitions labelled consume no symbol; acceptance means a path whose non-epsilon labels spell . In particular, acceptance of the empty word is tested using the epsilon closure of the initial state.
The same Kleene theorem holds for nondeterministic finite automata. For an NFA without epsilon transitions, the powerset construction has state set , initial state , transition on letter , and accepting subsets meeting . Induction on word length shows that its state is exactly the set of possible current NFA states. For an Epsilon-NFA, start from , where is epsilon closure, and use
This subset construction with epsilon transitions preserves the accepted formal language and gives a DFA with at most states. The already proved direction of Kleene theorem therefore gives a regular expression for every NFA language.
For the converse, recursively construct an Epsilon-NFA with a designated initial state and final state for a regular expression. Use two states with no connecting path for , one epsilon edge for , and one edge labelled for . Keep component state sets disjoint. Union uses a fresh initial state with epsilon edges into both components, and epsilon edges from their finals to a fresh final. Concatenation joins the first final to the second initial by an epsilon edge. For Kleene star, use fresh initial and final states, an epsilon edge directly between them for zero iterations, an edge into the old initial, and epsilon edges from the old final both back to the old initial and out to the new final. Each construction has exactly the intended union, concatenation, or iteration semantics. Induction on the regular expression proves correctness; the subset construction with epsilon transitions then gives a DFA. This proves both directions of Kleene theorem.
Treat the fixed letters , the empty-language and empty-word symbols, and the punctuation of expressions as a finite token alphabet. In the usual syntax allowing parentheses, union, concatenation, and star, the following context-free grammar generates exactly the syntactically valid regular expressions:
Structural induction proves that every generated string is an expression and that every expression has a derivation. Grammar ambiguity does not affect the context-free language assertion.
If the language of these expressions were a regular language, its intersection with the regular token language consisting of some opening parentheses, then , then some closing parentheses would be regular. That intersection is exactly
The pumping lemma for regular languages contradicts regularity: a sufficiently long opening-parenthesis prefix forces a pumpable segment wholly within that prefix, and pumping it changes the two parenthesis counts unequally. Hence the expression syntax is context-free but not regular. This conclusion concerns the strings describing expressions, not the languages those expressions denote; it uses the usual concrete syntax with arbitrary nested parentheses.
Use state elimination for finite automata on a generalized finite automaton, whose directed edges are labelled by regular expressions. Add a fresh initial state with an -edge to the old initial state and a fresh final state with -edges from all old accepting states. Every missing edge has label , the empty language; parallel edges are merged by union. The label denotes the language containing just the empty word.
When eliminating a state , replace the label on each surviving edge by
Here juxtaposition means concatenation of formal languages, and the Kleene star allows zero or more traversals of the loop at . Then delete and its incident edges. Eliminate every original state; the remaining label is a regular expression for exactly the accepted formal language. The update accounts for paths avoiding and paths entering , looping there any number of times, and leaving it.
An alphabet is a finite nonempty set of symbols. A word over an alphabet is a finite sequence of symbols from , including the empty word ; the set of all words is . A formal language over is any subset .
A regular expression is defined recursively from , , and the individual symbols by the operations of finite union, concatenation, and Kleene star. Its language is defined by
There are only countably many regular expressions: each is a finite word over a finite collection of symbols and punctuation. On the other hand, for every nonempty finite alphabet, is countably infinite, so its power set is uncountable by the Cantor theorem. Thus there are uncountably many languages but only countably many languages denoted by regular expressions. Consequently
A deterministic finite automaton is a tuple with finite state set , finite input alphabet , transition function , initial state , and accepting-state set . It accepts a word when the extended transition function of a deterministic finite automaton carries to a state in . A regular language is a language accepted by some deterministic finite automaton.
The pumping lemma for regular languages says that if a regular language is accepted by an automaton with states, every accepted word of length at least has a decomposition with , , and in the language for every . Indeed, among the states visited before and after the first symbols, two are equal by the pigeonhole principle. The intervening nonempty word labels a loop, which may be traversed any number of times without changing the final accepting state.
In base two, the powers of two have representations , so their language is the regular expression and is regular.
Suppose instead that their base-ten representations formed a regular language. Apply the pumping lemma to a sufficiently long decimal power of two , and put . Pumping gives decimal integers represented by , all powers of two. A direct place-value calculation shows that
for a constant independent of . The lengths, and hence the exponents in , tend to infinity. Dividing by gives
For large , the right side has absolute value less than one while the left side is an integer, so it must vanish. This would make a power of two equal to , impossible for by unique prime factorization. Thus the decimal powers of two are not a regular language.
A regular expression is built from , , and alphabet symbols using union, concatenation, and Kleene star; its language is defined by applying the corresponding set operations recursively. A deterministic finite automaton is a tuple and accepts
Kleene theorem says that the languages denoted by regular expressions are exactly those accepted by finite automata.
Regular languages are closed under finite union, using a product automaton or nondeterministic choice, and under finite intersection, using the product automaton with accepting set .
They are not closed under countable unions or intersections. Every language over a finite alphabet is a countable union of singleton languages, each regular, so a nonregular language such as is a counterexample. It is also
a countable intersection of regular languages, giving the second counterexample.
To remove an internal state , replace each surviving label by . The added term accounts for entering , traversing its loop any number of times, and leaving it. Fresh initial and final states allow all old states to be eliminated, producing a regular expression for the same language.