End Monic_Iso_Monic_Factorization.
(** In the following we show a similar result for any funtion. That is, we show that any function can be split into a split epic function followed by a monic function. Here the split epic function is not an isomorphism.  The monic is from the domain of the function to its image. The epic function is from the image of the function to its codomain. *)
Local Axiom ConstructiveIndefiniteDescription_Type :
forall T : Type, ConstructiveIndefiniteDescription_on T.
(** In this section we show that any morphism in Type_Cat (function in Coq) can be split in to two morphisms where one is monic and the other split epic. *)
Section split_Epic_Monic_Factorization.
Context {A B : Type} (f : A → B).
Definition Image_of : Type := {x : B | ∃ a, f a = x}.
Definition From_Image_forward : Image_of → B := fun x => proj1_sig x.
Program Definition Epic_Monic_Factor_Monic : @Monic Type_Cat Image_of B :=
{|
mono_morphism := From_Image_forward;
mono_morphism_monomorphic := fun T g h => _
|}
.
Next Obligation.
Definition To_Image : A → Image_of :=
fun a => exist _ (f a) (ex_intro _ a eq_refl).
Definition From_Image_back : Image_of → A :=
fun x => proj1_sig (ConstructiveIndefiniteDescription_Type _ _ (proj2_sig x)).

(* Specifications: *)
Theorem From_Image_back_form_split_epic :
∀ (x : Image_of), To_Image (From_Image_back x) = x.