(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(*FINITE*)
(*definit les ensembles finis et la sommation *)
Require Export bibli.
Unset Standard Proposition Elimination Names.
Section DEFIN.
(* un ensemble fini est un ensemble tel qu'il existe une liste contenant chaque element une fois et une seule *)
Variable E : Set.
Hypothesis eq_E_dec : eq_dec E.
Fixpoint only_once (x : E) (l : list E) {struct l} : Prop :=
match l with
| nil => False
| y :: l' =>
if eq_E_dec x y then ~ In x l' else only_once x l'
end.
Definition list_of_elements (l : list E) := forall x : E, only_once x l.

(* Specifications: *)
Lemma only_once_in : forall (l : list E) (x : E), only_once x l -> In x l.
Lemma equality_from_membership :
forall (x y : E) (l : list E), In y l -> ~ In x l -> x <> y.