SlideShare a Scribd company logo
Theory of Computation
By Rushabh Wadkar
Topics to be covered
Regular expressions & Regular
Languages relationship
Reduction of states
Pumping Lemma
Day 5
Regular languages
● Any language that can be depicted(expressed) using a Finite State
machine is called a Regular language.
● A FSM can’t store any input variable, nor can it count.
● Hence any language that requires memory is not a regular language
Regular languages
Let us revise some examples:
● L= { 0n
1m
: m>=0,n>=1}
Regular languages
Let us revise some examples:
● L= { 0101n
U 0100 : n>=0}
Regular languages
Let us revise some examples:
● L= {an
U bn
U cn
: n>=0}
Regular languages and Regular Expressions
● A regular language can be described using regular expressions
consisting of the symbols such as alphabets in Σ.
● Additionally consisting of operators like ‘.’ | ‘+’ | ‘*’
● The symbols ‘(’ and ‘)’ can be used with regular expressions.
Regular languages and Regular Expressions
● + operator(union), has the least precedence.
● . operator(concatenation) has mid precedence.
● * operator(closure) has highest precedence.
However the expression enveloped by parentheses
obtains the highest precedence.
Let us try to understand the precedence of these operators:
Regular languages and Regular Expressions
A regular expression is recursively defined as follows:
1. Φ is a regular expression denoting an empty language.
2. ε-(epsilon) is a regular expression indicates the language containing an empty string.
3. a is a regular expression which indicates the language containing only {a}
4. If R is a regular expression denoting the language LR and S is a regular expression denoting
the language Ls, then
a. R+S is a regular expression corresponding to the language LR
U LS
.
b. R.S is a regular expression corresponding to the languageLR
. LS
.
c. R* is a regular expression corresponding to the language LR
.
5. The expressions obtained by applying any of the rules from 1 to 4 are regular expressions.
Regular languages and Regular Expressions
a* String consisting of any number of a’s(0 or more)
a
+ String consisting of at least of a’s
a+b String consisting of either one a or one b
(a+b)* Set of strings of a’s and b’s of any length(NULL included)
(a+b)*abb Set of strings of a’s and b’s, ending with abb
ab(a+b)* Set of strings of a’s and b’s, starting with ab
Regular languages and Regular Expressions
(a+b)*aa(a+b)* Set of strings of a’s and b’s, having substring aa
a*b*c* String consisting of any number of a’s(0 or more) followed by any
number of b’s(0 or more) followed by any number of c’s(0 or more)
a
+
b
+
c
+ String consisting of at least 1 a, followed by string having at least 1
b, followed by string having at least 1 c
aa*bb*cc* String consisting of at least 1 a, followed by string having at least 1
b, followed by string having at least 1 c
(a+b)*(a+bb) Set of strings of a’s and b’s ending with either a or bb
(aa)*(bb)*b Set of strings of even number of a’s followed by odd number of b’s
Regular languages and Regular Expressions
Regular Expression Problems
Q. Obtain a regular expression having a’s and b’s having length 2.
Strings of a’s and b’s having length 2: aa, bb, ab, ba
RE is: (aa+bb+ab+ba)
Regular Expression Problems
Q. Obtain a regular expression having a’s and b’s having length <=2.
Strings of a’s and b’s having length <=2:
ε + a + b + aa + bb + ab + ba
This can be written as: (ε + a + b)(ε + a + b)
RE is: (ε + a + b)2
Regular Expression Problems
Q. Obtain a regular expression having a’s and b’s having length <=10.
From the logic of the previous problem
RE is: (ε + a + b)10
Regular Expression Problems
Q. Obtain a regular expression having a’s and b’s having even length.
To obtain this we will use strings aa,bb,ab,ba zero
or more times.
RE is: (aa+bb+ab+ba)*
This can also be written as:
RE is: ((a+b)(a+b))*
Regular Expression Problems
Q. Obtain a regular expression having a’s and b’s having odd length.
From the previous example we know that the RE
for even length is ((a+b)(a+b))*
To this we just need to add 1 more symbol.
Hence,
RE is: (a+b)((a+b)(a+b))*
Regular Expression Problems
Q. Obtain a regular expression having alternate a’s and b’s.
To get alternate a’s and b’s we can use multiple
concatenations of ‘ab’ or ‘ba’.
Additionally to take care of the starting and ending
variable to be either a or b, we add (ε+a) and (ε+b)
In appropriate places.
RE is: (ε+b)(ab)*(ε+a)
To obtain a FA from a RE
We have seen examples of obtaining finite automata from a regular
expression. Now let us see this conversion from the other end.
Here we have the schematic
Representation of a Finite Automata(M)
accepting a regular Expression(R).
Where q is the initial and
f is the final state.
To obtain a FA from a RE
Let’s see the various cases for conversion.
To obtain a FA from a RE
Let’s see the various cases for conversion.
To obtain a FA from a RE
Let’s see the various cases for conversion.
Case 3: R=(R1
)* we can construct a NFA that accepts L((R1
)*) as shown in fig 2.6
To obtain a FA from a RE
Obtain an FSM for RE: a* + b* + c*
To obtain a FA from a RE
Adding the three graphs obtained for a*, b*, c*
To obtain a FA from a RE
Obtain a FSM for (a+b)*aa(a+b)*
To obtain a FA from a RE
We obtain FA for ‘aa’, and concatenate with (a+b)*
To obtain a FA from a RE
Finally obtained FSM is:
Pumping Lemma and Regular Languages
Pumping Lemma for Regular Languages
For any regular language L, there exists an integer n, such that for all
x ∈ L with |x| ≥ n, there exists u, v, w ∈ Σ*, such that x = uvw, and
(1) |uv| ≤ n
(2) |v| ≥ 1
(3) for all i ≥ 0: u vi
w ∈ L
Pumping Lemma and Regular Languages
Show that L = {w.wR
| w ∈(0,1)*} is not regular
Pumping Lemma and Regular Languages
Show that L = {ai
bj
| i>j } is not regular
Minimization of DFA
Suppose there is a DFA D = { Q, Σ, q0
, δ, F } which recognizes a language L.
Then the minimized DFA D’ = { Q’, Σ, q0
, δ’, F’ } can be constructed for language L as:
Step 1: We will divide Q (set of states) into two sets. One set will contain all final states and other set
will contain non-final states. This partition is called P0
.
Step 2: Initialize k = 1
Step 3: Find Pk
by partitioning the different sets of Pk-1
. In each set of Pk-1
, we will take all possible
pair of states. If two states of a set are distinguishable, we will split the sets into different sets in Pk
.
Step 4: Stop when Pk
= Pk-1
(No change in partition)
Step 5: All states of one set are merged into one. No. of states in minimized DFA will be equal to no.
of sets in Pk
.
Minimization of DFA
Step 1: P0
will have two sets of states.
One set will contain q1, q2, q4 which are
final states of DFA and another set will
contain remaining states.
So P0
= { { q1, q2, q4 }, { q0, q3, q5 } }.
Step 2. To calculate P1, we will check
whether sets of partition P0 can be partitioned or not:
i) For set { q1, q2, q4 } :
δ ( q1, 0 ) = δ ( q2, 0 ) = q2 and
δ ( q1, 1 ) = δ ( q2, 1 ) = q5.
So q1 and q2 are not distinguishable.
Similarly, δ ( q1, 0 ) = δ ( q4, 0 ) = q2 and
δ ( q1, 1 ) = δ ( q4, 1 ) = q5.
So q1 and q4 are not distinguishable.
Minimization of DFA
ii) For set { q0, q3, q5 } :
δ ( q0, 0 ) = q3 and δ ( q3, 0 ) = q0
δ ( q0, 1) = q1 and δ( q3, 1 ) = q4
So, q0 and q3 are not distinguishable.
δ ( q0, 0 ) = q3 and δ ( q5, 0 ) = q5 and
δ ( q0, 1 ) = q1 and δ ( q5, 1 ) = q5
Moves of q0 and q5 on input symbol 1 are q3 and q5
respectively which are in different set in partition P0. So, q0 and
q5 are distinguishable. So, set { q0, q3, q5 } will be partitioned
into { q0, q3 } and { q5 }. So,
P1 = { { q1, q2, q4 }, { q0, q3}, { q5 } }
Minimization of DFA
To calculate P2, we will check whether
sets of partition P1 can be partitioned or not:
iii)For set { q1, q2, q4 } :
δ ( q1, 0 ) = δ ( q2, 0 ) = q2 and
δ ( q1, 1 ) = δ ( q2, 1 ) = q5.
So q1 and q2 are not distinguishable.
Similarly, δ ( q1, 0 ) = δ ( q4, 0 ) = q2 and
δ ( q1, 1 ) = δ ( q4, 1 ) = q5.
So q1 and q4 are not distinguishable.
So, { q1, q2, q4 } set will not be partitioned in P2.
Minimization of DFA
iv)For set { q0, q3 } :
δ ( q0, 0 ) = q3 and δ ( q3, 0 ) = q0
δ ( q0, 1 ) = q1 and δ ( q3, 1 ) = q4
Moves of q0 and q3 on input symbol 0 are
q3 and q0 respectively which are in same set in
partition P1. Similarly, Moves of q0 and q3 on input
symbol 1 are q3 and q0 which are in same set in
partition P1. So, q0 and q3 are not distinguishable.
Minimization of DFA
v) For set { q5 }:
Since we have only one state in this set, it can’t be
further partitioned. So,
P2 = { { q1, q2, q4 }, { q0, q3 }, { q5 } }
Since, P1=P2. So, this is the final partition.
Partition P2 means that q1, q2 and q4 states are
merged into one. Similarly, q0 and q3 are merged into one.
End of Day 5
Thank you...
Pumping lemma
Extra Slides
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Ad

More Related Content

What's hot (20)

Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
Animesh Chaturvedi
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
PRIM'S ALGORITHM
PRIM'S ALGORITHMPRIM'S ALGORITHM
PRIM'S ALGORITHM
garishma bhatia
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
shah zeb
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
Sujata Pardeshi
 
0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM
i i
 
TOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite AutomataTOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite Automata
Mohammad Imam Hossain
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ratnakar Mikkili
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithm
Acad
 
2.8 normal forms gnf &amp; problems
2.8 normal forms   gnf &amp; problems2.8 normal forms   gnf &amp; problems
2.8 normal forms gnf &amp; problems
Sampath Kumar S
 
Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstra
Roshan Tailor
 
TOC 5 | Regular Expressions
TOC 5 | Regular ExpressionsTOC 5 | Regular Expressions
TOC 5 | Regular Expressions
Mohammad Imam Hossain
 
Rabin karp string matching algorithm
Rabin karp string matching algorithmRabin karp string matching algorithm
Rabin karp string matching algorithm
Gajanand Sharma
 
push down automata
 push down automata push down automata
push down automata
nadiatariq6
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2
shah zeb
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitra
guest1f4fb3
 
Loop invarient
Loop invarientLoop invarient
Loop invarient
Amit Kumar Rathi
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
R Islam
 
Introduction To Autumata Theory
 Introduction To Autumata Theory Introduction To Autumata Theory
Introduction To Autumata Theory
Abdul Rehman
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
Maulik Togadiya
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
Animesh Chaturvedi
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
shah zeb
 
0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM
i i
 
TOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite AutomataTOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite Automata
Mohammad Imam Hossain
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithm
Acad
 
2.8 normal forms gnf &amp; problems
2.8 normal forms   gnf &amp; problems2.8 normal forms   gnf &amp; problems
2.8 normal forms gnf &amp; problems
Sampath Kumar S
 
Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstra
Roshan Tailor
 
Rabin karp string matching algorithm
Rabin karp string matching algorithmRabin karp string matching algorithm
Rabin karp string matching algorithm
Gajanand Sharma
 
push down automata
 push down automata push down automata
push down automata
nadiatariq6
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2
shah zeb
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitra
guest1f4fb3
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
R Islam
 
Introduction To Autumata Theory
 Introduction To Autumata Theory Introduction To Autumata Theory
Introduction To Autumata Theory
Abdul Rehman
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
Maulik Togadiya
 

Similar to Theory of Computation Regular Expressions, Minimisation & Pumping Lemma (20)

UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
karthikeyan Muthusamy
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
Lec1.pptx
Lec1.pptxLec1.pptx
Lec1.pptx
ziadk6872
 
Theory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite AcceptorsTheory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite Acceptors
Rushabh2428
 
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
 
Lex analysis
Lex analysisLex analysis
Lex analysis
Suhit Kulkarni
 
Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
VenkataRaoS1
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
Automata theory
Automata theoryAutomata theory
Automata theory
Pardeep Vats
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
Rushabh2428
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
viswanath kani
 
fullunit2-220307090026 (1) theory of computation.pptx
fullunit2-220307090026 (1) theory of computation.pptxfullunit2-220307090026 (1) theory of computation.pptx
fullunit2-220307090026 (1) theory of computation.pptx
yuvaraniit
 
Hwsoln03 toc
Hwsoln03 tocHwsoln03 toc
Hwsoln03 toc
parmeet834
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
parmeet834
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
Bipul Roy Bpl
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
RaviAr5
 
automata problems
automata problemsautomata problems
automata problems
aiswarya chelikani
 
FLAT.pdf
FLAT.pdfFLAT.pdf
FLAT.pdf
AtharvaJoshi930911
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
Theory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite AcceptorsTheory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite Acceptors
Rushabh2428
 
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
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
Rushabh2428
 
fullunit2-220307090026 (1) theory of computation.pptx
fullunit2-220307090026 (1) theory of computation.pptxfullunit2-220307090026 (1) theory of computation.pptx
fullunit2-220307090026 (1) theory of computation.pptx
yuvaraniit
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
parmeet834
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
Bipul Roy Bpl
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
RaviAr5
 
Ad

Recently uploaded (20)

Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Ad

Theory of Computation Regular Expressions, Minimisation & Pumping Lemma

  • 1. Theory of Computation By Rushabh Wadkar
  • 2. Topics to be covered Regular expressions & Regular Languages relationship Reduction of states Pumping Lemma Day 5
  • 3. Regular languages ● Any language that can be depicted(expressed) using a Finite State machine is called a Regular language. ● A FSM can’t store any input variable, nor can it count. ● Hence any language that requires memory is not a regular language
  • 4. Regular languages Let us revise some examples: ● L= { 0n 1m : m>=0,n>=1}
  • 5. Regular languages Let us revise some examples: ● L= { 0101n U 0100 : n>=0}
  • 6. Regular languages Let us revise some examples: ● L= {an U bn U cn : n>=0}
  • 7. Regular languages and Regular Expressions ● A regular language can be described using regular expressions consisting of the symbols such as alphabets in Σ. ● Additionally consisting of operators like ‘.’ | ‘+’ | ‘*’ ● The symbols ‘(’ and ‘)’ can be used with regular expressions.
  • 8. Regular languages and Regular Expressions ● + operator(union), has the least precedence. ● . operator(concatenation) has mid precedence. ● * operator(closure) has highest precedence. However the expression enveloped by parentheses obtains the highest precedence. Let us try to understand the precedence of these operators:
  • 9. Regular languages and Regular Expressions A regular expression is recursively defined as follows: 1. Φ is a regular expression denoting an empty language. 2. ε-(epsilon) is a regular expression indicates the language containing an empty string. 3. a is a regular expression which indicates the language containing only {a} 4. If R is a regular expression denoting the language LR and S is a regular expression denoting the language Ls, then a. R+S is a regular expression corresponding to the language LR U LS . b. R.S is a regular expression corresponding to the languageLR . LS . c. R* is a regular expression corresponding to the language LR . 5. The expressions obtained by applying any of the rules from 1 to 4 are regular expressions.
  • 10. Regular languages and Regular Expressions a* String consisting of any number of a’s(0 or more) a + String consisting of at least of a’s a+b String consisting of either one a or one b (a+b)* Set of strings of a’s and b’s of any length(NULL included) (a+b)*abb Set of strings of a’s and b’s, ending with abb ab(a+b)* Set of strings of a’s and b’s, starting with ab
  • 11. Regular languages and Regular Expressions (a+b)*aa(a+b)* Set of strings of a’s and b’s, having substring aa a*b*c* String consisting of any number of a’s(0 or more) followed by any number of b’s(0 or more) followed by any number of c’s(0 or more) a + b + c + String consisting of at least 1 a, followed by string having at least 1 b, followed by string having at least 1 c aa*bb*cc* String consisting of at least 1 a, followed by string having at least 1 b, followed by string having at least 1 c (a+b)*(a+bb) Set of strings of a’s and b’s ending with either a or bb (aa)*(bb)*b Set of strings of even number of a’s followed by odd number of b’s
  • 12. Regular languages and Regular Expressions
  • 13. Regular Expression Problems Q. Obtain a regular expression having a’s and b’s having length 2. Strings of a’s and b’s having length 2: aa, bb, ab, ba RE is: (aa+bb+ab+ba)
  • 14. Regular Expression Problems Q. Obtain a regular expression having a’s and b’s having length <=2. Strings of a’s and b’s having length <=2: ε + a + b + aa + bb + ab + ba This can be written as: (ε + a + b)(ε + a + b) RE is: (ε + a + b)2
  • 15. Regular Expression Problems Q. Obtain a regular expression having a’s and b’s having length <=10. From the logic of the previous problem RE is: (ε + a + b)10
  • 16. Regular Expression Problems Q. Obtain a regular expression having a’s and b’s having even length. To obtain this we will use strings aa,bb,ab,ba zero or more times. RE is: (aa+bb+ab+ba)* This can also be written as: RE is: ((a+b)(a+b))*
  • 17. Regular Expression Problems Q. Obtain a regular expression having a’s and b’s having odd length. From the previous example we know that the RE for even length is ((a+b)(a+b))* To this we just need to add 1 more symbol. Hence, RE is: (a+b)((a+b)(a+b))*
  • 18. Regular Expression Problems Q. Obtain a regular expression having alternate a’s and b’s. To get alternate a’s and b’s we can use multiple concatenations of ‘ab’ or ‘ba’. Additionally to take care of the starting and ending variable to be either a or b, we add (ε+a) and (ε+b) In appropriate places. RE is: (ε+b)(ab)*(ε+a)
  • 19. To obtain a FA from a RE We have seen examples of obtaining finite automata from a regular expression. Now let us see this conversion from the other end. Here we have the schematic Representation of a Finite Automata(M) accepting a regular Expression(R). Where q is the initial and f is the final state.
  • 20. To obtain a FA from a RE Let’s see the various cases for conversion.
  • 21. To obtain a FA from a RE Let’s see the various cases for conversion.
  • 22. To obtain a FA from a RE Let’s see the various cases for conversion. Case 3: R=(R1 )* we can construct a NFA that accepts L((R1 )*) as shown in fig 2.6
  • 23. To obtain a FA from a RE Obtain an FSM for RE: a* + b* + c*
  • 24. To obtain a FA from a RE Adding the three graphs obtained for a*, b*, c*
  • 25. To obtain a FA from a RE Obtain a FSM for (a+b)*aa(a+b)*
  • 26. To obtain a FA from a RE We obtain FA for ‘aa’, and concatenate with (a+b)*
  • 27. To obtain a FA from a RE Finally obtained FSM is:
  • 28. Pumping Lemma and Regular Languages Pumping Lemma for Regular Languages For any regular language L, there exists an integer n, such that for all x ∈ L with |x| ≥ n, there exists u, v, w ∈ Σ*, such that x = uvw, and (1) |uv| ≤ n (2) |v| ≥ 1 (3) for all i ≥ 0: u vi w ∈ L
  • 29. Pumping Lemma and Regular Languages Show that L = {w.wR | w ∈(0,1)*} is not regular
  • 30. Pumping Lemma and Regular Languages Show that L = {ai bj | i>j } is not regular
  • 31. Minimization of DFA Suppose there is a DFA D = { Q, Σ, q0 , δ, F } which recognizes a language L. Then the minimized DFA D’ = { Q’, Σ, q0 , δ’, F’ } can be constructed for language L as: Step 1: We will divide Q (set of states) into two sets. One set will contain all final states and other set will contain non-final states. This partition is called P0 . Step 2: Initialize k = 1 Step 3: Find Pk by partitioning the different sets of Pk-1 . In each set of Pk-1 , we will take all possible pair of states. If two states of a set are distinguishable, we will split the sets into different sets in Pk . Step 4: Stop when Pk = Pk-1 (No change in partition) Step 5: All states of one set are merged into one. No. of states in minimized DFA will be equal to no. of sets in Pk .
  • 32. Minimization of DFA Step 1: P0 will have two sets of states. One set will contain q1, q2, q4 which are final states of DFA and another set will contain remaining states. So P0 = { { q1, q2, q4 }, { q0, q3, q5 } }. Step 2. To calculate P1, we will check whether sets of partition P0 can be partitioned or not: i) For set { q1, q2, q4 } : δ ( q1, 0 ) = δ ( q2, 0 ) = q2 and δ ( q1, 1 ) = δ ( q2, 1 ) = q5. So q1 and q2 are not distinguishable. Similarly, δ ( q1, 0 ) = δ ( q4, 0 ) = q2 and δ ( q1, 1 ) = δ ( q4, 1 ) = q5. So q1 and q4 are not distinguishable.
  • 33. Minimization of DFA ii) For set { q0, q3, q5 } : δ ( q0, 0 ) = q3 and δ ( q3, 0 ) = q0 δ ( q0, 1) = q1 and δ( q3, 1 ) = q4 So, q0 and q3 are not distinguishable. δ ( q0, 0 ) = q3 and δ ( q5, 0 ) = q5 and δ ( q0, 1 ) = q1 and δ ( q5, 1 ) = q5 Moves of q0 and q5 on input symbol 1 are q3 and q5 respectively which are in different set in partition P0. So, q0 and q5 are distinguishable. So, set { q0, q3, q5 } will be partitioned into { q0, q3 } and { q5 }. So, P1 = { { q1, q2, q4 }, { q0, q3}, { q5 } }
  • 34. Minimization of DFA To calculate P2, we will check whether sets of partition P1 can be partitioned or not: iii)For set { q1, q2, q4 } : δ ( q1, 0 ) = δ ( q2, 0 ) = q2 and δ ( q1, 1 ) = δ ( q2, 1 ) = q5. So q1 and q2 are not distinguishable. Similarly, δ ( q1, 0 ) = δ ( q4, 0 ) = q2 and δ ( q1, 1 ) = δ ( q4, 1 ) = q5. So q1 and q4 are not distinguishable. So, { q1, q2, q4 } set will not be partitioned in P2.
  • 35. Minimization of DFA iv)For set { q0, q3 } : δ ( q0, 0 ) = q3 and δ ( q3, 0 ) = q0 δ ( q0, 1 ) = q1 and δ ( q3, 1 ) = q4 Moves of q0 and q3 on input symbol 0 are q3 and q0 respectively which are in same set in partition P1. Similarly, Moves of q0 and q3 on input symbol 1 are q3 and q0 which are in same set in partition P1. So, q0 and q3 are not distinguishable.
  • 36. Minimization of DFA v) For set { q5 }: Since we have only one state in this set, it can’t be further partitioned. So, P2 = { { q1, q2, q4 }, { q0, q3 }, { q5 } } Since, P1=P2. So, this is the final partition. Partition P2 means that q1, q2 and q4 states are merged into one. Similarly, q0 and q3 are merged into one.
  • 37. End of Day 5 Thank you...