A Mealy machine is a finite state machine where the output depends on both the present state and the current input symbol, represented by a six-tuple (Q, Σ, Δ, δ, λ, q₀) where Q is the set of states, Σ is the input alphabet, Δ is the output alphabet, δ is the transition function, λ is the output function, and q₀ is the initial state; the transition table format is input/output, and for an input string of length n, the output string is also of length n.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Mealy Machines
Added:Hello everyone. Welcome to Nesso Academy. We are learning theory of computation and in the previous lecture we have understood a basic introduction of finite automata with output. And today in this lecture we are going to start with the very first type of finite automata with output. That is Mealy machines. So the topic for this lecture is Mealy machine. Let's get started.
Mealy machine is a finite state machine in which output depends on the present state and the current input symbol.
What does that mean?
It means that Mealy machine is a type of finite state machine or you can say Mealy machine is a type of finite automata with output in which output depends on the present state and the current input symbol.
So the output in Mealy machine depends on the present state and the current input symbol.
Let's look at this diagram.
Zero and one are the output symbols while A and B are the input symbols. Now the present state Q0 and the current input symbol A determine the output symbol zero.
Similarly the present state Q0 and the current input symbol B determine the output symbol one.
The present state Q1 and the current input symbol A determine the output symbol zero. Similarly the present state Q1 and the current input symbol B determine the output symbol one. Which means the present state and the current input symbol determine the output symbol. Which means that output depends on the present state and the current input symbol.
In case of DFA, I have explained you that present state and the current input symbol determine the next state.
Similarly, in case of Mealy machines also, present state and current input symbol determine the next state. But additionally, present state and current input symbol also determine the output symbol. Like in this diagram, the present state q0 and input symbol b determine the next state, which is q1.
But it also determine the output symbol, which is one.
I hope this is clear now.
Now, if you look at this diagram, you will find that on every transition, we have input {slash} output.
So, we can say that transition label format, this particular transition label format, is input {slash} output. That means first, you will write the input symbol.
Then there is a {slash}. Then you will write the output symbol. This is a particular format for transition in case of Mealy machines.
I hope the transition diagram of Mealy machine is clear to you.
Now, let's understand how to construct the transition table of Mealy machine.
This is the basic structure of transition table of Mealy machine.
Now, here you can see this column is for present state.
And the present states are q0 and q1.
So, in this column, we will write q0 and q1.
Obviously, q0 is the initial state. And q1 is just an ordinary state of Mealy machine.
As I have already explained you, in case of finite automata with output, there is no final or accepting states. That is why in this diagram, we don't have any final state.
Now, we have two columns for input symbol A and input symbol B.
And as I have just explained you, the next state and the output is dependent on the present state and the input symbol. So, the present state and the input symbol will determine the next state. Similarly, the present state and the input symbol will also determine the output symbol.
Now, we have to fill these cells. Let's start with our very first state, which is Q0. So, Q0 and input symbol A.
Q0 and input symbol A, the next state is also Q0. So, here we will write Q0. And Q0 and input symbol A, the output symbol is zero. So, here we will write zero.
Now, Q0 on input symbol B.
So, Q0 on input symbol B, the next state is Q1 and the output symbol is one. So, here we will write Q1 and output symbol is one.
Now, let's talk about the state Q1. This is the state Q1. Q1 on input symbol A.
So, Q1 on A gives Q1 and output symbol zero. So, here we will write Q1 and output symbol zero.
Now, let's talk about the input symbol B.
So, Q1 on the input symbol B, the next state is Q0 and the output symbol is one. So, the next state is Q0 and the output symbol is one.
This is how we have the transition table for Mealy machine.
I hope you have now understood how to construct the transition table from the transition diagram of Mealy machine.
Now, let's understand the six-tuple representation of Mealy machine.
So, the basic six-tuple representation of finite automata with output, I have already explained you in the previous lecture.
Let's understand all these elements one by one.
In the previous lecture, I have explained you that Q is simply the set of states that we have in our transition diagram.
Sigma is the input alphabet, which is the set of input symbols.
Capital delta is the output alphabet, which is the set of output symbols. In that particular diagram, A and B were the input symbols, and 0 and 1 were the output symbols.
Delta is the transition function, and this is same as the transition function of a DFA.
That is, for present state and the current input symbol, we determine the next state. So, the next state is dependent on the present state and the current input symbol.
Now, lambda is the output function.
And in the previous lecture, I have explained you that lambda or the output function is different for both Mealy machines and Moore machines. So, in Mealy machine, output function is represented using this particular equation. That is, lambda Q cross sigma gives us delta. What does that mean?
Q is the present state, delta is the input symbol, and from the present state and the current input symbol, we determine the output symbol.
That I have just explained you.
So, present state and current input symbol will determine the output symbol.
So, in case of Mealy machine, the present state and the current input symbol will determine the next state as well as the output symbol.
Now, Q0 is the initial state of the Mealy machine.
Now, it is to be noted that this cross represents the cross product, which means for every present state, there should be a transition for every input symbol, which is same as that of a DFA. So, this condition of Mealy machine is same as that of a deterministic finite automata.
I hope the six-tuple representation of Mealy machine is now clear to you.
Now, let's find out the values of each of these elements one by one.
So, now let's find out the values of Q, sigma, capital delta, small delta, lambda, and Q0 with respect to this particular diagram of a Mealy machine.
Let's first find out the values of Q, sigma, capital delta, and Q0.
So, Q is equal to Q0, Q1. As you can see in this diagram, we have only two states, Q0 and Q1.
And this capital Q means the set of states.
So, we will have only two states in this particular set, that is Q0, Q1.
Now, let's talk about sigma. Sigma is the input alphabet, which is the set of input symbols. And I have explained you that there are only two input symbols in this particular case, A and B.
So, sigma is equal to set of two symbols, A and B.
Similarly, output alphabet delta is the set of output symbols. And in this particular diagram, we have two output symbols, 0 and 1. So, delta is equal to the set of 0 and 1.
Now, Q0 is the initial state, and in this particular case, the initial state is Q0 only. So, Q0 will be equal to Q0.
Now, let's find out the values of transition function.
So, these are the values of transition function, which is basically the set of different transition rules.
So, delta Q0, A is giving us Q0.
Q0 on A is giving us Q0. Q0 on B is giving us Q1. Q0 on B is giving us Q1.
Q1 on A is giving us Q1 itself. And Q1 on B, Q1 on B is giving us Q0.
So, these are all the transition rules, and collectively all the transition rules is called as the transition function.
Basically, the present state and the current input symbol determine the next state.
This is what the transition function is.
Now, let's find out the values of output function.
So, these are the values of output function. As I have explained you, the present state and the current input symbol determine the output.
So, Q0 on A gives the output 0. Q0 on A gives the output 0. Q0 on B gives 1. Q0 on B gives 1.
Q1 on A gives 0. Q1 on A gives 0.
Q1 on B gives 1. Q1 on B gives 1. So, the present state and the current input symbol determine the output symbol.
I hope the six-tuple representation of Mealy machine is now clear to you.
Now, let's talk about input to output generation in case of Mealy machines.
I have explained you that in case of finite automata with output, we give a particular input string and finite automata with output transduce or translate that input string into the corresponding output sequence.
So, now we are going to understand how an input string is converted into its corresponding output sequence.
So, for this particular diagram, I have taken an input string a b b a. And now we will translate this input string into its corresponding output sequence with the help of this diagram of Mealy machine.
Let's start with the initial state, which is q0. So, first we will write the initial state, that is q0.
Now, q0 is the initial state and the first input symbol is a. So, the first input symbol is a and now q0 on a.
So, q0 on a gives q0. So, the next state is also q0.
What is the output symbol?
q0 on a, the output symbol is zero. So, here we will write zero, which is the output symbol.
Now, the next symbol is b. The next input symbol is b. So, q0 on b. Let's check.
q0 on b gives q1.
So, we will write the next state, which is q1.
Now, let's see the output symbol.
q0 on b, the output symbol is one. So, here we will write one.
Now, the next input symbol is b.
So, we will check q1 on B.
So, Q1 on B gives the state Q0.
So, we will get Q not. Let's see the output. Q1 on B gives the output 1.
So, here we will get 1 as the output symbol.
Now, the last input symbol is A.
So, Q0 on A will give us Q0 on A will give us Q0.
So, we will get Q0.
And the output symbol, Q0 on A, the output symbol is 0.
So, output symbol we will get 0.
So, finally we are getting the output string as 0 1 1 0. So, for the input string A B B A, the output string is 0 1 1 0.
And if you clearly observe, you will find that on getting the input string of length n in Mealy machine, the output is also of length n.
What is the length of input string? 1 2 3 4. 4 is the length of input string.
Then, what is the length of output string? 1 2 3 4.
4 is also the length of output string.
That means, in case of Mealy machine, if the input string is of length n, then output string is also of the length n.
That is what we can conclude from input to output generation for Mealy machine.
And in this way, we are done with our topic Mealy machine.
I hope you have understood this topic perfectly.
Now, in the next lecture, we will understand Moore machine in detail. So, this was all from my side for this lecture. Thank you, and I'll see you in the next lecture.
>> [music] >> Mhm.
Related Videos

TOP 15 Data compression Interview Questions and Answers 2019 Part-2 | Data compression | Wisdom jobs
wisdomjobs
281 views•2019-06-28

CTS 158: 802.11w Management Frame Protection
ClearToSend
4K views•2019-02-04

NDSS 2019 Send Hardest Problems My Way: Probabilistic Path Prioritization for Hybrid Fuzzing
NDSSSymposium
496 views•2019-04-02

How realistic is Cities: Skylines?
CityBeautiful
159K views•2019-02-14

GUIs & TUIs: Choosing a User Interface for Your Python Project | Real Python Podcast
realpython
2K views•2025-04-04

The OSI Model - Explained by Example
hnasr
225K views•2019-05-12

Cloud Computing - Introduction
elithecomputerguy
98K views•2019-10-07

From Traveler's Dilemma to Dynamic Routing | Demystifying Networking
IITBombayJuly
5K views•2019-08-04
Trending

WOW! Judge TURNS THE TABLES on Trump in His OWN $10B LAWSUIT!!!
MeidasTouch
197K views•2026-07-23

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23