Proof using.
induction xs; intros.
- auto.
- simpl. repeat (break_match; simpl); auto using f_equal.
+ exfalso. apply n0. apply remove_preserve; auto.
+ exfalso. apply n. eapply in_remove; eauto.
Qed.

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