Question
Question: For the following regular expressions, draw the FA (Finite Automata) recognizing the corresponding l...
For the following regular expressions, draw the FA (Finite Automata) recognizing the corresponding language. [5]
i) ab∗+ba∗+b∗a+(a∗b)∗ ii) b∗a(a+b)∗ab∗

FA drawings as above
Solution
To draw the Finite Automata (FA) for the given regular expressions, we will construct Non-deterministic Finite Automata (NFA) using standard conversion rules.
Part i) ab∗+ba∗+b∗a+(a∗b)∗
This regular expression is a union of four sub-expressions. We will construct an NFA for each sub-expression and then combine them using a new start state and a new final state connected by ϵ-transitions.
Let Qstart be the global initial state and Qfinal be the global final state.
-
FA for ab∗:
- State Q1,1 (initial for this component) transitions to Q1,2 on 'a'.
- State Q1,2 has a self-loop on 'b'.
- Q1,2 is the final state for this component.
- Transitions: QstartϵQ1,1, Q1,1aQ1,2, Q1,2bQ1,2, Q1,2ϵQfinal.
-
FA for ba∗:
- State Q2,1 (initial for this component) transitions to Q2,2 on 'b'.
- State Q2,2 has a self-loop on 'a'.
- Q2,2 is the final state for this component.
- Transitions: QstartϵQ2,1, Q2,1bQ2,2, Q2,2aQ2,2, Q2,2ϵQfinal.
-
FA for b∗a:
- State Q3,1 (initial for this component) has a self-loop on 'b'.
- State Q3,1 transitions to Q3,2 on 'a'.
- Q3,2 is the final state for this component.
- Transitions: QstartϵQ3,1, Q3,1bQ3,1, Q3,1aQ3,2, Q3,2ϵQfinal.
-
FA for (a∗b)∗:
- Let's first construct FA for a∗b:
- State Q4,2 has a self-loop on 'a'.
- From Q4,2, it transitions to Q4,3 on 'b'.
- Q4,2 is the start of a∗b, Q4,3 is the end of a∗b.
- Now apply Kleene star:
- State Q4,1 is the initial state for (a∗b)∗.
- Q4,1 transitions to Q4,2 via ϵ (start of a∗b).
- Q4,1 transitions to Qfinal via ϵ (for the empty string, i.e., zero repetitions of a∗b).
- Q4,3 transitions back to Q4,1 via ϵ (for repetitions of a∗b).
- Q4,3 transitions to Qfinal via ϵ (end of a∗b to global final).
- Transitions: QstartϵQ4,1, Q4,1ϵQfinal, Q4,1ϵQ4,2, Q4,2aQ4,2, Q4,2bQ4,3, Q4,3ϵQ4,1, Q4,3ϵQfinal.
- Let's first construct FA for a∗b:
The complete NFA is shown below:
Part ii) b∗a(a+b)∗ab∗
This regular expression is a concatenation of five parts. We will construct an NFA for each part and then concatenate them sequentially.
Let Q0 be the initial state and QF be the final state.
-
FA for b∗:
- State Q0 (initial) has a self-loop on 'b'. Q0 is also a final state for this part.
- Transitions: Q0bQ0.
-
FA for a:
- State Q1 transitions to Q2 on 'a'. Q2 is a final state for this part.
- Transitions: Q1aQ2.
-
FA for (a+b)∗:
- State Q3 has self-loops on 'a' and 'b'. Q3 is also a final state for this part.
- Transitions: Q3aQ3, Q3bQ3.
-
FA for a:
- State Q4 transitions to Q5 on 'a'. Q5 is a final state for this part.
- Transitions: Q4aQ5.
-
FA for b∗:
- State Q6 has a self-loop on 'b'. Q6 is also a final state for this part.
- Transitions: Q6bQ6.
Now, concatenate these components using ϵ-transitions. The final state of one component becomes the initial state of the next via an ϵ-transition. The first component's initial state is the overall initial state, and the last component's final state is the overall final state.
- Q0 is the overall initial state.
- The final states of b∗ are Q0.
- Connect Q0 to Q1 (start of 'a') via ϵ.
- The final states of 'a' are Q2.
- Connect Q2 to Q3 (start of (a+b)∗) via ϵ.
- The final states of (a+b)∗ are Q3.
- Connect Q3 to Q4 (start of 'a') via ϵ.
- The final states of 'a' are Q5.
- Connect Q5 to Q6 (start of b∗) via ϵ.
- The final states of b∗ are Q6.
- Q6 is the overall final state.
The complete NFA is shown below:
The final state Q6 can also be the final state directly. The ϵ transition from Q6 to Qfinal is optional if Q6 is marked as final.
The solution involves constructing Non-deterministic Finite Automata (NFA) for the given regular expressions. For regular expressions involving union (+), a new start state and a new final state are introduced, with ϵ-transitions connecting the new start state to the start states of the individual components and the final states of the individual components to the new final state. For concatenation, ϵ-transitions are used to connect the final state of one component's FA to the initial state of the next component's FA. For Kleene star (∗), the standard construction involves creating a loop using ϵ-transitions from the final state back to the initial state of the sub-expression, and also an ϵ-transition from the initial state to the final state to account for zero repetitions.