Does My Automaton Do What I Meant?
Build a deterministic finite automaton (DFA) with a drawing or with a table, and check it against a language or against another automaton: the tool returns a shortest word on which the answers differ, and the states the automaton visits while reading it.
Last updated:
Checking an automaton against a language
A hand-designed automaton looks right until one word shows otherwise.
This tool checks an automaton that you build against a language, or against another automaton of yours, and decides exactly whether they accept the same words, without trying words one by one.
When they do not, it returns a shortest counterexample: a word on which the answers differ, with no shorter word on which they differ, and the states that your automaton visits while reading it.
How to use the workbench
- Double-click an empty place to add a state, and drag a state to move it. Double-click a state to make it accepting, or not accepting.
- Hold Shift and drag from an empty place to a state to mark it as the start state (drag the tail of its arrow to move or resize it). Hold Shift and drag from a state to another state (or back to the same state) to draw an arrow, then type its letters, separated by commas, and press Enter. Drag an arrow to bend it, and press Delete or Backspace to remove the selected state or arrow.
- Everything the drawing can do can also be done in the list of states and the transition table, with a keyboard or on a touch screen.
- Choose what to check against, and press “Check”. A deterministic finite automaton (DFA) must have exactly one arrow from every state on every letter; the workbench lists what is missing.
The workbench needs JavaScript. Use the questions below on paper instead.
Questions
Question 1. In machine A, build a DFA over for the words that end with .
Choose “Words that end with ab” in “Check against” and press “Check”.
If the workbench shows a word, find the arrow that gives the wrong answer on it and fix it.
Hint
Remember how many letters of the end of the word matches so far.
What happens after , after , and after a letter that breaks the match?
Answer
Three states: (the word does not end with or , start), (ends with ) and (ends with , accepting).
From : , . From : , . From :
, . The workbench then reports that the machine accepts exactly the words of the language.
Question 2. In machine A, build a DFA over for the words that contain , and in machine B a DFA for the words that end with .
Before pressing “Check”, predict the shortest word on which they differ.
Then check machine A against the other machine.
Hint
Look for a word that contains without ending with it.
Compare all words of length at most in the alphabetical order of their letters.
Answer
The word is : it contains but ends with , so machine A accepts it and machine B rejects it.
Every shorter word gets the same verdict from both machines:
are rejected by both and is accepted by both. Among the words of length that differ, comes before in alphabetical order.
Back to Designing a Deterministic Finite Automaton, or see the glossary.