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

14states 13 transitions · 4 final · |Σ| = 8

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 22
  2. subset construction 14
  3. minimal 11
walks× walked× talk× talked×
twaallkkeesddq0 = {q0} · Sq0q1 = {q12,q16} · Aq1q2 = {q1,q6} · Bq2q3 = {q13,q17} · Cq3q4 = {q2,q7} · Dq4q5 = {q14,q18} · Eq5q6 = {q3,q8} · Fq6q7 = {q15,q19} · G · finalq7q8 = {q4,q9} · Hq8q9 = {q20} · Iq9q10 = {q10} · Jq10q11 = {q5} · K · finalq11q12 = {q21} · L · finalq12q13 = {q11} · M · finalq13

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

Transition table
State adeklstw Nonterminal NFA states
→ q0 — — — — — — q1 q2 S {q0}
q1 q3 — — — — — — — A {q12,q16}
q2 q4 — — — — — — — B {q1,q6}
q3 — — — — q5 — — — C {q13,q17}
q4 — — — — q6 — — — D {q2,q7}
q5 — — — q7 — — — — E {q14,q18}
q6 — — — q8 — — — — F {q3,q8}
∗ q7 — — q9 — — — — — G {q15,q19}
q8 — — q10 — — q11 — — H {q4,q9}
q9 — q12 — — — — — — I {q20}
q10 — q13 — — — — — — J {q10}
∗ q11 — — — — — — — — K {q5}
∗ q12 — — — — — — — — L {q21}
∗ q13 — — — — — — — — M {q11}

→ 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
talk(ε|ed)|walk(s|ed)
Elimination steps (14)

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 → q3 ta
  2. remove q2: q0 → q4 wa
  3. remove q3: q0 → q5 tal
  4. remove q4: q0 → q6 wal
  5. remove q5: q0 → q7 talk
  6. remove q6: q0 → q8 walk
  7. remove q9: q7 → q12 ed
  8. remove q10: q8 → q13 ed
  9. remove q11: q8 → f s
  10. remove q12: q7 → f ε|ed
  11. remove q7: q0 → f talk(ε|ed)
  12. remove q13: q8 → f s|ed
  13. remove q8: q0 → f talk(ε|ed)|walk(s|ed)
  14. remove q0: s → f talk(ε|ed)|walk(s|ed)

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, C, D, E, F, G, H, I, J}, Σ = {a, d, e, k, l, s, t, w}, 14 rules.

S→ tA|wB
A→ aC
B→ aD
C→ lE
D→ lF
E→ kG|k
F→ kH
G→ eI
H→ eJ|s
I→ d
J→ d
Nonterminals and states

S = q0, A = q1, B = q2, C = q3, D = q4, E = q5, F = q6, G = q7, H = q8, I = q9, J = q10, K = q11, L = q12, M = q13