Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallA finite state machine (FSM) is a model that tracks one of a limited number of states and uses each incoming symbol or event to decide what state comes next. For a string recognizer, the machine accepts or rejects the input based on the state it reaches when the string ends.
What a finite state machine is
An FSM represents behavior using a finite set of conditions and explicit rules for moving among them. It begins in a designated start state. Whenever it receives an input, its transition function uses the current state and that input to select the next state. NIST’s Dictionary of Algorithms and Data Structures describes the process as beginning in the start state with an input string and changing states according to the transition function.
As an Amazon Associate I earn from qualifying purchases.
The phrase “finite state machine” is an umbrella term: some FSMs recognize strings, while others produce outputs or control a process. The exact formal definition depends on which kind is being described.
The parts of an FSM
- States (Q): The finite set of situations the machine can represent.
- Start state (q₀): The state in which processing begins.
- Input alphabet (Σ or X): The symbols or events the machine can receive. In formal language theory these are symbols; in a controller they may represent external events.
- Transition function (δ): The rule that determines the next state from the current state and an input.
- Accepting states (F or A): For a recognizer, the states that indicate acceptance if the input ends there.
- Output rule: For an output-producing machine, the mapping that determines what output to produce.
A deterministic acceptor is commonly defined by a five-tuple: states, input alphabet, transition function, start state, and accepting-state set. An output-producing FSM adds output symbols and an output function. Notation varies across texts, but the underlying roles are the same.
#1 Best Overall
How an FSM processes input
- Begin in the start state.
- Read the next input symbol or event.
- Use the transition function with the current state and input to select a next state.
- Repeat until the input is consumed.
- For a recognizer, accept if the final state is accepting; otherwise reject.
A deterministic FSM has exactly one next-state choice for each applicable state-and-input pair. A nondeterministic FSM can have multiple possible next states; its transition function returns a set of states. For finite automata used as language recognizers, deterministic and nondeterministic machines recognize the same class of languages.
Example: a drink or vending controller
Imagine a controller that tracks money deposited toward a drink’s price. Each state can represent the amount collected so far, and each coin is an input that moves the machine to another state. Once enough has been deposited, the machine can enter a state that triggers dispensing. A return input can move it back to its start state. This example shows how states summarize relevant history: the controller need not remember every action, only the current amount category needed to determine what happens next.
State diagrams and tables
A state transition graph shows states as nodes and transitions as directed edges. Each edge is labeled with the input that triggers that move. For an output-producing FSM, outputs are shown according to the machine’s convention. The same behavior can also be represented in a state table or implemented as a data structure. The University of Texas at Austin’s finite state machine chapter discusses these representations and their use in engineering.
Moore and Mealy machines: where outputs come from
| Machine type | Output depends on | Diagram convention |
|---|---|---|
| Moore | The current state | Output is associated with a state |
| Mealy | The current state and current input | Output is associated with a transition |
Both are finite-state models with outputs. Either form can describe a system’s behavior, though one may be more natural for a particular design. The distinction is about how output behavior is represented, not about whether the machine has a finite set of states.
Quick Recap
Which FSM definition applies?
- Recognizing strings: Look for an accepting-state set and a rule for deciding whether the completed input is accepted.
- Modeling control behavior: Identify the external events, state transitions, and outputs that drive the process.
- Checking determinism: Determine whether each state/input pair has one next state or a set of possible next states.
- Reading output diagrams: Check whether outputs are attached to states (Moore) or transitions (Mealy).
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




