SlideShare una empresa de Scribd logo
1 de 18
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Submitted By :
Name : Rohit Giri
CLASS : B.Tech Cse 6TH Sem
Roll No : 20320147008
Subject : Automata theory II
Topic : Regular Expression
Submitted To :
Dr. Navneet Kaur Sandhu
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
 Contents :
 Regular Expression
 Some RE Examples
 Regular Sets
• Properties of Regular Sets
 Identities related to Regular Expressions
 Arden’s Theorem
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
A Regular Expression can be recursively defined as follows −
•ε is a Regular Expression indicates the language containing an empty string. (L (ε) =
{ε})
•φ is a Regular Expression denoting an empty language. (L (φ) = { })
•x is a Regular Expression where L = {x}
•If X is a Regular Expression denoting the language L(X) and Y is a Regular
Expression denoting the language L(Y), then
• X + Y is a Regular Expression corresponding to the language L(X) ∪
L(Y) where L(X+Y) = L(X) ∪ L(Y).
• X . Y is a Regular Expression corresponding to the language L(X) .
L(Y) where L(X.Y) = L(X) . L(Y)
• R* is a Regular Expression corresponding to the language L(R*)where L(R*)
= (L(R))*
•If we apply any of the rules several times from 1 to 5, they are Regular Expressions.
 Regular Expression
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
 Some RE Examples
Regular Expressions Regular Set
(0 + 10*) L = { 0, 1, 10, 100, 1000, 10000, … }
(0*10*) L = {1, 01, 10, 010, 0010, …}
(0 + ε)(1 + ε) L = {ε, 0, 1, 01}
(a+b)* Set of strings of a’s and b’s of any length including the null string. So
L = { ε, a, b, aa , ab , bb , ba, aaa…….}
(a+b)*abb Set of strings of a’s and b’s ending with the string abb. So L = {abb,
aabb, babb, aaabb, ababb, …………..}
(11)* Set consisting of even number of 1’s including empty string, So L=
{ε, 11, 1111, 111111, ……….}
(aa)*(bb)*b Set of strings consisting of even number of a’s followed by odd
number of b’s , so L = {b, aab, aabbb, aabbbbb, aaaab, aaaabbb,
…………..}
(aa + ab + ba + bb)* String of a’s and b’s of even length can be obtained by concatenating
any combination of the strings aa, ab, ba and bb including null, so L
= {aa, ab, ba, bb, aaab, aaba, …………..}
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
 Regular Sets
 Properties of Regular Sets
Property 1. The union of two regular set is regular.
Proof −
Let us take two regular expressions
RE1 = a(aa)* and RE2 = (aa)*
So, L1 = {a, aaa, aaaaa,.....} (Strings of odd length excluding Null)
and L2 ={ ε, aa, aaaa, aaaaaa,.......} (Strings of even length including
Null)
L1 ∪ L2 = { ε, a, aa, aaa, aaaa, aaaaa, aaaaaa,.......}
(Strings of all possible lengths including Null)
RE (L1 ∪ L2) = a* (which is a regular expression itself)
Hence, proved.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Property 2. The intersection of two regular set is regular.
Proof −
Let us take two regular expressions
RE1 = a(a*) and RE2 = (aa)*
So, L1 = { a, aa, aaa, aaaa, ....} (Strings of all possible lengths excluding Null)
L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length including Null)
L1 ∩ L2 = { aa, aaaa, aaaaaa,.......} (Strings of even length excluding Null)
RE (L1 ∩ L2) = aa(aa)* which is a regular expression itself.
Hence, proved.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Property 3. The complement of a regular set is regular.
Proof −
Let us take a regular expression −
RE = (aa)*
So, L = {ε, aa, aaaa, aaaaaa, .......} (Strings of even length including Null)
Complement of L is all the strings that is not in L.
So, L’ = {a, aaa, aaaaa, .....} (Strings of odd length excluding Null)
RE (L’) = a(aa)* which is a regular expression itself.
Hence, proved.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Property 4. The difference of two regular set is regular.
Proof −
Let us take two regular expressions −
RE1 = a (a*) and RE2 = (aa)*
So, L1 = {a, aa, aaa, aaaa, ....} (Strings of all possible lengths
excluding Null)
L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length including
Null)
L1 – L2 = {a, aaa, aaaaa, aaaaaaa, ....}
(Strings of all odd lengths excluding Null)
RE (L1 – L2) = a (aa)* which is a regular expression.
Hence, proved.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Property 5. The reversal of a regular set is regular.
Proof −
We have to prove LR is also regular if L is a regular set.
Let, L = {01, 10, 11, 10}
RE (L) = 01 + 10 + 11 + 10
LR = {10, 01, 11, 01}
RE (LR) = 01 + 10 + 11 + 10 which is regular
Hence, proved.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Property 6. The closure of a regular set is regular.
Proof −
If L = {a, aaa, aaaaa, .......}
(Strings of odd length excluding Null)
i.e., RE (L) = a (aa)*
L* = {a, aa, aaa, aaaa, aaaaa,……………}
(Strings of all lengths excluding Null)
RE (L*) = a (a)*
Hence, proved.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Property 7. The concatenation of two regular sets is regular.
Proof −
Let RE1 = (0+1)*0 and RE2 = 01(0+1)*
Here, L1 = {0, 00, 10, 000, 010, ......} (Set of strings ending in 0)
and L2 = {01, 010,011,.....} (Set of strings beginning with 01)
Then,L1L2= {001,0010,0011,0001,00010,00011,1001,10010,.............}
Set of strings containing 001 as a substring which can be represented by an
RE − (0 + 1)*001(0 + 1)*
Hence, proved.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
 Identities Related to Regular Expressions
 Given R, P, L, Q as regular expressions, the
following identities hold −
•∅* = ε
•ε* = ε
•RR* = R*R
•R*R* = R*
•(R*)* = R*
•RR* = R*R
•(PQ)*P =P(QP)*
•(a+b)* = (a*b*)* = (a*+b*)* = (a+b*)* = a*(ba*)*
•R + ∅ = ∅ + R = R (The identity for union)
•R ε = ε R = R (The identity for concatenation)
•∅ L = L ∅ = ∅ (The annihilator for concatenation)
•R + R = R (Idempotent law)
•L (M + N) = LM + LN (Left distributive law)
•(M + N) L = ML + NL (Right distributive law)
•ε + RR* = ε + R*R = R*
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
 Statement −
Let P and Q be two regular expressions.
If P does not contain null string, then R = Q + RP has a unique solution that is R
= QP*
 Arden's Theorem
Proof −
R = Q + (Q + RP)P [After putting the value R = Q + RP]
= Q + QP + RPP
When we put the value of R recursively again and again, we get the following
equation −
R = Q + QP + QP2 + QP3…..
R = Q (ε + P + P2 + P3 + …. )
R = QP* [As P* represents (ε + P + P2 + P3 + ….) ]
Hence, proved.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
 Assumptions for Applying Arden’s Theorem:
•The transition diagram must not have NULL transitions
•It must have only one initial state
Method:
Step 1 − Create equations as the following form for all the states of the DFA
having n states with initial state q1.
q1 = q1R11 + q2R21 + … + qnRn1 + ε
q2 = q1R12 + q2R22 + … + qnRn2
…………………………
…………………………
…………………………
…………………………
qn = q1R1n + q2R2n + … + qnRnn
Rij represents the set of labels of edges from qi to qj, if no such edge exists,
then Rij = ∅
Step 2 − Solve these equations to get the equation for the final state in terms
of Rij
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
 Problem
 Construct a regular expression corresponding to the automata
given below −
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Solution −
Here the initial state and final state is q1.
The equations for the three states q1, q2, and q3 are as
follows −
• q1 = q1a + q3a + ε (ε move is because q1 is the initial
state0
• q2 = q1b + q2b + q3b
• q3 = q2a
Now, we will solve these three equations −
q2 = q1b + q2b + q3b
= q1b + q2b + (q2a)b (Substituting value of q3)
= q1b + q2(b + ab)
= q1b (b + ab)* (Applying Arden’s Theorem)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
q1 = q1a + q3a + ε
= q1a + q2aa + ε (Substituting value of q3)
= q1a + q1b(b + ab*)aa + ε (Substituting value of q2)
= q1(a + b(b + ab)*aa) + ε
= ε (a+ b(b + ab)*aa)*
= (a + b(b + ab)*aa)*
Hence, the regular expression is (a + b(b + ab)*aa)*.
THANK YOU

Más contenido relacionado

La actualidad más candente

Autómatas Finitos Deterministas y Lenguajes Formales
Autómatas Finitos Deterministas y Lenguajes FormalesAutómatas Finitos Deterministas y Lenguajes Formales
Autómatas Finitos Deterministas y Lenguajes Formales
Sandy Rafael Garcia
 
Lenguajes regulares
Lenguajes regularesLenguajes regulares
Lenguajes regulares
Kenia Adams
 
Listas en C#
Listas en C#Listas en C#
Listas en C#
rezzaca
 
Clase4: Transformación desde Expresión regular a Autómata finito determinista
Clase4: Transformación desde Expresión regular a Autómata finito deterministaClase4: Transformación desde Expresión regular a Autómata finito determinista
Clase4: Transformación desde Expresión regular a Autómata finito determinista
mvagila
 
Aseveraciones y cuantificadores
Aseveraciones y cuantificadoresAseveraciones y cuantificadores
Aseveraciones y cuantificadores
Iozelin Mendez
 

La actualidad más candente (20)

Conceptos Unidad 1 Lenguajes Automatas Introducción a la Teoría de Lenguaje...
Conceptos Unidad 1 Lenguajes Automatas Introducción  a  la Teoría de Lenguaje...Conceptos Unidad 1 Lenguajes Automatas Introducción  a  la Teoría de Lenguaje...
Conceptos Unidad 1 Lenguajes Automatas Introducción a la Teoría de Lenguaje...
 
Expresiones Regulares
Expresiones RegularesExpresiones Regulares
Expresiones Regulares
 
Introduccion A La Programacion
Introduccion A La ProgramacionIntroduccion A La Programacion
Introduccion A La Programacion
 
Autómatas Finitos Deterministas y Lenguajes Formales
Autómatas Finitos Deterministas y Lenguajes FormalesAutómatas Finitos Deterministas y Lenguajes Formales
Autómatas Finitos Deterministas y Lenguajes Formales
 
Java script
Java scriptJava script
Java script
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt
 
Lenguajes regulares
Lenguajes regularesLenguajes regulares
Lenguajes regulares
 
Compiladores, Analisis Lexico
Compiladores, Analisis LexicoCompiladores, Analisis Lexico
Compiladores, Analisis Lexico
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
Caracteristicas de C Sharp
Caracteristicas de C SharpCaracteristicas de C Sharp
Caracteristicas de C Sharp
 
Listas en C#
Listas en C#Listas en C#
Listas en C#
 
Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#
 
Programación Orientada a Objetos - constructores y destructores
Programación Orientada a Objetos - constructores y destructoresProgramación Orientada a Objetos - constructores y destructores
Programación Orientada a Objetos - constructores y destructores
 
Clase4: Transformación desde Expresión regular a Autómata finito determinista
Clase4: Transformación desde Expresión regular a Autómata finito deterministaClase4: Transformación desde Expresión regular a Autómata finito determinista
Clase4: Transformación desde Expresión regular a Autómata finito determinista
 
Aseveraciones y cuantificadores
Aseveraciones y cuantificadoresAseveraciones y cuantificadores
Aseveraciones y cuantificadores
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
Packages,interfaces and exceptions
Packages,interfaces and exceptionsPackages,interfaces and exceptions
Packages,interfaces and exceptions
 

Similar a regular expression

Class1
 Class1 Class1
Class1
issbp
 

Similar a regular expression (20)

FLAT.pdf
FLAT.pdfFLAT.pdf
FLAT.pdf
 
UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
Regular languag regular set
Regular languag regular setRegular languag regular set
Regular languag regular set
 
Regular languag regular set
Regular languag regular setRegular languag regular set
Regular languag regular set
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
6.sequences and series Further Mathematics Zimbabwe Zimsec Cambridge
6.sequences and series   Further Mathematics Zimbabwe Zimsec Cambridge6.sequences and series   Further Mathematics Zimbabwe Zimsec Cambridge
6.sequences and series Further Mathematics Zimbabwe Zimsec Cambridge
 
Math
MathMath
Math
 
Theory of computation
Theory of computationTheory of computation
Theory of computation
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
13000120020_A.pptx
13000120020_A.pptx13000120020_A.pptx
13000120020_A.pptx
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
theoryofautomataandformallanguagesunit21-161231042659.pptx
theoryofautomataandformallanguagesunit21-161231042659.pptxtheoryofautomataandformallanguagesunit21-161231042659.pptx
theoryofautomataandformallanguagesunit21-161231042659.pptx
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
 
Toc chapter 1 srg
Toc chapter 1 srgToc chapter 1 srg
Toc chapter 1 srg
 
L_2_apl.pptx
L_2_apl.pptxL_2_apl.pptx
L_2_apl.pptx
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
Class1
 Class1 Class1
Class1
 

Último

1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 

Último (20)

1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 

regular expression

  • 1. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Submitted By : Name : Rohit Giri CLASS : B.Tech Cse 6TH Sem Roll No : 20320147008 Subject : Automata theory II Topic : Regular Expression Submitted To : Dr. Navneet Kaur Sandhu
  • 2. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING  Contents :  Regular Expression  Some RE Examples  Regular Sets • Properties of Regular Sets  Identities related to Regular Expressions  Arden’s Theorem
  • 3. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING A Regular Expression can be recursively defined as follows − •ε is a Regular Expression indicates the language containing an empty string. (L (ε) = {ε}) •φ is a Regular Expression denoting an empty language. (L (φ) = { }) •x is a Regular Expression where L = {x} •If X is a Regular Expression denoting the language L(X) and Y is a Regular Expression denoting the language L(Y), then • X + Y is a Regular Expression corresponding to the language L(X) ∪ L(Y) where L(X+Y) = L(X) ∪ L(Y). • X . Y is a Regular Expression corresponding to the language L(X) . L(Y) where L(X.Y) = L(X) . L(Y) • R* is a Regular Expression corresponding to the language L(R*)where L(R*) = (L(R))* •If we apply any of the rules several times from 1 to 5, they are Regular Expressions.  Regular Expression
  • 4. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING  Some RE Examples Regular Expressions Regular Set (0 + 10*) L = { 0, 1, 10, 100, 1000, 10000, … } (0*10*) L = {1, 01, 10, 010, 0010, …} (0 + ε)(1 + ε) L = {ε, 0, 1, 01} (a+b)* Set of strings of a’s and b’s of any length including the null string. So L = { ε, a, b, aa , ab , bb , ba, aaa…….} (a+b)*abb Set of strings of a’s and b’s ending with the string abb. So L = {abb, aabb, babb, aaabb, ababb, …………..} (11)* Set consisting of even number of 1’s including empty string, So L= {ε, 11, 1111, 111111, ……….} (aa)*(bb)*b Set of strings consisting of even number of a’s followed by odd number of b’s , so L = {b, aab, aabbb, aabbbbb, aaaab, aaaabbb, …………..} (aa + ab + ba + bb)* String of a’s and b’s of even length can be obtained by concatenating any combination of the strings aa, ab, ba and bb including null, so L = {aa, ab, ba, bb, aaab, aaba, …………..}
  • 5. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING  Regular Sets  Properties of Regular Sets Property 1. The union of two regular set is regular. Proof − Let us take two regular expressions RE1 = a(aa)* and RE2 = (aa)* So, L1 = {a, aaa, aaaaa,.....} (Strings of odd length excluding Null) and L2 ={ ε, aa, aaaa, aaaaaa,.......} (Strings of even length including Null) L1 ∪ L2 = { ε, a, aa, aaa, aaaa, aaaaa, aaaaaa,.......} (Strings of all possible lengths including Null) RE (L1 ∪ L2) = a* (which is a regular expression itself) Hence, proved.
  • 6. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Property 2. The intersection of two regular set is regular. Proof − Let us take two regular expressions RE1 = a(a*) and RE2 = (aa)* So, L1 = { a, aa, aaa, aaaa, ....} (Strings of all possible lengths excluding Null) L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length including Null) L1 ∩ L2 = { aa, aaaa, aaaaaa,.......} (Strings of even length excluding Null) RE (L1 ∩ L2) = aa(aa)* which is a regular expression itself. Hence, proved.
  • 7. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Property 3. The complement of a regular set is regular. Proof − Let us take a regular expression − RE = (aa)* So, L = {ε, aa, aaaa, aaaaaa, .......} (Strings of even length including Null) Complement of L is all the strings that is not in L. So, L’ = {a, aaa, aaaaa, .....} (Strings of odd length excluding Null) RE (L’) = a(aa)* which is a regular expression itself. Hence, proved.
  • 8. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Property 4. The difference of two regular set is regular. Proof − Let us take two regular expressions − RE1 = a (a*) and RE2 = (aa)* So, L1 = {a, aa, aaa, aaaa, ....} (Strings of all possible lengths excluding Null) L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length including Null) L1 – L2 = {a, aaa, aaaaa, aaaaaaa, ....} (Strings of all odd lengths excluding Null) RE (L1 – L2) = a (aa)* which is a regular expression. Hence, proved.
  • 9. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Property 5. The reversal of a regular set is regular. Proof − We have to prove LR is also regular if L is a regular set. Let, L = {01, 10, 11, 10} RE (L) = 01 + 10 + 11 + 10 LR = {10, 01, 11, 01} RE (LR) = 01 + 10 + 11 + 10 which is regular Hence, proved.
  • 10. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Property 6. The closure of a regular set is regular. Proof − If L = {a, aaa, aaaaa, .......} (Strings of odd length excluding Null) i.e., RE (L) = a (aa)* L* = {a, aa, aaa, aaaa, aaaaa,……………} (Strings of all lengths excluding Null) RE (L*) = a (a)* Hence, proved.
  • 11. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Property 7. The concatenation of two regular sets is regular. Proof − Let RE1 = (0+1)*0 and RE2 = 01(0+1)* Here, L1 = {0, 00, 10, 000, 010, ......} (Set of strings ending in 0) and L2 = {01, 010,011,.....} (Set of strings beginning with 01) Then,L1L2= {001,0010,0011,0001,00010,00011,1001,10010,.............} Set of strings containing 001 as a substring which can be represented by an RE − (0 + 1)*001(0 + 1)* Hence, proved.
  • 12. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING  Identities Related to Regular Expressions  Given R, P, L, Q as regular expressions, the following identities hold − •∅* = ε •ε* = ε •RR* = R*R •R*R* = R* •(R*)* = R* •RR* = R*R •(PQ)*P =P(QP)* •(a+b)* = (a*b*)* = (a*+b*)* = (a+b*)* = a*(ba*)* •R + ∅ = ∅ + R = R (The identity for union) •R ε = ε R = R (The identity for concatenation) •∅ L = L ∅ = ∅ (The annihilator for concatenation) •R + R = R (Idempotent law) •L (M + N) = LM + LN (Left distributive law) •(M + N) L = ML + NL (Right distributive law) •ε + RR* = ε + R*R = R*
  • 13. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING  Statement − Let P and Q be two regular expressions. If P does not contain null string, then R = Q + RP has a unique solution that is R = QP*  Arden's Theorem Proof − R = Q + (Q + RP)P [After putting the value R = Q + RP] = Q + QP + RPP When we put the value of R recursively again and again, we get the following equation − R = Q + QP + QP2 + QP3….. R = Q (ε + P + P2 + P3 + …. ) R = QP* [As P* represents (ε + P + P2 + P3 + ….) ] Hence, proved.
  • 14. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING  Assumptions for Applying Arden’s Theorem: •The transition diagram must not have NULL transitions •It must have only one initial state Method: Step 1 − Create equations as the following form for all the states of the DFA having n states with initial state q1. q1 = q1R11 + q2R21 + … + qnRn1 + ε q2 = q1R12 + q2R22 + … + qnRn2 ………………………… ………………………… ………………………… ………………………… qn = q1R1n + q2R2n + … + qnRnn Rij represents the set of labels of edges from qi to qj, if no such edge exists, then Rij = ∅ Step 2 − Solve these equations to get the equation for the final state in terms of Rij
  • 15. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING  Problem  Construct a regular expression corresponding to the automata given below −
  • 16. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Solution − Here the initial state and final state is q1. The equations for the three states q1, q2, and q3 are as follows − • q1 = q1a + q3a + ε (ε move is because q1 is the initial state0 • q2 = q1b + q2b + q3b • q3 = q2a Now, we will solve these three equations − q2 = q1b + q2b + q3b = q1b + q2b + (q2a)b (Substituting value of q3) = q1b + q2(b + ab) = q1b (b + ab)* (Applying Arden’s Theorem)
  • 17. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING q1 = q1a + q3a + ε = q1a + q2aa + ε (Substituting value of q3) = q1a + q1b(b + ab*)aa + ε (Substituting value of q2) = q1(a + b(b + ab)*aa) + ε = ε (a+ b(b + ab)*aa)* = (a + b(b + ab)*aa)* Hence, the regular expression is (a + b(b + ab)*aa)*.