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

More Related Content

What's hot

Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal languageRabia Khalid
 
Theory of Computation Basic Concepts and Grammar
Theory of Computation Basic Concepts and GrammarTheory of Computation Basic Concepts and Grammar
Theory of Computation Basic Concepts and GrammarRushabh2428
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysisDattatray Gandhmal
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRRiazul Islam
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingHemantha Kulathilake
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR Zahid Parvez
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)Naman Joshi
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expressionAnimesh Chaturvedi
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxAkhilJoseph63
 
Generalized transition graphs
Generalized transition graphsGeneralized transition graphs
Generalized transition graphsArham Khan G
 
context free language
context free languagecontext free language
context free languagekhush_boo31
 
Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 
1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfaSampath Kumar S
 

What's hot (20)

Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Theory of Computation Basic Concepts and Grammar
Theory of Computation Basic Concepts and GrammarTheory of Computation Basic Concepts and Grammar
Theory of Computation Basic Concepts and Grammar
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
 
Flat unit 1
Flat unit 1Flat unit 1
Flat unit 1
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological Parsing
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptx
 
Generalized transition graphs
Generalized transition graphsGeneralized transition graphs
Generalized transition graphs
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
 
context free language
context free languagecontext free language
context free language
 
TOC 5 | Regular Expressions
TOC 5 | Regular ExpressionsTOC 5 | Regular Expressions
TOC 5 | Regular Expressions
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa
 

Viewers also liked

REGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.AREGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.ADev Ashish
 
Computation Theory Topic
Computation Theory TopicComputation Theory Topic
Computation Theory TopicRehan 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 KanpurVivekananda Samiti
 
RegExp20110305
RegExp20110305RegExp20110305
RegExp20110305tmiya
 
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
 
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 algorithmsAndrii Babii
 
Evolutionary computation and_applications
Evolutionary computation and_applicationsEvolutionary computation and_applications
Evolutionary computation and_applicationsddawar
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesMarina Santini
 
introduction to web technology
introduction to web technologyintroduction to web technology
introduction to web technologyvikram singh
 
Genetic Algorithms Made Easy
Genetic Algorithms Made EasyGenetic Algorithms Made Easy
Genetic Algorithms Made EasyPrakash Pimpale
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithmgarima931
 

Viewers also liked (17)

REGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.AREGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.A
 
Computation Theory Topic
Computation Theory TopicComputation Theory Topic
Computation Theory Topic
 
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
 
Pumping lemma (1)
Pumping lemma (1)Pumping lemma (1)
Pumping lemma (1)
 
RegExp20110305
RegExp20110305RegExp20110305
RegExp20110305
 
Differential evolution
Differential evolutionDifferential evolution
Differential evolution
 
Theory of computing pdf
Theory of computing pdfTheory of computing pdf
Theory of computing pdf
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Ch3
Ch3Ch3
Ch3
 
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?"
 
Evolution algorithms
Evolution algorithmsEvolution algorithms
Evolution algorithms
 
Evolutionary computation and_applications
Evolutionary computation and_applicationsEvolutionary computation and_applications
Evolutionary computation and_applications
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
introduction to web technology
introduction to web technologyintroduction to web technology
introduction to web technology
 
Genetic Algorithms Made Easy
Genetic Algorithms Made EasyGenetic Algorithms Made Easy
Genetic Algorithms Made Easy
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 

Similar to Regular expressions-Theory of computation

Similar to Regular expressions-Theory of computation (20)

Regular expression
Regular expressionRegular expression
Regular expression
 
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
 
UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
 
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
 
FLAT.pdf
FLAT.pdfFLAT.pdf
FLAT.pdf
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
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
 
Ch3.ppt
Ch3.pptCh3.ppt
Ch3.ppt
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
 
Pcd(Mca)
Pcd(Mca)Pcd(Mca)
Pcd(Mca)
 
Pcd(Mca)
Pcd(Mca)Pcd(Mca)
Pcd(Mca)
 
PCD ?s(MCA)
PCD ?s(MCA)PCD ?s(MCA)
PCD ?s(MCA)
 
Principles of Compiler Design
Principles of Compiler DesignPrinciples of Compiler Design
Principles of Compiler Design
 
Compiler Design Material 2
Compiler Design Material 2Compiler Design Material 2
Compiler Design Material 2
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 

More from Bipul Roy Bpl

Specification and complexity - algorithm
Specification and complexity - algorithmSpecification and complexity - algorithm
Specification and complexity - algorithmBipul Roy Bpl
 
Sequential circuit-Digital Electronics
Sequential circuit-Digital ElectronicsSequential circuit-Digital Electronics
Sequential circuit-Digital ElectronicsBipul Roy Bpl
 
Test design techniques
Test design techniquesTest design techniques
Test design techniquesBipul Roy Bpl
 
Software engineering quality assurance and testing
Software engineering quality assurance and testingSoftware engineering quality assurance and testing
Software engineering quality assurance and testingBipul Roy Bpl
 
Garment management system
Garment management systemGarment management system
Garment management systemBipul Roy Bpl
 

More from Bipul Roy Bpl (7)

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

Recently uploaded

Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 

Recently uploaded (20)

Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 

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