0% found this document useful (0 votes)
23 views15 pages

Vision 2023 Toc Chapter 2 Finite Automata 10

Uploaded by

VALO-CLIP
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)
23 views15 pages

Vision 2023 Toc Chapter 2 Finite Automata 10

Uploaded by

VALO-CLIP
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/ 15

byjusexamprep.

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. FINITE AUTOMATA CAN BE REPRESENTED BY USING

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?

Set of all strings


a) Starting with bb b) Ending with bb
c) Contains atleast 2b’s d) None
Ans. d)
Explanation: If we consider starting with bb correct then our automata accepts “abb”
also which makes it incorrect.If we consider Ending with bb correct then our automata
accepts “bba” also which makes option b incorrect.If we consider 3 rd option as correct
then our automata should accepts bab but it is not accepting so option 3 rd is also incorrect.
So D is correct.
Example 2:
Which of the following is correct?

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

a) Ending with 0 b) Starting with 0


c) Alternate sequence of 1 and 0 d) None of the above

4
byjusexamprep.com
Ans. a)
Complement of Above DFA:
By interchanging final state as non- final state & non -final state as final state.

Language accepted by DFA → set of strings not ending with 0


Note → Finite Automata Fails to accept languages in which comparison exist
between symbols.
The language for which finite automata possible are known as regular
languages.
Example: Which of the following language are regular ?
L1 = { 𝑎𝑛 𝑏 𝑚 | n,m >=1 }
We can make finite automata for L1. so language is regular.
L2 = { 𝑎𝑛 𝑏 𝑛 | 𝑛 ≥ 1}
We can not draw finite automata for L2 because comparison exist . So language is not
regular.
L3= { 𝑎𝑛 𝑏 𝑚 | 𝑛 < 𝑚}
We can not draw finite automata for L3 because comparison exist . So language is not
regular.
L4= { 𝑎𝑛 𝑏 2𝑚 | 𝑛, 𝑚 ≥ 1}
We can make finite automata for L4. so language is regular.
1.1.4 Minimization of DFA :
For one regular language there is possibility of having many of DFA but minimal state
DFA is only one.
Minimization algorithms applicable only for DFA (not applicable for NFA or ∈ 𝑁𝐹𝐴)
Step 1 − Draw a table for all pairs of states(𝑄𝑖 ,𝑄𝑗 ) not necessarily connected directly [All
are unmarked initially]
Step 2 − Consider every state pair (𝑄𝑖 ,𝑄𝑗 ) in the DFA where 𝑄𝑖 ∈ F and 𝑄𝑗 ∉ F or vice
versa and mark them. [Here F is the set of final states]
Step 3 − Repeat this step until we cannot mark anymore states −
If there is an unmarked pair (𝑄𝑖 ,𝑄𝑗 ) ,mark it if the pair {δ (𝑄𝑖 , A), δ (𝑄𝑖 , A)} is marked
for some input alphabet.
Step 4 − Combine all the unmarked pair (𝑄𝑖 ,𝑄𝑗 ) and make them a single state in the
reduced DFA.

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

Step 4: Set 1 has no similar rows so set 1 will be the same.

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

Step 6: Now combine set 1 and set 2 as:

State 0 1
→q0 q1 q3
q1 q0 q3
*q3 q3 q3

Now it is the transition table of minimized DFA.

Question : Consider the given DFA. Which of the following is false?


1. Complement of L(A) is context-free.
2. L(A) = L ( ( 11 * 0 + 0 ) ( 0 + 1 )* 0* 1* )
3. For the language accepted by A, A is the minimal DFA.
4. A accepts all strings over { 0, 1 } of length atleast two.

A. 1 and 3 only B. 2 and 4 only


C. 2 and 3 only D. 3 and 4 only

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:

1.2.1 Conversion from NFA to DFA


In this section, we will discuss the method of converting NFA to its equivalent DFA. In
NFA, when a specific input is given to the current state, the machine goes to multiple
states. It can have zero, one or more than one move on a given input symbol. On the
other hand, in DFA, when a specific input is given to the current state, the machine goes
to only one state. DFA has only one move on a given input symbol.
Let, M = (Q, ∑, δ, q0, F) is an NFA which accepts the language L(M). There should be
equivalent DFA denoted by M' = (Q', ∑', q0', δ', F') such that L(M) = L(M').
Steps for converting NFA to DFA:
Step 1: Initially Q' = ϕ
Step 2: Add q0 of NFA to Q'. Then find the transitions from this start state.
Step 3: In Q', find the possible set of states for each input symbol. If this set of states is
not in Q', then add it to Q'.
Step 4: In DFA, the final state will be all the states which contain F(final states of NFA)

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

*q2 q2 {q1, q2}

Now we will obtain δ' transition for state q0.


δ'([q0], 0) = [q0]
δ'([q0], 1) = [q1]
The δ' transition for state q1 is obtained as:
δ'([q1], 0) = [q1, q2] (new state generated)
δ'([q1], 1) = [q1]
The δ' transition for state q2 is obtained as:
δ'([q2], 0) = [q2]
δ'([q2], 1) = [q1, q2]
Now we will obtain δ' transition on [q1, q2].
δ'([q1, q2], 0) = δ(q1, 0) ∪ δ(q2, 0)
= {q1, q2} ∪ {q2}
= [q1, q2]

δ'([q1, q2], 1) = δ(q1, 1) ∪ δ(q2, 1)


= {q1} ∪ {q1, q2}
= {q1, q2}
= [q1, q2]
The state [q1, q2] is the final state as well because it contains a final state q2.

10
byjusexamprep.com
The transition table for the constructed DFA will be:

State 0 1

→[q0] [q0] [q1]

[q1] [q1, q2] [q1]

*[q2] [q2] [q1, q2]

*[q1, q2] [q1, q2] [q1, q2]


The Transition diagram will be:

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

→*p {q} {p} {ϕ}

*q {ϕ} {ϕ} {q}

Epsilon-closure (ε-closure) of a state:


The ε -closure of a state of ε-NFA is the set of stats those can be eased from that state
with s-transition. The ε -closure is defined as recursively as:
Basis: state q is in ε-closure (q).
Induction: If state q is reached with ε -transition from state q, p is in ε-closure (q). And
if there is
an arc from p to r labeled 2, then r is in ε-closure (q) and so on.
For Example:

ε-closure (P) = {p,q,r,s}


ε-closure (q) = {q, s}
ε-closure (r) = {r}
ε-closure (s) = {s}
ε-closure (t) = {t}
ε-closure (u) = {u,w,y}
ε-closure (v) = {v, x, y}
ε-closure (w) = {w, y}
ε-closure (x) = {x, y}
ε-closure (y) = {y}
1.3.1 Conversion of Epsilon-NFA to NFA
Non-deterministic Finite Automata (NFA) is a finite automata having zero, one or more
than one moves from a given state on a given input symbol. Epsilon NFA is the NFA which
contains epsilon move(s)/Null move(s). To remove the epsilon move/Null move from
epsilon-NFA and to convert it into NFA, we follow the steps mentioned below.

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

STATES/INPUT INPUT 0 INPUT 1 INPUT EPSILON

q0 – q1 q2

q1 – q0 –

q2 q3 q4 –

q3 q2 – –

q4 q2 – –

Resulting NFA :

The transition table for the above resulting NFA is:

STATES/INPUT INPUT 0 INPUT 1

q0 q3 q1, q4

q1 – q0

q2 q3 q4

q3 q2 –

q4 q2 –

1.4. Decision Properties of finite automata:


Decidable: A problem is said to be decidable if there exist algorithm to solve that
problem.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy