Section StateWhile_TerminatesIn_coind.
Variable (T : F1 -> tRel sig n).
CoInductive StateWhile_T : F1 -> tRel sig n :=
| StateWhile_T_intro l t k k1 :
T l t k1 ->
(forall t' l1,
R l t (inl l1, t') ->
exists k2, StateWhile_T l1 t' k2 /\ 1 + k1 + k2 <= k) ->
(forall tmid l2,
R l t (inr l2, tmid) -> k1 <= k) ->
StateWhile_T l t k.
End StateWhile_TerminatesIn_coind.

(* It's easy to show that the start-labels are irrevant if we fix the internal state. The transition functions are definitionally equal. *)
Lemma StartState_irrelevant (y y' : F1) (k : nat) (iconf : mconfig sig (FinType(EqType StateWhile_states)) n) :
loopM (projT1 (StateWhile y')) iconf k = loopM (projT1 (StateWhile y )) iconf k.