A **Finite State Diagram** is a graphical representation of a **[[Finite State Machine]] (FSM)**, a computational model used to illustrate how a system progresses through different states based on specific inputs or events. In a finite state diagram, the states, transitions, and actions are visually mapped out, making it easier to understand how a system behaves over time. # A Typical Finite State Diagram The following diagram is drawn in [[Mermaid]]. ```mermaid stateDiagram-v2 [*] --> Locked Locked --> Unlocked: Insert Coin Unlocked --> Locked: Push Gate Locked : In Locked state, the turnstile requires a coin to unlock. Unlocked : In Unlocked state, the turnstile can be pushed to lock again. ``` ### Key Components of a Finite State Diagram: 1. **States**: - Each **circle** or **node** in the diagram represents a distinct state that the system can be in. - One of the states is often labeled as the **start state** (commonly indicated with an arrow pointing to it without originating from another state). 2. **Transitions**: - **Arrows** between states indicate **transitions**, showing how the system moves from one state to another based on an input or condition. - Each transition is typically labeled with the **input** or **event** that triggers it, such as a specific command, character, or condition. 3. **Final or Accepting States**: - Some states are designated as **final or accepting states**, often marked with a double circle, representing the end of a successful sequence or operation. ### Uses and Applications of Finite State Diagrams: - **Programming and Software Design**: FSMs help design the flow of logic in software, especially in areas requiring predictable sequences, like user interfaces or protocol design. - **Digital Circuit Design**: FSMs model the behavior of circuits and are fundamental in designing control systems. - **Natural Language Processing (NLP)**: They assist in defining grammars and parsers, helping process text in applications like spell checkers and translators. - **Robotics and AI**: FSMs guide the behavior of autonomous systems, allowing robots to respond to changing environments in a controlled sequence of actions. ### Example Consider a simple turnstile system that has two states: **Locked** and **Unlocked**. In a finite state diagram: - The **Locked** state transitions to **Unlocked** when a coin is inserted. - The **Unlocked** state transitions back to **Locked** once the turnstile is pushed. Finite state diagrams provide a clear, visual way to see all potential behaviors of a system, making them essential in fields that require structured behavior and predictable outcomes. # References ```dataview Table title as Title, authors as Authors where contains(subject, "Finite State Diagram") sort title, authors, modified ```