(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)


(*****************************************************************************)
(*          Projet Coq - Calculus of Inductive Constructions V5.10           *)
(*****************************************************************************)
(*                                                                           *)
(*          Category Theory : Hom Functors                                   *)
(*                                                                           *)
(*          Amokrane Saibi May 1994                                          *)
(*                                                                           *)
(*****************************************************************************)

Require Export SET.
Require Export Functor.
Require Export Dual.

Set Implicit Arguments.
Unset Strict Implicit.

(* 1. Hom-Functor : C(a,-) : C-->SET *)

Section funset.

Variables (C : Category) (a : C).

(* to each object b of C, we associate Hom(a,b), a object of SET *)

Definition FunSET_ob (b : C) := a --> b.

 Section funset_map_def.

 Variable b c : C.

  Section funset_mor_def.

  Variable f : b --> c.
 
  Definition FunSET_mor1 (g : a --> b) := g o f.

  Lemma FunSET_map_law1 : Map_law FunSET_mor1.
  Proof.
(* Goal: @Map_law (@Hom C a b) (@Hom C a c) FunSET_mor1 *)
  unfold Map_law, FunSET_mor1 in |- *.
(* Goal: forall (x y : Carrier (@Hom C a b)) (_ : @Equal (@Hom C a b) x y), @Equal (@Hom C a c) (@Comp C a b c x f) (@Comp C a b c y f) *)
  intros g h H.
(* Goal: @Equal (@Hom C a c) (@Comp C a b c g f) (@Comp C a b c h f) *)
  apply Comp_r; assumption.
  Qed.

  Canonical Structure FunSET_mor : Map (FunSET_ob b) (FunSET_ob c) :=
    FunSET_map_law1.

  End funset_mor_def.

 Lemma FunSET_map_law : Map_law FunSET_mor.
 Proof.
(* Goal: @Map_law (@Hom C b c) (Map_setoid (FunSET_ob b) (FunSET_ob c)) FunSET_mor *)
 unfold Map_law in |- *; simpl in |- *.
(* Goal: forall a : Ob C, @Ext (FunSET_ob a) (FunSET_ob a) (@FunSET_mor a a (@Id C a)) (Id_SET (FunSET_ob a)) *)
 unfold Ext in |- *; simpl in |- *.
(* Goal: forall (a : Ob C) (x : Carrier (FunSET_ob a)), @Equal (FunSET_ob a) (@FunSET_mor1 a a (@Id C a) x) x *)
 unfold FunSET_mor1, FunSET_ob in |- *.
(* Goal: forall (x y : Carrier (@Hom C b c)) (_ : @Equal (@Hom C b c) x y) (x0 : Carrier (@Hom C a b)), @Equal (@Hom C a c) (@Comp C a b c x0 x) (@Comp C a b c x0 y) *)
 intros f g H h.
(* Goal: @Equal (@Hom C a c) (@Comp C a b c h f) (@Comp C a b c h g) *)
 apply Comp_l; assumption.
 Qed.

 Canonical Structure FunSET_map := Build_Map FunSET_map_law.

 End funset_map_def.

Lemma Fun_comp_law : Fcomp_law FunSET_map.
Proof.
(* Goal: @Fcomp_law C SET FunSET_ob FunSET_map *)
unfold Fcomp_law in |- *; simpl in |- *.
(* Goal: forall a : Ob C, @Ext (FunSET_ob a) (FunSET_ob a) (@FunSET_mor a a (@Id C a)) (Id_SET (FunSET_ob a)) *)
unfold Ext in |- *; simpl in |- *.
(* Goal: forall (a b c : Ob C) (f : Carrier (@Hom C a b)) (g : Carrier (@Hom C b c)) (x : Carrier (FunSET_ob a)), @Equal (FunSET_ob c) (@FunSET_mor1 a c (@Comp C a b c f g) x) (@FunSET_mor1 b c g (@FunSET_mor1 a b f x)) *)
unfold Comp_fun in |- *; simpl in |- *.
(* Goal: forall (a : Ob C) (x : Carrier (FunSET_ob a)), @Equal (FunSET_ob a) (@FunSET_mor1 a a (@Id C a) x) x *)
unfold FunSET_mor1, FunSET_ob in |- *.
(* Goal: forall (a0 b c : Ob C) (f : Carrier (@Hom C a0 b)) (g : Carrier (@Hom C b c)) (x : Carrier (@Hom C a a0)), @Equal (@Hom C a c) (@Comp C a a0 c x (@Comp C a0 b c f g)) (@Comp C a b c (@Comp C a a0 b x f) g) *)
intros b c d f g h.
(* Goal: @Equal (@Hom C a d) (@Comp C a b d h (@Comp C b c d f g)) (@Comp C a c d (@Comp C a b c h f) g) *)
apply Ass.
Qed.

Lemma Fun_id_law : Fid_law FunSET_map.
Proof.
(* Goal: @Fid_law C SET FunSET_ob FunSET_map *)
unfold Fid_law in |- *; simpl in |- *.
(* Goal: forall a : Ob C, @Ext (FunSET_ob a) (FunSET_ob a) (@FunSET_mor a a (@Id C a)) (Id_SET (FunSET_ob a)) *)
unfold Ext in |- *; simpl in |- *.
(* Goal: forall (a : Ob C) (x : Carrier (FunSET_ob a)), @Equal (FunSET_ob a) (@FunSET_mor1 a a (@Id C a) x) (@Id_fun (FunSET_ob a) x) *)
unfold Id_fun in |- *.
(* Goal: forall (a : Ob C) (x : Carrier (FunSET_ob a)), @Equal (FunSET_ob a) (@FunSET_mor1 a a (@Id C a) x) x *)
unfold FunSET_mor1, FunSET_ob in |- *.
(* Goal: forall (a0 : Ob C) (x : Carrier (@Hom C a a0)), @Equal (@Hom C a a0) (@Comp C a a0 a0 x (@Id C a0)) x *)
intros b f; apply Idr1.
Qed.

Canonical Structure FunSET := Build_Functor Fun_comp_law Fun_id_law.

End funset.



