Flat KJR
Flat KJR
Flat KJR
ENGG .GCEKJR)
Formal Languages and Automata Theory.
Introduction -:Automata theory is a study of abstract machine , automat and a
theoretical way solve computational problem using this abstract machine .It is
the theoretical computer science .The word automata plural of automaton comes
from Greek word ...which means “self making”.
Example1 -: ∑={0,1}
w=01010
|w|=5
States ↓ / input→ 0 1
s1 s2 ϕ
*s2 ϕ s1
Example 2-: Give the 5 tuple representation and draw the transition table for
the following fig.
DFA
Finite automata is devided in to two categories.
1DFA (Deterministic Finite Automata.
2NFA (Non Deterministic finite Automata.
Formal Definition-: DFA-:Formally defined using 5 tuple notation with
following restriction
Each and every state for every input symbol , there should be exactly one
transition.
DFA is the special case of NFA but the reverse is not true.
Simplified notation.
Machine M= (Q,∑, δ,q0,F)
Where
Q is the finite set of states.
∑ is the set of input symbol / alphabet.
δis the mapping function which maps Q × ∑ Q
q0is the initial state which must be element of ∑
F Set of final states must be subset of Q
Design of DFA-: In order to design the DFA first of all we need to understand
the language(Set of string ) accepted by DFA.
The second step towards solution is to identify the minimum length string
that is accepted by language and accordingly identify the minimum state
required and draw the diagram . the diagram will indicate initial and final
state.
The third step is ,for each state , decide the transition to be made for each
symbol as input.
If transition is not valid then insert a new state called dead state or trap
state and transit to this state.
Sol-:
Step1-:First step is to identify the language and that is
L={01,011,010,0100,0110,0111,0101,01111....}
It is easily observable that all string in the language start with ‘ 01’
Sept-2
It is also clear from the above statement that minimum string accepted by the
DFA is ‘01’ the length of the string is 2
Note-: if minimum length of string with starting point restriction is ‘n’
Then we need n+2 number of state including trap state.
Third step -:complete the figure by completing other transition over input
symbol.
For example q0 has one remaining transition over input symbol ‘1’
q1 has one remaining transition over input symbol ‘0’
q2 has two remaining transition over input symbol ‘0’ and ‘1’
we cannot draw the transition for q0 and q1 because the language has
starting point restriction so the initial state will not able to accept any other
symbol other than ‘0’ .
step4-: q0 has one remaining transition over input symbol ‘1’ which violets
the language rule that is if it accepts input symbol ‘1’ the pattern ‘01’ no
longer valid .
q1 has one remaining transition over input symbol ‘0’wich violets the
language rule. As discuss above
so we have to introduce new state called trap state. And the final figure is -:
Draw the transition table related to transition function δ for above fig.
States ↓ / input→ 0 1
q0 q1 q3
q1 q3 q2
*q2 q2 q2
q3 q3 q3
Try to solve the following question .(The solution will be provided later)
1. Construct a DFA that accept all string end with ‘01’ over input alphabet
{0,1}.
2. Construct a DFA that accept all string which has a substring ‘101’
3. Construct a DFA that accept all string which has a substring ‘001’
4. Construct a DFA that accept all string end with ‘ab’ over input alphabet
{a,b}.
5. Construct a minimum DFA that accept all ‘a’s and ‘b’s where each start
with ‘a’
6. Construct a minimum DFA that accept all ‘a’s and ‘b’s where each start
with ‘b’ and end with ‘a’
7. Construct a minimum DFA that accept all ‘a’s and ‘b’s where length of
string is exactly Three(3).
8. Construct a minimum DFA that accept all ‘a’s and ‘b’s where length of
string is at least Three(3).
9. Construct a minimum DFA that accept all ‘a’s and ‘b’s where length of
string is divisible by 2.
10. Construct a minimum DFA that accept all ‘a’s and ‘b’s where length of
string is divisible by 5
11. Construct a minmum DFA the accept all ‘a’s and ‘b’s where length of
the string is congruent to 2 mod 3.
12. Construct a minimum DFA that accept all binary number which are
divisible by 2
13. Construct a minimum DFA that accept all binary number which are
divisible by 5
14. Construct a minimum DFA that accept all string of ‘a’s and ‘b’s where
1st and last symbol are same
15. Construct a minimum DFA that accept all string of ‘a’s and ‘b’s where
1st and last symbol are different.
16. Construct a minimum DFA that accept all string of ‘a’s and ‘b’s where
Second symbol from right hand side is ‘a’.
Then complete the fig but remember that in NFA for a given input we can
go to any no of states .Max state is 2Q .. The rule for the language should not
be violated.
States ↓ / input→ a b
S1 S1,S2 S1
S2 S2 S3
S3 ----- S4
*S4 S4 S4
Sol-:
i. Initial state remains same for DFA and NFA so q0 is the initial
state.
ii. In DFA we cannot transit to two different state accepting input
symbol so we have to consider all possible state that is subset
of {q0,q1}
That is -: ϕ,[ q0],[ q1],[ q0q1].
Note-: [ q0q1] is a single state in case of DFA.
iii. In case of NFA q0 is the final state hence in DFA all the state
which has q0 will be the final state . so [q0] and [ q0q1] are the
two final state for equivalent DFA .
iv. δ transition function for old state remains the same but for new
state it is calculate as follows
δ([q0,q1],0)=δ(q0,0)Ս δ(q1,0)= q0q1
δ([q0,q1],1)=δ(q0,1)Ս δ(q1,1)= q1 Ս q0q1= q0q1
Now construct the transition table and diagram.
State ↓ / ∑→ 0 1
*q0 q0 q1
q1 q1 q0,q1
q0,q1 q0,q1 q0,q1
NFA with ε Transition.
In some situation , it would be useful to enhance the NFA by allowing transition
that are not triggered by any input symbol , such transition are called ε-
Transition.
Formal Definition-:NFA with ε move is denoted using 5 tuple