Automata Chapter 1
Automata Chapter 1
Definition of Automata
The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting".
An automaton (Automata in plural) is an abstract self-propelled computing device which
follows a predetermined sequence of operations automatically.
An automaton with a finite number of states is called a Finite Automaton (FA) or Finite State
Machine (FSM).
Alphabets and strings
Alphabet
Definition − An alphabet is any finite set of symbols.
Example − ∑ = {a, b, c, d} is an alphabet set where ‘a’, ‘b’, ‘c’, and ‘d’ are symbols.
String
Definition − A string is a finite sequence of symbols taken from ∑.
Example − ‘cabcad’ is a valid string on the alphabet set ∑ = {a, b, c, d}
Page | 1
Length of a String
Definition − It is the number of symbols present in a string. (Denoted by |S|).
Examples −
o If S = ‘cabcad’, |S|= 6
o If |S|= 0, it is called an empty string (Denoted by λ or ε)
In DFA, for each input symbol, one can determine the state to which the machine will move.
Hence, it is called Deterministic Automaton. As it has a finite number of states, the machine is
called Deterministic Finite Machine or Deterministic Finite Automaton.
Q = {a, b, c},
∑ = {0, 1},
q0 = {a},
F = {c}, and
Transition function δ as shown by the following table −
Present State Next State for Input 0 Next State for Input 1
a a b
b c a
c b c
Transition Systems
A transition graph or a transition system is a finite directed labeled graph in which
each vertex or node represents a state and the directed edges indicate the transition
of a state and the edges are labeled with input/output. An initial state
represented by a circle with an arrow pointing towards it, the final state by two
concentric circles, and the other states are represented by one circle.
The transitions frorn one internal state to another are governed bv the transition function δ, for
example, for
Then the dfa is in state q0 and the current input symbol is a, the dfa will go into state q1.
Properties of Transition Function.
Page | 3
Property 1. δ(q, ) = q in a finite automaton. This means the state of the
system can be changed only by an input symbol.
Property 2. For all strings W ∑* and input symbols a.
δ(q, aw) = δ ( δ(q, a), w)
δ(q, wa) = δ ( δ(q, w), a)
This property gives the state after the automaton reads the first symbol
of a string aw and the state after the automaton reads a prefix of the string
wa.
Example : prove that for any transition function δ and for any two input
string x and y.
δ(q, xy) = δ ( δ(q, x), y) 2.1
Proof: By the method of induction on |y|. i.e. length of y. when
|y|=1,y=a.
= δ(q, xa) = δ ( δ(q, x), a) by property 2.
Consider the finite state machine whose ={0,1}, K={q0,q1,q2, q3},q0 in
K is a initial state, final state is q0. Transition function δ is given in the
table. Give the entire sequence of state for the input string 110101.
Let consider the DFA ={a,b}, K={ q0 },q0 in K is a initial state, final state is q0.
Page | 4
Languages L(m) = { x/x * }
Let consider the DFA ={a,b}, K={q0,q1,D}, q0 in K is an initial state, final
state is q0.
Example
Q = {a, b, c},
∑ = {0, 1},
q0 = {a},
F = {c}, and
Transition function δ as shown by the following table −
Present State Next State for Input 0 Next State for Input 1
a a b
b c a
c b c
Page | 5
least one a and one b will be accepted. In the above fig. and table D is dead
state. Start from q0, read a and go to q1, from q1, read a and again go to
q1, from q1, read a and again go to q1, from q1, read b and go to q2,
from q2, read b and again go to q2, State q2 is a final state. The state
sequence of given input is q0q1q1q1q2q2. The string starting
with b is not accepted by the machine. The string end with a is not accepted
by the machine.
Let consider the DFA ={a,b}, K={ q0 },q0 in K is a initial state, final state is q0.
Page | 6
a b
* q0 q1 D
q1 D q0
D D D
Consider the finite state machine whose ={ a,b }, K={q0,q1,q2},q0 in K is an initial state,
final state is q0.
a b
* q0 q1 q1
q1 q2 q2
q2 q0 q0
Any string starting with a’s and b’s will be accepted by the machine. But string length should divisible
by 3. Language of the machine is L(m) = { x /x *,|x| = 3K }. K is a integer.
Any type of string starting with A-Z followed by A-Z or 0-9 and string length
should be 1 to 6 character. Languages L(m) = { x /x A-Z and x A-Z or 0-9,|x|
<=6}
Page | 7
Example
Let a deterministic finite automaton be →
Q = {a, b, c},
∑ = {0, 1},
q0 = {a},
F = {c}, and
Transition function δ as shown by the following table −
Present State Next State for Input 0 Next State for Input 1
a a b
b c a
c b c
Example
Let us consider the DFA shown below. From the DFA, the acceptable strings can be derived.
Page | 8
Strings accepted by the above DFA: {0, 00, 11, 010, 101, ...........}
Strings not accepted by the above DFA: {1, 011, 111, ........}
1.3.2 Non-Deterministic Finite State Automata
In NFA, for a particular input symbol, the machine can move to any combination of the states in
the machine. In other words, the exact state to which the machine moves cannot be determined.
Hence, it is called Non-deterministic Automaton. As it has finite number of states, the machine is
called Non-deterministic Finite Machine or Non-deterministic Finite Automaton.
Q = {a, b, c}
∑ = {0, 1}
q0 = {a}
F = {c}
Page | 9
The transition function δ as shown below −
Present State Next State for Input 0 Next State for Input 1
a a, b b
b c a, c
c b, c c
Consider the NFA whose ={a,b}, Q={ q0,q1,q2 },q0 in Q is initial state,
final state is q2, transition function δ is given in the table. To check
whether the given string aaabb is accepted by the machine or not.
Initial state q0. Two choose are there
reading a from q0 either it is go to q0 or
q1. Similarly two choose are there reading
b from q1 it is go either to q1 or q2. Final
state is q2. The string sequence of a’s
followed by sequence of b’s will be
accepted by the machine. The string
starting with b and ending a are not
accepted by the machine. The state
sequence is q0 ->q0->q0-> q1 -> q1 -> q2
for the input aaabb.
The initial state q0. Reading a from q0 and go to q0,
again a is reading from q0 and go to q0, again a is
reading from q0 and go to q1, again b reading from q1
and go to q1 and finally b reading from q1 and go to
q2,
Example: Ending of Strings
An NFA that accepts all binary strings that end with 101.
Page | 10
Design a NFA for the transition table as given below:
The transition diagram can be drawn by using the mapping function as given in the table.
Design an NFA with ∑ = {0, 1} in which double '1' is followed by double '0'.
Now before double 1, there can be any string of 0 and 1. Similarly, after double 0, there can be
any string of 0 and 1.
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'). Any string is
Page | 11
accepted by NFA can be accepted by a DFA. Method is called as subset.
Example 1:
For the given transition diagram we will first construct the transition table.
State 0 1
δ'([q1], 0) = ϕ
δ'([q1], 1) = [q0, q1]
Now we will obtain δ' transition on [q0, q1].
δ'([q0, q1], 0) = δ(q0, 0) ∪ δ(q1, 0)
= {q0, q1} ∪ ϕ
= {q0, q1}
= [q0, q1]
Similarly,
State 0 1
Page | 12
→[q0] [q0, q1] [q1]
Example 2:
For the given transition diagram we will first construct the transition table.
State 0 1
→q0 q0 q1
q1 {q1, q2} q1
Page | 13
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. The transition
table for the constructed DFA will be:
State 0 1
Consider the NFA whose ={a,b}, K={ q0,q1,q2 },q0 in K is a initial state, final
state is q2 transition function δ is given in the table. To check whether the
given string is aaabb accepted by the machine or not.
a b
q0 {q0,q1} {Ø}
q1 {Ø} {q1,q2}
* q2 {Ø} {Ø}
NFA State Table
a b
[q0] [q0,q1] [Ø]
[q0,q1] [q0,q1] [q1,q2]
* [q1,q2] [Ø] [q1,q2]
[Ø] [Ø] [Ø]
Page | 14
NFA Equivalent DFA State table
DFA Transition Diagram and state sequence.
Language of the machine L(m) = { am, bn / n,m >=1}. The state diagram is given
beside Initial state q0. Reading a from q0 and go to [q0,q1], again reading a from
[q0,q1] and go to [q0,q1], again reading a from [q0,q1] and go to [q0,q1], and
reading b from [q0,q1] and go to [q1,q2], again reading b from [q1,q2], and go
to [q1,q2]. That is a final state. The string sequence of a’s followed by sequence of
b’s will be accepted by the machine. The string staring with b and ending a are
not accepted by the machine. The state sequence is q0 δ [q0,q1] δ [q0,q1] δ
[q0,q1] δ [q1,q2] δ [q1,q2] for the input aaabb.
Consider the set of strings over = {0,1} which ending with either 00 or 11.
0 1
q0 {q0,q1} {q0,q3}
q1 {q2} {Ø}
* q2 {Ø} {Ø}
q3 {Ø} {q4}
* q4 {Ø} {Ø}
NFA State Table
0 1
[q0 ] [q0,q1] [q0,q3]
[q0,q1] [q0,q1,q2] [q0,q3]
[q0,q3] [q0,q1] [q0,q3,q4]
*[q0,q1,q2] [q0,q1,q2] [q0,q3]
*[q0,q3,q4] [q0,q1] [q0,q3,q4]
NFA Equivalent DFA State table DFA State Diagram
Initial state is [q0 ]. The given input string is 10100. Reading 1 from q0 and go
to [q0,q1], again reading 0 from [q0,q1] and go to [q0,q1,q2], again reading 1 from
[q0,q1,q2] and go to [q0,q3], again reading 0 from [q0,q3] and go to [q0,q1] and
finally reading 0 from [q0,q1] and go to [q0,q1,q2]. It is a final state. So given
string is accepted by machine.
Page | 15
x) F. one of them may be in Final state and another may not be in final state. X is
called the distinguishable string sequence.
We have to follow the various steps to minimize the DFA. These are as follows:
Step 1: Remove all the states that are unreachable from the initial state via any set of the
transition of DFA.
1. δ (q, a) = p
2. δ (r, a) = p
That means, find the two states which have the same value of a and b and remove one of
them.
Step 5: Repeat step 3 until we find no similar rows available in the transition table T1.
Step 6: Repeat step 3 and step 4 for table T2 also.
Step 7: Now combine the reduced T1 and T2 tables. The combined transition table is the
transition table of minimized DFA.
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.
Page | 16
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
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
Page | 17
*q3 q3 q3
Page | 18
goes to q1, output is y, reading 1 from q1 and goes to q2,
output is n, reading 0 from q2 and goes to q1, output is
n, reading 1 from q1 and goes to q2, output is n, reading
1 from q2 and goes to q2, output is y. Input and output
table is given below.
Input 0 O 1 0 1 1
output N y n n n y
Final output is y, so string ending with 2 ones was accepted by the machine. The
given input size is six and output size is also six.
Consider ={0,1} and output alphabets Δ = { 0, 1, 2, 3, 4} construct Moore
Machine with string 10001. Moore Machine : K Δ.
The input string is 100. It’s start from q0, reading
1 from q0 and goes to q1, output is 1, reading 0
from q1 and goes to q2, output is 2, reading 0
from q2 and goes to q4. Final output is 4. Input
string binary value is 100 and equivalent decimal
value is 4.
1 0 0 N
q0 q q Q4 N+
1 2 1
0 1 2 4 N+
1
The given input size is 3 (N) but state sequence size and output size are 4. That is
N+1. Moore Machine are depends only on states. Now we will see the input string
10001. It’s start from q0, reading 1 from q0 and goes to q1, output is 1, reading 0 from
q1 and goes to q2,output is 2, reading 0 from q2 and goes to q4, output is 4,
reading 0 from q4 and goes to q3, output is 3, reading 1 from q3 and goes to q2.
Final output is 2. The input string binary value is 10001 and equivalent decimal
value 17. Input value is divide by 5 and get remainder is 2. That is the final output
of given input.
Construct Moore Machine equivalent Mealy Machine
Consider ={0,1} and output alphabets Δ = { 0, 1, 2, 3, 4} construct Moore Machine
equivalent Mealy Machine with string 10011.
The input string 10001. It’s start from q0, reading 1 from q0 and goes to q1, output is 1,
reading 0 from q1 and goes to q2,output is 2, reading 0 from q2 and goes to q4, output
is 4, reading 0 from q4 and goes to q4, output is 4, reading 1 from q4 and goes to q4.
Final output is 4. The input string binary value is 10011 and equivalent decimal value
19. Input value is divide by 5 and get remainder is 4. That is the final output of given
input.
Page | 19
Input 1 O 0 1 1
output 1 2 4 4 4
Input string is 100. Initial state is p0,n], reading 1 from [p0,n] and goes to [p2,n],
output is n, reading 0 from [p2,n] and goes to [p1,n], output is n, reading 0 from
[p1,n] and goes to [p1,y], output is y. Size (N) of input is equal to size (N) of the
output. Input and output table is given below.
Input 1 O 0
output N N Y
Page | 20