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 strip_common_prefix_correct : forall xs ys,
length xs <= length ys ->
let post := strip_common_prefix xs ys in
ys = common_prefix xs ys ++ post.