(*********************************************************************) 
(*                  Some List Functions                              *) 
(*********************************************************************) 

Definition front (A : Set) (l : list A) : list A := rev (tail (rev l)).Definition last (A : Set) (l : list A) := head (rev l).Fixpoint take (A : Set) (n : nat) (l : list A) {struct l} : 
 list A :=
  match l with
  | nil => nil (A:=A)
  | a :: l' => match n with
               | O => nil (A:=A)
               | S m => a :: take m l'
               end
  end.(*********************************************************************) 
(*                  Some Functions for ListSet                       *) 
(*********************************************************************) 
 
Definition IsEmpty (A : Set) (B : set A) := forall x : A, ~ set_In x B.Definition Included (A : Set) (B C : set A) :=
  forall x : A, set_In x B -> set_In x C.

(* Specifications: *)
Lemma AllWaysIncluded : forall (A : Set) (B : set A), Included B B.
Lemma Set_union1 : forall (B C : set A) (x : A), set_In x (set_union Aeq_dec B C) -> ~ set_In x B -> set_In x C.
Lemma Set_union2 : forall (B C : set A) (x : A), set_In x (set_union Aeq_dec B C) -> set_In x (set_union Aeq_dec C B).
Lemma Set_remove2 : forall (B : set A) (x y : A), set_In x (set_remove Aeq_dec y B) -> set_In x B.
Lemma Set_add1 : forall (B : set A) (x y : A), set_In x (set_add Aeq_dec y B) -> x <> y -> set_In x B.
Lemma Set_add2 : forall (B : set A) (x y : A), x <> y -> ~ set_In x B -> ~ set_In x (set_add Aeq_dec y B).
Lemma Listeq_dec : forall A : Set, (forall a b : A, {a = b} + {a <> b}) -> forall x y : list A, {x = y} + {x <> y}.
Lemma Prodeq_dec : forall A B : Set, (forall x y : A, {x = y} + {x <> y}) -> (forall v w : B, {v = w} + {v <> w}) -> forall c d : A * B, {c = d} + {c <> d}.