TOC Unit 1 Notes
TOC Unit 1 Notes
Unit – I
Formal Language Theory and Finite
Automata
1. Finite Automata (FA)
Formal Language Theory is the foundation of automata theory and compiler design. It deals
with the structure and behavior of languages, which are defined using formal rules.
Examples: a, b, 0, 1, #, $
Σ = {a, b, c}
Examples: w = 0101
w = bbab
7. Language (L): A set of strings formed using the alphabet. A language can be finite or
infinite.
A Finite Automaton (FA) is a simple abstract machine used to recognize patterns within input
strings. It has a limited (finite) memory and operates by reading input symbols one at a
time, moving from one state to another.
It cannot remember anything beyond its current state (no external memory like a stack or
tape).
M = (Q, Σ, δ, q0, F)
1. Q – Set of States: This is the finite set of all possible states the automaton can be in. Each
state represents a condition or status of the machine at a particular moment.
2. Σ – Input Alphabet: A finite set of symbols that the machine can read as input. These
symbols form the language that the automaton operates on.
3. δ – Transition Function: This function tells the automaton how to move from one state to
another based on the input symbol. In a DFA, δ gives exactly one next state for a given
(current state, input symbol) pair.
Notation: δ: Q × Σ → Q
Example: δ (q0, 1). This means if the current state is q0 and input is 1, move to state q1.
4. q₀ – Initial (Start) State: The state where the automaton begins execution before any input
is read. It must be one of the states in Q.
Notation: q0 ∈ Q
5. F – Set of Final (Accepting) States: Subset of Q containing states that accept the input
string. If the automaton finishes reading the input and is in one of these states, the string is
accepted.
Notation: F ⊆ Q
Transi on Diagram
A transition diagram is a visual way to represent a DFA using states and transitions. It shows
how the machine moves from one state to another based on input symbols.
o These show how the automaton moves based on the current symbol.
4|Page © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
States:
Transitions:
From q0:
On a → go to q1
On b → go to q2
From q1:
On a → stay in q1 (self-loop)
On b → go to q3
From q2:
5|Page © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
On a → go to q3
On b → stay in q2 (self-loop)
From q3:
Start at q0
Read a → go to q1
Transi on Table
q0 q1 q2
q1 q1 q3
q2 q3 q2
q3 q3 q3
Example:
δ (q0, a) = q1
δ (q1, b) = q3
δ (q3, b) = q3 (self-loop)
6|Page © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
Goal: To model how an elevator moves between three floors using a Finite Automaton
(FA) with states representing each floor.
States (Q):
Transition System − The transition system of the lift can be represented as a directed
graph.
In this directed graph, circles denote states (Q0, Q1, Q2). Directed edges represent transitions
based on input symbols.
The transition system of the lift can be visualized as the above-mentioned directed graph with
three states: Q0 (ground floor), Q1 (first floor), and Q2 (second floor).
Each state is represented by a circle. The initial state, Q0, is indicated by an inward arrow.
Transitions between states are depicted by directed edges based on input symbols.
A Finite State Machine (FSM) is a mathematical model of computation that behaves like a
machine with a finite number of states and changes between them based on input symbols.
It is used to model systems that have a fixed number of conditions or modes (states) and
respond to external inputs.
M = (Q, Σ, δ, q0, F)
Where:
δ = Transition function: δ: Q × Σ → Q
3. It follows transitions (defined by δ) based on the current symbol and current state.
o Otherwise, it is rejected.
8|Page © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
Types of FSM:
o For each state and input symbol, exactly one transition exists.
o No ambiguity.
A language accepted by a FA is the set of all strings that the automaton accepts (i.e., ends in
a final state after reading the entire input).
Formal Definition:
L(M) = {w ∈ Σ* ∣ δ* (q0, w) ∈ F}
Where:
q0 = initial state
Key Points:
The collection of all such strings forms the language accepted by the FA.
A regular language is a type of formal language that can be recognized or accepted by a finite
automaton (FA).
Formal Definition:
Key Points:
They are the simplest and most restricted class in the Chomsky hierarchy.
∅ (empty language)
Example:
All these strings, when processed by the FA, end in a final state, so they belong to the regular
language.
2. FA without output
A Deterministic Finite Automaton (DFA) is a type of finite automaton where for each state
and input symbol, there is exactly one defined transition.
Symbol Meaning
δ Transition function: Q × Σ → Q
Characteristics of DFA:
1. Determinism: For every state and input, only one transition is defined.
Example 2.1.1 Design a DFA which checks whether a given binary number is divisible by 3.
Logic:
q1 → remainder 1
q2 → remainder 2
Start state: q0
Transition Table
→ *q0 q0 q1
q1 q2 q0
q2 q1 q2
Explanation of transitions
Transitions are based on taking the remainder mod 3 after each step.
Example 2.1.2 Design an FA which checks whether a given binary number is even.
A binary number is even if its last bit is 0. So, we only need to look at the last input symbol.
FA Components
States:
q0 → even number (last bit 0) Final State
Alphabet: {0, 1}
Final States: { q0 }
Transition Table
→* q0 q0 q1
q1 q0 q1
Explanation
If we are in odd state (q1) and read 0, it becomes even → move to q0.
Example 2.1.3 Design a DFA which accepts even number of 0’s and even number of 1’s.
Transition Table
→* q0 q1 q3
q1 q0 q2
q2 q3 q1
q3 q2 q0
Explanation
Example 2.1.4 Design finite automata for accepting strings, over Σ = {0, 1}, with even number
of 0’s and odd number of 1’s.
Example 2.1.5 Design a DFA which can accept a decimal number divisible by 3.
We will use modulo 3 arithmetic to keep track of the remainder when the number formed so
far is divided by 3.
14 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
States:
q1 → remainder 1
q2 → remainder 2
Transition Table:
Alphabet: {0,1,2,3,4,5,6,7,8,9}
Start State: q0
Accepting State: q0
Example:
Input: 120
o q0 120
15 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
o 1 q1 20
o 12 q0 0
o 120 q0
o Ends in q0 → Accepted
Example 2.1.6 Design DFA to accept L, where L = {Strings in which ‘a’ always appears
tripled} over the set Σ = {a, b}
L = {strings in which ’a’ always appears tripled over the alphabet Σ = {a,b}, we need to ensure
that every occurrence of 'a' in the string is part of a triple "aaa". That is:
States:
Transition Table
16 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
→ q0 q1 q0
q1 q2 qd
q2 q3 qd
* q3 (accept) q1 q3
qd (dead) qd qd
Example 2.1.7 Draw DFA for the following language over {0, 1}
The idea is to track the remainder when the number of 1’s seen so far is divided by 3.
On reading 0, we stay in the same state because we’re only counting 1’s.
Alphabet: {0, 1}
Transition Table:
17 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
→ *q0 q0 q1
q1 q1 q2
q2 q2 q0
→ q0 q0 q1
*q1 q1 q2
*q2 q2 q0
Example 2.1.8 Draw FA for strings which do not contain ‘00’ as a substring in it over alphabet
Σ = {0, 1}.
Explanation:
The FA must reject any string that contains "00" as a substring. So, it should accept strings
like: ε (empty string), 0, 1, 01, 101, 10101
States:
Transition Table:
→ *q1 qd q0
qd qd qd
Example 2.1.9 Construct DFA for the language of all strings that begin and end with same
symbol over the alphabet Σ = {0, 1}.
This DFA checks whether the first and last symbol of the string are the same.
We track the first symbol and then wait to see the last symbol. So, we accept only if:
Transition Table:
State 0 1
→ q0 q1 q2
q1 q3 q1
q2 q2 q4
*q3 q3 q1
*q4 q2 q4
Input: 0110
q0 → (0) → q1
q1 → (1) → q3
q3 → (1) → q3
q3 → (0) → q3
Ends in q3 → Rejected
The DFA accepts strings over Σ = {0, 1} that end with 10. This means the machine must
recognize when the last two symbols are exactly 1 followed by 0.
Transition Table:
→ q0 q0 q1
q1 q2 q1
*q2 q0 q1
1. q0 — 1 → q1
2. q1 — 0 → q2
3. q2 — 1 → q1
4. q1 — 0 → q2
Example 2.1.11 Construct a DFA accepting the following languages over the alphabet {a, b}.
The string must start with exactly ab, and anything can follow afterward (even empty).
States:
q1: Saw a
Transition Table:
→ q0 q1 qd
q1 qd q2
*q2 q2 q2
qd qd qd
Example:
ab → q0 → q1 → q2 (Accepted)
abaabb → q0 → q1 → q2 → q2 → q2 → q2
ba → q0 → qD (Rejected)
The DFA should reject any string that has three or more b's in a row (bbb, abbb, etc.).
States:
Transition Table:
→ *q0 q0 q1
*q1 q0 q2
*q2 q0 q3
q3 q3 q3
Example:
abbab → q0 → q1 → q2 → q0 → q1 (Accepted)
abbb → q0 → q1 → q2 → q3 (Rejected)
Example 2.1.12 Construct DFA for checking "whether a string over alphabet {a, b} contains a
substring aba".
We are to construct a DFA that accepts all strings over {a, b} which contain "aba" as a
substring. That means once the substring "aba" is found anywhere in the input, the string
should be accepted.
23 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
Transition Table:
State a b
→ q0 q1 q0
q1 q1 q2
q2 q3 q0
*q3 q3 q3
Input: bbabaabb
q0 → b → q0
q0 → b → q0
q0 → a → q1
q1 → b → q2
q2 → a → q3
q3 → a → q3
q3 → b → q3
q3 → b → q3 (Accepted, since we reached final state q3).
We are designing a DFA that accepts binary numbers divisible by 4. A binary number is
divisible by 4 if its last two digits are 00 (except for 0 itself).
State 0 1
q0 q0 q1
q1 q2 q3
q2 q0 q1
q3 q2 q3
q1: Remainder 1
q2: Remainder 2
q3: Remainder 3
Input: 100
q0 → 1 → q2
q2 → 0 → q2
q2 → 0 → q2
Not accepted
q0 → 1 → q1
q1 → 0 → q2
q2 → 0 → q0
Example 2.1.14 Design a DFA (Deterministic Finite Automata) that reads strings made up of
the letters in the word ‘UNIVERSITY’ and recognizes those strings that contain the word
‘UNITY’ as a substring.
We are to design a DFA over the alphabet {U, N, I, V, E, R, S, T, Y} which accepts strings
containing the substring "UNITY".
25 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
The DFA will transition through intermediate states on reading each character of the substring
"UNITY" and reach a final (accepting) state once the substring has been completely read.
Transition Table:
→ q0 U q1
q0 ≠U q0
q1 N q2
q1 U q1
q1 ≠N,U q0
q2 I q3
q2 U q1
q2 ≠I,U q0
q3 T q4
q3 U q1
q3 ≠T,U q0
q4 Y q5 (final)
q4 U q1
q4 ≠Y,U q0
Note:
Once we reach q5, we stay there since the string contains "UNITY".
26 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
q0 → V → q0
q0 → E → q0
q0 → R → q0
q0 → S → q0
q0 → U → q1
q1 → N → q2
q2 → I → q3
q3 → T → q4
q4 → Y → q5 (final)
Remaining letters → q5 → q5
For a given state and input symbol, the automaton can move to zero, one, or multiple next
states.
27 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
In contrast to a Deterministic Finite Automaton (DFA), where only one unique next state is
allowed for each input from a state.
Where:
Q = Set of states
q₀ = Start state
Transition for each Exactly one transition for Zero, one or more transitions
symbol every symbol from a state allowed
Next state Only one possible next state Can have multiple possible next
states
Acceptance of string Accepted if the only path Accepted if any one path ends in
ends in final state final state
Speed of execution Generally faster due to single May explore many paths
path (conceptually slower)
28 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
Ease of construction May require more states Can be simpler with fewer states
Used in real Yes, DFAs are preferred for Not used directly, but useful for
compilers? implementation design & theory
Example 2.2.1 An NFA with states 1-5 and input alphabet {a, b} has following transition table.
q 𝛿 (q, a) 𝛿 (q, b)
→1 {1, 2} {1}
2 {3} {3}
3 {4} {4}
4 {5} ∅
*5 ∅ {5}
i) Draw transition diagram. ii) Calculate 𝛿* (1, ab). iii) Calculate 𝛿* (1, abaab)
i) Transition Diagram
Start at state 1
δ(1, b) = {1}
δ(2, b) = {3}
We compute step-by-step:
δ(1, b) = {1}
δ(2, b) = {3}
So:
→ After ab: {1, 3}
Next input: a
δ(1, a) = {1, 2}
δ(3, a) = {4}
So:
→ After aba: {1, 2, 4}
Next input: a
δ(1, a) = {1, 2}
δ(2, a) = {3}
δ(4, a) = {5}
So:
→ After abaa: {1, 2, 3, 5}
Final input: b
δ(1, b) = {1}
δ(2, b) = {3}
δ(3, b) = {4}
δ(5, b) = {5}
Thus, it is not definite that on input 1 whether we will be in state q 1 or q2. Hence it is called
non-deterministic finite automaton (NFA) and since there are some ε moves to simply change
the states, it is called NFA with ε.
Σ: Input alphabet
This means from a state, on an input symbol or ε (epsilon), the machine can move to a set of
states
q0 ∈ Q: Start state
In simple words: An ε-NFA is like an NFA that also allows free transitions (ε-moves),
meaning it can change states without reading any input symbol.
31 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
Example 2.3.1 Construct NFA with ε that accepts a language consisting the strings of any
number of a’s followed by any number of b’s. Followed by any number of c’s.
We are given the task to construct an ε-NFA (NFA with epsilon transitions) for the language:
L = { aⁿ bᵐ cᵒ | n, m, o ≥ 0 }
That is: any number of as (including 0), followed by any number of bs, followed by any number
of c’s.
We connect these parts using ε-moves to allow smooth switching between groups without
consuming any input.
States:
q1 → handles b’s
q2 → handles c’s
Transition Table:
q0 {q0} ∅ ∅ {q1}
q1 ∅ {q1} ∅ {q2}
32 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
q2 ∅ ∅ {q2} ∅
The set of all states reachable from q by taking zero or more ε-transitions (i.e., moves
without consuming any input symbol).
If there exists ε-closure (P) = {q} and δ (q, ε) = r then, ε-closure (P) = {q, r}
Example 2.4.1 Find ε-closure for the following non-deterministic finite automata (NFA) with
epsilon.
ε-closure (q1) = {q1, q2} means q1 is a self-state and q2 is a state obtained from q1 with ε
input.
33 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
To convert an ε-NFA (NFA with epsilon transitions) into a regular NFA (without ε transitions),
follow these steps:
ε-closure(qi)
This includes all the states reachable from qi using only ε-transitions.
For each input symbol a ∈ Σ and for each state q ∈ Q, calculate the new transition:
This means:
o Then, from all those states, apply input a using the original δ
Apply the process for each symbol in the alphabet and each state in the NFA.
Use the results from step 3 to create a transition table for the equivalent NFA without
ε-transitions.
= ε-closure (q0 ∪ ∅ ∪ ∅)
= ε-closure (q0)
= ε-closure (∅ ∪ q1 ∪ ∅)
= ε-closure (q1)
= {q1, q2}
= ε-closure (∅ ∪ ∅ ∪ q2)
= ε-closure (q2)
= {q2}
= ε-closure (δ (ε-closure(q1), a)
= ε-closure (∅ ∪ ∅)
= ε-closure (∅)
=∅
= ε-closure (q1 ∪ ∅)
= ε-closure (q1)
= {q1, q2}
= ε-closure (∅ ∪ q2)
= ε-closure (q2)
= {q2}
36 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
= ε-closure (∅)
=∅
= ε-closure (∅)
=∅
= ε-closure (q2)
= {q2}
q2 ∅ ∅ {q2}
Example 2.5.2 Convert the following NFA with ε-moves into NFA without ε moves.
We compute ε closures of A, B, C, D
= ε-closure (A ∪ D ∪ C)
= {A, B, C, D}
= ε-closure (∅ ∪ B ∪ D)
= {B, D}
= ε-closure (D)
= {D}
= ε-closure (B)
= {B}
= ε-closure (C)
= {C}
= ε-closure (D)
= {D}
= ε-closure (∅)
= {∅}
= ε-closure (∅)
= {∅}
A {A, B, C, D} {B, D}
B {D} {B}
C {C} {D}
D ∅ ∅
o Q = Set of states
o Σ = Input alphabet
o δ = Transition function
o q₀ = Start state
M' = (Q', Σ', δ', q₀', F') such that L(M) = L(M')
Conversion Steps:
1. Start State: The start state of the DFA (q₀') will be the same as the start state of the NFA
(q₀), but represented as a set: q₀' = {q₀}. Add this to the set of DFA states Q'.
2. Transition Construction: For each state S = {q₁, q₂, ..., qᵢ} in Q' and for each input symbol
'a' in Σ:
41 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
ii) Let the resulting set of states be T = {q₁, q₂, ..., qₖ}. If T isn’t already in Q’, add it to Q’.
iii) Repeat this process for each newly added state and for each symbol in Σ until no new
states are generated.
3. Final States: Any DFA state S = {q₁, q₂, ..., qₙ} will be a final state in DFA (i.e., in F’) if
at least one qi ∈ F (final states of NFA).
As no new state is getting generated, we will stop applying δ transitions. The transition table
for DFA is as follows:
Final State F’ = { [s], [p, q, r, s], [p, q, s], [p, r, s], [p, s] }
The transition graph shows two disconnected parts. But part 1 will be accepted as final DFA
because it consists of start state and final states, in part 2 there is no start state.
The minimization of a Finite State Machine (FSM) means reducing the number of states in a
given FA without changing the language it accepts.
While minimizing an FSM, we first identify equivalent states — states that behave identically
for all input strings — and then represent them using a single representative state.
Equivalent States
Two states q₁ and q₂ are equivalent if, for every string x ∈ Σ*:
Create:
Thus:
π0 = { Q0¹ , Q0² }
o δ(q₁, a) and δ(q₂, a) belong to the same equivalence class in πk for all a ∈ Σ.
Split Qik into smaller sets based on this rule to form πk+1.
Repeat this process for every subset in πᵏ to get all elements of πk+1.
Continue refining:
45 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
π0 → π1 → π2 → … → πn
Replace all equivalent states in each final partition with a single representative state.
Result:
The resulting DFA has the minimum possible number of states while accepting the same
language as the original DFA.
Example 2.7.1 Construct the minimum state automaton for the following transition table.
Check each state in the non-final set and split based on transitions into different groups of π 0.
46 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
After splitting:
Split into:
o { q₀, q₆ }
o { q₁, q₅ }
2. { q₂, q₄, q₇ }:
Split into:
47 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
o { q₂, q₄ }
o { q₇ }
So
π2 = π3 → STOP
Transition Diagram:
3. FA with output
A Moore Machine is a type of Finite State Machine (FSM) in which the output is
determined solely by the current state, not by the input symbol.
This means the output is associated with each state, and it changes only when the machine
changes its state.
Formal Definition
M = (Q, Σ, Δ, δ, λ, q0)
Where:
Σ → Input alphabet.
Δ → Output alphabet.
Key Characteristics
Example
Next State
Present State Output
Σ=0 Σ=1
→ q0 1 q1 q2
q1 1 q2 q1
q2 0 q2 q0
49 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
Applications
Control systems.
A Mealy Machine is a type of Finite State Machine (FSM) in which the output depends on
both the current state and the current input symbol.
Unlike a Moore Machine, the output can change immediately when the input changes, without
waiting for a state change.
Formal Definition
M = (Q, Σ, Δ, δ, λ, q0)
Where:
Σ → Input alphabet.
Δ → Output alphabet.
Key Characteristics
Applications
Real-time systems.
Sequence detectors.
Example
Σ=0 Σ=1
State Output State Output
q0 q2 1 q1 0
q1 q1 0 q2 1
51 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
q2 q2 0 q0 0
Output Function λ: Q → Δ λ: Q × Σ → Δ
Output Change Output changes only on state Output can change immediately
change. with input change (even without
state change).
Number of States Usually more states are Usually fewer states are
required. required.
Speed of Output Slower, because output changes Faster, because output depends
after state transition. directly on input.
Design Complexity Easier to design and understand. Slightly more complex to design.
Example 3.3.1 Design a Moore Machine to generate 1’s complement of a given binary
number.
0→1
1→0
Goes to a state that gives output 1 for input 0, and output 0 for input 1.
Transition Table:
q0 q1 q2 0
q1 q1 q2 1
q2 q1 q2 0
1. Start at q0
Example 3.3.2. Design a Mealy Machine to find 2’s complement of a given binary number.
To compute the 2’s complement of a binary number using a Mealy machine, follow this
logic:
Copy all bits unchanged until the first 1 is found (this 1 is kept as-is).
States Description:
q0: Initial state – looking for the first 1 from right to left.
Transition Table
q0 q0/0 q1/1
q1 q1/1 q1/0
The output function λ' can be obtained as: λ' (q, a) = λ (δ(q, a))
Meaning: The Mealy Machine’s output for a given state and input is the output of the
destination state in the Moore Machine.
54 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
Example 3.4.1 Consider the Moore Machine described by the transition table given below.
Construct corresponding Mealy Machine.
Next State
Present State Output
Σ=0 Σ=1
→ q1 0 q1 q2
q2 0 q1 q3
q3 1 q1 q3
= λ (q1)
=0
= λ (q2)
=0
= λ (q1)
=0
55 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
= λ (q3)
=1
= λ (q1)
=0
= λ (q3)
=1
Σ=0 Σ=1
State Output State Output
q1 q1 0 q2 0
q2 q1 0 q3 1
q3 q1 0 q3 1
56 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
Then there exists an equivalent Moore Machine: M′ = (Q×Δ, Σ, Δ, δ′, λ′, [q0, b0])
Definition of Functions
This defines the output produced for the corresponding Moore state.
Meaning
In Moore, the output is linked to states, so we form new states as pairs [q, b], where:
/
For each Mealy transition 𝑞 𝑝, we create a Moore transition from [q, b′] to [p, b],
where b′ is the output of the source state.
Procedure
/
2. For each transition 𝑞 𝑝, create a Moore state [p, b] if it does not already exist.
3. Construct the transition table for δ′ using: δ′ ([q, b], a) = [δ (q, a), λ (q, a)]
Example 3.5.1 Convert the following Mealy machine into equivalent Moore Machine.
57 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
We first write the transition table for the given transition graph:
Now we will find out the states and corresponding outputs for Moore machine. The states for
Moore machine will be:
[q0, N], [q0, Y], [q1, N], [q1, Y], [q2, N], [q2, Y]
= [q1, N]
λ′ (q0, N) = N
= [q2, N]
λ′ (q0, N) = N
= [q1, N]
58 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
λ′ (q0, Y) = Y
= [q2, N]
λ′ (q0, Y) = Y
= [q1, Y]
λ′ (q1, N) = N
= [q2, N]
λ′ (q1, N) = N
= [q1, Y]
λ′ (q1, Y) = Y
= [q2, N]
λ′ (q1, Y) = Y
= [q1, N]
λ′ (q1, N) = N
= [q2, Y]
λ′ (q2, N) = N
= [q1, N]
59 | P a g e © Haris Chaus 2025 | ALL RIGHTS ARE RESERVED as per Copyright Act, 1957.
λ′ (q2, Y) = Y
= [q2, Y]
λ′ (q2, Y) = Y
Next State
Present State Output
Σ=0 Σ=1
[q0, N] N [q1, N] [q2, N]
Q. Justify that there can be the equivalent Mealy machine for any Moore machine by suitable
example.
Yes, for every Moore machine, there exists an equivalent Mealy machine.
To convert it: The output will now be on transitions depending on the next state’s output.
Explanation:
From state A:
o On input 0 → goes to B → B has output 1 → so transition is B/1
o On input 1 → goes to C → C has output 0 → so transition is C/0
And so on for others.
The behavior/output of both machines is the same, just represented differently. Hence,
every Moore machine can be converted to an equivalent Mealy machine.