(** An injective and surjective function is bijective. We need here stronger hypothesis : decidability of equality in Type. *)
Definition EqDec (A:Type) := forall x y:A, {x=y}+{x<>y}.
(** First, we show that a surjective f has an inverse function g such that f.g = id. *)
(* NB: instead of (Finite A), we could ask for (RecEnum A) with: Definition RecEnum A := exists h:nat->A, surjective h. *)

Lemma Surjective_inverse :
forall A B, Finite A -> EqDec B ->
forall f:A->B, Surjective f ->
exists g:B->A, forall x, f (g x) = x.