Having gained the knowledge of how to draw a basic Finite State Machine ( DFA, NFA or
-NFA ). We head to deriving a Regular Expression from the provided state machine.
PROOF :-
R = Q + RP
R = Q + QP*P ( Substituting the value of R )
R = Q( + P*P)
R = QP *( P*P = , + = P* )
Let’s solve the provided automata above with the help of Arden’s Theorem.
We see, that on state C, there is a state transition coming from B when a is the input
C = Ba
On state B, There is a self loop on input b, a transition from A when input is a, a transition from state C when input is b
B = Bb + Cb + Aa
On state A, There is a transition ( being the start state, transition must be included), a self loop on input a, a transition from B when input is b.
A = + Aa + Bb
Putting (2) in (1), we get
C = Ba
C = (Aa + Bb + Cb)a
C = Aaa + Bba + Cba
Putting (1) in (2), we get
B = Bb + Cb + Aa
B = Aa + Bb + (Ba)b
B = Aa + B(b + ab)
B = Aa(b + ab)* (Using R = QP*)
Putting (2) in (3), we get
A = + Aa + Bb
A = + Aa + Aa(b + ab)*b
A = + A(a + a(b + ab)*b)
A = (a + a(b + ab)*b)*
A = (a + a(b + ab)*b)*
As a final step, Let’s combine all the simplified equations onto the final state C
C = Ba
C = Aa(b + ab)*a
C = (a + a(b + ab)*b)* a (b + ab)* a
Now this example corresponded to direct derivation from a provided NFA to a Regular Expression.
Let’s say, we are provided with a problem that goes like
Problem : Derive a regular expression to represent a language having even no. of a’s
For this case, it’s difficult to arrive at a regular expression with just trial and error methodology.
We might come across sample solutions like :-
which might satisfy some cases, but also leads to unwanted cases and missing cases with alternate a’s and b’s.
The
best way to solve this problem is to first draw a finite state machine
for the same, and then derive the regular expression from the same.
Now that we have the DFA, let’s solve it using Arden’s Theorem of Individual State Equations.
We see that on state A, there is a self loop with input b and transition from B with input a
A = + Ab + Ba
We see that on state B, there is a self loop on input b and transition from A when input is a.
B = Aa + Bb
Taking equation for B, we can apply Arden’s theorem
B = Aa + Bb B = Aab*
Substituting the value of B in A we get
A = + Ab + Ba A = + Ab + (Aab*)a A = ( b + ab*a )* A = ( b + ab*a )*
Hence, the regular expression for the provided problem is RE : ( b + ab*a )*
We see that Arden’s theorem can be used as a powerful simplification tool to determine the Regular Expressions and also to design the desired Finite State Machine from the same.
0 Comments