SlideShare a Scribd company logo
THEORY OF AUTOMATAAND
FORMAL LANGUAGES
UNIT-2
ABHIMANYU MISHRA
ASSISTANT PROF.(CSE)
JETGI
Abhimanyu Mishra(CSE) JETGI12/31/2016 1
A regular expression (sometimes called a rational expression)is,
in computer science and formal languages theory, a sequence
of characters that define a search pattern. usually this pattern is then used
by in string searching algorithm "find" or "find and replace" operations on
strings.
2. REGULAR EXPRESSION AND LANGUAGES
Abhimanyu Mishra(CSE) JETGI12/31/2016 2
2.1 Definition of Regular Expression:
The set of regular expression of defined by the following rules:
(i) Every letter of ∑ can be made into regular expression, null string,€ itself is
a regular expression.
(ii) If r1 and r2 are regular expression, then
(a) (r1) (b) r1r2
(c) r1+r2 (d) r1
*
(e) r1
+ are also regular expression
(iii) Nothing else is regular expression.
12/31/2016 Abhimanyu Mishra(CSE) JETGI 3
2.1.1 Building Regular Expression
(i) The constants ϵ(null string) and ɸ(empty set) are regular expression,
denote the languages {ϵ} and ɸ, respectively.
That is, L(ϵ) = {ϵ} , and L(ɸ)= ɸ.
(ii) If a is any symbol, then a is regular expression. This expression denotes
the language {a}. That is L(a)={a}.
(iii) A variable, usually capitalized and such as L is a variable, representing
any language.
12/31/2016 Abhimanyu Mishra(CSE) JETGI 4
2.2 Construction of FA for Regular Expression
• The Expression is r+s for some smaller expression r and s. The following
automation serves, where R is automation for r and S is automation for s.
That is, starting at the new start state, We can go to the start state of either
the automation for r or the automation for S
So L(r) and L(s)
ϵ ϵ
Start
ϵ ϵ
12/31/2016 Abhimanyu Mishra(CSE) JETGI 5
R
S
2.The expression rs for some smaller expression r and s. The
automation for the concatenation is ………….
Start ϵ ϵ ϵ
3. The expression is r* for some smaller expression r. Then we use
automation of ……….
ϵ
Start ϵ ϵ
ϵ
12/31/2016 Abhimanyu Mishra(CSE) JETGI 6
R S
R
Example 1: Find the automation for regular expression a.(a+b)*.b.b
Solution:
The basic regular expression involved are a and b,we start with automation for
a and automation for b. Since brackets are evaluated first.(a+b).
ϵ a ϵ
Start
ϵ ϵ
b
12/31/2016 Abhimanyu Mishra(CSE) JETGI 7
Step 2: Since closure is required to take next, we construct automation for (a+b)*
using automation for (a+b) ……..
ϵ
a
ϵ ϵ
Start ϵ ϵ
ϵ b ϵ
ϵ
12/31/2016 Abhimanyu Mishra(CSE) JETGI 8
Step 3: Next we construct the automation for a.(a+b)* as………
ϵ a ϵ ϵ
Star a ϵ ϵ
ϵ b ϵ ϵ
12/31/2016 Abhimanyu Mishra(CSE) JETGI 9
Step 4: Next we construct the automation for a.(a+b)*.b by using automation
ϵ ϵ a ϵ
Start a ϵ ϵ b
ϵ b ϵ
ϵ
12/31/2016 Abhimanyu Mishra(CSE) JETGI 10
Step 5: Now finally we can construct automation for a.(a+b)*.b.b
ϵ ϵ a ϵ
Start a ϵ b b
ϵ ϵ
ϵ b ϵ
12/31/2016 Abhimanyu Mishra(CSE) JETGI 11
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
(I) R = Q + RP has a unique solution,
(ii) R = QP*
12/31/2016 Abhimanyu Mishra(CSE) JETGI 12
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 + ….) ]
proved.
12/31/2016 Abhimanyu Mishra(CSE) JETGI 13
Assumptions for Applying Arden’s Theorem −
The transition diagram must not have NULL transitions
It must have only one initial state:
Method
Step 1 − Create equations as the following form for all the states of the DFA
having n states with initial state q1.
q1 = q1R11 + q2R21 + … + qnRn1 + ϵ
q2 = q1R12 + q2R22 + … + qnRn2
…………………………………………………………….
…………………………………………………………….
qn = q1R1n + q2R2n + … + qnRnn
Rij represents the set of labels of edges from qi to qj, if no such edge exists,
then Rij = ɸ
Step 2 − Solve these equations to get the equation for the final state in terms of
Rij
12/31/2016 Abhimanyu Mishra(CSE) JETGI 14
Example 1: Construct a regular expression corresponding to the
automata given below −
b
a
b
b a
a
12/31/2016 Abhimanyu Mishra(CSE) JETGI 15
q2
q1
q3
Solution:
Here the initial state is q2 and the final state is q1.
The equations for the three states q1, q2, q3
q1 = q1a + q3a + ϵ (ϵ move is because q1 is the initial state)
q2 = q1b + q2b + q3b
q3 = q2a
Now, we will solve these three equations −
q2 = q1b + q2b + q3b
= q1b + q2b + (q2a)b (Substituting value of q3)
= q1b + q2(b + ab)
= q1b (b + ab)* (Applying Arden’s Theorem)
12/31/2016 Abhimanyu Mishra(CSE) JETGI 16
q1 = q1a + q3a + ϵ
= q1a + q2aa + ϵ (Substituting value of q3)
= q1a + q1b(b + ab*)aa + ϵ (Substituting value of q2)
= q1(a + b(b + ab)*aa) + ϵ
= ϵ (a+ b(b + ab)*aa)*
= (a + b(b + ab)*aa)*
Hence, the regular expression is (a + b(b + ab)*aa)*.
12/31/2016 Abhimanyu Mishra(CSE) JETGI 17
Solve This Problem? Construct the regular expression
0 0,1
1 1
0
12/31/2016 Abhimanyu Mishra(CSE) JETGI 18
q1
q2
q3
Construction of an FA from an RE
We can use Thompson's Construction to find out a Finite Automaton from a
Regular Expression. We will moderate the regular expression into minimum
regular expressions and converting these to NFA and finally to DFA.
Case 1 − For a regular expression ‘a’, we can construct the following FA
Finite Automata for RE = a
Start a
12/31/2016 Abhimanyu Mishra(CSE) JETGI 19
q1 qf
Case 2 − For a regular expression ‘ab’, we can construct the following FA −
Start a b
Case 3 − For a regular expression (a+b), we can construct the following FA −
Start a
b
Case 4 − For a regular expression (a+b)*, we can construct the following FA −
a,b
Start
12/31/2016 Abhimanyu Mishra(CSE) JETGI 20
qfq1 q2
q1 qf
qf
Example:-Convert the following RE into its equivalent DFA − 1 (0 + 1)* 0
0,1
start 1 ϵ ϵ 0
12/31/2016 Abhimanyu Mishra(CSE) JETGI 21
q0 q1 q2 q3 qf
Pumping Lemma for Regular Languages
Theorem
Let L be a regular language. Then there exists a constant ‘c’ such that
for every string w in L −
|w| ≥ c
We can break w into three strings, w = xyz, such that −
|y| > 0
|xy| ≤ c
For all k ≥ 0, the string xykz is also in L.
12/31/2016 Abhimanyu Mishra(CSE) JETGI 22
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 is non-regular, it does not satisfy Pumping Lemma.
Method to prove that a language L is not regular
At first, we have to assume that L is regular.
So, the pumping lemma should hold for L.
Use the pumping lemma to obtain a contradiction −
12/31/2016 Abhimanyu Mishra(CSE) JETGI 23
Use the pumping lemma to obtain a contradiction −
Select w such that |w| ≥ c
Select y such that |y| ≥ 1
Select x such that |xy| ≤ c
Assign the remaining string to z.
Select k such that the resulting string is not in L.
Hence L is not regular.
12/31/2016 Abhimanyu Mishra(CSE) JETGI 24
Application of the Pumping Lemma
(i) Select the language L ,You wish to prove non-regular.
(ii) The “adversary” pinks n, the constant mentioned in the pumping lemma,
Once the adversary has picked n, he may not change it.
(iii) Select a string z in L. Your choice may depend implicitly on the of n
chosen.
(iv) The adversary breaks z into u, v and w, subject to the constants that
|uv|<=n and |v|>=1
(v) You achieve a contradiction to the pumping leema by showing, for any
u,v and determined by the adversary that there exit i for which uviw is not
in L.it May then concluded and L is not regular. Your selection of
pumping leema on n,u,v and w.
12/31/2016 Abhimanyu Mishra(CSE) JETGI 25
Example: Prove that language L =(anbn for n= 0,1,2,3……} is not regular
Solution:
Case 1 If middle part y is made off entirely of a’s,as
x aaaaaaa….z
If we jump it as xyyz,xyyyz,then number of a”s increases,but in language {(anbn for n=
0,1,2,3,……} a’s and b’s are equal so it os not allowed.
Case 2 If middle part y is made off entirely of b’s as
x bbbbbbb……z
For the same reason, it is also not allowed.
Case 3 y part is made of some positive number of a’s and some number of b’s. This would
mean that y contain the substring ab
x……aaaaaaaabbbbbbbbbbb…………..z
Then xyyz would have two copies of the substring ab.But every world in L contains
substring ab exactly once.
This proves that the pumping lemma cannot apply to L and therefore L is not regular
12/31/2016 Abhimanyu Mishra(CSE) JETGI 26
Q1.Prove That L={0n1m2n , n,m>=0} is not regular.
Q2. Prove that language L ={0n |n is perfect square} is not regular.
Q3. Prove that language L ={0n |n is perfect cube} is not regular.
12/31/2016 Abhimanyu Mishra(CSE) JETGI 27
AUTOMATA WITH OUTPUT
Here we are using two Machines for finding the Finite Automata Output
(i) Moore Machine
(ii) Mealy Machine
12/31/2016 Abhimanyu Mishra(CSE) JETGI 28
Moore Machine
(i) Moore Machine
Moore machine is an FSM whose outputs depend on only the present
state.
A Moore machine can be described by a 6 tuple (Q, ∑, ∆, δ, ƛ’, q0)
where −
Q is a finite set of states.
∑ is a finite set of symbols called the input alphabet.
∆ is a finite set of symbols called the output alphabet.
δ is the input transition function where δ: Q × Σ → Q
ƛ’ is the output transition function where ƛ’ : Q × Σ → ∆
q0 is the initial state from where any input is processed (q0 ∈ Q).
12/31/2016 Abhimanyu Mishra(CSE) JETGI 29
Representation of Moore Machine:( Transition Table)
Present State Next state at input Output
a=0 a=1
q0 q3 q1 0
q1 q1 q2 1
q2 q2 q3 0
q3 q3 q0 0
12/31/2016 Abhimanyu Mishra(CSE) JETGI 30
Representation of Moore Machine:( Transition Diagram)
0
0
Start 1 1
0
1
0 1 0
0 1 0
12/31/2016 Abhimanyu Mishra(CSE) JETGI 31
q3
q0
q2
q1
Mealy Machine
A Mealy Machine is an FSM whose output depends on the present state as
well as the present input.
It can be described by a 6 tuple (Q, ∑, ∆, δ, ƛ’, q0) where −
Q is a finite set of states.
∑ is a finite set of symbols called the input alphabet.
∆ is a finite set of symbols called the output alphabet.
δ is the input transition function where δ: Q × ∑ → Q
ƛ’ is the output transition function where X: Q → ƛ’,
q0 is the initial state from where any input is processed (q0 ∈ Q).
12/31/2016 Abhimanyu Mishra(CSE) JETGI 32
Representation of Mealy Machine:( Transition Table)
Present State For input a=0 for input a=1
State Output State Output
q1 q3 0 q2 0
q2 q1 1 q4 0
q3 q2 1 q1 1
q4 q4 1 q3 0
12/31/2016 Abhimanyu Mishra(CSE) JETGI 33
Representation of Mealy Machine:( Transition Diagram)
Start 0/1
1/0
1/1 0/0 0/1 1/0
0/1
1/0
12/31/2016 Abhimanyu Mishra(CSE) JETGI 34
q1
q3 q4
q2
Mealy Machine vs. Moore Machine
12/31/2016 Abhimanyu Mishra(CSE) JETGI 35
Mealy Machine Moore Machine
Output depends both upon present
state and present input.
Output depends only upon the
present state.
Generally, it has fewer states than
Moore Machine.
Generally, it has more states than
Mealy Machine.
Output changes at the clock edges. Input change can cause change in
output change as soon as logic is
done.
Mealy machines react faster to
inputs.
In Moore machines, more logic is
needed to decode the outputs since
it has more circuit delays.

More Related Content

What's hot (20)

PPTX
Context free grammar
Mohammad Ilyas Malik
 
PPTX
Theory of Automata and formal languages unit 1
Abhimanyu Mishra
 
PPTX
3.5 equivalence of pushdown automata and cfl
Sampath Kumar S
 
PPT
Divide and conquer
Dr Shashikant Athawale
 
PPTX
Automata theory - Push Down Automata (PDA)
Akila Krishnamoorthy
 
PPTX
Asymptotic Notations
Rishabh Soni
 
PPTX
Theory of Automata and formal languages Unit 3
Abhimanyu Mishra
 
PPTX
Job sequencing with deadlines(with example)
Vrinda Sheela
 
PPTX
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
PPT
0/1 knapsack
Amin Omi
 
PPTX
3.4 deterministic pda
Sampath Kumar S
 
PPTX
Algorithms Design Patterns
Ashwin Shiv
 
PPTX
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Ashish Duggal
 
PPT
First order logic
Rushdi Shams
 
PPT
Intro automata theory
Rajendran
 
PDF
Approximation Algorithms
Nicolas Bettenburg
 
PPTX
Ambiguous & Unambiguous Grammar
MdImamHasan1
 
PDF
Formal Languages and Automata Theory Unit 1
Srimatre K
 
PPTX
Turing machine by_deep
Deepjyoti Kalita
 
PPTX
Regular expressions
Ratnakar Mikkili
 
Context free grammar
Mohammad Ilyas Malik
 
Theory of Automata and formal languages unit 1
Abhimanyu Mishra
 
3.5 equivalence of pushdown automata and cfl
Sampath Kumar S
 
Divide and conquer
Dr Shashikant Athawale
 
Automata theory - Push Down Automata (PDA)
Akila Krishnamoorthy
 
Asymptotic Notations
Rishabh Soni
 
Theory of Automata and formal languages Unit 3
Abhimanyu Mishra
 
Job sequencing with deadlines(with example)
Vrinda Sheela
 
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
0/1 knapsack
Amin Omi
 
3.4 deterministic pda
Sampath Kumar S
 
Algorithms Design Patterns
Ashwin Shiv
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Ashish Duggal
 
First order logic
Rushdi Shams
 
Intro automata theory
Rajendran
 
Approximation Algorithms
Nicolas Bettenburg
 
Ambiguous & Unambiguous Grammar
MdImamHasan1
 
Formal Languages and Automata Theory Unit 1
Srimatre K
 
Turing machine by_deep
Deepjyoti Kalita
 
Regular expressions
Ratnakar Mikkili
 

Viewers also liked (20)

PDF
Context free langauges
sudhir sharma
 
PPTX
Normal forms cfg
Rajendran
 
PPTX
Context free grammars
Shiraz316
 
PDF
L3 cfg
Self-employed
 
PPT
Context free languages
Jahurul Islam
 
PPT
Context free grammars
Ronak Thakkar
 
PPTX
Lect 5 2d clipping
majicyoung
 
PPTX
CNF & Leftmost Derivation - Theory of Computation
Drishti Bhalla
 
PPT
06 clipping
Ketan Jani
 
PDF
Formal language & automata theory
NYversity
 
PDF
Fafl notes [2010] (sjbit)
Siddharaj Junnarkar
 
PPT
Os6
issbp
 
PPT
Os4
issbp
 
PPT
Os5 2
issbp
 
PPT
Os2
issbp
 
PPT
Os6 2
issbp
 
PDF
Lecture 7: Definite Clause Grammars
CS, NcState
 
PPT
Os4 2
issbp
 
PPT
Ch11 input output systems
issbp
 
PPT
Class5
issbp
 
Context free langauges
sudhir sharma
 
Normal forms cfg
Rajendran
 
Context free grammars
Shiraz316
 
Context free languages
Jahurul Islam
 
Context free grammars
Ronak Thakkar
 
Lect 5 2d clipping
majicyoung
 
CNF & Leftmost Derivation - Theory of Computation
Drishti Bhalla
 
06 clipping
Ketan Jani
 
Formal language & automata theory
NYversity
 
Fafl notes [2010] (sjbit)
Siddharaj Junnarkar
 
Os6
issbp
 
Os4
issbp
 
Os5 2
issbp
 
Os2
issbp
 
Os6 2
issbp
 
Lecture 7: Definite Clause Grammars
CS, NcState
 
Os4 2
issbp
 
Ch11 input output systems
issbp
 
Class5
issbp
 
Ad

Similar to Theory of Automata and formal languages unit 2 (20)

PPTX
theoryofautomataandformallanguagesunit21-161231042659.pptx
SubhamJha26
 
DOCX
UNIT_-_II.docx
karthikeyan Muthusamy
 
PPTX
Complex differentiation contains analytic function.pptx
jyotidighole2
 
DOC
Netautomata1
Pandi Gingee
 
PDF
DSP_FOEHU - MATLAB 03 - The z-Transform
Amr E. Mohamed
 
PPTX
Daa unit 4
Abhimanyu Mishra
 
PDF
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
PDF
MOD2-DBMS.pdf
RohitKumarSahoo5
 
PDF
1 MARK TYPE (विभिन्न माध्यमों के लिए लेखन
VinayMishra859858
 
PDF
2 random variables notes 2p3
MuhannadSaleh
 
PPTX
01 FUNCTIONS.pptx
JonathanBeltranJr
 
PDF
Automata
Gaditek
 
PDF
Automata
Gaditek
 
DOCX
unit 2 part b.docx
karthikeyan Muthusamy
 
PDF
maths 12th.pdf
Ibrahim Ali Saify
 
PPT
Dfa h11
Rajendran
 
PPTX
Unit-1 Basic Concept of Algorithm.pptx
ssuser01e301
 
PDF
Ch03
Hankyo
 
PPTX
Linear Regression in Machine Learning YLP
davidrex699
 
PDF
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Vivekananda Samiti
 
theoryofautomataandformallanguagesunit21-161231042659.pptx
SubhamJha26
 
UNIT_-_II.docx
karthikeyan Muthusamy
 
Complex differentiation contains analytic function.pptx
jyotidighole2
 
Netautomata1
Pandi Gingee
 
DSP_FOEHU - MATLAB 03 - The z-Transform
Amr E. Mohamed
 
Daa unit 4
Abhimanyu Mishra
 
Chapter 3 REGULAR EXPRESSION.pdf
dawod yimer
 
MOD2-DBMS.pdf
RohitKumarSahoo5
 
1 MARK TYPE (विभिन्न माध्यमों के लिए लेखन
VinayMishra859858
 
2 random variables notes 2p3
MuhannadSaleh
 
01 FUNCTIONS.pptx
JonathanBeltranJr
 
Automata
Gaditek
 
Automata
Gaditek
 
unit 2 part b.docx
karthikeyan Muthusamy
 
maths 12th.pdf
Ibrahim Ali Saify
 
Dfa h11
Rajendran
 
Unit-1 Basic Concept of Algorithm.pptx
ssuser01e301
 
Ch03
Hankyo
 
Linear Regression in Machine Learning YLP
davidrex699
 
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Vivekananda Samiti
 
Ad

More from Abhimanyu Mishra (19)

PPT
Cd unit i
Abhimanyu Mishra
 
PPTX
Presentation1(JIT gnomio)
Abhimanyu Mishra
 
PPTX
Sta unit 5(abimanyu)
Abhimanyu Mishra
 
PPTX
Sta unit 3(abimanyu)
Abhimanyu Mishra
 
PPTX
Sta unit 4(abimanyu)
Abhimanyu Mishra
 
PPTX
Sta unit 3(abimanyu)
Abhimanyu Mishra
 
PPTX
Sta unit 2(abimanyu)
Abhimanyu Mishra
 
PPTX
Unit1
Abhimanyu Mishra
 
PPTX
Daa unit 5
Abhimanyu Mishra
 
PPTX
Daa unit 3
Abhimanyu Mishra
 
PPTX
Daa unit 2
Abhimanyu Mishra
 
PPTX
Daa unit 1
Abhimanyu Mishra
 
PPTX
Software Engineering unit 5
Abhimanyu Mishra
 
PPTX
Software Engineering unit 4
Abhimanyu Mishra
 
PPTX
Software Engineering unit 3
Abhimanyu Mishra
 
PPTX
Software Engineering unit 2
Abhimanyu Mishra
 
PPTX
Software Engineering Unit 1
Abhimanyu Mishra
 
PPTX
Theory of Automata and formal languages Unit 5
Abhimanyu Mishra
 
PPTX
Theory of automata and formal languages Unit 4
Abhimanyu Mishra
 
Cd unit i
Abhimanyu Mishra
 
Presentation1(JIT gnomio)
Abhimanyu Mishra
 
Sta unit 5(abimanyu)
Abhimanyu Mishra
 
Sta unit 3(abimanyu)
Abhimanyu Mishra
 
Sta unit 4(abimanyu)
Abhimanyu Mishra
 
Sta unit 3(abimanyu)
Abhimanyu Mishra
 
Sta unit 2(abimanyu)
Abhimanyu Mishra
 
Daa unit 5
Abhimanyu Mishra
 
Daa unit 3
Abhimanyu Mishra
 
Daa unit 2
Abhimanyu Mishra
 
Daa unit 1
Abhimanyu Mishra
 
Software Engineering unit 5
Abhimanyu Mishra
 
Software Engineering unit 4
Abhimanyu Mishra
 
Software Engineering unit 3
Abhimanyu Mishra
 
Software Engineering unit 2
Abhimanyu Mishra
 
Software Engineering Unit 1
Abhimanyu Mishra
 
Theory of Automata and formal languages Unit 5
Abhimanyu Mishra
 
Theory of automata and formal languages Unit 4
Abhimanyu Mishra
 

Recently uploaded (20)

PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PDF
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
PPTX
Smart_Cities_IoT_Integration_Presentation.pptx
YashBhisade1
 
PDF
13th International Conference of Networks and Communications (NC 2025)
JohannesPaulides
 
PPTX
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
PPTX
site survey architecture student B.arch.
sri02032006
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPT
Tiles.ppt The purpose of a floor is to provide a level surface capable of sup...
manojaioe
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PDF
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
PPTX
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
PDF
PRIZ Academy - Change Flow Thinking Master Change with Confidence.pdf
PRIZ Guru
 
PDF
BioSensors glucose monitoring, cholestrol
nabeehasahar1
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PDF
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
PDF
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
PDF
OT-cybersecurity-solutions-from-TXOne-Deployment-Model-Overview-202306.pdf
jankokersnik70
 
PPT
Total time management system and it's applications
karunanidhilithesh
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
Smart_Cities_IoT_Integration_Presentation.pptx
YashBhisade1
 
13th International Conference of Networks and Communications (NC 2025)
JohannesPaulides
 
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
site survey architecture student B.arch.
sri02032006
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Tiles.ppt The purpose of a floor is to provide a level surface capable of sup...
manojaioe
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
PRIZ Academy - Change Flow Thinking Master Change with Confidence.pdf
PRIZ Guru
 
BioSensors glucose monitoring, cholestrol
nabeehasahar1
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
OT-cybersecurity-solutions-from-TXOne-Deployment-Model-Overview-202306.pdf
jankokersnik70
 
Total time management system and it's applications
karunanidhilithesh
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 

Theory of Automata and formal languages unit 2

  • 1. THEORY OF AUTOMATAAND FORMAL LANGUAGES UNIT-2 ABHIMANYU MISHRA ASSISTANT PROF.(CSE) JETGI Abhimanyu Mishra(CSE) JETGI12/31/2016 1
  • 2. A regular expression (sometimes called a rational expression)is, in computer science and formal languages theory, a sequence of characters that define a search pattern. usually this pattern is then used by in string searching algorithm "find" or "find and replace" operations on strings. 2. REGULAR EXPRESSION AND LANGUAGES Abhimanyu Mishra(CSE) JETGI12/31/2016 2
  • 3. 2.1 Definition of Regular Expression: The set of regular expression of defined by the following rules: (i) Every letter of ∑ can be made into regular expression, null string,€ itself is a regular expression. (ii) If r1 and r2 are regular expression, then (a) (r1) (b) r1r2 (c) r1+r2 (d) r1 * (e) r1 + are also regular expression (iii) Nothing else is regular expression. 12/31/2016 Abhimanyu Mishra(CSE) JETGI 3
  • 4. 2.1.1 Building Regular Expression (i) The constants ϵ(null string) and ɸ(empty set) are regular expression, denote the languages {ϵ} and ɸ, respectively. That is, L(ϵ) = {ϵ} , and L(ɸ)= ɸ. (ii) If a is any symbol, then a is regular expression. This expression denotes the language {a}. That is L(a)={a}. (iii) A variable, usually capitalized and such as L is a variable, representing any language. 12/31/2016 Abhimanyu Mishra(CSE) JETGI 4
  • 5. 2.2 Construction of FA for Regular Expression • The Expression is r+s for some smaller expression r and s. The following automation serves, where R is automation for r and S is automation for s. That is, starting at the new start state, We can go to the start state of either the automation for r or the automation for S So L(r) and L(s) ϵ ϵ Start ϵ ϵ 12/31/2016 Abhimanyu Mishra(CSE) JETGI 5 R S
  • 6. 2.The expression rs for some smaller expression r and s. The automation for the concatenation is …………. Start ϵ ϵ ϵ 3. The expression is r* for some smaller expression r. Then we use automation of ………. ϵ Start ϵ ϵ ϵ 12/31/2016 Abhimanyu Mishra(CSE) JETGI 6 R S R
  • 7. Example 1: Find the automation for regular expression a.(a+b)*.b.b Solution: The basic regular expression involved are a and b,we start with automation for a and automation for b. Since brackets are evaluated first.(a+b). ϵ a ϵ Start ϵ ϵ b 12/31/2016 Abhimanyu Mishra(CSE) JETGI 7
  • 8. Step 2: Since closure is required to take next, we construct automation for (a+b)* using automation for (a+b) …….. ϵ a ϵ ϵ Start ϵ ϵ ϵ b ϵ ϵ 12/31/2016 Abhimanyu Mishra(CSE) JETGI 8
  • 9. Step 3: Next we construct the automation for a.(a+b)* as……… ϵ a ϵ ϵ Star a ϵ ϵ ϵ b ϵ ϵ 12/31/2016 Abhimanyu Mishra(CSE) JETGI 9
  • 10. Step 4: Next we construct the automation for a.(a+b)*.b by using automation ϵ ϵ a ϵ Start a ϵ ϵ b ϵ b ϵ ϵ 12/31/2016 Abhimanyu Mishra(CSE) JETGI 10
  • 11. Step 5: Now finally we can construct automation for a.(a+b)*.b.b ϵ ϵ a ϵ Start a ϵ b b ϵ ϵ ϵ b ϵ 12/31/2016 Abhimanyu Mishra(CSE) JETGI 11
  • 12. 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 (I) R = Q + RP has a unique solution, (ii) R = QP* 12/31/2016 Abhimanyu Mishra(CSE) JETGI 12
  • 13. 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 + ….) ] proved. 12/31/2016 Abhimanyu Mishra(CSE) JETGI 13
  • 14. Assumptions for Applying Arden’s Theorem − The transition diagram must not have NULL transitions It must have only one initial state: Method Step 1 − Create equations as the following form for all the states of the DFA having n states with initial state q1. q1 = q1R11 + q2R21 + … + qnRn1 + ϵ q2 = q1R12 + q2R22 + … + qnRn2 ……………………………………………………………. ……………………………………………………………. qn = q1R1n + q2R2n + … + qnRnn Rij represents the set of labels of edges from qi to qj, if no such edge exists, then Rij = ɸ Step 2 − Solve these equations to get the equation for the final state in terms of Rij 12/31/2016 Abhimanyu Mishra(CSE) JETGI 14
  • 15. Example 1: Construct a regular expression corresponding to the automata given below − b a b b a a 12/31/2016 Abhimanyu Mishra(CSE) JETGI 15 q2 q1 q3
  • 16. Solution: Here the initial state is q2 and the final state is q1. The equations for the three states q1, q2, q3 q1 = q1a + q3a + ϵ (ϵ move is because q1 is the initial state) q2 = q1b + q2b + q3b q3 = q2a Now, we will solve these three equations − q2 = q1b + q2b + q3b = q1b + q2b + (q2a)b (Substituting value of q3) = q1b + q2(b + ab) = q1b (b + ab)* (Applying Arden’s Theorem) 12/31/2016 Abhimanyu Mishra(CSE) JETGI 16
  • 17. q1 = q1a + q3a + ϵ = q1a + q2aa + ϵ (Substituting value of q3) = q1a + q1b(b + ab*)aa + ϵ (Substituting value of q2) = q1(a + b(b + ab)*aa) + ϵ = ϵ (a+ b(b + ab)*aa)* = (a + b(b + ab)*aa)* Hence, the regular expression is (a + b(b + ab)*aa)*. 12/31/2016 Abhimanyu Mishra(CSE) JETGI 17
  • 18. Solve This Problem? Construct the regular expression 0 0,1 1 1 0 12/31/2016 Abhimanyu Mishra(CSE) JETGI 18 q1 q2 q3
  • 19. Construction of an FA from an RE We can use Thompson's Construction to find out a Finite Automaton from a Regular Expression. We will moderate the regular expression into minimum regular expressions and converting these to NFA and finally to DFA. Case 1 − For a regular expression ‘a’, we can construct the following FA Finite Automata for RE = a Start a 12/31/2016 Abhimanyu Mishra(CSE) JETGI 19 q1 qf
  • 20. Case 2 − For a regular expression ‘ab’, we can construct the following FA − Start a b Case 3 − For a regular expression (a+b), we can construct the following FA − Start a b Case 4 − For a regular expression (a+b)*, we can construct the following FA − a,b Start 12/31/2016 Abhimanyu Mishra(CSE) JETGI 20 qfq1 q2 q1 qf qf
  • 21. Example:-Convert the following RE into its equivalent DFA − 1 (0 + 1)* 0 0,1 start 1 ϵ ϵ 0 12/31/2016 Abhimanyu Mishra(CSE) JETGI 21 q0 q1 q2 q3 qf
  • 22. Pumping Lemma for Regular Languages Theorem Let L be a regular language. Then there exists a constant ‘c’ such that for every string w in L − |w| ≥ c We can break w into three strings, w = xyz, such that − |y| > 0 |xy| ≤ c For all k ≥ 0, the string xykz is also in L. 12/31/2016 Abhimanyu Mishra(CSE) JETGI 22
  • 23. 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 is non-regular, it does not satisfy Pumping Lemma. Method to prove that a language L is not regular At first, we have to assume that L is regular. So, the pumping lemma should hold for L. Use the pumping lemma to obtain a contradiction − 12/31/2016 Abhimanyu Mishra(CSE) JETGI 23
  • 24. Use the pumping lemma to obtain a contradiction − Select w such that |w| ≥ c Select y such that |y| ≥ 1 Select x such that |xy| ≤ c Assign the remaining string to z. Select k such that the resulting string is not in L. Hence L is not regular. 12/31/2016 Abhimanyu Mishra(CSE) JETGI 24
  • 25. Application of the Pumping Lemma (i) Select the language L ,You wish to prove non-regular. (ii) The “adversary” pinks n, the constant mentioned in the pumping lemma, Once the adversary has picked n, he may not change it. (iii) Select a string z in L. Your choice may depend implicitly on the of n chosen. (iv) The adversary breaks z into u, v and w, subject to the constants that |uv|<=n and |v|>=1 (v) You achieve a contradiction to the pumping leema by showing, for any u,v and determined by the adversary that there exit i for which uviw is not in L.it May then concluded and L is not regular. Your selection of pumping leema on n,u,v and w. 12/31/2016 Abhimanyu Mishra(CSE) JETGI 25
  • 26. Example: Prove that language L =(anbn for n= 0,1,2,3……} is not regular Solution: Case 1 If middle part y is made off entirely of a’s,as x aaaaaaa….z If we jump it as xyyz,xyyyz,then number of a”s increases,but in language {(anbn for n= 0,1,2,3,……} a’s and b’s are equal so it os not allowed. Case 2 If middle part y is made off entirely of b’s as x bbbbbbb……z For the same reason, it is also not allowed. Case 3 y part is made of some positive number of a’s and some number of b’s. This would mean that y contain the substring ab x……aaaaaaaabbbbbbbbbbb…………..z Then xyyz would have two copies of the substring ab.But every world in L contains substring ab exactly once. This proves that the pumping lemma cannot apply to L and therefore L is not regular 12/31/2016 Abhimanyu Mishra(CSE) JETGI 26
  • 27. Q1.Prove That L={0n1m2n , n,m>=0} is not regular. Q2. Prove that language L ={0n |n is perfect square} is not regular. Q3. Prove that language L ={0n |n is perfect cube} is not regular. 12/31/2016 Abhimanyu Mishra(CSE) JETGI 27
  • 28. AUTOMATA WITH OUTPUT Here we are using two Machines for finding the Finite Automata Output (i) Moore Machine (ii) Mealy Machine 12/31/2016 Abhimanyu Mishra(CSE) JETGI 28
  • 29. Moore Machine (i) Moore Machine Moore machine is an FSM whose outputs depend on only the present state. A Moore machine can be described by a 6 tuple (Q, ∑, ∆, δ, ƛ’, q0) where − Q is a finite set of states. ∑ is a finite set of symbols called the input alphabet. ∆ is a finite set of symbols called the output alphabet. δ is the input transition function where δ: Q × Σ → Q ƛ’ is the output transition function where ƛ’ : Q × Σ → ∆ q0 is the initial state from where any input is processed (q0 ∈ Q). 12/31/2016 Abhimanyu Mishra(CSE) JETGI 29
  • 30. Representation of Moore Machine:( Transition Table) Present State Next state at input Output a=0 a=1 q0 q3 q1 0 q1 q1 q2 1 q2 q2 q3 0 q3 q3 q0 0 12/31/2016 Abhimanyu Mishra(CSE) JETGI 30
  • 31. Representation of Moore Machine:( Transition Diagram) 0 0 Start 1 1 0 1 0 1 0 0 1 0 12/31/2016 Abhimanyu Mishra(CSE) JETGI 31 q3 q0 q2 q1
  • 32. Mealy Machine A Mealy Machine is an FSM whose output depends on the present state as well as the present input. It can be described by a 6 tuple (Q, ∑, ∆, δ, ƛ’, q0) where − Q is a finite set of states. ∑ is a finite set of symbols called the input alphabet. ∆ is a finite set of symbols called the output alphabet. δ is the input transition function where δ: Q × ∑ → Q ƛ’ is the output transition function where X: Q → ƛ’, q0 is the initial state from where any input is processed (q0 ∈ Q). 12/31/2016 Abhimanyu Mishra(CSE) JETGI 32
  • 33. Representation of Mealy Machine:( Transition Table) Present State For input a=0 for input a=1 State Output State Output q1 q3 0 q2 0 q2 q1 1 q4 0 q3 q2 1 q1 1 q4 q4 1 q3 0 12/31/2016 Abhimanyu Mishra(CSE) JETGI 33
  • 34. Representation of Mealy Machine:( Transition Diagram) Start 0/1 1/0 1/1 0/0 0/1 1/0 0/1 1/0 12/31/2016 Abhimanyu Mishra(CSE) JETGI 34 q1 q3 q4 q2
  • 35. Mealy Machine vs. Moore Machine 12/31/2016 Abhimanyu Mishra(CSE) JETGI 35 Mealy Machine Moore Machine Output depends both upon present state and present input. Output depends only upon the present state. Generally, it has fewer states than Moore Machine. Generally, it has more states than Mealy Machine. Output changes at the clock edges. Input change can cause change in output change as soon as logic is done. Mealy machines react faster to inputs. In Moore machines, more logic is needed to decode the outputs since it has more circuit delays.