100% found this document useful (15 votes)
389 views

Theory of Computation Unit-1 - Notes

This is for Anna university regulation 2021 syllabus based on the notes
Copyright
© © All Rights Reserved
100% found this document useful (15 votes)
389 views

Theory of Computation Unit-1 - Notes

This is for Anna university regulation 2021 syllabus based on the notes
Copyright
© © All Rights Reserved
You are on page 1/ 100

UNIT – 1

AUTOMATA AND REGULAR EXPRESSIONS

Need for automata theory - Introduction to formal proof – Finite Automata


(FA) – Deterministic Finite Automata (DFA) – Non-deterministic Finite
Automata (NFA) – Equivalence between NFA and DFA – Finite Automata
with Epsilon transitions – Equivalence of NFA and DFA- Equivalence of
NFAs with and without ε-moves- Conversion of NFA into DFA –
Minimization of DFAs.

Prepared By,
Dr.P.Vijayalakshmi, Associate Professor
Mrs.R.Kamali, Assistant Professor
Mrs.K.Hemalatha, Assistant Professor
Department of Computer Science and Engineering
Knowledge Institute of Technology
Kakapalayam, Salem
1.1 Need for automata theory

Automata Theory is the way to how computation done by machine

Automata is the kind of machine which takes some string as input and this input

goes through a finite number of states and may enter in the final state.

This automaton consists of states and transitions. The state is represented by

circles and the Transitions is represented by arrows.

Example Switch

Push ON, OFF - States

ON OFF Push - Transitions

Push

There are four major families of automaton

1. Finite -State machine (Unit – I) Less Powerful

2. Pushdown Automata (Unit – III)

3. Linear – bounded Automata

4. Turing Machine (UNIT – IV) More powerful

Application of Theory of Computation

1. Compiler Design

2. Robotics

3. Artificial Intelligence
4. Knowledge Engineering

5. Vending Machines (working DFA Method)

Basic Concepts of Automata Theory

1. Symbol

2. Alphabet

3. String

4. Language

Symbol

→ Symbol is a character

→ It is the smallest building block

Examples

Alphabets : a, b, c,...............z / A, B, C, ......................Z

Digits : 0, 1, 2, ................................. 9

Special Characters : t, - , *, / , - , etc

Alphabet

→ Alphabet is a finite non – empty set of symbols


→ It is denoted by  (Sigma)

(Summation)

Examples

•  = {0, 1} is a set of binary digits


•  = {0, 1, 2, ......... 9} is a set of decimal digits
•  = { a, b, c } is a set of 3 lowercase letters
•  = { +, - , * , & ,...........} is a set of all special

Power of an Alphabet () :

Power of an  is the set of all strings of certain length formed form the  by
using Exponential notation.

It is denoted by k is the set of all strings of length k

There are two types

1. Kleen closure (k)


2. Positive Closure (t)

1. Kleen Closure

The Kleen Closure is also called star closure.

It is represented by occurrence of zero or more symbol over an alphabet

Example

Let  = { a, b } obtain kleen closure

Sol :

 * = 0 U 1 U 2 U 3...............

 * = { , a, b, aa, bb, ab, ba, aba, aaa, bbb, ................ }

String

• String is a finite sequence of symbols chosen from some alphabet


• String is denoted as W
• Length of a string

* Total number of symbols in the string

* It is denoted by / W /

Example

The given string W = 01001

/W/ = 5
Empty string

Empty string is the string with zero occurrence of symbol

It is denoted by e

The length of the empty string is /W/ = O

Operations on string

1. Concatenation
2. Transpose
3. Palindrome

1. Concatenation of String

In this operation two stings are combined together to form a single string

Example : 1

1. If X abc, Y = degs

Then XY = abcdegs
YX = degsabc

Example 2
If X = {Block }, y = { Red}

Then XY = { Black Red }


YX = {Red Black}

Transpose (Reverse) of string

The reverse of a string is formed by writing the symbols in reverse order

Let W be the string then reverse of the string denoted by W R

Example

W = 1011001

WR = 1001101

3. Palindrome of string

A palindrome is a string which is same whether it’s written backward or


forward
Example

Madam, Malayalam, Noon

Language

A language is a finite set of non – empty strings

(Or)

A language is a collection of strings

It is denoted by L

Operation of Languages

If L1 and L2 are two languages then,

1. Union of two languages is denoted as L1, U L2 (L1 or L2)


2. Concatenation of two languages is denoted by L1 – L2
3. Intersection of two languages is denoted by L1 n L2 (L1 AND L2)
4. Difference of two languages is denoted by L1 – L2

1.2 Introduction to Formal proof

Formal proof is one in which step by step procedure is used to solve the
problem

1. Deductive proof
2. Inductive Proof

1. Deductive Proof

A deductive proof consists of a sequence of statements whose truth leads from


some initial statements called hypothesis.

“If H then C “

Where H → Hypothesis

C → Conclusion
Example

Theorem 1 : If x  4, then 2x 2x 2

Sol

Here, H is x  4 → Hypothesis

C is 2 x x 2 → Conclusion

The above statement 2x  x2 will be true and it depends on the value of x

[ If x = 2 ; 22  22 = 4  4 Condition True

x = 3 ; 23  32 = 8  9 False

x = 4 ; 24  42 = 16  16 True

x = 6 ; 26  62 = 64  36 True

→ In the Same way the C → 2x x2 is true for certain values of x and false for
some other values.

→ If C is false for x = 3
→ So the terms 2X x2

Proof

→ If we name the given four positive integers names a, b, c and d


→ X is the sum of the squarer of four positive integers

(i e) (a2 + b2 + c2 + d2) → x2

Example 2

n
Prove 12 + 22 + 32 + ........... n2 =  i2 = n (n+1) (2n+1)
Wing
i=i 6
Mathematical induction
AU: May – 07, 16, Mark 6, May – 14, Mark -8

Solution

1. Basis

Let n = O

L.H.S. =O

R.H.S= O

R.H.S = L.H.S

Let n = 1

L.H.S = 12 = 1

1(1+1)(2+1)
R.H.S= =6 = 1
6 6

L.H.S = R.H.S

Hence Proved

Example 1

n
Prove by Induction on n that  i = n (n+1)
i=o 2
Prove 1 + 2 + 3+ .................. + n = n (n+1) (AU: May – 12 Mark 6)
2

Sol
1. Bans
Let n = O

L.H.S = O

R.H.S. = 0 (0 + 1) = 0
2
L.H.S. = R.H.S

Let n = 1

L.H.S = 1

R.H.S = 1 (1+1) = 2 = 1
2 2

L.H.S = R.H.S

2. Induction Hypothesis

Let, n = k

1 + 2 + 3 + ............................ + K = K (K + 1) → 2

3. Inductive Step

Now we assume that equations is true for n = k. And we will then check if it is
also true for n = k + 1 or not.

n=K+1

L.H.S = 1 + 2 + 3 +.....................+ K + K + 1

equ 1
K (K+1)(K+2)
= 2
K (K+1)(K+2)
L.H.S = → 2
2

K (K+1)
R.H.S=
2

n = K+1
K (K+1)
= 2
(K+1)
K (K+1)+ 2 (K+1) K (K+1)(K+2)
= R.H.S = → 3
2 2

2 = 3
L.H.S = R.H.S
Hence Proved
Example : 3

Prove 13+ 23 +.............. + n3 = n2 (n+1) 2 by mathematical


4
Induction (or)
n
Sol: Prove by mathematical Induction  i3 = {n (n+1) / 2}2
1. Basis AU: May – 17, Mark 16
Let n = O
L.H.S = O
R.H.S = O L.H.S = R.H.S
Let n = 1
L.H.S = 13

R.H.S = 1 (1+1) 2 = 1
4
L.H.S = R.H.S
2. Induction Hypothesis
Let n = K
Then
1

13 + 23 + ...................... + K3 = K2 (K+1) 2
4
3. Inductive Step
Now, we will try to prove it for n = K + 1
L.H.S
13 + 23 + ................. + K3 + (K + 1) = K2 (K + 1) 2 + K + 1) 3
equ 1 4
K2 (K+1) 2 + (K + 1) 3 = K2 (K + 1) 2 + (K + 1) 3
4 4
(K + 1) 2 [K2 + 4 (K + 1)] = (K + 1) 2 [K2 + 4 (K+1) ]
4 4

(K + 1) 2 [K2 + 4 K + 4)] = (K + 1) 2 [K2 + 4K+4) ]


4 4
(K + 1) 2 [K +2) 2] = (K + 1) 2 [K + 2) 2]
4 4
L.H.S = R.H.S
Hence Proved
Example 4
Prove 2n > n for all n ≥ 𝑂
Sol
1. Basis
Let n = 0
20 = L.H.S
R.H.S= 0
L.H.S = R.H.S
Let n = 1
L.H.S = 2
R.H.S= 1 True
Condition True
Len n = 2
L.H.S = 4
R.H.S= 2
Condition True
Induction Hypothesis
Let n = k
Then,
2k> K i.e 2 k – K > O; 2k K > t → 1
Inductive Step
2 n> n is true for all K ≤ n and now we have prove it for n = K + 1
Such that 2 K + 1> (K + 1)
From 1 2K+1 - (K+1)
= 2 k. 2 1 - (K+1)
From equ 1 2k = K + t
Then, (K + t) 2 – (K + 1)
= 2K + 2t – K – 1
= K + 2t – 1
i.e as positive number
This implies 2K+1 > K _+ 1
Hence 2n > n true
Example :5
Prove that for every integer n  O the number
Solution
1. Basis
Let n = O
42 (0) + 1 + 30+2 = 41 + 32 = 4 + 9 = 13
Let n = 1
42 (1) + 1 + 31+2 = 43 + 33 = 64 + 27 = 91
(Which is multiple of 13)
2. Induction Hypothesis
Let n = K
P (K) = 42K+1 + 3K+2
P (K) = 13m
Where m is some integer
3. Inductive Step
Thus we assume that given expression is true for P (K). Now we will prove
that is also true for P (K+1)
n = K+1 then
P(K+1) = 42(K+1)+1 + 3(K+1)+2
= 4(2K+2+1) + 3K+1+2
= 42K+1 42 + 3K+2 31
= 42 42K+1 + 42 (3K+2) – 3K+2) + 31. 3K+2
= 42 42K+1 + 3K+2 – 42 + 3K+2 + 31. 3Ki2
Taking common factors as 42 and 3K+2 we get.
= 42 (42K+1+ 3K+2)+3K_2(-42 + 3)
= 42 (13m) + 3K+2 (-13)
P (K+1) = 13 (42m – 3K+2)
This is multiple of 13for P(K+1)
This proves that given integer is multiple of 13
Example 6
Prove S (n) = 52n -1 is divisible by 24 for n  O
Solution
1. Basis
Let n = O
52(0) – 1 = O
Let n = 1
52(1) – 1 = 25-1 = 24 divisible by 24
Let n = 2
52(2) -1 = 625-1 = 624 divisible by 24
2. Induction Hypothesis
Let n = K
P (K) → 52K -1 → 24m
52K = 24 m +1
3. Inductive Step
Thus we assume that given expression is true for P (K). Now we will prove
that is also true for P (K+1)
Let n = K+1
P(K+1) = 5
= 52K 52 – 1
= (24m + 1) 52 - 1
= 24m.52 + 52 – 1
= 24m.52 + 24
P (K+1) = 24 (52m+1)
This is divisible by 24
Hence Proved
1.3. Finite Automata
Finite Automata is an abstract computing device
It is a mathematical model of a system with discrete inputs. Outputs, states and
a set of transitions from state to state that occurs on input symbols from the alphabet

Finite Automata Mode 1


i). Input tape
It is a linear tape having some number of cells
Each input symbol is placed in each cell
a b a b a b a

Finite Control

ii). Finite Control


The finite control decides the next state on receiving particular input from
input tape.
The tape reader reads the cells one by one from left to right and at a time only
one input symbol is read.

Representation of Finite Automata


The notation for representing the finite Automata
1). Transition Diagram
2). Transition Table
1. Transition Diagram
Finite Automata can be represented by a directed graph namely “Transition
Diagram”.
The steps for constructing the transition diagram.
1. The vertices in the transition diagram are the state of finite automata.
2. The edges represent the transitions. If there is any transition from state q, to
q2 on in input symbol ‘a’ then draw an edge from q to q2 labelled with ‘a’
3. The initial state should be indicated by an arrow in front.
S1 represent the state
→ Represent transition from one state to another
So
→ S0 } Start State
4. The find state will be indicated by double circles

S+

n
Final State

S+

Example

q0 q1
Start

Transition Table
The transition table is the tabular representation of the  transition of FA.
Whose rows denoted the states and column denote the input symbols.
Transition table

State / Input a b
→qo q1 -
* q1 qo q1

Transition Function’’
Transition is the process of moving from one state to another state on reading
an input symbol.
Normally the DFA defines a language as the; ET of all strings that result in a
sequence of state transitions from start state to end state.
 (q, a) = q1
This means that the state cannot be changed = o another state without reading
an input symbol.
For all strings ‘w’ and an input symbol ‘a’
 (q, aw) =  ((q, a) = w)
Extended Transition Function ‘’
The transition function  is extended to ‘’
Extended transition function ‘’ that operates on strings and states.
It describes what happens when we start in any state and follow any sequence
of inputs.
1 (q.w1 = 1 (q, xy) = (1 (q, x), y)
‘W’ is the string of the form ‘xy4’
5. Language of FA
The language of FA m= (Q,,,qo, F) is denoted by L(m) and it is defined as.
L (m) = { (W/’ (q0, W) is in F)}
That is the language of M is the set of strings ‘W’ that starts with state qo to
reach one of the accepting state.

Types of Automata

1. Deterministic Finite Automata (DFA)


2. Non – Deterministic Finite Automata (NFA)
3. Non – Deterministic Finite Automata With  transition (NFA - )

1. Deterministic Finite Automata (DFA)

Au: Dec – 07, 10, 11, 13 15, May

DFA, if there is only one path for a specific input from current state to next state.

DFA is a five tuple notation denoted as

A = (Q,,,qo, F)

1. The finite set of states Q

2. The finite set of input symbol 

3. The Transition function  (QX→ Q)

4. The start state qo (q0 Q)

5. A set of final states F (F C Q)


DFA Problems

1. Design DFA to L1 = set of all the strings that start with ‘O’

Solution

L = {0, 00, 01, 000, 001,................ }

Transition Diagram
q0 q1


q2
0,1

Dead state
Transition Table

0 1
State / Input
→q0 q1 q2
* q1 q1 q1
q2 q2 q2

Transition Function
Input 001
1 (q0, 001) = 1 ((qo, o), 01)
= 1 (q, 01)
= 1 ((q, 0), 1)
= 1 (q, 1)
= 1 ((q1, 1))
=  (q1,)
Construct DFA that accepts input strings of O’S and is that end with 11.
Solution
L = {011, 11, 1011, 0011, 01011, ........................ }
Transition Diagram

0 0 1
Start 1 1
q0 q1 q2

0
Transition Table

0 1
State / Input
→q0 q0 q1
* q1 q0 q2
* q2 q0 q2
Transition Function
Input 011
1 (q0, 011) = 1 ( (q0, 0), 11)
= 1 (q0, 11)
= 1 ((q0, 1), 1)
= 1 (q1, 1)
= 1 ( (q1, 1) )
= (q2, t) = q2 / Final State
3. Design FA which checks whether the given unary number is divisible by 3
Solution
The unary number is made up of ones
L = {111, 111 111, 111111111, ............................ }
Transition Diagram
1 1 1
q0 q1 q2 q3

Start
1

Transition Table
0 1
State / Input
→q0 q0 q1
* q1 q0 q2
Transition Function Input: 111
* q2 q0 q2
 (q0, 111) = 1 ( (q0, 1), 11)
= 1 (q1, 11)
= 1 ((q1, 1), 1)
= 1 (q2, 1)
= 1 ( (q2, 1) )
= q3 Final State
String Accepted
Construct DFA for set of all strings with three consecutive O’S at its end
Solution
L = {1000, 0001000, 100011, 0001, ............................. 3)
Transition Diagram

1 0 0 0 0
q0 q1 q2 q3

Start 1 1

5). Construct DFA for all the set of strings with {0, 1} that has even number of
O’S and I’ S
AU: Dec – 10, Magic

Solution

L = {0011, 00001111, 1010, 0101,..................... }

Transition Diagram

1
q0
1 q1
Start 1

0 0 0 0

q2 1 q3

Transition Table

0 1
State / Input
→q0 q2 q1
* q1 q3 q0
* q2 q0 q3
q3 q1 q3

1) Construct a DFA that accepts all the strings on {0, 1} except those Containing
the substring 101

AU: M -07, mark6, May -16, Marks 8


Solution

L = {01011, 10, 100,....................... }


The DFA that does not accept the language containing substring 101
0 0 1, 0
1 q2
0 1
q0 q3 q4

1 0

q3

1
Change Non – Final state into Final State
Final state into non – Final State

0 0 1,0
q0
1 q2 0 q3
1
q4
Start
1 0

q3
1

7. Construct a DFA accepting all string W over {0, 1} such that number of 1’ S in W
is 3 mod 4

Solution

AU: Dec – 11, Mark 8 1

0 0 0 0
q0
1 q2 1 q3
1
q4

1
1
8. Give DFA the following language over the alphabet
1. Number of 1’S is a multiple of 3
2. Number of 1’ S is not a multiple of 3
Solution
1). L = {111, 111111, 111111111 …}
1 1 1
q0 q1 q2 q3
Start
1 1
q4

2. Change Non – Final into Final state


1 1 1
q0 q1 q2 q3
Start
1 1
q4

9. Given  = {a, b} Construct a DFA which recognize the language L = {bm abn
:m, n>0}

Solution

L = {bab, bbab, babb ..................... }

L = b+ ab+

b b
b a b
q0 q1 q2 q3
Start
10. Construct DFA for set of all strings {o, 1} with 011 as substring
Solution
L = {1 011, 011, 100110, ................. }

1 0 1/0
0 1 1
q0 q1 q2 q3
0

1. Construct DFA for the set of all strings with equal number of O’S & 1’ S
starting with “0”
L = {01 0101, 0011,...................... }
1 0 0

q0 q1
1

2. Construct DFA for the language L = {anb, n 0)


Solution
L = {b, ab, aab, aaab,…................. }
a

q0
b q1

3. Construct DFA for set of all string S {0, 1} with strings ending with 01
Solution
L = {001, 101, 1101, ..................... }
1 0
0 1
Start q0 q1 q2
0
2. Non – Deterministic Finite Automata (NFA)
NFA allows zero one or more transitions from a state on the same input symbol
The NFA can be formally defined as a collection of 5 – tuples
A = (a,,,qo, F)
1. The finite set of states Q
2. The finite set of input symbol 
3. The transition function  (QX→ 2Q)
4. The start state qo (q0 Q)
5. A set of final states F (F C Q)
1. Construct a NFA for a language L which accepts all the strings in which the third
symbol from right end is always a over  = {a, b}
Solution
L = {a a b a, b a a a, a a b b, .................. }
a/b
a a,b a,b
q0 q1 q2 q3

Transition Table
a b
State / Input
q0 {q0, q1} {q0}
q1 {q2} {q2}
q2 {q3} {q3}
q3 - -

Transition function
Input baaa
 (q0, baaa) = 1 ((q0, b) aaa)
= 1 (q0, aaa)
= 1 ((q0, a) aa)
= 1 ((q0, q1) aa)
= 1 ((q0, q) U (q1, a), a)
= 1 (([q0, q1} U {q2}), a)
= 1 ({q0, q1, q2}), a)
= 1 ( (q0, q1, q2), a)
= 1 ((q0, a) U S (q1, a) U S (q2, a))
= 1 ({q0, q, } U { q2 } U {q3})
= 1 q0, q1, q2, q3)
= 1 q0, baaa)  F
= q0 q1, q2, q3)  {q3}
String Accepted
2. Construct NFA for FA over {a, b} containing substring aabb
AU : May – 09, Mark – 4→
Solution
L = {aaabbb, baabbb,............................. }
Transition Diagram
a,b a,b
a b b b
q0 q1 q2 q3 q4

Transition Table
a b
State / Input
q0 {q0, q1} {q0}
q1 {q2} -
q2 - {q3}
q3 - {q4}
q4 {q4} {q4}
Transition Function
Input aaabb
 (q0, baaa) = 1 ((q0, b) aaa)
= 1 (q0, q1), aaa)
= 1 ((q0, q1), a), abb)
= 1 ((q0, q, q2), abb)
= 1 ((q0, q1, q2), a) bb)
= 1 ( q0, a) US (q1, a) US (q2, a), bb)
= 1 ({qo, q1, q2,} bb)
= 1 (((q0, q1, q2) b) b)
= 1 ((q0, b) U S (q1, b) U  (a, b), b)
= ({q0, q3}, b)
= 1 ((q0, q3), b)
= 1 ( ({q0, q4}, }
= {q0, q4}
= 1 (q0 aaabb)  F
= {q0, q4}  {q4}
= {q4} Final state
String Accepted
3. Construct NFA that end with string II for set of all strings {0, 1}
Solution
L = {0 11, 1011 111, 0011, .................... }
0/1 1

q0 1 q1 1 q2

Finite Automata with Epsilon Transition


The  - transition is NFA are given in order move from One state to another
without wing any symbol from input set 

A = (Q,, , qo, F) be a NFA with 


Where
1. The finite set of state Q
2. The finite set of input symbol 
3. The transition function  (Q X {  U  } → 2Q)
4. The start state qo
5. The final state F c Q
Construct NFA with  which accepts a language visiting the strings of any number of
a’s followed by number of b’ s followed by any number of c’ s .
Finition
a b c

E q1 E
q0 q2
Start

Finition of  - closure of q0 ( - closure (q0)) denotes set of all states P such that there
is a with (or) transition from q0 to P on  - transition.

4). Construct NFA for set of all strings {0, 1} that end with three consecutive I’ S at
its end
Solution
L = {1111, 0111, 1011,. .............. }

0/1 1

1 1 1
q0 q1 q2 q3
Start
0 0
5. Construct NFA with 011 as substring solution
L = {011, 10110, 10111, .................. }

1/0 1/0

0 1 1
q0 q1 q2 q3

6. Construct NFA accepting binary string with two consecutive O’


Solution
L = {100, 1001, 0000 ................. }
1/0 0 1
q0 q1 q1
1 0

Transition Table


a b c
State / Input
 -
 
q0 q0 q1

 
q1 q1 q2

  
q2 q2

Closure
 - Closure (q0) – {q0, q1, q2}
Self state + E – reachable state
 - Closure (q1)- {q1, q2}
Self state (q1) + q2 is a state obtained from q1 with  input
 - Closure (q2)- {q2}
Transition Function
Input = aabbcc
 (q0, aabbcc = Ⱶ (q0, aabbcc)
= Ⱶ (q0, abbcc)
= Ⱶ (q0, bbcc)
= Ⱶ (q0, bcc)
= Ⱶ  (q0, cc)
= Ⱶ  (q1, c)
= Ⱶ  (q2, E)
= q2 Final State
String Accepted
2. Consider the following NFA  - Closure of all input symbols for each state and
check whether the string “abb” is accepted.
a b c
 
q0 q1 q2

a b
Solution
 - Closure of all the state
 - Closure (q0) = {q0, q1, q2}
 - Closure (q1) = {q1, q2}
 - Closure (q2) = {q2}

Transition Table

a b c 
State / Input
 
q0 {q0, q1} {q}

 
q1 {q1, q2} {q2}

  
q2 {q2}
Transition Function
Input string = abb
 ( q0, ) =  closure (q0) = {q0, q1, q2}
 (q0, a) =  closure ( ( (q0, ), a))
=  closure ( (q0, q1, q2), a)
=  closure ( (q0, a) U  (q`, a) U  (q2, a) )
=  Closure (q0, q1)
=  closure (q0) U  closure (q1)

 (q0, a) = {q0, q1, q2}


 (q0, ab) =  closure ( ( (q0, a), b))
=  closure ( (q0, q1, q2), b))
=  closure ( (q0, b) U  (q1, b) U  (q2, b))
=  closure (q1, q2)
=  closure (q1) U  closure (q2)
 (q0, a) = {q1, q2}
(q0, abb) =  closure ( ( (q0, ab), b))
=  closure ( (q1, q2), b))
=  closure ( (q1. B) U  (q, b))
=  closure (q1, q2)
=  closure (q1) U  closure (q2)
 (q0, abb) = {q1, q2}
 (q0, abb) n F = {q1, q2} n {q2}
= {q2} → Final State
So the string “abb” is accepted
Construct NFA with  that end with string for the set of all strings {0, 1}
0, 1

 q1 1 q2  q3 1 q4
q0

Construct NFA  with all as substring for H1 the set of all string {0, 1}

0,1 0,1

 q1 0 q2  q3 1 q4  1
q0 q5 q6

Construct NFA -  with ab as substring for the set of strings {a, b}

Set of strings {a, b}

a, b a, b

 q1 a q2  q3 b
q0 q4

Construct NFA -  for L = { an b, n>0} for all strings { a, b}


n = 1, 2, 3, .....................
L = { ab, aab, aaab,...................}
Problems for converting of NFA with  to NFA without  to NFA without 
Convert the following NFA with S to NFA without 
AU: Dec – 09, Mark 8
0 1 2

 q1 
q0 q2

Solution
Transition table for NFA

0 1 2 
State / Input
→ q0 {q0}   {q}
 
q1 {q1} {q2}

  
q2 {q2}
Step 1
 - Closure (q0) = { q0, q1, q2}
 - Closure (q1) = { q1, q2}
 - Closure (q2) = {q2}
Step 2: Processin g state q0 :
 (q0, ) =  Closure (q0) = { q0, q1, q2}
 (q0, 0) =  Closure ( ((q0, ), 0)
=  Closure ( (q0, q1, q2), 0)
=  Closure ((q0, 0) U  (q1, 0) U  (q2, 0))
=  Closure (q0)

 (q0, 0) = {q0, q1, q2}


 (q0, 1) =  closure ( ( (q0, ), 1)
=  closure ( (q0, q1, q2), 1)
=  closure (q1)
 (q0) 1) = {q1, q2}

 (q0, 2) =  closure ( (q0, ), 2)


=  Closure ( (q0, q1, q2), 2)
=  Closure (q2)
 (q0, 2) = {q2}
Processing State 9:
 (q, 0) =  Closure ( ((q1, ), 0))
=  Closure ((q1, q2) 0)
=  Closure ( (q1, 0) U  (q2, 0)
=  Closure (q)
 (q1, 0) = 
 (q1, 1) =  - Closure ( ((q1, ), 1))
=  Closure ( (q1, q2), 1)
=  Closure ( (q1, 1) U  (q2, 1)
=  Closure (q1)
 (q1, 1) = {q1, q2}
 (q1, 2) =  - Closure ( ((q1, ), 2))
=  - Closure ((q1, q2) 2)
=  - Closure ((q2) U  (q2 2)
=  Closure (q2)
 (q1, 2) = {q2}
Processing state q2:
 (q2, 0) =  Closure ( (q2, ), 0))
=  Closure ( (q2), 0)
=  Closure ()
 (q2, 0) = 

 (q2, 1) =  Closure ( ( (q2, ), 1))


=  Closure ( (q2), 1)
=  Closure ()
 (q2, 1) = 

 (q2, 2) =  Closure ( ((q2, ), 2))


=  Closure ((q2), 2)
=  Closure (q2)

 (q2, 2) = q2
Transition table for DFA: without:
0 1 2
State / Input
{q0, {q1, q2} {q2}
→ q0
q1,q2}
 {q2}
q1 {q1, q2}

q2   {q2}

Transition Diagram for NFA without 


0 1 2

0,1 q1 1,2
q0 q2

PROBLEMS FOR CONVERSION OF NFA TO DFA

1. Convert the following NFA to DFA

0/1

0 1
q0 q1 q2

Solution

Transition Table for NFA :


0 1
State / Input
{q0}
→ q0 {q0, q1}

q1 {q2}
 
q2

Here staring state is {q0}


For converting DFA consider [q0] = A
Step 1 :
(A,O) =  (q0, 0)

= (q0, q1) = B

(A, 1) =  (q0, 1)

(q0) = A

Step 2:

(B, O)=  (q0, q1), 0)

=  (q0, 0) U  (q1, 0)

= (q0, q1) = B

(B, 1) =  ((q0, q1), 1)

=  (q0, 1) U  (q1, 1)

= (q0, q2) = C

Step 3:

(C, O)=  (q0, q2), 0)

=  (q0, 0) U  (q2, 0)

= (q0, q1) = B

(B, 1) =  ((q0, q2), 1)

=  (q0, 1) U  (q2, 1)

= (q0) = A

Transition table for DFA

0 1
State / Input
→ q0 [q0, q1]
[q0]

[q0, q1] [q0, q1] [q0, q2]

[q0,q2] [q0, q1] [q0]

Transition Diagram for DFA


1 0
0
[q0] q0, q1

1 0 1

[q0,q2]

Convert to DFA the following NFA

0 1

→P {p, q} {p}

q {r} {r}

r {r}
{s}
*s {s}
Solution
Transition diagram for NFA
0, 1 0,1

0 0 0
p q r s
1

Here staring state is {P}


For converting DFA consider {P} = A
Step 1
(A, 0) =  (P, 0)
= (p, q) → B
(A, 1) =  (P1, 1)
= (P) → A
Step 2:

(B, O)=  (p, q), 0)

=  (q1, 0) U  (q, 0)

= (p1 q1 r) → C

(B, 1) =  ((p, q)), 1)

=  (p1) U  (q, 1)

= (p, r) → D

Step 3:

(C, O)=  (p1 q1 r), 0)

=  (p1 0) U  (q1, 0) U  (r, 0)

= (p, q, r, s) → E

(C 1) =  ((p1 q1 r), 1)

=  (p1 1) U  (q1, 1) U  (r, 1)

= (p r) → D

Step 4:

(D, O) =  (p, r), 0)

=  (p, 0) U  (r, 0)
= (p, q, s) → F

(D1) =  ((p, r), 1)

=  (p, 1) U  (r, 1)

= [P] → A

Step 5:

(E, O)=  (p, q, r, s), 0)

=  (p, 0) U  (q, 0) U  (r, 0), (s, 0)

= (p, q, r, s) → E

(E 1) =  ((p, q, r, s), 1)

=  (p, 1) U  (q, 1) U  (r, 1) U (s, 1)

= [p, r, s] → G

Step 6:

(F, O) =  (p, q, s), 0)

=  (p, 0) U  (q, 0) U  (s, 0)

= (p, q, r, s) → E

(F 1) =  ((p, q, s), 1)

=  (p, 1) U  (q, 1) U  (r, 1) U (s, 1)

= [p, r, s] → G

Step 7:

(G, O) =  (p, r, s), 0)

=  (p, 0) U  (r, 0) U  (r, 0), (s, 0)


= (p, q, s) → F

(G 1) =  ((p, r, s), 1)

=  (p, 1) U  (r, 1) U  (s, 1)

= [p, s] → H

Step 8:

(H, 0) =  (p, s), 0)

=  (p, 0) U  (s, 0)

= (p, q, s) → F

(H 1) =  ((p, s), 1)

=  (p, 1) U  (s, 1)

= [p, s] → H

Transition table for DFA

State / Inputs 0 1
→ [p] [p, q] [p]
[p,q] [p,q,r] [p,r]
[p,q,r] [p,q,r,s] [p,r]
[p,r] [p,q,s] [p]
* [p,q,r,s] [p,q,r,s] [p,r,s]
* [p,q,s] [p, q, s] [p, s]
* [ p, r, s] [p] [p, s]
Transition Diagram for DFA :

1 1
[ p] 0 [p, q] 0 [p, q, r] 1 [p, r]

0 0

[p, q, r, s] 0 [p, q, s]

1 0 0

[p, q, s] 0 0
1 [p, q]

Determine the DFA from a given NFA

M = [ {q0, q1}, {a, b}, , q0, {q1}) with the state table diagram for  given
below

AU Dec – 16 Marks 10, May – 18, Marks 13

 a b
q0 [q0, q1] [q1]
q1  [q0, q1]

Solution

Let the DFA M1 = (Q, , 1, q0, F)


= {(qo, q1), (a, b),, q0, {q1}}

Starting state = [q0]

Final state = [q1]

Transition table for NFA

State / Inputs a b
→ [q0] {q0, q1} {q1}
* q1  {q0, q1}
Here starting state is [q0]

For converting DFA consider [q0] = A

Step 1:

(A, a) =  (q0, a)

= [q0, q1] → B

(A, b) =  (q0, b)

= [q] → C

Step 2

(B, 0) =  (q0, q1), a)

=  (q0, a) U (q1, a)

= {q0, q1} → B

(B, 1) =  ((q0, q1), b)

=  (q0, b) U (q1, b)

= (q0, 4) → B
Step 3

(C, a)=  (q1, a)

= 

(C, b) =  (q1, b)

= (q0, q1) → B

Transition table for DFA

a b
→ [q0] {q0, q1} {q1}
[q0, q1) [q0, q1] {q0, q1}
[q1]  [q0 q1]

Transition Diagram for DFA

a [q0,q1 a, b
q0 ]

b b

[q]

4. Construct NFA that accepts the set of all strings {a, b} ending with “aba” as and
contract
DFA
Solution
Transition diagram for NFA
a,b

a b q2 a
q0 q1 q3
Transition table for NFA:
State / Input a b
→ q0 {q0, q1} {q0}
q1  {q2}
q2 {q3} 
* q3  

Here initial state is [q0] = A


Step 1
(A, a) =  (q0, a)
= (q0, q1) → B
(A, b) =  (q0, b)
(q0) → A
Step 2
(B, a) =  (q0, q1), a)
=  (q0, a) U (q1, a)
= [q0, q1] → B
(B, b) =  (q0, q1), b)
=  (q0, b) U  (q1, b)
= [q0, q2] → C
Step 3
(C, a) =  (q0, q1), a)
=  (q0, a) U  (q2, a)
= [q0, q1, q3] → D
(C, b) =  (q0, q2), b)
=  (q0, b) U  (q2, b)
= [q0] → A
Step 4
(D, a) =  (q0, q1, q3), b)
=  (q0, b) U  (q1, b) U  (q3, b)
= [q0, q1] →B
(D, b) =  (q0, q1, q2), b)
=  (q0, b) U  (q1, b) U  (q3, b)
= [q0, q2] →C

State / Input a b
→ [q0] [q0, q1] [q0]
[q0, q1] [q0, q1] [q0, q2]
[q0, q2] [q0, q1, q3] [q2]
* [q0, q1, q3] [q0, q1] [q0, q2]

Transition Diagram for DFA


b a

→ [q0 a [q0, q1]

b b a

[q0, q2] [q0, q1, q2]

a
b
Construct DFA for the following NFA
0 1

q0 0 q1 1 q2
Solution
Transition table for NFA

State / Input 0 1
→ q0 {q0, q1} 
q1  {q2}
q2  {q2}

Hero the initial state is [q0] → A


(A, 0) =  (q0, 0)
= [(q0, q1] →B
(A, 1) =  (q0, 1)
= 
Step 2
(B, 0) =  (q0, q1), o)
=  (q0, o) U (q1, o)
= [q0, q1] → B
(B, 1) =  (q0, q1), 1)
=  (q0, 1) U  (q1, 1)
= [q2] → C
Step 2
(C, a) =  (q2,0))
= 
(C, 1) =  (q2, 1)
= [q2] → C
Transition table for DFA
State / Input 0 1
→[q0] [q0, q1] 
[q0, q1] [q0, q1] [q2]
* [q2]  [q2]

Transition Diagram for DFA


0 1

[q0] 0 [q1] 1 [q2]

Conversion of NFA with  to NFA without 


1). Construct an NFA without  transitions for the NFA
AU: May – 12 Mark 8

0 1

q0 q1

Solution
Transition Table for NFAE
State / Input 0 1 
→ q0 {q0}  {q1}
q1  {q2} 

Step 1
 - Closure {q0} - {q0, q1}
 - Closure {q1}- {q1}
Step 2
 (q0, ) =  - Closure (q0) = {q0, q1}
 (q0, 0) =  - Closure ( ( (q0, ) ), 0)
=  - Closure ((q0, 0) U  (q1, 0))
=  - Closure {q0, U }
=  - Closure {q0}
 (q0, 0) = {q0, q1}
 (q0, 1) =  - Closure ( ( (q0, ) ), 1)
=  - Closure ((q0, q1) 1)
=  - Closure {q0, 1) U (q1, 1))
=  - Closure ( {} U {q1})
=  - Closure (q1)
 (q0, 1) = {q1}
Step 3 : Processing state q1
 (q1, ) =  - Closure (q1) = {q1}
 (q1, 0) =  - Closure ( ((q0, )), 0)
=  - Closure ( (q1, 0))
=  - Closure ()
 (q1, 0) = 
 (q1, 1) =  - Closure ( ( (q1, ), 1))
=  - Closure ( (q1, 1))
=  - Closure (q1)
 (q1, 1) = {q1}
Transition Table for NFA
State / Input 0 1
→ q0 {q0, q1} {q1}
* q1  {q1}
Transition Diagram
0 1

q0 0, 1 q1

Note
\ State {q0} and {q1} becomes final state because  - Closure of q0, q0 contains
q2
Convert the following NFA with  to NFA without

b
a 
q0 q1 q2

Transition Table of NFA - 

State / Input a b E
→ q0 {q1}  
* q2  {q2} 

Step 1
 - Closure (q0) - {q0}
 - Closure (q1) - {q1, q 2}
 - Closure (q2) - {q2}

Step 2 : Processing State q0


 (q0, ) =  - Closure (q0, ) = {q0}
 (q0, a) =  - Closure ( ( (q0, ) ), a))
=  - Closure ((q0, a))
=  - Closure {q0}
 (q0, a) = {q0, q1}
 (q0, b) =  - Closure ( ( (q0, b) ))
=  - Closure ()
 (q0, b) = 
Processing of q1 State
 (q1, a) =  - Closure ( (q1, )), a))
=  - Closure ( (q1, q2), a))
=  - Closure ( (q1, a) U  (q2, a)
=  - Closure ( U )
=  - Closure ()
 (q1, a) = 
 (q1, b) =  - Closure ( ( (q1, ), b))
=  - Closure ( (q1, q2), b))
=  - Closure ( (q1, b) U  (q2, b))
=  - Closure ( U q2)
=  - Closure (q2)
 (q1, b) = {q2}
Processing state of q2
 (q2, a) =  - Closure ( (q2, )), a)
=  - Closure ( (q2), a))
=  - Closure ()
 (q2, a) = 
 (q2, b) =  - Closure ( ( (q2,b)
=  - Closure (q2)
 (q2, b) = {q2}
Transition Table
State / Input a b
→ q0 {q0, q2} 
* q1  {q2}
* q1  {q2}

Transition Diagram
a b b
q0 q1 q2

a
Note : State q1, q2 becomes the final state because  - Closure, q1 and q2 contains the
final state of q2.
4. Convert the following NFA with  to NFA without 

5
4
8 9
0 → 1 → 2 → 3

6 → 7


Solution
Transition Table for NFA – 
State / Input a b E
→0 {1}  
1  {2} 
2   {3, 9}
3   {4, 6}
4 {5}  
5   {8}
6  {7} 
  {8}
8   {3 9}
*9   

Step 1
 - Closure (0) = {0}
 - Closure (1) = {1}
 - Closure (2) = {2, 3, 4, 6, 9}
 - Closure (3) = {3, 4, 6}
 - Closure (4) = {4}
 - Closure (5) = {3, 4, 5, 6, 8, 9}
 - Closure (6) = {6}
 - Closure (7) = {3, 4, 6, 7, 8, 9}
 - Closure (8) = { 3, 4, 6, 8, 9}
 - Closure (9) = {9}

Transition Table for NFA

State / Input a b
→0 {1} 
1  {2, 3, 4, 6, 9}
*2  {3, 4, 7, 6, 8, 9}
3 {3, 4, 5, 6, 8, 9} {3, 4, 7, 6, 8, 9}
4 {3, 4, 5, 6, 8, 9} 
*5 {3, 4,5, 6, 8, 9} {3, 4, 7, 6, 8, 9}
6  {3, 4, 6,7, 8, 9}
*7 {3, 4, 4, 5, 6, 8, {3, 4, 6, 7, 8, 9}
9}
*8 {3, 4, 5, 6, 8, 9} {3, 4, 6, 7, 8, 9}
*9  

a b a,b
5
→ 0 1 2 3 4
b
8
a,b
a, b 6

a, b
9

Conversion of NFA -  to DFA

Convert the following NFA with  to equivalent DFA

b  a 
q0 q1 q2

a
b

Solution

Transition Table

State / Input a b 
→ q0  {q0} {q1}
q1 {q3}  {q2}
* q2 {q1} {q0} 

Step 1
 - Closure {q0} - {q0, q1, q2}

 - Closure {q1} - {q1, q2}

 - Closure {q2} - {q2}

Step 2
 - Closure {q0} – {q0, q1, q2}

We will call this state as A

Step 2: Processing state A

 (A, a) =  - Closure ( (A, a))


=  - Closure ( (q0, q1, q2) a)
=  - Closure ( (q0, a) U  (q1, a) U  (q1, a)
=  - Closure {a}
 (A, a) = {q1, q2}
Let us call it as state B
 (A, b) =  - Closure ( (A, b))
=  - Closure (  (q0, q1, q2), b)

=  - Closure (  (qo b) U  (q1, b) U  (q2, b))

=  - Closure (q0)

 (A, b) = {q0, q1, q2}

Processing state B

 (B, a) =  - Closure ( (q0, q2), a)


=  - Closure ( (q1, a) U  (q2, a))
=  - Closure (q1)
 (B, a) = {q1, q2}
 (B, b) =  - Closure ( (q1, q2), b)
=  - Closure ( (q1, b) U  (q2, b))
=  - Closure (q0)
 (B, b) = {q0, q1, q2}
Transition Table
State / Input a b
→A {q1, q2} { q0, q1, q2}
*B {q1, q2} {q0, q1, q2}

Transition Diagram
b a a
q0, q1, q2 q1, q2

b
Consider following NFA with 

State / Input a b c E
→p {p} { q} {r} 
q {q} {r}  {p}
• r {r}  {p} {q}

Convert it to its equivalent DFA

AU : May – 11, Mark 6


Solution

ab a
p q

c c b e

Step 1

 - Closure (p) = { p}
 - Closure (q) = {p, q}
 - Closure (r) = {q, r}

Step 2

 - Closure (p) = {p} Call it as state A

Processing state A

 (A, a) =  - Closure (  (A, a))

=  - Closure ( (p, a))

=  - Closure (p)

 (A, a) = {p}

 (A, b) =  - Closure ( (A, b))

=  - Closure ( (p, b))

=  - Closure (q)

 (A, b) = {q, p}

 (A, c) =  - Closure ( (A, c))


=  - Closure ( (p, c))

=  - Closure (r)

 (A, c) = {q, r} → C

Processing state B

 (B, a) =  - Closure ( (B, a))

=  - Closure ( (p, q), a)

=  - Closure ( (p, a) U  (q, a)

=  - Closure (p, q)

=  - Closure (P) U  - Closure (q)

 (B, a) = {p, q}

 (B, b) =  - Closure ( (B, b))

=  - Closure ( (p, q), b)

=  - Closure (p, b) U  - (q, b))

=  - Closure (q, r)

=  - Closure (q) U  - Closure (r)

 (B, b) = {p, q, r} →D

 (B, c) =  - Closure ( (B, c))

=  - Closure ( (p, q), c))

=  - Closure (p, c) U  - (q, c))

=  - Closure (r,)
=  - Closure (r)

 (B, c) = {q, r}

Processing state C

 (C, a) =  - Closure ( (C, a))

=  - Closure ( (q, r), a)

=  - Closure (q, a) U  - (r, a))

=  - Closure (q u r)

=  - Closure (r) u E – closure (r)

 (C, a) = {p,q, r}

 (C, b) =  - Closure ( (C, b))

=  - Closure ( (q, r), b)

=  - Closure (q, b) U  - (r, b))

=  - Closure (r, u)

=  - Closure (r)

 (C, b) = {q, r}

 (C, c) =  - Closure ( (C, c))

=  - Closure ( (q, r), c)

=  - Closure ( (q, c) U  - (r, c))

=  - Closure (, u p)
=  - Closure (p)

 (C, c) = {P}

Processing state D

 (D, a) =  - Closure ( (D, a))

=  - Closure ( (p, q, r), a)

=  - Closure ( (p, a) U  (q, a) U  (r, a)

=  - Closure (p u q u r)

=  - Closure (p) U  - Closure () U  - Closure (r)

 (D, a) = {p, q, r}

 (D, b) =  - Closure ( (D, b))

=  - Closure (  (p, q, r), b)

=  - Closure ( (p, b) U  (q, b) U  (r, b)

=  - Closure (q u r u )

=  - Closure (q) U  - Closure (r)

 (D, b) = {p, q, r}

 (D, c) =  - Closure ( (D, c))

=  - Closure ( (p, q, r), c))

=  - Closure ( (p, c) U  (q, c) U  (r, c)

=  - Closure (r u  u p)

=  - Closure (r) U  - Closure (p)


 (D, c) = {p, q, r}

Transition Table

State / Input a b c
→{p} {p} { p, q} {q, r}
{p, q} {p, q} {p, q, r} {q, r}
* {q, r} {p, q, {p, q, r} {p, q, r}
r}
Transition Diagram
a

p
c b
q, r
c

b c

a b abc
p, q p, q, r

Consider the following NFA -  for an identifier consider the each state and find it’s
equivalent DFA
5 6
Letter
7 10
1 2 3 4

8 9
Digit 1 AU: Dec -15, Mark 10

Solution

Transition Table

State / Input letter Digit 


→1 {2}  
2   {3}
3   {4,10}
4   {5, 8}
5 {6}  
6   {7}
7   {3, 10}
8  {9} 
9   {7}
10   

Step 1
 - Closure (1) = {1}
 - Closure (2) = {2, 3, 4, 5, 8, 10}
 - Closure (3) = {3, 4, 5, 8, 10}
 - Closure (4) = {4, 5, 8}
 - Closure (5) = {5}
 - Closure (6) = {6, 7, 10, 4,5, 8}
 - Closure (7) = {7, 10}
 - Closure (8) = { 8}
 - Closure (9) = {9, 7, 9, 5, 8, 10}
 - Closure (10) = {10}

Step 2

 - Closure (1) = {1} Call it as state A

 (A, letter) =  - Closure ( (A, letter))

=  - Closure ( (1, letter))

=  - Closure (2)

 (A, letter) = {2, 3, 4, 5, 8, 10} →B


 (A, digit) =  - Closure ( (1, digit))

= 

 (A, digit) = 

Processing state B

 (B, letter) =  - Closure (  (B, letter))

=  - Closure ( (2, 3, 4, 5, 8, 10), letter)

=  - Closure ( (2, letter) U  (3, letter) U

 (4 let) U  (5, let) U  (8, let) U  (10, let)

=  - Closure (6)

 (B, letter) = {4, 5, 6, 7, 8, 10}

 (B, digit) =  - Closure ( (B, digit))

=  - Closure (9)

= {9, 7, 4, 5, 8, 10}

 (B, digit) = {4, 5, 7, 8, 9, 10}

Processing state C

 (C, letter) =  - Closure ( (C, letter))

=  - Closure ( (4, 5, 6, 7, 8, 10), letter)

=  - Closure (6)

 (C, letter) = {4, 5, 6, 7, 8, 10}

 (C, digit) =  - Closure ( (C, digit))

=  - Closure (9)
 (C, digit) = {4, 5, 7, 8, 9, 10}

Processing state D

 (D, letter) =  - Closure (  (4, 5, 7, 8, 9, 10), letter)

=  - Closure (6)

 (D, letter) = { 4, 5, 6, 7, 8, 10}

 (D, digit) =  - Closure (  (D, digit))

=  - Closure (9)

 (D, digit) = {4, 5, 7, 8, 9, 10}

State / Input letter Digit


→A B 
*B C D
*C C D
*D C D

Transition Diagram

Letter

→ A B

digit Letter

digit Letter
D C
digit letter

The two states C and D are equivalent. Similarly state B and C are equivalent
B = C = D

The minimized DFA will be

Letter letter/digit

→ A B

4). Convert the following NFA -  to NFA and then convert the resultant NFA to
DFA

D AU: Dec – 18, Mark – 13

1 1 0 1

A B C

E E

Solution

Conversion of NFA -  to NFA

Step 1

 - Closure (A) = {A, B, C}


 - Closure (B) = {B, C}
 - Closure (C) = {C}
 - Closure (D) = {D}

Processing State A

 (A, 0) =  - Closure ( ( - Closure (A), 0))

=  - Closure ( (A, B, C), 0)

=  - Closure ( (A, 0) U  (B, 0) U S (C, 0))

=  - Closure ()
 (A, 0) = 

 (A, 1) =  - Closure ( (A, 1))

=  - Closure ( (A, B, C), 0)

=  - Closure ( (A, 0) U  (B, 0) U  (C, 0))

=  - Closure ( (A) U  - Closure (D) U  - Closure (C)

 (A, 1) = {A, B, C, D}

Processing State B

 (B, 0) =  - Closure ( (B,), 0)

=  - Closure ( (B, C), 0)

=  - Closure ( (B, 0) U  ((C, 0))

=  - Closure ()

 (B, 0) = 

 (B, 1) =  - Closure ( (B, C), 1)

=  - Closure ( (B, 1) U  (C, 1))

=  - Closure (D, C)

 (B, 1) = {D, C}

Processing State C

 (C, 0) =  - Closure ( (C,), 0)

=  - Closure ( (C, 0))

=  - Closure ()
 (C, 0) = 

 (C, 1) =  - Closure ( (C, 1))

=  - Closure (C)

 (C, 1) = {C}

Processing State D

 (D, 0) =  - Closure ( (D,), 0)

=  - Closure ( (D, 0))

=  - Closure (B)

 (D, 0) = {B, C}

 (D, 1) =  - Closure ( (D,), 1)

=  - Closure ()

 (D, 1) = {}

Transition Table

State / Input letter Digit


→A  {A, B, C, D}
*B  {C, D}
*C  {C}
D {B, C} 
Transition Diagram for NFA

→→A 1 B

1 1 1 1
D C
0 1

Conversion of NFA to DFA

Initial state A

 (A, 0) = 

 (A, 1) =  {a, 1}

 (A, 1) = {A, B, C, D} → P

 (P, 0) =  ((A, B, C, D), 0)

=  ((A, 0), U (B, 0), U (C, 0) U (D, 0)

=  ( U  U  U {B, C})

 (P, 0) = {B, C} → Q

(P, 1) =  ((A, B, C, D), 1)

=  (A, 1) U (B, 1) U (C, 1) U (D, 1)

 (P, 1) = {A, B, C, D}

 (Q, 0) =  (Q, 0)

=  ((B, C), 0)

=  ((B, 0) U (C, 0))

 (Q, 0) = 

 (Q, 1) =  (B, c), 1)

=  ((B, 1) U  (C, 1)))

=  ((B, 0) U (C, 0))

 (Q, 1) = {C, D} → R
 (R, 0) =  (R, 0)

=  ((C, D), 0)

=  ((C, D) U (D, 0))

 (R, 0) = {B, C}

 (R, 1) =  (R, 1)

=  ((C, D), 1)

=  ((C, 1) U (D, 1))

 (R, 1) = {C,}

 (R, 1) = {C} → S

 (S, 0) =  (C, 0)

 (C, 0) = 

 (S, 1) =  (C, 1)

 (S, 1) = C

Transition Table

State / Input letter Digit


→A  P
P Q P
R Q R
R Q C
S  C

Transition Diagram
1

→ A 1 P

0 1
Q 1 R 1 S

Equivalence of Finite Automata

Conversion of NFA with  to NFA without E

In this method we try to remove all the  - transitions from given NFA

1. Find out all the  transitions from each state from Q. That will be called as 
- Closure {q}where q;  Q
2. Then ’ transitions can be obtained the ’ transitions means an  - closure
on  moves.
3. Step 2 is repeated for each input symbol and each state of given NFA
4. Using the resultant states the transition table for equivalent NFA without 
can be built.

Theorem:

If L is accepted by NFA with  transitions, then there exists L which accepted


by NFA without  transitions.

Au: May – 09, Mark – 12, Dec – 09, 13 Mark 8

Proof

Let M = (Q,,, q0, F) be an NFA with  - transitions

Construct M’ = (Q,’ q0, F’) where


F1 = FU (q0) if  - closure contains state of F otherwise.

M’ is a NFA without  moves. The’ function can be denoted by \ with some


input.

For example’ (q, a) =” (q, a) for some q in Q and a from 

We will apply the method of induction with input x the X will not be 
because.

1 (q0,) = {q0}

” (q0,) =  - closure (q0)

Therefore we will assume length of string to be 1

Basis

1X1 = 1. Then X is a symbol a

1 (q0, a) = ” (q0, a)

Induction

1X1 > 1 = Let X = Wa

1 (q0, wa) = ” (1, (q0, w), a)

By inductive hypothesis

1 (q0, w) = ” (q0, w) = P

Now we will show that

1 (P, a) =  (q0, wa)

But

1 (P, a) = U ’ (q, a) = U ” (q, a)


Q in P q in P

As P = ” (q0, w)

We have U” (q, a) = ” (q0, wa)

q in P

Thus by definition”

1 (q0, wa) =” (q0, wa)

Rule for conversion

1 (q, a) =  - Closure ( ( (q,), a))

Where  (q, ) =  - closure (q)

Conversion of NFA to DFA

Theorem

Let L be a set accepted by Non – deterministic finite automation. Then there


exists a deterministic finite automation that accepts L

(Or)

Prove that “A language L is accepted by some DFA if and only if L is accepted


by some NFA

AU: May – 05, Dec – 14, 15 Mark 10

Proof

Let M = (Q,,, q0, F’)

The states of M1 are all the subset of M’.

The Q’ = 2Q
F’ be the set of all the final states in M

The elements in Q’ will be denoted by [q1, q2, q3 ................... q1] and elements in Q are
denoted by {q0, q1, q2, ........................}The [q1, q2, ...................... q1] will be assumed
as one state in Q’ if in the NFA q0 is initial state it is denoted in DFA as q0’ = [q0]

We defined

’ (q1, q2, q3, ........................qi], a) = [ P1, P2, P3,................. P3] if and only if

 ({q1, q2, q3,......................qi}, a) = {P1, P2, P3,. ..................... Pi}

This means that whenever in NFA at the current states {q1, q2, q3..............................qi}
if we get input a and it goes to the next states {P1, P2, .........Pj} then while
constructing DFA for in the current state is assumed to be [P1, P2 ......................Pj]

On applying  function on each of the states q1, q2, q3................qi the new
states may be any of the states from [P1, P2, ................. Pj]

The theorem can be proved with the induction method by assuming length of
input string X

1 (q0, X) = [q1, q2, ........................ qi]

Basis

If and only if

 (q0, X) = {q1, q2, q3, ................................. qi}

1.e : 1X1 = 0, that means X is  then q0 = [q0]

Induction

If we assume that the hypothesis is trust for the input string of length in or less
than m.

Then if X a is a string of length m + 1


Then the function’ cloud be written as

1 (q0, X a) = 1 (1 (q0, X), a)

By the induction hypothesis

1 (q0, X) = [P1, P2, ....................... Pj]

If and only if

 (q0, X) = {P1, P2, P3 ................. Pj}

By definition of ’

1 ([P1, P2, ...................... Pj], a) = [r1, r2,. ................ rk)

If and only if

 ({P1, P2,…………….. Pj) a) = {r1, r2, .........................rk)

Thus

1 (q0’ Xa) = [r1, r2,… .................... rk]

If and only if

 (q0, Xa) = {r1, r2, ..........................rk)

Is shown by inductive hypothesis

Thus L (m) = L (m)

Conversion of NFA with e to DFA

AU: May – 05, 11, Dec – 06, 08, 13, 15]

Prove that there exist a DFA for every NFA - 

Step 3
Consider M – (Q,,, qo, F) is a NFA with  we have to convert this NFA with
 to equivalent DFA denoted by

MD = (QD, , D, q0, FD)

Then obtain

 - Closure (q0) = {P1, P2, P3 ................................. Pn} then

[P1, P2, P3,....................... Pn]  QD

Step 2

We will obtain  transitions on [P1, P2, P3 .......................... Pn] for each input

D ([P1, P2,……………. Pn], a) =  - Closure ( (P1, a) U  (P2a) U  (Pn,


a))

n
= U  - Closure d (P;, a)
i=1

Where a is input e 

Step 3

The states obtained [P1, P2, P3……………….Pn]  QD. The states containing
final state in Pi is a find state in DFA

Additional forms of proof

1. Proofs about sets


2. Proofs by contradiction
3. Proofs by counter example

1. Proofs about sets

The set is a collection of elements or items.


This Proof is of the kind “if and only if” that means an element X is in A if and
only if it is in E.

We will make use of sequence of statements along with logical justification in


order to prove this equivalence.

Let us prove P U Q = Q U P

Proving LHS

S.No Statement Justification


1. X is in PUQ Given
2. X is in P or X is in a 1. And by definition of Union
3. X is in P or X is in P 2. And by definition of Union
4. X is in QUP 3. Rule (2) and by definition of union.

Proving RHS

S.No Statement Justification


1. X is in PUQ Given
2. X is in Q or X is in P 1. And by definition of Union
3. X is in Q or X is in Q 2. And by definition of Union
4. X is in PUQ 3. Rule (2) and by definition of union.

Hence PUQ = QUP. Thus A = B is true as element X is in B if and only if X is in A.

Proof by contradiction

Another way to prove the statement “if H then C” is by the form.

“H and not C implies Contradiction


Here we assume that the hypothesis and the negation of the conclusion as true
and then we complete the proof by showing that something known to be false

This form of proof is called proof by contradiction”.

3. Counter Examples

A counter example to an statement is a situation which shows that the


condition than have true premises and a false contusion

Example 1

If a food is a fruit, then it is an Apple → statement

Condition Conclusion

Condition is true but conclusion is false

Mango is a counter example

Mango is a fruit but not an Apple

Example 2

Proof: if X integer and X is prime, then X is odd Disproof. The .integer 2 is a


prime but 2 are even.

MINIMIZATION OF AUTOMATA

DFA minimization stands for converting a given DFA to its equivalent DFA
with minimum number of states. DFA minimization is also called a optimization of
DFA and uses positioning algorithm.

Automation of DFA

 

Equivalence Myhill Nerode

Theorem Theorem / Table Method


Inaccessible State

All thase states which can never be reached from the initial state are called as
inaccessible states.

→ Accepting state = Final state

→ Non Accepting state = Reaming State

→ Do not compare the accepting state to a non accepting state.

→ Do not compare same state with same state

PROBLEMS

Final the equivalence and Minimization of finite automata for the following FA

Start 0 1 1 0
→ A B C D

2 1 0
E G H
→ F 1

Solution 0

Accepting state = C

Non accepting state = A, B, D, E, F, G, H

We do not compare

(A, C) (B, C)

(D, C) (E, C) (F, C)

(G, C) (H, C)
B
X X
C
X
D
X
E
X √
F
X
G
X
H

A B C D E F G

Transition table for DFA

States / Input O 1

A B F

B G C

*C A C

D C G

E H F

F C G

G G E

H G C

From the transition table (B, H)

 (B, O) = G  (B, O) = C (B, H) are equivalent

 (H, O) = G  (H, 1) = C

II Pair(D, F)

 (D, O) = C  (D, 1) = G (D, F) are equivalent


 (F, O) = C  (P, 1) = G

III Pair (A, B)

 (A, O) = B  (A, 1) = F

 (B, O) = G  (B, 1) = C F, N, F

Pair (A, B) is not equivalent

IV Pair (A, D)

 (A, O) = B  (A, 1) = F Pair (A, D)is not equivalent

 (D, O) = C  (P, 1) = G

 

F, N, F N, F

Pair (A, E)

V Pair (A, E)

 (A, O) = B  (A, 1) = F Pair (A, E) is equivalent

 (E, O) = C  (E, 1) = G

 

E N, F

VI Pair (A, F)

 (A, O) = B  (A, 1) = F Pair A, F is not equivalent

 (F, O) = C  (F, 1) = G

 

F, N, F N, F
VII Pair (A, D)

 (A, O) = B  (A, 1) = F Pair (A, G)is not equivalent

 (G, O) = G  (G, 1) = E

 
F, N, F N, F
III Pair (A, H)

 (A, O) = B  (A, 1) = F (A, H) is not equivalent

 (H, O) = C  (H, 1) = C
 
N, F F + N, F

B
X X
C
X X
D
√ X
E
X X √
F
X X
G
X X
H

A B C D E F G

I Pair (B, D)

 (B, O) = G  (D, 1) = C Pair (B, D) not equivalent

 (D, O) = C  (D, 1) = G
II Pair(B, E)

 (B, O) = C  (B, 1) = C Pair (B, E) not equivalent

 (E, O) = H  (E, 1) = F

III Pair (B, F)

 (B, O) = G  (B, 1) = C Pair (B, F) not equivalent

 (F, O) = C  (F, 1) = G

IV Pair (B, G)

 (B, O) = G  (B, 1) = C Pair (B, G) is not equivalent

 (G, O) = G  (G, 1) = E

VI Pair (D, E)

 (D, O) = C  (D, 1) = G (D, E) are equivalent

 (E, O) = H  (E, 1) = F

VII Pair (D, G)

 (D, O) = C  (D, 1) = G (D, G) is not equivalent

 (G, O) = G  (G, 1) = E

VII Pair (D, H)

 (D, O) = C  (D, 1) = G Pair (D, H) is not equivalent

 (H, O) = G  (H, 1) = C

VIII Pair (E, F)

 (E, O) = H  (E, 1) = F Pair (E, F) is not equivalent


 (F, O) = C  (F, 1) = G

VI Pair (E, G)

 (E, O) = H  (E, 1) = F Pair (E, G) is not equivalent

 (G, O) = G  (G, 1) = E

III Pair (E, H)

 (E, O) = H  (E, 1) = F Pair (E, H) is not equivalent

 (H, O) = G  (H, 1) = C

I Pair (F, G)

 (F, O) = C  (F, 1) = G Pair (F, G) is not equivalent

 (G, O) = G  (G, 1) = E

I Pair (F, H)

 (F, O) = C  (D, 1) = G (D, F) are equivalent

 (G, O) = G  (H, 1) = C

Pair (G, H)

 (G, O) = G  (G, 1) = E Pair (G, H) is not equivalent

 (H, O) = G  (H, 1) = C

= equivalent states = (B, H) (D, F) (A, E) Minimized Transition Table DFA

States / Input O 1

A B D

B G C

*C A C

D C G
B X

C X X

D X X X

E √ X X √

F X X X √ X

G X X X X X X

H X √ X X X X X

A B C D E F G

Transition Diagram for minimized DFA

1 0
A=E G D=F

0 0 0 1 0

B =H C
1

1
2. Minimize the AU: Dec – 18

b
4
a a

2
b b
5

a a

1
6

b a a b

3 b

b
7

Solution

Accepting state = 1, 2, 7

Non Accepting State = 3, 4, 5, 6

We do not compare the states = (1, 3) (1, 4) (1, 5), (1, 6)

(2, 3) (2, 4) (2, 5) (2, 6)

(7, 3) (7, 4) (7, 5) (7, 6)

Equivalent state = { (1, 2) (1, 7) (2, 7)}


2 √

3 X X

4 X X

5 √ X

6 X X

7 √ √ X X X X

1 2 3 4 5 6

Transition table for DFA

States / Input a b

2 3

*2 4 5

3 6 7

4 5 4

5 7 5

6 2 7

*7 7 4

Steps

i) Pair (3, 4)

 (3, a) = 6  (3, b) = 7 (3, 4) not equivalent

 (4, a) = 5  (4, b) = 4

N, F F, N, F
ii) Pair (3, 5)

 (3, a) = 6  (3, b) = 7 (3, 5) not equivalent

 (5, a) = 7  (5, b) = 5

F, N, F F, N, F

iii) Pair (3, 6)

 (3, a) = 6  (3, b) = 7 (3, 6) not equivalent

 (6, a) = 2  (6, b) = 7

F, N, F F

iv) Pair (4, 5)

 (4, a) = 5  (4, b) = 4 (4, 5) not


equivalent

 (5, a) = 7  (5, b) = 5

F, N, F N, F

ii) Pair (4, 6)

 (4, a) = 5  (4, b) = 4 (4, 6) not equivalent

 (6, a) = 2  (6, b) = 7

F, N, F F, N, F

iii) Pair (5, 6)

 (5, a) = 7  (5, b) = 5 (5, 6) not equivalent

 (6, a) = 2  (6, b) = 7
F N, F

Thus we do not get any of the mentioned pairs as equivalent pair.

The only equivalent pair (1, 2), (1, 7), (2, 7) we eliminate state and 7 by
replacing them by 1.

Minimized Transition

Table for DFA

States / Input a b

→ 1 3

3 6 1

4 5 4

5 1 5

6 1 1

Minimized Transition Diagram for DFA

a b a
3 6
1 b

a,b
5 b
4
a
b

4. Define distinguishable and indistinguishable states using table filling method


minimize the following DFA Draw the transition diagram of resulting DFA
0 1

→A B E

B C F

*C D H

D E H

E F I

*F G B

G H B

H I C

*I A E

Accepting state = C, F, I
Non Accepting state = A, B, D, E, G, H
Equivalent state = { (C, F) (C, I) (F, I)}
We do not compare the states = (A, C)(B, C)(D, C)(E, C) (G, E)(H, C)
(A, F)(B, F) (D, F)(E, F) (G, F)(H, F)
(A, I) (B, I) (D, I) (E, I) (G, I) (H, I)

B X

C X X

D X

E X

F X X √ X X

G X X

H X X X

I X X √ X X √ X X

A B C D E F G H
Steps

i) Pair(G, H)

 (G, O) = H  (G, 1) = B (G, H) not equivalent

 (H, O) = I  (H, 1) = C

F, N, F F, N, F

ii) Pair (G, H)

 (E, O) = F  (E, 1) = I (E,G) not equivalent

 (G, O) = H  (G, 1) = B

F, N, F F, N, F

IIi) Pair (E, H)

 (E, O) = F  (E, 1) = I (E, H) Equivalent

 (H, O) = I  (H, 1) = C

Equivalent Final Final

v) Pair (D, E)

 (D, O) = E  (D, 1) = H (D, E) not equivalent

 (E, O) = F  (E, 1) = I

F, N, F F, N, F

v) Pair (D, G)

 (D, O) = E  (D, 1) = H (D, G) Equivalent

 (G, O) = H  (G, 1) = B
F, N, F F, N, F

i) Pair(D, H)

 (D, O) = E  (D, 1) = H Pair (D, H) not equivalent

 (H, O) = I  (H, 1) = C

F, N, F F, N, F

ii) Pair (B, D)

 (B, O) = C  (B, 1) = F (B, D) not equivalent

 (D, O) = E  (D, 1) = H

F, N, F F, N, F

iii) Pair (B, E)

 (B, O) = C  (B, 1) = F (B, E) Equivalent

 (E, O) = F  (E, 1) = I

Final Final Equivalent

iii) Pair (B, G)

 (B, O) = C  (B, 1) = F (B, E) Equivalent

 (G, O) = H  (G, 1) = B

Final + NF F + N.F

iv) Pair (B, H)

 (B, O) = C  (B, 1) = F (B, H) Equivalent

 (H, O) = I  (H, 1) = C

F+F N+F
i) Pair(A, B)

 (A, O) = B  (A, 1) = E (G, H) not equivalent

 (B, O) = C  (B, 1) = F

NF + F FF + F

ii) Pair (A, D)

 (A, O) = B  (A, 1) = E (A, D) equivalent

 (D, O) = E  (D, 1) = H

N, F + N F N, F

iii) Pair (A, E)

 (A, O) = B  (A, 1) = E

 (E, O) = F  (E, 1) = I

NF+F FN+NF

iv) Pair (A, G)

 (A, O) = B  (A, 1) = E (A,G) Equivalent

 (G, O) = H  (G, 1) = B

Equivalent

v) Pair (A, H)

 (A, O) = H  (A, 1) = E

 (H, O) = I  (H, 1) = C

F, N, F F, N, F
B X

C X X

D √ X X

E X √ X X

F X X √ X X

G √ X X √ X X

H X √ X X √ X

I X X √ X X √ X X

A B C D E F G H

The blank entries represent equivalent states

A = G = D

B = H = E

C = I = F

Reduced DFA Table

State / Input 0 1

→A B B

B C C

• C A B
Minimized transition diagram for DFA

0, 1
A=G=D B=H=E
→ 1

C=I=F

0 0,1

4). Construct the transition diagram

1 0 1 0 0
A
→ 0 B C D 0 E 1

0 1
F
H G
1 0

1 0

Solution

Initial state : A

Final state : D

We do not compare the state : (A, D) (B, D)(C, D)(E,D) (F, D)(G, D)
(H, D)

D X X X

E X

F X

G X
H X

A B C D E F G

Transition Table

State / Input 0 1

→A B A

B A A

• C D B

• D D A

E D F

F G E

G F G

H G D

i) Pair(A, B)

 (A, O) = B  (A, 1) = A (A, B) are not equivalent

 (B, O) = A  (B, 1) = C

NF NF

ii) Pair (A, C)

 (A, O) = B  (A, 1) = A

 (C, O) = D  (C, 1) = B

F, N, F NF

iii) Pair (A, E)

 (A, O) = B  (A, 1) = A
 (E, O) = D  (E, 1) = F

F, N, F NF

iv) Pair (A, F)

 (A, O) = B  (A, 1) = A

 (F, O) = G  (F, 1) = E

i) Pair(A, G)

 (A, O) = B  (A, 1) = A (A, G) equivalent

 (G, O) = F  (G, 1) = G

ii) Pair (A, H)

 (A, O) = B  (A, 1) = A (A, H) are not equivalent

 (H, O) = G  (H, 1) = D

FNF

i) Pair(B, C)

 (B, O) = A  (B, 1) = C ( B, C) are not equivalent

 (C, O) = D  (C, 1) = B

F, N. F

ii) Pair (B, E)

 (B, O) = A  (B, 1) = C (B, E) are not equivalent

 (E, O) = D  (E, 1) = F

i) Pair(B, F)

 (B, O) = A  (B, 1) = C N.F. : String (i.o)


 (F, O) = G  (F, 1) = E  (B, O) = D

 (F, O) = D

(B, F) are equivalent

i) Pair(B, G)

 (B, O) = A  (B, 1) = C (B, G) are not equivalent

 (G, O) = F  (G, 1) = G

Not equivalent N.F (B, O)= D

(G, O) = F

v) Pair (B, H)

 (B, O) = A  (B, 1) = C (B, H) are not equivalent

 (H, O) = G  (H, 1) = D

F, N.F

i) Pair(C, E)

 (C, O) = D  (C, 1) = B K, E are not equivalent

 (E, O) = D  (E, 1) = F

F Equivalent

ii) Pair (C, F)

 (C, O) = D  (C, 1) = B

 (F, O) = G  (F, 1) = E

F, N.F

ii) Pair (C, G)


 (C, O) = D  (C, 1) = B

 (G, O) = F  (G, 1) = G

F, N.F

iv) Pair (C, H)

 (C, O) = D  (C, 1) = B

 (H, O) = G  (H, 1) = D

i) Pair(E, F)

 (E, O) = D  (C, 1) = B

 (F, O) = G  (H, 1) = D

ii) Pair (E, F)

 (E, O) = D  (E, 1) = F

 (F, O) = G  (F, 1) = E

F.N.F
iii) Pair (E, G)
 (E, O) = D  (E, 1) = F

 (G, O) = F  (G, 1) = G

F, N.F

iii) Pair (E, G)

 (E, O) = D  (E, 1) = F

 (G, O) = F  (G, 1) = G

iii) Pair (E, H)


 (E, O) = D  (E, 1) = F

 (H, O) = G  (H, 1) = D

F, N.F

ii) Pair (F, G)

 (F, O) = G  (F, 1) = E String 10

 (G, O) = F  (G, 1) = G (A, 10) = D

N.F (G, O) = F

ii) Pair (F, H)

 (F, O) = G  (F, 1) = E

 (H, O) = G  (H, 1) = D

F, N.F

ii) Pair (G, H)

 (G, O) = F  (G, 1) = G A, G (B, F) (C, F)

 (H, O) = G  (H, 1) = D

F, N.F

B X

C X X

D X X X

E X X √ X

F X √ X X X

G √ X X X X X
H X X X X X X X

A B C D E F G

Minimized Transition Table for DFA

State
0 1
/ Input
A B A A=G

B A C B=F
C=E
C D B

*D D A

H A D

Minimized Transition Diagram for DFA

1 0 1
A=G B=F C, E
0 1

0 1 1 0

H D
1 0

You might also like