SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Topic - Regular Expressions andTopic - Regular Expressions and
LanguagesLanguages
Dilouar Hossain
dilouarbd@gmail.com
Topic ContentsTopic Contents
 Regular ExpressionsRegular Expressions

 Finite Automata and Regular ExpressionsFinite Automata and Regular Expressions

 Applications of Regular ExpressionsApplications of Regular Expressions

 Algebraic Laws for Regular ExpressionsAlgebraic Laws for Regular Expressions

Regular Expressions
Md. Tarek Habib3
Regular expressions are language-defining notation
Regular expressions are useful in applications such as text-search
applications and compiler components
Regular Expressions…
Md. Tarek Habib4
A FA (NFA or DFA) is a “blueprint" for constructing
a machine recognizing regular language.
A regular expression is a “user-friendly,"
declarative way of describing a regular language.
Example: 01* + 10*
Regular expressions are used in
1. UNIX grep command
2. UNIX Lex (Lexical analyzer generator)...
Operations
5
Building Regular Expressions (regex’s)
6
Example
7
Equivalence of FA’s and regex’s
Md. Tarek Habib8
FA to regex
9
For each accepting state q, apply a reduction process to
produce an equivalent automaton with regular-
expression labels on the arcs. Eliminate all states except
q and the start state q0.
If q ≠ q0, then we shall be left with a two-state
automaton that looks like:
FA to regex…
Md. Tarek Habib10
If the start state is also an accepting state, then we must
also perform a state-elimination from the original FA
that gets rid of every state except the start state. Then
we are left with a one-state automaton:
FA to regex…
Md. Tarek Habib11
If there is more than one final state in the original FA, then
we must union all the Eq to obtain the final regular
expression.
FA to regex Example
Md. Tarek Habib12
FA to regex Example…
13
FA to regex Example…
14
regex to FA
Md. Tarek Habib15
Suppose L = L(R) for a regex R. Then we can design a -NFAε
E such that L(R) = L(E).
E will have:
• Exactly one accepting state
• No arcs into the initial state
• No arcs out of the accepting state
regex to FA…
Md. Tarek Habib16
regex to FA…
17
regex to FA Example
18
Algebraic Laws for Regular Expressions:
Commutativity and Associativity
Md. Tarek Habib19
Algebraic Laws for Regular Expressions:
Identities and Annihilators
Md. Tarek Habib20
Algebraic Laws for Regular Expressions:
Distributive Laws
Md. Tarek Habib21
Algebraic Laws for Regular Expressions:
Distributive Laws
Md. Tarek Habib22
Algebraic Laws for Regular Expressions:
The Idempotent Law
Md. Tarek Habib23
Algebraic Laws for Regular Expressions:
Laws Involving Closures
Md. Tarek Habib24
The End

Weitere ähnliche Inhalte

Was ist angesagt?

Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFAMaulik Togadiya
 
RABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGRABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGAbhishek Singh
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expressionAnimesh Chaturvedi
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture NotesFellowBuddy.com
 
0.0 Introduction to theory of computation
0.0 Introduction to theory of computation0.0 Introduction to theory of computation
0.0 Introduction to theory of computationSampath Kumar S
 
Regular expression
Regular expressionRegular expression
Regular expressionRajon
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal languageRabia Khalid
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free GrammarAkhil Kaushik
 
Rabin Carp String Matching algorithm
Rabin Carp String Matching  algorithmRabin Carp String Matching  algorithm
Rabin Carp String Matching algorithmsabiya sabiya
 
Deciability (automata presentation)
Deciability (automata presentation)Deciability (automata presentation)
Deciability (automata presentation)Sagar Kumar
 

Was ist angesagt? (20)

Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Theory of computation Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
RABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGRABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHING
 
TOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFATOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFA
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture Notes
 
0.0 Introduction to theory of computation
0.0 Introduction to theory of computation0.0 Introduction to theory of computation
0.0 Introduction to theory of computation
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Rabin Carp String Matching algorithm
Rabin Carp String Matching  algorithmRabin Carp String Matching  algorithm
Rabin Carp String Matching algorithm
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
Finite automata
Finite automataFinite automata
Finite automata
 
Rabin karp string matcher
Rabin karp string matcherRabin karp string matcher
Rabin karp string matcher
 
Deciability (automata presentation)
Deciability (automata presentation)Deciability (automata presentation)
Deciability (automata presentation)
 
Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
Naive string matching
Naive string matchingNaive string matching
Naive string matching
 

Andere mochten auch (13)

Theory of computing pdf
Theory of computing pdfTheory of computing pdf
Theory of computing pdf
 
LinkedIn Hacks
LinkedIn HacksLinkedIn Hacks
LinkedIn Hacks
 
正規表現の先読みについて
正規表現の先読みについて正規表現の先読みについて
正規表現の先読みについて
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINE
 
Pda
PdaPda
Pda
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Push down automata
Push down automataPush down automata
Push down automata
 
Ch3
Ch3Ch3
Ch3
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Inheritance
InheritanceInheritance
Inheritance
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 

Ähnlich wie Regular expressions and languages pdf

Ähnlich wie Regular expressions and languages pdf (18)

Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
 
Lexical Analyzer Implementation
Lexical Analyzer ImplementationLexical Analyzer Implementation
Lexical Analyzer Implementation
 
Lex and Yacc Tool M1.ppt
Lex and Yacc Tool M1.pptLex and Yacc Tool M1.ppt
Lex and Yacc Tool M1.ppt
 
Chapter-3 compiler.pptx course materials
Chapter-3 compiler.pptx course materialsChapter-3 compiler.pptx course materials
Chapter-3 compiler.pptx course materials
 
replacement grammars
replacement grammarsreplacement grammars
replacement grammars
 
CH 2.pptx
CH 2.pptxCH 2.pptx
CH 2.pptx
 
LVEE 2014: Text parsing with Python and PLY
LVEE 2014: Text parsing with Python and PLYLVEE 2014: Text parsing with Python and PLY
LVEE 2014: Text parsing with Python and PLY
 
Regular expression
Regular expressionRegular expression
Regular expression
 
531AlmadhorAlwageed2010.ppt
531AlmadhorAlwageed2010.ppt531AlmadhorAlwageed2010.ppt
531AlmadhorAlwageed2010.ppt
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Cse presentation
Cse   presentationCse   presentation
Cse presentation
 
SS UI Lecture 6
SS UI Lecture 6SS UI Lecture 6
SS UI Lecture 6
 
01.ppt
01.ppt01.ppt
01.ppt
 
Class9
 Class9 Class9
Class9
 
Unit ii
Unit iiUnit ii
Unit ii
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design File
 
C programming-apurbo datta
C programming-apurbo dattaC programming-apurbo datta
C programming-apurbo datta
 
Regular Expression to Finite Automata
Regular Expression to Finite AutomataRegular Expression to Finite Automata
Regular Expression to Finite Automata
 

Mehr von Dilouar Hossain

Digital Marketing Trainer Interview Overview.pptx
Digital Marketing Trainer Interview Overview.pptxDigital Marketing Trainer Interview Overview.pptx
Digital Marketing Trainer Interview Overview.pptxDilouar Hossain
 
Future lab institute plan
Future lab institute planFuture lab institute plan
Future lab institute planDilouar Hossain
 
Welcome to our presentation
Welcome to our presentationWelcome to our presentation
Welcome to our presentationDilouar Hossain
 
Pharmacy management software presentation overview
Pharmacy management software presentation overviewPharmacy management software presentation overview
Pharmacy management software presentation overviewDilouar Hossain
 
Training overview on digital marketing
Training overview on digital marketingTraining overview on digital marketing
Training overview on digital marketingDilouar Hossain
 
How to work zoom meeting apps | zoom cloud meetings
How to work zoom meeting apps | zoom cloud meetingsHow to work zoom meeting apps | zoom cloud meetings
How to work zoom meeting apps | zoom cloud meetingsDilouar Hossain
 
Digital marketing Tips (Facebook, Linkedin, Twitter Marketing)
Digital marketing Tips (Facebook, Linkedin, Twitter Marketing)Digital marketing Tips (Facebook, Linkedin, Twitter Marketing)
Digital marketing Tips (Facebook, Linkedin, Twitter Marketing)Dilouar Hossain
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Dilouar Hossain
 
Web development (Wordpress)
Web development (Wordpress)Web development (Wordpress)
Web development (Wordpress)Dilouar Hossain
 
Internship Training overview
Internship Training overviewInternship Training overview
Internship Training overviewDilouar Hossain
 
My life style of Dilouar Hossain
My life style of Dilouar HossainMy life style of Dilouar Hossain
My life style of Dilouar HossainDilouar Hossain
 
Career guideline for freelancers By Dilouar Hossain
Career guideline for freelancers By Dilouar HossainCareer guideline for freelancers By Dilouar Hossain
Career guideline for freelancers By Dilouar HossainDilouar Hossain
 
Welcome to creative Software in Bangladesh
Welcome to creative Software in BangladeshWelcome to creative Software in Bangladesh
Welcome to creative Software in BangladeshDilouar Hossain
 
Two phase commit protocol in dbms
Two phase commit protocol in dbmsTwo phase commit protocol in dbms
Two phase commit protocol in dbmsDilouar Hossain
 
High pass filter with analog electronic
High pass filter with analog electronicHigh pass filter with analog electronic
High pass filter with analog electronicDilouar Hossain
 
Dc generator with machine 2
Dc generator with machine 2Dc generator with machine 2
Dc generator with machine 2Dilouar Hossain
 
Dc generator with machine 2
Dc generator with machine 2Dc generator with machine 2
Dc generator with machine 2Dilouar Hossain
 

Mehr von Dilouar Hossain (19)

Digital Marketing Trainer Interview Overview.pptx
Digital Marketing Trainer Interview Overview.pptxDigital Marketing Trainer Interview Overview.pptx
Digital Marketing Trainer Interview Overview.pptx
 
Future lab institute plan
Future lab institute planFuture lab institute plan
Future lab institute plan
 
Welcome to our presentation
Welcome to our presentationWelcome to our presentation
Welcome to our presentation
 
Pharmacy management software presentation overview
Pharmacy management software presentation overviewPharmacy management software presentation overview
Pharmacy management software presentation overview
 
Training overview on digital marketing
Training overview on digital marketingTraining overview on digital marketing
Training overview on digital marketing
 
How to work zoom meeting apps | zoom cloud meetings
How to work zoom meeting apps | zoom cloud meetingsHow to work zoom meeting apps | zoom cloud meetings
How to work zoom meeting apps | zoom cloud meetings
 
Digital marketing Tips (Facebook, Linkedin, Twitter Marketing)
Digital marketing Tips (Facebook, Linkedin, Twitter Marketing)Digital marketing Tips (Facebook, Linkedin, Twitter Marketing)
Digital marketing Tips (Facebook, Linkedin, Twitter Marketing)
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Web development (Wordpress)
Web development (Wordpress)Web development (Wordpress)
Web development (Wordpress)
 
Internship Training overview
Internship Training overviewInternship Training overview
Internship Training overview
 
My life style of Dilouar Hossain
My life style of Dilouar HossainMy life style of Dilouar Hossain
My life style of Dilouar Hossain
 
Career guideline for freelancers By Dilouar Hossain
Career guideline for freelancers By Dilouar HossainCareer guideline for freelancers By Dilouar Hossain
Career guideline for freelancers By Dilouar Hossain
 
Welcome to creative pos
Welcome to creative posWelcome to creative pos
Welcome to creative pos
 
Welcome to creative Software in Bangladesh
Welcome to creative Software in BangladeshWelcome to creative Software in Bangladesh
Welcome to creative Software in Bangladesh
 
Batch operating system
Batch operating system Batch operating system
Batch operating system
 
Two phase commit protocol in dbms
Two phase commit protocol in dbmsTwo phase commit protocol in dbms
Two phase commit protocol in dbms
 
High pass filter with analog electronic
High pass filter with analog electronicHigh pass filter with analog electronic
High pass filter with analog electronic
 
Dc generator with machine 2
Dc generator with machine 2Dc generator with machine 2
Dc generator with machine 2
 
Dc generator with machine 2
Dc generator with machine 2Dc generator with machine 2
Dc generator with machine 2
 

Kürzlich hochgeladen

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...Health
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxnuruddin69
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 

Kürzlich hochgeladen (20)

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 

Regular expressions and languages pdf

  • 1. Topic - Regular Expressions andTopic - Regular Expressions and LanguagesLanguages Dilouar Hossain dilouarbd@gmail.com
  • 2. Topic ContentsTopic Contents  Regular ExpressionsRegular Expressions   Finite Automata and Regular ExpressionsFinite Automata and Regular Expressions   Applications of Regular ExpressionsApplications of Regular Expressions   Algebraic Laws for Regular ExpressionsAlgebraic Laws for Regular Expressions 
  • 3. Regular Expressions Md. Tarek Habib3 Regular expressions are language-defining notation Regular expressions are useful in applications such as text-search applications and compiler components
  • 4. Regular Expressions… Md. Tarek Habib4 A FA (NFA or DFA) is a “blueprint" for constructing a machine recognizing regular language. A regular expression is a “user-friendly," declarative way of describing a regular language. Example: 01* + 10* Regular expressions are used in 1. UNIX grep command 2. UNIX Lex (Lexical analyzer generator)...
  • 8. Equivalence of FA’s and regex’s Md. Tarek Habib8
  • 9. FA to regex 9 For each accepting state q, apply a reduction process to produce an equivalent automaton with regular- expression labels on the arcs. Eliminate all states except q and the start state q0. If q ≠ q0, then we shall be left with a two-state automaton that looks like:
  • 10. FA to regex… Md. Tarek Habib10 If the start state is also an accepting state, then we must also perform a state-elimination from the original FA that gets rid of every state except the start state. Then we are left with a one-state automaton:
  • 11. FA to regex… Md. Tarek Habib11 If there is more than one final state in the original FA, then we must union all the Eq to obtain the final regular expression.
  • 12. FA to regex Example Md. Tarek Habib12
  • 13. FA to regex Example… 13
  • 14. FA to regex Example… 14
  • 15. regex to FA Md. Tarek Habib15 Suppose L = L(R) for a regex R. Then we can design a -NFAε E such that L(R) = L(E). E will have: • Exactly one accepting state • No arcs into the initial state • No arcs out of the accepting state
  • 16. regex to FA… Md. Tarek Habib16
  • 18. regex to FA Example 18
  • 19. Algebraic Laws for Regular Expressions: Commutativity and Associativity Md. Tarek Habib19
  • 20. Algebraic Laws for Regular Expressions: Identities and Annihilators Md. Tarek Habib20
  • 21. Algebraic Laws for Regular Expressions: Distributive Laws Md. Tarek Habib21
  • 22. Algebraic Laws for Regular Expressions: Distributive Laws Md. Tarek Habib22
  • 23. Algebraic Laws for Regular Expressions: The Idempotent Law Md. Tarek Habib23
  • 24. Algebraic Laws for Regular Expressions: Laws Involving Closures Md. Tarek Habib24