intros R; try assumption.
exact (Rel_compatible_prf (r:=R)).
Qed.
Hint Resolve Rel_comp: algebra.
Variable R : Relation.
Hypothesis R_equiv : equivalence R.
Set Strict Implicit.
Unset Implicit Arguments.
Definition quotient : Setoid := Build_Setoid R_equiv.
Set Implicit Arguments.
Unset Strict Implicit.
End Quotient1.
Section Maps1.
Comments
"Maps between two sets are functions which are compatible with equalities:".
Section Maps1_1.
Variable A B : Setoid.
Definition fun_compatible (f : A -> B) : Prop :=
forall x y : A, Equal x y -> Equal (f x) (f y).
Record Map : Type :=
{Ap :> A -> B; Map_compatible_prf :> fun_compatible Ap:Prop}.
Comments "Two maps are equal when they have the same values:".
Definition Map_eq (f g : Map) : Prop := forall x : A, Equal (f x) (g x).
Let Map_eq_equiv : equivalence Map_eq.
red in |- *.
split; [ try assumption | idtac ].
red in |- *.
unfold Map_eq, app_rel in |- *; simpl in |- *; auto with algebra.
red in |- *.
split; [ try assumption | idtac ].
red in |- *.
unfold Map_eq, app_rel in |- *; simpl in |- *; auto with algebra.
intros x y z H' H'0 x0; try assumption.
apply Trans with (y x0); auto with algebra.
red in |- *.
unfold Map_eq, app_rel in |- *; simpl in |- *; auto with algebra.
Qed.
Definition MAP : Setoid := Build_Setoid Map_eq_equiv.
Comments "We note" (MAP A B) "the set of maps between" A "and" B.
End Maps1_1.
Comments "Some immediate properties of maps:".

Lemma Ap_comp :
forall (A B : Setoid) (f g : MAP A B) (x y : A),
Equal x y -> Equal f g -> Equal (f x) (g y).