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

Unit 1 Toc

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

Unit 1 Toc

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

UNIT – I AUTOMATA

Theory of Computation:

1. The theory of computation describes the basic ideas and models underlying computation.
2. Computation is the process of execution of an algorithm such that it involves taking
inputs and performing required operation on it to produce an output.
3. So computation is a sequence of steps that can be performed by the computer.
4. The applications of Theory of computation are compiler design, Robotics, Artificial
Intelligence etc.,

1.1 Automata Theory:

Automata theory is the study of abstract computing devices or “Machines”.

1.1.1 Finite Automata:

1. Finite automata involves states and transitions among states in response to inputs.
2. It is a useful model for many kinds of hardware and software.

Some of the important kinds of software are:

1. Software for designing and checking the behavior of digital circuits.


2. The “lexical analyzer” of a typical compiler
3. Software for scanning large bodies of text, such as collections of web pages, to find
occurrences of words, phrases, or other patterns.
1.1.2 Structural Representation:
There are two important notations that are not automaton-like , but play an important role
in the study of automata and their applications.
1. Grammars are useful models when designing software that processes data with a
recursive structure. Eg., Parser
2. Regular Expressions also denote the structure of data, especially text strings.
1.2 Introduction to Formal Proof

1. In addition to models, it has become traditional for a course on automata theory to cover
methodologies of formal proof.
2. Under this formal proof, we have several methods.

1. Deductive proof.

2. Reduction to definition

3. Other theorem forms.

4. Theorems that appear not to be if-then statements.

1.2.1 Deductive proof:

1. A deductive proof consists of a sequence of statements whose truth leads us from some
initial statement called ‘hypothesis’ or the given statements to a ’conclusion’ statement.
Theorem 1: If x ≥ 4 then 2x ≥ x2

Proof:

Given Hypothesis, H= x ≥ 4

If x = 4 => 24 ≥ 42

=> 16 ≥ 16

Therefore, the conclusion C is true

If x = 5 => 25 ≥ 52

=> 32 ≥ 25

Therefore, C is true

2x ≥ x2 will be true whenever x ≥ 4

L.H.S => As x grows larger than 4, 2x doubles each time x increases by 1.

25 , 26, 27, …..

32, 64, 128…….

( ) ( )
2 2
x+ 1 x+ 1
R.H.S x2 grows by the ratio , by mathematical induction, 1,4,9,25,36...(x+1)2 =
x x

( )
2
2 x+ 1
x =
x

( )
2
4 +1
If x ≥ 4,
4

()
2
5
=
4

= (1.25)2

= 1.5625

( )
2
x+ 1
cannot be greater than 1.5625
x

Conclusion: Since 1.5625 < 2, each time x increase above 4, the L.H.S 2x grows more than the
R.H.S. x2 .
Theorem 2:

If x is the sum of the squares of four positive integers, then 2x ≥ x2

Statement Justification
1. x = a2+b2+c2+d2 Given
2. a≥1, b≥1,c≥1,d≥1 Given
3. a2≥1, b2≥1,c2≥1,d2≥1 (2) and properties of arithmetic
4. x ≥ 4 (1),(3), and properties of arithmetic
5. 2x ≥ x2 (4) andTheorem 2.

Hence it is justified

1.2.2. Reduction to definition:

1. Reduction to definition states that “If you are not sure how to start a proof convert all
terms in the hypothesis to their definition”

Theorem 1: Let S be a finite subset of some infinite set U. Let T be the complement of S with
respect to U. Then T is infinite.

Consider,

U = { 1,2,3,4,…….}

S = {2,3,4}

S∈U

T = {1,5,6,7,…}

T is infinite

Original Statement New statement


S is finite There is a integer such that||S|| = n
U is infinite For no integer p is ||U|| = p
T is the complement of S S ∪ T = U and S ∩ T = ∅

Hence it is justified

1.2.3. Other Theorem Forms:

The other most common forms of statements that we need to prove are as follows:

1. Ways of Saying “If – Then”


2. If-And-Only- If Statements
1. Ways of Saying “If-Then”:

1. The simple “if H then C” form implies: if hypothesis H is true for a given value of
parameter then conclusion C is true for the same value.
2. The other ways of “If H then C “ are
1. H implies C
2. H only if C
3. C if H
4. Whenever H holds C follows

Example :

1. x ≥ 4 implies 2x ≥ x2
2. x ≥ 4 only if 2x ≥ x2
3. 2x ≥ x2 if x ≥ 4
4. Whenever x ≥ 4 holds 2x ≥ x2 follows

2. If –And-Only-If statements:

1. The statement of the form “A if and only if B” and other forms of this statements are
“A iff B”, A is equivalent to B” , or A exactly when B”
2. This statements is actually two if –then statements: “if A then B”, and “if B then A”.
We prove “A if and only if B” by proving these two statements”

1. The if part: “if B then A”, and

2. The only-if part: “if A then B”, which is often stated in the equivalent form “A

only if B”.

3. The operators  and  are used to denote an “if-and-only-if” statement.


4. That is, AB and AB mean the same as “A if and only if B”.

Theorem: Let x be a real number. Then x= x if and only if x is an integer.

Note:

1. x , the floor of real number x, is the greatest integer equal to or less than x.

2. x , the ceiling of real number x, is the integer equal to or greater than x.

Proof:

Only-if part:

Assume x = x , to prove x is an integer.

x ≤ x --------------- 1
x ≥ x -------------- 2

Substitute the floor for the ceiling in - 1

We get x ≤ x

Since both x ≤ x and

x ≥ x

By Arithmetic Inequality

x = x

Since x is always an integer, x must be an integer

If part:

Assume x is an integer, to prove x = x. By the definition of floor and ceiling, when x
is an integer, both x and x are equal to x and therefore equal to each other.

1.2.4. Theorems that appear not to be if-then statements:

In some cases, the theorems appear not to have a hypothesis that are all comes under this
case.

Theorem: sin2θ + cos2 θ

Description: In this theorem, the hidden hypothesis is that, θ is an angle and therefore the
functions sine and cosine have their usual meaning for angles.

1.3 Additional Forms of Proofs:

The additional forms of proofs are

1. Proofs about sets.

2. Proofs by contra positive.

3. Proofs by contradiction.

4. Proofs by counterexample.

1.3.1 Proof about sets:

The sets are set of character strings, and the sets are called “languages”

Theorem: R∪ ( S ∩ T) = (R∪S) ∩ (R∪T).

Proof: The two expressions involved are E = R∪ ( S ∩ T) and F = (R∪S) ∩ (R∪T).

We can write a set-equality E = F as if-and-only statement: an element x is in E if and


only if x is in F.
If –part:

Statement Justification
1. x is in R∪ ( S ∩ T) Given
2. x is in R or x is in S ∩ T (1) and definition of union
3. x is in R or x is in both S and T (2) and definition of intersection
4. x is in R∪S (3) and definition of union
5. x is in R∪T (4) and definition of union
6. x is in (R∪S) ∩ (R∪T) (4),(5) and definition of intersection

Only-if –part:

Statement Justification
1. x is in (R∪S) ∩ (R∪T) Given
2. x is in R∪S (1) and definition of intersection
3. x is in R∪T (2) and definition of intersection
4. x is in R or x is in both S and T (2),(3), and reasoning about unions
5. x is in R or x is in S ∩ T (4) and definition of intersection
6. x is in R∪ ( S ∩ T) (5) and definition of unoin

1.3.2 Proof by Contrapositive:

The contrapositive of the statement “if H then C” is “if not C then not H”. A statement
and its contrapositive are either both true or both false.

Example: If x ≥ 4 then 2x ≥ x2

The Contrapositive of this statement is “if not 2x ≥ x2 then not x ≥ 4.

1.3.3 Proof by Contradiction:

Another way to prove a statement of the form “if H then C” is to prove the statement “H
and not C implies falsehood”.

Theorem: Let S be a finite subset of some infinite Set U. Let T be the complement of S with
respect to U. Then T is infinite.

Proof:

Let us assume “not C”; that is we assumed T is finite.

Our proof is to derive a falsehood from H and not C.

Given:

S∪T = U

Since S and T are disjoint, then


||S|| + ||T|| = ||U||

Assume T is finite [not C]

Since S is finite, ||S|| = n, for some integer n

U is infinite, ||U|| = p, for no integer p.

T is finite (we assumed)

||T|| = m

Then, ||U|| = ||S|| + ||T||

= n+m

This contradicts the given statement that there is no integer p equal to ||U||

Hence proved.

1.3.4 Proof by Counterexamples:

Theorems generally are statements about an infinite number of cases, perhaps values of
its parameters. A statement that just misses being a theorem are comes under this case.

Alleged Theorem: All primes are odd. (formally if integer x is a prime, then x is odd)

Disproof:

The integer 2 is prime but not odd.

Alleged Theorem: There is no pair of integers a and b such that a mod b = b mod a .

2 mod 3 = 3 mod 2

2≠1

In case, if a = b =2

2 mod 2 = 2 mod 2

0=0

Thus we have a disproof of the alleged theorem

1.4 Inductive Proofs:

Consider the statement p(n),where n is an integer varying over the natural number 1,2,3,
…n. The statement p(n) is true for all natural numbers by proving two things.

a) Basis: p(1) is true,


b) Inductive step: If p(k) is true, then p(k+1) is true.

Problems:

1. By using the principles of mathematical induction, prove that 1+2+3+….n = n(n+1) / 2

Solution:

a) Basis: To prove p(1) is true is true.

Assume n = 1

L.H.S., n = 1

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

1(1+1)
=
2

= 2/2

=1

L.H.S = R.H.S

P(1) is true

b) Induction Step:

Assume n = k

K ( K +1)
1+2+3+….k = ----------------1
2

Assume n = k+1

( K +1 ) (K +1+1)
1+2+3+….k+k+1 = --------2
2

Substitute 1 in 2

L.H.S = 1+2+3+….k+k+1

K ( K +1)
= +k + 1
2

K ( K +1 )+ 2( K +1)
=
2

( K +1 ) (K +2)
=
2
( K +1 ) (K +1+1)
=
2

L.H.S = R.H.S

Therefore, if P(k+1) is true, then P(k) is true.

n
n ( n+1 ) (2 n+1)
2. Prove that 1 + 2 + 3 + …….+n = ∑ i =
2 2 2 2 2

i=1 6

Solution:

a) Basis:

To prove p(n) is true

L.H.S = n2

n=1

L.H.S = 12

=1

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

1 ( 1+1 ) (2(1)+1)
=
6

(2)(3)
=
6

(6)
=
6

R.H.S =1

L.H.S = R.H.S

P(1) is true

b) Induction Step:

Assume n = k

k ( k +1 ) (2 k +1)
12 + 22 + 32 + …….+k2 = ---------- 1
6
Assume n = k+1

(k + 1) ( k +1+1 ) (2 (k +1)+ 1)
12 + 22 + 32 + …….+k2 +(k+1)2 = ---------- 2
6

Substitute 1 in 2

L.H.S = 12 + 22 + 32 + …….+k2 +(k+1)2

k ( k +1 ) (2 k +1)
= +(k+1)2
6

k (2 k +1)
= (k+1)[ + k+1]
6

k ( 2 k +1 ) +6 k +6
= (k+1)[ ]
6
2
2 k + k +6 k + 6
= (k+1)[ ]
6
2
2 k + 7 k +6
= (k+1)[ ]
6
2
2 k + 4 k +3 k +6
= (k+1)[ ]
6

2 k ( k +2 ) +3(k +2)
= (k+1)[ ]
6

( k +2 ) (2 k +3)
= (k+1)[ ]
6

( k +1+1 ) +2 ( k +1 ) +1
= (k+1)[ ]
6

= R.H.S

Therefore, if P(k+1) is true, then P(k) is true.

3. Prove that all natural numbers of the form n3 + 2n are divisible by 3 using principle of
induction.

Solution:

P(n) = n3 + 2n

a) Basis: To prove p(1) I true

Let n = 1

P(1) = (1)3 + 2 (1)


= 3 which is a divisible of 3.

b) Induction:

Assume n = n+ 1

P(n+1) = (n+1)3 + 2(n+1)

=(n+1) (n+1)2 +2n +2

= (n+1) (n2 + 2n +1) + 2n +2

= n3 + 2n2+ n + n2+2n +1+ 2n + 2

= n3 + 3n2 + 5n +3

= n3 + 2n + 3n2 + 3n +3

= (n3+2n) + 3(n2+n+1)

n3 + 2n is divisible by 3 which is proved in basis step. The other term 3(n2+n+1) is a multiple of
3, which means it is also divisible by 3.

Therefore, if p(n+1) is true, then P(n) is true.

1.5 The Central Concept of Automata Theory:

The most important definitions of terms that pervade the theory of automata are:

Alphabets:

An alphabet is a finite nonempty set of symbols denoted by the symbol “∑”. Common
alphabet include

1.∑ = {0,1}, the binary alphabet.

2. ∑ = {a, b, …z}, the set of all lower-case letters.

String:

A string (or sometimes word) is a finite sequence of symbol chosen from some alphabets.

Example: 111011 is a string from the binary alphabet ∑ = {0,1}.

Length of the string:

1. The length of the string is the number of positions for symbols in the string.
2. It is common to say that the length of a string is “the number of symbols” in the
string.
3. The standard notation for the length of a string w is |w|.

Example: w = 111011

|w| = 6
Empty String:

1. Empty string is the string with ‘0’ occurrences of symbols which is denoted by epsilon ‘ε
’.
2. Length of the empty string is ‘0’, |ε | = 0

Power of an alphabet:

If ∑ is an alphabet, the power of an alphabet ∑k is the set of all strings of a certain length
k from that alphabet

If ∑ = {a,b,c} then

∑1 = {a,b,c}

∑2 = {aa,ab,ac,ba,bb,bc,ca,cb,cc}

∑3 = {aaa, aab,aac,……}

Note 1: The set of all strings over an alphabet ∑ is denoted by ∑*.

{0,1}* = {ε, 01,00,10,11,000,……}

Another way,

∑* = ∑0 U ∑1U∑2 U ……. (Kleene Closure)

Note 2: The set of nonempty strings from an alphabet ∑ denoted by ∑+.

∑+ = ∑1 U ∑2 U ∑3 …… (Positive Closure)

Concatenation of two strings:

Let x and y be the strings, then xy denotes the concatenation of x and y.

x = a1a2……ai

y = b1b2……bj

xy = a1a2……ai b1b2……bj

Example:

Let x = 1101 and y = 0011. Then

xy = 11010011

yx = 00111101

Languages:

1. Let ∑ be the alphabet set, any subset of ∑* is called a Language.


2. If ∑ is an alphabet, and L⊆ ∑*, then L is a language over ∑.
Example:

Consider the alphabet set {0,1}


1. The language of all string consisting of n 0’s followed by n 1’s, for some n ≥ 0;
{ε, 01,0011,000111,….}
2. The set of strings of 0’s and 1’s with an number of each:
{ε,01,10,0011,1010,1001,……}
3. The set of binary numbers whose value is a prime:
{10,11,101,111,1011,….}

Set-Formers as a Way to Define Language:

It is common to describe a language using a “set-former”:

1. {w| w consists of an equal number of 0’s and 1’s}.

2. {w| w is a binary integer that is prime }

Problems:
1. Given ∑ = {a,b} obtain ∑* .
i) Give an example of a finite language in ∑.
ii) Given L = { an bn; n≥ 0}, check if the string aabb, abb are in the language L.
Solution:
Given ∑ = {a,b}
∑* = {ε, a,b,ab,ba,aaa,….}
i) L = {ab, aabb, aaabbb}
ii) Given L = { an bn }
L = aabb (a2b2)
Here, n = 2
So, aabb is a string in the language L.
L =abb
Number of a’s are not equal to number of b’s, so this string is not in the language L

1.6 Finite Automata


1. A Finite Automaton has a set of states, and its “control” moves from state to state in
response to external “inputs”.
2. Finite Automaton is a mathematical model of a system with discrete inputs and outputs.
3. The system can be in any one of the finite number of states.
4. It is an useful model for many important kinds of hardware and software.

It is classified in to

1. Deterministic Finite Automata


2. Non-Deterministic Finite Automata

Deterministic Finite Automata (DFA):


In DFA, on each input there is one and only one state to which the automaton has
transition from its current state.

Definition of Deterministic Finite Automaton:

A Deterministic Finite Automaton (DFA) consists of 5-tuple:

A = (Q, ∑, δ, q0, F )

Where
A is the name of the DFA
Q = Finite set of “states”
∑ = Finite set of symbols called “Input alphabet”
δ = Transition Function
q0 = Start state
F = Set of Final states or Accepting states

Simpler Notations for DFA’s:

There are two preferred notations for describing automata:

1. Transition Diagram
2. Transition Table

Transition Diagram:

A transition diagram for a DFA A = (Q, ∑, δ, q0, F ) is a graph defined as follows:

a) For each state in Q there is a node.

b) For each state q in Q and input symbol a in ∑, let δ (q,a) = p. Then transition diagram
has an arc from node q to node p, labeled a.

c) There is an arrow into the start state q0, labeled start. This arrow does not originate at
any node.

d) Nodes corresponding to accepting states are marked by a double circle.

1 0 0,1

q0 0 1
q2 q1

Fig: The transition diagram for the DFA accepting all strings with a substring 01.

Transition Table:
1. A transition table is a conventional, tabular representation of a function δ that takes two
arguments and returns a value.
2. The rows of the table correspond to the states, and the columns correspond to the input.

0 1
q0 q2 q0
*q1 q1 q1
q2 q2 q1
Fig: Transition table for the DFA of above diagram

Extending the Transition Function to Strings:

If δ is the transition function, the extended transition function ǧ is a function that takes a
state q and string w and returns a state p – the state that the automaton reaches when starting in
state q and processing the sequence of inputs w.

ǧ(q,w) = δ(ǧ(q,x),a)

Language accepted by a DFA

1. Let A = (Q, S, d, q0 , F ) be a DFA. The language accepted by A is denoted by L(A ) and is


defined by

L(A) = {w | ǧ(q0,w) is in F}

That is, The language of A is the set of strings w that take the start state q0 to one of the
accepting states.

2. If L is L(A) for some DFA A, then we say L is a regular language.

Problems:

1. Consider the DFA, the transition diagram as follows:

q0 q1
a
b
b
b b

a
q2 q3

i) Construct the equivalent transition function and table


ii) Find δ(q0, ababa), δ(q1, b3), δ(q3, b4), δ(q3, ε)

Solution: Transition table:

a b

q0 q1 q2
q1 q0 q3
Transition q2 q3 q0 function:
*q3 q2 q1
δ(q0 , a) = q1
δ(q0 , b) = q2
δ(q1 , a) = q0
δ(q1 , b) = q3
δ(q2 , a) = q3
δ(q2 , b) = q0
δ(q3 , a) = q2
δ(q3 , b) = q1
ii) δ(q0, ababa) = δ(q1, baba)
= δ(q3, aba)
= δ(q2, ba)
= δ(q0, a)
δ(q0, ababa) = q1
δ(q1, b3 ) = δ(q1, bbb)
= δ(q3, bb)
= δ(q1, b)
= q3
δ(q1, b4 ) = δ(q3, bbbb)
= δ(q1, bbb)
= δ(q3, bb)
= δ(q1, b)
= q3
δ(q3, ε) = q3

2. Construct the finite automata for the language i) L = { 1n | n , n ≥ 0} ii) L = { 1n | n, n≥ 1}.


Draw transition diagram.

Solution: i)
1

q0

L = 0,1, 12, 13, 14, 15,….1n

∑* = { ∑0 U ∑1 U ∑3,……}

0 = ε ( empty set)

Epsilon will be accepted when initial state equals final state.

ii)

1
q0 q1

L = 1, 12, 13, 14, 15,….1n

3. Design a DFA that accepts the string defined by the language L = { an b ; n≥1} ( Epsilon do
not accepted)

b
q0 q1

L = { b, ab, a2b, ……}

4. Design a DFA that recognizes the set of all strings on ∑ = { a, b} starting with the prefix ab.
a,b
a b
q0 q1 q2

Language L = { ab, aba, abb,abaa,abbb…..}

5. Construct the DFA that will accept the string on {a, b} where the number of b’s divisible by 3.
Draw also the transition table.

Transition Table:
δ a b
q0 q0 q1
q1 q1 q2
q2 q2 q0

Language L = {bbb, babb,bbab,bbba…}

1.7 Non-Deterministic Finite Automata: (NFA)

1. In NFA, for a given input symbol there are zero, one or more number of transitions to
next state from a given state.
2. A Non- Deterministic Finite Automaton (NFA) in a 5-tuple notation

A = (Q, ∑, δ, q0 , F )

where
Q = Finite set states
∑ = Finite set of input symbols
δ = Transition Function
q0, a member of Q, is the start state
F⊆ Q Set of Final states
Difference between NFA and DFA.

S. No NFA DFA
1 δ is a transition function that takes a state and The transition function returns
input symbol as argument but returns a zero, one exactly one state
or more states.
2 Q×(∑U{ε})2Q Q×∑Q

NFA:

0
0

q1
q0

DFA:

1
q1
q0

The language of an NFA:

L(A) = { w| δ(q0,w) ∩ F ≠ ∅}

L(A) is the set of strings w in ∑* such that δ(q0,w) contain at least one accepting state.

Problems:

1. Consider the NFA whose transition diagram is


1,0

1 1,0
q0 q1 q2

Find 01010.

δ(q0,01010) = δ(q0,1010)
= δ({q0,q1}, 010)
= δ(δ(q0,0)U δ(q1,0),10)
= δ({q0}U{q2}, 10)
= δ({q0,q2},10)
= δ(δ(q0,1)U δ(q2,1),0)

= δ({q0,q1}U{∅ },0)
= δ(δ(q0,0)U δ(q1,0))
= {q0 U q2}
= (q0, q2 ) ∩ F ≠ ∅
= (q0, q2 ) ∩ q2
= q2 (Which is a final state)
The given string 01010 is accepted by NFA.

2. Obtain an NFA which should accept a language L, given by L {x ∈{ a,b}* :| x | 3 }and
third symbol of x from the right is {‘a’}.
The conditions are
(a) the last two symbols can be ‘a’ or ‘b’.
(b) third symbol from the right is ‘a’
(c) symbol in any position but for the last three position can be ‘a’ or
‘b

L = {aaaa, aaab ,baaa,aabb, babb,aaa..}

3. Determine an NFA accepting all strings over {0,1} which end in 1 but does not contain the
substring 00.
The conditions to be satisfied are:
(a) String should end in a 1
(b) String should not contain 00.
L = {1,11,1101,101…}

4. Construct an NDFA for all strings over alphabet ∑ = {a,b} that contains a substring ‘ab’.

a,b a,b

a b
q0 q1 q2

Language L = {aab, bab, aba,abb,…}

1.8 EQUIVALENCE OF NFA AND DFA:

Theorem: Let L be a set accepted by NFA, then there exists a DFA that accepts L.

L(D) = L(N)

This proof uses a method “Subset construction” because it involves constructing all subset of the
set states of the NFA.

Let N = (QN, ∑, δN, q0 , FN ) be the NFA for language L.

D= (QD, ∑, δD, q0 , FD ) is the DFA.

The states of D are all the subsets of the set of states N.

i.e., QD=2Q N

The elements of QD is denoted by by [q1,q2,q3…qi]

Where q1,q2,q3…qi are in Q.


We define

δD ([q1,q2,q3…qi],a) = [p1,p2,p3…pj]
if and only if ,
δN ({q1,q2,q3…qi},a) =[p1,p2,p3…pj ]
So we claim that
δD ([q1,q2,q3…qi],w) = [p1,p2,p3…pj]
if and only if
δN ({q1,q2,q3…qi},w) ={p1,p2,p3…pj}

where ‘w’ be the string

Then the theorem can be proved by induction method.

Basis:

Consider the length of the string n=0, i.e., |w|=0

The string w should be ϵ(i.e., w= ε)

δD({q0},ε) = q0

δN(q0,ε) = q0

So, it is true for the length n=0

Induction Step:

Let w be the length n+1, Break w up as w = xa, where a is the final symbol of w.

Then the function δD could be written as

δD(q0,xa) = δD(δD(q0,x),a)

δD(q0,x) = [p1,p2,p3…pj]

if and only if

δN(q0,x) = [p1,p2,p3…pj]

By the definition of δD

δD([p1,p2,p3…pj],a) = [r1,r2,r3…rk]

if and only if,

δN({p1,p2,p3…pj},a) ={r1,r2,r3…rk}

Thus,

δD(q0,xa) = [r1,r2,r3…rk]

δN(q0,xa) = [r1,r2,r3…rk]

is shown by induction method


L(D) = L(N)
i.e., w is accepted by D if and only if it accepted by N.
Problems:

1. Construct the DFA equivalent to the given NFA

δ 0 1
p {p,r} {q}
q {r,s} {p}
*r {p,s} {r}
*s {q,r} ∅
Solution:
δ(p,0) = {p,r}
δ(p,1) = {q}
δ({p,r},0) = δ(p,0) U δ(r,0)
= {(p,r) U (p,s)}
={p,r,s}
δ({p,r},1) = δ(p,1) U δ(r,1)
= {q U r}
= {q,r}
δ(q,0) = {r,s}
δ(q,1) = {p}
δ({p,r,s},0) = δ(p,0) U δ(r,0) U δ(s,0)
= {(p,r) U (p,s) U (q,r)}
= {p,q,r,s}
δ({p,r,s},1) = δ(p,1) U δ(r,1) U δ(s,1)
= {q U r U ∅ }
= {q,r}
δ({q,r},0) = δ(q,0) U δ(r,0)
= (r,s) U (p,s)
= {p,r,s}
δ({q,r},1) = δ(q,1) U δ(r,1)
= {p U r}
= {p,r}
δ({r,s},0) = δ(r,0) U δ(s,0)
= (p,s) U (q,r)
= {p,q,r,s}
δ({r,s},1) = δ(r,1) U δ(s,1)
= {(r) U ∅ }
= {r}
δ({p,q,r,s},0) = δ(p,0) U δ(q,0) U δ(r,0) U δ(s,0)
= {(p,r) U (r,s) U (p,s) U (q,r)
= {p,q,r,s}
δ({p,q,r,s},1) = δ(p,1) U δ(q,1) U δ(r,1) U δ(s,1)
= {q U p U r U∅ }
= {p,q,r}
δ({p,s},0) = δ(p,0) U δ(s,0)
= (p,r) U (q,r)
= {p,q,r}
δ({p,s},1) = δ(p,1) U δ(s,1)
= {qU ∅ }
= {q}
δ({p,q,r},0) = δ(p,0) U δ(q,0) U δ(r,0)
= (p,r) U (r,s) U (p,s)
= {p,r,s}
δ({p,q,r},1) = δ(p,1) U δ(q,1) U δ(r,1)
= {qUpUr}
= {p,q,r}
Transition Table:

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

Transition Diagram:

0 0
p q3
p,r p,r,s
1
0
1
q
1 p,q,r,s

0 1
0

0
q,r 0 r,s
p,q,r
p,s
0 1
1.9 Finite Automata with Epsilon transitions:

An NFA is allowed to make transition spontaneously, without receiving an input symbol.


This move is called ϵ - move or ϵ transitions.

Formal Notation for an ϵ - NFA:


We represent an ϵ - NFA A by
A = (Q, ∑, δ, q0 , F )

δ function takes the arguments:

1. A states in Q and
2. A member of ∑∪ { ϵ } , i.e., either an input symbol or the symbol ϵ.

Epsilon Closure:

ϵ - closure of a state is that all transitions out of that state that are labeled ϵ.

Example:

0 1 0

ϵ ϵ 1
q0 q1 q2 q3

ϵ - closure (q0) = {q0,q1,q2}


ϵ - closure (q1) = {q1,q2}
ϵ - closure (q2) = {q2}
ϵ - closure (q3) = {q3}

Extended Transitions and Langauge for ε-NFA:

1. δ(q,ϵ) = ϵ - closure (q)


2. For w in ∑*, and a in ∑
δ(q,wa) = ϵ - closure δ(δ(q,w),a)
1. The language accepted by ε-NFA is defined as
L(M) = {w | δ(q0,w) contains a state in F}

Theorem: A Language L is accepted by some ε-NFA if and only if L is accepted by some DFA.

Proof : If Part

Suppose L= L(D) for some DFA, turn D in to an ε-DFA E by adding δ(q, ε) =  for all
states q of D.
Then, we must also convert the transition on D on input symbol e.g δD(q, a) = p in an
NFA – transition to the set containing only p, i.e δE(q, a) ={p}. Thus the transition of E and D
are same.

Only if part:

Let E=(QE,∑,δE,q0,FE) be an ε-NFA .We need to apply modified subset


construction to DFA.

D = (QD, ∑, δD, qD, FD)

We need to show that

L(D) = L(E)

δE(q0, w) = δD(qD, w)

by induction on the length w.

Basis:

If |w| = 0, then w = ε

δE(q0, ε) = ε-closure(q0 )

δD(qD, ε) = qD = ε-closure(q0 ) [ because that is how the start


state of D is defined]

It is true for |w| = 0.

Induction:

Le n+1 be the length of the string.

Suppose w = xa, where a is the final symbol of w.

consider,

δE(q0, x) = {p1,p2,……. pk }

δE({p1,p2,……. pk }, a) = ε-closure δ (p1, a) U δ (p2, a)U… δ (pk, a)

= ε-closure r1 U r2 U…rj

= ¿ j=1¿ m❑ ϵ-closure rj

δE(q0, w) = δD(qD, w)

• It is also true for length n+1

• Hence proved.
1. Consider the NFA with ϵ- moves, the transition diagram is given by

q2 q4

a
b b a

ϵ ϵ ϵ
q0 q1 q3 q5

Find i) δ(q0,ϵ) ii) δ(q0,aba) iii) δ(q0,abb)

Solution:

i) δ(q0,ϵ) = ϵ - closure q0
= { q0,q1,q3,q5 }

ii) δ(q0,aba) = ϵ - closure δ(δ(q0,ϵ),aba)


ϵ - closure δ(δ(q0,ϵ),a) = ϵ - closure δ{( q0,q1,q3,q5),a)
= ϵ - closure δ(q0,a) U δ(q1,a) U δ(q3,a) U δ(q5,a)
= ϵ - closure () U (q2) U() U ()
= ϵ - closure (q2)
= q2
ϵ - closure δ(δ(q0,ϵ),ab) = ϵ - closure δ{( q0,q1,q3,q5),ab)
= ϵ - closure δ(q2,b)
= ϵ - closure (q1)
= { q1,q3,q5 }
ϵ-closure δ(δ(q0,ϵ),aba) = ϵ - closure δ{(q1,q3,q5),a)
= ϵ - closure δ(q1,a) U δ(q3,a) U δ(q5,a)
= ϵ - closure (q2) U() U ()
δ(q0,aba) = q2

iii) δ(q0,abb) = ϵ - closure δ(δ(q0,ϵ),abb)


We already found,
ϵ - closure δ(δ(q0,ϵ),a) = q2
ϵ - closure δ(δ(q0,ϵ),ab) ={ q1,q3,q5 }

ϵ - closure δ(δ(q0,ϵ),abb) = ϵ - closure δ{(q1,q3,q5),b)


= ϵ - closure δ(q1,b) U δ(q3,b) U δ(q5,b)
= ϵ - closure () U (q4) U()
= ϵ - closure (q4)
δ(q0,abb) = q4

Eliminating ϵ - Transitions:

1. Remove all ϵ -move from NFA, the transition is given by

a b c

ϵ ϵ
q0 q1 q2

ϵ - closure (q0) = {q0,q1,q2}


ϵ - closure (q1) = {q1,q2}
ϵ - closure (q2) = {q2}
δ(q0,a) = ϵ - closure δ{(q0,ϵ),a}
= ϵ - closure δ{(q0,q1,q2),a}
= ϵ - closure δ{(q0,a) U(q1,a) U (q2,a)}
= ϵ - closure {q0} U{} U {}
= ϵ - closure {q0}
= {q0,q1,q2}

δ(q0,b) = ϵ - closure δ{(q0,ϵ),b}


= ϵ - closure δ{(q0,q1,q2),b}
= ϵ - closure δ{(q0,b) U(q1,b) U (q2,b)}
= ϵ - closure {}U{q1} U {}
= ϵ - closure {q1}
= {q1,q2}

δ(q0,c) = ϵ - closure δ{(q0,ϵ),c}


= ϵ - closure δ{(q0,q1,q2),c}
= ϵ - closure δ{(q0,c) U(q1,c) U (q2,c)}
= ϵ - closure {}U{}U {q2}
= ϵ - closure {q2}
= {q2}

δ(q1,a) = ϵ - closure δ{(q1,ϵ),a}


= ϵ - closure δ{(q1,q2),a}
= ϵ - closure δ{(q1,a) U (q2,a)}
= ϵ - closure {} U {}
= ϵ - closure {}
= {}
δ(q1,b) = ϵ - closure δ{(q1,ϵ),b}
= ϵ - closure δ{(q1,q2),b}
= ϵ - closure δ{(q1,b) U (q2,b)}
= ϵ - closure {q1} U {}
= ϵ - closure {q1}
= {q1,q2}
δ(q1,c) = ϵ - closure δ{(q1,ϵ),c}
= ϵ - closure δ{(q1,q2),c}
= ϵ - closure δ{(q1,c) U (q2,c)}
= ϵ - closure {} U {q2}
= ϵ - closure {q2}
= {q2}
δ(q2,a) = ϵ - closure δ{(q2,ϵ),a}
= ϵ - closure δ{(q2),a}
= ϵ - closure {}
= {}

δ(q2,b) = ϵ - closure δ{(q2,ϵ),b}


= ϵ - closure δ{(q2),b}
= ϵ - closure {}
= {}

δ(q2,c) = ϵ - closure δ{(q2,ϵ),c}


= ϵ - closure δ{(q2),c}
= ϵ - closure {q2}
= {q2}

a b c

a,b
q0 q1 c,b q2

a,b,c

Converting ϵ-NFA to DFA:

1. Consider the following ϵ - NFA. Compute the ϵ - closure of each state and find it equivalent
DFA.

ϵ a b c
P {q,r}  {q} {r}
q  {p} {r} {p,q}
r    {r}
b

c
ϵ
p q

a,c
b
ϵ

c
r

ϵ-closure(p) = {p,q,r}
ϵ-closure(q) = {q}
ϵ-closure(r) = {r}
DFA construction:
1. Start state p = ϵ-closure(p) = {p,q,r}
2. Find the transitions for new states
ϵ-closure (p,a) = ϵ-closure δ{(p, ϵ),a)
= ϵ-closure δ{(p,q,r),a}
= ϵ-closure δ(p,a) U δ(q,a)U δ(r,a)
= ϵ-closure()U (p)U ()
= ϵ-closure(p)
= {p,q,r}
ϵ-closure δ{(p,q,r),a} = ϵ-closure δ{(p,q,r),a}
= ϵ-closure δ(p,a) U δ(q,a)U δ(r,a)
= ϵ-closure()U (p)U ()
= ϵ-closure(p)
= {p,q,r}
ϵ-closure δ{(p,q,r),b} = ϵ-closure δ{(p,q,r),b}
= ϵ-closure δ(p,b) U δ(q,b)U δ(r,b)
= ϵ-closure(q)U (r)U ()
= ϵ-closure(qUr)
= ϵ-closure (q) U ϵ-closure(r)
= {q,r}U{r}
={q,r}
ϵ-closure δ{(p,q,r),c} = ϵ-closure δ{(p,q,r),c}
= ϵ-closure δ(p,c) U δ(q,c)U δ(r,c)
= ϵ-closure (r) U (q,r) U (r)
={p,q,r}
ϵ-closure δ{(q,r),a} = ϵ-closure δ{(q,r),a}
= ϵ-closure δ(q,a)U δ(r,a)
= ϵ-closure (p)U ()
= ϵ-closure(p)
= {p,q,r}
ϵ-closure δ{(q,r),b} = ϵ-closure δ{(q,r),b}
= ϵ-closure δ(q,b)U δ(r,b)
= ϵ-closure (r)U ()
= ϵ-closure(r)
= {r}
ϵ-closure δ{(q,r),c} = ϵ-closure δ{(q,r),c}
= ϵ-closure δ(q,c)U δ(r,c)
= ϵ-closure (p,q)U (r)
= {p,q,r}
ϵ-closure δ(r,a) = ϵ-closure 
=
ϵ-closure δ(r,b) = ϵ-closure 
=
ϵ-closure δ(r,c) = ϵ-closure(r,c)
= ϵ-closure r
= {r}
b
c

r q,r

a,c

p,q,r b

a,c

You might also like