(* 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.
induction lsa; intuition; simpl in *.
destruct (in_dec (EqDec_dec eqda) a lsa);
destruct (in_dec (EqDec_dec eqdb) (inj a) (map inj lsa));
intuition.
exfalso.
apply n.
apply in_map_iff.
econstructor.
intuition.
apply in_map_iff in i.
destruct i.
intuition.
apply H in H1.
subst.
intuition.
Qed.

Theorem Permutation_hasDups :
forall (A : Set)(eqd : EqDec A)(ls1 ls2 : list A),
Permutation ls1 ls2 ->
hasDups eqd ls1 = hasDups eqd ls2.