Finite automata to regular expression conversion in theory of automata
How we convert the following Finite Automata into Regular expression?
Let’s start drawing the FSA.
we can see that we can move left or we can move right from start state, so we need to build two R.E and then to combine them.
Left part of FA:
Step | State | R.E |
1 | start | b |
2 | 3 | b* |
3 | 3 | a |
4 | end5 | a* |
5 | end5 | Moving back by loop |
Now, add all the R.E from step 1 to 4 and loop it again and again by step 5.
R.E = step1 + step2+ step3+ step4. R.E = b b* a a* For moving back for getting more and more string we can have kleen star closure as mentioned in step 5. So, R.E = (step1 + step2+ step3+ step4)* R.E = ( b b* a a* )* |
Detailed tutorial on what is meaning of kleen star closure or null or epsilon
The right part of FA
Step | State | R.E |
1 | start | a |
2 | 2 | a* |
3 | 2 | b |
4 | end4 | b* |
5 | end4 | Moving back by loop |
Now, add all the R.E from step 1 to 4 and loop it again and again by step 5.
R.E = step1 + step2+ step3+ step4 R.E = a a* b b* For moving back for getting more and more string we can have kleen star closure as mentioned in step 5. So, R.E = (step1 + step2+ step3+ step4)* R.E = ( a a* b b* )* |
Now we combine the left and right R.E by having an option. So the final R.E will be as follows.
R.E = Left part of R.E OR Right part of R.E
R.E = ( b b* a a* )* + ( a a* b b* )* |