Fixpoint undup (A : list X) : list X :=
    match A with
      | nil => nil
      | x::A' => if decision (x el A') then undup A' else  x :: undup A'
    end.

(* Specifications: *)
Lemma dupfree_undup A : dupfree (undup A).
Lemma undup_eq A : dupfree A -> undup A = A.
Lemma undup_idempotent A : undup (undup A) = undup A.
Lemma dupfree_ex A B : eq_dec X -> dupfree A -> dupfree B -> |A| < |B| -> exists x, x el B /\ ~ x el A.