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

4states 3 transitions · 3 final · |Σ| = 2

Deterministic, by subset construction on the NFA: the prefix tree (trie) of the words. Hover a state to see the NFA states it stands for. Partial: a missing transition means rejection (an implicit dead state).

  1. NFA 7
  2. subset construction 4
  3. minimal 4
a× ab× abb×
abbq0 = {q0} · Sq0q1 = {q1,q2,q4} · A · finalq1q2 = {q3,q5} · B · finalq2q3 = {q6} · C · finalq3

Hover or tap a word to trace its path. Double circles are final states.

Transition table
State ab Nonterminal NFA states
→ q0 q1 — S {q0}
∗ q1 — q2 A {q1,q2,q4}
∗ q2 — q3 B {q3,q5}
∗ q3 — — C {q6}

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

Regular expression

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

Notation
a(ε|b(ε|b))
Elimination steps (4)

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 q0: s → q1 a
  2. remove q3: q2 → f ε|b
  3. remove q2: q1 → f ε|b(ε|b)
  4. remove q1: s → f a(ε|b(ε|b))

Regular grammar

Right-linear rewriting rules read off the DFA: 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}, Σ = {a, b}, 5 rules.

S→ aA|a
A→ bB|b
B→ b
Nonterminals and states

S = q0, A = q1, B = q2, C = q3