Rewrite merge_states function

Merge states now merges a single state p with a set of states P
rather than merging each pair separately.  It is now iterative
instead of recursive.  Reachable accepting states are calculated
each call which greatly simplifies all of the modifier functions
especially concat.  Fixes the issues where merge_states behaved
incorrectly when merging states belonging to the same DFA.

DFA representation now uses a set instead of a list for accepting
states.