(** [removelast l] remove the last element of [l] *)

  Fixpoint removelast (l:list A) : list A :=
    match l with
      | [] =>  []
      | [a] => []
      | a :: l' => a :: removelast l'
    end.

(* Specifications: *)
Lemma app_removelast_last : forall l d, l <> [] -> l = removelast l ++ [last l d].
Lemma exists_last : forall l, l <> [] -> { l' : (list A) & { a : A | l = l' ++ [a]}}.
Lemma removelast_app : forall l l', l' <> [] -> removelast (l++l') = l ++ removelast l'.
Lemma removelast_last : forall l a, removelast (l ++ [a]) = l.