Upload
api-3828940
View
7.288
Download
3
Embed Size (px)
Citation preview
Presentation on :Presentation on :
Presented by:-Presented by:- Gaurav Gupta Gaurav Gupta 20/0520/05 IInd B.Tech I.T.IInd B.Tech I.T.
““ARDEN’S ARDEN’S THEOREM”THEOREM”
CONSRTRUCTION OF CONSRTRUCTION OF REGULAR EXPRESSION REGULAR EXPRESSION FROM DFAFROM DFA
The regular expression is mathematical The regular expression is mathematical expression for a given regular language.expression for a given regular language.
We know that for every regular language there We know that for every regular language there exist a DFA.exist a DFA.
We can conclude that for regular expression, We can conclude that for regular expression, regular language for that regular expression and regular language for that regular expression and DFA for that regular language are similar things DFA for that regular language are similar things in different representation.in different representation.
So we can construct regular expression for every So we can construct regular expression for every Deterministic Automata.Deterministic Automata.
ARDEN’S THEOREMARDEN’S THEOREM is one means to implement is one means to implement it. it.
ARDEN’S THEOREMARDEN’S THEOREMLet P and Q be two regular expression Let P and Q be two regular expression over alphabet over alphabet ΣΣ. If P does not contain . If P does not contain NULL STRING (NULL STRING (εε), then :), then :
R = Q + RPR = Q + RP
Has a Has a unique solutionunique solution that is : that is :
R = QP*R = QP*
Now lets have a look at its mathematical Now lets have a look at its mathematical proof…proof…
MATHEMATICAL MATHEMATICAL PROOFPROOFIt can be understood as :It can be understood as :
R = Q + R = Q + RRPPPut the value of R in R.H.S.Put the value of R in R.H.S.
R = Q + R = Q + (Q + RP)(Q + RP) P P= Q +QP + RP= Q +QP + RP22
When we put the value of R again and again we get the When we put the value of R again and again we get the following equation:following equation:
R = Q + QP + QPR = Q + QP + QP2 2 + QP+ QP33…… R = Q ( 1 + P + PR = Q ( 1 + P + P2 2 + P+ P33 …) …) R = Q ( R = Q ( εε + P + P + P + P2 2 + P+ P33 … ) … )
R = QP*R = QP* -(By the definition of closure operation for -(By the definition of closure operation for
regular expression.)regular expression.)
IMPLEMENTATION :IMPLEMENTATION :USE OF ARDEN’S THEOREM TO FIND USE OF ARDEN’S THEOREM TO FIND REGULAR EXPRESSION OF A REGULAR EXPRESSION OF A DFA :DFA :
There are certain There are certain assumptionsassumptions which which are made regarding the transition are made regarding the transition system : system :
The transition diagram should not have The transition diagram should not have εε--transition.transition.
It must have only a single initial state.It must have only a single initial state. Its vertices are q1 , q2 , … , qn . Its vertices are q1 , q2 , … , qn . qi is the final state.qi is the final state.
...contd....contd.
Contd…Contd… wwij ij denotes the regular expression denotes the regular expression
representing the set of labels of edges from representing the set of labels of edges from qqi i to to qqjj .We can get the following set of .We can get the following set of equation in qequation in q11 … q … qn .n .
qq1 = 1 = qq1 1 ww11 11 ++ qq2 2 ww21 21 + … + q+ … + qn n wwn1 n1 + + εε(since q(since q1 1 is the initial state)is the initial state)
qq2 = 2 = qq2 2 ww12 12 ++ qq2 2 ww22 22 + … + q+ … + qn n wwn2n2
::::qqn = n = qq1 1 ww1n 1n ++ qq2 2 ww2n 2n + … + q+ … + qn n wwnnnn
We solve these equations for qWe solve these equations for qi i in termsin terms wwijij‘s ‘s and it will be the required expression.and it will be the required expression.
EXAMPLE # 1 :EXAMPLE # 1 :
QUES:QUES: Find the regular expression Find the regular expression for transition diagram given for transition diagram given below :below :
q1 q2
q3 q4
a
b
a
b
a b
a,b
SOLUTION # 1 :SOLUTION # 1 :
q1 q2
q3 q4
a
b
a
b
b a
a,b
Form the eqns. Form the eqns.
q1 = q2 b + q3 aq1 = q2 b + q3 a + + εε
-eqn(i)-eqn(i)
SOLUTION # 1 :SOLUTION # 1 :
Form the eqns. Form the eqns.
q1 = q2 b + q3 a + q1 = q2 b + q3 a + εε
-eqn(i)-eqn(i)
q2 = q1 a q2 = q1 a -eqn(ii)-eqn(ii)
q1 q2
q3 q4
a
b
a
b
a b
a,b
SOLUTION # 1 :SOLUTION # 1 :
Form the eqns.Form the eqns.q1 = q2 b + q3 a + q1 = q2 b + q3 a + εε
-eqn(i)-eqn(i)
q2 = q1 a q2 = q1 a -eqn(ii)-eqn(ii)
q3 = q1 bq3 = q1 b -eqn(iii)-eqn(iii)
q1 q2
q3 q4
a
b
a
b
a b
SOLUTION # 1 :SOLUTION # 1 :
Form the eqns. Form the eqns. q1 = q2 b + q3 a + q1 = q2 b + q3 a + εε -(i)-(i)
q2 = q1 a q2 = q1 a –(ii)–(ii)
q3 = q1 b q3 = q1 b –(iii)–(iii)
q4 = q2 a + q3 b + q4 = q2 a + q3 b + q4 a + q4 b q4 a + q4 b
-eqn(iv)-eqn(iv)
q1 q2
q3 q4
a
b
a
b
a b
a,b
SOLUTION # 1 :SOLUTION # 1 :
Form the eqns. Form the eqns. q1 = q2 b + q3 a + q1 = q2 b + q3 a + εε –(i)–(i)
q2 = q1 aq2 = q1 a –(ii)–(ii)
q3 = q1 b q3 = q1 b –(iii)–(iii)
q4 = q2 a + q3q4 = q2 a + q3 b + q4 a b + q4 a + q4 b + q4 b –(iv)–(iv)
Put Put q2q2 and and q3q3 in q1 as : in q1 as :q1 = q1 = q1 aq1 ab + b + q1 bq1 ba + a + εεq1 = q1 = εε + + q1 (ab + ba)q1 (ab + ba)q1 = q1 = εε (ab + ba)*(ab + ba)*
q1 q2
q3 q4
a
b
a
b
a b
a,b
So required regular expression isSo required regular expression is : (ab + : (ab + ba)*ba)*
EXAMPLE # 2 :EXAMPLE # 2 :
QUES:QUES: Construct a regular Construct a regular expressionexpression
corresponding to the state corresponding to the state diagram:diagram:
q1
q2
q3
0
1
1
0
0 1
SOLUTION # 2 :SOLUTION # 2 :
Form the eqns.Form the eqns.q1 = q1 0 + q3 0 + q1 = q1 0 + q3 0 + εε -(i)-(i)q2 = q1 1 + q2 1 + q3 1q2 = q1 1 + q2 1 + q3 1 -(ii)-(ii)q3 = q2 0q3 = q2 0 –(iii)–(iii)q2 = q1 1 + q2 1 + (q2 0)1 q2 = q1 1 + q2 1 + (q2 0)1 = q1 1 + q2(1 + 01)= q1 1 + q2(1 + 01)q2 = q1 1(1 + 01)*q2 = q1 1(1 + 01)*So, q1 = q1 0 + q3 0 + So, q1 = q1 0 + q3 0 + εε = q1 0 + q2 00 + = q1 0 + q2 00 + εε = q1 0 + (q1 1(1 + 01)*00) = q1 0 + (q1 1(1 + 01)*00)
+ + εε = q1(0 + 1(1 + 01)*00) + = q1(0 + 1(1 + 01)*00) + εε = = εε(0 + 1(1 + 01)*00)*(0 + 1(1 + 01)*00)*
q1
q2
q3
0
1
1
0
01
So required regular expression isSo required regular expression is : : (0 + 1(1 + 01)*00)*(0 + 1(1 + 01)*00)*
EXAMPLE # 3 :EXAMPLE # 3 :
q4
q2q1
q3
1
0
1
00
0 1
QUES :QUES : Find the regular expression Find the regular expression corresponding to:corresponding to:
11
SOLUTION # 3 :SOLUTION # 3 :
Form the eqns.Form the eqns.q1 = q1 0 + q3 0 + q4 0 + q1 = q1 0 + q3 0 + q4 0 +
εεq2 = q1 1 + q2 1 + q4 1q2 = q1 1 + q2 1 + q4 1q3 = q2 0q3 = q2 0q4 = q3 1q4 = q3 1Now q4 = q3 1 = q2 01Now q4 = q3 1 = q2 01Using q2 equation, we get :Using q2 equation, we get :q2 = q1 1 + q2 1 + q2 011 q2 = q1 1 + q2 1 + q2 011 = q1 1 + q2(1+011)= q1 1 + q2(1+011) = q1 1(1 + 011)*= q1 1(1 + 011)* = q1 (1(1 + 011)*)= q1 (1(1 + 011)*)
q4
q2q1
q3
1
0
1
00
0 1
11
……contd.contd.
SOLN # 3 : (contd…) SOLN # 3 : (contd…)
Put q3 and q4 in q1 eqn.Put q3 and q4 in q1 eqn.q1 = q1 0 + q2 00 + q2 010 + q1 = q1 0 + q2 00 + q2 010 + εε = q1 0 + q2 (00 + 010) + = q1 0 + q2 (00 + 010) + εε = q1 0 + q1 1(1 + 011)* (00 + 010)*= q1 0 + q1 1(1 + 011)* (00 + 010)* = = εε (0 + 1(1 + 011)* (00 + 010))* (0 + 1(1 + 011)* (00 + 010))*Put q2 in q4 eqn.Put q2 in q4 eqn.q4 = q1 1(1 + 011)* 01q4 = q1 1(1 + 011)* 01 = q1 (1(1 + 01)* 01)= q1 (1(1 + 01)* 01) = (0+1(1 + 011)* ( 00 + 010))* ( 1(1 + 011)* = (0+1(1 + 011)* ( 00 + 010))* ( 1(1 + 011)*
01)01)So the required regular expression is :So the required regular expression is :
(0+1(1 + 011)* ( 00 + 010))* ( 1(1 + 011)* 01)(0+1(1 + 011)* ( 00 + 010))* ( 1(1 + 011)* 01)
Prof. Vinay Pathak Prof. Vinay Pathak
H.O. C.S.E. DepartmentH.O. C.S.E. Department
H.B.T.I. Kanpur.H.B.T.I. Kanpur.
Special Thanks Special Thanks to :to :