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

18states 17 transitions · 5 final · |Σ| = 10

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 30
  2. subset construction 18
  3. minimal 12
cantava× canti× parlo× parlava× parli×
cpaanrtlaiaiovvaaq0 = {q0} · Sq0q1 = {q1,q8} · Aq1q2 = {q13,q18,q25} · Bq2q3 = {q2,q9} · Cq3q4 = {q14,q19,q26} · Dq4q5 = {q3,q10} · Eq5q6 = {q15,q20,q27} · Fq6q7 = {q4,q11} · Gq7q8 = {q16,q21,q28} · Hq8q9 = {q5} · Iq9q10 = {q12} · M · finalq10q11 = {q22} · Jq11q12 = {q29} · N · finalq12q13 = {q17} · O · finalq13q14 = {q6} · Kq14q15 = {q23} · Lq15q16 = {q7} · P · finalq16q17 = {q24} · Q · finalq17

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

Transition table
State acilnoprtv Nonterminal NFA states
→ q0 — q1 — — — — q2 — — — S {q0}
q1 q3 — — — — — — — — — A {q1,q8}
q2 q4 — — — — — — — — — B {q13,q18,q25}
q3 — — — — q5 — — — — — C {q2,q9}
q4 — — — — — — — q6 — — D {q14,q19,q26}
q5 — — — — — — — — q7 — E {q3,q10}
q6 — — — q8 — — — — — — F {q15,q20,q27}
q7 q9 — q10 — — — — — — — G {q4,q11}
q8 q11 — q12 — — q13 — — — — H {q16,q21,q28}
q9 — — — — — — — — — q14 I {q5}
∗ q10 — — — — — — — — — — M {q12}
q11 — — — — — — — — — q15 J {q22}
∗ q12 — — — — — — — — — — N {q29}
∗ q13 — — — — — — — — — — O {q17}
q14 q16 — — — — — — — — — K {q6}
q15 q17 — — — — — — — — — L {q23}
∗ q16 — — — — — — — — — — P {q7}
∗ q17 — — — — — — — — — — Q {q24}

→ 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
cant(i|ava)|parl(i|o|ava)
Elimination steps (18)

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 ca
  2. remove q2: q0 → q4 pa
  3. remove q3: q0 → q5 can
  4. remove q4: q0 → q6 par
  5. remove q5: q0 → q7 cant
  6. remove q6: q0 → q8 parl
  7. remove q9: q7 → q14 av
  8. remove q10: q7 → f i
  9. remove q11: q8 → q15 av
  10. remove q12: q8 → f i
  11. remove q13: q8 → f i|o
  12. remove q14: q7 → q16 ava
  13. remove q15: q8 → q17 ava
  14. remove q16: q7 → f i|ava
  15. remove q7: q0 → f cant(i|ava)
  16. remove q17: q8 → f i|o|ava
  17. remove q8: q0 → f cant(i|ava)|parl(i|o|ava)
  18. remove q0: s → f cant(i|ava)|parl(i|o|ava)

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, K, L}, Σ = {a, c, i, l, n, o, p, r, t, v}, 17 rules.

S→ cA|pB
A→ aC
B→ aD
C→ nE
D→ rF
E→ tG
F→ lH
G→ aI|i
H→ aJ|i|o
I→ vK
J→ vL
K→ a
L→ a
Nonterminals and states

S = q0, A = q1, B = q2, C = q3, D = q4, E = q5, F = q6, G = q7, H = q8, I = q9, J = q11, K = q14, L = q15, M = q10, N = q12, O = q13, P = q16, Q = q17