How to use the DFA Simulator
- 1. Define the DFAWrite transitions like q0 1 -> q1, plus the start and accept states.
- 2. Check the diagramIt redraws as you type. Missing moves are flagged.
- 3. Run a stringStep through to see each move and whether it ends in an accept state.
What a DFA is
A deterministic finite automaton is a machine with a finite set of states, an input alphabet, a start state, a set of accept states, and exactly one move for every state and symbol. It reads a string one symbol at a time, follows the matching move each time, and accepts the string if it ends in an accept state.
DFAs recognise exactly the regular languages, the same ones that regular expressions describe. They're used in lexers, input validation and protocol design, and they're a core topic in theory of computation (TOC) and compiler design courses.
The simulator checks your machine as you type: two different moves from the same state on one symbol isn't a DFA, so you'll see an error, and any missing move is listed as a warning (the string is rejected if it gets stuck there). Accept states are drawn as double circles and the current state is shown in orange.
Worked example
The first example accepts binary numbers divisible by 3. Its states q0, q1 and q2 stand for the remainder so far: reading bit b moves from remainder r to (2r + b) mod 3. The start and only accept state is q0.
Run 110 (six in decimal): q0 reads 1 → q1, reads 1 → q0, reads 0 → q0. It ends in q0, so the string is accepted; 6 is divisible by 3. Try 111 (seven): q0 → q1 → q0 → q1, which is rejected.
The other examples are strings ending in 01, strings with an even number of 0s, and strings containing "ab". Use them as templates for homework questions, and step through with Prev and Next to watch the highlighted state move around the diagram.
Frequently asked questions
Does it support NFAs or ε-moves?
No, this simulator is for DFAs only, with exactly one move per state and symbol.
Can symbols be longer than one character?
Yes. If any symbol is longer than one character, separate the input string's symbols with spaces.
How do I write the empty string?
Leave the input blank. It is accepted only if the start state is an accept state.
Is the dfa simulator free to use?
Yes, the dfa simulator is free and costs nothing. Running your first string shows a short form for your name and WhatsApp number one time; once that's done, this tool and every other Uncodemy tool open with no form.