X-Git-Url: http://git.megacz.com/?p=coq-hetmet.git;a=blobdiff_plain;f=src%2FProgrammingLanguage.v;h=5ce624ff048fc5ec42ad6fcda35723bb37e8985d;hp=6dd9c714bbe28ca22f8a09634d18d5f7c667c5e0;hb=ec8ee5cde986e5b38bcae38cda9e63eba94f1d9f;hpb=e15a8b6d72e0b28af765acfda7ddad21b50704ee diff --git a/src/ProgrammingLanguage.v b/src/ProgrammingLanguage.v index 6dd9c71..5ce624f 100644 --- a/src/ProgrammingLanguage.v +++ b/src/ProgrammingLanguage.v @@ -1,7 +1,7 @@ (*********************************************************************************************************************************) (* ProgrammingLanguage *) (* *) -(* Basic assumptions about programming languages . *) +(* Basic assumptions about programming languages. *) (* *) (*********************************************************************************************************************************) @@ -27,22 +27,6 @@ Require Import FunctorCategories_ch7_7. Require Import NaturalDeduction. Require Import NaturalDeductionCategory. -Require Import FreydCategories. - -Require Import Reification. -Require Import GeneralizedArrow. -Require Import GeneralizedArrowFromReification. -Require Import ReificationFromGeneralizedArrow. - -(* - * Everything in the rest of this section is just groundwork meant to - * build up to the definition of the ProgrammingLanguage class, which - * appears at the end of the section. References to "the instance" - * mean instances of that class. Think of this section as being one - * big Class { ... } definition, except that we declare most of the - * stuff outside the curly brackets in order to take advantage of - * Coq's section mechanism. - *) Section Programming_Language. Context {T : Type}. (* types of the language *) @@ -50,12 +34,6 @@ Section Programming_Language. Context (Judg : Type). Context (sequent : Tree ??T -> Tree ??T -> Judg). Notation "cs |= ss" := (sequent cs ss) : pl_scope. - (* Because of term irrelevance we need only store the *erased* (def - * 4.4) trees; for this reason there is no Coq type directly - * corresponding to productions $e$ and $x$ of 4.1.1, and TreeOT can - * be used for productions $\Gamma$ and $\Sigma$ *) - - (* to do: sequent calculus equals natural deduction over sequents, theorem equals sequent with null antecedent, *) Context {Rule : Tree ??Judg -> Tree ??Judg -> Type}. @@ -65,24 +43,6 @@ Section Programming_Language. Open Scope nd_scope. Open Scope pl_scope. - (* - * - * Note that from this abstract interface, the terms (expressions) - * in the proof are not accessible at all; they don't need to be -- - * so long as we have access to the equivalence relation upon - * proof-conclusions. Moreover, hiding the expressions actually - * makes the encoding in CiC work out easier for two reasons: - * - * 1. Because the denotation function is provided a proof rather - * than a term, it is a total function (the denotation function is - * often undefined for ill-typed terms). - * - * 2. We can define arr_composition of proofs without having to know how - * to compose expressions. The latter task is left up to the client - * function which extracts an expression from a completed proof. - * - * This also means that we don't need an explicit proof obligation for 4.1.2. - *) Class ProgrammingLanguage := { pl_eqv : @ND_Relation Judg Rule where "pf1 === pf2" := (@ndr_eqv _ _ pl_eqv _ _ pf1 pf2) ; pl_tsr :> @TreeStructuralRules Judg Rule T sequent @@ -128,13 +88,13 @@ Section Programming_Language. Defined. Definition Types_first c : EFunctor TypesL TypesL (fun x => x,,c ). - refine {| efunc := fun x y => (nd_rule (@se_expand_right _ _ _ _ _ _ _ (@pl_sequent_join PL) c x y)) |}. + refine {| efunc := fun x y => (@se_expand_right _ _ _ _ _ _ _ (@pl_sequent_join PL) c x y) |}. intros; apply MonoidalCat_all_central. intros. unfold ehom. unfold hom. unfold identityProof. unfold eid. simpl. unfold identityProof. apply se_reflexive_right. intros. unfold ehom. unfold comp. simpl. unfold cutProof. - rewrite <- (@ndr_prod_preserves_comp _ _ pl_eqv _ _ [#se_expand_right _ c#] _ _ (nd_id1 (b|=c0)) - _ (nd_id1 (a,,c |= b,,c)) _ [#se_expand_right _ c#]). + rewrite <- (@ndr_prod_preserves_comp _ _ pl_eqv _ _ (se_expand_right _ c) _ _ (nd_id1 (b|=c0)) + _ (nd_id1 (a,,c |= b,,c)) _ (se_expand_right _ c)). setoid_rewrite (@ndr_comp_right_identity _ _ pl_eqv _ [a,, c |= b,, c]). setoid_rewrite (@ndr_comp_left_identity _ _ pl_eqv [b |= c0]). apply se_cut_right. @@ -142,13 +102,13 @@ Section Programming_Language. Definition Types_second c : EFunctor TypesL TypesL (fun x => c,,x). eapply Build_EFunctor. - instantiate (1:=(fun x y => (nd_rule (@se_expand_left _ _ _ _ _ _ _ (@pl_sequent_join PL) c x y)))). + instantiate (1:=(fun x y => ((@se_expand_left _ _ _ _ _ _ _ (@pl_sequent_join PL) c x y)))). intros; apply MonoidalCat_all_central. intros. unfold ehom. unfold hom. unfold identityProof. unfold eid. simpl. unfold identityProof. apply se_reflexive_left. intros. unfold ehom. unfold comp. simpl. unfold cutProof. - rewrite <- (@ndr_prod_preserves_comp _ _ pl_eqv _ _ [#se_expand_left _ c#] _ _ (nd_id1 (b|=c0)) - _ (nd_id1 (c,,a |= c,,b)) _ [#se_expand_left _ c#]). + rewrite <- (@ndr_prod_preserves_comp _ _ pl_eqv _ _ (se_expand_left _ c) _ _ (nd_id1 (b|=c0)) + _ (nd_id1 (c,,a |= c,,b)) _ (se_expand_left _ c)). setoid_rewrite (@ndr_comp_right_identity _ _ pl_eqv _ [c,,a |= c,,b]). setoid_rewrite (@ndr_comp_left_identity _ _ pl_eqv [b |= c0]). apply se_cut_left. @@ -161,10 +121,39 @@ Section Programming_Language. |}. Defined. - Definition Types_PreMonoidal : PreMonoidalCat Types_binoidal []. + Definition Types_assoc a b : Types_second a >>>> Types_first b <~~~> Types_first b >>>> Types_second a. + admit. + Defined. + + Definition Types_cancelr : Types_first [] <~~~> functor_id _. + admit. + Defined. + + Definition Types_cancell : Types_second [] <~~~> functor_id _. + admit. + Defined. + + Definition Types_assoc_ll a b : Types_second (a,,b) <~~~> Types_second b >>>> Types_second a. + admit. + Defined. + + Definition Types_assoc_rr a b : Types_first (a,,b) <~~~> Types_first a >>>> Types_first b. admit. Defined. + Instance Types_PreMonoidal : PreMonoidalCat Types_binoidal [] := + { pmon_assoc := Types_assoc + ; pmon_cancell := Types_cancell + ; pmon_cancelr := Types_cancelr + ; pmon_assoc_rr := Types_assoc_rr + ; pmon_assoc_ll := Types_assoc_ll + }. + admit. (* pentagon law *) + admit. (* triangle law *) + admit. (* assoc_rr/assoc coherence *) + admit. (* assoc_ll/assoc coherence *) + Defined. + Definition TypesEnrichedInJudgments : Enrichment. refine {| enr_c := TypesL |}. Defined. @@ -173,12 +162,17 @@ Section Programming_Language. { }. + Lemma CartesianEnrMonoidal (e:Enrichment) `(C:CartesianCat(Ob:= _)(Hom:= _)(C:=Underlying (enr_c e))) : MonoidalEnrichment e. + admit. + Defined. + (* need to prove that if we have cartesian tuples we have cartesian contexts *) Definition LanguagesWithProductsAreSMME : HasProductTypes -> SurjectiveMonicMonoidalEnrichment TypesEnrichedInJudgments. admit. Defined. End LanguageCategory. + End Programming_Language. Structure ProgrammingLanguageSMME := @@ -191,56 +185,5 @@ Structure ProgrammingLanguageSMME := }. Coercion plsmme_pl : ProgrammingLanguageSMME >-> ProgrammingLanguage. Coercion plsmme_smme : ProgrammingLanguageSMME >-> SurjectiveMonicMonoidalEnrichment. - -Section ArrowInLanguage. - Context (Host:ProgrammingLanguageSMME). - Context `(CC:CartesianCat (me_mon Host)). - Context `(K:@ECategory _ _ _ _ _ _ (@car_mn _ _ _ _ _ _ _ CC) C Kehom). - Context `(pmc:PreMonoidalCat K bobj mobj (@one _ _ _ (cartesian_terminal C))). - (* FIXME *) - (* - Definition ArrowInProgrammingLanguage := - @FreydCategory _ _ _ _ _ _ (@car_mn _ _ _ _ _ _ _ CC) _ _ _ _ pmc. - *) -End ArrowInLanguage. - -Section GArrowInLanguage. - Context (Guest:ProgrammingLanguageSMME). - Context (Host :ProgrammingLanguageSMME). - Definition GeneralizedArrowInLanguage := GeneralizedArrow Guest Host. - - (* FIXME - Definition ArrowsAreGeneralizedArrows : ArrowInProgrammingLanguage -> GeneralizedArrowInLanguage. - *) - Definition TwoLevelLanguage := Reification Guest Host (me_i Host). - - Context (GuestHost:TwoLevelLanguage). - - Definition FlatObject (x:TypesL _ _ Host) := - forall y1 y2, not ((reification_r_obj GuestHost y1 y2)=x). - - Definition FlatSubCategory := FullSubcategory (TypesL _ _ Host) FlatObject. - - Section Flattening. - - Context (F:Retraction (TypesL _ _ Host) FlatSubCategory). - Definition FlatteningOfReification := garrow_from_reification Guest Host GuestHost >>>> F. - Lemma FlatteningIsNotDestructive : - FlatteningOfReification >>>> retraction_retraction F >>>> RepresentableFunctor _ (me_i Host) ~~~~ GuestHost. - admit. - Qed. - - End Flattening. - -End GArrowInLanguage. - -Inductive NLevelLanguage : nat -> ProgrammingLanguageSMME -> Type := -| NLevelLanguage_zero : forall lang, NLevelLanguage O lang -| NLevelLanguage_succ : forall (L1 L2:ProgrammingLanguageSMME) n, - TwoLevelLanguage L1 L2 -> NLevelLanguage n L1 -> NLevelLanguage (S n) L2. - -Definition OmegaLevelLanguage : Type := - { f : nat -> ProgrammingLanguageSMME - & forall n, TwoLevelLanguage (f n) (f (S n)) }. - + Implicit Arguments ND [ Judgment ].