You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
A Finite State Machine (FSM) is a mathematical model of computation that has a finite number of states. At any given time, the machine is in exactly one state. It transitions from one state to another in response to inputs, following a set of transition rules. FSMs are one of the most fundamental concepts in the theory of computation.
An FSM is defined as a 5-tuple (Q, Σ, δ, q₀, F):
| Symbol | Meaning |
|---|---|
| Q | A finite set of states |
| Σ (sigma) | A finite set of input symbols (the alphabet) |
| δ (delta) | A transition function: δ(state, input) → next state |
| q₀ | The start state (q₀ ∈ Q) |
| F | A set of accepting (final) states (F ⊆ Q) |
In a DFA, for each state and input symbol, there is exactly one transition. The machine always knows exactly which state to move to.
In an NFA, for a given state and input, there may be zero, one, or more possible transitions. The machine can be thought of as exploring all possible paths simultaneously.
Key theorem: Every NFA can be converted to an equivalent DFA. They recognise exactly the same set of languages (regular languages).
FSMs are commonly represented as state transition diagrams:
States: {S0, S1, S2}
Start: S0
Accepting: {S2}
Transitions:
S0 --0--> S1
S0 --1--> S0
S1 --0--> S1
S1 --1--> S2
S2 --0--> S1
S2 --1--> S0
Processing the input "1001":
| Step | Current State | Input | Next State |
|---|---|---|---|
| 1 | S0 | 1 | S0 |
| 2 | S0 | 0 | S1 |
| 3 | S1 | 0 | S1 |
| 4 | S1 | 1 | S2 |
Final state: S2 (accepting). The string "1001" is accepted.
Processing "1010":
| Step | Current State | Input | Next State |
|---|---|---|---|
| 1 | S0 | 1 | S0 |
| 2 | S0 | 0 | S1 |
| 3 | S1 | 1 | S2 |
| 4 | S2 | 0 | S1 |
Final state: S1 (not accepting). The string "1010" is rejected.
An alternative representation is a transition table:
| Current State | Input 0 | Input 1 |
|---|---|---|
| → S0 | S1 | S0 |
| S1 | S1 | S2 |
| *S2 | S1 | S0 |
→ indicates start state, * indicates accepting state.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.