Skip to content
Part IA Michaelmas, Lent Term

Kleene's Theorem

Statement

Kleene’s Theorem: A language LΣL \subseteq \Sigma^* is regular (recognised by a finite automaton) if and only if it is denoted by a regular expression.

L is regular     regex R.L=L(R)L \text{ is regular} \iff \exists \text{ regex } R. L = L(R)

Two Directions

Part (a): Regex \Rightarrow Automaton

Every regular expression can be converted to an equivalent NFA-ε\varepsilon.

Part (b): Automaton \Rightarrow Regex

Every finite automaton can be converted to an equivalent regular expression.

Part (a): Regex to NFA

Construction by Induction

Base cases:

ε\varepsilon: NFA with one state, start = accept, no transitions.

q\xrightarrow{\quad} \textcircled{\scriptstyle q}

\emptyset: NFA with one state, start state, no accepting states.

q\xrightarrow{\quad} q

Symbol aa: NFA with two states.

q0aq1\xrightarrow{\quad} q_0 \xrightarrow{a} \textcircled{\scriptstyle q_1}

Inductive Constructions

Union R1R2R_1 | R_2:

  • New start state qnewq_{\text{new}}
  • ε\varepsilon-transitions to starts of M1M_1 and M2M_2
  • Accepting: F1F2F_1 \cup F_2

NFA construction for union

Concatenation R1R2R_1 R_2:

  • ε\varepsilon-transitions from accept states of M1M_1 to start of M2M_2
  • Start: start of M1M_1
  • Accepting: F2F_2

NFA construction for concatenation

Star RR^*:

  • New state qnewq_{\text{new}} (start and accepting)
  • ε\varepsilon-transition to old start
  • ε\varepsilon-transitions from old accepting states back to qnewq_{\text{new}}

NFA construction for star

Part (b): NFA to Regex

The State Elimination Method

For automaton M=(Q,Σ,Δ,s,F)M = (Q, \Sigma, \Delta, s, F), compute regular expression for each “region” of the automaton.

A region (q,S,q)(q, S, q') consists of:

  • Start state qq
  • End state qq'
  • Set SS of intermediate states allowed

The regional language LM(q,S,q)L_M(q, S, q') contains strings taking qq to qq' through only states in SS.

Recursive Definition

Base (S=S = \emptyset):

LM(q,,q)={{ε}{a:qaq}q=q{a:qaq}qqL_M(q, \emptyset, q') = \begin{cases} \{\varepsilon\} \cup \{a : q \xrightarrow{a} q'\} & q = q' \\ \{a : q \xrightarrow{a} q'\} & q \neq q' \end{cases}

This is a finite language, hence regular (expressible as finite union of regex).

Inductive step: Pick q0Sq_0 \in S. Define S=S{q0}S' = S \setminus \{q_0\}.

LM(q,S,q)=LM(q,S,q)LM(q,S,q0)LM(q0,S,q0)LM(q0,S,q)L_M(q, S, q') = L_M(q, S', q') \cup L_M(q, S', q_0) \cdot L_M(q_0, S', q_0)^* \cdot L_M(q_0, S', q')

Intuition

Paths through SS either:

  • Don’t visit q0q_0 at all: LM(q,S,q)L_M(q, S', q')
  • Visit q0q_0 at least once: go to q0q_0, loop zero or more times, go to qq'

Final Expression

The language of MM is:

L(M)=qfFLM(s,Q,qf)L(M) = \bigcup_{q_f \in F} L_M(s, Q, q_f)

where ss is the start state and QQ is all states.

Example

Simple Automaton

Simple NFA for regex conversion

q0aq1q_0 \xrightarrow{a} q_1, q1bq0q_1 \xrightarrow{b} q_0, q1cq1q_1 \xrightarrow{c} q_1

Start: q0q_0, Accepting: {q1}\{q_1\}

Computation

LM(q0,{q0,q1},q1)L_M(q_0, \{q_0, q_1\}, q_1):

  • Either go directly q0q1q_0 \to q_1 on aa: contributes aa
  • Or go to q0q_0, loop, and exit: contributes q0aq1cq1bq0aq1q_0 \xrightarrow{a} q_1 \xrightarrow{c} q_1 \xrightarrow{b} q_0 \xrightarrow{a} q_1 pattern

Result (simplified): a(cba)ca(c|ba)^*c^*| or via careful analysis: language of strings with more aa‘s than bb‘s modulo some pattern.


Summary

  • Kleene’s theorem: regular expressions \Leftrightarrow finite automata
  • Regex to NFA: inductive construction using ε\varepsilon-transitions
  • NFA to regex: region decomposition, eliminate states
  • Regular = automata-recognisable = regex-definable