Theory of
Computation/Automata
Theory of Automata
• Theory of automata is a theoretical branch of computer science and
mathematical. It is the study of abstract machines and the
computation problems that can be solved using these machines. The
abstract machine is called the automata. The main motivation behind
developing the automata theory was to develop methods to describe
and analyse the dynamic behaviour of discrete systems.
• This automaton consists of states and transitions. The State is
represented by circles, and the Transitions is represented by arrows.
Theory of Automata
• Automata is the kind of machine which takes some string as input and this
input goes through a finite number of states and may enter in the final
state.
• There are the basic terminologies that are important and frequently used
in automata:
• Symbols:
• Symbols are an entity or individual objects, which can be any letter,
alphabet or any picture.
• Example:
• 1, a, b, #
• Alphabets:
• Alphabets are a finite set of symbols. It is denoted by ∑.
Theory of Automata
• Examples:
1.∑ = {a, b}
2.∑ = {A, B, C, D}
3.∑ = {0, 1, 2}
4.∑ = {0, 1, ....., 5]
5.∑ = {#, β, Δ}
Theory of Automata
• String:
• It is a finite collection of symbols from the alphabet. The string is
denoted by w.
• Example 1:
• If ∑ = {a, b}, various string that can be generated from ∑ are {ab, aa,
aaa, bb, bbb, ba, aba.....}.
• A string with zero occurrences of symbols is known as an empty
string. It is represented by ε.
• The number of symbols in a string w is called the length of a string. It
is denoted by |w|.
Theory of Automata
Example 2:
1.w = 010
2.Number of Sting |w| = 3
• Language:
• A language is a collection of appropriate string. A language which is
formed over Σ can be Finite or Infinite.
Theory of Automata
Example 1:
{a,b};
L1 = {Set of string of length 2} = {aa, bb, ba, bb} Finite Language
L2 = {Set of all strings starts with 'a'} = {a, aa, aaa, abb, abbb, ababb}
Infinite Language
Finite Automata
• Finite automata are used to recognize patterns.
• It takes the string of symbol as input and changes its state accordingly.
When the desired symbol is found, then the transition occurs.
• At the time of transition, the automata can either move to the next
state or stay in the same state.
• Finite automata have two states, Accept state or Reject state. When
the input string is processed successfully, and the automata reached
its final state, then it will accept.
Formal Definition of FA
• A finite automaton is a collection of 5-tuple (Q, ∑, δ, q0, F), where:
1.Q: finite set of states
2.∑: finite set of the input symbol
3.q0: initial state
4.F: final state
5.δ: Transition function
Finite Automata Model:
• Finite automata can be represented by input tape and finite control.
• Input tape: It is a linear tape having some number of cells. Each input
symbol is placed in each cell.
• Finite control: The finite control decides the next state on receiving
particular input from input tape. The tape reader reads the cells one
by one from left to right, and at a time only one input symbol is read.
Finite Automata Model:
•.
Types of Automata:
There are two types of finite automata:
1.DFA(deterministic finite automata)
2.NFA(non-deterministic finite automata)
Types of Automata
1. DFA
DFA refers to deterministic finite automata. Deterministic refers to the uniqueness of
the computation. In the DFA, the machine goes to one state only for a particular input
character. DFA does not accept the null move.
2. NFA
NFA stands for non-deterministic finite automata. It is used to transmit any number of
states for a particular input. It can accept the null move.
Transition Diagram
A transition diagram or state transition diagram is a directed graph which can be
constructed as follows:
•There is a node for each state in Q, which is represented by the circle.
•There is a directed edge from node q to node p labeled a if δ(q, a) = p.
•In the start state, there is an arrow with no source.
•Accepting states or final states are indicating by a double circle.
Some Notations that are used in the transition diagram:
Transition Diagram
Transition Diagram
1. In DFA, the input to the automata can be any string. Now, put a pointer to the start state q and
read the input string w from left to right and move the pointer according to the transition
function, δ. We can read one symbol at a time. If the next symbol of string w is a and the
pointer is on state p, move the pointer to δ(p, a). When the end of the input string w is
encountered, then the pointer is on some state F.
2. The string w is said to be accepted by the DFA if r ∈ F that means the input string w is
processed successfully and the automata reached its final state. The string is said to be
rejected by DFA if r ∉ F.
Example 1:
DFA with ∑ = {0, 1} accepts all strings starting with 1.
Transition Diagram
Example 1:
DFA with ∑ = {0, 1} accepts all strings starting with 1.
The finite automata can be represented using a transition graph. In the above diagram, the
machine initially is in start state q0 then on receiving input 1 the machine changes its state to q1.
From q0 on receiving 0, the machine changes its state to q2, which is the dead state. From q1 on
receiving input 0, 1 the machine changes its state to q1, which is the final state. The possible input
strings that can be generated are 10, 11, 110, 101, 111......., that means all string starts with 1.
Transition Table
The transition table is basically a tabular representation of the transition function. It takes two
arguments (a state and a symbol) and returns a state (the "next state").
A transition table is represented by the following things:
•Columns correspond to input symbols.
•Rows correspond to states.
•Entries correspond to the next state.
•The start state is denoted by an arrow with no source.
•The accept state is denoted by a star.
Example
Present State Next state for Next State of
Input 0 Input 1
Solution: →q0 q1 q2
Transition table of given DFA is as follows:
q1 q0 q2
*q2 q2 q2
Transition Table
Present State Next state for Input 0 Next State of Input 1
→q0 q1 q2
q1 q0 q2
*q2 q2 q2
Explanation:
•In the above table, the first column indicates all the current states. Under column 0 and 1, the
next states are shown.
•The first row of the transition table can be read as, when the current state is q0, on input 0 the
next state will be q1 and on input 1 the next state will be q2.
•In the second row, when the current state is q1, on input 0, the next state will be q0, and on 1
input the next state will be q2.
•In the third row, when the current state is q2 on input 0, the next state will be q2, and on 1 input
the next state will be q2.
•The arrow marked to q0 indicates that it is a start state and circle marked to q2 indicates that it is
a final state.
DFA (Deterministic finite automata)
•DFA refers to deterministic finite automata. Deterministic refers to the uniqueness of the
computation. The finite automata are called deterministic finite automata if the machine is read
an input string one symbol at a time.
•In DFA, there is only one path for specific input from the current state to the next state.
•DFA does not accept the null move, i.e., the DFA cannot change state without any input
character.
•DFA can contain multiple final states.
In the following diagram, we can see that from state q0 for input a, there is only one path which
is going to q1. Similarly, from q0, there is only one path for input b going to q2.
Formal Definition of DFA
•A DFA is a collection of 5-tuples(Q, ∑, δ, q0, F) same as we described in the definition of FA.
•Q is a finite set of states.
•∑ is a finite set of symbols called the alphabet.
•δ is the transition function where δ: Q × ∑ → Q
•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).
Graphical Representation of DFA
•A DFA can be represented by digraphs called state diagram. In which:
•The vertices represent the states.
•The arcs labeled with an input alphabet show the transitions.
•The initial state is denoted by an empty single incoming arc. The initial state is
marked with an arrow.
•The final state is indicated by double circles.
Example 1:
1.Q = {q0, q1, q2}
2.∑ = {0, 1}
3.q0 = {q0}
4.F = {q2}
Graphical Representation of DFA
Example 1:
1.Q = {q0, q1, q2}
2.∑ = {0, 1}
3.q0 = {q0}
4.F = {q2}
Transition Table:
Present State Next state for Input 0 Next State of Input 1
→q0 q0 q1
q1 q2 q1
*q2 q2 q2
Solution:
Transition Diagram:
Graphical Representation of DFA
Example-2
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
Solution:
Transition Diagram:
c
DFA- Practice Questions
Q-1
DFA with ∑ = {0, 1} accepts all starting with 0.
Solution:
•Explanation:
•In the above diagram, we can see that on given 0 as input to DFA in state q0 the DFA changes
state to q1 and always go to final state q1 on starting input 0. It can accept 00, 01, 000,
001....etc. It can't accept any string which starts with 1, because it will never go to final state on
a string starting with 1.
DFA- Practice Questions
Q-2
DFA with ∑ = {0, 1} accepts all ending with 0.
Solution:
•Explanation:
•In the above diagram, we can see that on given 0 as input to DFA in state q0, the DFA changes
state to q1. It can accept any string which ends with 0 like 00, 10, 110, 100....etc. It can't accept
any string which ends with 1, because it will never go to the final state q1 on 1 input, so the
string ending with 1, will not be accepted or will be rejected.
DFA- Practice Questions
Q-3
Design DFA with ∑ = {0, 1} accepts those string which starts with 1 and ends with 0.
Solution:
The FA will have a start state q0 from which only the edge with input 1 will go to the next state.
•Explanation:
•In state q1, if we read 1, we will be in state q1, but if we read 0 at state q1, we will reach to
state q2 which is the final state. In state q2, if we read either 0 or 1, we will go to q2 state or q1
state respectively. Note that if the input ends with 0, it will be in the final state.
DFA- Practice Questions
Q-4
Design a DFA with ∑ = {0, 1} accepts the only input 101.
•Explanation:
•In the given solution, we can see that only input 101 will be accepted. Hence, for input 101,
there is no other path shown for other input.
QUESTIONS AND ANSWERS