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 in_app_case : forall (xs ys xs' ys' : list A) x,
xs ++ ys = xs' ++ x :: ys' ->
(In x ys /\ exists zs, ys = zs ++ x :: ys') \/ (In x xs /\ exists zs, xs = xs' ++ x :: zs).