Lec 02 - Finite Automata
Lec 02 - Finite Automata
COMPUTATION
18/10/2023 1
Finite State Machines/ Finite State Automation
➢A finite-state machine (FSM), finite-state automaton(FSA), finite
automaton, or simply a state machine, is a mathematical model of
computation.
➢The FSM can change from one state to another in response to some inputs;
the change from one state to another is called a transition.
18/10/2023 2
Simple Examples to demonstrate FSA
02
18/10/2023 3
Practical Examples of the Uses of FSA/ FSM
➢The behavior of state machines can be observed in many devices in modern society
that perform a predetermined sequence of actions depending on a sequence of events
with which they are presented. Simple examples are;
❑ Vending machines (which dispense products when the proper combination of
coins is deposited)
❑ Elevators (whose sequence of stops is determined by the floors requested by
riders)
❑ Traffic lights (which change sequence when cars are waiting)
❑ Combination locks (which require the input of a sequence of numbers in the
proper order)
18/10/2023 4
Practical Examples of the Uses of FSA/ FSM:
Traffic Lights
𝑀 = (𝑆, 𝐼, 𝑓, 𝑠0 , 𝐹)
Where;
𝑆 = Set of all states, 𝐼 = Set of Inputs 𝑓 = Transition function
𝑠0 = Initial State / start 𝐹 = Final State
18/10/2023 6
Finite State Machines - Concept and Terminology
Example 2.1:
18/10/2023 7
III IV I II
18/10/2023 8
(I) Deterministic Finite Automata (Finite State machines without output)
➢DFA is a finite automata, in which for each input symbols, there is only one
transitions for each state.
➢The mathematical model is 𝑀 = (𝑆, 𝐼, 𝑓, 𝑠0 , 𝐹)
Example 2.2 Let a deterministic finite automation be 𝑆 = {𝑎, 𝑏, 𝑐}, 𝐼 = 0,1 , 𝑠0 = {𝑎},
𝐹 = {𝑐} and the transition function (𝑓) as shown by the following table. Construct the
state diagram
Present State Next state for input 0 Next state for input 1
a a b
b c a
c b c
18/10/2023 9
(I) Deterministic Finite Automata (Finite State machines without output)
Example 2.3
Construct the state diagram for the following situation,
𝑀 = 𝑆𝑒𝑡 𝑜𝑓 𝑠𝑡𝑟𝑖𝑛𝑔𝑠 𝑡ℎ𝑎𝑡 𝑠𝑡𝑎𝑟𝑡 𝑤𝑖𝑡ℎ 0
M={……………………………………………}
Example 2.4
Construct a state diagram to represent the set of bit strings that begin with two 0’s.
M={…………………………………………….}
18/10/2023 10
(I) Deterministic Finite Automata (Finite State machines without output)
Example 2.5
Construct a state diagram to represent the set of bit strings that do not contain two
consecutive 0s.
Example 2.6
Construct a state diagram to represent the set of bit strings that end with two 0s
Example 2.7
Construct a state diagram to represent the set of bit strings that contain at least two
0s
18/10/2023 11
(II) Non Deterministic Finite Automata (Finite State machines without
output)
➢Some moves of the machine cannot be determined uniquely by the input symbol and the
present state of such machines are called non deterministic automata.
➢In NDFA, for a particular input symbol, the machine can move to any combination of
the state in the machine.
18/10/2023 12
(II) Non Deterministic Finite Automata (Finite State machines without
output)
Example 2.8
Present State Next state for input 0 Next state for input 1
a a, b b
b C a,c
c b, c c
18/10/2023 13
(II) Non Deterministic Finite Automata (Finite State machines without
output)
Example 2.9
18/10/2023 14
(II) Non Deterministic Finite Automata (Finite State machines without
output)
Example 2.10
Design a NFA for the language L, all the strings over {0,1} that have atleast two
consecutive 0’s or 1’s
Exercise: Find out what are the differences between DFA and NFA and prepare a table
18/10/2023 15
Finite State machines with output (Moore Machines and Mealy Machines)
18/10/2023 16
Finite State machines with output - Moore Machines
18/10/2023 17
Finite State machines with output - Moore Machines
Example 2.11
Construct a Moore machines that counts the occurrence of ‘abb’ in any input string over
{a ,b }
18/10/2023 18
Finite State machines with output - Mealy Machines
18/10/2023 19