Section Maps1_3.
Comments "We define the composition of maps:".
Variable E F G : Setoid.
Variable g : MAP F G.
Variable f : MAP E F.
Comments
"First, we define the composition of the functions associated to two maps:"
f "and" g.
Definition comp_map_fun (x : E) := g (f x).
Comments "Then, we proof that the result is compatible with equality:".
red in |- *.
unfold comp_map_fun in |- *.
auto with algebra.
Qed.
Comments "With this result, we can build the composed map:".
Definition comp_map_map : MAP E G := Build_Map comp_map_fun_compatible.
End Maps1_3.
Comments "We note" (comp_map_map g f) "the composition of" g "and" f.
Comments "Composition is compatible with equality of maps:".
unfold comp_map_map in |- *; simpl in |- *.
unfold Map_eq in |- *; simpl in |- *; auto with algebra.
unfold comp_map_fun in |- *.
auto with algebra.
Qed.
Hint Resolve comp_map_comp: algebra.
Comments "Composition is associative:".
unfold comp_map_map in |- *; simpl in |- *.
unfold Map_eq in |- *; simpl in |- *; auto with algebra.
Qed.
Hint Resolve comp_map_assoc: algebra.
Comments "We define now the identity map:".
Definition Id : forall A : Setoid, MAP A A.
intros A; try assumption.
apply (Build_Map (A:=A) (B:=A) (Ap:=fun x : A => x)).
red in |- *.
auto with algebra.
Defined.
Comments "Identity map is a unit element for composition:".
unfold comp_map_map in |- *; simpl in |- *.
unfold Map_eq in |- *; simpl in |- *; auto with algebra.
Qed.
Hint Resolve Id_unit_r: algebra.
unfold comp_map_map in |- *; simpl in |- *.
unfold Map_eq in |- *; simpl in |- *; auto with algebra.
Qed.
Hint Resolve Id_unit_l: algebra.
intros A; red in |- *.
split; [ red in |- * | idtac ].
simpl in |- *; auto with algebra.
red in |- *.
intros y; exists y; try assumption; auto with algebra.
Qed.
Hint Resolve Id_is_bijective: algebra.
Comments "Some properties of composition:".
unfold injective in |- *.
intros A B C f g H' x y H'0; try assumption.
apply H'.
unfold comp_map_map in |- *; simpl in |- *.
unfold comp_map_fun in |- *.
auto with algebra.
Qed.
Hint Resolve comp_injective: algebra.
unfold surjective in |- *.
intros A B C f g H' y; try assumption.
elim (H' y); intros x E; try exact E.
simpl in E.
unfold comp_map_fun in E.
exists (Ap f x); try assumption; auto with algebra.
Qed.
intros A B f g H' H'0; try assumption.
unfold bijective in |- *.
split; [ try assumption | idtac ].
apply comp_injective with A g; auto with algebra.
apply injective_comp with (f := Id A); auto with algebra.
apply comp_surjective with B g; auto with algebra.
apply surjective_comp with (f := Id B); auto with algebra.
Qed.
intros A B f g H'; try assumption.
apply comp_injective with A g; auto with algebra.
apply injective_comp with (f := Id A); auto with algebra.
Qed.

Lemma comp_is_id_then_surjective :
forall (A B : Setoid) (f : MAP A B) (g : MAP B A),
Equal (comp_map_map f g) (Id B) -> surjective f.