SlideShare a Scribd company logo
1 of 38
Courtesy: Costas/Ullman 1
Regular Expressions
2
RE’s: Introduction
• Regular expressions describe
languages by an algebra.
• They describe exactly the regular
languages.
• If E is a regular expression, then L(E)
is the language it defines.
• We’ll describe RE’s and their
languages recursively.
Courtesy: Costas/Ullman
3
Operations on Languages
• RE’s use three operations: union,
concatenation, and Kleene star.
• The union of languages is the usual thing,
since languages are sets.
• Example: {01,111,10}{00, 01} =
{01,111,10,00}.
Courtesy: Costas/Ullman
4
Concatenation
• The concatenation of languages L and
M is denoted LM.
• It contains every string wx such that
w is in L and x is in M.
• Example: {01,111,10}{00, 01} = {0100,
0101, 11100, 11101, 1000, 1001}.
Courtesy: Costas/Ullman
5
Kleene Star
• If L is a language, then L*, the Kleene star
or just “star,” is the set of strings formed
by concatenating zero or more strings from
L, in any order.
• L* = {ε}  L  LL  LLL  …
• Example: {0,10}* = {ε, 0, 10, 00, 010, 100,
1010,…}
Courtesy: Costas/Ullman
6
RE’s: Definition
• Basis 1: If a is any symbol, then a is a RE,
and L(a) = {a}.
– Note: {a} is the language containing one string,
and that string is of length 1.
• Basis 2: ε is a RE, and L(ε) = {ε}.
• Basis 3: ∅ is a RE, and L(∅) = ∅.
Courtesy: Costas/Ullman
7
RE’s: Definition – (2)
• Induction 1: If E1 and E2 are regular
expressions, then E1+E2 is a regular
expression, and L(E1+E2) = L(E1)L(E2).
• Induction 2: If E1 and E2 are regular
expressions, then E1E2 is a regular
expression, and L(E1E2) = L(E1)L(E2).
• Induction 3: If E is a RE, then E* is a RE,
and L(E*) = (L(E))*.
Courtesy: Costas/Ullman
Courtesy: Costas/Ullman 8
Definition (continued)
For regular expressions and1r 2r
     2121 rLrLrrL 
     2121 rLrLrrL 
    ** 11 rLrL 
    11 rLrL 
9
Precedence of Operators
• Parentheses may be used wherever needed
to influence the grouping of operators.
• Order of precedence is * (highest), then
concatenation, then + (lowest).
Courtesy: Costas/Ullman
Courtesy: Costas/Ullman 10
Example
Regular expression:   *aba 
  *abaL      *aLbaL 
   *aLbaL 
       *aLbLaL 
       *aba 
  ,...,,,, aaaaaaba 
 ,...,,,...,,, baababaaaaaa
Courtesy: Costas/Ullman 11
Example
Regular expression    bbabar  *
   ,...,,,,, bbbbaabbaabbarL 
Courtesy: Costas/Ullman 12
Example
Regular expression     bbbaar **
  }0,:{ 22
 mnbbarL mn
Courtesy: Costas/Ullman 13
Example
Regular expression *)10(00*)10( r
)(rL = { all strings containing substring 00 }
Courtesy: Costas/Ullman 14
Example
Regular expression )0(*)011( r
)(rL = { all strings without substring 00 }
Courtesy: Costas/Ullman 15
Equivalent Regular Expressions
Definition:
Regular expressions and
are equivalent if
1r 2r
)()( 21 rLrL 
Courtesy: Costas/Ullman 16
Example
L = { all strings without substring 00 }
)0(*)011(1 r
)0(*1)0(**)011*1(2  r
LrLrL  )()( 21
1r 2rand
are equivalent
regular expressions
Courtesy: Costas/Ullman 17
Regular Expressions
and
Regular Languages
Courtesy: Costas/Ullman 18
Theorem
Languages
Generated by
Regular Expressions
Regular
Languages
Courtesy: Costas/Ullman 19
Languages
Generated by
Regular Expressions
Regular
Languages

Languages
Generated by
Regular Expressions
Regular
Languages

Proof:
Courtesy: Costas/Ullman 20
Proof - Part 1
r
)(rL
For any regular expression
the language is regular
Languages
Generated by
Regular Expressions
Regular
Languages

Proof by induction on the size of r
Courtesy: Costas/Ullman 21
Induction Basis
Primitive Regular Expressions: ,,
Corresponding
NFAs
)()( 1  LML
)(}{)( 2  LML 
)(}{)( 3 aLaML 
regular
languages
a
Courtesy: Costas/Ullman 22
Inductive Hypothesis
Suppose
that for regular expressions and ,
and are regular languages
1r 2r
)( 1rL )( 2rL
Courtesy: Costas/Ullman 23
Inductive Step
We will prove:
 
 
 
  1
1
21
21
*
rL
rL
rrL
rrL


Are regular
Languages
Courtesy: Costas/Ullman 24
By definition of regular expressions:
     
     
    
    11
11
2121
2121
**
rLrL
rLrL
rLrLrrL
rLrLrrL




Courtesy: Costas/Ullman 25
)( 1rL )( 2rL
By inductive hypothesis we know:
and are regular languages
Regular languages are closed under:
   
   
  *1
21
21
rL
rLrL
rLrL Union
Concatenation
Star
We also know:
Courtesy: Costas/Ullman 26
Therefore:
     
     
    ** 11
2121
2121
rLrL
rLrLrrL
rLrLrrL



Are regular
languages
)())(( 11 rLrL  is trivially a regular language
(by induction hypothesis)
End of Proof-Part 1
Courtesy: Costas/Ullman 27
Using the regular closure of operations,
we can construct recursively the NFA
that accepts
M
)()( rLML 
Example: 21 rrr 
)()( 11 rLML 
)()( 22 rLML 
)()( rLML 


Courtesy: Costas/Ullman 28
For any regular language there is
a regular expression with
Proof - Part 2
Languages
Generated by
Regular Expressions
Regular
Languages

L
r LrL )(
We will convert an NFA that accepts
to a regular expression
L
Courtesy: Costas/Ullman 29
Since is regular, there is a
NFA that accepts it
L
M
LML )(
Take it with a single accept state
Courtesy: Costas/Ullman 30
From construct the equivalent
Generalized Transition Graph
in which transition labels are regular expressions
M
Example:
a
ba,
c
M
a
ba 
c
Corresponding
Generalized transition graph
Courtesy: Costas/Ullman 31
Another Example:
ba 
a
b
b
0q 1q 2q
ba,
a
b
b
0q 1q 2q
b
bTransition labels
are regular
expressions
Courtesy: Costas/Ullman 32
Reducing the states:
ba 
a
b
b
0q 1q 2q
b
0q 2q
babb*
)(* babb 
Transition labels
are regular
expressions
Courtesy: Costas/Ullman 33
Resulting Regular Expression:
0q 2q
babb*
)(* babb 
*)(**)*( bbabbabbr 
LMLrL  )()(
Courtesy: Costas/Ullman 34
In General
Removing a state:
iq q jq
a b
cd
e
iq jq
dae* bce*
dce*
bae*
2-neighbors
Courtesy: Costas/Ullman 35
iq jq
dae* bce*
dce*
bae*
iq q jq
a b
cd
e
kq
f g
kq
fge*
dge*
fae*
bge*
fce*
This can be generalized
to arbitrary number
of neighbors to q
3-neighbors
Courtesy: Costas/Ullman 36
0q fq
1r
2r
3r
4r
*)*(* 213421 rrrrrrr 
LMLrL  )()(
The resulting regular expression:
By repeating the process until
two states are left, the resulting graph is
Initial graph Resulting graph
End of Proof-Part 2
Courtesy: Costas/Ullman 37
Standard Representations
of Regular Languages
Regular Languages
DFAs
NFAs
Regular
Expressions
Courtesy: Costas/Ullman 38
When we say: We are given
a Regular Language
We mean:
L
Language is in a standard
representation
L
(DFA, NFA, or Regular Expression)

More Related Content

What's hot

Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryTsegazeab Asgedom
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsShiraz316
 
Ch3 4 regular expression and grammar
Ch3 4 regular expression and grammarCh3 4 regular expression and grammar
Ch3 4 regular expression and grammarmeresie tesfay
 
Regular Expression Examples.pptx
Regular Expression Examples.pptxRegular Expression Examples.pptx
Regular Expression Examples.pptxGhulamRabani9
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Srimatre K
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2shah zeb
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR Zahid Parvez
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignAkhil Kaushik
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of ComputationShiraz316
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of AutomataFarooq Mian
 
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 2Srimatre K
 
Regular expression
Regular expressionRegular expression
Regular expressionRajon
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02hamzamughal39
 

What's hot (20)

Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Ch3 4 regular expression and grammar
Ch3 4 regular expression and grammarCh3 4 regular expression and grammar
Ch3 4 regular expression and grammar
 
Regular Expression Examples.pptx
Regular Expression Examples.pptxRegular Expression Examples.pptx
Regular Expression Examples.pptx
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of Computation
 
Finite automata
Finite automataFinite automata
Finite automata
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Chomsky Hierarchy.ppt
Chomsky Hierarchy.pptChomsky Hierarchy.ppt
Chomsky Hierarchy.ppt
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
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
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02
 

Viewers also liked

Dfa example
Dfa   exampleDfa   example
Dfa examplesaerrii
 
Properties of Regular Expressions
Properties of Regular ExpressionsProperties of Regular Expressions
Properties of Regular ExpressionsShiraz316
 
Variants of Turing Machine
Variants of Turing MachineVariants of Turing Machine
Variants of Turing MachineRajendran
 
Deterministic Finite Automata
Deterministic Finite AutomataDeterministic Finite Automata
Deterministic Finite AutomataShiraz316
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1Rajendran
 
Pumping lemma for regular language
Pumping lemma for regular languagePumping lemma for regular language
Pumping lemma for regular languagesadique_ghitm
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesMarina Santini
 

Viewers also liked (9)

Dfa example
Dfa   exampleDfa   example
Dfa example
 
Properties of Regular Expressions
Properties of Regular ExpressionsProperties of Regular Expressions
Properties of Regular Expressions
 
Variants of Turing Machine
Variants of Turing MachineVariants of Turing Machine
Variants of Turing Machine
 
Deterministic Finite Automata
Deterministic Finite AutomataDeterministic Finite Automata
Deterministic Finite Automata
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1
 
Pumping lemma for regular language
Pumping lemma for regular languagePumping lemma for regular language
Pumping lemma for regular language
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
Dfa vs nfa
Dfa vs nfaDfa vs nfa
Dfa vs nfa
 
Nfa egs
Nfa egsNfa egs
Nfa egs
 

Similar to Regular expressions

Similar to Regular expressions (20)

Unit ii
Unit iiUnit ii
Unit ii
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
Re1 (3)
Re1 (3)Re1 (3)
Re1 (3)
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
RegularExpressions.pdf
RegularExpressions.pdfRegularExpressions.pdf
RegularExpressions.pdf
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
FLAT.pdf
FLAT.pdfFLAT.pdf
FLAT.pdf
 
Resumen material MIT
Resumen material MITResumen material MIT
Resumen material MIT
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
RegularLanguage.pptx
RegularLanguage.pptxRegularLanguage.pptx
RegularLanguage.pptx
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
L_2_apl.pptx
L_2_apl.pptxL_2_apl.pptx
L_2_apl.pptx
 
Flat unit 1
Flat unit 1Flat unit 1
Flat unit 1
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
regular expression
regular expressionregular expression
regular expression
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
 
1LECTURE 8 Regular_Expressions.ppt
1LECTURE 8 Regular_Expressions.ppt1LECTURE 8 Regular_Expressions.ppt
1LECTURE 8 Regular_Expressions.ppt
 
Module 1 TOC.pptx
Module 1 TOC.pptxModule 1 TOC.pptx
Module 1 TOC.pptx
 

More from Shiraz316

FINGERNAIL DISORDER DETECTION FOR DISEASE ANALYSIS
FINGERNAIL DISORDER DETECTION FOR DISEASE ANALYSISFINGERNAIL DISORDER DETECTION FOR DISEASE ANALYSIS
FINGERNAIL DISORDER DETECTION FOR DISEASE ANALYSISShiraz316
 
K neareast neighbor algorithm presentation
K neareast neighbor algorithm presentationK neareast neighbor algorithm presentation
K neareast neighbor algorithm presentationShiraz316
 
Khi 087 revised dt report
Khi 087 revised dt reportKhi 087 revised dt report
Khi 087 revised dt reportShiraz316
 
Khi 117 revised dt report
Khi 117 revised dt reportKhi 117 revised dt report
Khi 117 revised dt reportShiraz316
 
Khi 164 revised dt report
Khi 164 revised dt reportKhi 164 revised dt report
Khi 164 revised dt reportShiraz316
 
Khi 054 revised dt report
Khi 054 revised dt reportKhi 054 revised dt report
Khi 054 revised dt reportShiraz316
 
Khi 061 revised dt report
Khi 061 revised dt reportKhi 061 revised dt report
Khi 061 revised dt reportShiraz316
 
Khi 022 revised dt report
Khi 022 revised dt reportKhi 022 revised dt report
Khi 022 revised dt reportShiraz316
 
Khi 113 revised dt report
Khi 113 revised dt reportKhi 113 revised dt report
Khi 113 revised dt reportShiraz316
 
Khi 156 revised dt report
Khi 156 revised dt reportKhi 156 revised dt report
Khi 156 revised dt reportShiraz316
 
Khi 142 revised dt report
Khi 142 revised dt reportKhi 142 revised dt report
Khi 142 revised dt reportShiraz316
 
Khi 316 revised dt report
Khi 316 revised dt reportKhi 316 revised dt report
Khi 316 revised dt reportShiraz316
 
Khi 186 revised dt report
Khi 186 revised dt reportKhi 186 revised dt report
Khi 186 revised dt reportShiraz316
 
Khi 052 revised dt report
Khi 052 revised dt reportKhi 052 revised dt report
Khi 052 revised dt reportShiraz316
 
Khi 151 revised dt report
Khi 151 revised dt reportKhi 151 revised dt report
Khi 151 revised dt reportShiraz316
 
Khi 150 revised dt report
Khi 150 revised dt reportKhi 150 revised dt report
Khi 150 revised dt reportShiraz316
 
Khi 078 revised dt report
Khi 078 revised dt reportKhi 078 revised dt report
Khi 078 revised dt reportShiraz316
 
LTE quick introduction session Training
LTE quick introduction session TrainingLTE quick introduction session Training
LTE quick introduction session TrainingShiraz316
 
LTE Sales Training for CPE Device
LTE Sales Training for CPE DeviceLTE Sales Training for CPE Device
LTE Sales Training for CPE DeviceShiraz316
 
Witribe Customer Premises Equipment Training for LTE
Witribe Customer Premises Equipment Training for LTEWitribe Customer Premises Equipment Training for LTE
Witribe Customer Premises Equipment Training for LTEShiraz316
 

More from Shiraz316 (20)

FINGERNAIL DISORDER DETECTION FOR DISEASE ANALYSIS
FINGERNAIL DISORDER DETECTION FOR DISEASE ANALYSISFINGERNAIL DISORDER DETECTION FOR DISEASE ANALYSIS
FINGERNAIL DISORDER DETECTION FOR DISEASE ANALYSIS
 
K neareast neighbor algorithm presentation
K neareast neighbor algorithm presentationK neareast neighbor algorithm presentation
K neareast neighbor algorithm presentation
 
Khi 087 revised dt report
Khi 087 revised dt reportKhi 087 revised dt report
Khi 087 revised dt report
 
Khi 117 revised dt report
Khi 117 revised dt reportKhi 117 revised dt report
Khi 117 revised dt report
 
Khi 164 revised dt report
Khi 164 revised dt reportKhi 164 revised dt report
Khi 164 revised dt report
 
Khi 054 revised dt report
Khi 054 revised dt reportKhi 054 revised dt report
Khi 054 revised dt report
 
Khi 061 revised dt report
Khi 061 revised dt reportKhi 061 revised dt report
Khi 061 revised dt report
 
Khi 022 revised dt report
Khi 022 revised dt reportKhi 022 revised dt report
Khi 022 revised dt report
 
Khi 113 revised dt report
Khi 113 revised dt reportKhi 113 revised dt report
Khi 113 revised dt report
 
Khi 156 revised dt report
Khi 156 revised dt reportKhi 156 revised dt report
Khi 156 revised dt report
 
Khi 142 revised dt report
Khi 142 revised dt reportKhi 142 revised dt report
Khi 142 revised dt report
 
Khi 316 revised dt report
Khi 316 revised dt reportKhi 316 revised dt report
Khi 316 revised dt report
 
Khi 186 revised dt report
Khi 186 revised dt reportKhi 186 revised dt report
Khi 186 revised dt report
 
Khi 052 revised dt report
Khi 052 revised dt reportKhi 052 revised dt report
Khi 052 revised dt report
 
Khi 151 revised dt report
Khi 151 revised dt reportKhi 151 revised dt report
Khi 151 revised dt report
 
Khi 150 revised dt report
Khi 150 revised dt reportKhi 150 revised dt report
Khi 150 revised dt report
 
Khi 078 revised dt report
Khi 078 revised dt reportKhi 078 revised dt report
Khi 078 revised dt report
 
LTE quick introduction session Training
LTE quick introduction session TrainingLTE quick introduction session Training
LTE quick introduction session Training
 
LTE Sales Training for CPE Device
LTE Sales Training for CPE DeviceLTE Sales Training for CPE Device
LTE Sales Training for CPE Device
 
Witribe Customer Premises Equipment Training for LTE
Witribe Customer Premises Equipment Training for LTEWitribe Customer Premises Equipment Training for LTE
Witribe Customer Premises Equipment Training for LTE
 

Recently uploaded

DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...sonatiwari757
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.soniya singh
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
Call Girls in Mayur Vihar ✔️ 9711199171 ✔️ Delhi ✔️ Enjoy Call Girls With Our...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 

Regular expressions

  • 2. 2 RE’s: Introduction • Regular expressions describe languages by an algebra. • They describe exactly the regular languages. • If E is a regular expression, then L(E) is the language it defines. • We’ll describe RE’s and their languages recursively. Courtesy: Costas/Ullman
  • 3. 3 Operations on Languages • RE’s use three operations: union, concatenation, and Kleene star. • The union of languages is the usual thing, since languages are sets. • Example: {01,111,10}{00, 01} = {01,111,10,00}. Courtesy: Costas/Ullman
  • 4. 4 Concatenation • The concatenation of languages L and M is denoted LM. • It contains every string wx such that w is in L and x is in M. • Example: {01,111,10}{00, 01} = {0100, 0101, 11100, 11101, 1000, 1001}. Courtesy: Costas/Ullman
  • 5. 5 Kleene Star • If L is a language, then L*, the Kleene star or just “star,” is the set of strings formed by concatenating zero or more strings from L, in any order. • L* = {ε}  L  LL  LLL  … • Example: {0,10}* = {ε, 0, 10, 00, 010, 100, 1010,…} Courtesy: Costas/Ullman
  • 6. 6 RE’s: Definition • Basis 1: If a is any symbol, then a is a RE, and L(a) = {a}. – Note: {a} is the language containing one string, and that string is of length 1. • Basis 2: ε is a RE, and L(ε) = {ε}. • Basis 3: ∅ is a RE, and L(∅) = ∅. Courtesy: Costas/Ullman
  • 7. 7 RE’s: Definition – (2) • Induction 1: If E1 and E2 are regular expressions, then E1+E2 is a regular expression, and L(E1+E2) = L(E1)L(E2). • Induction 2: If E1 and E2 are regular expressions, then E1E2 is a regular expression, and L(E1E2) = L(E1)L(E2). • Induction 3: If E is a RE, then E* is a RE, and L(E*) = (L(E))*. Courtesy: Costas/Ullman
  • 8. Courtesy: Costas/Ullman 8 Definition (continued) For regular expressions and1r 2r      2121 rLrLrrL       2121 rLrLrrL      ** 11 rLrL      11 rLrL 
  • 9. 9 Precedence of Operators • Parentheses may be used wherever needed to influence the grouping of operators. • Order of precedence is * (highest), then concatenation, then + (lowest). Courtesy: Costas/Ullman
  • 10. Courtesy: Costas/Ullman 10 Example Regular expression:   *aba    *abaL      *aLbaL     *aLbaL         *aLbLaL         *aba    ,...,,,, aaaaaaba   ,...,,,...,,, baababaaaaaa
  • 11. Courtesy: Costas/Ullman 11 Example Regular expression    bbabar  *    ,...,,,,, bbbbaabbaabbarL 
  • 12. Courtesy: Costas/Ullman 12 Example Regular expression     bbbaar **   }0,:{ 22  mnbbarL mn
  • 13. Courtesy: Costas/Ullman 13 Example Regular expression *)10(00*)10( r )(rL = { all strings containing substring 00 }
  • 14. Courtesy: Costas/Ullman 14 Example Regular expression )0(*)011( r )(rL = { all strings without substring 00 }
  • 15. Courtesy: Costas/Ullman 15 Equivalent Regular Expressions Definition: Regular expressions and are equivalent if 1r 2r )()( 21 rLrL 
  • 16. Courtesy: Costas/Ullman 16 Example L = { all strings without substring 00 } )0(*)011(1 r )0(*1)0(**)011*1(2  r LrLrL  )()( 21 1r 2rand are equivalent regular expressions
  • 17. Courtesy: Costas/Ullman 17 Regular Expressions and Regular Languages
  • 18. Courtesy: Costas/Ullman 18 Theorem Languages Generated by Regular Expressions Regular Languages
  • 19. Courtesy: Costas/Ullman 19 Languages Generated by Regular Expressions Regular Languages  Languages Generated by Regular Expressions Regular Languages  Proof:
  • 20. Courtesy: Costas/Ullman 20 Proof - Part 1 r )(rL For any regular expression the language is regular Languages Generated by Regular Expressions Regular Languages  Proof by induction on the size of r
  • 21. Courtesy: Costas/Ullman 21 Induction Basis Primitive Regular Expressions: ,, Corresponding NFAs )()( 1  LML )(}{)( 2  LML  )(}{)( 3 aLaML  regular languages a
  • 22. Courtesy: Costas/Ullman 22 Inductive Hypothesis Suppose that for regular expressions and , and are regular languages 1r 2r )( 1rL )( 2rL
  • 23. Courtesy: Costas/Ullman 23 Inductive Step We will prove:         1 1 21 21 * rL rL rrL rrL   Are regular Languages
  • 24. Courtesy: Costas/Ullman 24 By definition of regular expressions:                      11 11 2121 2121 ** rLrL rLrL rLrLrrL rLrLrrL    
  • 25. Courtesy: Costas/Ullman 25 )( 1rL )( 2rL By inductive hypothesis we know: and are regular languages Regular languages are closed under:           *1 21 21 rL rLrL rLrL Union Concatenation Star We also know:
  • 26. Courtesy: Costas/Ullman 26 Therefore:                 ** 11 2121 2121 rLrL rLrLrrL rLrLrrL    Are regular languages )())(( 11 rLrL  is trivially a regular language (by induction hypothesis) End of Proof-Part 1
  • 27. Courtesy: Costas/Ullman 27 Using the regular closure of operations, we can construct recursively the NFA that accepts M )()( rLML  Example: 21 rrr  )()( 11 rLML  )()( 22 rLML  )()( rLML   
  • 28. Courtesy: Costas/Ullman 28 For any regular language there is a regular expression with Proof - Part 2 Languages Generated by Regular Expressions Regular Languages  L r LrL )( We will convert an NFA that accepts to a regular expression L
  • 29. Courtesy: Costas/Ullman 29 Since is regular, there is a NFA that accepts it L M LML )( Take it with a single accept state
  • 30. Courtesy: Costas/Ullman 30 From construct the equivalent Generalized Transition Graph in which transition labels are regular expressions M Example: a ba, c M a ba  c Corresponding Generalized transition graph
  • 31. Courtesy: Costas/Ullman 31 Another Example: ba  a b b 0q 1q 2q ba, a b b 0q 1q 2q b bTransition labels are regular expressions
  • 32. Courtesy: Costas/Ullman 32 Reducing the states: ba  a b b 0q 1q 2q b 0q 2q babb* )(* babb  Transition labels are regular expressions
  • 33. Courtesy: Costas/Ullman 33 Resulting Regular Expression: 0q 2q babb* )(* babb  *)(**)*( bbabbabbr  LMLrL  )()(
  • 34. Courtesy: Costas/Ullman 34 In General Removing a state: iq q jq a b cd e iq jq dae* bce* dce* bae* 2-neighbors
  • 35. Courtesy: Costas/Ullman 35 iq jq dae* bce* dce* bae* iq q jq a b cd e kq f g kq fge* dge* fae* bge* fce* This can be generalized to arbitrary number of neighbors to q 3-neighbors
  • 36. Courtesy: Costas/Ullman 36 0q fq 1r 2r 3r 4r *)*(* 213421 rrrrrrr  LMLrL  )()( The resulting regular expression: By repeating the process until two states are left, the resulting graph is Initial graph Resulting graph End of Proof-Part 2
  • 37. Courtesy: Costas/Ullman 37 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions
  • 38. Courtesy: Costas/Ullman 38 When we say: We are given a Regular Language We mean: L Language is in a standard representation L (DFA, NFA, or Regular Expression)