DFA Simulator
Build, edit, and simulate strings in a DFA visualizer
About This Simulation
This DFA simulator lets you design a deterministic finite automaton on a canvas, then run input strings through it and watch each transition until the string is accepted or rejected.
Features
- Add states, transitions, a start state and accepting states
- Run any input string symbol by symbol
- Current state and used transition highlighted
- Accept or reject result for each string
- Pan, zoom and fullscreen editing
Explanation
A deterministic finite automaton (DFA) is a machine with a finite number of states that reads an input string one symbol at a time. For every state and symbol there is exactly one next state. The string is accepted if the machine ends in an accepting state.
How it works
- A DFA is defined by the 5-tuple (Q, Σ, δ, q₀, F): states, alphabet, transition function, start state and accepting states.
- Start in q₀ and read the first symbol of the input.
- Move to the state δ(current state, symbol). Repeat for every symbol.
- After the last symbol, accept if the current state is in F; otherwise reject.
Why it matters
DFAs recognise exactly the regular languages. They are used in lexical analysers of compilers, pattern matching, text search, network protocols and vending-machine style controllers. They are the first machine model studied in CSE331.
Frequently Asked Questions
What is the difference between a DFA and an NFA?
In a DFA each state has exactly one transition for every symbol. An NFA can have zero, one or several transitions for a symbol and ε-transitions. Both recognise the same class of languages, the regular languages.
What is the 5-tuple of a DFA?
(Q, Σ, δ, q₀, F): Q is the finite set of states, Σ the input alphabet, δ: Q × Σ → Q the transition function, q₀ the start state and F ⊆ Q the set of accepting states.
What is a dead (trap) state?
A non-accepting state that loops to itself on every symbol. Once the DFA enters it, the string can never be accepted. It is used to complete the transition function.
Can a DFA recognise the language aⁿbⁿ?
No. A DFA has finite memory and cannot count an unbounded number of a's. The pumping lemma for regular languages proves that aⁿbⁿ is not regular; it needs a pushdown automaton or a context-free grammar.
Topics covered
- Deterministic Finite Automaton (DFA)
- Regular Languages
- States and Transitions
- Transition Function
- Accepting States
Tags
- dfa
- deterministic finite automaton
- regular language
- states
- transitions
Related Simulations
Theory of Computation: Automata and Computability
State Transition Diagram
Create, edit, and test state machines interactively.
Theory of Computation: Automata and Computability
CFG (Context Free Grammar) Simulator
Interactive Context-Free Grammar parser and derivation visualizer
Theory of Computation: Automata and Computability
NFA Simulator
Build, edit, and simulate strings in an NFA visualizer
Theory of Computation: Automata and Computability
TM (Turing Machine) Simulator
Design, edit, and run computations in an interactive Turing Machine simulator

