(** In this section we show that any monic morphism in Type_Cat ( injective function in Coq) can be split in to two morphisms where one is an iso morphism and the other monic.  The isomorphism is from the domain of the function to its image. The epic function is from the image of the function to its codomain. *)
Section Monic_Iso_Monic_Factorization.
Context
{A B : Type}
{f : A → B}
(fm : @is_Monic Type_Cat _ _ f)
.
Definition Monic_Image_of : Type := {x : B & {a : A | f a = x}}.
Definition Monic_From_Image_forward : Monic_Image_of → B := fun x => projT1 x.
Program Definition Monic_Iso_Monic_Factor_Monic :
@Monic Type_Cat Monic_Image_of B :=
{|
mono_morphism := Monic_From_Image_forward;
mono_morphism_monomorphic := fun T g h => _
|}
.
Next Obligation.
Definition Monic_To_Image : A → Monic_Image_of :=
fun a => existT _ (f a) (exist _ a eq_refl).
Definition Monic_From_Image_back : Monic_Image_of → A :=
fun x => proj1_sig (projT2 x).

Theorem Monic_From_Image_back_is_Monic :
@is_Monic Type_Cat _ _ Monic_To_Image.