Add a function to remove unreachable states in the automaton