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

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