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 [::].

Lemma belast_cat x s1 s2 : belast x (s1 ++ s2) = belast x s1 ++ belast (last x s1) s2.