5
Axiom eq_dec : forall a b : A, {a = b} + {a <> b}.
9
| Add : A -> set -> set.
11
Fixpoint In (a : A) (s : set) {struct s} : Prop :=
14
| Add b s' => a = b \/ In a s'
17
Definition same (s t : set) : Prop := forall a : A, In a s <-> In a t.
19
Lemma setoid_set : Setoid_Theory set same.
21
unfold same in |- *; split ; red.
29
elim (H a); elim (H0 a).
33
Add Setoid set same setoid_set as setsetoid.
35
Add Morphism In : In_ext.
36
unfold same in |- *; intros a s t H; elim (H a); auto.
41
same s t -> forall a b : A, In a (Add b s) -> In a (Add b t).
42
unfold same in |- *; simple induction 2; intros.
44
simpl in |- *; left; reflexivity.
52
Add Morphism Add : Add_ext.
60
Fixpoint remove (a : A) (s : set) {struct s} : set :=
65
| left _ => remove a t
66
| right _ => Add b (remove a t)
70
Lemma in_rem_not : forall (a : A) (s : set), ~ In a (remove a (Add a Empty)).
73
setoid_replace (remove a (Add a Empty)) with Empty.
83
intros; absurd (a = a); trivial.
89
Parameter P : set -> Prop.
90
Parameter P_ext : forall s t : set, same s t -> P s -> P t.
92
Add Morphism P : P_extt.
93
intros; split; apply P_ext; (assumption || apply (Seq_sym _ _ setoid_set); assumption).
97
forall (a : A) (s t : set), same s t -> P (Add a s) -> P (Add a t).
107
(* Unifying the domain up to delta-conversion (example from emakarov) *)
109
Definition id: Set -> Set := fun A => A.
110
Definition rel : forall A : Set, relation (id A) := @eq.
111
Definition f: forall A : Set, A -> A := fun A x => x.
113
Add Relation (id A) (rel A) as eq_rel.
115
Add Morphism (@f A) : f_morph.
117
unfold rel, f. trivial.
120
(* Submitted by Nicolas Tabareau *)
121
(* Needs unification.ml to support environments with de Bruijn *)
125
(Q : (nat -> Prop) -> Prop)
126
(H : forall (h : nat -> Prop), Q (fun x : nat => f (h x)) <-> True)
128
Q (fun x : nat => f (Q (fun b : nat => f (h x)))) <-> True.