Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

What Is a Finite State Machine? Definition, Parts, and Examples

A finite state machine tracks a limited set of states and changes state in response to inputs. Learn its components, how it processes input, and how common variants differ.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

How an FSM processes input

  1. Begin in the start state.
  2. Read the next input symbol or event.
  3. Use the transition function with the current state and input to select a next state.
  4. Repeat until the input is consumed.
  5. 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.