Thompson Construction

1 min read Updated Fri Apr 24 2026 03:19:45 GMT+0000 (Coordinated Universal Time)

An algorithm for converting a regular expression into an NFA-Λ\Lambda. Aka. McNaughton-Yamada-Thompson algorithm.

Steps

  • Break the regular expression into subexpressions
  • Construct basic automata
  • Combine them using inductive rules

Basis Automata

For {a},{Λ}\set{a}, \set{ \Lambda }, connect from the starting state to the accepting state for the input.

Thompson's Construction Basic

For \emptyset, no diagrams.

Rules

Suppose N(s)N(s) and N(t)N(t) are NFA-Λ\Lambda for ss and tt respectively.

Union

For strings either ss or tt.

Thompson's Construction Union

Concatenation

For strings stst.

Thompson's Construction Concatenation

Kleene Star

For strings ss*.

Thompson's Construction Closure

Properties of Thompson Automata

  • Exactly one start state
  • Exactly one accept state
  • No incoming edges to start state
  • No outgoing edges from accept state
  • Number of states ≤ 2 × (operators + operands)