What is Kleene's theorem?

Kleene's theorem is used to show the equivalence between regular languages, regular expressions, and finite automata. Kleene's theorem states that:

For any regular expression of a language, there exists a finite automaton.

In simple words, a regular expression can be used to represent a finite automaton and vice versa. Regular expressions are composed of unions, concatenations, and Kleene's starKleene's star is unary operation in which the character or expression is repeated n number of times..

Kleene's theorem defines rules to perform these operations on regular expressions to convert them into finite automata.

Conversion of regular expressions to FA's

Rules

The following rules are followed to make conversions:

  • For union operations, a new initial state is introduced and is connected to the individual FA's that are to be unionized.

 For example, M1+M2M_1+M_2, where M1M_1 and M2M_2 can be any regular expression.

g ENTRY q0 q0 ENTRY->q0 q2 q2 q4 q4 q1 q1 q0->q1 ^ q3 q3 q0->q3 ^ q1->q2 M1 q3->q4 M2
The FA of the union of M1 and M2
  • For concatenation operations, a FA is connected to the other by making null transitions from the final state(s) of the first FA to the initial state of the second FA.

  For example, M1.M2M_1.M_2, whereM1M_1and M2M_2are two FA's of a regular expression.

g ENTRY q0 q0 ENTRY->q0 ENTRY1 q3 q3 ENTRY1->q3 q1 q1 q2 q2 q4 q4 q0->q1 ... q0->q2 ... q3->q4 ...
FA of M1 and M2 seperately

  After performing concatenation, the FA will look as follows:

g ENTRY q0 q0 ENTRY->q0 q4 q4 q1 q1 q0->q1 ... q2 q2 q0->q2 ... q3 q3 q1->q3 ^ q2->q3 ^ q3->q4 ...
The FA of the concatenation of M1 and M2
  • For Kleene's star operations, the final state of the FA is looped back with a null transition to a new initial state that is introduced.

  For example, (M1)(M_1)^*whereM1M_1can be any regular expression

g ENTRY q4 q4 ENTRY->q4 q0 q0 q4->q0 ^ q1 q1 q0->q1 ... q3 q3 q0->q3 ... q1->q4 ^ q3->q4 ^
The FA of the Kleene's star of M1

Example

Let's see an example:

Suppose a regular expression ab+bab+b^*. The FA's mentioned below are the building block of the complete regular expression.

g ENTRY q0 q0 ENTRY->q0 ENTRY1 q2 q2 ENTRY1->q2 q3 q3 q1 q1 q2->q3 b q0->q1 a
FA's of a and b

In the next step, the FA's above are used to construct ab and bab \space and\space b^*.

g ENTRY q0 q0 ENTRY->q0 ENTRY1 q4 q4 ENTRY1->q4 q3 q3 q5 q5 q4->q5 ^ q1 q1 q0->q1 a q2 q2 q1->q2 ^ q2->q3 b q6 q6 q5->q6 b q6->q4 ^
Individual FAs for b* and ab

By applying union to the FA's above, the resultant FA is as follows:

g ENTRY q7 q7 ENTRY->q7 q3 q3 q4 q4 q5 q5 q4->q5 ^ q7->q4 ^ q0 q0 q7->q0 ^ q1 q1 q0->q1 a q2 q2 q1->q2 ^ q2->q3 b q6 q6 q5->q6 b q6->q4 ^
The FA of ab+b*

To see the generation of FA's to regular expressions by the state elimination method, click here

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved