0% found this document useful (0 votes)
95 views

Theory of Computation: Sathyabama

Uploaded by

anonymous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

Theory of Computation: Sathyabama

Uploaded by

anonymous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 92

THEORY OF COMPUTATION

Dr.S.Prince Mary M.E.,Ph.D., Associate Professor,


Department of Computer Science and Engineering,
School of Computing

SATHYABAMA
Institute of Science and Technology
Deemed to be University
Chennai.

July 31, 2024 School of Computing 1


UNIT- I
FINITE AUTOMATA
&
REGULAR LANGUAGES
Syllabus
• Introduction
• Regular Languages and Regular Expressions
• Deterministic Finite Automata
• Non-Deterministic Finite Automata
• NFA to DFA Conversion
• NFA-NULL Construction
• NFA – NULL to NFA Conversion
• Kleene’s Theorem Part I & II
What is Theory of Computation or Automata
Theory?
• It is the study of abstract mathematical machine and it deals
with definitions and properties of different types of
“computation models”.
• Examples of such computational models are:
– Finite Automata: text processing, compilers, and
hardware design.
– Context-Free Grammars: define programming languages
and in Artificial Intelligence.
– Context-Sensitive Grammars: grammars used for compiler
designing and in Artificial intelligence.
– Turing Machines: These form a simple abstract model of a
“real” computer.
Theory of Computation
Basic Units of Regular Language
• Alphabets (∑ ) : {a,b} or {0,1}
• String( w) : Collection of input alphabets
• Language (L) : Collection of Strings

Empty Set : Ø
NULL String :ε or λ
Finding Language using Conditions
• Find L with 0’S and 1’s with odd no. of 1’s
– ∑ ={ 0,1}
– w ={ 1,01,10,100,010, 111,1011……..}
– w ={ 1,01,10,100,010, 110 ,111,1011……..} --invalid
– L = {w/w consists of odd no. of 1’s}
• Find L with 0’s and 1’s with even no. of 1’s
– ∑ ={ 0,1}
– w ={Λ ,11,011,101,110,0110, 1010, ……..}
– w ={Λ ,11,011,101,100, 110,0110, 1010, …..} --invalid
– L = {w/w consists of even no. of 1’s}
Finding Language using Conditions
• Find L with a’s and b’s with even no. of a’s
– ∑ ={ a,b}
– w ={Λ ,aa,baa,aba,aab,baab, abba,abab ……..}
– w ={Λ ,aa,baa,aaa,aab,baab, abba,abab ……..} --invalid
– L = {w/w consists of even no. of a’s}
• Find L with a’s and b’s with even no of a’s and b’s.
– ∑ ={ a,b}
– w ={Λ ,aa,bb,aabb,abab,baba,bbaa ……..}
– L = {w/w consists of even no. of a’s and b’s}
• Find L with a’s and b’s having a substring aa
– ∑ ={ a,b}
– w ={aa,baa,aab,baab, abaa,aabaa ……..}
– L = {w/w consists of a substring aa}
Define Regular language and
Regular Expression over ∑.

• RL:
– A language is regular if there exits a DFA for that
language
– The language accepted by DFA is RL.
• RE:
– A Mathematical notation used to describe the regular
language.
– This is formed by using 3 Symbols:
(i) . [dot operator] – for concatenation
(ii) + [Union operator] –at least 1 occurrence
(iii) {*} [Closure Operator ] – Zero or more occurrences
Basic Regular Expressions?
• Ø is a RE and denotes the empty set.
• ε is a RE and denotes the set { ε }
• For each a in ∑, a is a RE and denotes the set
{a}
• If r and s are RE that denoting the languages R
and S respectively, then,
– (r+s) is a RE that denotes the set (RUS)
– (r.s) is a RE that denotes the set RS
– (r)* is a RE that denotes the set R*
Writing Regular Expressions
1. Write RE for the language of even no of 1’s
∑ ={ 1}
w ={Λ , 11,1111, ……..}
RE = (11)*
2. Write RE for the language of odd no of 1’s
∑ ={ 1}
w ={1,111,11111 ……..}
RE = (11)*.1
3. Write RE with a string starting with a
∑ ={ a,b}
w ={a,ab,aba,aab ……..}
RE = (a) (a+b)*
Writing Regular Expressions
4. Write RE with a string starting with either a or ab
∑ ={ a,b}
w ={a,ab,aba,aab ……..}
RE = (a+ab) (a+b)*

5. Write RE with a string consist of a’s and b’s any length include
λ
RE= (a+b)*
6. Write RE with a string a’s and b’s ending with abb
RE= (a+b)*abb
7. Write RE with a string a’s and b’s starting with abb
RE= abb (a+b)*
Writing Regular Expressions
8. Write RE with a string having a substring aa
RE= (a+b)*.aa.(a+b)*
9. Write RE with a string that begins and ends
with double consecutive letters
RE = (aa+bb).(a+b)*.(aa+bb)
10. Strings of a’s and b’s of even length
RE= (aa+bb+ab+ba)*
11. Strings of a’s and b’s in which 3rd symbolfrom right
end is a.
RE = (a+b)*.a.(a+b).(a+b)
What is Finite Automata?
• Finite automata are used to recognize
patterns.
• A machine that accepts Regular Language
Applications:
– Compliers
– Text processing
– Hardware design.
Types of Automata
DFA (Deterministic Finite Automata)
• Only one path for specific input from the
current state to the next state.
• DFA does not accept the null move
• It is used in Lexical Analysis phase in
Compilers.
• Example: RE=(a+b)+
Formal Definition of DFA
A DFA or finite state machine is a 5 tuple
M=(Q, ∑, q0, δ, A) machine,
where,
Q -is a finite set of states
∑ - finite set of input symbols
q0 Q - Initial states
A ⊆ Q - Set of accepting states
δ - transition function
δ : Q x ∑ -> Q
Construction of DFA
Problems:
1. Design DFA to accept the strings having exactly one a.
∑ ={ a,b}
w ={a,ab, ba, abb,bab ……..} RE = b*.a. b*

Tuples: DFA - State Diagram


Q={q0,q1}
∑={a,b}
q0 -> start state
A= {q1}
δ - transition function
δ (q0,a)->q1
δ (q0,b)->q0
δ (q1,a)-> null
δ (q1,b)-> q1

δ : Q x ∑ -> Q
2. Design DFA to accept strings having at least one a.

∑ ={ a,b} w={ a, ab, ba, ….} RE = b*.a. (a+b)*


DFA- Diagram

Tuples:
Q={q0,q1}
∑={a,b}
q0 -> start state
A= {q1}
δ - transition function
δ (q0,a)->q1
δ (q0,b)->q0
δ (q1,a)-> q1
δ (q1,b)-> q1
3. Design DFA to accept
Case 1: strings of even a’s and even b’s
Case 2: strings of even a’s and odd b’s
Case 3: strings of odd a’s and even b’s
Case 4: strings of odd a’s and odd b’s

Case 1: even -even


DFA Diagram:
W={Λ, aa,bb,abab,….}
Case 2: even-odd
DFA Diagram
W={aab, aba,baa…}

Case 3: odd - even


DFA Diagram
W={abb,bab,bba…….}
Case 4: odd-odd
DFA Diagram
W={ ab, abbb,baaa…..}

Tuples:
Q={q0,q2,q3,q4}
Σ ={a,b}
q0= start state, A={q3}
Transition Function:
δ(q0,a)={q2}, δ(q0,b)={q4}
δ(q2,b)={q3}, δ(q2,a)={q0}
δ(q3,a}={q4}, δ(q3,b)={q2}
Extended Transition Function (δ*)
• δ*
– Describes what happens when we start in a any state
and follow any sequence of inputs.
– Definition of δ*:
Let M= (Q,Σ,δ,q0,A) be a FA.
We define the function δ* : Q x ∑ *->Q as follows:
1. For any state q ∈ Q , δ* (q, Λ ) = q
2. for any state q ∈ Q , y ∈ ∑ *, a ∈ ∑
δ*(q, ya) = δ(δ*( q,y),a)
Note:
δ* - to read a string
δ – to read a symbol
Problems - (δ*)
• Find δ*(q0,abc) ?

δ* ( q0,abc) = δ(δ*(q0,ab),c)

= δ(δ(δ* (q0,a),b),c)

= δ(δ(δ (δ* (q0, Λ ),a),b),c)

= δ(δ(δ (q0,a),b),c)

= δ(δ(q1,b),c)

=δ(q2,c)

Ans= q3
Definitions
• String acceptance by Finite Automata
• Let M=(Q,∑,q0,A, δ) be an FA.
• A string x∈ ∑* is accepted by M, if δ*( q0,x) ∈ A
• Language acceptance by Finite Automata
– The language accepted by M or the language
recognized by M is the set,
– L(M)= {x | x ∈ ∑* and δ*( q0,x) ∈ A}
Non-Deterministic Finite Automata
• When there exist many paths for specific input from the
current state to the next state.
• Every NFA is not DFA, but each NFA can be translated into
DFA.
• Types
1. NFA without Λ 2.
2. NFA with Λ
Advantages of NFA over DFA:
– DFAs are faster but more complex
– Build a FA representing the language that is a
union, intersection, concatenation etc. of two (or more)
languages easily by using NFA's.
• Design NFA to accept the Language
L= {w/w = ababn /aban}

Q= {q0,q1,q2,q3,q5,q6} ∑ ={a,b} q0=start state


A={q3,q6}
Transition Function (δ ):
δ(q0,a)={q1,q5} etc
Formal definition of NFA


Conversion of NFA to DFA
• Problem 1: convert the given NFA to DFA

• For the given transition diagram ,first construct the transition


table. NFA Transition Table
State 0 1
q0 {q0,q1} {q1}
q1 {q1,q2} {q1}
q2 {q2 } {q1,q2}
Step 1: Add q0 of NFA to DFA
Step 2: From the start state of q0 find the transitions
δ'([q0], 0) = [q0,q1] -------- (A )
δ'([q0], 1) = [q1] -----(B)

Step 3: Find the possible set of states for each input symbol
3.1 From A: DFA- Transition
State 0 Table 1
δ'([q0, q1], 0) = δ(q0, 0) ∪ δ(q1, 0) q0 A B
= {q0, q1} ∪ {q1,q2} A C B
= {q0, q1, q2}
B D B
= [q0, q1, q2] --------(C)

δ'([q0, q1], 1) = δ(q0, 1) ∪ δ(q1, 1) DFA - State Diagram


= {q1} ∪ { q1}
= {q1}
= [q1] ------( B)
3.2 From B:
δ'([q1], 0) = [q1, q2]--------(D)
δ'([q1], 1) = [q1] ------------(B)
3.3 From C:
δ'([q0, q1, q2], 0) = δ(q0, 0) ∪ δ(q1, 0) ∪ δ(q2, 0)
= {q0, q1} ∪ {q1, q2} ∪ q2
= {q0, q1, q2}
= [q0, q1, q2] ----(C)

δ'([q0, q1,q2], 1) = δ(q0, 1) ∪ δ(q1, 1) ∪ δ(q2,1)


= {q1} ∪ { q1} ∪ {q1, q2}
= {q1, q2}
= [q1, q2] ------( D)
3.4 From D:
δ'([q1, q2], 0) = δ(q1, 0) ∪ δ(q2, 0) State 0 1
= {q1, q2} ∪ q2
q0 A B
= [q1, q2]--------(D)
A C B
δ'([q1, q2], 1) = δ(q1, 1) ∪ δ(q2, 1)
= {q1} ∪ {q1, q2 } B D B
= [q1, q2] ------------(D) C C D
D D D
Final states of DFA

• Final States : C and D


The state [q0,q1,q2…qn] ∈ Q (DFA) is the
final state is atleast one of the states in

• Transition Table State diagram – DFA


State 0 1
q0 A B
A C B
B D B
C C D
D D D
Conversion of NFA to DFA
• Problem 1:

• For the given transition diagram we will first construct the


Step 1: Add q0 of NFA to DFA

Step 2: From the start state of q0 find the transitions


δ'([q0], 0) = [q0]
δ'([q0], 1) = [q1] -----(A)

Step 3: find the possible set of states for each input symbol
3.1 From A

δ'([q1], 0) = δ(q1, 0)
= [q1,q2 ] -------------(B)

δ'([q1], 1) = δ(q1, 1)
= [q1] --------------(A)
3.2 From B:
δ'([q1,q2], 0) = δ(q1,0) U δ(q2,0)
={q1,q2} U {q2}
={q1,q2} --------------(B)

δ'([q1,q2], 1) = δ(q1,1) U δ(q2,1)


={q1} U{q1,q2}
= [q1, q2] ------------(B)

Step 4: Final State = [B]


Extended Transition Function of NFA (δ*)

• Find δ*(q0,11), δ*(q0,01), δ*(q0,011), δ*(q0,111) from the
given NFA:

Find:
i. δ*(q0,11):

δ*(q0,11)=

= δ(q0,1) U δ(q1,1)
={q0,q1} U {q2}
ii. Find δ*(q0,01)
δ*(q0,01)=

= δ(q0,1)
={q0,q1}
iii. Find δ*(q0,011)
δ*(q0,011)=

=δ(q0,1) U δ(q1,1)
={q0,q1} U{q2} ={q0,q1,q2}
iv.Find: δ*(q0,111)
δ*(q0,111)=

=δ(q0,1) U δ(q1,1) U δ(q2,1)


= {q0,q1} U{q2}U{q3}
= {q0,q1,q2,q3}

∴111 is accepted.
Theorem 1
• Statement:
For any NFA machine M=(Q, ∑, q0, δ , A)
accepting a language L ⊆ ∑*, there is a DFA
machine M1= (Q, ∑, q0, δ , A) that accepts L.
Proof by Structural Induction

• Proof:
DFA- M1is defined as follows:
– Q1=2Q
– q1=q0
– A1={qϵQ1 |A⊆Q}
– For,qϵQ1 and aϵ∑,

To prove, δ1*(q1,x)= δ*(q0,x)

M1accepts the same language as M


• Proof by Structural Induction:
1.Basis Step
Strings of length 0
If x=ꓥ,
LHS = δ1*(q1,x) = δ1*(q1,ꓥ)
= q1------- (By definition of δ1*)
= {q0} ------- (By definition of q1)
= δ*(q0,ꓥ)------- (By definition of δ*)
= δ*(q0,x) = RHS
2.Induction Hypothesis:
Assume the statement to be proved is true.
x is a string satisfying,
3.Induction Step:
To prove, for any aϵ∑, xϵ∑*
to be proved

LHS=δ1*(q1,xa)=δ1(δ1*(q1,x),a) ------- (By definition of δ1*)


= δ1(δ*(q0,x),a) -------(By Induction Hypothesis)
= -------(By 1)
=δ*(q0,xa) =RHS------- (By definition of δ*)
Hence Proved.
NFA – with Λ Transition

• This allows transitions not only input symbols


but also on null inputs.
• Ʌ or ε (EPSILON )Empty string does not do any
operation.
– aɅ=a | oɅ=0 |1Ʌ = 1
NFA-with Λ Transitions
• Example:
– RE=0*
– NFA without NULL
NFA with NULL
Formal definition of NFA with Λ
• NFA -Λ also has five tuples same as NFA, but with
different transition function, as shown follows:
NFA - Λ is a 5 tuple M=(Q, ∑, q0, δ , A) machine,
where,
Q -is a finite set of states
∑ - finite set of input symbols
q0 Q - Initial states
A ⊆ Q - Set of accepting states
δ - transition function
δ: Q x ∑ {Λ }→2Q
Epsilon (NULL) Closure of a state -Λ(q)
• Λ(q) of a set of states can be defined as
follows:
• It is a set of all states that can be reached from
any state on Λ symbol
• Let M=(Q, ∑, q0, δ , A) be a NFA- Λ machine
and let S be any subset of Q.
• The Λ(S) is the set defined as follows:
1. Every element of S is in element of Λ(S)
2. For any q 𝞮 Λ(S), every element of
δ(q, Λ) is in Λ(S)
Problems on Ʌ Closure
1.

Ʌ(q0)={ }
Ʌ(q1) ={ }
Ʌ(q2)={ }
Problems on Ʌ Closure
2.

Ʌ(q0)={ }
Ʌ(q1) ={ }
Ʌ(q2)={ }
Extended Transition Function of
NFA- Λ (δ*)
• δ*
– Describes what happens when we start in a any state and follow any
sequence of inputs.
– Definition of δ*:
Let M= (Q,Σ,δ,q0,A) be a NFA with Λ .
We define the function δ* : Q x ∑ * {Λ }→2Q as follows:
1. For any state q 𝞮 Q , δ* (q, Λ ) = Λ (q)
2. for any state q 𝞮 Q , y 𝞮∑ *, a 𝞮 ∑

δ*(q, ya)

δ* - to read a string
δ – to read a symbol
Extended Transition Function (δ*)
Problem on δ*

i.Find δ*(q0,Ʌ) = Ʌ({q0})


δ*(q0,Ʌ) = {q0,p,t}
ii.Find δ*(q0,0)
δ*(q0,Ʌ0)

=Ʌ(δ(q0,0) U δ(p,0) U δ(t,0))


=Ʌ(∅ U{P}U{u})
= Ʌ({p,u})
={p,u}
ii.Find δ*(q0,01)
δ*(q0,01)

=Ʌ(δ(p,1) U δ(u,1))
=Ʌ({r}U∅)
= Ʌ({r})
δ*(q0,01) ={r}
iii.Find δ*(q0,010)
δ*(q0,010)

=Ʌ(δ(r,0))
= Ʌ({s})
={s,w,q0,p,t}

Accepted
Conversion of NFA-Ʌ to an NFA

• Find Ʌ-closure of all states


Ʌ-closure(A)
={A,B,D}
Ʌ-closure(B)
={B,D}
Ʌ-closure(C)
={C}
Ʌ-closure(D)
={D}
• Find δ* for all the states:
i. δ*(A,0)=δ*(A,Ʌ0)

=Ʌ(δ(A,0) U δ(B,0) U δ(D,0))


=Ʌ(A,C,D)
={A,B,C,D}
ii. δ*(A,1)=δ*(A,Ʌ1)

=Ʌ(δ(A,1) U δ(B,1) U δ(D,1)) = Ʌ(∅)


=∅
iii. δ*(B,0)=δ*(B,Ʌ0)

=Ʌ(δ(B,0) U δ(D,0))
= Ʌ(C,D)
={C,D}
• iv. δ*(B,1)=δ*(B,Ʌ1)

=Ʌ(δ(B,1) U δ(D,1))
= Ʌ(∅)
=∅
v.δ*(C,0)=δ*(C,Ʌ0)

=Ʌ(δ(C,0))= Ʌ(∅)=∅
vi. δ*(C,1)=δ*(C,Ʌ1)

=Ʌ(δ(C,1)) =Ʌ(B)= {B,D}


vii. δ*(D,0)=δ*(D,Ʌ0)

=Ʌ(δ(D,0))=Ʌ(D)={D}
viii.δ*(D,1)= δ*(D,Ʌ1)

=Ʌ(δ(D,1)) = Ʌ(∅) =∅
Final state of NFA

• Final state of NFA and NFA-Ʌ are same,


• If initial state Ʌ(A)={A,B,D} has NFA-Ʌ final state
then initial state A is also final state.

• Given NFA- Ʌ NFA


Conversion of NFA-Ʌ to an NFA

Problem-2 GIVEN NFA-Ʌ

Ʌ -Closure (A)=
{A,B,D}
Ʌ -Closure (B)=
State
{B} CONVERTED NFA0 1
A {A,B,C,D,E} {D,E}
Ʌ -Closure (C)=
B {C} {E}
{C}
C - {B}
Ʌ -Closure (D)=
D {E} {D}
{D}
E - -
Ʌ -Closure (E)=
{E}
Theorem 2
• Equivalence of NFA-ꓥ and NFA
• If L is accepted by an NFA with ꓥ transitions then
L is accepted by NFA without ꓥ transitions
• Statement:
For any NFA NULL machine M=(Q, ∑, q0, δ , A)
accepting a language L ⊆ ∑*, there is a NFA
machine M1= (Q, ∑, q0, δ , A) that accepts L.

Given:
NFA-ꓥ, M=(Q,∑,δ,q0,A)
NFA, M1=(Q1,∑,δ1,q1,A1)
Given:
NFA-ꓥ, M=(Q,∑,δ,q0,A) NFA-ꓥ:
NFA, M1=(Q1,∑,δ1,q1,A1)
Proof: NFA:
• By Definitions:

• For, aϵ∑ :
(By definition it is true if we
pass a single length string)
• To Prove:
• Proof: By Structural Induction
• Basis Step:
Take |x|=0 => x= Ʌ

LHS:

RHS:

So the above statement is not true for |x|=ꓥ

Hence we begin the induction with |x|=1


• Let, x=a

(By definition it is true if we pass a single length string)


• Induction Hypothesis: Assumption:
x is a string satisfying: δ1*(q1,x)= δ*(q0,x)
• Induction Step
– To prove, for any aϵ∑, x ϵ∑*
δ1*(q1,xa)= δ*(q0,xa)

LHS: δ1*(q1,xa)

----(By Induction Hypothesis)

( δ=δ1 if the length of the string


is 1)

= δ*(q, xa)
=RHS Hence the theorem is proved.
Kleene’s Theorem Part -I

1. For any regular expression r that represents


language L(r), there is a finite automaton that
accepts that same language.
2. For any finite automaton M that accepts
language L(M), there is a regular expression
that represents the same language.
Regular Expressions to NFA -Ʌ
Kleene’s Theorem Part-I:

• For each kind of RE, define an NFA.


• Input: A Regular Expression r over an alphabet ∑
• Output: An NFA N accepting L(r)
• Method:
start ε
Step 1: For  i f

The NFA recognizes {}

Step 2: For a in ∑ start a


i f

The NFA recognizes {a}

July 31, 2024 69


Regular Expressions to NFA- Ʌ

Step 3: RE=a |b a
1 2
ε
ε
start
0
5
ε ε
3 4
The NFA recognizes {a,b} b

Step 4: RE=ab

start a b OR start a ε b
0 1 2 0 1 2 3

The NFA recognizes {ab}

July 31, 2024 70


Kleene’s Theorem Part-I:
Step 5: RE=a* ε

start ε a ε
0 1 2 3

The NFA recognizes {ε,a,aa,aaa,.......}

Step 6: RE= a+
= a.a*
Follow step 4 for construction.

July 31, 2024 71


Converting RE to NFA-Ʌ
Problem 1
• Construct Non deterministic Finite Automata with NULL
transition or the following regular expression using
Kleene’s Theorem Part-I: method.

a. (a|b)*abb
b. (a|b)*
c. (a*|b*)* =a*,b* , (a*+b*)
d. ((ε|a)b*)*
e. (0|123)*=0,123,0+123,

July 31, 2024 73


Example 1
• Decomposition of (a|b)*abb
r11 start a
0 1
r9
r10 start b
r7 2 3
r8
r5 b
a
r6 b 1 2
r4 * ε
ε
a start
( r3 ) 0
5
r1 r2 ε ε
| 3 4
b
a b

July 31, 2024 74


Example 1(contd.)
• Decomposition of (a|b)*abb
r11

ε
r9
r10
r7 a
r8 2 3
r5 b ε
ε ε
start
r6 b 0 1 ε
r4 * 6 7
a ε ε
4 5
( r3 ) b

r1 r2 ε
|

a b

July 31, 2024 75


Example 1(contd.)
• Decomposition of (a|b)*abb
r11

ε
r9
r10
r7 a
r8 2 3
r5 b ε
ε ε
start a
r6 b 0 1 ε
r4 6 7 8
*
a ε ε
4 5
( r3 ) b

r1 r2 ε
|

a b

July 31, 2024 76


NFA- Ʌ for (a|b)*abb

a
2 3
ε
ε
start ε
0 1 ε a b b
6 7 8 9 10
ε ε
4 5
b

July 31, 2024 77


Assignment
• Construct Non deterministic Finite Automata with NULL
transition or the following regular expression using
Kleene’s Theorem Part-I: method.

a. (a|b)*abb
b. (a|b)*
c. (a*|b*)*
d. ((ε) |a)b*)*= ε,a, ε+a,b*, , (ε+a)b*,
e. (0|123)*

July 31, 2024 78


Kleene’s Theorem Part-I:
Statement:
• Any RL can be accepted by a FA.
Or
• Let ‘r’ be a RE, then there exists an NFA with Ʌ
transitions that accepts L(r).
Proof:
By induction on the number of operators in the
RE ‘r’ that there is an NFA ‘M’ with Ʌ-transitions
having one final state, and no transitions out of
this final state,
such that L(M)=L(r).
• Basis Step: ‘r’ has ∅ operators
‘r’ must be
The NFA-Ʌ for ‘r’ are

r=Φ r=Ʌ r=’a’

• Induction Hypothesis:
Assume that theorem is true for ‘r’ with fewer than
‘i’ operators, i>=1 =>1<=n<i
• Induction Step:
Let ‘r’ have ‘i’ operators.
Case 1: r=r1+r2
Let NFA-Ʌ Machine
M1=(Q1,∑1,δ1,q1, {f1})
L(M1)=L(r1)
Let NFA- Ʌ’s machine
M2=(Q2,∑2,δ2,q2,{f2})
L(M2)=L(r2)
Where Q1 and Q2 are disjoint.
q0->new initial state
f0->new final state
Construct M= (Q1UQ2U{q0,f0}, ∑1U∑2,δ,q0,{f0})
Where δ is defined by,
δ(q0,Ʌ)={q1,q2}

δ(q,a)=δ1(q,a) for q in Q1-{f1} & a in ∑1U{Ʌ}

δ(q,a)=δ2(q,a) for q in Q2-{f2} & a in ∑2U{Ʌ}

δ(f1,Ʌ)=δ(f2,Ʌ)={f0}
Thus all the moves of M1 and M2 are in M.
There is a path labelled x in M from q1
to f1 or a path in M2 from q2 to f2.
Hence L(M)=L(M1) U L(M2)
L(M)={x|x is in L(M1) or x is in L(M2)}
Case 2: r=r1 . r2
Let M1 and M2 be as in case 1

Construct M=(Q1UQ2,∑1U∑2,δ, {q1}, {f1})


Where δ is defined by,
δ(q,a)=δ1(q,a) for q in Q1-{f1} &a in ∑1U{Ʌ}
δ(f1,Ʌ)={q2}
δ(q,a)=δ2(q,a) for q in Q2-{f2} & a in ∑2U{Ʌ}
Hence
Every path in M from q1 to f2 is a path labelled by some string
x from q1to f1 followed by the edge from f1 to q2 labelled Ʌ
followed by a path labelled by some string ‘y’ from q2 to f2.
L(M)=L(M1) . L(M2)
• Case 3:r =r1*
Let M1=(Q1,∑1,δ1,q1,{f1}) & L(M1)=L(r1)
Construct M= (Q1U{q0,f0}, ∑1,δ1,q0,{f0})
Where δ is defined by
δ(q0,Ʌ)=δ(f1,Ʌ) = {q1,f0}
δ(q,a)=δ1(q,a) for q in Q1-{f1} & a in ∑1U{Ʌ}
Any path from q0 to f0 consists either of a path from q0 to f0
on Ʌ or a path from q0 to q1 on Ʌ, followed by some number
of paths from q1 to f1, then back to q1 on Ʌ, each labelled by
a string in L(M1) followed by a path from q1 to f1 on a string
in L(M1).
Hence L(M)= L(M1)*
• Hence any RL can be accepted by a NFA is proved.
Kleene’s Theorem Part -II
• Any language accepted by a finite automaton
is regular.
Conversion of DFA to Regular Expression

• Formula:

• Where
– i= Start state
– j = Final state
– k = No.of states
Problem 1: Obtain the regular expression for the
finite automata shown below:
Formula for RE:

Step 1: Rename the states:


Step 2: Find the values of i,j,k
i=1 (start state)
j=2 (final state)
k=2 (no. of states)
Substitute I,j,k in formula:

Find:
In:

When K=0:

Substitute in equation 2 and 3:


Substitute in equation 3:

When K=0:

Substituting in 1:
Substituting in 1:
2. Obtain the RE for the following DFA

You might also like