Flat Unit 1 Notes
Flat Unit 1 Notes
Syllabus: Introduction to Finite Automata: Structural Representations, Automata and Complexity, the
Central Concepts of Automata Theory – Alphabets, Strings, Languages, and Problems. Nondeterministic
Finite Automata: Formal Definition, an application, Text Search, Finite Automata with Epsilon-Transitions.
Deterministic Finite Automata: Definition of DFA, How A DFA Process Strings, The language of DFA,
Conversion of NFA with €-transitions to NFA without €-transitions. Conversion of NFA to DFA, Moore and
Melay machines
Reading Head:
The Reading head examines only one square at a time and can move one square towards left till end of
the string.
Alphabets
Definition: An alphabet is any finite set of symbols. It is denoted by Σ
Strings
Definition: A string is a finite sequence of symbols taken from Σ.
d}
It is not the case that a string over some alphabet should contain all the symbols from the alphabet. For
example, the string cc over the alphabet { a, b, c } does not contain the symbols a and b. Hence, it is true that a
string over an alphabet is also a string over any superset of that alphabet.
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
Definition: The Kleene star, Σ*, is a unary operator on a set of symbols or strings, Σ, that
gives the infinite set of all possible strings of all possible lengths over Σ including λ.
Positive Closure
Definition: The set Σ+ is the infinite set of all possible strings of all possible lengths over Σ
excluding λ.
Representation: Σ+ = Σ1 U Σ2 U Σ3 U…….
Σ+ = Σ* − { λ }
Example : If the language takes all possible strings of length 2 over Σ = {a, b}, then L = {
ab, bb, ba, bb}
Problems
Construct a Language consisting of a set of strings over {a, b} in which each string of the
language starts with ‘01’
L = {01,011,010,…….}
q0 is the initial state from where any input is processed (q0 ∈ Q).
Problem 1: Construct a NFA accepting a set of strings over {a, b} in which each string of the language
ends with ‘01’
q2
ˆδ (q0, 001) = {q0,q2}
So the above string w=001 is accepted by the automata. Since { q0, q2 }∩{q2}(i.e Final state F) ≠Ф
– Techniques
Problem: Construct a NFA with epsilon, accepting a Language consists a set of strings with any number
of 0’s followed by any number of 1’s followed by any number of 2’s over {0, 1, 2}.
Problem : Construct a DFA accepting a set of strings over {0, 1} in which each string of the language
ends with ‘01’
Problem Statement
Let X = (Qx, Σ, δx, q0, Fx) be an €-NFA which accepts the language L(X). We have to design an
equivalent NDFA Y = (Qy, Σ, δy, q0, Fy) such that L(Y) = L(X). The following procedure converts
the NFA with €-transitions to NFA without €-transitions
Algorithm
Input: An NFA with €-transitions
Output: An equivalent NFA without €-transitions
Step 1: Find out all the ε transitions from each state from Q. That will be called as ε-closure{q1}
where qi ∈ Q.
Step 2: Then δ' transitions can be obtained. The δ' transitions mean a ε-closure on δ moves.
δ'(q, a) =ε-closure(δ(ε-closure(q),a))
step 3: Repeat Step-2 for each input symbol and each state of given €-NFA.
Step 4: Find the final states F for the NFA ( F={q}, where ε-closure(q) П Final states of €-NFA )
Step 5: Using the resultant states, the transition table and transition diagram for equivalent NFA
without ε can be built.
Solution:
ε-closure(q0) = {q0}
ε-closure(q2) = {q2}
step2: Now the δ' transition on each input symbol is obtained as:
δ'(q0, a) = ε-closure(δ(δ^(q0, ε),a))
= ε-closure(δ(ε-closure(q0),a))
= ε-closure(δ(q0, a))
= ε-closure(q1)
= {q1, q2}
δ'(q0, b) = ε-closure(δ(δ^(q0, ε),b))
= ε-closure(δ(ε-closure(q0),b))
= ε-closure(δ(q0, b))
=Ф
Now the δ' transition on q1 is obtained as:
δ'(q1, a) = ε-closure(δ(δ^(q1, ε),a))
= ε-closure(δ(ε-closure(q1),a))
= ε-closure(δ(q1, q2), a)
= ε-closure(Ф ∪ Ф)
=Ф
δ'(q1, b) = ε-closure(δ(δ^(q1, ε),b))
= ε-closure(δ(ε-closure(q1),b))
= ε-closure(δ(q1, q2), b)
= ε-closure(Ф ∪ q2)
= {q2}
= ε-closure(Ф)
=Ф
= ε-closure(δ(q2, b))
= ε-closure(q2)
= {q2}
Step 4: State q1 and q2 become the final state as ε-closure of q1 and q2 contain the final state q2.
States a b
→q0 {q1, q2} Ф
*q1 Ф {q2}
*q2 Ф {q2}
Algorithm
Input: An NDFA
Output: An equivalent DFA
Step 1 Create state table from the given NDFA.
Step 2 Create a blank state table under possible input alphabets for the equivalent
DFA. Step 3 Mark the start state of the DFA by q0 (Same as the NDFA).
Step 4 Find out the combination of States {Q0, Q1,... , Qn} for each possible input
alphabet.
Step 5 Each time we generate a new DFA state under the input alphabet columns, we have
to apply step 4 again, otherwise go to step 6.
Step 6 The states which contain any of the final states of the NDFA are the final states of
the equivalent DFA.
Example
Let us consider the NDFA shown in the figure below.
q δ(q,0) δ(q,1)
a {a,b,c,d,e} {d,e}
b {c} {e}
c ∅ {b}
d {e} ∅
e ∅ ∅
Using the above algorithm, we find its equivalent DFA. The state table of the DFA is shown in
below.
Q δ(q,0) δ(q,1)
[a] [a,b,c,d,e] [d,e]
[a,b,c,d,e] [a,b,c,d,e] [b,d,e]
[d,e] [e] ∅
[b,d,e] [c,e] [e]
[e] ∅ ∅
[c,e] ∅ [b]
[b] [c] [e]
[c] ∅ [b]
DFA vs NDFA
The following table lists the differences between DFA and NDFA.
DFA NDFA
The transition from a state is to a single The transition from a state can be to multiple
particular next state for each input symbol. next states for each input symbol. Hence it is
Hence it is called deterministic. called non-deterministic.
Empty string transitions are not seen in DFA. NDFA permits empty string transitions.
Finite automata may have outputs corresponding to each transition. There are two types of finite state
machines that generate output:
Melay Machine
Moore machine
Melay Machine
A Melay Machine is an FSM whose output depends on the present state as well as the present
input(transition).
Moore Machine
Moore machine is an FSM whose outputs depend on only the present state. A Moore machine can
Next State
Present State Output
Input = 0 Input = 1
a b c x2
b b d x1
c c d x2
d d d x3
Output depends both upon present state Output depends only upon the present state.
and present input.
Generally, it has fewer states than Moore Generally, it has more states than Melay
Machine. Machine.
Input change can cause change in output
Output changes at the clock edges. change as soon as logic is done.
In Moore machines, more logic is needed to
Melay machines react faster to inputs decode the outputs since it has more circuit
delays.
Next State
Present State a=0 a=1
State Output State Output
->a d b
b a d
c c c
d b a
Next State
Present State a=0 a=1
State Output State Output
-> a d 1 b 0
b a 1 d 1
c c 0 c 0
d b 0 a 1
Algorithm 5:
Input: Melay Machine
Output: Moore Machine
Step 1 Calculate the number of different outputs for each state (Qi) that are available in the
state table of the Melay machine.
Step 2 If all the outputs of Qi are same, copy state Qi. If it has n distinct outputs, break Qi
into n states as Qin where n = 0, 1,2.......
Step 3 If the output of the initial state is 1, insert a new initial state at the beginning which
gives 0 output.
Next State
Present
State a=0 a=1
Next Next
Output Output
State State
->a d 0 b 1
b a 1 d 0
c c 1 c 0
d b 0 a 1
State table of a Melay Machine
Here, states ‘a’ and ‘d’ give only 1 and 0 outputs respectively, so we retain states ‘a’ and ‘d’. But states ‘b’
and ‘c’ produce different outputs (1 and 0). So, we divide b into b0, b1 and c into c0, c1.