0% found this document useful (0 votes)
29 views71 pages

Unit - 1 TOC

Uploaded by

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

Unit - 1 TOC

Uploaded by

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

CS8501- THEORY OF

COMPUTATION
capabilities of today‟s computer.

In 1940‟s and 1950‟s, the machines were simplified to finite automation machines.
Researchers proposed the automation model in order to model the functions of human brain.

The linguist Noam Chomsky made a study on formal grammars in late 1950‟s .These
grammars provided the basis of compliers.

S.Cook extended Turing‟s study in 1969, which separated the problems as solvable
and unsolvable. He classified problems as NP-Hard and as NP-Complete.

Example of a Finite state system: Switch operation

PUSH

Start
OFF ON

PUSH
1.2 Theory of Computation

Here,

 When the electric switch = “ON” indicates logic „1‟ when pushed from start state.

 Goes to „OFF‟ state when pushed from „ON‟ state.

Example: Pattern searching of sting = “then”

t h e n
t th the then

Example: Pattern searching of sting = “automata

a u t o m a t
a au aut auto autom automa automat

a automata

BASIC MATHEMATICAL NOTATION AND TECHNIQUES


Basic Mathematical
Objects Sets [A]
A set is collection of elements of finite number.
Example:
A = {10, 01, 00, 11}
B = {w | w is a set of prime numbers less than 100}
wB
C = {r | r is a set of strings generated from vowels}
rC

Subset [  ]
Let A1and A2 are two sets, then A1 is a subset of A2 [indicated as A1  A2 ], if every
element of A1 is in A2.
Example:
A1 = {1, 2, 3, 4}
A2 = {1, 2, 3, 4, 5}
 A1  A2
Automata Fundamentals 1.3

Complement of a Set [A']

Let A be a set of finite number of elements. Then A' is a set of elements that are not
the elements of set A. [A'  A]

Example:

A1 = {a, e, i, o, u}

A' = { all alphabets except vowels}

Operations on Sets
Union [ ]

The union of two sets results in a set containing the elements of both the sets (without
repeatition of elements).

Example:

A1 = {1, 3, 5, 7}

A2 = {1, 2, 3, 4,}

A1 A2 = {1, 2, 3, 4, 5, 7}

Intersection [ ]

The intersection of two sets contains a set of elements that are available in both the
sets.

Example:
A1 = {1, 3, 5, 7}
A2 = {1, 2, 3, 4}
A1 A2 = {1, 3}

Difference [ - ]

The difference of two sets A and B results in the set of elements that are in A and not
in B.

Example:

A1 = {1, 3, 5, 7}
A2 = {1, 2, 3, 4}
A1 – A2 = {5, 7}  [A1 – A2 = A1 A2']
1.4 Theory of Computation

Laws on Sets
Commutative Laws
A B =B A
A B=B A
Associative Laws
A (B C) = (A B) C
A (B C) = (A B) C

Distributive Laws
A (B C) = (A B) (A C)
A (B C) = (A B) (A C)

Idempotent Laws
A A= A
A B=A
Absorptive Laws
A (A B) = A
A (A B) = A
De Morgan‟s Laws
(A B) ' = A' B'
(A B) ' = A' B'

Other Laws
(A') ' =A
A A' = 
A A' = Universal set, ‟U‟
A  =A
A  = 
A U =U
A U =A
Automata Fundamentals 1.5

Equality of sets [ = ]

Two sets are set to be equal if both the sets contain the same elements.
Example:
A = {1, 3, 5, 7}
B = {set of odd numbers less than 8}
Then, A = B

Empty set [ ]
A set containing no elements is said to be an empty set.
Example:
A = { set of natural numbers between 1 and 2}
 A =  or { }

Power of a set [ Ak ]
The power of a set A, denoted by A k is the set containing all elements of A, whose
length is less than or equal to k.
Example:
A = {1, 2}
A2 = { , 1, 2, 12}

Relationship of Sets
Relation of two sets is the association of one set with other.

Types based on the properties of sets


1) Reflexive: Every element of the set is associated with itself.
2) Symmetric: Let a, b ϵ A, then a is related to b, and b is related to a [aRb = bRa]
3) Transitive: If a  b and b  c, then a  c. It is denoted as: aRb, bRc then aRc.

Logic
Logic deals with the logical proportions and connectives.

Proposition
Proposition is a meaningful, objective, declarative statement that has a truth value as
true / false.
1.6 Theory of Computation

Example:
0  1, New Delhi is the capital of India, 5 is an even number, Chennai is in AP.

Connective
Logical connective is a compound statement formed from simple proportions using a
connective such as
  and connective /conjunction
  or connective /disjunction
  Not / Negative connective
Example

p Q p^q pq p q
T T T T F F

T F F T F T

F T F T T F

F F F F T T

Implication
It is a conditional statement of the form, “if p then q” (p implies q), where p and q are
simple proportions.

It is denoted as p  q = p  q

p q pq

T T T

T F F

F T T

F F T

Proofs
A proof is single line / multiline derivation that provide a convincing argument to
make a statement true.
Proofs can be derived from assumptions or facts or existing derivations.
Automata Fundamentals 1.7

Forms of Proofs
There are basically two forms of proofs. Thery are,
1) Deductive Proofs
2) Inductive Proofs

Deductive Proofs
These are sequence of statements which are derived from any assumption (hypothesis)
or a given initial statement to a conclusion statement.
The proofs are generated using some facts / accepted logics.
Example: If x  4, 2x  x2

The hypothesis statement  x  4

Conclusion statement  2x  x2

This can be provided as substitution statement as:


When x = 4:- 24  42  16  16  True

When x = 5:- 25  52  32  25  True

When x = 6:- 26  62  16  36  True

When x = 3:- 23  32  16  9  False

Hence proved.

Inductive Proof
It has a sequence of recursive / parametrical statements that handle the statement with
lower values of its parameters.
There are two types of inductions, namely -
 Mathematical Induction
 Structural Induction

Mathematical Induction
This follows induction principle that follows two steps, namely-
 Basis of Induction: It considers „n‟ of f(n) as the lowest possible integer (n = 0 or 1)
and prove the given statement using substitution.
1.8 Theory of Computation

 Inductive step: Assume that the given statement is true for nth value and prove the
statement for n = n+1.

This applies for all integer related statement.

Structural Induction
Structural Induction follows the mathematical induction concept but applies for trees
and expressions.

Example: Every tree has one node than it has edges, balancing parenthesis etc.

Additional forms of proofs


 Proofs about sets
 Proof by contradiction
 Proof by counter example
 Direct Proofs

Proofs about set

Proof about the set includes the proofs on the properties of the sets.

Example: Commutative law, Distributive law etc

Consider, A = P  Q, B = Q  P

Since P  Q = Q  P ( by Commutative law), we prove that A = B.

This proof follows “if and only if” type. This is A= B is true if and only if
P  Q = Q  P is true.

Proof by contradiction
The proof p  q is true, then the method follows a contradictory assumption that
p  q and from the result, it proves the assumption is false and thus proves, p  q.

Example:

To prove P  Q = Q  P, we first assume that P  Q ≠ Q  P.

Now consider an element, x from P that is also in Q.

xϵPQ

Thus all the element of P is taken and compared with that of Q.


Automata Fundamentals 1.9

Finally , P  Q = Q  P is proved [contradiction to our assumption]

Proof by Counter Example

Given a statement, that can be proved to be true for a domain of input instances, and
false for other inputs.

Example: a mod b ≠ b mod a

Let a = 5 and b = 10

a % b = 5 % 10 = 5

b % a = 10 % 5 = 0

Hence a % b  b % a, the statement is true only if a = b.

Thus proved.

Inductive Proofs

These are special type of proofs used to prove recursively defined objects.

It consists of sequence of parameterized statement that uses the statement itself with
lower values of its parameter.

Two steps

1. Basis of Induction  We start with the lowest possible value.

Example: To prove f(n) . We take n = 0 or 1 initially.

2. Inductive step Here we prove if f(n) is true, f(n+1) is also true.

SAMPLE PROBLEMS:
1. Prove that: 1+2 +3+ ………+n (n+1) / 2 using method of induction for (n>0).
Proof:
Basis of Induction
Let n = 1 [We cannot take n = 0 since U.H.S starts from 1]
L.H.S = 1
111 1  2  2
R.H.S    1
2 2 2
1.10 Theory of Computation

Since L.H.S = R.H.S  Proved.

Inductive Step
n  n 1
We have 1 2  3  n  
2
Sub n = n + 1
n

L.H.S 1 + 2 + 3 +…… + n = i
i1

When we substitute n = n+1,


n 1 5 4
L.H.S = i
i1
Eg: i i  5
i1 i1

= i  (n  1)
i1

n(n  1)
=  (n  1)
2
n(n  1)  2(n  1)
=
2

n2  n  2n  2
=
2

n2  3n  2
= ----- (1)
2

n(n  1)
R.H.S =
2
When we substitute n=n+1,

(n  1)((n  1)  1)
R.H.S =
2
(n  1)(n  2)
=
2

n2  2n  n  2
=
2
Automata Fundamentals 1.11

n2  3n  2
= ----- (2)
2
From (1) and (2), L.H.S = R.H.S
So the given hypothesis is proved.

2. For all n  0  i  n(n  1)(2n 1)



n
2

i1 6

Basis of induction
Let n=1 (we can‟t take n=0 since i=1 in L.H.S)
n

L.H.S = i
i1
2
= 12 = 1

1(1 1)(2(1) 1) 1(2)(2 1) 2(3) 6


R.H.S =    1
6 6 6 6
L.H.S = R.H.S.
Hence basis of induction is proved.

Inductive step
n
n(n  1)(2n 1)

i
i1
2
6

L.H.S: Sub n=n+1


n 1
= i
i1
2

n 3 2

=  i2  (n  1)2
i1
 i2   i2  (3)2
i1 i1

n(n)(2n  1)
= (n  1)2
6

n(n  1)(2n  1)  6(n  1)2


=
6

n(2n2  n  2n 1)  6(n2  2n 1)


=
6
1.12 Theory of Computation

2n3  n 2  2n2  n  6n2  12n  6


=
6

2n3  9n2  13n  6


= ----- (1)
6

R.H.S: Sub n=n+1

n(n 1)(2n 1) (n 1)((n 1) 1)(2(n 1))



6 6

(n  1)(n  2)(2n  2  1)
=
6

(n2  2n  n  2)(2n  3)
=
6

2n3  3n2  4n2  6n  2n2  3n  4n  6


=
6

2n3  9n2  13n  6


=
6
From (1) and (2) L.H.S = R.H.S
The hypothesis is proved.

3) P.T for every integer, n  0 the number 42n1  3n2 is a multiple of 13.

Solution
Basis of induction
Let n = 0

L.H.S = 42(0)1  3(0)2

= 41  32  4  9

= 13 multiple of 13
Inductive proof
Let n=n+1

42n1  3n2  42(n1)1  3(n1)2

= 42n21  3n3
Automata Fundamentals 1.13

= 42n3  3n3

= 42n1.42  3n2.31

= 16(42n1 )  3(3n2 )

= 13(42n1 )  3(42n1 )  3(3n2 )

= 13(42n1 )  3(42n1  3n2 )



Multiple of 13

= 13(42n1 )  3(13n)

= 13(42n1  3n) multiple of 13

The hypothesis is proved.

4) Show that n4  4n2 is divisible by 3 for n  0


Basis of induction
Consider n = 0

n4  4n2  0  0  0  3 0  Divisible by 3
Hence proved.
Inductive step

Let us assume that n4  4n2 is divisible by 3 for n, and try to prove the same for n=n+1

n4  4n2  (n 1)4  4(n 1)2

Using induction hypothesis,

(n 1)4  4(n 1)2  n4  4n2 ((n+1) - nth term = a multiple of 3)

 n4  4n3  6n2  4n 1 4n2  8n  4  n4  4n2

 n4  4n3  2n2  4n  3  n4  4n2

 4n3  6n2  4n  3

 4n(n2 1)  6n2  3


1.14 Theory of Computation

 4n(n 1)(n 1)  6n2  3  Multiple of 3 for all n  0



Divisible by 3

FINITE AUTOMATA
Basic Definitions

Alphabet (  )

An alphabet is a finite, non empty set of symbols.

Example:  0,1 Binary alphabet


 a, b, c, .... zLower - case letters set
 1, 2,3 Digits
String (w)
A string is a finite sequence of symbols chosen from some alphabet.

Example:

01101 is a string from  0,1

aa, bb, ab, ba are strings from  a, b

Empty string () / Null string /  / 

An empty string is the string with zero occurrences of symbols.

Length of a string (  )

Let  be the string, then the length of the string,  is the number of symbols
composing the string.
Example:
 010 ;  3

  ;0

abcba ;  5
Automata Fundamentals 1.15

Concatenation of strings
The concatenation of two strings '' and ' v ' is the string obtained by appending the
symbols of v to the right end of .
Example:
  010
v 111
v  010111

Power of an alphabet (  k )

If  is an alphabet, we can express the set of all string of a certain length from that
alphabet by using an exponential notation.

We define,  k to be the set of strings of length k, each of whose symbol is in 


Example:

 
0

Let  a, b, c

 
0

  a, b, c
1

 aa, bb, cc, ab, ac, ba, bc, ca, cb


2

 aaa, bbb, ccc, aab, aac, aba, aca, abb, acc, abc, acb, bba, bbc, bab, bcb, baa, bcc,..... 
3

Reversing a string ( R )

The reverse of the string is obtained by writing the string in reverse order.

Example:
 abc

R cba

Kleene closure ( * )

Let  be an alphabet. Then the kleen closure,  * denotes the set of all strings over
the alphabet, 
1.16 Theory of Computation

Example:

1) Let  a, b


 , a, b, aa, bb, ab, ba, aaa, aab,...
*

2) Let  1
 
0

  1
1

 11
2

 * 0
  1   2  .....

,1,11,111,...

Kleene plus / Positive closure (   )

Let  be an alphabet. Then the positive closure,  


denotes the set of all strings
over the alphabet,  except null string () .

Example:

Let  1, 0


 
  1   2   3 ...

  1 ,0
1

 11, 00,10, 01


2

 111, 000,110,101, 011,...


3

   1, 0,11, 00,10, 01,111, 000,101,...

    
 *

Substring

The string, v if it appears within another string , then v is called as the substring
of .
Automata Fundamentals 1.17

Example:
Let v111 ; 010111
 v is a substring of 
Let 1, 2,3

Prefixes ,1,12,123

Suffixes ,3, 23,123


Palindrome
A palindrome is a string which is same when read in backward or forward direction.
R  is a palindrome
Example: 1001

 R 1001 equal   is a palindrome.

Language (L)
Alphabet  finite set of symbols

String  collection of alphabets

Language  collection of appropriate strings

A set of strings taken from an alphabet is called a language.

Example:
1)  {a, b}

L{an b, n  0}{b, ab, aab, aaab, aaaab,.... }

2)  {0,1}
L{Set of stringsending with11}
= {ε, 11, 011, 0011, 1011, 0111, 101111, …}

Properties of String Operations


1. Concatenation of a string is always associative.
(uv) w  u(vw)
2. If u and v are two strings, then the length of this concatenation is the sum of the
langth of the individual lengths.
1.18 Theory of Computation

| xy || x | | y |

Example: Let x 10

y101

Then xy10101Concatenation.

| xy || x | | y |

23

5

Operations of Languages
1. Product or concatenation (L1 L2 )
L1{b, ab, aab, ... }{an b, n  0}

L2 {1,01, 001, ....}{0n1, n  0}


L L {an b 0n1, an bL & 0n1L }
1 2 1 2

2. Reversal (LR )
The reversal of a language is a set of all string reverses.
LR {wR / wL}

3. Kleen Star/ Star Closure (L*)

L* LoU L1U L2 U....


4. Positive Closure
L  L* {}
 L1 U L2 U L3 U....

Other Operation on Set/Language


1. Union
L1  L2 = {x | x ϵ L1 or x ϵ L2}
2. Intersection
L1  L2 {w, wL1 and wL2 }
3. Difference:
L1 L2 {w, wL1 and wL2 }
Automata Fundamentals 1.19

Definition of Finite Automata [FA]


Finite Automata is a mathematical model of system with certain input and it is
processed through various intermediate states and finally gives certain output.

Model of FA
a1 a2 a3 a4 … Infinite tape

Read Head

Finite
CPU
control

Input Tape
 It is divided into number of cells.
 Each cell holds one symbol.

Read Head
 Reads one cell at a time and moves ahead.

Finite Control
 Acts like a CPU.
 Depending on current state and input symbol read from tape, it changes state.

Formal Definition of FA

M(Q, , , q0 , F)

FA consist of 5 Tuples,
Q Set of finite states.

  Set of input alphabets


 Transition function [Q Q]

q0  Start state
F Set of final states. [FQ]
Representation of FA
1. Transition Diagram
2. Transition Table
1.20 Theory of Computation

Transition Diagram
It can be directed graph with vertices of a graph corresponding to states and edges
indicates transition from one state to another

0 1
q0 q1 q2

Start
Final
state
state
 Start state indicated by circle.
 Start transition indicated by arrow.
 Final state indicated by double circle.

Transition Table
It is a tabular listing of the transition function which by implication tells us, set of
states and input alphabet.
b

a b
q0 q1 q2

State  a b
(q0 , a) q1
Input 
(q 0 , b) q 0
 q0 q1 q0
(q1 , b) q 2
q1  q2

*q2  

Applications
1. Design of digital circuits.
2. String searching
3. Communication protocols for information exchange.
4. Lexical analysis phase of a compiler.
Types
1. Deterministic Finite Automata [DFA]
2. Non-Deterministic Finite Automata [NFA]
Automata Fundamentals 1.21

DETERMINISTIC FINITE AUTOMATA [DFA] /FA


 The word deterministic refers to the fact the transition is deterministic.
 There is only one path for specific input from current state to next state.

DFA is defined by 5 tuples,


A(Q, , , q0 , F)
where,
Q Finite set of states.

  Finite set of input symbols.


q0  Initial state
 Transition function
F Final state / Accepting state

Properties of DFA
 There is only one path for an input from current state to next state.
 It contains only one final state.

PROBLEMS
1. Design a DFA for the language, L  {anb; n  0}
If n  0La 0 b b n 3La 3 b aaab
n 1La 1 b ab n  4La 4 b aaaab
n  2La 2 b aab n 5La5 b aaaaab
a

b
q0 q1

Here, Q{q0 ,q1};

 {a, b}
q0 {q0 }

Transition function,
(q0 , a) {q0 }
1.22 Theory of Computation

(q0 , b) {q1}
(q1 , a) 
(q1 , b) 
F{q1}
2. Design a DFA that accept L  {w / w (a, b,c), and w contains only abac}

a b a c
q0 q1 q2 q3 q4 Valid input: abac

Invalid inputs: aa, abc,


b, c a, b
a, c abaca, bbca, …
b, c a, b, c
q2

Trap

3. Design a DFA that accept L  {w (0, 1)*, where every 0 in w has 1 immediately to
its right.

0 1 Valid input
q0 q1 q2 01

0 1
q0 q1 q2 0101
0
1 1
101, 1101
0 1
q0 q1 q2 Invalid inputs:
0 00, 10, 1100, 1001, ….
0

Trap  q2
0, 1

4. Design a DFA that accept only „101‟.


1 0 1
q0 q1 q2 q3 Valid input: 101
Automata Fundamentals 1.23

1 0 1
q0 q1 q2 q3 Invalid inputs:
00, 100, 010, 1010, …
1 0
0 0, 1

q4

Trap 0, 1

5. Design a DFA that accepts string that starts with „ab‟.

a b Valid inputs:
q0 q1 q2 101

a, b
a b aba, abb, abaa, abbb,
q0 q1 q2
abab, ….

b a, b Invalid inputs:
a
q0 q1 q2 ba, aa, aab, bab, aaaa,
baab, ….
b a
q1

Trap
a, b

6. Design a DFA that accepts all strings of length atmost 5 over   {0, 1}

Valid inputs:
0, 00, 000, 0000,
0, 1 0, 1 0, 1 0, 1 0, 1 00000, 1, 11, 111,
q0 q1 q2 q3 q4 q5
1111, 1111, 10101,
010, 100, 0010, …

0, 1 0, 1 0, 1 0, 1 0, 1
q0 q1 q2 q3 q4 q5 Invalid inputs:
101010, 0000000,
11110000,
0, 1 100011001,
q1 1111111111, …

Trap
0, 1
1.24 Theory of Computation

7. Design a DFA that accepts even number of a‟s over   {a}

a a Valid inputs:
q0 q1 q2
aa

a a
q0 q1 q2
aaaa, aaaaaa, a8, a16, ...
a

a q3 a
Invalid input
q0 q2 a, aaa, aaaaa, a7, a17, ...

a a
q1

8. Design a DFA that accepts a language, L having even number of 0s and 1s.

0 Valid inputs:
q2 q1 00, 11, 0000, 1111, 08, 18, …
0

1 1

q1

0
q2 q1 0110, 0101, 1010, 1100, 110011,
0 10101010, 00001111, ...

1 1 1 1 Invalid inputs
0 0, 1, 000, 111, 101010, 110, 1101,
q1 0100, …
q1 0
Automata Fundamentals 1.25

9. Design a DFA that accepts all strings containing atleast two zeroes.
Valid inputs:
0 0
q0 q1 q2 00

0, 1
0 0 00, 000, 0000, 00000, 0001,
q0 q1 q2
000111, …
1
0, 1
0 0 100, 1100, 11100000,
q0 q1 q2
110011, 1001, 11000010, …

1 1 1010, 10110, 11011011,


0, 1 0101, 1101101101, …
0 0
q0 q1 q2
Invalid inputs:
1, 10, 111, 0111, 101, 11011,
01, …

10. Design a DFA that accepts strings ending with „00‟ over   {0, 1}

Valid inputs:
0 0
q0 q1 q2 00

0
0 0 000, 0000, 00000, …
q0 q1 q2

1
0
q0 0 0 100, 1000, 1100 110000, …
q1 q2

1
0 0100, 101000, 110100, …
0 0
q0 q1 q2
1
1
0 00100, 1000, 1010100, 001000
0 0
q0 q1 q2
1 Invalid input:
1 001, 0011, 101, 10011, 1, 01, ..,
1.26 Theory of Computation

11. Design a DFA that accepts a language, L which has the number of zeroes is of
multiples of 3.

Valid inputs:
0 0
q0 q1 q2 000, 000000, 09, 012, …

0
1

0 0
q0 q1 q2 1, 1000, 100000, …

0
1 1

0 0
q0 q1 q2 10100, 11000, 101100, …

0
1 1
1
0 101010, 1101010, 1101110110, …
0
q0 q1 q2 Invalid inputs: 0,00,10000,01011, …


12. Design a DFA that accepts L   01 12j , i  1; j  1

i

 

1 1 
q0 0 1 q3 Valid inputs:
q1 q2 q4
 i = 1, j = 1  L = 0111

0 1 1 1 i = 1, j = 2,  L = 011111
q0 q1 q2 q3 q4
i = 1, j = 3,  L = 01111111
1
i = 2, j = 1 L = 010111
1 1 1
q0 0 q1 q2 q3 q4 i = 3, j = 1,  L = 01010111
i = 2, j = 2 L = 01011111
0 1 i = 3, j = 3,  L = 010101111111
Automata Fundamentals 1.27

Invalid inputs:
0 1 1 1
q0 q1 q2 q3 q4 1, 00, 0100, 0110, 01110,
1 011110, 1000, 101, …
0 0
0

Trap
0, 1


13. Design a DFA that accepts L     a, b  / n b   mod 3  1
*

Valid inputs:
b b
q0 q1 q2 bb, b5, b8, b11 [No. of b%3]
bb  2b‟s  2% 3  2
b > 1 
a bbbbb  5b‟s  5%
3  2 > 1 
b b bbb  3b‟s  3% 3  0
q0 q1 q2
> 1 
b 
abb, abbbbb, ab8, …
a a
a-b2, a3b5, ...
b b
q0 q1 q2 bab, abab, aabbbbb, …

a a a
bba, bbaa, abba, abbaa, ….
b b Invalid inputs:
q0 q1 q2
b, b3, b4, b6, b7, b9, a, aa, aaa, aba,
b baa, ababb
1.28 Theory of Computation

14. Design a DFA accepting strings containing exactly one 1 over   {0, 1}

1 Valid inputs:
q0 q1 1

1 01, 001, 0001, …


q0 q1

0 0

1 10, 100, 1000, 010, 0100, …


q0 q1

0 0

1
q0 q1 Invalid inputs:
11
1
Trap q2

0 0

1
q0 q1 0110, 0101, 1111, 101,…

Trap q2 0, 1

15. Design a DFA that accepts all strings with exactly two 1s over   {0, 1}

Valid inputs:
1 1
q0 q1 q2 1

0
1 1
q0 q1 q2 011, 0011, 00011, …

0 0
1 1
q0 q1 q2 0101, 1001, 101, …
Automata Fundamentals 1.29

0 0 0

1 1
q0 q1 q2 110, 01010, 1010, 11000 ….

0 0 0
Invalid inputs:
1 1
q0 q1 q2 111, 1110, 0111, 10101, 1111,
1110101, …
1

Trap q3 0, 1

16. DFA that accepts strings containing „00‟ as substring.


Valid inputs:
0 0
q0 q1 q2 00

0 0
q0 q1 q2 000, 0000, 00000, …

1 0

0 0
q0 q1 q2 100, 1100, 11000, …

1 0

0 0
q0 q1 q2 10100, 1101100, 101101, ….
1
0, 1
1
0 0 Invalid inputs:
q0 q1 q2
1001, 11001, 101001, …
1
1.30 Theory of Computation

17. Design a DFA that accepts string,  such that its second symbol is zero and fourth
symbol is 1.

Valid inputs:
0 0 0 1
q0 q1 q2 q3 q4 0001

q0 0, 1 0 0 1 1001
q1 q2 q3 q4

0, 1 0 0 1
q0 q1 q2 q3 q4 0011, 1011

0, 1
0, 1 0 0, 1 1 00010, 10010, 00110, 00011,
q0 q1 q2 q3 q4
10011, 00111, …

0, 1
0, 1 Invalid inputs:
0 0, 1 1
q0 q1 q2 q3 q4 0101, 0100, 0010, 1100,
0000, 1000, …

1 0
q5
Trap

0, 1
0, 1 0 0, 1 1
q0 q1 q2 q3 q4 01010, 01000, 11111,
0100000, …

1 0
q5
Trap

0, 1
Automata Fundamentals 1.31

18. Design a DFA that accepts atmost 3 a‟s.

a a a Valid inputs:
q0 q1 q2 q3 aaa, a, aa,


b

a a a
q0 q1 q2 q3 b, ba, baa, baaa, bb, bba, bbba,

b b
a a a
q0 q1 q2 q3 bab, abba, abbbaa, babba,…

b b b
a a a
q0 q1 q2 q3 babab, aabb, aaba, bbbaaba, …

b b b b
a a a
q0 q1 q2 q3 aaabbb, aaabab, baaaba, …

b b b b
a a a Invalid inputs:
q0 q1 q2 q3 aaaa, aaabab, baaaba,

a, b q4

Trap
1.32 Theory of Computation

19. Design a DFA that accepts all strings containing substring „101‟.

Valid inputs:
1 0 1
q0 q1 q2 q3 101

0
1 0 1
q0 q1 q2 q3 0101, 000101, …

0 1
1 0 1
q0 q1 q2 q3 011101

0 1 0, 1
1 0 1
q0 q1 q2 q3 10100, 101, 101101, …

0
0 1 0,1
Complementary
1 0 1
q0 q1 q2 q3 [Does not accept
substring with „101‟]
0

20. Design a DFA to check whether a string over   {a, b}contains „abb‟ is accepted.

a Valid inputs:
b b
q0 q1 q2 q3 abb

b
a b b
q0 q1 q2 q3 babb, bbabb, …

b a
a b b
q0 q1 q2 q3 aabb, baaabb, …

b a
a b b
q0 q1 q2 q3 ababb, abaabb, bababb, …
a
b a a, b
abba, abbb, abbab
a b b
q0 q1 q2 q3
a Invalid inputs:
ab, bbb, aaaa,abab, aaba,…
Automata Fundamentals 1.33

21. Design a DFA that accepts odd number of ones over   {0, 1}

1 Valid inputs:
q0 q1 1

1
q0 q1 111, 11111, 17, 19, 111, …
1
0

1
q0 q1 01, 001, 0000111, …
1

0 0
10, 1011, 10001111, 01101,…
1
q0 q1
Invalid inputs:
1 11, 1111, 0110110, 111100110, …

22. Design a DFA that accepts a substring “001”.


Valid inputs:
0 0 1
q0 q1 q2 q3 001

1
0 0 1
q0 q1 q2 q3 1001, 11001, 111001, …

1 0
0 0 1
q0 q1 q2 q3 0001, 000001, …

1 0 0, 1
0 0 1
q0 q1 q2 q3 00010, 110011, 110010, …

1 0 0, 1
0 0 1
q0 q1 q2 q3 101001, 10101001, …
1
Invalid inputs:
1111, 0111, 0101, 000, …
1.34 Theory of Computation

23. Design a DFA that recognize words which do not end in „b‟ over   {a, b}
a
Valid inputs:
a, aa, aaa, aaaa, …
q0

b aaba, ba, aba, …


q0 q1
a
a
b
aabbaa, bba, bbabba, …
b
q0 q1
Invalid inputs:
a b, bbb, abb, aabb, abab, …

24. Design a DFA that accepts exactly 4 ones over   {0, 1}

Valid inputs:
1 1 1 1
q0 q1 q2 q3 q4 1111

0 0 0 0 0

q0
1 0 0 1 01111, 010100, 01010101,
q1 q2 q3 q4
1111000, 1101100, …
0 0 0 0 0
q0
1 1 1 1 Invalid inputs:
q1 q2 q3 q4
111101, 10101011, 110111, …

1
Trap q5

0 0 0 0 0

q0
1 1 1 1 1111010, 1111011, …
q1 q2 q3 q4

1
q5
0, 1
Automata Fundamentals 1.35

Extended transition function: δ    Delta Cap/Hat

 The extended transition function,  takes two parameters, state and string.
 It is a mapping from Q   *  Q

 Formally  cann be defined as

o (q0 ,)q 0
 

o (q0 , a) ((q0 , ), a)

PROBLEMS
1) Consider the transition diagram
b a a, b

a b
q0 q1 q2

Check whether the input string,”aab” is accepted by the finite automata.




(q0 ,) q0


 

(q0 , aab) ((q0 , aa), b)




(((q0 , a), a), b)




((((q0 ,), a), a), b)


(((q0 , a), a), b)
((q1 , a), b)
 (q1 , b)
q2 Final state
Hence the given string “aab” is accepted by FA.

2) Consider the FA
a
a

q0 b
q1

b
1.36 Theory of Computation

Show how the string ω1 =aabba and ω2 =aba is processed.


1) 1 aabba
 

(q0 , aabba) (q0 , abba)




 (q0 , bba)


 (q1 , ba)


 (q0 , a)
 q0  Final state  string is accepted
2) 2 aba
 

(q0 , aba) (q0 , ba)




 (q1 , a)
q1  Not a final state  string not accepted

3) Check whether the strings “ababba” ,”baab” are accepted by the DFA?
AU – May / June, Nov / Dec 2009

a b

a
q0 q1 q2
a, b
1) 1 ababba
 

(q0 , ababba) ((q0 , ababb), a)


 

(((q0 , abab), b)a)




((((q0 , aba), b), b), a)




(((((q0 , ab), a), b), b), a)




((((((q0 , a), b), a), b), b), a)




((((((((q0 , ), a), b), a), b), b), a)


(((((((q0 , a), b), a), b), b), a)
Automata Fundamentals 1.37

((((((q0 , b), a), b), b), a)


(((((q1 , a), b), b), a)
((((q2 , b), b), a)
(((q1 , b), a)
((q1 , a)
(q3 , )
q3 Not a Final state  Not accepted
2) 2 baab
 

(q0 , baab) ((q0 , baa), b)




(((q0 , ba), a), b)


 

((((q0 , b), a), a), b)




(((((q0 , ), b), a), a), b)


((((q0 , b), a), a), b)
(((q1 , a), a), b)
((q2 , a), b)
 (q1 , b)
q1 Final state  string accepted

NON DETERMINISTIC FINITE AUTOMATA AU - Nov/Dec 2013


A NFA has 5 tuples defined as,
M = ( Q, , , q0 , F)
where,
Q  a finite set of states

 A finite set of inputs


 Transition function from Q  Q
q0  Start / initial state
F  A set of final / accepting states  FQ 

Subset
1.38 Theory of Computation

Difference between DFA and NFA

S.NO DFA NFA


1. The transition is deterministic The transition is non-deterministic
2. It has more number of states than It has less number of states.  2Q 
NFA
3. It provides only one state transition It may lead to more than one states for
for a given input given input
4. It has only one final state It has more than one final states
5. More difficult to design It is easy to design
6. It has a single path for an input It may have several paths for a single
from a state input from a state. Backtracking is
required.

PROBLEMS
1) Sketch the NFA state diagram for M = (q 0 , q1 , q 2 , q3  , 0,1 , , q 0 , q 3 ) with  given as


∑ 0 1
Q
 q0 (q0 , q1 ) (q0 , q2 )

q1 q3 

q2  q3

* q3 q3 q3


Solution:
0, 1 0, 1
0 q1 0
q0 q3

1 q2 1
Automata Fundamentals 1.39

2) Design a NFA with no more than five states for the set abab n : n  0  aba n : n  0 .
b

a b a
q0 q1 q2 q3

a
q4

3) Determine a NFA that accepts L(aa * (a  b)) .

a
a a, b
q0 q1 q2

4) For NFA shown, check whether „0100‟ is accepted or not.


0 1

q0 0
q1

1
0
1 1
q2

0
:

∑ 0 1
Q
 q0 q 0 , q1 q 2 
q1  q1 , q 2 
* q2 q0 , q 2  q1 
Solution:


(q0 , 0100)
(q0 , 0)  q 0 , q1  (q 0 , q1  , 0)  q 0 , q1     q 0 , q1 
(q0 , 01) ((q0 , 0),1)
 (q 0 , q1  ,1)
1.40 Theory of Computation

(q0 ,1)  (q1 ,1)


 q 2   q1 , q 2 

 q1 , q 2 
(q0 , 010) ((q0 , 01), 0)
 (q1 , q 2  , 0)
(q1 , 0)  (q2 , 0)
   q 0 , q 2 

 q 0 , q 2 
(q0 , 0100) ((q0 , 010), 0)
 (q 0 , q2  , 0)

 (q 0 , 0)  (q 2 , 0)  q 0 , q1  q 0 , q 2 

 q0 , q1 , q 2   Since q0 is final state  string accepted

5) NFA with states 1,2,3, 4,5 and  a, bhas  as,


Calculate 1) (1, abab)
2) (2, baba)
∑ a b
Q
1 1, 2 1
2 3 3
3 4 4
4 5 
5  5
Solution:
1) (1, abab)
(1, a) 1, 2
(1,ab) ((1, a), b)
 (1,2, b)
Automata Fundamentals 1.41

(1, b) (2, b)
1 3

1, 3
(1, aba) ((1, ab), a)
 (1,3, a)
(1, a) (3, a)
1, 24

1, 2, 4
(1, abab) ((1, aba), b)
 (1, 2, 4, b)
(1, b) (2, b) (4, b)
1 3 1,3
2) (2, baba) :
(2, b) 3
(2, ba) ((2, b), a)
 (3, a)
4
(2, bab) ((2, ba), b)
 (4, b)

(2, baba) ((2, bab), a)
(, a)

6) Design a NFA to accept strings containing the substring,”0101”.
0, 1 0, 1
0 1 0 1
q0 q q q q
1 2 3 4
1.42 Theory of Computation

NFA: M (Q, , , q0 , F) where,

Q q 0 , q1 , q 2 , q3 , q 4 

 0,1
q 0  q 0 

F  q 4 
 is given as 


∑ 0 1
Q
 q0 q 0 , q1 q 0 
q1  q 2 
q2 q 3  

q3  q 4 
* q4 q 4  q 4 

7) Construct a NFA that accepts L  x a, b/ x ends with 'aab'
a, b
a a
q0 q1 q2
b q3

M(Q, , , q0 , F)  is given as 

Q  q 0 , q1 , q 2 , q 3 
∑ a b
 a, b Q
 q0 q 0 , q1 q 0 
q 0  q 0 
q1 q 2  
F  q3 
q2  q3 
* q3  

Automata Fundamentals 1.43

8) Design a NFA to accept strings over alphabet0, 1, such that the third symbol from
right end is 0.
0, 1
0 0, 1 0, 1
q0 q1 q2 q3


Q  q 0 , q1 , q 2 , q3  The transition function,  is given as

 0,1 

0 1
q0  q0  Q 

F  q3 
 q0 q 0 , q1 q 0 
 q1 q 2  q 2 


q2 q3  q3 
 * q3  


L  x {a, b, c : x contains exactly one b immediately
*
9) Construct a NFA for
following c}.
a, b a, b, c

c a, c
q0 q1 q1

1 b
Trap
a b

q4

10) Construct a NFA that accept L  x {0, 1 : x is starting with 1 and | x | is divisible
*

by 3}.
0, 1
q4 Trap
0

q1

1 0, 1
q1

0, 1

q3 0, 1
1.44 Theory of Computation

11) Design a NFA for L = L  {x {a, b}* / x contains any number of a‟s followed by
atleast one b}.
a b a, b

b a
q0 q1 q2

Trap

12) Design a NFA for a binary number where the first and the last digits are same.
0, 1

q2
0 q4
0

q1

1 1
q3 q5

0, 1

13) Construct a NFA over 0, 1 such that each „0‟ is immediately preceded and
immediately followed by 1.
1

1
q0 q1

0 1
0

q3 0
q2

0, 1
Trap

14) Construct NFA for the RE: (0+1)01.

0,1
0 1
q0 q1 q2

EQUIVALENCE OF DFA AND NFA

Every language that can be described by some NFA can also be described by some
DFA. It involves subset construction process for conversion.
Automata Fundamentals 1.45

Let N  (QN ,  , N, q 0 , FN ) be the given NFA.

We can construct DFA,


D = (QD ,  , D , q 0 , FD )
where,
QD Set of all subsets of QN
FD  Set of subsets,S of QN such that S FN  
 D For each set, S contained in QN , i.e., S  QN and each input a in  be

defined as D (s, a) N (p, a); p s

Procedure
1. If Q  q0 , q1 , q 2  , then create subsets, q0  , q1 , q2  , q0 , q1 , q0 , q 2  , q1, q 2  ,
q0 , q1 , q2  and  . Thus if no of states = n; the no of subsets =2n.
2. Construct the transition table for the subsets over the given language,  .
3. Minimise the table by considering only the reachable states from the start state.
4. Draw the DFA from the minimised transition table.

PROBLEMS
1) Construct a DFA from the following NFA that accepts all strings of 0‟s and 1‟s that
end with „01‟. AU - NOV/DEC 2013, NOV/DEC 2003, MAY/JUNE 2006
Solution:
NFA
0,1
0 1
q0 q1 q2

Here ,

QN  q 0 , q1 , q 2  

 0,1 ∑ 0 1
Q
q 0  q 0 
 q0 q 0 , q1 q 0 
F  q 2 
q1  q 2 
* q2  
1.46 Theory of Computation

Subsets
QD  , q 0  , q1 , q2 q0 , q1 q0 , q 2 q1 , q 2 q 0 , q1 , q 2 

Transition table: D


0 1
Q
  
→ q 0  q 0 , q1 q 0 
q1   q 2 
* q 2   

q 0 , q1 q 0 , q1 q0 , q 2 


* q 0 , q 2  q 0 , q1 q 0 
* q1 , q 2   q 2 
* q 0 , q1 , q 2  q 0 , q1 q0 , q 2 
Minimised transition table

0 1
Q
 q 0  q 0 , q1 q 0   q 0  Processed

q 0 , q1 q 0 , q1 q0 , q 2   q 0 , q1  Processed

* q0 , q 2  q 0 , q1 q 0   q 0 q0 , q1  both are processed

Minimised DFA
1 0

0 1
{q0} {q0 , q1} {q0 , q 2}

0
1
Automata Fundamentals 1.47

2) Convert the given NFA to DFA.

QN p, q, r,s N : ∑
0 1
Q
 0,1 →p p, q p
q0 p q r r
FN s r s 

NFA for the above specification *s s s


0, 1 0, 1

0 0, 1 0, 1
p q r s

Subsets
QD ,p,q,r,s,p, q, p, r,p,sq, r,q,s,r,s,
p, q, r,p, q,s,q, r,s,p, r,s,p, q, r,s
QD  24 16

Transition table

0 1
Q
  
p p, q p
q r r
r s 
*s s s
p, q p, q, r p, r
p, r p, q,s p
*p, s p, q,s p, s
q, r r, s r
*q, s r, s r, s
*r, s s s
1.48 Theory of Computation

p, q, r p, q, r,s p, r


*p, q,s p, q, r,s p, r,s
*p, r,s p, q,s p, s
*q, r,s r, s r, s
*p, q, r,s p, q, r,s p, r,s
Minimised transition table

0 1
Q
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, r,s p, r,s
p, r,s p, q,s p, s
* p, s p, q,s p, s
DFA
1

0 0
{p} {p, q} {p, q, r}

1 0
1
1 0
{p, r} {p, q, r, s}

0
0 1
1
{p, q, s} {p, r, s}
0
0 1
{pp,,ss}

1
Automata Fundamentals 1.49

3) Convert the following NFA to DFA. AU NOV/DEC 2004


0 1
Q
p q, s q
q* r q, r
r s p
*s  p
Solution:-
Here,
QN p, q, r,s

 0,1
q0 p
FN q,s
0

p
0, 1 0, 1 0
r r s

1 1
1

Subsets:
QD ,p,q,r, s,p, q,p, r,p,s ,q, r,q,s,r,s,p, q, r ,
p, q,sp, r,s,q, r,s,p, q, r,s
FD q,s,p,s,q, r,q,s, r,s,p, q, r,p, q,s, p, r,s,q, r,s,p, q, r,s

Transition table:-

0 1
Q
  
p q, s q
*q r q, r
1.50 Theory of Computation

-r s {p}

*s  p
p, q q, r,s p, q, r
p, r q, s p, q
*p, s q, s p, q
q, r r, s p, q, r
*q, s r p, q, r
*r, s s p
p, q, r q, r,s p, q, r
*p, q,s q, r,s p, q, r
*p, r,s q, s p, q
*q, r,s r, s p, q, r
*p, q, r,s q, r,s p, q, r
Minimised transition table:-

0 1
Q
p q, s q
q, s r p, q, r
q r q, r
r s p
p, q, r q, r,s p, q, r
q, r r, s p, q, r
s  p
q, r,s r, s p, q, r
*r, s s p
Automata Fundamentals 1.51

DFA diagram:-
1

1
{q, s} {p, q, r}
0 0

{p}
1 {r}
0 1 {r, s}
1 0 1
0
1 {q} 1 {q, r, s}

0
1 {q, r}
{s} 0
0

4) Construct a DFA for the following NFA. AU MAY/JUN 2009

0 1
q0 q1 q2

0 1

Solution:-
QN = {q0, q1, q2} ∑
0 1
Q
∑ = {0, 1}
→{q0} {q0, q1} 
q0 = {q0} {q0}  {q2}
FN = {q2} *{q2}  {q2}

Construction of DFA:-
QD = {, {q0}, {q1}, {q2}, {q0, q1}, {q0, q2}, {q1, q2}, {q0, q1, q2}}

FD = {{q2}, {q0, q2}, {q1, q2}, {q0, q1, q2}}

q0 = {q0}
1.52 Theory of Computation

Transition table:-

0 1
Q
  
{q0} {q0, q1} 
{q1}  {q2}
*{q2}  {q2}
{q0, q1} {q0, q1} {q2}
*{q0, q2} {q0, q1} {q2}
*{q1, q2}  {q2}
{q0, q1, q2} {q0, q1} {q2}

Minimized transition table:-



0 1
Q

→{q0} {q0, q1} 


{q0, q1} {q0, q1} {q2}
*{q2}  {q2}

Minimized DFA:-
1
0

0 1
{q0} {q0 , q1} {q2}

5) Convert M = ({q1, q2, q3}, {0, 1}, {q1}, {q3}), where  is given by,
 (q1, 0) = {q2, q3}  (q1, 1) = {q1}
 (q2, 0) = {q1, q2}  (q2, 1) = 
 (q3, 0) = {q2}  (q3, 1) = {q1, q2}
Construct an equivalent DFA
Automata Fundamentals 1.53

Solution:
Given NFA,
1 0
0
0 0,1
q1 q2 q3
0
1


0 1
Q

q1 {q2, q3} {q1}


q2 {q1, q2} 
* q3 {q2} {q1, q2}

DFA Construction:-
∑ = {0, 1}
QD = {, {q1}, {q2}, {q3}, {q1, q2}, {q1, q3}, {q2, q3}, {q1, q2, q3}}
q0 = {q1}
FD = {{q3}, {q1, q3}, {q2, q3}, {q1, q2, q3}}

Transition Table:-

0 1
Q
→   
{q1} {q2, q3} {q1}
{q2} {q1, q2} 
* {q3} {q2} {q1, q2}
{q1, q2} {q1, q2, q3} {q1}
* {q1, q3} {q2, q3} {q1, q2}
* {q2, q3} {q1, q2} {q1, q2}
* {q1, q2, q3} {q1, q2, q3} {q1, q2}
1.54 Theory of Computation

Minimized DFA table:-



0 1
Q
→ {q1} {q2, q3} {q1}
{q2, q3} {q1, q2} {q1, q2}
{q1, q2} {q1, q2, q3} {q1}
* {q1, q2, q3} {q1, q2, q3} {q1, q2}

Minimized DFA:-
0
1

0 0,1 0
{q1} {q2 , q3} {q1, q2} {q1, q 2 , q3}
1
1

THEOREM AU – MAY 2005, DEC 2006, DEC 2013


A Language, L is accepted by some NFA if and only if it is accepted by some DFA
(or)
For every NFA, there exists an equivalent DFA
Proof:-
This theorem has two parts:-
1) If L is accepted by a DFA (M2), then L is accepted by some NFA (M1)
2) If L is accepted by a NFA (M1), then L is accepted by some DFA (M2)
To prove the theorem, it is enough to prove that

D ({q0 }, w)  N ({q0 }, w)
For an arbitrary string w, we prove this statement, we use induction principle on w .
Basis of Induction:-
Let w =0

Then w = ε
By the definition of extended transition function,
D ({q0 },) {q0 } ----- (1)
Automata Fundamentals 1.55

N ({q0 },)  {q0 } ----- (2)


D ({q0 }, w)  N ({q0 }, w) is true for w = Є Hence proved that L [D] = L [N].
Inductive Step:-
Let us assume that the theorem is true for all the strings, w of length „n‟. (i.e.) w  n .

Now let us prove that the same is true for a string of length, n+1
Let w = xa, where
a → last symbol of w.
By assumption, we have,

D ({q0}, x)  N ({q0}, x)
k 
 {P1, P2 ,.....Pk } subsets  Pi 
 i1 
Now, by the definition of extended transition function of DFA,
D ({q0}, x)  D ({q0}, xa )

= D (({q0}, x), a)
= D ({P1, P2, .... Pk}

 Ui1
K
N (Pi, a) Bysubset construction

= N (q0 , w) By definition of of NFA


 By induction principle, the theorem is true for all the strings, w of the given
language.

Thus, L [D] = L [N]

NFA WITH Є TRANSITIONS


The Є [Epsilon] used to indicate null string. The string is used for transition from one
state to other without any input. AU DEC 2007

Formal Notation for Є – NFA:


A non deterministic FA, M with Є –transition is given by E = (Q, ∑, δ, q0, F), where
Q →finite set of states
∑→finite set of input alphabets
1.56 Theory of Computation

q0 → Initial/ start state


F → F  Q →set of final/accepting states
δ → Transition/ Mapping function from
Q X {∑ U {Є}} → 2Q

EPSILON CLOSURE AU MAY 2012, DEC 2010, MAY 2013


Epsilon closure of a state, q is defined as the set of states reachable from q on Є
moves. Є - closure of q0 is denoted as ЄCLOSE (q0).
Example: Obtain Є closure of each state in the following Є – NFA with Є – move.
AU DEC 2005
 
q0 q1 q2

0 0 2
Є CLOSURE {q0} = {q0, q1, q2}
Є CLOSURE {q1} = {q1, q2}
Є CLOSURE {q2} = {q2}

Find Є- CLOSURE of States 1,2 and 4 from the following transition diagram.
AU MAY 2008
Є Є
3 6
2
Є

1 Є
a 7
4 5
Є

Є –Closure {1} = {1,2,4,3,6}


Є –Closure {2} = {2,3,6}
Є –Closure {4} = {4}

Eliminating Epsilon transitions


Given any epsilon NFA with Є moves, we can find a DFA that accept the same
language as E.
Automata Fundamentals 1.57

Let E = (QE, ∑,δE, qE, FE)


Then the equivalent DFA,
D = (QD, ∑,δD, qD, FD) is defined as follows.
(i) QD is the set of subsets, s of QE. S  QE such that s= ECLOSE (S)
(ii) qD = ECLOSE(qE)
(iii) FD = {s / s is in QD and S n FE ≠  }
(iv) δD(s,Q) is computed for all a in ∑ and sets, S in QD by
a) Let S = P1, P2,….,Pk)
b) Uk (P , a) {r , r ,....r }
i1 i 1 2 m

c)  (s, a)  U ECLOSE(r ) m

D j1 j

PROBLEMS
1) Design a DFA that eliminates Є transition from the following Є- NFA.


Є a b c d
QE
q0 q0, q1    
q1 q1 q1, q2 q3  
q2 q2, q3   q2 q2
*q3 q3 q3 q3  

a c,d

Є a
q0 q1 q2

b Є

q3

a,b
Solution :-
Start state of DFA:-
ECLOSE (q0) = {q0, q1} → Start State of DFA
1.58 Theory of Computation

Successors of {q0, q1} for the input symbols, {a,b,c,d}:-


D ({q0 , q1}, a) : 
E (q0 , a) 
E (q1, a) {q1, q2}
E ({q0 , q1}, a) {q1, q2}
D ({q0 , q1}, a)  ECLOSE(q1)UECLOSE(q2 )
{q1}U{q2 , q3}
D ({q0 , q1}, a) {q1, q2 , q3}

D ({q0 , q1}, b) : 
E (q0 , b) 
E (q1, b) {q3}
E ({q0 , q1}, b)  {q3}
D ({q0 , q1}, b)  ECLOSE(q3 )
D ({q0 , q1}, b)  {q3}

D ({q0 , q1}, c) : 
E (q0 , c) 
E (q1 , c) 
E ({q0 , q1}, c) 
D ({q0 , q1}, c) ECLOSE ()
D ({q0 , q1}, c) 

D ({q0 , q1}, d) : 
E ( q0 , d) 
E ( q1 , d) 
E ({q0 , q1}, d) 
D ({q0 , q1}, d) ECLOSE ()
D ({q0 , q1}, d) 

Automata Fundamentals 1.59

Successors of q1 , q 2 , q 3  for the input symbols {a,b,c,d}:-

D ({q1, q2 , q3}, a) : 

E (q1, a) {q1, q2}

E (q2 , a) 

E ({q1, q2 , q3}, a) {q1, q2 , q3}

D ({q1, q2 , q3}, a) CLOSE{q1}UECLOSE{q3}

{q1}U{q2 , q3}U{q3}

D ({q1, q2 , q3}, a) {q1, q2 , q3}

D ({q1, q2 , q3}, b) : 

E (q1, b) {q3}

E (q2 , b) 

E (q3 , b) {q3}

E ({q1, q2 , q3}, b)  {q3}

D ({q1, q2 , q3}, b)  ECLOSE{q3}

D{q1, q2 , q3}, b)  {q3}

D ({q1, q2 , q3}, c) : 

E ( q1 , c) 

E (q2 , c) {q2}

E ( q3 , c) 

E ({q1, q2 , q3}, c)  {q2}

D ({q1, q2 , q3}, c)  ECLOSE{q2}

D ({q1, q2 , q3}, d) : 

E ( q2 , d) 

E (q3 , d) {q2}

E ( q3 , d) 
1.60 Theory of Computation

E ({q1, q2 , q3}, d)  {q2}

D ({q1, q2 , q3}, d)  ECLOSE{q2}

D{q1, q2 , q3}, d)  {q2 , q3}

Successors of {q3}for the input symbols,{a,b,c,d}:-


D ({q3}, a) : 
E{q3}, a)  {q3}
D (q3 , a)  ECLOSE{q3}
D (q3 , a)  {q3}
D ({q3}, b) : 
E{q3}, b)  {q3}
D (q3 , b)  ECLOSE{q3}
D ({q3}, b)  {q3}
D ({q3}, c) : 
E ({q3}, c) 
D ({q3}, c)  
D ({q3}, c)  
D ({q3}, d) : 
E ({q3}, d) 
D ({q3}, d)  
D ({q3}, d)  

Successors of {q2 , q3} over the input symbols {a,b,c,d}:-


D ({q2 , q3}, a) : 
E ({q2 }, a) 
E ({q3}, a)  q3
E ({q2 , q3}, q)  {q3}
Automata Fundamentals 1.61

D ({q2 , q3}, a) ECLOSE{q3}


D ({q2 , q3}, a) {q3}
D ({q2 , q3}, b) : 
D ({q3}, b)  
E ({q3}, b) {q3}
E ({q2 , q3}, b)  {q3}
D ({q2 , q3}, b) ECLOSE{q3}
D ({q2 , q3}, b) {q3}
D ({q2 , q3}, c) : 
E ({q2}, c) {q2}
D ({q3}, c)  
({q2 , q3}, c)  {q2}
D ({q2 , q3}, c) ECLOSE{q2}
D ({q2 , q3}, c) {q2 , q3}
D ({q2 , q3}, d) : 
E ({q2}, d) {q2}
D ({q3}, d)  
({q2 , q3}, d) {q2}
D ({q2 , q3}, d) ECLOSE(q2 )
D ({q2 , q3}, d) {q2 , q3}

Transition Table:-

a b c d
QD

{q0,q1} {q1,q2,q3} {q3}  


{q1,q2,q3} {q1,q2,q3} {q3} {q2,q3} {q2,q3}
* {q3} {q3} {q3}  
{q2,q3} {q3} {q3} {q2,q3} {q2,q3}
1.62 Theory of Computation

Equivalent DFA:-

a
{q0 , q1} {q1, q2 , q3}

b
b
c, d

{{{qq33}}
a, b {q2 , q3}
a, b c, d

2) Design a DFA that eliminates Є transitions from the following Є-NFA.


a d e

Є C e
q0 q1 q2 q3

Є
b C

q0 Є
q5

a
Solution:-
Start of DFA:-
ECLOSE(q0) ={q0, q1}

Start State of DFA

Successors of {q0, q1} over ∑={a,b,c,d,e}:-


D ({q0 , q2 ,}, a) : 

E ({q0 , q1}, a)  E ({q0}, a)UE ({q1}, a)

 U{q4} {q1}
Automata Fundamentals 1.63


Є a b c d e
QD
q0 q0, q1     
q1 q1 q1 q4 q2  
q2 q2    q2 q3
q3 q3, q5     q3
q4 q4, q5 q4  q2  
*q5 q5     

D ({q0 , q1}, a) ECLOSE(q1)


D ({q0 , q1}, a) {q1}

D ({q0 , q2 ,}, b) : 
E ({q0 , q1}, b)  E ({q0}, b)UE ({q1}, b)
 U{q4}
{q4}
D ({q0 , q1}, b) ECLOSE(q4 )
D ({q0 , q1}, b) {q4 , q5}
D ({q0 , q2 ,}, c) : 
E ({q0 , q1}, c)  E ({q0}, c)UE ({q1}, c)
U{q2}
{q2}
D ({q0 , q1}, c) ECLOSE(q2 )
D ({q0 , q1}, c) {q2}

D ({q0 , q2 ,}, d) : 
E ({q0 , q1}, d)  E ({q0}, d)UE ({q1}, d)

 


D ({q0 , q1}, d) 


1.64 Theory of Computation

Successors of {q1} over ∑ = {a, b, c, d, e}:-

D ({q1}, a) : 
E ({q1}, a)  {q1}
D ({q1}, a)  ECLOSE(q1 )
D ({q1}, a)  {q1}
D ({q1}, b) : 
E ({q1}, b)  {q4}
D ({q1}, b)  ECLOSE(q4 )
D ({q1}, b)  {q4,q5}

D ({q1}, c) : 
E ({q1}, c)  {q2}
D ({q1}, c)  ECLOSE(q2 )
D ({q1}, c)  {q2}
D ({q1}, d) : 
E ({q1}, d) 
D ({q1}, d)  ECLOSE () 
D ({q1}, e) : 
E ({q1}, e) 
D ({q1}, e)  ECLOSE () 

Successors of {q4,q5} over ∑ = {a, b, c, d, e}:-


D ({q4 , q5}, a) : 

E ({q4 , q5}, a)  E ({q4}, a)UE ({q5}, a)

{q1}U

{q4}

D ({q4 , q5}, a) {q4 , q5}


Automata Fundamentals 1.65

D ({q4 , q5}, b) : 
E ({q4 , q5}, b)  E ({q4}, b)UE ({q5}, b)


D ({q4 , q5 }, b)  ECLOSE () 

D ({q4 , q5}, c) : 
E ({q4 , q5}, c)  E ({q4}, c)UE ({q5}, c) {q2 }U
{q2}
D ({q4 , q5}, c)  ECLOSE(q2 )
D ({q4 , q5}, c) {q2}

D ({q4 , q5}, d) : 
E ({q4 , q5}, d)  E ({q4}, d)UE ({q5}, d)

D ({q4 , q5 }, d)  ECLOSE () 

D ({q4 , q5}, e) : 
E ({q4 , q5}, e)  E ({q4}, e)UE ({q5}, e)

D ({q4 , q5 }, d)  ECLOSE () 

Successors of {q2} over ∑ = {a, b, c, d, e}:-

D ({q2}, a) : 
E ({q2 }, a) 

D ({q2 }, a)  ECLOSE () 



D ({q2}, b) : 
D ({q2 }, b) 

D ({q2}, b)  ECLOSE () 


1.66 Theory of Computation

D ({q2}, c) : 
D ({q2}, c) 

D ({q2}, c)  ECLOSE () 



D ({q2}, d) : 
E ({q2}, d) {q2}

D ({q2}, d)  ECLOSE( q2 )

D ({q2}, d) {q2}

D ({q2}, e) : 
E ({q2}, e) {q3}

D ({q2}, e) ECLOSE( q3 )

D ({q2}, e) {q3}

Successors of {q3, q5} over ∑ = {a, b, c, d, e}:-

D ({q3,q5}, a) : 

E ({q3,q5}, a)  E ({q3}, a)U E ({q5}, a)


 U
D ({q3 , q5 }, a)    ECLOSE () 

D ({q3,q5}, b) : 

E ({q3,q5}, b)  E ({q3}, b)UE ({q5}, b)


 U
D ({q3 , q5 }, b)    ECLOSE () 

D ({q3,q5}, c) : 

E ({q3,q5}, c)  E ({q3}, c)UE ({q5}, c)


 U
D ({q3 , q5 }, c)    ECLOSE () 

Automata Fundamentals 1.67

D ({q3,q5}, d) :  V

E ({q3,q5}, d)  E ({q3}, d)U E ({q5}, d)


 U
D ({q3 , q5 }, d)    ECLOSE () 

D ({q3,q5}, e) : 
E ({q3,q5}, e)  E ({q3}, e)UE ({q5}, e)
 {q3} U 
{q3}
D ({q3 , q5}, e)  ECLOSE(q3 )
D ({q3 , q5}, e) {q3,q5}

Transition Table:-

a b c d e
QD
{q0,q1} {q1} {q4,q5} {q2}  
{q1} {q1} {q4,q5} {q2}  
{q4,q5} {q4,q5}  {q2}  
{q2}    {q2} {q3,q5}
*{q3,q5}     {q3,q5}

DFA – Transition Diagram :-

a
{q0 , q1} {q1}

b
b c e

c
{q4, q5} {q2 , q3} {q3, q5}

a
d
1.68 Theory of Computation

3) Consider the following Є – NFA



Є a b c
QE
p {q,r}  {q} {r}

q  {p} {r} {p,q}

*r    

a) Complete the Є – closures of each state


b) Convert the automation to DFA

Solution:-
a)  – closure of states:-
State - Closure
p {p,q,r}
q {q}
r {r}

b) Є NFA → DFA:-
Start state of DFA, qD
ECLOSE (P) = {p, q, r}

Successors of {p, q, r} over ∑ = {a, b, c}:-


D ({p, q, r}, a) : 
E ({p, q, r}, a)  E ({p}, a)UE ({q}, a)UE ({r}, a)
= U{p}U
{p}
D ({p, q, r}, a) ECLOSE(p)
D ({p, q, r}, a) {p, q, r}

D ({p, q, r}, b) : 
E ({p, q, r}, b)  E ({p}, b)UE ({q}, b)UE ({r}, b)
 {q} U {r} U 
{q, r}
Automata Fundamentals 1.69

D ({p, q, r}, b) ECLOSE(q) UECLOSE(r)


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

D ({p, q, r}, c) : 

E ({p, q, r}, c)  E ({p}, c)UE ({q}, c)UE ({r}, c)


 {r} U {p, q} U 
{p, q, r}

D ({p, q, r}, c) ECLOSE(p) U ECLOSE(q)U ECLOSE(r)


{p, q, r}U{q}U{r}

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

Successors of {q, r} over ∑ = {a, b, c}:-


D ({q, r}, a) : 
E ({q, r}, a)  E ({q}, a)UE ({r}, a)
 {p} U 
{p,}
D ({q, r}, a) ECLOSE(p)
D ({q, r}, c) {p, q, r}

D ({q, r}, b) : 
E ({q, r}, b)  E ({q}, b)UE ({r}, b)
 {r} U 
{r}
D ({q, r}, b) ECLOSE(r)
D ({q, r}, b) {r}

D ({q, r}, c) : 
E ({q, r}, c)  E ({q}, c)UE ({r}, c)
 {p, q} U 
{p, q}
1.70 Theory of Computation

D ({q, r}, c) ECLOSE(p) U ECLOSE(q)


D ({q, r}, c) {p, q, r} {p, q, r}U{q}{p, q, r}

Successsors of {r} over ∑ = (a,b,c):-


D ({r}, a) : 
E ({r}, a) 
D ({r}, a)   ECLOSE () 
D ({r}, b) : 
E ({r}, b)  
D ({r}, b)   ECLOSE () 
D ({r}, c) : 
E ({r}, c)  
D ({r}, c)   ECLOSE () 

Transition Table:-

a b c
QD
{p,q,r} {p,q,r} {q,r} {p,q,r}
{q,r} {p,q,r} {r} {p,q,r}
* {r}   

Transition diagram:-

b
{p,q,r} {q,r}
a,c

{r}


You might also like