Fixpoint last x s := if s is x' :: s' then last x' s' else x.Fixpoint belast x s := if s is x' :: s' then x :: (belast x' s') else [::].

(* Specifications: *)
Lemma lastI x s : x :: s = rcons (belast x s) (last x s).
Lemma last_cons x y s : last x (y :: s) = last y s.
Lemma size_belast x s : size (belast x s) = size s.
Lemma last_cat x s1 s2 : last x (s1 ++ s2) = last (last x s1) s2.
Lemma last_rcons x s z : last x (rcons s z) = z.
Lemma belast_cat x s1 s2 : belast x (s1 ++ s2) = belast x s1 ++ belast (last x s1) s2.
Lemma belast_rcons x s z : belast x (rcons s z) = x :: s.
Lemma cat_rcons x s1 s2 : rcons s1 x ++ s2 = s1 ++ x :: s2.
Lemma rcons_cat x s1 s2 : rcons (s1 ++ s2) x = s1 ++ rcons s2 x.