Fixpoint nodup (l : list A) : list A :=
    match l with
      | [] => []
      | x::xs => if in_dec decA x xs then nodup xs else x::(nodup xs)
    end.

Lemma NoDup_nth_error l : NoDup l <-> (forall i j, i<length l -> nth_error l i = nth_error l j -> i = j).