1 (*********************************************************************************************************************************)
2 (* HaskProgrammingLanguage: *)
4 (* System FC^\alpha is a ProgrammingLanguage. *)
6 (*********************************************************************************************************************************)
8 Generalizable All Variables.
9 Require Import Preamble.
10 Require Import General.
11 Require Import NaturalDeduction.
12 Require Import Coq.Strings.String.
13 Require Import Coq.Lists.List.
15 Require Import Algebras_ch4.
16 Require Import Categories_ch1_3.
17 Require Import Functors_ch1_4.
18 Require Import Isomorphisms_ch1_5.
19 Require Import ProductCategories_ch1_6_1.
20 Require Import OppositeCategories_ch1_6_2.
21 Require Import Enrichment_ch2_8.
22 Require Import Subcategories_ch7_1.
23 Require Import NaturalTransformations_ch7_4.
24 Require Import NaturalIsomorphisms_ch7_5.
25 Require Import MonoidalCategories_ch7_8.
26 Require Import Coherence_ch7_8.
28 Require Import HaskKinds.
29 Require Import HaskCoreTypes.
30 Require Import HaskLiterals.
31 Require Import HaskTyCons.
32 Require Import HaskStrongTypes.
33 Require Import HaskProof.
34 Require Import NaturalDeduction.
35 Require Import NaturalDeductionCategory.
37 Require Import HaskStrongTypes.
38 Require Import HaskStrong.
39 Require Import HaskProof.
40 Require Import HaskStrongToProof.
41 Require Import HaskProofToStrong.
42 Require Import ProgrammingLanguage.
46 (* The judgments any specific Γ,Δ form a category with proofs as morphisms *)
47 Section HaskProgrammingLanguage.
49 Context (ndr_systemfc:@ND_Relation _ Rule).
51 Context Γ (Δ:CoercionEnv Γ).
54 Definition JudgΓΔ := prod (Tree ??(LeveledHaskType Γ ★)) (Tree ??(LeveledHaskType Γ ★)).
56 Definition RuleΓΔ : Tree ??JudgΓΔ -> Tree ??JudgΓΔ -> Type :=
59 (mapOptionTree (fun j => Γ > Δ > fst j |- snd j) h)
60 (mapOptionTree (fun j => Γ > Δ > fst j |- snd j) c).
62 Definition SystemFCa_cut : forall a b c, ND RuleΓΔ ([(a,b)],,[(b,c)]) [(a,c)].
69 (* when the cut is a single leaf and the RHS is a single leaf: *)
76 set (RArrange Γ Δ _ _ _ (AuCanL [l0])) as rule.
77 apply org_fc with (r:=RArrange _ _ _ _ _ (AuCanL [_])).
79 eapply nd_comp; [ idtac | eapply nd_rule; apply org_fc with (r:=RArrange _ _ _ _ _ (ACanL _)) ].
83 assert (h0=h2). admit.
85 apply org_fc with (r:=@RLet Γ Δ [] a h1 h h2).
90 apply (Prelude_error "systemfc cut rule invoked with [a|=[b]] [[b]|=[]]").
91 apply (Prelude_error "systemfc cut rule invoked with [a|=[b]] [[b]|=[x,,y]]").
92 apply (Prelude_error "systemfc rule invoked with [a|=[]] [[]|=c]").
93 apply (Prelude_error "systemfc rule invoked with [a|=[b,,c]] [[b,,c]|=z]").
96 Instance SystemFCa_sequents : @SequentND _ RuleΓΔ _ _ :=
97 { snd_cut := SystemFCa_cut }.
98 apply Build_SequentND.
105 apply org_fc with (r:=RVar _ _ _ _).
108 apply org_fc with (r:=RVoid _ _ ).
111 eapply nd_comp; [ apply nd_llecnac | idtac ].
112 apply (nd_prod IHa1 IHa2).
114 apply org_fc with (r:=RJoin _ _ _ _ _ _).
124 Definition SystemFCa_left a b c : ND RuleΓΔ [(b,c)] [((a,,b),(a,,c))].
127 eapply nd_comp; [ apply nd_llecnac | eapply nd_comp; [ idtac | idtac ] ].
128 eapply nd_prod; [ apply snd_initial | apply nd_id ].
130 apply org_fc with (r:=RJoin Γ Δ a b a c).
135 Definition SystemFCa_right a b c : ND RuleΓΔ [(b,c)] [((b,,a),(c,,a))].
138 eapply nd_comp; [ apply nd_rlecnac | eapply nd_comp; [ idtac | idtac ] ].
139 eapply nd_prod; [ apply nd_id | apply snd_initial ].
141 apply org_fc with (r:=RJoin Γ Δ b a c a).
146 Instance SystemFCa_sequent_join : @ContextND _ _ _ _ SystemFCa_sequents :=
147 { cnd_expand_left := fun a b c => SystemFCa_left c a b
148 ; cnd_expand_right := fun a b c => SystemFCa_right c a b }.
150 intros; apply nd_rule. simpl.
151 apply (org_fc _ _ _ _ ((RArrange _ _ _ _ _ (AuAssoc _ _ _)))).
154 intros; apply nd_rule. simpl.
155 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (AAssoc _ _ _))); auto.
157 intros; apply nd_rule. simpl.
158 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (ACanL _))); auto.
160 intros; apply nd_rule. simpl.
161 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (ACanR _))); auto.
163 intros; apply nd_rule. simpl.
164 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (AuCanL _))); auto.
166 intros; apply nd_rule. simpl.
167 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (AuCanR _))); auto.
177 Instance OrgFC : @ND_Relation _ RuleΓΔ.
180 Instance OrgFC_SequentND_Relation : SequentND_Relation SystemFCa_sequent_join OrgFC.
184 Definition OrgFC_ContextND_Relation
185 : @ContextND_Relation _ _ _ _ _ SystemFCa_sequent_join OrgFC OrgFC_SequentND_Relation.
190 Instance SystemFCa : @ProgrammingLanguage (LeveledHaskType Γ ★) _ :=
191 { pl_eqv := OrgFC_ContextND_Relation
192 ; pl_snd := SystemFCa_sequents
195 End HaskProgrammingLanguage.