(*****************)
(** ** Remove    *)
(*****************)
Fixpoint remove (x : A) (l : list A) : list A :=
match l with
| [] => []
| y::tl => if (eq_dec x y) then remove x tl else y :: remove x tl
end.

(* Specifications: *)
Lemma remove_cons : forall x l, remove x (x :: l) = remove x l.
Lemma remove_app : forall x l1 l2,
remove x (l1 ++ l2) = remove x l1 ++ remove x l2.
Theorem remove_In : forall (l : list A) (x : A), ~ In x (remove x l).
Lemma notin_remove: forall l x, ~ In x l -> remove x l = l.
Lemma in_remove: forall l x y, In x (remove y l) -> In x l /\ x <> y.
Lemma in_in_remove : forall l x y, x <> y -> In x l -> In x (remove y l).
Lemma remove_remove_comm : forall l x y,
remove x (remove y l) = remove y (remove x l).
Lemma remove_remove_eq : forall l x, remove x (remove x l) = remove x l.
Lemma remove_length_lt : forall l x, In x l -> length (remove x l) < length l.
Fixpoint count_occ (l : list A) (x : A) : nat :=
match l with
| [] => 0
| y :: tl =>
let n := count_occ tl x in
if eq_dec y x then S n else n
end.