2 - Module 2
2 - Module 2
2 - Module 2
BY
Mrs Charusheela Nehete
Assistant Professor,
IT Department ,
VESIT
1
Module 2 -Finite Automata
Finite Automata: FA as language acceptor or verifier, NFA ( with and without ε) , DFA, RE
to NFA, NFA to DFA, Reduced DFA , NFA-DFA equivalence, FA to RE. Finite State
Machines with output : Moore and Mealy machines. Moore and Mealy M/C conversion.
Limitations of FA.
Self-learning Topics: Practice exercise on FA and NFA
2
Contents
• Basic Machine
• Finite State Machine
• Finite Automaton (FA)
• Deterministic Finite Automata (DFA)
• Formal Definition
• Transition Diagram
• Examples
3
Basic Machine
4
Basic Machine Examples(Cntd..)
5
Finite State Machines FSM)
• Unlike basic machine, in FSM, we are concerned with machine
behavior, regarding in which internal state machine is and
how machine behaves upon receiving different intermediate
inputs in the current state.
6
FSM: Examples
7
FSM: Examples
8
I S Carry No Carry I S Carry No Carry
9
10
11
Design/Construct a FSM Steps:
12
Example 2:
13
14
15
Example 3:
16
Example 3:
17
Simulation for input 101
Example 4:
18
Finite Automaton (FA)
• FA is a mathematical model of FSM.
19
FA– Formal Definition
• FA is formally defined as a collection of 5 tuples:
• FA= (Q, ∑ , δ q0, F )
Where
– Q is a finite set of states
– ∑ is a finite set of input symbols (alphabet)
– q0 is a start state
– F is a finite set of accepting states
– δ is a transition function, which is a mapping Q x ∑ 🡪 Q
• Upon reading entire input string if machine resides in any of the final states,
then i/p string is considered to be accepted by m/c otherwise rejected.
21
Examples of Finite Automata as Acceptor
∑ = { C,H,A,R.I,O,T}
Q={ q0, q1, q2, q3 }
q0 = Initial State of machine
q1 = State of the machine after reading a string ending in C
q2 = State of the machine after reading a string ending in CA
q3 = State of the machine after reading a string ending in CAT
F = { q3 }
δ : Q x ∑ --> Q
22
Examples of Finite Automata as Acceptor
δ : Q x ∑ --> Q F = { q3 }
23
Examples of Finite Automata as Acceptor
Design a FA that accepts all strings over ∑={0,1} which end with either
‘00’ or ‘11’
δ : Q x ∑ --> Q
24
Exercises
25
Exercises
26
Exercises
27
Exercises
• Design FA that accepts all strings over ∑={x,y} ending with xyy.
28
Exercises
29
Exercises
Design DFA for the following languages:
30
FA as finite Control
31
Types of FA
Finite Automata
32
FA without Output
• FA without o/p :
• Deterministic Finite Automata (DFA)
– A FA is said to be deterministic if for every state, there
is a unique input symbol that takes the state to
required next unique state.
– There can not be more than one transitions on same
input symbol from same state.
• Non-deterministic Finite Automata (NFA)
– A FA in which there exists at least one state from which
there are more than one transitions on same input
symbol.
33
Formal Definition
• Deterministic Finite Automata (DFA)
DFA= (Q, ∑ , δ, q0, F ) Where
– Q is a finite set of states
– ∑ is a finite set of input symbols (alphabet)
– q0 is a start state
– F is a finite set of accepting states
– δ is a transition function, which is a mapping Q x ∑ 🡪 Q
36
Example
o
1
O, 1
q0 q1
37
Solution
38
Solution
F’= set of all states in Q’ that contains at least one final state of given NFA
={ [ q1], [q0,q1] }
39
Solution
40
Solution
41
Equivalent states
• Two or more states are said to be equivalent
states if
– They undergo the same transitions on reading
the same input symbol , and are of the same
type ie. Either final or non-final.
– Ie. All these states move to the same next state.
– The equivalent states are used to minimize DFA.
• If there are more than one equivalent states we can
remove all the equivalent states except one.
42
DFA Minimization Rules
43
44
DFA Minimization
45
Further Minimization of DFA
Replace
9 by 4
12 by 7
46
Further Minimization of DFA
47
Further Minimization of DFA
• Unreachable States
– A state is said to be an ‘unreachable
state’ if it cannot be reached from
the initial state on reading any input
symbol. Hence must be removed.
– E.g. states 2, 3, 4, 8 are
unreachable states
• Dead States
– These are the states which has no
outgoing transitions except to
themselves. These are also called as
trap states because once entered
there is no escape.
– These dead states must be removed
in order to minimize the DFA.
48
Minimized DFA
49
50
51
52
Thus in Mealy machine, output depends on both the current state as well as current input symbol
53
54
55
δ:Qx∑🡪Q λ:Qx∑🡪 Δ
56
δ:Qx∑🡪Q λ:Qx∑🡪Δ
57
58
Δ = {0,1 }
59
60
61
Mealy Machine:
62
63
64
65
Moore to Mealy machine conversion
66
Mealy to Moore machine conversion
67
68
• Convert following Mealy machine to its equivalent Moore
Machine
69
70