1 (*********************************************************************************************************************************)
2 (* ProgrammingLanguageArrow *)
4 (* Arrows in ProgrammingLanguages. *)
6 (*********************************************************************************************************************************)
8 Generalizable All Variables.
9 Require Import Preamble.
10 Require Import General.
11 Require Import Categories_ch1_3.
12 Require Import InitialTerminal_ch2_2.
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 MonoidalCategories_ch7_8.
22 Require Import Coherence_ch7_8.
23 Require Import Enrichment_ch2_8.
24 Require Import RepresentableStructure_ch7_2.
25 Require Import FunctorCategories_ch7_7.
27 Require Import NaturalDeduction.
28 Require Import NaturalDeductionCategory.
30 Require Import ProgrammingLanguage.
31 Require Import ProgrammingLanguageGeneralizedArrow.
32 Require Import FreydCategories.
34 Require Import GeneralizedArrow.
36 Section ExtendFunctor.
39 Context (P:c1 -> Prop).
41 Definition domain_subcat := FullSubcategory c1 P.
43 Definition functor_restricts_to_full_subcat_on_domain_fobj (a:domain_subcat) : c2 :=
46 Definition functor_restricts_to_full_subcat_on_domain_fmor (a b:domain_subcat)(f:a~~{domain_subcat}~~>b) :
47 (functor_restricts_to_full_subcat_on_domain_fobj a)~~{c2}~~>(functor_restricts_to_full_subcat_on_domain_fobj b) :=
50 Lemma functor_restricts_to_full_subcat_on_domain : Functor domain_subcat c2 functor_restricts_to_full_subcat_on_domain_fobj.
51 refine {| fmor := functor_restricts_to_full_subcat_on_domain_fmor |};
52 unfold functor_restricts_to_full_subcat_on_domain_fmor; simpl; intros.
53 setoid_rewrite H; reflexivity.
54 setoid_rewrite fmor_preserves_id; reflexivity.
55 setoid_rewrite <- fmor_preserves_comp; reflexivity.
60 Section MonoidalSubCat.
62 (* a monoidal subcategory is a full subcategory, closed under tensor and containing the unit object *)
63 Class MonoidalSubCat {Ob}{Hom}{C:Category Ob Hom}{MFobj}{MF}{MI}(MC:MonoidalCat C MFobj MF MI) :=
65 ; msc_closed_under_tensor : forall o1 o2, msc_P o1 -> msc_P o2 -> msc_P (MC (pair_obj o1 o2))
66 ; msc_contains_unit : msc_P (mon_i MC)
67 ; msc_subcat := FullSubcategory MC msc_P
69 Local Coercion msc_subcat : MonoidalSubCat >-> SubCategory.
71 Context `(MSC:MonoidalSubCat).
73 (* any full subcategory of a monoidal category, , is itself monoidal *)
74 Definition mf_restricts_to_full_subcat_on_domain_fobj (a:MSC ×× MSC) : MSC.
78 set (MC (pair_obj x x0)) as m'.
80 apply msc_closed_under_tensor; auto.
83 Definition mf_restricts_to_full_subcat_on_domain_fmor
85 (f:a~~{MSC ×× MSC}~~>b)
87 (mf_restricts_to_full_subcat_on_domain_fobj a)~~{MSC}~~>(mf_restricts_to_full_subcat_on_domain_fobj b).
88 destruct a as [[a1 a1pf] [a2 a2pf]].
89 destruct b as [[b1 b1pf] [b2 b2pf]].
90 destruct f as [[f1 f1pf] [f2 f2pf]].
92 exists (MC \ (pair_mor (pair_obj a1 a2) (pair_obj b1 b2) f1 f2)); auto.
95 Lemma mf_restricts_to_full_subcat_on_domain : Functor (MSC ×× MSC) MSC
96 mf_restricts_to_full_subcat_on_domain_fobj.
97 refine {| fmor := fun a b f => mf_restricts_to_full_subcat_on_domain_fmor f |};
98 unfold functor_restricts_to_full_subcat_on_domain_fmor; simpl; intros.
104 Definition subcat_i : MSC.
106 apply msc_contains_unit.
109 Lemma full_subcat_is_monoidal : MonoidalCat MSC _ mf_restricts_to_full_subcat_on_domain subcat_i.
113 Lemma inclusion_functor_monoidal : MonoidalFunctor full_subcat_is_monoidal MC (InclusionFunctor _ MSC).
118 Coercion full_subcat_is_monoidal : MonoidalSubCat >-> MonoidalCat.
120 Section ArrowInLanguage.
122 (* an Arrow In A Programming Language consists of... *)
124 (* a host language: *)
125 Context `(Host:ProgrammingLanguage).
127 (* ... for which Types(L) is cartesian: *)
128 Context {MF}(center_of_TypesL:MonoidalCat (TypesL _ _ Host) (fun x => (fst_obj _ _ x),,(snd_obj _ _ x)) MF []).
130 (* along with a monoidal subcategory of Z(Types(L)) *)
131 Context (VK:MonoidalSubCat center_of_TypesL).
133 (* a premonoidal category enriched in aforementioned full subcategory *)
134 Context (Kehom:center_of_TypesL -> center_of_TypesL -> @ob _ _ VK).
136 Context (KE:@ECategory (@ob _ _ VK) (@hom _ _ VK) VK _ VK (mon_i (full_subcat_is_monoidal VK)) (full_subcat_is_monoidal VK) center_of_TypesL Kehom).
138 Check (Underlying KE).
140 Context {kbo:center_of_TypesL -> center_of_TypesL -> center_of_TypesL}.
142 Context (kbc:@BinoidalCat center_of_TypesL _ (Underlying KE) kbo).
144 Check (@PreMonoidalCat)
145 Definition one' := @one _ _ _ (car_terminal(CartesianCat:=CC))
146 Context (K:@PreMonoidalCat _ _ KE kbo kbc ).
147 Context (CC:CartesianCat center_of_TypesL).
150 Definition K_enrichment : Enrichment.
151 refine {| enr_c := KE |}.
153 Context (K_surjective:SurjectiveEnrichment K_enrichment).
155 Check (@FreydCategory).
157 Definition ArrowInProgrammingLanguage :=
158 @FreydCategory _ _ _ _ _ _ center_of_TypesL _ _ _ _ K.
160 Definition ArrowsAreGeneralizedArrows (arrow:ArrowInProgrammingLanguage) : GeneralizedArrow K_enrichment Host.
161 refine {| ga_functor_monoidal := inclusion_functor_monoidal VK |}.
164 End GArrowInLanguage.