Theory of Computation
Lecture 8 {29/30 July}
Swati Jaipurkar,
Assistant Professor,
Department of Computer Science & Engg
MIT, Aurangabad, Maharashtra. INDIA
Regular Expression
▪ Regular expressions aim to solve a simple problem: defining strings
to match other strings.
▪ It is a sequence of characters that define a search pattern, mainly
for use in pattern matching with strings, or string matching, i.e. “find
and replace”-like operations.
▪ However, the power of regular expressions extends far beyond
matching a single word: regular expressions can be used to match
complex patterns of symbols also.
Applications of RE
▪ Regular expressions have numerous applications throughout
computer science, ranging from the mundane (compilers) to
the tasks we perform every day (using search engines).
▪ Over the years, the use of regular expressions in search
engines has waned, giving way to more advanced techniques
for indexing and matching search strings.
Recursive Definition of RE
▪ Regular Languages are the most restricted types of languages and are accepted by finite
automata.
Regular Expressions are used to denote regular languages. An expression is regular if:
1. Any terminal symbol (symbol in ∑), ᴧ and ф are regular expressions.
2. The union of two regular expressions R1 and R2, written as R1+ R2, is also a regular expression.
3. The concatenation of two regular expressions R1 and R2, written as R1.R2, is also a regular
expression.
4. The iteration (or closure) of a regular expression R written as R*, is also a regular expression.
5. If R is a regular expression, then (R) is also a regular expression.
6. The regular expressions over ∑ are precisely those obtained recursively by the application of the
rules 1-5 once or several times.
Operators of RE
1. Union of two languages: L, M are Two languages, then L U M is the set of strings
that are either in L or M or both.
E.g.: if L={011,10,111} and M={ℇ,011} then L U M ={ℇ,10,011,111}
2. Concatenation: It is a set that is formed by taking any string in L and concatenating it
with any string in M.
3. The Closure(Star/Kleene Closure) : represents the set of those strings that can be
formed by taking any number of strings from L, possibly with repetitions and
concatenating all of them.
L={0,11}, then L*=all strings of 0’s and 1’s such that 1’s come in pair.
L={ℇ,0,11,011,01111,110,11110}
Writing RE : (*) and (+)
▪ These symbols act as repeaters and tell the computer that the preceding
character is to be used for more than just one time.
•The asterisk symbol ( * ):
Match the preceding character (or set of characters) for 0 or more
times (up to infinite).
•Example : The regular expression ab*c will give ac, abc, abbc, abbbc….and so on
•The Plus symbol ( + ):
Repeat the preceding character (or set of characters) for at least one
or more times(up to infinite).
•Example : The regular expression ab+c will give abc, abbc, abbc, … and so on.
Describe the following sets by regular expressions:
(a) L1 = {the set of all strings of O's and 1's ending in 00}
Ans: Any string in L1 is obtained by concatenating any string over {0,1} and the string 00.
{0,1} is represented by (0 + 1).
Hence L1 is represented by (0 + 1)* 00.
(b) L2 ={ᴧ, 11, 1111, 111111, ...}
Ans: Any element of L2 is either ᴧ or a string of even number of 1's, i.e. a string of the form
(11)n, n>=0. So L2 can be represented by (11)*.
IDENTITIES FOR REGULAR EXPRESSIONS
▪ Simplification of RE:
Replacing regular expression in to more simpler Regular expression.
I1: ф + R =R I2: ф R = R ф = R
I3: ᴧ R=R ᴧ = R I4: ᴧ* = ᴧ and ф* = ᴧ
I5: R+R=R I6: R*R*=R*
I7: RR*= R*R I8: (R*)*=R*
I9: ᴧ + RR* =R*= ᴧ + R*R I10: (PQ)*P=P(QP)*
I11: (P+Q)*= (P*Q*)* = P*Q* I 12: (P+Q)R= PR+QR
Arden’s Theorem: Let P and Q be two regular expressions over ∑. If P does
not contain ᴧ, then the following equation in R, namely R = Q + RP has
unique solution R=QP*
▪ Let R= QP* & put in above eq. R=Q+RP
▪ QP* = Q + (QP*)P
= Q (ᴧ+ P*P) …….. using I9
= QP* Hence Proved..
Let’s prove the uniqueness:
replace R by Q + RP on the R.H.S. of given
expression,
Q + RP = Q + (Q + RP)P
=Q + QP + RPP
= Q + QP + RP2
= Q + QP + QP2 + + QPi + RPi+1
= Q(ᴧ+ P + P2 + ……. + pi) + RPi+1
From given eq.
R = Q(ᴧ + P + P2 + ……. + pi) + RPi+1 ……………. for i >= 0
Lets prove R=Q+RP is equal to QP*
Let w be a string of length in the set R, then w must
belong to
R = Q(ᴧ + P + P2 + ……. + pi) + RPi+1 for i >= 0
As P does not contain ᴧ, RPi+1 has all strings with length
equal to i+1 and so w does not belong to the set RPi+1
This means w belongs to the set Q(ᴧ+ P + P2 + ……. + pi)
and hence to QP*
Prove (1 + 00*1) + (1 + 00*1)(0 + 10*1)* (0 + 10*1) =0*1(0 + 10*1)*.
L.H.S. = (1 + 00*1) (ᴧ + (0 + 10*1)* (0 + 10*1) using (I12)
= (1 + 00*1) (0 + 10*1)* using (I9)
= (ᴧ + 00*)1 (0 + 10*1)* using (I12)
= 0* 1 (0 + 10*1)* using (I9)
= R.H.S.
▪ Hence Proved.
Finite Automata AND RE
Two notations turn out to represent exactly the same set of languages (Regular Language)
1. The regular expression
2. Finite automaton
Both are totally different.
Deterministic finite automata and the two kinds of nondeterministic finite automata with
and without null transitions accept the same class of languages.
In order to show that the regular expressions define the same class we must show that
1. Every language defined by one of these automata is also defined by a regular
expression.
2. Every language defined by a regular expression is defined by one of these automata.
Continued…..
TRANSITION SYSTEM
▪ Convert a transition system with ᴧ-moves into an equivalent transition system without ᴧ
-moves
▪ Lets replace a ᴧ -move from vertex V1 to vertex V2
Step 1: Find all the edges starting from V2
Step 2: Duplicate all these edges starting from V1, without changing the edge labels.
Step 3: If V1 is an initial state, make V2 also as initial state.
Step 4: If V2 is a final state, make V1 also as the final state.
Consider a finite automaton, with ᴧ -moves as given below & obtain
an equivalent automaton without ᴧ -moves.
• First eliminate the ᴧ -move from qo to q1
• qo is V1 and q1 is V2
• Now eliminate the ᴧ -move from q1 to q2
• q1 is V1 and q2 is V2
Consider a finite automaton, with ᴧ -moves as given below & obtain
an equivalent automaton without ᴧ -moves.
• First eliminate the ᴧ -move from qo to q3
• qo is V1 and q3 is V2
ANS:
Finite Automata AND RE
NFAs WITH ᴧ-MOVES AND RE
▪Kleene's theorem: If R is a regular expression over L representing L as
subset of ∑* , then there exists an NFA M with ᴧ-moves such that L = T(M).
▪ It gives a method of constructing NFAs accepting P + Q, PQ and P* using the
NFAs corresponding to P and Q.
▪ Then obtain NFA without null moves.
▪ Convert NFA to DFA.
NFAs WITH ᴧ-MOVES AND RE
▪ Let L(R) denote the set represented by R.
▪ Basis: Let the number of characters in R be ONE. Then R =ᴧ, or R = ф , or R =ai, ai ℇ ∑ the
following transition systems will recognise these RE
▪ Induction step: Assume that the theorem is true for regular expressions having ‘n’ characters.
Let R be a regular expression having (n+1) characters.
The RE can be written as R=P+Q or R = PQ or R =P*
By induction hypothesis, L(P) and L(Q) are recognized by M1 and M2, where M 1 and M2 are NFAs
with ᴧ-moves, such that L(P) = T(M1 ) and L(Q) = T(M2).
NFAs WITH ᴧ-MOVES AND RE
▪ M1 & M2 can be represented by Transition Diagram as follows:
Case 1: R =P + Q.
Lets construct an NFA M with ᴧ-moves that accepts L(P + Q)
NFA M1 NFA M2
NFAs WITH ᴧ-MOVES AND RE
Case 2 : R =PQ
Lets construct an NFA M with ᴧ-moves that accepts L(PQ)
NFAs WITH ᴧ-MOVES AND RE
Case 3 : R =P*
Lets construct an NFA M with ᴧ-moves that accepts L(P)*
FA and RE
Example : Construct a DFA with reduced states equivalent to the R.E.
10 + (0 + 11»)0*1.
▪ Step 1: Construct the transition graph with ᴧ-moves using the constructions of Theorem 5.2 (Kleene's
theorem) .
▪ Step 2: Then eliminate ᴧ-moves to get transition diagram without null moves.
Lets start drawing transition diagram:
Now eliminate the concatenation operators in the given RE by introducing new states q1 and q2 as
shown below:
Continued……….
▪ Next eliminate the * operations by introducing two new States with ᴧ-moves
▪ Then eliminate concatenations and + operation by introducing new states:
After removing
Null Transitions: -
Continued……….
▪ Construct the DFA equivalent to NFA
▪ Transition table and diagram for DFA is :
DFA for RE 10 + (0 + 11»)0*1
ALGEBRAIC METHOD USING ARDEN'S THEOREM
▪ To find the RE recognized by a transition system.
The following assumptions are made regarding the transition system:
(i) The transition graph does not have null-moves. ii) It has only one initial state, say v1
iii) Its vertices are v1, …..vn
iv) Vi the RE - the set of strings accepted by the system even though vi is a final state.
v) αij denotes the RE representing the set of labels of edges from vi to vj, When there is no such
edge αij =ф. Consequently, we can get the following set of equations in V1 to Vn:
V1=V1 α11 + V2 α21+…….. +Vn αn1 + ᴧ
V2=V1 α21 + V2 α22+…….. +Vn αn2
.
Vn=V1 αn1 + V2 αn2+…….. +Vn αnn
Continued……………
▪ By repeatedly applying substitutions and Theorem 5.1 (Arden's theorem), we can
express Vi in terms of αij’s.
▪ The Union of all Vi’s give the set of strings recognized by the transition system.
▪ Construct a regular expression corresponding to the following state diagram by
Arden’s Theorem: Let P and Q be two regular expressions over ∑. If P does
not contain ᴧ, then the following equation in R, namely R = Q + RP has
unique solution R=QP*
▪ Let R= QP* & put in above eq. R=Q+RP
▪ QP* = Q + (QP*)P
= Q (ᴧ+ P*P) …….. using I9
= QP* Hence Proved..
Let’s prove the uniqueness:
replace R by Q + RP on the R.H.S. of given
expression,
Q + RP = Q + (Q + RP)P
=Q + QP + RPP
= Q + QP + RP2
= Q + QP + QP2 + + QPi + RPi+1
= Q(ᴧ+ P + P2 + ……. + pi) + RPi+1
From given eq.
R = Q(ᴧ + P + P2 + ……. + pi) + RPi+1 ……………. for i >= 0
Lets prove R=Q+RP is equal to QP*
Let w be a string of length in the set R, then w must
belong to
R = Q(ᴧ + P + P2 + ……. + pi) + RPi+1 for i >= 0
As P does not contain ᴧ, RPi+1 has all strings with length
equal to i+1 and so w does not belong to the set RPi+1
This means w belongs to the set Q(ᴧ+ P + P2 + ……. + pi)
and hence to QP*
EQUIVALENCE OF TWO FINITE AUTOMATA
Two finite automata over L are equivalent if they accept
the same set of strings over L.
Two finite automata over L are not equivalent if they
satisfy the following: One autmaton reaches a final state
on application of w, whereas the other automaton
reaches a nonfinal state.
To test the equivalence of two finite automata
Comparison method is used.
Let M1 and M2 be two finite automata over L.
Construct a comparison table consisting of n + 1
columns. where n is the number of input symbols. The
first column consists of pairs of vertices of the form (q,
q'), where q E M1 and q’ E M2.
The comparison table is constructed by starting with the pair of
initial states of M1 and M2.
The first elements in the subsequent columns are (qa, q’a), where
qa and q’a are reachable by a-paths from q and q’.
Repeat the construction by considering the pairs in the second
and subsequent columns which are not in the first column.
There are two cases:
Case 1: If we reach a pair (q. q') such that q is a final state of M1,
and q’ is a nonfinal state of M2 or vice versa, we terminate the
construction and conclude that M1 and M2 are not equivalent.
Case 2 : When the construction is terminated when no new
element appears in the second and subsequent columns which
are not in the first column (i.e. when all the elements in the
second and subsequent columns appear in the first column). In
this case we conclude that M1 and M2 are equivalent.
Example 1: Consider the following two DFAs M1 and M2 over
{0, 1} as shown below. Determine whether M1 and M2 are
equivalent.
State / ∑ i/p = c i/p=d
(q1,q4) (q1,q4) (q2,q5)
(q2,q5) (q3,q6) (q1,q4)
(q3,q6) (q2,q7) (q3,q6)
(q2,q7) (q3,q6) (q1,q4)
M1 and M2 are equivalent

FLAT.pdf

  • 1.
    Theory of Computation Lecture8 {29/30 July} Swati Jaipurkar, Assistant Professor, Department of Computer Science & Engg MIT, Aurangabad, Maharashtra. INDIA
  • 2.
    Regular Expression ▪ Regularexpressions aim to solve a simple problem: defining strings to match other strings. ▪ It is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. “find and replace”-like operations. ▪ However, the power of regular expressions extends far beyond matching a single word: regular expressions can be used to match complex patterns of symbols also.
  • 3.
    Applications of RE ▪Regular expressions have numerous applications throughout computer science, ranging from the mundane (compilers) to the tasks we perform every day (using search engines). ▪ Over the years, the use of regular expressions in search engines has waned, giving way to more advanced techniques for indexing and matching search strings.
  • 4.
    Recursive Definition ofRE ▪ Regular Languages are the most restricted types of languages and are accepted by finite automata. Regular Expressions are used to denote regular languages. An expression is regular if: 1. Any terminal symbol (symbol in ∑), ᴧ and ф are regular expressions. 2. The union of two regular expressions R1 and R2, written as R1+ R2, is also a regular expression. 3. The concatenation of two regular expressions R1 and R2, written as R1.R2, is also a regular expression. 4. The iteration (or closure) of a regular expression R written as R*, is also a regular expression. 5. If R is a regular expression, then (R) is also a regular expression. 6. The regular expressions over ∑ are precisely those obtained recursively by the application of the rules 1-5 once or several times.
  • 5.
    Operators of RE 1.Union of two languages: L, M are Two languages, then L U M is the set of strings that are either in L or M or both. E.g.: if L={011,10,111} and M={ℇ,011} then L U M ={ℇ,10,011,111} 2. Concatenation: It is a set that is formed by taking any string in L and concatenating it with any string in M. 3. The Closure(Star/Kleene Closure) : represents the set of those strings that can be formed by taking any number of strings from L, possibly with repetitions and concatenating all of them. L={0,11}, then L*=all strings of 0’s and 1’s such that 1’s come in pair. L={ℇ,0,11,011,01111,110,11110}
  • 6.
    Writing RE :(*) and (+) ▪ These symbols act as repeaters and tell the computer that the preceding character is to be used for more than just one time. •The asterisk symbol ( * ): Match the preceding character (or set of characters) for 0 or more times (up to infinite). •Example : The regular expression ab*c will give ac, abc, abbc, abbbc….and so on •The Plus symbol ( + ): Repeat the preceding character (or set of characters) for at least one or more times(up to infinite). •Example : The regular expression ab+c will give abc, abbc, abbc, … and so on.
  • 7.
    Describe the followingsets by regular expressions: (a) L1 = {the set of all strings of O's and 1's ending in 00} Ans: Any string in L1 is obtained by concatenating any string over {0,1} and the string 00. {0,1} is represented by (0 + 1). Hence L1 is represented by (0 + 1)* 00. (b) L2 ={ᴧ, 11, 1111, 111111, ...} Ans: Any element of L2 is either ᴧ or a string of even number of 1's, i.e. a string of the form (11)n, n>=0. So L2 can be represented by (11)*.
  • 8.
    IDENTITIES FOR REGULAREXPRESSIONS ▪ Simplification of RE: Replacing regular expression in to more simpler Regular expression. I1: ф + R =R I2: ф R = R ф = R I3: ᴧ R=R ᴧ = R I4: ᴧ* = ᴧ and ф* = ᴧ I5: R+R=R I6: R*R*=R* I7: RR*= R*R I8: (R*)*=R* I9: ᴧ + RR* =R*= ᴧ + R*R I10: (PQ)*P=P(QP)* I11: (P+Q)*= (P*Q*)* = P*Q* I 12: (P+Q)R= PR+QR
  • 9.
    Arden’s Theorem: LetP and Q be two regular expressions over ∑. If P does not contain ᴧ, then the following equation in R, namely R = Q + RP has unique solution R=QP* ▪ Let R= QP* & put in above eq. R=Q+RP ▪ QP* = Q + (QP*)P = Q (ᴧ+ P*P) …….. using I9 = QP* Hence Proved.. Let’s prove the uniqueness: replace R by Q + RP on the R.H.S. of given expression, Q + RP = Q + (Q + RP)P =Q + QP + RPP = Q + QP + RP2 = Q + QP + QP2 + + QPi + RPi+1 = Q(ᴧ+ P + P2 + ……. + pi) + RPi+1 From given eq. R = Q(ᴧ + P + P2 + ……. + pi) + RPi+1 ……………. for i >= 0 Lets prove R=Q+RP is equal to QP* Let w be a string of length in the set R, then w must belong to R = Q(ᴧ + P + P2 + ……. + pi) + RPi+1 for i >= 0 As P does not contain ᴧ, RPi+1 has all strings with length equal to i+1 and so w does not belong to the set RPi+1 This means w belongs to the set Q(ᴧ+ P + P2 + ……. + pi) and hence to QP*
  • 10.
    Prove (1 +00*1) + (1 + 00*1)(0 + 10*1)* (0 + 10*1) =0*1(0 + 10*1)*. L.H.S. = (1 + 00*1) (ᴧ + (0 + 10*1)* (0 + 10*1) using (I12) = (1 + 00*1) (0 + 10*1)* using (I9) = (ᴧ + 00*)1 (0 + 10*1)* using (I12) = 0* 1 (0 + 10*1)* using (I9) = R.H.S. ▪ Hence Proved.
  • 11.
    Finite Automata ANDRE Two notations turn out to represent exactly the same set of languages (Regular Language) 1. The regular expression 2. Finite automaton Both are totally different. Deterministic finite automata and the two kinds of nondeterministic finite automata with and without null transitions accept the same class of languages. In order to show that the regular expressions define the same class we must show that 1. Every language defined by one of these automata is also defined by a regular expression. 2. Every language defined by a regular expression is defined by one of these automata.
  • 12.
  • 13.
    TRANSITION SYSTEM ▪ Converta transition system with ᴧ-moves into an equivalent transition system without ᴧ -moves ▪ Lets replace a ᴧ -move from vertex V1 to vertex V2 Step 1: Find all the edges starting from V2 Step 2: Duplicate all these edges starting from V1, without changing the edge labels. Step 3: If V1 is an initial state, make V2 also as initial state. Step 4: If V2 is a final state, make V1 also as the final state.
  • 14.
    Consider a finiteautomaton, with ᴧ -moves as given below & obtain an equivalent automaton without ᴧ -moves. • First eliminate the ᴧ -move from qo to q1 • qo is V1 and q1 is V2 • Now eliminate the ᴧ -move from q1 to q2 • q1 is V1 and q2 is V2
  • 15.
    Consider a finiteautomaton, with ᴧ -moves as given below & obtain an equivalent automaton without ᴧ -moves. • First eliminate the ᴧ -move from qo to q3 • qo is V1 and q3 is V2 ANS:
  • 16.
    Finite Automata ANDRE NFAs WITH ᴧ-MOVES AND RE ▪Kleene's theorem: If R is a regular expression over L representing L as subset of ∑* , then there exists an NFA M with ᴧ-moves such that L = T(M). ▪ It gives a method of constructing NFAs accepting P + Q, PQ and P* using the NFAs corresponding to P and Q. ▪ Then obtain NFA without null moves. ▪ Convert NFA to DFA.
  • 17.
    NFAs WITH ᴧ-MOVESAND RE ▪ Let L(R) denote the set represented by R. ▪ Basis: Let the number of characters in R be ONE. Then R =ᴧ, or R = ф , or R =ai, ai ℇ ∑ the following transition systems will recognise these RE ▪ Induction step: Assume that the theorem is true for regular expressions having ‘n’ characters. Let R be a regular expression having (n+1) characters. The RE can be written as R=P+Q or R = PQ or R =P* By induction hypothesis, L(P) and L(Q) are recognized by M1 and M2, where M 1 and M2 are NFAs with ᴧ-moves, such that L(P) = T(M1 ) and L(Q) = T(M2).
  • 18.
    NFAs WITH ᴧ-MOVESAND RE ▪ M1 & M2 can be represented by Transition Diagram as follows: Case 1: R =P + Q. Lets construct an NFA M with ᴧ-moves that accepts L(P + Q) NFA M1 NFA M2
  • 19.
    NFAs WITH ᴧ-MOVESAND RE Case 2 : R =PQ Lets construct an NFA M with ᴧ-moves that accepts L(PQ)
  • 20.
    NFAs WITH ᴧ-MOVESAND RE Case 3 : R =P* Lets construct an NFA M with ᴧ-moves that accepts L(P)*
  • 21.
  • 22.
    Example : Constructa DFA with reduced states equivalent to the R.E. 10 + (0 + 11»)0*1. ▪ Step 1: Construct the transition graph with ᴧ-moves using the constructions of Theorem 5.2 (Kleene's theorem) . ▪ Step 2: Then eliminate ᴧ-moves to get transition diagram without null moves. Lets start drawing transition diagram: Now eliminate the concatenation operators in the given RE by introducing new states q1 and q2 as shown below:
  • 23.
    Continued………. ▪ Next eliminatethe * operations by introducing two new States with ᴧ-moves ▪ Then eliminate concatenations and + operation by introducing new states: After removing Null Transitions: -
  • 24.
    Continued………. ▪ Construct theDFA equivalent to NFA ▪ Transition table and diagram for DFA is : DFA for RE 10 + (0 + 11»)0*1
  • 25.
    ALGEBRAIC METHOD USINGARDEN'S THEOREM ▪ To find the RE recognized by a transition system. The following assumptions are made regarding the transition system: (i) The transition graph does not have null-moves. ii) It has only one initial state, say v1 iii) Its vertices are v1, …..vn iv) Vi the RE - the set of strings accepted by the system even though vi is a final state. v) αij denotes the RE representing the set of labels of edges from vi to vj, When there is no such edge αij =ф. Consequently, we can get the following set of equations in V1 to Vn: V1=V1 α11 + V2 α21+…….. +Vn αn1 + ᴧ V2=V1 α21 + V2 α22+…….. +Vn αn2 . Vn=V1 αn1 + V2 αn2+…….. +Vn αnn
  • 26.
    Continued…………… ▪ By repeatedlyapplying substitutions and Theorem 5.1 (Arden's theorem), we can express Vi in terms of αij’s. ▪ The Union of all Vi’s give the set of strings recognized by the transition system. ▪ Construct a regular expression corresponding to the following state diagram by
  • 27.
    Arden’s Theorem: LetP and Q be two regular expressions over ∑. If P does not contain ᴧ, then the following equation in R, namely R = Q + RP has unique solution R=QP* ▪ Let R= QP* & put in above eq. R=Q+RP ▪ QP* = Q + (QP*)P = Q (ᴧ+ P*P) …….. using I9 = QP* Hence Proved.. Let’s prove the uniqueness: replace R by Q + RP on the R.H.S. of given expression, Q + RP = Q + (Q + RP)P =Q + QP + RPP = Q + QP + RP2 = Q + QP + QP2 + + QPi + RPi+1 = Q(ᴧ+ P + P2 + ……. + pi) + RPi+1 From given eq. R = Q(ᴧ + P + P2 + ……. + pi) + RPi+1 ……………. for i >= 0 Lets prove R=Q+RP is equal to QP* Let w be a string of length in the set R, then w must belong to R = Q(ᴧ + P + P2 + ……. + pi) + RPi+1 for i >= 0 As P does not contain ᴧ, RPi+1 has all strings with length equal to i+1 and so w does not belong to the set RPi+1 This means w belongs to the set Q(ᴧ+ P + P2 + ……. + pi) and hence to QP*
  • 28.
    EQUIVALENCE OF TWOFINITE AUTOMATA Two finite automata over L are equivalent if they accept the same set of strings over L. Two finite automata over L are not equivalent if they satisfy the following: One autmaton reaches a final state on application of w, whereas the other automaton reaches a nonfinal state. To test the equivalence of two finite automata Comparison method is used. Let M1 and M2 be two finite automata over L. Construct a comparison table consisting of n + 1 columns. where n is the number of input symbols. The first column consists of pairs of vertices of the form (q, q'), where q E M1 and q’ E M2. The comparison table is constructed by starting with the pair of initial states of M1 and M2. The first elements in the subsequent columns are (qa, q’a), where qa and q’a are reachable by a-paths from q and q’. Repeat the construction by considering the pairs in the second and subsequent columns which are not in the first column. There are two cases: Case 1: If we reach a pair (q. q') such that q is a final state of M1, and q’ is a nonfinal state of M2 or vice versa, we terminate the construction and conclude that M1 and M2 are not equivalent. Case 2 : When the construction is terminated when no new element appears in the second and subsequent columns which are not in the first column (i.e. when all the elements in the second and subsequent columns appear in the first column). In this case we conclude that M1 and M2 are equivalent.
  • 29.
    Example 1: Considerthe following two DFAs M1 and M2 over {0, 1} as shown below. Determine whether M1 and M2 are equivalent. State / ∑ i/p = c i/p=d (q1,q4) (q1,q4) (q2,q5) (q2,q5) (q3,q6) (q1,q4) (q3,q6) (q2,q7) (q3,q6) (q2,q7) (q3,q6) (q1,q4) M1 and M2 are equivalent