Program Definition CoNat_coalg : @CoAlgebra Type_Cat S_nat_func :=
{|
Alg_Carrier := CoNat;
Constructors :=
fun x : CoNat =>
match x return unit + CoNat  with
| CoO => inl tt
| CoS x' => inr x'
end
|}.
(* morphism from another alg to CoNat_coalg *)
Program Definition CoNat_coalg_morph coalg' : CoAlgebra_Hom CoNat_coalg coalg'
:=
{|
Alg_map :=
cofix f (x : Alg_Carrier coalg') : CoNat :=
match Constructors coalg' x return CoNat with
| inl _ => CoO
| inr s => CoS (f s)
end
|}.
Next Obligation. (* coalg_map_com *)
(* CoNat_coalg_morph defined *)
(* The following two lemmas help go around Bug 5215. *)

Lemma inl_inr A B (x : A) (y : B) : inl x = inr y → False.