Automata ch1
Automata ch1
End of state
• 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.
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Basic terminologies that are important and frequently used in automata:
3. 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|.
• Example 2: w = 010
Number of Sting |w| = 3
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Continue..
Example: 2
L2 = {Set of all strings starts with 'a'} = {a, aa, aaa, abb, abbb, ababb}
Infinite Language
• Example 1:
• DFA with ∑ = {0, 1} accepts all strings starting with 1.
• Solution:
• Example 2:
• NFA with ∑ = {0, 1} accepts all strings starting with 1.
• Solution:
Example 1:
Solution:
• Transition table of given DFA is as follows:
→q0 q1 q2
q1 q0 q2
*q2 q2 q2
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.
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Example 2:
Solution:
→q0 q0 q1
q1 q1, q2 q2
q2 q1 q3
*q3 q2 q2
→q0 q0 q1
q1 q2 q1
*q2 q2 q2
• 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.
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Example 3:
• 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.
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Example 4:
Design a FA 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.
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.
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Example 5:
Design a FA with ∑ = {0, 1} accepts the only input 101.
Solution:
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.
NFA is defined in the same way as DFA but with the following two
exceptions, it contains multiple next states, and it contains ε transition.
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Continue..
In the following image, we can see that from state q0 for input a, there
are two next states q1 and q2, similarly, from q0 for input b, the next
states are q0 and q1. Thus it is not fixed or determined that with a
particular input where to go next. Hence this FA is called non-
deterministic finite automata.
NFA also has five states same as DFA, but with different
transition function, as shown follows:
δ: Q x ∑ →2Q
where,
•Q: finite set of states
•∑: finite set of the input symbol
•q0: initial state
•F: final state
•δ: Transition function
• Transition Table:
Present State Next state for Next State of Input
Input 0 1
→q0 q0, q1 q1
q1 q2 q0
*q2 q2 q1, q2
→q0 q1 q1
q1 q2 q2
*q2 Ε ε
Present State 0 1
→q0 q0, q1 q0, q2
q1 q3 ε
q2 q2, q3 q3
→q3 q3 q3
*q1 Ф {q2}
*q2 Ф {q2}
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)
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}
State 0 1
→[q0] [q0] [q1]
[q1] [q1, q2] [q1]
*[q2] [q2] [q1, q2]
*[q1, q2] [q1, q2] [q1, q2]
• ε-closure: ε-closure for a given state A means a set of states which can
be reached from the state A with only ε(null) move including the state
A itself.
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Steps for converting NFA with ε
to DFA:
Step 1: We will take the ε-closure for the starting state of NFA as a
starting state of DFA.
Step 2: Find the states for each input symbol that can be traversed from
the present. That means the union of transition value and their closures
for each state of NFA present in the current state of DFA.
Step 3: If we found a new state, take it as current state and repeat step 2.
Step 4: Repeat Step 2 and Step 3 until there is no new state present in
the transition table of DFA.
Step 5: Mark the states of DFA as a final state which contains the final
state of NFA.
03/11/2025 For third year CS student by Gezahiegn.T In 2022
Example 1:
• Convert the NFA with ε into its equivalent DFA.
• Solution: