Theory of Computation & Computer Graphics β Introduction to Finite Automata, NEC licence examination syllabus (Nepal Engineering Council).
Equivalence of RE and Finite Automata
Kleene's theorem β the notation and the machine describe exactly the same languages, and each converts to the other.
π Where this lives: This equivalence is not an abstract nicety; it is a compilation pipeline that runs every time you use grep or a compiler's lexical analyser. The pattern you write is a regular expression, the thing that actually scans your text is a finite automaton, and Thompson's construction is the compiler between them. Ken Thompson patented the technique in 1968 β one of the earliest software patents β precisely because turning a pattern into a machine automatically was a commercially valuable idea. Search "Thompson NFA construction regular expression compilation".
Kleene's theorem and RE β NFA
KLEENE'S THEOREM (1956):
A LANGUAGE IS DESCRIBED BY A REGULAR EXPRESSION IF AND ONLY IF
IT IS ACCEPTED BY A FINITE AUTOMATON.
The proof is in two directions, and BOTH ARE CONSTRUCTIVE β
they are algorithms, not existence arguments, which is what
makes them useful in practice.
ββ DIRECTION 1: REGULAR EXPRESSION β NFA βββββββββββββββββββ
THOMPSON'S CONSTRUCTION, by induction on the structure of the
expression. Each piece is built as an NFA with EXACTLY ONE
START STATE AND EXACTLY ONE ACCEPTING STATE, which is what
makes the pieces composable.
BASE CASES:
β β two states, no transitions at all
Ξ΅ β two states joined by an Ξ΅-transition
a β two states joined by an a-transition
INDUCTIVE CASES, given machines N(r) and N(s):
UNION r + s
A new start state with Ξ΅-transitions into BOTH N(r) and
N(s); their accepting states given Ξ΅-transitions to a
new single accepting state.
ββΞ΅β [N(r)] βΞ΅ββ
βββββ€ βββββ
ββΞ΅β [N(s)] βΞ΅ββ
THE NON-DETERMINISM IS THE CHOICE at the new start
state β the machine tries both branches.
CONCATENATION r s
The accepting state of N(r) is joined by an
Ξ΅-transition to the start state of N(s).
β[N(r)] βΞ΅β [N(s)]ββ
KLEENE STAR r*
A new start and accept state, with FOUR Ξ΅-transitions:
new start β N(r)'s start (enter the loop)
N(r)'s accept β N(r)'s start (repeat)
N(r)'s accept β new accept (exit)
new start β new accept (SKIP ENTIRELY β this is
what supplies Ξ΅ β L(r*))
THE FOURTH TRANSITION IS THE ONE STUDENTS OMIT, and
without it the machine cannot accept the empty string,
which r* must.
THE SIZE GUARANTEE: an expression with n symbols yields an NFA
with AT MOST 2n STATES β the construction adds at most two
states per operator. It is LINEAR, which is why it is
practical.
ββ DIRECTION 2: FINITE AUTOMATON β REGULAR EXPRESSION ββββββ
Two standard methods.
METHOD A β STATE ELIMINATION, the one to use in an exam.
1. Add a NEW start state with an Ξ΅-transition to the old
start, and a NEW single accept state with Ξ΅-transitions
from all old accepting states. (This guarantees the
start has no incoming and the accept no outgoing
transitions.)
2. Repeatedly REMOVE one intermediate state q at a time. For
every pair of states p β q β r, replace the path with a
direct transition labelled
R(p,r) += R(p,q) Β· R(q,q)* Β· R(q,r)
where R(q,q) is the label on q's self-loop (or Ξ΅ if none).
THE STAR ON THE SELF-LOOP IS THE HEART OF THE METHOD: it
captures "go round the loop at q any number of times
before leaving".
3. When only the new start and accept remain, the label on
the single remaining transition IS the regular
expression.
THE ORDER OF ELIMINATION AFFECTS THE SIZE OF THE RESULT BUT
NOT ITS CORRECTNESS. Eliminating the most-connected states
last usually gives a shorter expression.
METHOD B β ARDEN'S THEOREM, an algebraic alternative.
Write one equation per state, expressing it as the set of
strings reaching it. Then solve using:
IF X = XA + B AND Ξ΅ β L(A), THEN X = BA*
THE CONDITION Ξ΅ β L(A) IS ESSENTIAL: without it the solution
is not unique, and this is the detail examiners check.
ββ A WORKED STATE ELIMINATION ββββββββββββββββββββββββββββββ
DFA: states A (start), B (accepting); Ξ΄(A,0)=A, Ξ΄(A,1)=B,
Ξ΄(B,0)=B, Ξ΄(B,1)=A.
Add new start S βΞ΅ A, and new accept T with B βΞ΅ T.
ELIMINATE A: A has a self-loop 0, is entered from S by Ξ΅ and
from B by 1, and leaves to B by 1.
S β B gets Ξ΅ Β· 0* Β· 1 = 0*1
B β B gets 1 Β· 0* Β· 1 added to its existing self-loop
0, giving 0 + 10*1
ELIMINATE B: now S β B β T with B's self-loop (0 + 10*1).
S β T gets 0*1 Β· (0 + 10*1)* Β· Ξ΅
RESULT: 0*1(0 + 10*1)*
READ IT BACK: reach B for the first time with 0*1 (any
zeros, then a one), then stay in B by either reading 0 or by
going out to A and back with 10*1. THE EXPRESSION IS THE
LANGUAGE OF BINARY STRINGS WITH AN ODD NUMBER OF 1s, which
is what this machine recognises β B is entered on each odd
1.
The representations are equivalent in power but not in size: REβNFA is linear, NFAβDFA can be exponential, and DFAβRE can be exponential too. That asymmetry is why choosing a representation is a genuine engineering decision β you convert toward whichever form makes the operation you need cheap.
π Go further: The decidability results here are worth contrasting deliberately with what comes later, because the pattern is one of the deepest lessons in the subject. For regular languages, every natural question β membership, emptiness, finiteness, equivalence, containment β has an algorithm. For context-free languages, equivalence becomes undecidable. For Turing machines, Rice's theorem says essentially every non-trivial property of the recognised language is undecidable. Expressive power and analysability trade off against each other, and that trade-off is why practical systems deliberately use weak formalisms β regular expressions for scanning, type systems that are decidable by design β when they want guarantees rather than generality. Search "expressiveness decidability tradeoff formal languages".
π‘ Exam angle: state Kleene's theorem and note that both directions are constructive. Give Thompson's construction with diagrams for the three base cases and the three operators β and do not omit the skip Ξ΅-transition in the star construction. For the other direction, know state elimination with the rule R(p,r) += R(p,q)Β·R(q,q)*Β·R(q,r), and be able to work a small example fully. Know Arden's theorem X = XA + B βΉ X = BA* and its condition Ξ΅ β L(A). Be ready to draw the full conversion cycle and to list the decidable questions about regular languages.
Syllabus points
RE β FA (Thompson's construction)
FA β RE (state elimination / Arden's theorem)
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.