Section ListFacts.
Context {A : Type}.
Variable Aeq : forall (x y : A), {x = y} + {x <> y}.
(** common_prefix *)
Fixpoint common_prefix (xs ys : list A) : list A :=
match xs, ys with
| x :: xs', y :: ys' =>
if Aeq x y then x :: common_prefix xs' ys' else nil
| _, _ => nil
end.
Definition strip_common_prefix (xs ys : list A) : list A :=
let longer := if length xs <=? length ys then ys else xs in
skipn (length (common_prefix xs ys)) longer.

Lemma cons_app_single : forall (xs ys : list A) x,
xs ++ x :: ys = (xs ++ x :: nil) ++ ys.