Section dedup.
Variable A : Type.
Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}.
Fixpoint dedup (xs : list A) : list A :=
match xs with
| [] => []
| x :: xs => let tail := dedup xs in
if in_dec A_eq_dec x xs then
tail
else
x :: tail
end.
Proof using.
intros. simpl in *.
break_match.
+ auto.
+ exfalso. intuition.
Qed.
Proof using.
induction xs; intros; simpl in *.
- intuition.
- break_if; intuition; subst; simpl; auto.
Qed.

Lemma filter_dedup (pred : A -> bool) :
forall xs (p : A) ys,
pred p = false ->
filter pred (dedup (xs ++ ys)) = filter pred (dedup (xs ++ p :: ys)).