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

Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsShiraz316
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expressionAnimesh Chaturvedi
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computationBipul Roy Bpl
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory Rajendran
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFAMaulik Togadiya
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESsuthi
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free GrammarAkhil Kaushik
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDAAshish Duggal
 

What's hot (20)

Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Turing machines
Turing machinesTuring machines
Turing machines
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
Chomsky Hierarchy.ppt
Chomsky Hierarchy.pptChomsky Hierarchy.ppt
Chomsky Hierarchy.ppt
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Theory of computation Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTES
 
TOC 5 | Regular Expressions
TOC 5 | Regular ExpressionsTOC 5 | Regular Expressions
TOC 5 | Regular Expressions
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
 

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
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of ComputationShiraz316
 
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 (10)

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
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of Computation
 
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
 
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
 
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
 
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

Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsMonica Sydney
 
💚 Call Girls Bahraich 9332606886 High Profile Call Girls You Can Get The S...
💚 Call Girls Bahraich   9332606886  High Profile Call Girls You Can Get The S...💚 Call Girls Bahraich   9332606886  High Profile Call Girls You Can Get The S...
💚 Call Girls Bahraich 9332606886 High Profile Call Girls You Can Get The S...Sareena Khatun
 
Leading-edge AI Image Generators of 2024
Leading-edge AI Image Generators of 2024Leading-edge AI Image Generators of 2024
Leading-edge AI Image Generators of 2024SOFTTECHHUB
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书F
 
一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理F
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasDigicorns Technologies
 
Call girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girlsCall girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girlsMonica Sydney
 
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...gragchanchal546
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...kumargunjan9515
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsMonica Sydney
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Balliameghakumariji156
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsMonica Sydney
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查ydyuyu
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...kajalverma014
 
PIC Microcontroller Structure & Assembly Language.ppsx
PIC Microcontroller Structure & Assembly Language.ppsxPIC Microcontroller Structure & Assembly Language.ppsx
PIC Microcontroller Structure & Assembly Language.ppsxjeykeydeveloper
 

Recently uploaded (20)

Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
💚 Call Girls Bahraich 9332606886 High Profile Call Girls You Can Get The S...
💚 Call Girls Bahraich   9332606886  High Profile Call Girls You Can Get The S...💚 Call Girls Bahraich   9332606886  High Profile Call Girls You Can Get The S...
💚 Call Girls Bahraich 9332606886 High Profile Call Girls You Can Get The S...
 
Leading-edge AI Image Generators of 2024
Leading-edge AI Image Generators of 2024Leading-edge AI Image Generators of 2024
Leading-edge AI Image Generators of 2024
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
 
一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
Call girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girlsCall girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girls
 
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
PIC Microcontroller Structure & Assembly Language.ppsx
PIC Microcontroller Structure & Assembly Language.ppsxPIC Microcontroller Structure & Assembly Language.ppsx
PIC Microcontroller Structure & Assembly Language.ppsx
 

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)