FSA from words to automata

finite-state automata · regular expressions · type-3 grammars

Separate words with spaces, commas or new lines. Each character is one symbol; type ε for the empty word.

Automaton

8states 7 transitions · 4 final · |Σ| = 2

Non-deterministic: one path per word, all leaving q0. One state has more than one transition on the same symbol (in red).

  1. NFA 8
  2. subset construction 5
  3. minimal 4
a× ab× abb× b×
aababbbq0 · Sq0q1 · D · finalq1q2 · Aq2q3 · E · finalq3q4 · Bq4q5 · Cq5q6 · F · finalq6q7 · G · finalq7

Hover or tap a word to trace its path. Double circles are final states. Red symbols leave a state on more than one transition.

Transition table
State ab Nonterminal
→ q0 {q1, q2, q4} q7 S
∗ q1 — — D
q2 — q3 A
∗ q3 — — E
q4 — q5 B
q5 — q6 C
∗ q6 — — F
∗ q7 — — G

→ initial, ∗ final. Empty cells (—) lead to rejection.

Regular expression

Equivalent to the NFA shown, by state elimination. Each automaton gives a different but equivalent expression: compare NFA, DFA and minimal DFA.

Notation
a|ab|abb|b
Elimination steps (8)

A new initial state s and final state f are linked by ε to the automaton; then each state is removed, and every path through it becomes one edge labelled with the concatenation. States with one way in and one way out go first.

  1. remove q1: q0 → f a
  2. remove q2: q0 → q3 ab
  3. remove q3: q0 → f a|ab
  4. remove q4: q0 → q5 ab
  5. remove q5: q0 → q6 abb
  6. remove q6: q0 → f a|ab|abb
  7. remove q7: q0 → f a|ab|abb|b
  8. remove q0: s → f a|ab|abb|b

Regular grammar

Right-linear rewriting rules read off the NFA: one nonterminal per state, S for q0.

Form

Chomsky type-3 form: p —a→ q gives P → a Q when q has a way out, and P → a when q is final; S → ε only if ε is a word.

G = ⟨N, Σ, P, S⟩ with N = {S, A, B, C}, Σ = {a, b}, 7 rules.

S→ a|aA|aB|b
A→ b
B→ bC
C→ b
Nonterminals and states

S = q0, A = q2, B = q4, C = q5, D = q1, E = q3, F = q6, G = q7