update Demo.hs
[coq-hetmet.git] / src / GeneralizedArrowCategory.v
1 (*********************************************************************************************************************************)
2 (* CategoryOfGeneralizedArrows:                                                                                                  *)
3 (*                                                                                                                               *)
4 (*   There is a category whose objects are surjective monic monoidal enrichments (SMME's) and whose morphisms                    *)
5 (*   are generalized  Arrows                                                                                                     *)
6 (*                                                                                                                               *)
7 (*********************************************************************************************************************************)
8
9 Generalizable All Variables.
10 Require Import Preamble.
11 Require Import General.
12 Require Import Categories_ch1_3.
13 Require Import Functors_ch1_4.
14 Require Import Isomorphisms_ch1_5.
15 Require Import ProductCategories_ch1_6_1.
16 Require Import OppositeCategories_ch1_6_2.
17 Require Import Enrichment_ch2_8.
18 Require Import Subcategories_ch7_1.
19 Require Import NaturalTransformations_ch7_4.
20 Require Import NaturalIsomorphisms_ch7_5.
21 Require Import BinoidalCategories.
22 Require Import PreMonoidalCategories.
23 Require Import MonoidalCategories_ch7_8.
24 Require Import Coherence_ch7_8.
25 Require Import Enrichment_ch2_8.
26 Require Import Enrichments.
27 Require Import RepresentableStructure_ch7_2.
28 Require Import GeneralizedArrow.
29 Require Import WeakFunctorCategory.
30
31 (*
32  * Technically reifications form merely a *semicategory* (no identity
33  * maps), but one can always freely adjoin identity maps (and nothing
34  * else) to a semicategory to get a category whose non-identity-map
35  * portion is identical to the original semicategory
36  *
37  * Also, technically this category has ALL enrichments (not just the
38  * surjective monic monoidal ones), though there maps OUT OF only the
39  * surjective enrichments and INTO only the monic monoidal
40  * enrichments.  It's a big pain to do this in Coq, but sort of might
41  * matter in real life: a language with really severe substructural
42  * restrictions might fail to be monoidally enriched, meaning we can't
43  * use it as a host language.  But that's for the next paper...
44  *)
45 Inductive GeneralizedArrowOrIdentity : SMMEs -> SMMEs -> Type :=
46   | gaoi_id   : forall smme:SMMEs,                             GeneralizedArrowOrIdentity smme smme
47   | gaoi_ga : forall s1 s2:SMMEs, GeneralizedArrow s1 s2  -> GeneralizedArrowOrIdentity s1   s2.
48
49 Definition generalizedArrowOrIdentityFobj (s1 s2:SMMEs) (f:GeneralizedArrowOrIdentity s1 s2) : s1 -> s2 :=
50   match f in GeneralizedArrowOrIdentity S1 S2 return S1 -> S2 with
51   | gaoi_id  s       => fun x => x
52   | gaoi_ga s1 s2 f  => fun a => ehom(ECategory:=s2) (enr_c_i (smme_e s2)) (ga_functor_obj f a)
53   end.
54
55 Definition generalizedArrowOrIdentityFunc s1 s2 (f:GeneralizedArrowOrIdentity s1 s2)
56   : Functor s1 s2 (generalizedArrowOrIdentityFobj _ _ f) :=
57   match f with
58   | gaoi_id  s       => functor_id _
59   | gaoi_ga s1 s2 f  => ga_functor f >>>> HomFunctor s2 (enr_c_i s2)
60   end.
61
62 Instance compose_generalizedArrows (s0 s1 s2:SMMEs) 
63   (g01:GeneralizedArrow s0 s1)(g12:GeneralizedArrow s1 s2) : GeneralizedArrow s0 s2 :=
64     { ga_functor_monoidal := g01 >>⊗>> smme_mon s1 >>⊗>> g12 }.
65   apply ga_host_lang_pure.
66   Defined.
67
68 Definition generalizedArrowOrIdentityComp
69   : forall s1 s2 s3, GeneralizedArrowOrIdentity s1 s2 -> GeneralizedArrowOrIdentity s2 s3 -> GeneralizedArrowOrIdentity s1 s3.
70   intros.
71   destruct X.
72     apply X0.
73   destruct X0.
74     apply (gaoi_ga _ _ g).
75     apply (gaoi_ga _ _ (compose_generalizedArrows _ _ _ g g0)).
76     Defined.
77
78 Definition MorphismsOfCategoryOfGeneralizedArrows : @SmallFunctors SMMEs.
79   refine {| small_func      := GeneralizedArrowOrIdentity
80           ; small_func_id   := fun s => gaoi_id s
81           ; small_func_func := fun smme1 smme2 f => generalizedArrowOrIdentityFunc _ _ f
82           ; small_func_comp := generalizedArrowOrIdentityComp
83          |}; intros; simpl.
84   apply if_id.
85   destruct f as [|fobj f]; simpl in *.
86     apply if_inv.
87     apply if_left_identity.
88   destruct g as [|gobj g]; simpl in *.
89     apply if_inv.
90     apply if_right_identity.
91   unfold mf_F.
92   idtac.
93   apply if_associativity.
94   Defined.
95
96 Definition CategoryOfGeneralizedArrows :=
97   WeakFunctorCategory MorphismsOfCategoryOfGeneralizedArrows.