intros.
destruct xs1;try (discriminate H).
exists (nil (A:=A)).
split.
apply nil_is_permutation.
reflexivity.
intros.
destruct xs1;try (discriminate H1).
simpl in H1.
injection H1;clear H1;intros.
subst x.
elim (IHis_permutation _ _ _ H1).
intro xs2.
intros.
elim H2;clear H2;intros.
subst l'.
elim (insertion_map _ _ _ _ H0 _ f a (refl_equal (f a)) xs2 (refl_equal (map f xs2))).
intros.
elim H3;clear H3;intros.
exists x.
split;auto.
eapply cons_is_permutation;eauto.
Qed.

(** if l' is a permutation of l and the elements of l are pairwise distinct, then so are those of l' *)
Lemma is_permutation_set : forall (A:Set)(l l':list A),(is_permutation _ l l')->(is_set _ l)->(is_set _ l').
induction 1.