(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
(** * Finite sets library *)
(** This module proves many properties of finite sets that are consequences of the axiomatization in [FsetInterface] Contrary to the functor in [FsetProperties] it uses sets operations instead of predicates over sets, i.e. [mem x s=true] instead of [In x s], [equal s s'=true] instead of [Equal s s'], etc. *)
Require  FSetEqProperties.
Module WEqPropertiesOn (Import E:DecidableType)(M:WSetsOn E).
Module Import MP := WPropertiesOn E M.
Definition Add := MP.Add.
Section BasicProperties.
(** Some old specifications written with boolean equalities. *)
Variable s s' s'': t.
Variable x y z : elt.

(* Specifications: *)
Lemma mem_eq:
E.eq x y -> mem x s=mem y s.
Lemma equal_mem_1:
(forall a, mem a s=mem a s') -> equal s s'=true.
Lemma equal_mem_2:
equal s s'=true -> forall a, mem a s=mem a s'.
Lemma subset_mem_1:
(forall a, mem a s=true->mem a s'=true) -> subset s s'=true.
Lemma subset_mem_2:
subset s s'=true -> forall a, mem a s=true -> mem a s'=true.
Lemma empty_mem: mem x empty=false.
Lemma is_empty_equal_empty: is_empty s = equal s empty.
Lemma choose_mem_1: choose s=Some x -> mem x s=true.
Lemma choose_mem_2: choose s=None -> is_empty s=true.
Lemma add_mem_1: mem x (add x s)=true.
Lemma add_mem_2: ~E.eq x y -> mem y (add x s)=mem y s.
Lemma remove_mem_1: mem x (remove x s)=false.
Lemma remove_mem_2: ~E.eq x y -> mem y (remove x s)=mem y s.
Lemma singleton_equal_add:
equal (singleton x) (add x empty)=true.
Lemma union_mem:
mem x (union s s')=mem x s || mem x s'.
Lemma inter_mem:
mem x (inter s s')=mem x s && mem x s'.
Lemma diff_mem:
mem x (diff s s')=mem x s && negb (mem x s').