Variant last_spec : seq T -> Type :=
  | LastNil        : last_spec [::]
  | LastRcons s x  : last_spec (rcons s x).Variant last_spec : seq T -> Type :=
  | LastNil        : last_spec [::]
  | LastRcons s x  : last_spec (rcons s x).Variant last_spec : seq T -> Type :=
  | LastNil        : last_spec [::]
  | LastRcons s x  : last_spec (rcons s x).

(* Specifications: *)
Lemma lastP s : last_spec s.
Lemma last_ind P : P [::] -> (forall s x, P s -> P (rcons s x)) -> forall s, P s.
Lemma nth0 s : nth s 0 = head s.
Lemma nth_default s n : size s <= n -> nth s n = x0.
Lemma nth_nil n : nth [::] n = x0.
Lemma last_nth x s : last x s = nth (x :: s) (size s).
Lemma nth_cat s1 s2 n : nth (s1 ++ s2) n = if n < size s1 then nth s1 n else nth s2 (n - size s1).
Lemma nth_ncons m x s n : nth (ncons m x s) n = if n < m then x else nth s (n - m).
Lemma nth_nseq m x n : nth (nseq m x) n = (if n < m then x else x0).
Lemma eq_from_nth s1 s2 : size s1 = size s2 -> (forall i, i < size s1 -> nth s1 i = nth s2 i) -> s1 = s2.
Lemma set_nth_nil n y : set_nth [::] n y = ncons n x0 [:: y].