(** Results about [nth_error] *)

(* Specifications: *)
Lemma nth_error_In l n x : nth_error l n = Some x -> In x l.
Lemma In_nth_error l x : In x l -> exists n, nth_error l n = Some x.
Lemma In_iff_nth_error l x : In x l <-> exists n, nth_error l n = Some x.
Lemma nth_error_Some l n : nth_error l n <> None <-> n < length l.
Lemma nth_error_split l n a : nth_error l n = Some a ->
exists l1, exists l2, l = l1 ++ a :: l2 /\ length l1 = n.
Lemma nth_error_app1 l l' n : n < length l ->
nth_error (l++l') n = nth_error l n.
Lemma nth_error_app2 l l' n : length l <= n ->
nth_error (l++l') n = nth_error l' (n-length l).
Lemma nth_error_app l l' n : nth_error (l ++ l') n =
if Nat.ltb n (length l)
then nth_error l n
else nth_error l' (n - length l).
Lemma nth_error_ext l l':
(forall n, nth_error l n = nth_error l' n) -> l = l'.
Lemma unfold_nth_error l n
: nth_error l n
= match n, l with
| O, x :: _ => Some x
| S n, _ :: l' => nth_error l' n
| _, _ => None
end.
Lemma nth_error_nth' : forall (l : list A) (n : nat) (d : A),
n < length l -> nth_error l n = Some (nth n l d).
Lemma nth_error_nth_None (l : list A) (n : nat) (d : A) :
nth_error l n = None -> nth n l d = d.