FLAT - UNIT1 - Regulation18
FLAT - UNIT1 - Regulation18
Introduction:
Working of every process can be represented by means of model. The model can be a
theoretical or mathematical model. The model helps in representing the concept of every
activity.
Finite Automata
Pushdown Automata
Linear Bounded Automata
Turing Machine
The logic or behavior of such models can be well understood with the help of Proof.
1. Automata Theory: Some mathematical model done automatically. This type of study is
called automata theory. Example: Calculator and Computer perform the task
automatically.
2. Computability Theory: All problems have not solved by all devices. Each device has some
limitations. In this model, we have to study the problem has been solved or not.
3. Complexity Theory: Different ways are used to solve a particular problem/task. This type
of study is used to select one of the efficient ways and to measure the efficient of that
model that is if a problem is possible to solve, how much time or space has taken.
1
The different models are,
Finite Automata
Push Down Automata
Turing Machine
Automata Theory:
Automata theory is the base of computation. The automata theory has four models.
The authors were proposed many models but some of them were implemented.
i) Finite Automata(FA):
Finite means limited amount of memory and process. Automata describe the process
has perform automatically. Finite automata (automaton- singular) are the simplest type of
abstract machine, also called Finite State Machine (FSM). It can solve problem without
memory. Example, Automated door in shopping mall.
iii) Linear Bound Automata (LBA): This model overcomes the previous one. The PDA has not
possible of random element selection. The LBA has finite length of tape as a memory unit,
2
which can be divided into number of cells. Elements can be stored in each cell. We can
move left and right-side direction, but in PDA, it is not possible. It recognizes context
sensitive language. The disadvantage of this model,tape size is limited and finite size.
iv) Turing Machine (TM): Alan Turing, British mathematician developed TM is more powerful
than other models. It has infinite amount of Tape (auxiliary) memory accessible in both
directions that is left or right. Itrecognizes recursive enumerable languages. Turing
machine can solve all type of problems as computer performs the task in now days. If a
function not computable by TM, it can’t be computed even by digital computer.
Formal proof is the proof in which we try to prove that statement B is true
because statement A is true, where statement A is called Hypothesis and
statement B is called Conclusion statement. If A then B means we say that B is
deduced from A.
2. Reduction to Definitions:
If the hypothesis does not use familiar terms like integer, multiplication, addition etc., then we
can convert all terms in the hypothesis to their definitions.
Theorem: A set S is finite. If there exists an integer n such that S has exactly n elements. |s|
= n, where n denotes the number of elements in the set S. If S and T are both subsets of
some infinite set U, then T is the complement of S(with respect to U) if SUT = U and S ∩ T =
Ф. Then T is infinite.
4
Proof: We can use proof by contradiction. It is a technique where we assume that the
conclusion is false. Then use that assumption together with hypothesis, prove the opposite of
one of the given statements of the hypothesis. So, the only possibility that remains is that the
conclusion is true whenever the hypothesis is true.
Here T is finite (because we assume the conclusion is false), but T is infinite (Given).
Let us assume T is finite, along with the statement of the hypothesis, S is finite.
ie.,|S|= n for some integer n.
|T|= m for some integer m.
n
n>= 1 only if ∑ i∗2 < n∗2
i n+1
1
n
∑ i∗2i< n∗2n+1 if n ≥1
1
n
∑ i∗2i< n∗2n+1 if n ≥1 follows
1
In formal logic, the operators ⟷or ≡ to denote an “if – and - only – if” statement.
This statement is actually two if-then statements: “if A then B “and “if B then A”
5
Theorem: Let x be a real number. Then |x| =⌈x⌉if and only if x is an integer.
⌈x⌉, ceiling of real number x, is the least integer equal to or greater than x]
[Note: |x|, floor of real number x, is the greatest integer equal to or less than x.
Proof:
⌈x⌉≤|x|
Substituting 1 in 2, we get
6
x is in R ꓴ( S ∩ T)
x is in R or x is in (S ∩ T)
x is R or x is in both S and T
x is in R ꓴ S
x is in (R ꓴ S) ∩(R ꓴ T)
ii) We can also prove it by “only – if” statement.
x is in (R ꓴ S) ∩(R ꓴ T)
x is in R ꓴ S
x is in R ꓴ T
x is in R or x is in both S and T
x is in R or x is in S ∩ T
xis in R ꓴ( S ∩ T)
P Q PQ
T T T
T F F
F T T
T T T
“if P then Q” and “ if not Q then not P” are logically equivalent. This logical equivalence is,
P Q ¬P ¬Q PQ ¬ P ¬ Q
T T F F T T
T F F T F F
F T T F T T
F F T T T T
Example:
if x ≥ 4 the 2x ≥ x2. The contrapositive of this statement is “if not 2x ≥x2, then not x ≥ 4”.
Therefore, not x ≥ 4 is x < 4
not 2x ≥ x2 is 2x< x2
7
ie., “if 2x< x2, then x < 4”
Proof by Contradiction:
In proof by contradiction, we assume that the theorem is false and then show
that this assumption leads to an obviously false consequence, called a contradiction.
ie., To prove a statement of the form “if H then C” is to prove the statement “H and
not C implies falsehood”.
Step a: State by assuming both the hypothesis H and the negation of the
conclusion C.
Step b: Compute the proof by showing that something known to be false
follows logically from H and C. This form of proof is called proof by contradiction.
Theorem: Let S be a finite subset of some infinite set U. Let T be complement of S
with respect to U. Then T is infinite.
Proof:H = “S is finite set of U.
U is an infinite set,
T is the complement of S w.r.t U”
Conclusion C = “T is infinite”
We proceed to prove the theorem by proof by contradiction.
We assume, not C is true ie., T was finite.
From the assumption S is finite, if T is also finite, then U = S ꓴ T is also finite. But
hypothesis says U is infinite. Therefore, the logical statement is false.
2. Proof by Counter Examples: In order to prove certain statements, we need to see all
possible conditions in which that statement remains true.
Example : There is no such pair of integers such that a mod b = b mod a
Proof: Consider a = 2 and B= 3, then
2 mod 3 ≠ 3 mod 2
Thus, the given pair is true for any pair of integers but if a = b then naturally a mod b =
b mod a
Thus, we need to change the statement slightly. We can say: a mod b = b mod a, when
a= b
Since proof is true only at some specific condition.
Inductive Proof:
Inductive proofs are special kind of proofs which is used to prove recursively defined objects
like tree, expressions of various sorts etc. This type of proof is also called as “ Proof by
mathematical induction”.
The proof by mathematical induction can be carried out using following steps:
8
Let there be a given statementP(n) involving natural numbers n,
(i) Basis: In this step we assume the lowest possible value. This is the initial step. Statement is true
for n = 1
ie. P(1) is true. [Note : Suppose x ≥ 5, the 1st step is P(5)]
(ii) Induction Hypothesis: Let the statement be true for n=K, where K is some positive integer.
(Assumption)
(iii) Inductive Step: If statement P(K) is true we establish that P(K+1) is also true.
(ie.,) truth of P(K) truth of P(K+1).
Solution:
n(n+1)
Let P(n) = 1 + 2 + 3 + . . . + n = (Given)
2
Basis: For n = 1
1(1+1)
P(1) : 1 =
2
1=1
i.e. P(1) is true.
Inductive Step: We shall now prove thatP(K +1) is also true whenever P(K) is true
P(K + 1) : 1 + 2 + 3 + . . . + K + (K+1)
K ( K +1)
= + (K + 1) by equation 1.
2
K ( K +1 )+ 2( K +1)
=
2
9
( K +1)(K +2)
=
2
(k + 1)(K +1+1)
=
2
( K +1)(( K+ 1)+1)
=
2
Thus P(K +1) is true whenever P(K) is true. Hence, the statement P(n) is true for all n ≥ 1
Solution:
2
Let P(n) = 1 + 3 + 5 + . . . + (2n – 1) = n ------ Given
Basis :for n = 1
2
P(1) : 1 = 1
1 = 1 i.e. P(1) is true
Induction Hypothesis:
AssumeP(K) is true, where K is some positive integer.
2
P(K) : 1 + 3 + 5 + . . . (2K – 1) = K --------------- 1
Inductive Step :
We shall now prove that P(K + 1) is also true whenever P(K) is true.
P(K + 1) = 1 + 3 + 5 + . . . (2K – 1) + 2((K + 1) – 1)
2
= K + 2K + 1
2
=K +K+K+1
= K ( K + 1) + 1(K + 1)
= (K + 1)(K + 1)
2
= (K + 1)
Thus P(K + 1) is true whenever P(K) is true for all n ≥ 1
1 1 1 1 n
5. Prove that + + +…+ = for all n ≥ 1
1. 2 2. 3 3 . 4 n .(n+1) n+1
Solution:
1 1 1 1 n
Given, P(n): + + +…+ =
1. 2 2. 3 3 . 4 n .(n+1) n+1
Basis : For n = 1,
11
1 1
P(1) : =
1. 2 1+ 1
1 1
=
2 2
Hence, P(1) is true.
Induction hypothesis:
Let us assume,
1 1 1 1 K
P(K): + + +…+ = is true -------1
1. 2 2. 3 3 . 4 K . (K +1) K +1
where K is positive integer
Inductive step: P(K+1) is true, since P(K) is true.
1 1 1 1 1
P(K+1) : + + +…+ +
1. 2 2. 3 3 . 4 K . ( K +1 ) ( K +1 )( K +1 )+1
K 1
= + [From equation 1]
K +1 ( K +1 )( K + 2 )
K ( K + 2 )+ 1
=
( K +1 )( K + 2 )
2
K +2 K +1
=
( K +1 )( K + 2 )
2
(K +1)
=
( K +1 )( K + 2 )
K +1
=
( K +1+1 )
Hence P(K+1) is true.
Basic Definitions of Automated Theory:
1. Set: Set is used to represent the mathematical model. Set is defined as collection of objects.
These objects are called elements of the set.All the elements are enclosed within curly
brackets {&} and every element is separated by commas.
If ‘a’ is an element of set A then we say that a ∈ A and if ‘a’ is not an element of A then we say
that a∉A.
Typically set is denoted by a capital letter. The set can be represented using 3 methods.
(a) Listing method: The elements are listed in the set.
Example: A set of elements which are less than 5. The A = {0, 1, 2, 3, 4}
(b) Describing properties: The properties of elements of a set.
Example: A set of vowels vowel is a property of the set which defines the set as,
A = {a, e, i, o, u}
(c)Recursion method: The recursion occurs to define the elements of the set.
12
This defines the set as,
A = {0, 1, 4, 9, 16, 25, …100}
2. Subset: A set ‘A’ is said to be a subset of ‘B’ if every element of A is present in B. We write
3. Empty Set: the set having no element. It is denoted by A = { } and it can be written as
Ф(phi).
5. Equal set: The two sets are said to be equal (A = B) if A ⊆ B and B ⊆ A. i.e every element of
set A is an element of B and vice versa. Example: A = {1,2,3} & B= {1,2,3} then A= B
13
9. Length of a string: The length of a string is the number of symbols in the string. The
length of a string ‘w’ is written as |w|.
Example: w = 101101 the |w| = 6.
10.Empty or Null string: The empty string is the string with zero occurrences of symbols. It
is represented by ε or λ. (epsilon or lambda)
12.Reverse of a string: The reverse of a string is obtained by writing the symbols in reverse
order.
Example: U = 01011 then UR = 11010
13.Concatenation of string: The concatenation of two strings U and V is the string obtained
by appending the symbols of V to the right end of U.
15.Kleene Closure (or) Kleene star (∑*):The Kleene star, Σ* is a unary operator on a set of
symbols or strings, Σ, that gives the infinite set of all possible strings of all possible lengths
over Σ including ε or λ. It is represented by,
¿
L =¿ i=0 ¿ ∞ Li [zero or more occurrence of strings]
transition]
15
ii) Recognizing a string ‘the’. State state: 1
Final state: 4
Input symbols: t,h,e
The read head examines the cells one by one from left to right and at a time only
one input symbol is read.
Example:
Here, q0,q1,q2 are states,q0 is start state and q2 is the final state or acceptance state.
2. Transition Table:
Transition table is a tabular representation of finite automata. For transition table the
transition function is used.
Example: (i)
Transition Table:
A string ‘x’ is accepted by finite automata, M = (Q, ∑, 𝛿, q0, F) only if 𝛿 (q0, x) = P for
Language Acceptance by FA/ Language of FA:
some P in F. This concludes that the string is accepted when it enters into the
final state on the last input element.
The language accepted by M which is denoted by L(M)
Inputs
States
0 1
18
*q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Basis: (q, ε) = q. That is, if we are in a state q and read no inputs, then we are still in
state q.
thestring consisting of all but the last symbol ‘a’[For example, w=1101 is broken
Induction: Suppose w is a string of the form xa; that is,‘a’ is the last symbol of w, and x is
To compute (q, w), first compute (q, x), the state that the automaton
is in after processing all but the last symbol of w.
Suppose this state is p, ie., (q, x) = p
Then (q, w) is what we get by making a transition from state p on
input a, the last symbol of w. That is (q, w) = 𝛿(p, a)
Example 2:
Inputs
States
0 1
q0 q0 q1
q1 q2 q1
*q2 q2 q2
In state q0, when input is 0, the transition is q0, when the input is 1, the transition is q1.
In state q1, when input is 1, the transition is q1 and when the input is 0, we have the
transition q2. In state q2, when the input is 0 and 1, the transition is in same state.
20
Dead State/Trap State/Dump state:
A dead state is state from where the automaton cannot reach an accept state.
EXAMPLES of DFA :
1. Design a DFA that accepts set of string such that every string ends with 00, over
alphabet{0,1}.
Solution:
Let M = (Q, Σ, δ, q0, F) be the DFA
According to the problem we have to design a DFA which accepts strings w00. Where ‘w’
can be any combination of 0’s and 1’s such that,
L / Σ*= {00, 100, 000, 1100,101000, . . . . . . }
From the above transition diagram, each state has one and only transition for each input
symbol. The five tuples of DFA M are,
M = {{q0, q1, q2},{0, 1}, δ, q0,q2}
Transition Table:
Inputs
States
0 1
q0 q1 q0
q1 q2 q0
*q2 q2 q0
Consider the string 1100. If this string is accepted by the DFA then by taking this string
will reach to the final state otherwise it will not reach the final state.
δ (q0, 1100) = δ(q0, 1100)
= δ(δ(q0, 1), 100) [ input 1 on state q0, then it will go to state q0]
= δ(q0, 100)
= δ(δ(q0, 1), 00)
= δ(q0, 00)
=δ(δ(q0, 0), 0)
=δ(q1, 0)
21
=q2 [ q2 is final state]
Hence, the given string is accepted as it reaches at the final state q2.
2. Design a DFA for string with at least two consecutive zero which is anywhere in the
string.
Solution:
According the problem we have to design a DFA which accepts string w00w. Where ‘w’
can be any combination of 0’s and 1’s such that,
L={00, 100, 1001, 10100, 0011,100010 . . . . . . . }
3. Design a DFA for string which accept a string containing ‘aba’ as its substring over
Σ* such that Σ = {a, b}.
Solution:
According the problem we have to design a DFA which accepts string wabaw. Where ‘w’
can be any combination of a’s and b’s such that,
L={aba, aaba, abab, aabaa, bbababb, . . . . . . . }
4. Design a DFA for string which accepts set of all string on Σ = {a, b} with no more than
three a’s.
Solution:
Here we have design a DFA which accepts strings of any combination of a’s and b’s but do
not more than three a’s such that,
L/Σ* ={a, b, aa, bb, aba, abb, aab, aaabb, . . . . }
22
5. Design a DFA that accepts the language
L={ w ∈ (0, 1)* | second symbol of w is 0 and fourth input is 1}
Solution:
Here we have to design a DFA in which the number 0 should be at 2 nd position and
1 will be at 4th position such that,
9. Construct a DFA for the set of strings over {a, b, c} having ‘bca’ as substring.
Solution:
Here we have to design a DFA which accepts string ‘bca’ as a substring.
i.e. w= x bca x. where x can be any combination of a’s, b’s and c’s.
L= {bca, abca, bbcaaa, cbcabc, . . . .}
10. Design a DFA for the language L = {w | n a(w) ≥ 1, w∈(a, b)*} where na is number
of a’s in string.
Solution:
Here we have to design a DFA in which numbers of a’s in the strings is one or
more. b’s can occur for any number of times at any place. i.e.
L= { a, aa, aaa, ba, bba, bbabb, bbbbba, abbbbba, . . . . . . . . }
24
11.Give DFA accepting the language over the alphabet {0, 1}. “ The set of all strings
whose tenth symbol from the right end is a 1”.
0 1
A A B
*B B A
Therefore, L = 0*1(11)*0* . It is defined by the statement that “The set of strings of 0’s and
1’s containing odd number of 1’s”.
13.Describe the language accepted DFA M= ({q0,q1,q2},{0, 1},q0, δ,{q1}, where δ is
given by,
Inputs
States
0 1
q0 q0 q1
q1 q0 q2
q2 q2 q1
Solution:
25
Examples: (String testing)
1. δ (q0, 0)= q0 Non accepting state
2. δ (q0, 01)= q1 Accepting state
3. δ (q0, 01101)= q1 Accepting state
4. δ (q0, 11)= q2 Non accepting state
Hence the above DFA accepts 01,01101, 101,0111. That is odd number of ones.
i.e. L = { w | w is a combination of 0’s and 1’s containing odd number of 1’s}
Language of DFA:
A string ‘x’ is said to be accepted by DFA M = (Q, Σ, δ, q0, F), if δ(q0,x) = P for some P in F.
The language accepted by DFA is,
L(M) = {w | (q0, w) is in F}
The language accepted by DFA is called regular language
Extended transition function of DFA ( ): If 𝛿 is a transition function, then the
extended transition function is denoted by . The extended function is a
function that takes a state q and a string w and returns a state P.
Basis: (w has length 0) In this case w is the empty string, i.e. the string of length 0, for
which we writeε. Then,
(q, ε) = q
If we are in a state q and read no inputs, then we are still in state q.
Induction: Suppose w is a string of the form xa; that is ‘a’ is the last symbol of w, and x is
the string consisting of all but the last symbol. Then,
(q, w)=δ ( (q, x),a)
To compute (q, w), first compute (q, x), the state that the automaton
is in after processing all but the last symbol of w.
Suppose this state is p, ie., (q, x) = p
Then (q, w) is what we get by making a transition from state p on
input a, the last symbol of w. that is (q, w) = 𝛿(p, a)
26
i) Using transition function (𝛿): DFA starts with initial state q0. Let a1, a2, . . .
. . .an be a sequence of input symbols, 𝛿 is transition function.
Step 1: (q0, a1) = q1, DFA in state q0 on input a1 enters state q1.
Step 2: (q1, a2) = q2 ,DFA in state q1 on input a2 enters state q2.
Similarly, (qi-1, ai) = qi for each i(1≤ i ≤ n )
If qn is a member of F, then the input string a1, a2, . . . . . .anis accepted,
otherwiseit is rejected.
Example1: Use δ to describe how the string 011101 is processed by the given DFA: (Using
transition function)
Example2: Use to describe how the string 011101 is processed by the following DFA:
(using extended transition function)
(q0, Є) = δ(q0, Є) = q0
(q0, Є0) = δ( (q0, Є),0) = δ(q0, 0) = q1
(q0, 01) = δ( (q0, 0),1) = δ(q1, 1) = q2
(q0, 011) = δ( (q0, 01),1) = δ(q2, 1) = q3
27
(q0, 0111) = δ( (q0, 011),1) = δ(q3, 1) = q2
(q0, 01110) = δ( (q0, 0111),0) = δ(q2, 0) = q3
(q0, 011101) = δ( (q0, 01110),1) = δ(q3, 1) = q2
The finite automata are called NFA whenthere exist many paths for a specific input
from current state to next state.
The NFA can be formally defined as a collection of 5 tuples.
M = (Q, Σ, δ, q0, F)
Where,
Q is a finite set of states.
Σ is a finite set of symbols called the alphabets.
δ is the transition function where δ: Q × Σ →2 Q (or) Q × (Σ U ε) →2Q (Here the
power set of Q(2Q) has been taken because in case of NDFA, from a state,
transition can occur to any combination of Q states)
q0 is the initial state from where any input is processed (q0∈Q).
F is a set of final state/states of Q (F⊆Q).
Example
In NFA, if any path for an input string leads to a final state, then the input string accepted.
For example, in above NFA, there are multiple paths for input string “00”. Since, one of the
paths leads to a final state, “00” is accepted by above NFA.
Properties of NFA :
1. There may be a transition on input symbol ‘ε’ i.e., empty input symbol.
2. A state can have more than one transition on the input symbol
Inputs Inputs
States States
0 1 0 1
q0 {q0, q1} {q1} q0 q0 q1
*q1 Ф {q1} *q1 q1 q1
NFA EXAMPLES:
1. Construct a NFA over alphabet Σ = {a, b} that accepts stringwith substring
ab.
2. Construct a NFA over Σ = {a, b} that accepts string which has 3rd symbol b
from right. (or) Obtain a NFA which should accept a language L, where
L = { x ∈(a, b)* : | x | ≥ 3 and 3rd symbol of x from the right is ‘b’
Solution:
29
L2= { 0n U 1n}
Solution:
For L1 : There can be any combination of o and 1 in the language but a substring
0101 must be present.
For L2: This language be any number of 0’s or any number of 1’s. It accepts { ε, a,
aa, aaa, . . . , b, bb, bbb, . . . . . }
4. Design the NFA transition diagram for the transition table as given below
Inputs
States
0 1
q0 {q0, q1} {q0, q2}
q1 {q3}
q2 {q2, q3} {q3}
*q3 {q3} {q3}
Solution:
30
The NFA M is ({q0, q1, q2, q3}, {0,1}, δ , q0, {q3})
The transitions are
δ(q0, 0) = {q0, q1} ; δ(q0, 1) = {q1} ; δ(q1, 0)={q3};
δ(q2,0) = {q2, q3}; δ(q2,1) = {q3} ; δ(q3,0)= {q3};
δ(q3,1)= {q3}
Language of NFA :
If A = (Q, Σ, δ, q0, F) is an NFA then,
L(A) = {w | (q0, w) ∩ F ≠ Ф}
i.e. L(A) is the set of strings w in ∑* such that (q0, w) contains atleast one accepting
state.
function that takes a state q and a string of input symbols w, and returns the set of
Basis: (q,Є)={q}. That is without reading any input symbols; we are only in the same
state.
Induction: Suppose w is of the form w=xa, where ‘a’ is the last symbol and x is the
substring containing rest of w.
Also, suppose that (q,x)={p1,p2…..pk} . Let,
¿ i=1 ¿ k δ ( Pi , a )={r 1 , r 2, … rm }
Then, (q,w)={r1,r2……..rm}. Less formally, we compute (q,w) by first computing (q,x),
and by then following any transition from any of these states that is labeled a.
31
i) Using proliferation diagram:
(q0, Є) = {q0}
(q0, 00) = δ ( (q0, 0), 0) = δ({q0, q1}, 0) = δ(q0,0) ∪ δ (q1, 0) = {q0, q1} ∪ ϕ = {q0,q1}
(q0, 001) = δ ( (q0, 00), 1) = δ({q0, q1}, 1) = δ(q0,1) ∪δ (q1, 1) = {q0} ∪ {q2} ={q0,
q2}
32
(q0, 0010) = δ ( (q0, 001), 0) = δ({q0,q2},0) = δ(q0,0) U δ(q2,0) = {q0,q1} U Ф ={q0,q1}
(q0, 00101) =δ( (q0, 0010),1) = δ ({q0,q1},1) = δ(q0,1) U δ(q1,1) = {q0} U {q2}
={q0,q2}
={q0,q2} ∩ F ≠ Ф
= {q0, q2} ∩ {q2} ≠ Ф
= {q2}≠ Ф
Hence the given string 00101 is accepted.
Example 2: Use extended function( ) to describe how the string 01010 is processed by the
following NFA:
33
SOLUTION:
M= (Q , Σ, δ , q0, F) is a NFA,
Where Q→{ q0, q1, q2, q3, q4},
Σ→{0,1},
F→{q2, q4},
δ →QXε to 2Q
INPUTS
STATES 0 1
q0 {q0, q3} {q0, q1}
q1 Φ q2
q2 q2 q2
q3 q4 ϕ
q4 q4 q4
34
Using Extended Transition function:
4.For the NFA shown, check whether the input string 0100 is accepted or not?
35
SOLUTION:
INPUTS
STATES 0 1
q0 {q0, q1} {q2}
q1 ϕ {q1, q2}
q2 {q0, q2} {q1}
Input string = 0100,
= {q0, q2}
36
5.The NFA with states {1,2,3,4,5} and input alphabet Σ={a,b} has the following
transition.
INPUTS
STATES a b
1 {1, 2} {1}
2 {3} {3}
3 {4} {4}
4 {5} ϕ
5 Φ {5}
The DFA is not possible to move to next In NFA, we can move to next state without
state without reading any symbol reading any symbol.
ε (or null) move is not allowed in DFA. ε (or null) move is allowed in NFA.[NFA
[DFA cannot change state without any input can change state without any input
character] character]
DFA for a language is difficult to construct NFA for a language can be smaller and
than NFA easier to construct than a DFA
Q X (Σ U ℇ) 2Q
Transition function, Transition function,
Q X Σ Q
DFA can be understood as one machine. NFA can be understand as several little
machines that computer together.
Time needed for checking string acceptance It takes more time as compared to DFA.
is less as compared to NFA.
38
Equivalence of NFA and DFA:
Since every DFA is an NFA, it is clear that the class of languages accepted by
NFA’s includes the regular set.
Theorem: Let L be a set accepted by an NFA then there exists a DFA that accepts same
language, L.
Proof:
As the language accepted by DFA, ie., for every NFA, we can construct an
equivalent DFA, one which accepts the same language.
Let L be a set accepted by an NFA. There exists a DFA that accepts L
Let M = (Q, Σ, δ, q0, F) be the NFA accepting L
Let M’ =(Q’, Σ, δ’, q0’, F’) be the DFA accepting L
The states (Q’) of DFA M’ will be subsets of the states of M,
i.e. Q’ = 2Q
Final State of DFA F' is the finite set of final states of M . That is F' is the set of all
final states in Q' containing a final state of M. Observe that [q0, q1, q2,. . . , qi] is a
single state of DFA corresponding to a set of states [q0, q1, q2,. . . , qi] of the NFA.
Initial state of DFA
q0’ = [q0]
δ' Mapping of DFA
We define δ' mapping as follows δ'[q0, q1, q2,. . . , qi] , a) = [p0, p1, p2, . . . ,
pi]
if and only if
δ'[q0, q1, q2,. . . , qi] , a) = [p0, p1, p2, . . . , pi]
That is δ' applied to an element [q0, q1,..., qi] of Q' is computed by applying δ to
each state of Q represented by {q0, q1, q2,. . . , qi}. On applying δ to each of q0, q1,
q2,. . . , qi, and taking the union, we get some new set of states {po, p1, . . . ,pi). This
new set of states has a representative, [p0, p1, p2, . . . , pi] in Q', and that element is
the value of δ'([q0, q1, q2,. . . , qi] , a).
By induction we can show that the length of the input string x
δ'(q0’, x)= [q0, q1, q2,. . . , qi]
if and only if
δ(q0, x)= {q0, q1, q2,. . . , qi}
Step 1: Basis
For | x | = 0
i. e. x is = ε, and we have q0’ = [q0] as initial state so basis is true.
EXAMPLES:
1. Converting the following NFA diagram to DFA.
Solution.
STEP 2: New statement [q0, q1] process the input symbols 0 &
δN ({q0, q1},0) =δN (q0,0)∪ δN (q1,0)
= {q0, q1}∪Φ
={q0, q1}
Hence δD ([q0, q1],0)=[q0, q1] Existing state
δN ({q0, q1},1) =δN (q0, 1)∪ δN (q1,1)
={q0} ∪ {q2}
={q0, q2}
Hence δD ([q0, q1],1)=[q0, q2]New state
STEP 3:New state is [q0, q2] process the input symbols 0 & 1
δN ({ q0, q2},0) =δN (q0,0)∪ δN (q2,0)
= { q0, q1}∪Φ
={ q0, q1}
Hence δD ([ q0, q2])=[q0, q1] Existing state
δN ({ q0, q2},1) = δN (q0,1)∪ δN (q2,1)
= {q0}∪Φ
={q0}
Hence δD ([ q0, q2],1)=[q0]Existing state
No new state can be found.
STEP 4: Construct the DFA transition table
INPUTS
STATES
0 1
[ q0] [ q0, q1] [ q0]
[ q0, q1] [ q0, q1] [ q0, q2]
* [ q0, q2] [ q0, q1] [ q0]
STEP 5: Draw the DFA transition diagram:
41
∴ q0 is initial state in NFA, therefore
[q0] is initial state in DFA
∴ q2 is final state in NFA ,therefore [q0,
q2] is final state in DFA, because [q0,
q2] contains q2.
We construct a DFA M'= (Q', Σ,δ', q0’, F') an equivalent which accepts L(M).
={p} U {r}
=[p,r]New state
={p} U{r} U{ ϕ }
={p,q}U{ s }
={p} U{ ϕ }
=[p,s]New state
={p,q} U{s}
={p} U{s}
INPUTS
STATES 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,r,s] [p,r,s]
*[p,r,s] [p,q,s] [p,s]
*[p,s] [p,q,s] [p,s]
The final state F' = ([p,q,r,s],[p,q,s],[p,r,s],[p,s]),since it contains {s}.
44
Finite Automaton with Є-move/transition (or) NFA with Є- move/transition:
Where,
Q is a finite non empty set of states.
Σ is a finite non empty set of symbols called the alphabets.
δ is the transition function or mapping function where δ: Q X (Σ U ε) →2Q
q0 is the initial state from where any input is processed (q0∈Q).
F is a set of final state/states of Q (F⊆Q).
Acceptance of Language:
45
The string w in L accepted by NFA can be represented as,
The transition diagram of the NFA accepts the language consisting of any number
of 0’s followed by any number of 1’s followed by any number of 2’s. For example, the
string w = 002 is accepted by the NFA along the path,
EXAMPLES :
1. Construct NFA with ε which accepts a language consisting the strings of any
number of a’s followed by any number of b’s followed by any number of c’s.
Normally ε’sare not shown in the input string. The transition table can be,
Inputs
States
a b c ε
q0 {q0} Ф Ф {q1}
q1 Ф {q1} Ф {q2}
*q2 Ф Ф {q2} Ф
⊢ δ (q0, bbcc)
⊢ δ (q0, εbbcc)
⊢
⊢
δ (q1, bbcc)
⊢
δ (q1, bcc)
δ (q1, cc)
46
⊢ δ (q1, εcc)
⊢ δ (q2, cc)
⊢ δ (q2, c)
⊢ δ (q2, ε)
Thus, we reach to accept state, after scanning the complete input string.
ε–closure:
The ε–closure (p) is a set of all states which are reachable from state p on ε –
transition such that:
(i) ε – closure (p) = p where p∈ Q
(ii) If there exists ε–closure(p) = {q} and δ (q, ε) = r then
ε–closure(p) = {q, r}
EXAMPLE:
1. Find the ε–closure for the following NFA with ε.
Solution:
ε–closure(q0) = {q0, q1, q2} [ self state + ε reachable state]
ε–closure(q1) = {q1,q2}
ε–closure(q2) = {q2}
2. Consider the NFA given below and find (q0, 01) [or] Consider NFA with ε-
move (q0, 01).
Solution:
(q0, ε) = ε–closure(q0) = {q0, q1, q2} ------------------------------- 1
Thus,
47
(q0, 0) = ε–closure(δ ( (q0, ε), 0))
= ε– closure(δ(ε–Closure(q0),0))
= ε–closure(δ({q0, q1, q2}, 0)
= ε–closure(δ(q0,0) U δ (q1,0) U δ(q2,0))
= ε–closure({q0} U {Ф} U {Ф})
= ε–closure({q0})
= {q0, q1, q2} ------------------------------ From 1
Then
Since (q0, 01) = {q1, q2} which contain final state {q2}. It is an accepted string.
Equivalence of NFA’s with and without ε – moves [or Conversion of NFA with ε to
NFA without ε]
Theorem: If L is accepted by an NFA with ε – transition then L is accepted by NFA
without ε-transition.
Proof: Let M = (Q,Σ,δ,q0, F) be an NFA with ε – transitions. Construct M’ which is NFA
without ε – transition.
M’ = (Q,Σ,δ’,q0, F’)
Where,
δ’(q0,x) = (q0, x)
This statement is not true if x = ε because δ’(q0,ε) = {q0} in NFA without ε and
= ( (q0, w), a)
= (q0, wa)
= (q0, x)
EXAMPLES:
Solution:
Let, M = ( Q, Σ, δ, q0, F) be NFA with ε– transition.
M’ = ( Q, Σ, δ’, q0, F’) be NFA without ε–transition.
49
Step 1: Obtain the ε–closure of each state i.e. find out ε reachable states from current state.
ε–closure(q0) = {q0, q1, q2}
ε–closure(q1) = {q1, q2}
ε–closure(q2) = {q2}
Step 2: Final state, F’ = {q0, q1, q2}, Since q2 has appeared in ε–closure of all states.
Step 3: Then find the extended transition function of NFA with ε - move.
For each state, process all the input symbols {a, b}.
(q0, 2) = {q2}
(q1, 0) ={ Ф }
(q1, 2) = {q2}
(q2, 0) ={Ф }
(q2, 1) ={ Ф }
Inputs
States
0 1 2
*q0 {q0,q1,q2} {q1,q2} {q2}
*q1 Ф {q1,q2} {q2}
*q2 Ф Ф {q2}
Solution:
52
Step 2: Final state, F’ = {q0, q1}, Since ε–closure(q0) contains final state q1, add q0 also
in set of final states for FA without ε–moves.
Step 3: Then find the extended transition function of NFA with ε - move.
For each state, process all the input symbols {a, b}
(q1, a) = Ф
(q1, b) = {q1}
Step 4: Construct the transition table for NFA without ε-transition :
53
Inputs
States
a b
*q0 {q0, q1} {q1}
*q1 Ф {q1}
Step 5 : Draw the transition diagram of an NFA without ε-transition
Shortcut Method:
States ε* Input a ε*
q0 q0 {q0,q1}
q0
q1 Ф -
ε* Input b ε*
q0 Ф -
q0
q1 q1 {q1}
ε* Input a ε*
q1 q1 Ф -
ε* Input b ε*
q1 q1 q1 {q1}
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, P3, . . . Pn], a) = ε–closure( δ (P1, a) U δ(P2, a) U . . . δ(Pn, a)
54
Where ‘a’ is input ∈Σ
EXAMPLES:
Solution:
First find the Є-closure of all states.
Now we will obtain transition, Let us start from Є-closure of start state.
(A, a) = ε–closure(δ(A, a)
=ε–closure(δ(q0, q1, q2), a))
= ε–closure(δ(q0,a) U δ(q1,a) U δ(q2,a))
= ε–closure(q1)
(A, b) = ε–closure(δ(A, b)
=ε–closure(δ(q0, q1, q2), b))
= ε–closure(δ(q0,b) U δ(q1,b) U δ(q2,b))
= ε–closure(q0)
55
(A, b) = {q0, q1, q2} A
Hence,
(B, a) = ε–closure(δ(B, a)
=ε–closure(δ(q1, q2), a))
= ε–closure(δ(q1,a) U δ(q2,a))
= ε–closure(q1)
(B, b) = ε–closure(δ(B, b)
=ε–closure(δ(q1, q2), b))
= ε–closure(δ(q1,b) U δ(q2,b))
= ε–closure(q0)
Inputs
States
0 1
*A B A
*B B A
56
Final states are A and B, since the final state of NFA with ε is q2, which is present in
both A and B.
Solution:page 122
First obtain the ε–closure of each state
ε–closure(q0) = {q0, q1, q2}
ε–closure(q1) = {q1, q2}
ε–closure(q2) = {q2}
57
3. Consider the following ε–NFA for an identifier. Consider the ε–closure of each state
and find its equivalent DFA.
Minimization of DFA:
DFA Minimization using Myphill-Nerode Theorem/Table Filling Method:
Procedure:
Step 2 –Mark all pairs where P ∈ FS and Q ∉ FS or vice versa and mark them. [Here FS is
Step 1 − Draw a table for all pairs of states (P, Q).
Step 1 &2 − Draw a table for all pair of states&Mark the state pairs.
Check B, A Both are non-final state, so
δ(B, 0) = A δ(B, 1) = D
(A, B) is not already marked. So do not
Check (B, A) :
mark (B, A)
δ(A, 0) = B δ(A, 1) = C
δ(D, 0) = E δ(D, 1) = F
Check (D, C): (E, E) and (F, F) is no pair.
δ(C, 0) = E δ(C, 1) = F
δ(E, 0) = E δ(E, 1) = F
Check (E, D): (E, E) and (F, F) is no pair.
δ(D, 0) = E δ(D, 1) = F
δ(F, 0) = F δ(F, 1) = F
Check (F, A) : (F, C) is already marked. So mark (F, A)
δ(A, 0) = B δ(A, 1) = C
Step 4 –After step 3, we have got state combinations {A, B} {C, D} {C, E} {D, E} that are
unmarked.
We can recombine {C, D} {C, E} {D, E} into {C, D, E}
Hence we got two combined states as − {A, B} and {C, D, E}
So the final minimized DFA will contain three states {F}, {A, B } and {C, D, E}
Step 5: Minimized DFA diagram is,
60
http://www.plantuml.com/plantuml/umla/
JT3DYeCm5CNn_NsAiqmMWXywphWOtFH1nAGQI1NYBNtztjGhT2NdbxyY6G-
U4ZyVaQA_CtX72ilAS27vcSE-qJ5FqQCkIxo2u_LhhpwdH6GgMnJ5lwajC21wPfyWBFlZZHM-
KNxAX6ajCe1Cgz9f8Vk4NuNkWXy1_JJ9gUfVLXUMm2J5YO3fzMqvrb04WqX_HQOgDLBItyhIg4YZDFhDoI
Mz0G00
61