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.

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)).