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 dedup_partition : forall xs (p : A) ys xs' ys', dedup (xs ++ p :: ys) = xs' ++ p :: ys' -> remove A_eq_dec p (dedup (xs ++ ys)) = xs' ++ ys'.