Minimal deterministic finite state machine