(* 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                                                     *)


(****************************************************************************)
(*                 The Calculus of Inductive Constructions                  *)
(*                                                                          *)
(*                                Projet Coq                                *)
(*                                                                          *)
(*                     INRIA                        ENS-CNRS                *)
(*              Rocquencourt                        Lyon                    *)
(*                                                                          *)
(*                                 Coq V6.1                                 *)
(*                               Oct 1st 1996                               *)
(*                                                                          *)
(****************************************************************************)
(*                                    CAT.v                                 *)
(****************************************************************************)

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


Require Export IdCAT.
Require Export Category_dup1.

Set Implicit Arguments.
Unset Strict Implicit.

(* Functor composition operator *)

Lemma Comp_Functor_congl : Congl_law' Comp_Functor.
Proof.
(* Goal: @Congl_law' Category Functor_setoid Comp_Functor *)
unfold Congl_law' in |- *; simpl in |- *.
(* Goal: forall (a b c : Category) (f g : Functor a b) (h : Functor b c) (_ : @Equal_Functor a b f g), @Equal_Functor a c (@Comp_Functor a b c f h) (@Comp_Functor a b c g h) *)
unfold Equal_Functor, Comp_Functor in |- *.
(* Goal: forall (a b c : Category) (f g : Functor a b) (h : Functor b c) (_ : forall (a0 b0 : Ob a) (f0 : Carrier (@Hom a a0 b0)), @Equal_hom b (@FOb a b f a0) (@FOb a b f b0) (@FMor a b f a0 b0 f0) (@FOb a b g a0) (@FOb a b g b0) (@FMor a b g a0 b0 f0)) (a0 b0 : Ob a) (f0 : Carrier (@Hom a a0 b0)), @Equal_hom c (@FOb a c (@Build_Functor a c (@Comp_FOb a b c f h) (@Comp_FMap a b c f h) (@Comp_Functor_comp_law a b c f h) (@Comp_Functor_id_law a b c f h)) a0) (@FOb a c (@Build_Functor a c (@Comp_FOb a b c f h) (@Comp_FMap a b c f h) (@Comp_Functor_comp_law a b c f h) (@Comp_Functor_id_law a b c f h)) b0) (@FMor a c (@Build_Functor a c (@Comp_FOb a b c f h) (@Comp_FMap a b c f h) (@Comp_Functor_comp_law a b c f h) (@Comp_Functor_id_law a b c f h)) a0 b0 f0) (@FOb a c (@Build_Functor a c (@Comp_FOb a b c g h) (@Comp_FMap a b c g h) (@Comp_Functor_comp_law a b c g h) (@Comp_Functor_id_law a b c g h)) a0) (@FOb a c (@Build_Functor a c (@Comp_FOb a b c g h) (@Comp_FMap a b c g h) (@Comp_Functor_comp_law a b c g h) (@Comp_Functor_id_law a b c g h)) b0) (@FMor a c (@Build_Functor a c (@Comp_FOb a b c g h) (@Comp_FMap a b c g h) (@Comp_Functor_comp_law a b c g h) (@Comp_Functor_id_law a b c g h)) a0 b0 f0) *)
intros A B C F G H eq_FG a1 a2 f.
(* Goal: @Equal_hom C (@FOb A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a1) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a2) (@FMor A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a1 a2 f) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a1) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a2) (@FMor A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a1 a2 f) *)
unfold FMor in |- *; simpl in |- *.
(* Goal: @Equal_hom C (@Comp_FOb A B C F H a1) (@Comp_FOb A B C F H a2) (@Comp_FMor A B C F H a1 a2 f) (@Comp_FOb A B C G H a1) (@Comp_FOb A B C G H a2) (@Comp_FMor A B C G H a1 a2 f) *)
unfold Comp_FOb, Comp_FMor in |- *.
(* Goal: @Equal_hom C (@FOb B C F (@FOb A B H a1)) (@FOb B C F (@FOb A B H a2)) (@FMor B C F (@FOb A B H a1) (@FOb A B H a2) (@FMor A B H a1 a2 f)) (@FOb B C G (@FOb A B H a1)) (@FOb B C G (@FOb A B H a2)) (@FMor B C G (@FOb A B H a1) (@FOb A B H a2) (@FMor A B H a1 a2 f)) *)
apply eq_FG.
Qed.

Lemma Comp_Functor_congr : Congr_law' Comp_Functor.
Proof.
(* Goal: @Congr_law' Category Functor_setoid Comp_Functor *)
unfold Congr_law' in |- *; simpl in |- *.
(* Goal: forall (a b c : Category) (f g : Functor a b) (h : Functor b c) (_ : @Equal_Functor a b f g), @Equal_Functor a c (@Comp_Functor a b c f h) (@Comp_Functor a b c g h) *)
unfold Equal_Functor, Comp_Functor in |- *.
(* Goal: forall (a b c : Category) (f g : Functor a b) (h : Functor b c) (_ : forall (a0 b0 : Ob a) (f0 : Carrier (@Hom a a0 b0)), @Equal_hom b (@FOb a b f a0) (@FOb a b f b0) (@FMor a b f a0 b0 f0) (@FOb a b g a0) (@FOb a b g b0) (@FMor a b g a0 b0 f0)) (a0 b0 : Ob a) (f0 : Carrier (@Hom a a0 b0)), @Equal_hom c (@FOb a c (@Build_Functor a c (@Comp_FOb a b c f h) (@Comp_FMap a b c f h) (@Comp_Functor_comp_law a b c f h) (@Comp_Functor_id_law a b c f h)) a0) (@FOb a c (@Build_Functor a c (@Comp_FOb a b c f h) (@Comp_FMap a b c f h) (@Comp_Functor_comp_law a b c f h) (@Comp_Functor_id_law a b c f h)) b0) (@FMor a c (@Build_Functor a c (@Comp_FOb a b c f h) (@Comp_FMap a b c f h) (@Comp_Functor_comp_law a b c f h) (@Comp_Functor_id_law a b c f h)) a0 b0 f0) (@FOb a c (@Build_Functor a c (@Comp_FOb a b c g h) (@Comp_FMap a b c g h) (@Comp_Functor_comp_law a b c g h) (@Comp_Functor_id_law a b c g h)) a0) (@FOb a c (@Build_Functor a c (@Comp_FOb a b c g h) (@Comp_FMap a b c g h) (@Comp_Functor_comp_law a b c g h) (@Comp_Functor_id_law a b c g h)) b0) (@FMor a c (@Build_Functor a c (@Comp_FOb a b c g h) (@Comp_FMap a b c g h) (@Comp_Functor_comp_law a b c g h) (@Comp_Functor_id_law a b c g h)) a0 b0 f0) *)
intros A B C F G H eq_FG a1 a2 f.
(* Goal: @Equal_hom C (@FOb A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a1) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a2) (@FMor A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a1 a2 f) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a1) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a2) (@FMor A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a1 a2 f) *)
unfold FMor in |- *; simpl in |- *.
(* Goal: @Equal_hom C (@Comp_FOb A B C F H a1) (@Comp_FOb A B C F H a2) (@Comp_FMor A B C F H a1 a2 f) (@Comp_FOb A B C G H a1) (@Comp_FOb A B C G H a2) (@Comp_FMor A B C G H a1 a2 f) *)
unfold Comp_FOb, Comp_FMor in |- *.
(* Goal: @Equal_hom C (@FOb B C H (@FOb A B F a1)) (@FOb B C H (@FOb A B F a2)) (@FMor B C H (@FOb A B F a1) (@FOb A B F a2) (@FMor A B F a1 a2 f)) (@FOb B C H (@FOb A B G a1)) (@FOb B C H (@FOb A B G a2)) (@FMor B C H (@FOb A B G a1) (@FOb A B G a2) (@FMor A B G a1 a2 f)) *)
elim (eq_FG a1 a2 f); intros g eq_Ff_g.
(* Goal: @Equal_hom C (@FOb B C H (@FOb A B F a1)) (@FOb B C H (@FOb A B F a2)) (@FMor B C H (@FOb A B F a1) (@FOb A B F a2) (@FMor A B F a1 a2 f)) (@FOb B C H (@FOb A B F a1)) (@FOb B C H (@FOb A B F a2)) (@FMor B C H (@FOb A B F a1) (@FOb A B F a2) g) *)
apply Build_Equal_hom; apply FPres; assumption.
Qed.

Definition Comp_CAT := Build_Comp' Comp_Functor_congl Comp_Functor_congr.
     
Lemma Assoc_CAT : Assoc_law' Comp_CAT.
Proof.
(* Goal: @Assoc_law' Category Functor_setoid Comp_CAT *)
unfold Assoc_law', Cat_comp' in |- *; simpl in |- *.
(* Goal: forall (a b c d : Category) (f : Functor a b) (g : Functor b c) (h : Functor c d), @Equal_Functor a d (@Ap2' (Functor_setoid a b) (Functor_setoid b d) (Functor_setoid a d) (Comp_CAT a b d) f (@Ap2' (Functor_setoid b c) (Functor_setoid c d) (Functor_setoid b d) (Comp_CAT b c d) g h)) (@Ap2' (Functor_setoid a c) (Functor_setoid c d) (Functor_setoid a d) (Comp_CAT a c d) (@Ap2' (Functor_setoid a b) (Functor_setoid b c) (Functor_setoid a c) (Comp_CAT a b c) f g) h) *)
intros C D E F G H X.
(* Goal: @Equal_Functor C F (@Ap2' (Functor_setoid C D) (Functor_setoid D F) (Functor_setoid C F) (Comp_CAT C D F) G (@Ap2' (Functor_setoid D E) (Functor_setoid E F) (Functor_setoid D F) (Comp_CAT D E F) H X)) (@Ap2' (Functor_setoid C E) (Functor_setoid E F) (Functor_setoid C F) (Comp_CAT C E F) (@Ap2' (Functor_setoid C D) (Functor_setoid D E) (Functor_setoid C E) (Comp_CAT C D E) G H) X) *)
unfold Equal_Functor in |- *; simpl in |- *.
(* Goal: forall (a b : Ob C) (f : Carrier (@Hom C a b)), @Equal_hom F (@Comp_FOb D E F H X (@FOb C D G a)) (@Comp_FOb D E F H X (@FOb C D G b)) (@FMor C F (@Ap2' (Functor_setoid C D) (Functor_setoid D F) (Functor_setoid C F) (Comp_CAT C D F) G (@Ap2' (Functor_setoid D E) (Functor_setoid E F) (Functor_setoid D F) (Comp_CAT D E F) H X)) a b f) (@Comp_FOb C E F (@Ap2' (Functor_setoid C D) (Functor_setoid D E) (Functor_setoid C E) (Comp_CAT C D E) G H) X a) (@Comp_FOb C E F (@Ap2' (Functor_setoid C D) (Functor_setoid D E) (Functor_setoid C E) (Comp_CAT C D E) G H) X b) (@FMor C F (@Ap2' (Functor_setoid C E) (Functor_setoid E F) (Functor_setoid C F) (Comp_CAT C E F) (@Ap2' (Functor_setoid C D) (Functor_setoid D E) (Functor_setoid C E) (Comp_CAT C D E) G H) X) a b f) *)
unfold Ap2 in |- *; simpl in |- *; auto.
Qed.

(* Id *)

Lemma Idl_CAT : Idl_law' Comp_CAT Id_CAT.
Proof.
(* Goal: @Idl_law' Category Functor_setoid Comp_CAT Id_CAT *)
unfold Idl_law', Cat_comp', Ap2 in |- *; simpl in |- *.
(* Goal: forall (a b : Category) (f : Functor b a), @Equal_Functor b a f (@Ap2' (Functor_setoid b a) (Functor_setoid a a) (Functor_setoid b a) (Comp_CAT b a a) f (Id_CAT a)) *)
intros C D G; unfold Comp_Functor, Equal_Functor in |- *.
(* Goal: @Equal_hom C (@FOb A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a1) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a2) (@FMor A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a1 a2 f) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a1) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a2) (@FMor A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a1 a2 f) *)
intros a b f; unfold FMor in |- *; simpl in |- *.
(* Goal: @Equal_hom C (@FOb D C G a) (@FOb D C G b) (@Ap (@Hom D a b) (@Hom C (@FOb D C G a) (@FOb D C G b)) (@FMap D C G a b) f) (@Id_CAT_ob C (@FOb D C G a)) (@Id_CAT_ob C (@FOb D C G b)) (@Comp_FMor D C C G (Id_CAT C) a b f) *)
unfold Comp_FMor in |- *; unfold Id_CAT, FMor in |- *; simpl in |- *.
(* Goal: @Equal_hom C (@FOb D C G a) (@FOb D C G b) (@Ap (@Hom D a b) (@Hom C (@FOb D C G a) (@FOb D C G b)) (@FMap D C G a b) f) (@Id_CAT_ob C (@FOb D C G a)) (@Id_CAT_ob C (@FOb D C G b)) (@Id_fun (@Hom C (@FOb D C G a) (@FOb D C G b)) (@Ap (@Hom D a b) (@Hom C (@FOb D C G a) (@FOb D C G b)) (@FMap D C G a b) f)) *)
auto.
Qed.

Lemma Idr_CAT : Idr_law' Comp_CAT Id_CAT.
Proof.
(* Goal: @Idr_law' Category Functor_setoid Comp_CAT Id_CAT *)
unfold Idr_law', Cat_comp', Ap2 in |- *; simpl in |- *.
(* Goal: forall (a b : Category) (f : Functor b a), @Equal_Functor b a f (@Ap2' (Functor_setoid b a) (Functor_setoid a a) (Functor_setoid b a) (Comp_CAT b a a) f (Id_CAT a)) *)
intros C D G; unfold Comp_Functor, Equal_Functor in |- *.
(* Goal: @Equal_hom C (@FOb A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a1) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a2) (@FMor A C (@Build_Functor A C (@Comp_FOb A B C F H) (@Comp_FMap A B C F H) (@Comp_Functor_comp_law A B C F H) (@Comp_Functor_id_law A B C F H)) a1 a2 f) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a1) (@FOb A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a2) (@FMor A C (@Build_Functor A C (@Comp_FOb A B C G H) (@Comp_FMap A B C G H) (@Comp_Functor_comp_law A B C G H) (@Comp_Functor_id_law A B C G H)) a1 a2 f) *)
intros a b f; unfold FMor in |- *; simpl in |- *.
(* Goal: @Equal_hom C (@FOb D C G a) (@FOb D C G b) (@Ap (@Hom D a b) (@Hom C (@FOb D C G a) (@FOb D C G b)) (@FMap D C G a b) f) (@Id_CAT_ob C (@FOb D C G a)) (@Id_CAT_ob C (@FOb D C G b)) (@Comp_FMor D C C G (Id_CAT C) a b f) *)
unfold Comp_FMor in |- *; unfold Id_CAT, FMor in |- *; simpl in |- *.
(* Goal: @Equal_hom C (@FOb D C G a) (@FOb D C G b) (@Ap (@Hom D a b) (@Hom C (@FOb D C G a) (@FOb D C G b)) (@FMap D C G a b) f) (@Id_CAT_ob C (@FOb D C G a)) (@Id_CAT_ob C (@FOb D C G b)) (@Id_fun (@Hom C (@FOb D C G a) (@FOb D C G b)) (@Ap (@Hom D a b) (@Hom C (@FOb D C G a) (@FOb D C G b)) (@FMap D C G a b) f)) *)
auto.
Qed.

Canonical Structure CAT : Category' :=
  Build_Category' Assoc_CAT Idl_CAT Idr_CAT.
              