(* Copyright 2012-2015 by Adam Petcher.				* * Use of this source code is governed by the license described	* * in the LICENSE file at the root of the source tree.		*)
Set Implicit Arguments.
Local Open Scope list_scope.
Fixpoint hasDups (A : Set)(eqd : EqDec A)(ls : list A) :=
match ls with
| nil => false
| a :: ls' =>
if (in_dec (EqDec_dec _) a ls') then true else
(hasDups _ ls')
end.
induction ls; intuition; simpl in *.
econstructor.
destruct (in_dec (EqDec_dec eqd) a ls).
discriminate.
econstructor; intuition.
inversion H1; clear H1; subst.
destruct (in_dec (EqDec_dec eqd) a ls);
intuition.
Qed.
induction ls; intuition; simpl in *.
exfalso.
eapply H.
econstructor.
inversion H2; clear H2; subst.
destruct (in_dec (EqDec_dec eqd) a ls); intuition.
destruct (in_dec (EqDec_dec eqd) a ls); intuition.
eapply H0.
intuition.
eapply H1.
econstructor; intuition.
Qed.

Theorem hasDups_inj_equiv :
forall (A B : Set)(eqda : EqDec A)(eqdb : EqDec B)(lsa : list A)(inj : A -> B),
(forall a1 a2, inj a1 = inj a2 -> a1 = a2) ->
hasDups _ lsa = hasDups _ (map inj lsa).