Mealy Machine

2 min read Last updated Sat Jun 27 2026 08:46:52 GMT+0000 (Coordinated Universal Time)

A finite state transducer where output depends on the current state and the input symbol. Output is produced on transitions, not on states. A 6-tuple.

M=(Q,Σ,Δ,q0,δ,λ)M = (Q, \Sigma, \Delta, q_0, \delta, \lambda) where:

  • QQ is a finite set of states
  • Σ\Sigma is the input alphabet
  • Δ\Delta is the output alphabet
  • q0Qq_0 \in Q is the initial state
  • δ:Q×ΣQ\delta : Q \times \Sigma \rightarrow Q is the transition function
  • λ:Q×ΣΔ\lambda : Q \times \Sigma \rightarrow \Delta is the output function

Example

A Mealy machine that outputs 11 when the number of aas seen so far is even, and 00 otherwise:

  • States: {q0,q1}\{q_0, q_1\}, where q0q_0 = even count, q1q_1 = odd count
  • On input aa in q0q_0: move to q1q_1, output 00
  • On input aa in q1q_1: move to q0q_0, output 11

Input aaa produces output 010.

Mealy vs Moore Machine

Both are finite state transducers. The difference is where output is generated.

PropertyMealyMoore
Output depends onState + inputState only
Output produced onTransitionEntry to state
States neededFewerMore
Output latencyImmediate on inputAfter state change

Every Moore machine has an equivalent Mealy machine and vice versa. The Mealy-to-Moore conversion typically increases state count.

Was this helpful?