SlideShare a Scribd company logo
Theory of Computation - RegularRegular
ExpressionsExpressions
Notation to specify a language
Declarative
Sort of like a programming language.
Fundamental in some languages like perl and
applications like grep or lex
Capable of describing the same thing as a NFA
The two are actually equivalent, so RE =
NFA = DFA
We can define an algebra for regular
expressions
Algebra for LanguagesAlgebra for Languages
 Previously we discussed these operators:
 Union (+)
 Concatenation (.)
 Kleene Star/Closure (*)
Definition of a Regular
Expression
 R is a regular expression if it is:
1. a for some a in the alphabet ∑, standing for the
language {a}
2. , standing for the language { }ε ε
3. Ø, standing for the empty language
4. R1+R2where R1 and R2 are regular expressions, and
+ signifies union (sometimes | is used)
5. R1R2 where R1 and R2 are regular expressions and
this signifies concatenation
6. R* where R is a regular expression and signifies
closure
7. (R) where R is a regular expression, then a
parenthesized R is also a regular expression
RE Examples:RE Examples:
 L(001) = {001}
 L(0+10*) = { 0, 1, 10, 100, 1000, 10000, … }
 L(0*10*) = {1, 01, 10, 010, 0010, …} i.e. {w | w has
exactly a single 1}
 L(∑∑)* = {w | w is a string of even length}
 L((0(0+1))*) = { , 00, 01, 0000, 0001, 0100, 0101, …}ε
 L((0+ )(1+ε ε)) = { , 0, 1, 01}ε
 L(1Ø) = Ø ; concatenating the empty set to any set
yields the empty set.
 R = Rε
 R+Ø = R
Equivalence of FA andEquivalence of FA and
RERE
 Finite Automata and Regular Expressions are
equivalent. To show this:
Show we can express a DFA as an equivalent
RE
Show we can express a RE as an NFA.
Turning a DFA into a RETurning a DFA into a RE
Theorem: If L=L(A) for some DFA , then there
is a regular expression R such that L=L(R).
State Elimination
We’ll see how to do this next, easier than
inductive construction, there is no
exponential number of expressions
DFA to RE: StateDFA to RE: State
EliminationElimination
Eliminates states of the automaton and
replaces the edges with regular expressions
that includes the behavior of the eliminated
states.
Eventually we get down to the situation
with just a start and final node, and this is
easy to express as a RE
DFA to RE via StateDFA to RE via State
Elimination (1)Elimination (1)
1. Starting with intermediate states and then
moving to accepting states, apply the state
elimination process to produce an
equivalent automaton with regular
expression labels on the edges.
• The result will be a one or two state
automaton with a start state and
accepting state.
DFA to RE StateDFA to RE State
Elimination (2):Elimination (2):
2. If the two states are different, we will have an
automaton that looks like the following:
Start
S
R
T
U
We can describe this automaton as:
(R+SU*T)*SU*
DFA to RE StateDFA to RE State
Elimination (3)Elimination (3)
3. If the start state is also an accepting state, then
we must also perform a state elimination from
the original automaton that gets rid of every
state but the start state. This leaves the
following:
Start
R
We can describe this automaton as simply R*.
DFA to RE State EliminationDFA to RE State Elimination
(4)(4)
4. If there are n accepting states, we must repeat
the above steps for each accepting states to get
n different regular expressions, R1, R2, … Rn.
For each repeat we turn any other accepting
state to non-accepting. The desired regular
expression for the automaton is then the union
of each of the n regular expressions: R1∪ R2…
∪ RN
DFARE Example
Convert the following to a RE
First convert the edges to RE’s:
3Start 1 2
1 1
0
0
0,1
3Start 1 2
1 1
0
0
0+1
DFADFA  RE Example (2)RE Example (2)
Eliminate State 1:
3Start 1 2
1 1
0
0
0+1
3Start 2
11
0+10 0+1
Answer: (0+10)*11(0+1)*
Converting a RE to anConverting a RE to an
AutomataAutomata
We have shown we can convert an automata to a
RE. To show equivalence we must also go the
other direction, convert a RE to an automaton.
We can do this easiest by converting a RE to an
NFA
Inductive construction
Start with a simple basis, use that to build
more complex parts of the NFA
RE toRE to NFA:NFA:
Basis:
R=a
R=ε
a
ε
R=Ø
R=S+T
S
T
ε
ε
ε
ε
R=ST
S T
ε
R=S*
S
ε
ε
ε
ε
RE to NFA Example
 Convert R= (ab+a)* to an NFA
We proceed in stages, starting from simple elements
and working our way up
a
a
b
b
ab
a bε
RE toRE to NFANFA Example (2):Example (2):
ab+a
a bε
a
ε
ε
ε
ε
(ab+a)*
a bε
a
ε
ε
ε
ε
εε
ε
ε
Algebraic Laws for RE’s
Just like we have an algebra for arithmetic, we
also have an algebra for regular expressions.
While there are some similarities to arithmetic
algebra, it is a bit different with regular
expressions.
Algebra for RE’s:Algebra for RE’s:
Commutative law for union:
L + M = M + L
Associative law for union:
(L + M) + N = L + (M + N)
Associative law for concatenation:
(LM)N = L(MN)
Note that there is no commutative law for
concatenation, i.e. LM ≠ ML
Algebra for RE’s (2):Algebra for RE’s (2):
The identity for union is:
L + Ø = Ø + L = L
The identity for concatenation is:
L = L = Lε ε
The annihilator for concatenation is:
ØL = LØ = Ø
Left distributive law:
L(M + N) = LM + LN
Right distributive law:
(M + N)L = LM + LN
Idempotent law:
L + L = L
Laws Involving Closure:Laws Involving Closure:
(L*)* = L*
i.e. closing an already closed expression does
not change the language
Ø* = ε
 *ε = ε
L+
= LL* = L*L
L* = L+
+ ε
23
End of SlidesEnd of Slides
Ad

More Related Content

What's hot (20)

Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
Rabia Khalid
 
Syntax-Directed Translation into Three Address Code
Syntax-Directed Translation into Three Address CodeSyntax-Directed Translation into Three Address Code
Syntax-Directed Translation into Three Address Code
sanchi29
 
Compiler design syntax analysis
Compiler design syntax analysisCompiler design syntax analysis
Compiler design syntax analysis
Richa Sharma
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
Animesh Chaturvedi
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
Vignesh Saravanan
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
Iffat Anjum
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
Mohammad Ilyas Malik
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
parmeet834
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
Dattatray Gandhmal
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
Janki Shah
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
Maulik Togadiya
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
Rajendran
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
Riazul Islam
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
Iffat Anjum
 
Functions in discrete mathematics
Functions in discrete mathematicsFunctions in discrete mathematics
Functions in discrete mathematics
Rachana Pathak
 
Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ratnakar Mikkili
 
Regular Expression to Finite Automata
Regular Expression to Finite AutomataRegular Expression to Finite Automata
Regular Expression to Finite Automata
Archana Gopinath
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
Rabia Khalid
 
Syntax-Directed Translation into Three Address Code
Syntax-Directed Translation into Three Address CodeSyntax-Directed Translation into Three Address Code
Syntax-Directed Translation into Three Address Code
sanchi29
 
Compiler design syntax analysis
Compiler design syntax analysisCompiler design syntax analysis
Compiler design syntax analysis
Richa Sharma
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
Iffat Anjum
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
parmeet834
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
Janki Shah
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
Maulik Togadiya
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
Rajendran
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
Riazul Islam
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
Iffat Anjum
 
Functions in discrete mathematics
Functions in discrete mathematicsFunctions in discrete mathematics
Functions in discrete mathematics
Rachana Pathak
 
Regular Expression to Finite Automata
Regular Expression to Finite AutomataRegular Expression to Finite Automata
Regular Expression to Finite Automata
Archana Gopinath
 

Viewers also liked (15)

REGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.AREGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.A
Dev Ashish
 
Computation Theory Topic
Computation Theory TopicComputation Theory Topic
Computation Theory Topic
Rehan Hattab
 
Quiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurQuiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Vivekananda Samiti
 
Pumping lemma (1)
Pumping lemma (1)Pumping lemma (1)
Pumping lemma (1)
Self-employed
 
RegExp20110305
RegExp20110305RegExp20110305
RegExp20110305
tmiya
 
Differential evolution
Differential evolutionDifferential evolution
Differential evolution
ҚяậŧĭҚậ Jậĭn
 
Theory of computing pdf
Theory of computing pdfTheory of computing pdf
Theory of computing pdf
Dilouar Hossain
 
Ch3
Ch3Ch3
Ch3
kinnarshah8888
 
Xin Yao: "What can evolutionary computation do for you?"
Xin Yao: "What can evolutionary computation do for you?"Xin Yao: "What can evolutionary computation do for you?"
Xin Yao: "What can evolutionary computation do for you?"
ieee_cis_cyprus
 
Evolution algorithms
Evolution algorithmsEvolution algorithms
Evolution algorithms
Andrii Babii
 
Evolutionary computation and_applications
Evolutionary computation and_applicationsEvolutionary computation and_applications
Evolutionary computation and_applications
ddawar
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
Marina Santini
 
introduction to web technology
introduction to web technologyintroduction to web technology
introduction to web technology
vikram singh
 
Genetic Algorithms Made Easy
Genetic Algorithms Made EasyGenetic Algorithms Made Easy
Genetic Algorithms Made Easy
Prakash Pimpale
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
garima931
 
REGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.AREGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.A
Dev Ashish
 
Computation Theory Topic
Computation Theory TopicComputation Theory Topic
Computation Theory Topic
Rehan Hattab
 
Quiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurQuiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz1 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Vivekananda Samiti
 
RegExp20110305
RegExp20110305RegExp20110305
RegExp20110305
tmiya
 
Xin Yao: "What can evolutionary computation do for you?"
Xin Yao: "What can evolutionary computation do for you?"Xin Yao: "What can evolutionary computation do for you?"
Xin Yao: "What can evolutionary computation do for you?"
ieee_cis_cyprus
 
Evolution algorithms
Evolution algorithmsEvolution algorithms
Evolution algorithms
Andrii Babii
 
Evolutionary computation and_applications
Evolutionary computation and_applicationsEvolutionary computation and_applications
Evolutionary computation and_applications
ddawar
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
Marina Santini
 
introduction to web technology
introduction to web technologyintroduction to web technology
introduction to web technology
vikram singh
 
Genetic Algorithms Made Easy
Genetic Algorithms Made EasyGenetic Algorithms Made Easy
Genetic Algorithms Made Easy
Prakash Pimpale
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
garima931
 
Ad

Similar to Regular expressions-Theory of computation (20)

Regular expression
Regular expressionRegular expression
Regular expression
MONIRUL ISLAM
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
VenkataRaoS1
 
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
Srimatre K
 
UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
karthikeyan Muthusamy
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
viswanath kani
 
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
Rushabh2428
 
FLAT.pdf
FLAT.pdfFLAT.pdf
FLAT.pdf
AtharvaJoshi930911
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
raosir123
 
AUTOMATA AUTOMATA Automata4Chapter3.pptx
AUTOMATA AUTOMATA Automata4Chapter3.pptxAUTOMATA AUTOMATA Automata4Chapter3.pptx
AUTOMATA AUTOMATA Automata4Chapter3.pptx
ArjayBalberan1
 
regular expression smmlmmmmmmmmmmmmm.ppt
regular expression smmlmmmmmmmmmmmmm.pptregular expression smmlmmmmmmmmmmmmm.ppt
regular expression smmlmmmmmmmmmmmmm.ppt
rishabhsrivastava518345
 
Unit ii
Unit iiUnit ii
Unit ii
TPLatchoumi
 
re1.ppt
re1.pptre1.ppt
re1.ppt
PEzhumalai
 
re1.ppt
re1.pptre1.ppt
re1.ppt
Sarvesh Warjurkar
 
re1.ppt
re1.pptre1.ppt
re1.ppt
MichelAdorableeCoraz
 
Re1 (3)
Re1 (3)Re1 (3)
Re1 (3)
pepe3059
 
RegularExpressions-theory of computation and formal language
RegularExpressions-theory of computation and formal languageRegularExpressions-theory of computation and formal language
RegularExpressions-theory of computation and formal language
mohdfareeduddin5
 
theory of computation notes for school of engineering
theory of computation notes for school of engineeringtheory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
Ch3.ppt
Ch3.pptCh3.ppt
Ch3.ppt
MDSayem35
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
bolovv
 
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
Srimatre K
 
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
Rushabh2428
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
raosir123
 
AUTOMATA AUTOMATA Automata4Chapter3.pptx
AUTOMATA AUTOMATA Automata4Chapter3.pptxAUTOMATA AUTOMATA Automata4Chapter3.pptx
AUTOMATA AUTOMATA Automata4Chapter3.pptx
ArjayBalberan1
 
regular expression smmlmmmmmmmmmmmmm.ppt
regular expression smmlmmmmmmmmmmmmm.pptregular expression smmlmmmmmmmmmmmmm.ppt
regular expression smmlmmmmmmmmmmmmm.ppt
rishabhsrivastava518345
 
RegularExpressions-theory of computation and formal language
RegularExpressions-theory of computation and formal languageRegularExpressions-theory of computation and formal language
RegularExpressions-theory of computation and formal language
mohdfareeduddin5
 
theory of computation notes for school of engineering
theory of computation notes for school of engineeringtheory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
bolovv
 
Ad

More from Bipul Roy Bpl (8)

Specification and complexity - algorithm
Specification and complexity - algorithmSpecification and complexity - algorithm
Specification and complexity - algorithm
Bipul Roy Bpl
 
Sequential circuit-Digital Electronics
Sequential circuit-Digital ElectronicsSequential circuit-Digital Electronics
Sequential circuit-Digital Electronics
Bipul Roy Bpl
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
Bipul Roy Bpl
 
Software engineering quality assurance and testing
Software engineering quality assurance and testingSoftware engineering quality assurance and testing
Software engineering quality assurance and testing
Bipul Roy Bpl
 
DFD level-0 to 1
DFD level-0 to 1DFD level-0 to 1
DFD level-0 to 1
Bipul Roy Bpl
 
Garment management system
Garment management systemGarment management system
Garment management system
Bipul Roy Bpl
 
Finite automata
Finite automataFinite automata
Finite automata
Bipul Roy Bpl
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
Bipul Roy Bpl
 
Specification and complexity - algorithm
Specification and complexity - algorithmSpecification and complexity - algorithm
Specification and complexity - algorithm
Bipul Roy Bpl
 
Sequential circuit-Digital Electronics
Sequential circuit-Digital ElectronicsSequential circuit-Digital Electronics
Sequential circuit-Digital Electronics
Bipul Roy Bpl
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
Bipul Roy Bpl
 
Software engineering quality assurance and testing
Software engineering quality assurance and testingSoftware engineering quality assurance and testing
Software engineering quality assurance and testing
Bipul Roy Bpl
 
Garment management system
Garment management systemGarment management system
Garment management system
Bipul Roy Bpl
 

Recently uploaded (20)

Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Tools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google CertificateTools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google Certificate
VICTOR MAESTRE RAMIREZ
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdfTop Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
evrigsolution
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
The Elixir Developer - All Things Open
The Elixir Developer - All Things OpenThe Elixir Developer - All Things Open
The Elixir Developer - All Things Open
Carlo Gilmar Padilla Santana
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
Meet the New Kid in the Sandbox - Integrating Visualization with Prometheus
Meet the New Kid in the Sandbox - Integrating Visualization with PrometheusMeet the New Kid in the Sandbox - Integrating Visualization with Prometheus
Meet the New Kid in the Sandbox - Integrating Visualization with Prometheus
Eric D. Schabell
 
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEMGDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
philipnathen82
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Tools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google CertificateTools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google Certificate
VICTOR MAESTRE RAMIREZ
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdfTop Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
evrigsolution
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
Meet the New Kid in the Sandbox - Integrating Visualization with Prometheus
Meet the New Kid in the Sandbox - Integrating Visualization with PrometheusMeet the New Kid in the Sandbox - Integrating Visualization with Prometheus
Meet the New Kid in the Sandbox - Integrating Visualization with Prometheus
Eric D. Schabell
 
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEMGDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
philipnathen82
 

Regular expressions-Theory of computation

  • 1. Theory of Computation - RegularRegular ExpressionsExpressions Notation to specify a language Declarative Sort of like a programming language. Fundamental in some languages like perl and applications like grep or lex Capable of describing the same thing as a NFA The two are actually equivalent, so RE = NFA = DFA We can define an algebra for regular expressions
  • 2. Algebra for LanguagesAlgebra for Languages  Previously we discussed these operators:  Union (+)  Concatenation (.)  Kleene Star/Closure (*)
  • 3. Definition of a Regular Expression  R is a regular expression if it is: 1. a for some a in the alphabet ∑, standing for the language {a} 2. , standing for the language { }ε ε 3. Ø, standing for the empty language 4. R1+R2where R1 and R2 are regular expressions, and + signifies union (sometimes | is used) 5. R1R2 where R1 and R2 are regular expressions and this signifies concatenation 6. R* where R is a regular expression and signifies closure 7. (R) where R is a regular expression, then a parenthesized R is also a regular expression
  • 4. RE Examples:RE Examples:  L(001) = {001}  L(0+10*) = { 0, 1, 10, 100, 1000, 10000, … }  L(0*10*) = {1, 01, 10, 010, 0010, …} i.e. {w | w has exactly a single 1}  L(∑∑)* = {w | w is a string of even length}  L((0(0+1))*) = { , 00, 01, 0000, 0001, 0100, 0101, …}ε  L((0+ )(1+ε ε)) = { , 0, 1, 01}ε  L(1Ø) = Ø ; concatenating the empty set to any set yields the empty set.  R = Rε  R+Ø = R
  • 5. Equivalence of FA andEquivalence of FA and RERE  Finite Automata and Regular Expressions are equivalent. To show this: Show we can express a DFA as an equivalent RE Show we can express a RE as an NFA.
  • 6. Turning a DFA into a RETurning a DFA into a RE Theorem: If L=L(A) for some DFA , then there is a regular expression R such that L=L(R). State Elimination We’ll see how to do this next, easier than inductive construction, there is no exponential number of expressions
  • 7. DFA to RE: StateDFA to RE: State EliminationElimination Eliminates states of the automaton and replaces the edges with regular expressions that includes the behavior of the eliminated states. Eventually we get down to the situation with just a start and final node, and this is easy to express as a RE
  • 8. DFA to RE via StateDFA to RE via State Elimination (1)Elimination (1) 1. Starting with intermediate states and then moving to accepting states, apply the state elimination process to produce an equivalent automaton with regular expression labels on the edges. • The result will be a one or two state automaton with a start state and accepting state.
  • 9. DFA to RE StateDFA to RE State Elimination (2):Elimination (2): 2. If the two states are different, we will have an automaton that looks like the following: Start S R T U We can describe this automaton as: (R+SU*T)*SU*
  • 10. DFA to RE StateDFA to RE State Elimination (3)Elimination (3) 3. If the start state is also an accepting state, then we must also perform a state elimination from the original automaton that gets rid of every state but the start state. This leaves the following: Start R We can describe this automaton as simply R*.
  • 11. DFA to RE State EliminationDFA to RE State Elimination (4)(4) 4. If there are n accepting states, we must repeat the above steps for each accepting states to get n different regular expressions, R1, R2, … Rn. For each repeat we turn any other accepting state to non-accepting. The desired regular expression for the automaton is then the union of each of the n regular expressions: R1∪ R2… ∪ RN
  • 12. DFARE Example Convert the following to a RE First convert the edges to RE’s: 3Start 1 2 1 1 0 0 0,1 3Start 1 2 1 1 0 0 0+1
  • 13. DFADFA  RE Example (2)RE Example (2) Eliminate State 1: 3Start 1 2 1 1 0 0 0+1 3Start 2 11 0+10 0+1 Answer: (0+10)*11(0+1)*
  • 14. Converting a RE to anConverting a RE to an AutomataAutomata We have shown we can convert an automata to a RE. To show equivalence we must also go the other direction, convert a RE to an automaton. We can do this easiest by converting a RE to an NFA Inductive construction Start with a simple basis, use that to build more complex parts of the NFA
  • 15. RE toRE to NFA:NFA: Basis: R=a R=ε a ε R=Ø
  • 17. RE to NFA Example  Convert R= (ab+a)* to an NFA We proceed in stages, starting from simple elements and working our way up a a b b ab a bε
  • 18. RE toRE to NFANFA Example (2):Example (2): ab+a a bε a ε ε ε ε (ab+a)* a bε a ε ε ε ε εε ε ε
  • 19. Algebraic Laws for RE’s Just like we have an algebra for arithmetic, we also have an algebra for regular expressions. While there are some similarities to arithmetic algebra, it is a bit different with regular expressions.
  • 20. Algebra for RE’s:Algebra for RE’s: Commutative law for union: L + M = M + L Associative law for union: (L + M) + N = L + (M + N) Associative law for concatenation: (LM)N = L(MN) Note that there is no commutative law for concatenation, i.e. LM ≠ ML
  • 21. Algebra for RE’s (2):Algebra for RE’s (2): The identity for union is: L + Ø = Ø + L = L The identity for concatenation is: L = L = Lε ε The annihilator for concatenation is: ØL = LØ = Ø Left distributive law: L(M + N) = LM + LN Right distributive law: (M + N)L = LM + LN Idempotent law: L + L = L
  • 22. Laws Involving Closure:Laws Involving Closure: (L*)* = L* i.e. closing an already closed expression does not change the language Ø* = ε  *ε = ε L+ = LL* = L*L L* = L+ + ε
  • 23. 23 End of SlidesEnd of Slides
  翻译: