SlideShare a Scribd company logo
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

More Related Content

PDF
Formal Languages and Automata Theory unit 2
Srimatre K
 
DOCX
unit 2 part b.docx
karthikeyan Muthusamy
 
PPTX
AUTOMATA AUTOMATA Automata4Chapter3.pptx
ArjayBalberan1
 
PPTX
regular expression
RohitKumar596173
 
PDF
QB104541.pdf
MrRRajasekarCSE
 
DOCX
UNIT_-_II.docx
karthikeyan Muthusamy
 
PDF
RegularExpressions.pdf
ImranBhatti58
 
PDF
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
Formal Languages and Automata Theory unit 2
Srimatre K
 
unit 2 part b.docx
karthikeyan Muthusamy
 
AUTOMATA AUTOMATA Automata4Chapter3.pptx
ArjayBalberan1
 
regular expression
RohitKumar596173
 
QB104541.pdf
MrRRajasekarCSE
 
UNIT_-_II.docx
karthikeyan Muthusamy
 
RegularExpressions.pdf
ImranBhatti58
 
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 

Similar to FLAT.pdf (20)

PDF
Automata
Gaditek
 
PDF
Automata
Gaditek
 
PPT
regular expression smmlmmmmmmmmmmmmm.ppt
rishabhsrivastava518345
 
PDF
Flat unit 2
VenkataRaoS1
 
PPT
Re1 (3)
pepe3059
 
PPT
re1.ppt
PEzhumalai
 
PPT
RegularExpressions-theory of computation and formal language
mohdfareeduddin5
 
PPT
re1.ppt
Sarvesh Warjurkar
 
PPT
1LECTURE 8 Regular_Expressions.ppt
Marvin886766
 
PDF
Unit ii
TPLatchoumi
 
PPT
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
PPT
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
PPT
3-regular_expressions_and_languages.ppt 1
gokikayal1998
 
PPT
Theory of Computation - Lectures 4 and 5
Dr. Maamoun Ahmed
 
DOCX
Regular Expression .docx
SUNEEL37
 
PPTX
Regular expression
MONIRUL ISLAM
 
PPT
Regular expressions-Theory of computation
Bipul Roy Bpl
 
PPT
Regular Languages
parmeet834
 
PDF
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Rushabh2428
 
Automata
Gaditek
 
Automata
Gaditek
 
regular expression smmlmmmmmmmmmmmmm.ppt
rishabhsrivastava518345
 
Flat unit 2
VenkataRaoS1
 
Re1 (3)
pepe3059
 
re1.ppt
PEzhumalai
 
RegularExpressions-theory of computation and formal language
mohdfareeduddin5
 
1LECTURE 8 Regular_Expressions.ppt
Marvin886766
 
Unit ii
TPLatchoumi
 
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
3-regular_expressions_and_languages (1).ppt
gokikayal1998
 
3-regular_expressions_and_languages.ppt 1
gokikayal1998
 
Theory of Computation - Lectures 4 and 5
Dr. Maamoun Ahmed
 
Regular Expression .docx
SUNEEL37
 
Regular expression
MONIRUL ISLAM
 
Regular expressions-Theory of computation
Bipul Roy Bpl
 
Regular Languages
parmeet834
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Rushabh2428
 
Ad

Recently uploaded (20)

PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PDF
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PPTX
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
Zero Carbon Building Performance standard
BassemOsman1
 
Information Retrieval and Extraction - Module 7
premSankar19
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
Ad

FLAT.pdf

  • 1. Theory of Computation Lecture 8 {29/30 July} Swati Jaipurkar, Assistant Professor, Department of Computer Science & Engg MIT, Aurangabad, Maharashtra. INDIA
  • 2. 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.
  • 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 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.
  • 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 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)*.
  • 8. 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
  • 9. 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*
  • 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 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.
  • 13. 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.
  • 14. 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
  • 15. 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:
  • 16. 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.
  • 17. 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).
  • 18. 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
  • 19. NFAs WITH ᴧ-MOVES AND RE Case 2 : R =PQ Lets construct an NFA M with ᴧ-moves that accepts L(PQ)
  • 20. NFAs WITH ᴧ-MOVES AND RE Case 3 : R =P* Lets construct an NFA M with ᴧ-moves that accepts L(P)*
  • 22. 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:
  • 23. 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: -
  • 24. Continued………. ▪ Construct the DFA equivalent to NFA ▪ Transition table and diagram for DFA is : DFA for RE 10 + (0 + 11»)0*1
  • 25. 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
  • 26. 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
  • 27. 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*
  • 28. 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.
  • 29. 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