Professional Documents
Culture Documents
DFA To Regular Expressions
DFA To Regular Expressions
DFA To Regular Expressions
<DFA to Regular
expressions>
1. Aiden’s Method(Theorem)
Aiden’s methods(Theorem)
Arden’s theorem states that:
“If P and Q are two regular expressions over ∑ and P does
not contain any null string(ε), then the following equation in R
given by
has a unique solution i.e. “
It means, whenever we get any equation in the form of
, then we can directly replace it with
R = Q + RP
Can be written
as:
R = QP*
5
Proof:
R = Q + RP________(1)
R = Q + RP
R = Q + RP
Can be written
R = Q + (Q+RP)P
as:
R = Q + QP + RP2 R = QP*
R = Q + QP + (Q+RP)P2
R = Q + QP + QP2 +RP3
R = Q + QP + QP2 + QP3 +….+QPN+RPN+1
R = Q [^+P+P2+P3+….]
R = QP*________(2)
6
Note:
Solution: R = Q + RP
q1 = ε _____(1) Can be written
as:
q2 = q1a + q2a _____(2) R = QP*
q3 = q1a + q3a _____(3)
Now, Put q1=ε in eq.2
q2 = ε.a+ q2(a)
7
R=Q+R P R = Q P* Note:
R = Q + RP
Now, Put q1=ε in eq.3
Can be written
as:
q3 = q1(b) + q3(a)
R = QP*
q3 = ε.b + q3(a)
q3 = b + q3(a) Can be written as q3 = b a*_____(5)
R =Q+R P R = Q P*
As we have two final states that are q2 and q3 therefore , we have to join eq. (4) and eq. (5) to
generate final regular expression.
Solution:
q1 = ε + q1a + q3a_____(1)
q2 = q1b + q2b + q3b_____(2)
q3 = q2a_____(3)
9
Solution:
q1 = ε + q1a + q2b_____(1)
q2 = q1a + q2b + q3a_____(2)
q3 = q2a_____(3)
11
Note:
R = Q + RP
Can be written
as:
R = QP*
12
q2 = q1a(b + aa)*____(4)
q1 = (a + a(b + aa)*b)*___(5)
Put eq.1 in eq.4
q2 = (a + a(b + aa)*b)*a(b + aa)*____(6)
q3 = q2a_____(3)
Put eq.6 in eq.3
q3 = (a + a(b + aa)*b)*a(b + aa)*a
As q3 is final state , so it is our required regular expression.
Step-1
➢ Initial State of DFA must not have any incoming edge.
➢ If there is any incoming edge at initial state then, create a
new initial state have no incoming edge.
Example:
15
Step-02
➢ There must be one/single final state.
➢ If there exist multiple final states then, convert all final
states into non-final states and create a single final state.
Example:
16
Step-03
➢ The final state must not have any outgoing edge.
➢ If there exist any outgoing edge at final state then, make it
non-final and create new final state having no outgoing
edge.
Example:
17
Step-04
➢ Eliminate all intermediate(states between initial and final
state) states.
➢ These intermediate states can be eliminated in any order.
Example:
18
Problem 01. Convert this DFA into R.E. using State Elimination Method.
Solution:
Step-01:
initial state has incoming edge .
So, we create a new initial state.
19
Step-02:
There are no multiple final state in the above diagram ( No action needed )
Step-03:
Final state B has an outgoing edge .
So , make state B non-final and add new final state.
20
R.E. = 0(10)*
21
Problem 02. Convert this DFA into R.E. using State Elimination Method.
R.E. = 0
23
Problem 03. Convert this DFA into R.E. using State Elimination Method.
Solution:
Step – 01:
Initial state has incoming edges.
So, we create new initial state.
24
We have initial and final states now . Their cost is our required R.E.
Problem 04. Convert this DFA into R.E. using State Elimination Method.
Solution: Note that state D is a dummy/dead state because it can’t reach final state
anyway, so we have to remove it , in order to proceed.
28
Step – 01:
Initial state has incoming edge .
So, we create new initial state.
29
Step – 02:
There are multiple final state exists
Make them non-final and convert them into single state by creating a
new final state
30
Step – 03: There is no outgoing edge from final state(No action required)
Step – 04: (Removing intermediate states)
Eliminating State C;
31
No Eliminating state B
32
We have initial and final states now . Their cost is our required R.E.
Problem 05. Convert this DFA into R.E. using State Elimination Method.
Solution:
Step – 01:
Initial state has incoming edge
So, we create a new initial state
34
Eliminating State C
37
Eliminating State A
R.E. = ( 01 + 1 (0 + 11))*
38
Problem 06. Convert this DFA into R.E. using State Elimination Method.
Solution:
Step – 01: There is no incoming edge at initial state(No process required)
Step – 02: There are multiple Final states that are B and C.
So, we make B and C non-final and create a new final state.
39
Step – 03 : There is no outgoing edge at final state qf. (No action required)
Step – 04 : Eliminating all intermediate states.
First eliminating state B
40
Eliminating state C