FLAT Unit 1 Notes(Typed) (1)
FLAT Unit 1 Notes(Typed) (1)
Unit 1
1. INTRODUCTION
Alphabet: It is a finite set of symbols, represented by Σ.
Example: Σ={0,1}
2. FINITE AUTOMATA
Finite automata consists of finite set of states and a set of transitions from the state to state that
occur on input symbols chosen from an alphabet Σ.
One state q0 is initial state in which automation starts.
Some states are designated as final states.
Finite automata can be classified into two types based on transition function:
1. Deterministic Finite Automata (DFA)
2. Non-Deterministic Finite Automata (NFA)
2.1 Deterministic Finite Automata (DFA)
It can be defined as M= (Q,Σ,δ,q0,F),
where
Q-Finite set of states
Σ-Input alphabet
δ-Transition function
q0-Initial state
F-Set of final states(accepting states)
RULES:
1. (q,∈)=q. and
2. For all strings w and input symbols a,
(q,wa)=δ( (q,w),a).
1. Transition table
In transition table the input symbols are represented as column headers and states are
represented as row headers.
The initial state is preceded by an arrow symbol and final state is encircled.
The table entries are transitions i.e. states.
2. Transition diagram
A directed graph called transition diagram is associated with finite automata as follows
The vertices of the graph correspond to the states of the finite automata.
If there is a transition from q to state p on input ‘a’ i.e. δ(q,a)=p then there is an arc
labelled 'a' from state q to state p.
The initial state is represented as vertex preceded by an arrow labelled with start.
The final states are represented as double circled vertices.
2.3 Design of DFA Examples
1. Design a DFA to accept a string with two consecutive 0’s over the alphabet {0,1} .
Solution:-
M=(Q, Σ,δ,q0,F)
Q={q0,q1,q2}—Set of states
∑={0,1}—Alphabet set
q0=Initial state
F={q2}---Final state
Language, L={0,1,10,11,100,101,110,111,1000,1001,1010,1011,1100,1101,1110,1111…}
Solution:-
M=(Q, Σ,δ,q0,F)
Q={q0,q1,q2,q3}—Set of states
∑={0,1}—Alphabet set
q0=Initial state
F={q1}---Final state
Language, L={0,1,10,11,100,101,110,111,1000,1001,1010,1011,1100,1101,1110,1111…}
3. Design a DFA to recognize strings ending with 10 over the alphabet {0,1}.
Solution:-
M=(Q, Σ,δ,q0,F)
Q={q0,q1,q2}—Set of states
∑={0,1}—Alphabet set
q0=Initial state
F={q2}---Final state
Language, L={0,1,10,11,100,101,110,111,1000,1001,1010,1011,1100,1101,1110,1111…}
2.4 Non-Deterministic Finite Automata (NFA)
NFA allows zero, one or more transitions from a state from the same input symbol.
NFA can be defined as M= (Q,Σ,δ,q0,F),
where
Q-Finite set of states
Σ-Input alphabet
δ-Transition function
q0-Initial state
F-Set of final states(accepting states)
RULES:
1. (q,∈)=q. and
2. For all strings w and input symbols a,
(q,wa)=δ( (q,w),a)
3. (P,w)= ⋃ (q, w)
1. Design a Non-Deterministic Finite Automata to accept the strings ending with 10.
Solution:-
Q = {q0,q1,q2}
Σ = {0,1}
q 0 = q0
F = {q2}
L = {10,010,110,0010,0110,1010,1110,….}
2. Design a Non-Deterministic Finite Automata to accept the strings with 0’s and 1’s such that
string contains two consecutive 0’s (or) two consecutive 1’s.
Solution:-
Q = {q0,q1,q2,q3,q4}
Σ = {0,1}
q0 = q0
F = {q2, q4}
3. Design a Non-Deterministic Finite Automata to accept the strings ending with 101.
Solution:-
Q = {q0,q1,q2,q3}
Σ = {0,1}
q0 = q0
F = {q3}
2.6 Equivalence between NFA and DFA
Theorem: If L is the language accepted by Non Deterministic Finite automata (NFA) then
there exist a DFA accepting same language L
2. Let M'=(Q',∑,δ',q0',F') is a DFA where Q' is defined as Q'=2Qand all the elements of
power set are represented in square brackets which represents single state
3. Initial state q0'=[q0]
4. F' is the set of all states of Q' which are having the final state of given NFA
5. δ' is calculated using δ'([q],a)=δ(q ,a ), δ'([p , q], a)=δ(p , a) U δ(q , a)
Note: In NFA to DFA conversation we can also define the transition table as follows
1. Start with initial state and define the transition over input symbols.
2. Define the transitions for the states over the input symbols [The transitions not
defined yet] under the input symbol columns.
3. Repeat step 2 until there are no states for which the transitions are to be defined.
Given NFA
M= (Q, ∑, δ, q0, F)
Q= {q0, q1}
∑= {0,1}
Q0=q0
F= {q1}
Constructing DFA
q0|= {q0}
F|= { [q1],[q0,q1]}
Input Symbols
State 0 1
[q0] [q0,q1] [q1]
[q1] [Ø] [q0,q1]
[q0,q1] [q0,q1] [q0,q1]
[Ø] [Ø] [Ø]
2) Convert Following NFA into Equivalent DFA.
M= {{p, q, r, s}, {0, 1}, δ, p, s}
δ 0 1
p {p, q} p
q r r
r s -
s s s
Sol: DFA:-
Q|={[Ø],[p],[q],[r],[s],[p,q],[q,r],[r,s],[p,s],[q,s],[p,r],[p,q,r],[q,r,s],[p,q,s],[p,r,s],[p,q,r,s]}
q0|= [p]
F|={[s],[r,s],[s,p],[q,s][q,r,s],[p,q,s],[p,r,s],[p,q,r,s] }
δ| 0 1
[p] [p,q] [p]
[p,q] [p,q,r] [p,r]
[p,r] [p,q,s] [p]
[p,q,r] [p,q,r,s] [p,r]
[p,q,s] [p,q,r,s] [p,r,s]
[p,r,s] [p,q,s] [p,s]
[p,s] [p,q,s] [p,s]
[p,q,r,s] [p,q,r,s] [p,r,s]
3) Convert the following NFA TO DFA?
δ 0 1
p [q,s] q
q r [q,r]
r s p
s - p
Solution:
DFA:
Q|={[Ø],[p],[q],[r],[s],[p,q],[q,r],[r,s],[p,s],[q,s],[p,r],[p,q,r],[q,r,s],[p,q,s],[p,r,s],[p,q,r,s]}
q0|= [p]
F|={ [q],[s],[q,r],[p,s],[r,s],[q,s],[p,q],[p,q,r],[q,r,s],[p,r,s],[p,q,s],[p,q,r,s]}
δ| 0 1
[p] [q,s] [q]
[q] [r] [q,r]
[q,s] [r] [p,q,r]
[r] [s] [p]
[q,r] [r,s] [p,q,r]
[p,q,r] [q,r,s] [p,q,r]
[s] [Ø] [p]
[q,r,s] [r,s] [p,q,r]
[r,s] [s] [p]
2.7 NFA- ε Transitions
M= (Q, Σ, δ, q0, F)
– Q is a set of states
=Q X Σ* to 2Q
ε –closure(q) is the set of all states p such that there is a path from q to p labelled ‘ ε ’.
Rules-
1. (q, ε) =ε-closure(q)
2. (q, wa)=ε-closure(δ( (q,w),a))
3. (p, w)=Uq in p δ(q,a)
4. δ(p,a)=Uq in p δ(q,a)
1) Design a NFA with є transitions to accept the language containing any no of zeroes
followed by any no of ones followed by any no of twos.
M={Q, Σ,𝛿,q0,F}
Q={q0,q1,q2}
Σ ={0,1,2}
F={q2}
L={ ε,0,01,10,001,0001……..}
2.8 Equivalence between NFA with ɛ-Transition to NFA
Theorem: If ‘L’ is a Language accepted by NFA with ɛ transitions, then there exists NFA
without ɛ transition (NFA) accepting the same language L.
We construct NFA M|= (Q, ∑, δ|, q0, F|) equivalent to M with the following steps.
where, ( q, ɛ) = ɛ-closure(q)
3. F| is defined as the set of all states whose ɛ-closure contains a final state in F.
3. Finite Automata with Output
1. Moore Machine
2. Melay Machine
Σ=input alphabet
Δ=output alphabet
δ=transition function
λ=output function
q0=initial state
The Moore machine gives the output λ(q0) for empty input ε.
2. Mealy Machine- In this machine the output depends on the transition.
Σ=input alphabet
Δ=output alphabet
δ=transition function
λ=output function
q0=initial state