Definition TMrules : list (list rsig * list rsig) :=
     List.concat ((List.map (fun q1 => match trans (q1,None) with
                      |(q2,(o,m)) => get_rules q1 q2 None o m
                                   end) not_halting_states) ++
                 (List.map (fun (P: states T * sig) => let (q1,s) := P in match trans (q1,Some s) with
                                                    |(q2,(o,m)) => get_rules q1 q2 (Some s) o m
                                                    end)
                           (list_prod not_halting_states (elem sig)))).

Lemma state_eqlist A B C D q1 q2: A ++(state q1)::B = C++(state q2)::D -> (exists (E F: list rsig'), C = List.map symb E /\ D = List.map symb F) -> A = C /\ B = D /\ q1 = q2.