Vision 2023 Toc Chapter 2 Finite Automata 10
Vision 2023 Toc Chapter 2 Finite Automata 10
com
1
byjusexamprep.com
THEORY OF COMPUTATION
2 FINITE AUTOMATA
Finite Automata:
It is mathematical model which contains finite number if states and transitions.
There are two types of automata :
1. Language recognizer
2. Output Generator
1. Language Recognizer : There exist three technique to design Language recognizer.
1. DFA (Deterministic Finite Automata)
2. NFA (Non- Deterministic Finite Automata)
3. Є- NFA (Epsilon Non- Deterministic Finite Automata)
2. Output Generator: There are two techniques to design Output Generator:
1. Mealy Machine
2. More Machine
1. Transition Diagram
2. Transition Table
1. Finite automata practically used in compiler design.
2. Language accepted by finite automata Known as regular languages.
1.1. Deterministic Finite Automata:
It is a finite automata in which from each and every state on every input symbol , exactly
one transition should exist.
Formal definition : { Q, Σ, q, F, δ }.
Q= Finite number of states
𝛴 : set of Input Symbols.
𝑞0, = initial stte
F= final state
𝛿= Transition Function
Transition Function, defined as δ : Q X Σ --> Q.
In a DFA, for a particular input character, the machine goes to one state only. A transition
function is defined on every state for every input symbol. Also in DFA null (or ε) move is
not allowed, i.e., DFA cannot change state without any input character.
2
byjusexamprep.com
For example, below DFA with Σ = {0, 1} accepts all strings ending with 0.
One important thing to note is, there can be many possible DFAs for a pattern. A DFA
with minimum number of states is generally preferred.
1.1.1 Acceptance Method in DFA :
By reading complete string from left to right, end of the string DFA halts in final State
then given string is accepted. Otherwise string is rejected.
Set of all strings accepted by DFA is known as language accepted by DFA.
Example 1:
Which of the following is answer?
a) Even no’s of 0 and even no’s of 1 b) Odd no’s of 0 and even no’s of 1
c) Any no’s of 0 and even no’s of 1 d) None of the above
Ans. c)
3
byjusexamprep.com
1.1.2. Designing of DFA:
Problem-1: Construction of a DFA for the set of string over {a, b} such that length of the
string |w|=2 i.e, length of the string is exactly 2.
Explanation – The desired language will be like:
L = {aa, ab, ba, bb}
The state transition diagram of the language will be like:
Here,
State A represent set of all string of length zero (0), state B represent set of all string of
length one (1), state C represent set of all string of length two (2). State C is the final
state and D is the dead state it is so because after getting any alphabet as input it will
not go into final state ever.
The above automata will accept all the strings having the length of the string exactly 2.
When the length of the string is 1, then it will go from state A to B. When the length of
the string is 2, then it will go from state B to C and when the length of the string is greater
than 2, then it will go from state C to D (Dead state) and after it from state D TO D itself.
1.1.3 Complement of DFA :
By interchanging final state as non- final state & non -final state as final state we can
complement a DFA.
1. If Language accepted by a DFA is L then complemented DFA accepts Σ ∗ − 𝐿.
2. Complement is not applicable for NFA & ∈ - NFA.
Note – In any DFA if all states are final states that DFA accepts complete
Language.
In Any DFA if there is no final state that DFA accepts empty Language.
Example 3:
Identify Language accepted by given DFA
4
byjusexamprep.com
Ans. a)
Complement of Above DFA:
By interchanging final state as non- final state & non -final state as final state.
5
byjusexamprep.com
Example
Let us use Algorithm to minimize the DFA shown below.
Solution:
Step 1: In the given DFA, q2 and q4 are the unreachable states so remove them.
Step 2: Draw the transition table for the rest of the states.
State 0 1
→q0 q1 q3
q1 q0 q3
*q3 q5 q5
*q5 q5 q5
Step 3: Now divide rows of transition table into two sets as:
1. One set contains those rows, which start from non-final states:
State 0 1
q0 q1 q3
q1 q0 q3
2. Another set contains those rows, which starts from final states.
State 0 1
q3 q5 q5
q5 q5 q5
6
byjusexamprep.com
Step 5: In set 2, row 1 and row 2 are similar since q3 and q5 transit to the same state
on 0 and 1. So skip q5 and then replace q5 by q3 in the rest.
State 0 1
q3 q3 q3
State 0 1
→q0 q1 q3
q1 q0 q3
*q3 q3 q3
7
byjusexamprep.com
Solution : Statement 4 says, it will accept all strings of length atleast 2. But it accepts 0
which is of length 1. So, 4 is false.
Statement 3 says that the DFA is minimal. We will check using the algorithm discussed
above.
P0 = { { q2 }, { q0, q1 } }
P1 = { q2 }, { q0, q1 } }. Since, P0 = P1, P1 is the final DFA. q0 and q1 can be merged.
So minimal DFA will have two states. Therefore, statement 3 is also false.
So correct option is (D).
Note → Expressive power of DFA and NFA is same . Hence every NFA can be
converted into DFA .
Question: 𝐷𝑓 , 𝐷𝑝 are Number of language accepted by DFA and DPDA respectively. 𝑁𝑓 &
𝑁𝑝 are number of language accepted by NFA and NPDA respectively.
Which of the following is true?
a) 𝐷𝑓 = 𝑁𝑓 , 𝐷𝑓 = 𝑁𝑝 b) 𝐷𝑓 ∁ 𝑁𝑓 , 𝐷𝑓 ∁ 𝑁𝑝
c) 𝐷𝑓 = 𝑁𝑓 , 𝑁𝑝 ∁ 𝐷𝑝 d) 𝑁𝑜𝑛𝑒 𝑜𝑓 𝑡ℎ𝑒 𝑎𝑏𝑜𝑣𝑒
Ans. d)
Question: For every non deterministic automata an equivalent deterministic automata
not possible For which of the following ?
a) Finite Automata b) Turing Machine
c) Pushdown Automata d) None of the above
Ans c)
Explanation
For Pushdown automata non deterministic automata an equivalent deterministic
automata not possible.
1.2. Non Deterministic Finite Automata:
In NFA from the given state and given input symbol. There may be zero transitions or
one transition or more than one transition exist.
Formal definition of NFA:
NFA also has five states same as DFA, but with different transition function, as shown
follows:
δ: Q x ∑ →𝟐𝑸
Q: finite set of states
∑: finite set of the input symbol
q0: initial state
F: final state
δ: Transition function
1. Complement is not possible for NFA
2. Minimization algorithm is not applicable for NFA
3. Language Detection is difficult in NFA compare to DFA
4. Construction of NFA is easy than DFA
5. In NFA for valid string automata may halt in non final state also.
8
byjusexamprep.com
In NFA for valid string even though automata halt in non final state but atleast one time
should halt in final state.
Every DFA is NFA but every NFA need not be DFA.
Note → In NFA given state and given input symbol number of transition
possibilities power set of stated of automata. (hence 𝟐𝑸 transition).
Example 1:
NFA with ∑ = {0, 1} accepts all strings with 01.
Solution:
Example 2:
NFA with ∑ = {0, 1} and accepts all string of length atleast 2.
Solution:
9
byjusexamprep.com
Example 1:
Convert the given NFA to DFA.
Solution: For the given transition diagram we will first construct the transition table.
State 0 1
→q0 q0 q1
q1 {q1, q2} q1
10
byjusexamprep.com
The transition table for the constructed DFA will be:
State 0 1
1.3. Є –NFA :
A string will be accepted if there is at least one sequence of state transitions on an input
(including ε transitions) that leaves the machine in an accepting state.
A Non-Deterministic Finite Automata with ε transitions is a 5-tuple (Q, Σ, qo, δ, F) where
– Q is a finite set (of states)
– Σ is a finite alphabet of symbols
– qo ∈ Q is the start state
– F ⊆ Q is the set of accepting states
– δ is a function from Q x (Σ ∪ {ε}) to 2𝑄 (transition function)
Expressive power of ∈- NFA same as NFA and DFA . hence every ∈- NFA can be converted
into NFA and DFA.
Example:
11
byjusexamprep.com
Transition Table :
δ a b
12
byjusexamprep.com
Step-1:
Consider the two vertexes having the epsilon move. Here in Fig.1 we have vertex v1 and
vertex v2 having epsilon move from v1 to v2.
Step-2:
Now find all the moves to any other vertex that start from vertex v2 (other than the
epsilon move that is considering).
After finding the moves, duplicate all the moves that start from vertex v2, with the same
input to start from vertex v1 and remove the epsilon move from vertex v1 to vertex v2.
Step-3:
See that if the vertex v1 is a start state or not. If vertex v1 is a start state, then we will
also make vertex v2 as a start state. If vertex v1 is not a start state, then there will not
be any change.
Step-4:
See that if the vertex v2 is a final state or not.
If vertex v2 is a final state, then we will also make vertex v1 as a final state.
If vertex v2 is not a final state, then there will not be any change.
Repeat the steps(from step 1 to step 4) until all the epsilon moves are removed from the
NFA.
Now, to explain this conversion, let us take an example.
Example: Convert epsilon-NFA to NFA.
Consider the example having states q0, q1, q2, q3, and q4.
In the above example, we have 5 states named as q0, q1, q2, q3 and q4. Initially, we
have q0 as start state and q2 as final state. We have q1, q3 and q4 as intermediate
states.
Transition table for the above NFA is:
13
byjusexamprep.com
q0 – q1 q2
q1 – q0 –
q2 q3 q4 –
q3 q2 – –
q4 q2 – –
Resulting NFA :
q0 q3 q1, q4
q1 – q0
q2 q3 q4
q3 q2 –
q4 q2 –
14
byjusexamprep.com
Following are some of decidable problem in finite automata:
1. Equivalence problem: Means checking whether language accepted by given two
automata are same or not.
2. Finiteness Problem: means checking whether language accepted by given automata
is finite or not.
3. Emptyness problem: checking whether language accepted by given automaya is empty
or not.
4. Membership problem:check whether string is accepted by given automata or not.
****
15