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:".
intros A B f g x y H' H'0; try assumption.
apply Trans with (f y).
apply (Map_compatible_prf f); auto with algebra.
simpl in H'0.
unfold Map_eq in H'0.
auto with algebra.
Qed.
Hint Resolve Ap_comp: algebra.

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