SlideShare a Scribd company logo
UNIT-2
REGULAR EXPRESSION
K LAKSHMI SRVANI
ASST PROFESSOR
SYLLABUS
Regular Expressions: Finite Automata and Regular Expressions,
Applications of Regular Expressions, Algebraic Laws for Regular
Expressions, Conversion of Finite Automata to Regular Expressions.
Pumping Lemma for Regular Languages, Statement of the pumping
lemma, Applications of the Pumping Lemma.
Closure Properties of Regular Languages: Closure properties of
Regular languages, Decision Properties of Regular Languages,
Equivalence and Minimization of Automata.
Regular Expressions.
● Regular expressions are used for representing certain
sets of strings in algebraic fashion.
● Any terminal symbol belongs to Σ including ɸ,ɛ are
RE
● The union of 2 RE is also RE
● The Concatenation of 2 RE is also RE
● The iteration or closure of RE is also RE
Regular Expressions Regular Set
(0 + 10*) L = { 0, 1, 10, 100, 1000, 10000, … }
(0*10*) L = {1, 01, 10, 010, 0010, …}
(0 + ε)(1 + ε) L = {ε, 0, 1, 01}
(a+b)* Set of strings of a’s and b’s of any length
including the null string. So L = { ε, a, b, aa
, ab , bb , ba, aaa…….}
(11)* Set consisting of even number of 1’s
including empty string, So L= {ε, 11, 1111,
111111, ……….}
(0+1)*011(0+1)* Sub string 011
Operators of RE
Operators used in regular expressions include:
• Union: If R1 and R2 are regular expressions, then R1 | R2 (also written as R1 U R2 or R1 +
R2) is also a regular expression.
L(R1|R2) = L(R1) U L(R2) or L(R1+R2)



• Concatenation: If R1 and R2 are regular expressions, then R1R2 (also written as R1.R2) is
also a regular expression.
L(R1R2) = L(R1) concatenated with L(R2).



• Kleene closure: If R1 is a regular expression, then R1* (the Kleene closure of R1) is also a
regular expression.
L(R1*) = epsilon U L(R1) U L(R1R1) U L(R1R1R1) U ...

Precedence
● Closure > Concatenation > Union
● (01*+1)
Applications of RE
● RE in unix
• [ :digit:][0-9]
• [:alpha:]a-z A-Z
• [:Alnum:] [A-Z a-z 0-9]
● Lexical Analysis
● Finding Patterns in Text
● Grep utility in unix.
Algebraic Laws of RE
● COMMUTATIVITY
● ASSOCIATIVITY
● IDENTITIES
● ANNIHILATOR
● DISTRIBUTIVE
● IDEMPOTENT
COMMUTATIVITY
● For regular expressions, we have:
● L + M = M + L
● Commutative law for union: we may make the union of two
languages in either order
● Clearly the law L.M = M.L is FALSE (Commutative law for
concatenation)
ASSOCIATIVITY
● (L + M) + N = L + ( M + N) Associative law for union: we
may take the union of three languages either by taking the
union of the first two initially, or taking the union of the last
two initially. Together with the commutative law we can take
the union of any collection of languages with any order and
grouping, and the result will be the same. Intuitively, a string
is in L1 ∪ L2 . . . ∪ Lk iff it is in one or more of the Li s.
● (L.M).N = L.(M.N) Associative law for concatenation: we
can concatenate three-languages by concatenating either the
first two or the last two initially
IDENTITIES
● An identity for an operator is a value that when the
operator is applied to the identity and some other value, the
result is the other value.
● ∅ + L = L + ∅ = L
● e.L = L.e = L
ANNIHILATOR
● An annihilator for an operator is value that when the
operator is applied to the annihilator and some other
value, the result is the annihilator.
● ∅.L = L. ∅ = ∅
DISTRIBUTIVE
● For regular expressions we have:
● Left distributivity: L.(M + N) = LM + LN
● Right distributivity: (M + N).L = ML + NL
IDEMPOTENT
● An operator is idempotent if the result of applying it to two
of
● the same values as arguments is that value.
● Idempotent Law for union:
● L + L = L
● If we take the union of two identical expressions, we can
replace them by one copy of the expression.
Identities Related to Regular Expressions l={0,1}{l2}
Given R, P, L, Q as regular expressions, the following
identities hold −
• ∅* = ε
• ε* = ε
• RR* = R*R=R+
• R*R* = R*
• (R*)* = R*
• (PQ)*P =P(QP)*
• (a+b)* = (a*b*)* = (a*+b*)* = (a+b*)* = a*(ba*)*
• R + ∅ = ∅ + R = R (The identity for union)
• R ε = ε R = R (The identity for concatenation)
• ∅ L = L ∅ = ∅ (The annihilator for concatenation)
• R + R = R (Idempotent law)
• L (M + N) = LM + LN (Left distributive law)
• (M + N) L = ML + NL (Right distributive law)
• ε + RR* = ε + R*R = R*
Arden’s Theorem
In order to find out a regular expression of a Finite Automaton, we
use Arden’s Theorem along with the properties of regular
expressions.
Statement −
Let P and Q be two regular expressions.
If P does not contain null string, then R = Q + RP has a unique
solution that is R = QP*
Proof −
R = Q + (Q + RP)P [After putting the value R = Q + RP]
= Q + QP + RPP
When we put the value of R recursively again and again, we get the
following equation −
R = Q + QP + QP2 + QP3…..
R = Q (ε + P + P2 + P3 + …. )
R = QP* [As P* represents (ε + P + P2 + P3 + ….) ]
Hence, proved.
FA & RE
From DFA to RE
● Arden’s Theorem Steps:
● 1) Build RE for each state
● 2) Solve final states equations first
● State Elimination Method Steps
● 1) The start state of DFA must not have any incoming edges. If there exists any
incoming edge to start state ,then create a new state having no income edges.
● 2)There must be only one final state in DFA, If DFA contain more final states,
then create a new final state and all other final states to non final states
● 3) The final state of DFA doesn’t contain any out going edges, then create new
final state without any out going edges
● 4) Now start elimination intermediate states in any order. Finally we have
initial state going to final state.
● Question 1:
Question 2
RE to FA
Limitation of FA
● It have finite number of states.
● Finite amount of memory so doesn’t remember
previous state outcome.
● So in above scenarios we use pumping lemma.
Pumping Lemma
Theorem
Let L be a regular language. Then there exists a
constant ‘n’ such that for every string w in L −
|w| ≥ n
We can break w into three strings, w = xyz, such that −
• |y| = ε
• |xy| ≤ n
• For all k ≥ 0, the string xykz is also in L.
Applications of Pumping Lemma
Pumping Lemma is to be applied to show that certain
languages are not regular. It should never be used to show a
language is regular.
• If L is regular, it satisfies Pumping Lemma.

• If L does not satisfy Pumping Lemma, it is non-regular.

Applications of PL
Properties of Regular Sets/ Closure Properties
Property 1. The union of two regular set is regular.
Proof −
Let us take two regular expressions
RE1 = a(aa)* and RE2 = (aa)*
So, L1 = {a, aaa, aaaaa,.....} (Strings of odd length
excluding Null)
and L2 ={ ε, aa, aaaa, aaaaaa,.......} (Strings of even
length including Null)
L1 ∪ L2 = { ε, a, aa, aaa, aaaa, aaaaa, aaaaaa,.......}
(Strings of all possible lengths including Null)
RE (L1 ∪ L2) = a* (which is a regular expression itself)
Hence, proved.
Property 2. The intersection of two regular set is regular.
Proof −
Let us take two regular expressions
RE1 = a(a*) and RE2 = (aa)*
So, L1 = { a,aa, aaa, aaaa, ....} (Strings of all possible lengths
excluding Null)
L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length
including Null)
L1 ∩ L2 = { aa, aaaa, aaaaaa,.......} (Strings of even length
excluding Null)
RE (L1 ∩ L2) = aa(aa)* which is a regular expression itself.
Hence, proved.
Property 3. The complement of a regular set is regular.
Proof −
Let us take a regular expression −
RE = (aa)*
So, L = {ε, aa, aaaa, aaaaaa, .......} (Strings of even length
including Null)
Complement of L is all the strings that is not in L.
So, L’ = {a, aaa, aaaaa, .....} (Strings of odd length
excluding Null)
RE (L’) = a(aa)* which is a regular expression itself.
Hence, proved.
Property 4. The difference of two regular set is regular.
Proof −
Let us take two regular expressions −
RE1 = a (a*) and RE2 = (aa)*
So, L1 = {a, aa, aaa, aaaa, ....} (Strings of all possible
lengths excluding Null)
L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length
including Null)
L1 – L2 = {a, aaa, aaaaa, aaaaaaa, ....}
(Strings of all odd lengths excluding Null)
RE (L1 – L2) = a (aa)* which is a regular expression.
Hence, proved.
Property 5. The reversal of a regular set is regular.
Proof −
We have to prove LR is also regular if L is a regular
set.
Let, L = {01, 10, 11, 10}
RE (L) = 01 + 10 + 11 + 10
LR = {10, 01, 11, 01}
RE (LR) = 01 + 10 + 11 + 10 which is regular
Hence, proved.
Property 6. The closure of a regular set is regular.
Proof −
If L = {a, aaa, aaaaa, .......} (Strings of odd length
excluding Null)
i.e., RE (L) = a (aa)*
L* = {a, aa, aaa, aaaa , aaaaa,……………} (Strings of
all lengths excluding Null)
RE (L*) = a (a)*
Hence, proved.
Property 7. The concatenation of two regular sets is
regular.
Proof −
Let RE1 = (0+1)*0 and RE2 = 01(0+1)*
Here, L1 = {0, 00, 10, 000, 010, ......} (Set of strings
ending in 0)
and L2 = {01, 010,011,.....} (Set of strings beginning
with 01)
Then, L1 L2 =
{001,0010,0011,0001,00010,00011,1001,10010,..........
...}
Set of strings containing 001 as a substring which can
be represented by an RE − (0 + 1)*001(0 + 1)*
Hence, proved.
Decision Properties of Regular Languages
● Membership
L={ends with 00|{0,1}}
w={1100,00,100,0100,00100….}
● Emptiness
● Equivalence
Equivalence and Minimisation of Automata
● Refer unit 1 ppt.
● Slides 42-50

More Related Content

What's hot

Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
VenkataRaoS1
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
Maulik Togadiya
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
deepinderbedi
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5
Srimatre K
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
Tsegazeab Asgedom
 
Flat unit 1
Flat unit 1Flat unit 1
Flat unit 1
VenkataRaoS1
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
Rajendran
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Shiraz316
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
SOMNATHMORE2
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
Marina Santini
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
Zahid Parvez
 
1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions
Sampath Kumar S
 
linear probing
linear probinglinear probing
linear probing
rajshreemuthiah
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTES
suthi
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
valuebound
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
Akhil Kaushik
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
 

What's hot (20)

Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Flat unit 1
Flat unit 1Flat unit 1
Flat unit 1
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deep
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
 
1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions1.8. equivalence of finite automaton and regular expressions
1.8. equivalence of finite automaton and regular expressions
 
linear probing
linear probinglinear probing
linear probing
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTES
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 

Similar to Formal Languages and Automata Theory unit 2

Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
VenkataRaoS1
 
regular expression
regular expressionregular expression
regular expression
RohitKumar596173
 
Unit ii
Unit iiUnit ii
Unit ii
TPLatchoumi
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
parmeet834
 
UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
karthikeyan Muthusamy
 
Regular expression
Regular expressionRegular expression
Regular expression
MONIRUL ISLAM
 
re1.ppt
re1.pptre1.ppt
re1.ppt
PEzhumalai
 
Re1 (3)
Re1 (3)Re1 (3)
Re1 (3)
pepe3059
 
re1.ppt
re1.pptre1.ppt
RegularExpressions-theory of computation and formal language
RegularExpressions-theory of computation and formal languageRegularExpressions-theory of computation and formal language
RegularExpressions-theory of computation and formal language
mohdfareeduddin5
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Rushabh2428
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
viswanath kani
 
RegularExpressions.pdf
RegularExpressions.pdfRegularExpressions.pdf
RegularExpressions.pdf
ImranBhatti58
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
Ch3.ppt
Ch3.pptCh3.ppt
Ch3.ppt
MDSayem35
 
Automata
AutomataAutomata
Automata
Gaditek
 
Automata
AutomataAutomata
Automata
Gaditek
 
unit 2 part b.docx
unit 2 part b.docxunit 2 part b.docx
unit 2 part b.docx
karthikeyan Muthusamy
 

Similar to Formal Languages and Automata Theory unit 2 (20)

Flat unit 2
Flat unit 2Flat unit 2
Flat unit 2
 
FLAT.pdf
FLAT.pdfFLAT.pdf
FLAT.pdf
 
regular expression
regular expressionregular expression
regular expression
 
Unit ii
Unit iiUnit ii
Unit ii
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
 
Regular expression
Regular expressionRegular expression
Regular expression
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
Re1 (3)
Re1 (3)Re1 (3)
Re1 (3)
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
RegularExpressions-theory of computation and formal language
RegularExpressions-theory of computation and formal languageRegularExpressions-theory of computation and formal language
RegularExpressions-theory of computation and formal language
 
re1.ppt
re1.pptre1.ppt
re1.ppt
 
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
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
 
RegularExpressions.pdf
RegularExpressions.pdfRegularExpressions.pdf
RegularExpressions.pdf
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
Ch3.ppt
Ch3.pptCh3.ppt
Ch3.ppt
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
unit 2 part b.docx
unit 2 part b.docxunit 2 part b.docx
unit 2 part b.docx
 

More from Srimatre K

ML_ Unit 2_Part_B
ML_ Unit 2_Part_BML_ Unit 2_Part_B
ML_ Unit 2_Part_B
Srimatre K
 
ML_Unit_2_Part_A
ML_Unit_2_Part_AML_Unit_2_Part_A
ML_Unit_2_Part_A
Srimatre K
 
ML_Unit_1_Part_C
ML_Unit_1_Part_CML_Unit_1_Part_C
ML_Unit_1_Part_C
Srimatre K
 
ML_Unit_1_Part_B
ML_Unit_1_Part_BML_Unit_1_Part_B
ML_Unit_1_Part_B
Srimatre K
 
Internet of things unit-1
Internet of things unit-1Internet of things unit-1
Internet of things unit-1
Srimatre K
 
ML_ Unit_1_PART_A
ML_ Unit_1_PART_AML_ Unit_1_PART_A
ML_ Unit_1_PART_A
Srimatre K
 
Formal Languages and Automata Theory unit 4
Formal Languages and Automata Theory unit 4Formal Languages and Automata Theory unit 4
Formal Languages and Automata Theory unit 4
Srimatre K
 

More from Srimatre K (7)

ML_ Unit 2_Part_B
ML_ Unit 2_Part_BML_ Unit 2_Part_B
ML_ Unit 2_Part_B
 
ML_Unit_2_Part_A
ML_Unit_2_Part_AML_Unit_2_Part_A
ML_Unit_2_Part_A
 
ML_Unit_1_Part_C
ML_Unit_1_Part_CML_Unit_1_Part_C
ML_Unit_1_Part_C
 
ML_Unit_1_Part_B
ML_Unit_1_Part_BML_Unit_1_Part_B
ML_Unit_1_Part_B
 
Internet of things unit-1
Internet of things unit-1Internet of things unit-1
Internet of things unit-1
 
ML_ Unit_1_PART_A
ML_ Unit_1_PART_AML_ Unit_1_PART_A
ML_ Unit_1_PART_A
 
Formal Languages and Automata Theory unit 4
Formal Languages and Automata Theory unit 4Formal Languages and Automata Theory unit 4
Formal Languages and Automata Theory unit 4
 

Recently uploaded

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 

Formal Languages and Automata Theory unit 2

  • 1. UNIT-2 REGULAR EXPRESSION K LAKSHMI SRVANI ASST PROFESSOR
  • 2. SYLLABUS Regular Expressions: Finite Automata and Regular Expressions, Applications of Regular Expressions, Algebraic Laws for Regular Expressions, Conversion of Finite Automata to Regular Expressions. Pumping Lemma for Regular Languages, Statement of the pumping lemma, Applications of the Pumping Lemma. Closure Properties of Regular Languages: Closure properties of Regular languages, Decision Properties of Regular Languages, Equivalence and Minimization of Automata.
  • 3. Regular Expressions. ● Regular expressions are used for representing certain sets of strings in algebraic fashion. ● Any terminal symbol belongs to Σ including ɸ,ɛ are RE ● The union of 2 RE is also RE ● The Concatenation of 2 RE is also RE ● The iteration or closure of RE is also RE
  • 4. Regular Expressions Regular Set (0 + 10*) L = { 0, 1, 10, 100, 1000, 10000, … } (0*10*) L = {1, 01, 10, 010, 0010, …} (0 + ε)(1 + ε) L = {ε, 0, 1, 01} (a+b)* Set of strings of a’s and b’s of any length including the null string. So L = { ε, a, b, aa , ab , bb , ba, aaa…….} (11)* Set consisting of even number of 1’s including empty string, So L= {ε, 11, 1111, 111111, ……….} (0+1)*011(0+1)* Sub string 011
  • 5. Operators of RE Operators used in regular expressions include: • Union: If R1 and R2 are regular expressions, then R1 | R2 (also written as R1 U R2 or R1 + R2) is also a regular expression. L(R1|R2) = L(R1) U L(R2) or L(R1+R2)
 
 • Concatenation: If R1 and R2 are regular expressions, then R1R2 (also written as R1.R2) is also a regular expression. L(R1R2) = L(R1) concatenated with L(R2).
 
 • Kleene closure: If R1 is a regular expression, then R1* (the Kleene closure of R1) is also a regular expression. L(R1*) = epsilon U L(R1) U L(R1R1) U L(R1R1R1) U ...

  • 6. Precedence ● Closure > Concatenation > Union ● (01*+1)
  • 7. Applications of RE ● RE in unix • [ :digit:][0-9] • [:alpha:]a-z A-Z • [:Alnum:] [A-Z a-z 0-9] ● Lexical Analysis ● Finding Patterns in Text ● Grep utility in unix.
  • 8. Algebraic Laws of RE ● COMMUTATIVITY ● ASSOCIATIVITY ● IDENTITIES ● ANNIHILATOR ● DISTRIBUTIVE ● IDEMPOTENT
  • 9. COMMUTATIVITY ● For regular expressions, we have: ● L + M = M + L ● Commutative law for union: we may make the union of two languages in either order ● Clearly the law L.M = M.L is FALSE (Commutative law for concatenation)
  • 10. ASSOCIATIVITY ● (L + M) + N = L + ( M + N) Associative law for union: we may take the union of three languages either by taking the union of the first two initially, or taking the union of the last two initially. Together with the commutative law we can take the union of any collection of languages with any order and grouping, and the result will be the same. Intuitively, a string is in L1 ∪ L2 . . . ∪ Lk iff it is in one or more of the Li s. ● (L.M).N = L.(M.N) Associative law for concatenation: we can concatenate three-languages by concatenating either the first two or the last two initially
  • 11. IDENTITIES ● An identity for an operator is a value that when the operator is applied to the identity and some other value, the result is the other value. ● ∅ + L = L + ∅ = L ● e.L = L.e = L
  • 12. ANNIHILATOR ● An annihilator for an operator is value that when the operator is applied to the annihilator and some other value, the result is the annihilator. ● ∅.L = L. ∅ = ∅
  • 13. DISTRIBUTIVE ● For regular expressions we have: ● Left distributivity: L.(M + N) = LM + LN ● Right distributivity: (M + N).L = ML + NL
  • 14. IDEMPOTENT ● An operator is idempotent if the result of applying it to two of ● the same values as arguments is that value. ● Idempotent Law for union: ● L + L = L ● If we take the union of two identical expressions, we can replace them by one copy of the expression.
  • 15. Identities Related to Regular Expressions l={0,1}{l2} Given R, P, L, Q as regular expressions, the following identities hold − • ∅* = ε • ε* = ε • RR* = R*R=R+ • R*R* = R* • (R*)* = R* • (PQ)*P =P(QP)* • (a+b)* = (a*b*)* = (a*+b*)* = (a+b*)* = a*(ba*)* • R + ∅ = ∅ + R = R (The identity for union) • R ε = ε R = R (The identity for concatenation) • ∅ L = L ∅ = ∅ (The annihilator for concatenation) • R + R = R (Idempotent law) • L (M + N) = LM + LN (Left distributive law) • (M + N) L = ML + NL (Right distributive law) • ε + RR* = ε + R*R = R*
  • 16. Arden’s Theorem In order to find out a regular expression of a Finite Automaton, we use Arden’s Theorem along with the properties of regular expressions. Statement − Let P and Q be two regular expressions. If P does not contain null string, then R = Q + RP has a unique solution that is R = QP* Proof − R = Q + (Q + RP)P [After putting the value R = Q + RP] = Q + QP + RPP When we put the value of R recursively again and again, we get the following equation − R = Q + QP + QP2 + QP3….. R = Q (ε + P + P2 + P3 + …. ) R = QP* [As P* represents (ε + P + P2 + P3 + ….) ] Hence, proved.
  • 18. From DFA to RE ● Arden’s Theorem Steps: ● 1) Build RE for each state ● 2) Solve final states equations first ● State Elimination Method Steps ● 1) The start state of DFA must not have any incoming edges. If there exists any incoming edge to start state ,then create a new state having no income edges. ● 2)There must be only one final state in DFA, If DFA contain more final states, then create a new final state and all other final states to non final states ● 3) The final state of DFA doesn’t contain any out going edges, then create new final state without any out going edges ● 4) Now start elimination intermediate states in any order. Finally we have initial state going to final state.
  • 22. Limitation of FA ● It have finite number of states. ● Finite amount of memory so doesn’t remember previous state outcome. ● So in above scenarios we use pumping lemma.
  • 23. Pumping Lemma Theorem Let L be a regular language. Then there exists a constant ‘n’ such that for every string w in L − |w| ≥ n We can break w into three strings, w = xyz, such that − • |y| = ε • |xy| ≤ n • For all k ≥ 0, the string xykz is also in L. Applications of Pumping Lemma Pumping Lemma is to be applied to show that certain languages are not regular. It should never be used to show a language is regular. • If L is regular, it satisfies Pumping Lemma.
 • If L does not satisfy Pumping Lemma, it is non-regular.

  • 25. Properties of Regular Sets/ Closure Properties Property 1. The union of two regular set is regular. Proof − Let us take two regular expressions RE1 = a(aa)* and RE2 = (aa)* So, L1 = {a, aaa, aaaaa,.....} (Strings of odd length excluding Null) and L2 ={ ε, aa, aaaa, aaaaaa,.......} (Strings of even length including Null) L1 ∪ L2 = { ε, a, aa, aaa, aaaa, aaaaa, aaaaaa,.......} (Strings of all possible lengths including Null) RE (L1 ∪ L2) = a* (which is a regular expression itself) Hence, proved.
  • 26. Property 2. The intersection of two regular set is regular. Proof − Let us take two regular expressions RE1 = a(a*) and RE2 = (aa)* So, L1 = { a,aa, aaa, aaaa, ....} (Strings of all possible lengths excluding Null) L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length including Null) L1 ∩ L2 = { aa, aaaa, aaaaaa,.......} (Strings of even length excluding Null) RE (L1 ∩ L2) = aa(aa)* which is a regular expression itself. Hence, proved.
  • 27. Property 3. The complement of a regular set is regular. Proof − Let us take a regular expression − RE = (aa)* So, L = {ε, aa, aaaa, aaaaaa, .......} (Strings of even length including Null) Complement of L is all the strings that is not in L. So, L’ = {a, aaa, aaaaa, .....} (Strings of odd length excluding Null) RE (L’) = a(aa)* which is a regular expression itself. Hence, proved.
  • 28. Property 4. The difference of two regular set is regular. Proof − Let us take two regular expressions − RE1 = a (a*) and RE2 = (aa)* So, L1 = {a, aa, aaa, aaaa, ....} (Strings of all possible lengths excluding Null) L2 = { ε, aa, aaaa, aaaaaa,.......} (Strings of even length including Null) L1 – L2 = {a, aaa, aaaaa, aaaaaaa, ....} (Strings of all odd lengths excluding Null) RE (L1 – L2) = a (aa)* which is a regular expression. Hence, proved.
  • 29. Property 5. The reversal of a regular set is regular. Proof − We have to prove LR is also regular if L is a regular set. Let, L = {01, 10, 11, 10} RE (L) = 01 + 10 + 11 + 10 LR = {10, 01, 11, 01} RE (LR) = 01 + 10 + 11 + 10 which is regular Hence, proved.
  • 30. Property 6. The closure of a regular set is regular. Proof − If L = {a, aaa, aaaaa, .......} (Strings of odd length excluding Null) i.e., RE (L) = a (aa)* L* = {a, aa, aaa, aaaa , aaaaa,……………} (Strings of all lengths excluding Null) RE (L*) = a (a)* Hence, proved.
  • 31. Property 7. The concatenation of two regular sets is regular. Proof − Let RE1 = (0+1)*0 and RE2 = 01(0+1)* Here, L1 = {0, 00, 10, 000, 010, ......} (Set of strings ending in 0) and L2 = {01, 010,011,.....} (Set of strings beginning with 01) Then, L1 L2 = {001,0010,0011,0001,00010,00011,1001,10010,.......... ...} Set of strings containing 001 as a substring which can be represented by an RE − (0 + 1)*001(0 + 1)* Hence, proved.
  • 32. Decision Properties of Regular Languages ● Membership L={ends with 00|{0,1}} w={1100,00,100,0100,00100….} ● Emptiness ● Equivalence
  • 33. Equivalence and Minimisation of Automata ● Refer unit 1 ppt. ● Slides 42-50