(* 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.		*)
(* Additional facts about fold and special kinds of fold (e.g. iterated sums) *)
Set Implicit Arguments.
Local Open Scope rat_scope.
(* The traditional functional zip and unzip. *)
(* TODO: get rid of these and replace with combine and split *)
Definition unzip(A B : Set)(ls : list (A * B)) :=
(map (@fst _ _) ls, map (@snd _ _) ls).
Fixpoint zip(A B : Set)(lsa : list A)(lsb : list B) :=
match lsa with
| nil => nil
| a :: lsa' =>
match lsb with
| nil => nil
| b :: lsb' =>
(a, b) :: (zip lsa' lsb')
end
end.
Ltac pairInv :=
match goal with
| [H : (_, _) = (_, _) |- _] =>
inversion H; clear H; subst
end.
(* RemoveDups -- Removing duplicates from a list *)
Section RemoveDups.
Variable A : Set.
Variable eqd : EqDec A.
Fixpoint removeDups(ls : list A) :=
match ls with
| nil => nil
| a' :: ls' =>
if (in_dec (EqDec_dec _) a' ls') then (removeDups ls') else (a' :: (removeDups ls'))
end.

Theorem removeDups_in :
forall (ls : list A) a,
In a (removeDups ls) ->
In a ls.