Definition optSwap (A : Set)(opt : option (A * A)) :=
  match opt with
    | None => None
    | Some (a1, a2) =>
      Some (a2, a1)
  end.

Lemma nth_lt_length : forall (A : Set)(ls : list A)(i : nat) a def, nth i ls def = a -> def <> a -> i < length ls.