Track progress, take quizzes and save notes on this lesson.

Free forever · no card needed

Start free
Advanced

Finite State Machines

4.4.2.1 Finite state machines (FSMs) with and without output

Aligned to the AQA 7517 specification

Level
Advanced
Reading time
9 min
Published
6 June 2026
Updated
1 July 2026
On this page
  1. 1.What Is a Finite State Machine?
  2. 2.State Transition Diagrams
  3. 3.State Transition Tables
  4. 4.Tracing an FSM
  5. 5.Mealy Machines: FSMs With Output
  6. 6.Tracing a Mealy Machine
  7. 7.Common Exam Mistakes

Key takeaways

  • A finite state machine is defined by five components: a finite set of states, an input alphabet, a transition function, a start state, and (for FSMs without output) a set of accepting states.
  • An FSM without output accepts a string only if the machine is left in an accepting state after all input symbols have been consumed; stopping the trace early is incorrect.
  • In a state transition diagram the start state is shown by an incoming arrow from outside and an accepting state by a double circle; omitting these standard markers loses marks.
  • A Mealy machine is an FSM with output where each transition is labelled input/output and produces one output symbol per input symbol; it has no accepting states.
  • AQA requires only FSMs without output and Mealy machines; Moore machines (output depends on current state only) are not in the specification.

What Is a Finite State Machine?

A finite state machine (FSM) is an abstract model of computation that processes an input sequence one symbol at a time and changes state based on each symbol received. At any moment, the machine is in exactly one of a finite number of states.

An FSM is defined by five components:

ComponentDescription
A finite set of statesThe possible configurations of the machine
An input alphabetThe set of symbols the machine can receive
A transition functionRules that define the next state for each (current state, input) pair
A start stateThe state the machine begins in
A set of accepting states (for FSMs without output)States that indicate a valid/accepted input string

FSMs are used throughout computing: in lexical analysers (recognising valid tokens in source code), network protocol design, input validation, and digital circuit design. The key insight is that many useful computational tasks can be performed without any memory beyond "which state am I currently in."

AQA requires two types: FSMs without output (which accept or reject strings) and Mealy machines (FSMs with output, where each transition produces an output symbol).

State Transition Diagrams

A state transition diagram is the standard graphical representation of an FSM. Each component of the machine maps to a specific visual element:

ComponentDiagram notation
StateCircle labelled with the state name
Start stateCircle with an arrow pointing to it from outside (no source state)
Accepting state (FSMs without output)Double circle
TransitionArrow from one state to another, labelled with the input symbol
Self-loopArrow from a state back to itself

Example — FSM over {0, 1} accepting strings that contain an even number of 1s:

States: (start, accepting),

Transitions:

  • on input 0 → (self-loop: receiving a 0 does not change parity)
  • on input 1 → (one 1 seen so far — odd count)
  • on input 0 → (self-loop: 0 does not change parity)
  • on input 1 → (second 1 seen — back to even count)

is a double circle (accepting). The machine ends in — and therefore accepts — if and only if the number of 1s in the input string is even (including zero 1s).

When drawing a diagram: label each arrow with the input symbol that causes that transition. If two different inputs from the same state lead to the same destination, either draw two separate arrows or label one arrow with both symbols separated by a comma.

State Transition Tables

A state transition table is the tabular equivalent of a state transition diagram. It lists every (current state, input) combination and the resulting next state.

For the even-number-of-1s FSM above:

Current stateInput: 0Input: 1
(start, accept)

State transition tables and diagrams contain identical information. A table is unambiguous and easy to construct; a diagram makes the overall structure and flow more immediately visible. Exam questions may give either and ask you to produce the other.

Reading a table: each row is a state; each column is an input symbol. The cell at (row, column) gives the next state. To trace a string, start at the start state and look up each input symbol in sequence.

Constructing a table from a description: list all states as rows, all input symbols as columns, then fill in each cell by applying the transition rules.

The transition function must be total for a complete FSM — every (state, input) pair must have a defined next state. If some inputs from a state lead nowhere valid, a dead state (also called a reject/trap state) is added, with all transitions from it looping back to itself.

Tracing an FSM

A trace determines whether a given input string is accepted or rejected by an FSM without output. A string is accepted if processing all its symbols leaves the machine in an accepting state.

Worked trace — does the string "10110" contain an even number of 1s?

Using the even-1s FSM ( = accepting, start):

StepCurrent stateInput symbolNext state
Start
11
20
31
41
50

Final state: — not an accepting state. Rejected.

Check: "10110" contains three 1s (an odd number). Correct — the FSM correctly rejects it. ✓

Does "1010" get accepted?

Start: → input 1 → → input 0 → → input 1 → → input 0 →

Final state: — accepting. Accepted. "1010" contains two 1s (even). ✓

Worth saving these ideas?

Turn what you've read into instant revision cards. Free to get started.

Make flashcards

Mealy Machines: FSMs With Output

A Mealy machine is an FSM that produces an output symbol on each transition. The output depends on both the current state and the current input. Unlike FSMs without output, Mealy machines do not have accepting states — they produce a string of output symbols as they process the input.

Transition notation for Mealy machines: each arrow is labelled input/output — the input that triggers the transition followed by the output produced.

Example — a binary parity machine:

This Mealy machine reads a sequence of bits and outputs after each bit whether the total number of 1s seen so far is even (E) or odd (O).

States: (start),

Current stateInput: 0Input: 1
/ E / O
/ O / E

Each cell shows: next state / output symbol. As a diagram, each arrow is labelled input / output:

The output is produced at the moment of each transition — one output symbol per input symbol.

Tracing a Mealy Machine

Worked trace — input string "1 0 1 0" through the parity Mealy machine:

StepCurrent stateInputNext stateOutput
11O
20O
31E
40E

Output sequence: O, O, E, E

Interpretation: after the 1st bit (one 1 seen) — odd. After the 2nd bit (still one 1) — odd. After the 3rd bit (two 1s seen) — even. After the 4th bit (still two 1s) — even. ✓

Converting a Mealy machine state transition diagram to a table:

To construct the table from a diagram: list all states as rows, all input symbols as columns, and for each cell write the next state and output symbol, separated by a forward slash. The same information is in both representations.

AQA only requires Mealy machines for FSMs with output. Moore machines (where output depends on the current state only, not the input) are not in the specification and should not appear in exam answers.

Common Exam Mistakes

1. Forgetting the start state marker

In a state transition diagram, the start state must be indicated by an incoming arrow from outside — not just by labelling it "start" in text. If the start state is not clearly marked, the diagram is incomplete.

2. Omitting the double circle for accepting states

Accepting states in FSMs without output require a double circle. A single circle, even if the state is labelled "accept", does not use the standard notation and will lose marks.

3. Labelling Mealy transitions as "input" only

Mealy machine transitions must show both input and output in the format input/output on each arrow. Writing only the input symbol produces a diagram that looks like an FSM without output — different semantics, and an incorrect answer.

4. Including Moore machine logic

Moore machines produce output based on the current state (not the transition). The AQA spec only requires Mealy machines. If a question asks for an FSM with output, use Mealy (output on transitions), not Moore (output on states).

5. Stopping the trace before consuming all input

A string is accepted or rejected based on the state after all input symbols have been consumed. Stopping mid-trace at the first accepting state encountered is incorrect — the machine must process the entire string before the accept/reject decision is made.

Key terms

Finite state machine (FSM)
An abstract model of computation that processes an input sequence one symbol at a time, always being in exactly one of a finite number of states.
Transition function
The rules that define the next state for each (current state, input) pair; it must be total for a complete FSM.
Accepting state
A state in an FSM without output that indicates a valid/accepted input string, drawn as a double circle.
Start state
The state the machine begins in, shown in a diagram by an arrow pointing to it from outside with no source state.
State transition diagram
The graphical representation of an FSM using labelled circles for states and labelled arrows for transitions.
State transition table
The tabular equivalent of a transition diagram, listing every (current state, input) combination and the resulting next state.
Mealy machine
An FSM that produces an output symbol on each transition, where the output depends on both the current state and the current input.
Dead state
A reject/trap state added to make the transition function total, with all its transitions looping back to itself.
Self-loop
A transition arrow that goes from a state back to itself.

Frequently asked questions

An FSM without output accepts or rejects strings using accepting states, while a Mealy machine produces an output symbol on each transition and has no accepting states. Mealy transitions are labelled input/output; FSM-without-output transitions are labelled with just the input symbol.

A string is accepted only if, after every input symbol has been consumed, the machine is in an accepting state. You must process the whole string before deciding; stopping at the first accepting state reached mid-trace is wrong.

No. AQA only requires Mealy machines (output produced on each transition) for FSMs with output. Moore machines, where output depends on the current state only, are not in the specification and should not appear in exam answers.

Generate revision on any topic you study

Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.

Lessons on anything

Structured, level-matched lessons on any topic you study

Practice quizzes

Find out what you actually know before the exam does

Flashcard sets

Lock in key concepts with instant revision cards

Ask Aica

Stuck on something? Get a clear explanation, any time

Prev

Abstraction and Automation

Next

Sets and Formal Languages

Related lessons

5 min

8 min

Lesson

Regular Expressions

A-Level Computer Science · AQA 7517

1 month ago

6 min

Lesson

Turing Machines

A-Level Computer Science · AQA 7517

1 month ago

Top students don’t revise more. They revise what counts.

Start revising free

Free to start. No card needed.