(* There is nth_error in the Coq library, but it seems to return something in Type. *)
Fixpoint nth_option(A : Set)(ls : list A)(i : nat) :=
  match ls with 
    | nil => None
    | a :: ls' =>
      match i with
        | O => Some a
        | S i' =>
          nth_option ls' i'
          end
  end.

Theorem cons_ne : forall (A : Set)(eqda : eq_dec A)(a1 a2 : A)(ls1 ls2 : list A), ((a1 :: ls1) = (a2 :: ls2) -> False) -> (a1 <> a2) \/ (ls1 <> ls2).