1. Gyanastra
  2. Theory of Computation
  3. Moore and Mealy Machines
  4. Output Function of Mealy Machine (Output Associated with Transitions)
Free lesson, no account needed 4 min read 11 practice questions after it
Asked in past papers2 times
  • GATE CSE20212002

Theory of Computation · Moore and Mealy Machines

Output Function of Mealy Machine (Output Associated with Transitions)

Overview

In a Mealy machine the output is produced on the transition rather than by the state, so the output depends on the combination of the current state and the current input. This distinguishes Mealy machines from Moore machines, where each state carries a single fixed output.

Key concepts

  • Mealy machine output: the output is associated with the transition, not with the state.
    For a given state and a given input symbol there is some output, so the output depends on the combination of the current state and the current input.
  • Moore machine output: the output is associated with the state itself — every state has one output.
  • Memory aid: write "Moore" as M O O R E — the two O's stand for "one output" (one output per state).

How it works

  1. Look at the current state.
  2. Look at the input symbol being read.
  3. The pair (current state, input symbol) determines the output produced on that transition.
Figure. Q0 gives output 1 on a and 0 on b. q1 gives output 0 on b and 1 on a. These pairs show the Mealy output depends on state and input.

Formulas

  • Mealy: output=f(current state,input symbol)\text{output} = f(\text{current state}, \text{input symbol}) — the output is attached to the transition.
  • Moore: output=f(current state)\text{output} = f(\text{current state}) — the output is attached to the state.

Worked examples

State Q0:

  • input a → output 1
  • input b → output 0

State q1:

  • input b → output 0
  • input a → output 1

The same state can produce different outputs depending on the input read (Q0 gives 1 on a and 0 on b), and the same input can produce different outputs in different states — the output is a function of (state, input).

Comparison

FeatureMoore MachineMealy Machine
Output associated withThe state itselfThe transition (current state + input)
Outputs per stateOne output per stateOutput depends on each (state, input) pair
Memory aidM O O R A — two O's, one outputOutput = combination of current state and input

Revision summary

  • Mealy output is attached to the transition; Moore output is attached to the state.
  • In a Mealy machine, output =f(current state,input symbol)= f(\text{current state}, \text{input symbol}).
  • In a Moore machine, output =f(current state)= f(\text{current state}).
  • Same state with different inputs can give different outputs (Q0: a → 1, b → 0).
  • Moore (M O O R A) → one output per state; Mealy → output on the state–input combination.

Previous-year exam insights

  • Formal definitions: a Mealy machine is a 6-tuple (Q, Σ, Δ, δ, λ, q0) with δ: Q×Σ→Q and λ: Q×Σ→Δ (output on transitions); a Moore machine is a 6-tuple (Q, Σ, Δ, δ, λ, q0) with λ: Q→Δ (output on states).
    Asked inGATE 2021
  • In a Mealy machine the number of states can be smaller than in an equivalent Moore machine (Mealy may need fewer states), but a Moore machine generally needs more states; both can be converted into each other, and conversion Moore→Mealy is trivial while Mealy→Moore may increase the number of states.
    Asked inGATE 2021
  • For a Mealy machine with n states, m input symbols and k output symbols, the maximum number of transitions (edges) is n·m, and each transition is labelled input/output; the output length equals the input length (no extra output for the initial state).
    Asked inGATE 2002
  • In a Moore machine the output sequence has length one more than the input sequence, because the start state emits an output before any input is read; in a Mealy machine output length equals input length.
    Asked inGATE 2002
  • A Mealy machine's output at time t depends on the present state and present input (it can respond within the same clock cycle), whereas a Moore machine's output depends only on the present state (it is delayed by one cycle relative to the input that caused the transition).
    Asked inGATE 2021GATE 2002
  • To design a Mealy machine for a pattern/sequence-detection problem, define states by the relevant history (e.g., longest matching prefix seen so far) and place the output on the transition that completes the pattern; the same state may have different outputs for different inputs.
    Asked inGATE 2021GATE 2002
Pages 1–2 of 2