(** An alternate, equivalent definition of [forever] that is useful for coinductive reasoning. *)
Variable A: Type.
Variable order: A -> A -> Prop.
CoInductive forever_N (ge: genv) : A -> state -> traceinf -> Prop :=
| forever_N_star: forall s1 t s2 a1 a2 T1 T2,
star ge s1 t s2 ->
order a2 a1 ->
forever_N ge a2 s2 T2 ->
T1 = t *** T2 ->
forever_N ge a1 s1 T1
| forever_N_plus: forall s1 t s2 a1 a2 T1 T2,
plus ge s1 t s2 ->
forever_N ge a2 s2 T2 ->
T1 = t *** T2 ->
forever_N ge a1 s1 T1.
Hypothesis order_wf: well_founded order.

(* Specifications: *)
Lemma forever_N_inv:
forall ge a s T,
forever_N ge a s T ->
exists t, exists s', exists a', exists T',
step ge s t s' /\ forever_N ge a' s' T' /\ T = t *** T'.
Lemma forever_N_forever:
forall ge a s T, forever_N ge a s T -> forever ge s T.