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 HaskLiteralsAndTyCons.
31 Require Import HaskStrongTypes.
32 Require Import HaskProof.
33 Require Import NaturalDeduction.
34 Require Import NaturalDeductionCategory.
36 Require Import HaskStrongTypes.
37 Require Import HaskStrong.
38 Require Import HaskProof.
39 Require Import HaskStrongToProof.
40 Require Import HaskProofToStrong.
41 Require Import ProgrammingLanguage.
45 (* The judgments any specific Γ,Δ form a category with proofs as morphisms *)
46 Section HaskProgrammingLanguage.
48 Context (ndr_systemfc:@ND_Relation _ Rule).
50 Context Γ (Δ:CoercionEnv Γ).
53 Definition JudgΓΔ := prod (Tree ??(LeveledHaskType Γ ★)) (Tree ??(LeveledHaskType Γ ★)).
55 Definition RuleΓΔ : Tree ??JudgΓΔ -> Tree ??JudgΓΔ -> Type :=
58 (mapOptionTree (fun j => Γ > Δ > fst j |- snd j) h)
59 (mapOptionTree (fun j => Γ > Δ > fst j |- snd j) c).
61 Definition SystemFCa_cut : forall a b c, ND RuleΓΔ ([(a,b)],,[(b,c)]) [(a,c)].
68 (* when the cut is a single leaf and the RHS is a single leaf: *)
75 set (RArrange Γ Δ _ _ _ (RuCanL [l0])) as rule.
76 apply org_fc with (r:=RArrange _ _ _ _ _ (RuCanL [_])).
78 eapply nd_comp; [ idtac | eapply nd_rule; apply org_fc with (r:=RArrange _ _ _ _ _ (RCanL _)) ].
82 assert (h0=h2). admit.
84 apply org_fc with (r:=@RLet Γ Δ [] a h1 h h2).
89 apply (Prelude_error "systemfc cut rule invoked with [a|=[b]] [[b]|=[]]").
90 apply (Prelude_error "systemfc cut rule invoked with [a|=[b]] [[b]|=[x,,y]]").
91 apply (Prelude_error "systemfc rule invoked with [a|=[]] [[]|=c]").
92 apply (Prelude_error "systemfc rule invoked with [a|=[b,,c]] [[b,,c]|=z]").
95 Instance SystemFCa_sequents : @SequentND _ RuleΓΔ _ _ :=
96 { snd_cut := SystemFCa_cut }.
97 apply Build_SequentND.
104 apply org_fc with (r:=RVar _ _ _ _).
107 apply org_fc with (r:=RVoid _ _ ).
110 eapply nd_comp; [ apply nd_llecnac | idtac ].
111 apply (nd_prod IHa1 IHa2).
113 apply org_fc with (r:=RJoin _ _ _ _ _ _).
123 Definition SystemFCa_left a b c : ND RuleΓΔ [(b,c)] [((a,,b),(a,,c))].
126 eapply nd_comp; [ apply nd_llecnac | eapply nd_comp; [ idtac | idtac ] ].
127 eapply nd_prod; [ apply snd_initial | apply nd_id ].
129 apply org_fc with (r:=RJoin Γ Δ a b a c).
134 Definition SystemFCa_right a b c : ND RuleΓΔ [(b,c)] [((b,,a),(c,,a))].
137 eapply nd_comp; [ apply nd_rlecnac | eapply nd_comp; [ idtac | idtac ] ].
138 eapply nd_prod; [ apply nd_id | apply snd_initial ].
140 apply org_fc with (r:=RJoin Γ Δ b a c a).
145 Instance SystemFCa_sequent_join : @ContextND _ _ _ _ SystemFCa_sequents :=
146 { cnd_expand_left := fun a b c => SystemFCa_left c a b
147 ; cnd_expand_right := fun a b c => SystemFCa_right c a b }.
149 intros; apply nd_rule. simpl.
150 apply (org_fc _ _ _ _ ((RArrange _ _ _ _ _ (RCossa _ _ _)))).
153 intros; apply nd_rule. simpl.
154 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (RAssoc _ _ _))); auto.
156 intros; apply nd_rule. simpl.
157 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (RCanL _))); auto.
159 intros; apply nd_rule. simpl.
160 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (RCanR _))); auto.
162 intros; apply nd_rule. simpl.
163 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (RuCanL _))); auto.
165 intros; apply nd_rule. simpl.
166 apply (org_fc _ _ _ _ (RArrange _ _ _ _ _ (RuCanR _))); auto.
176 Instance OrgFC : @ND_Relation _ RuleΓΔ.
179 Instance OrgFC_SequentND_Relation : SequentND_Relation SystemFCa_sequent_join OrgFC.
183 Definition OrgFC_ContextND_Relation
184 : @ContextND_Relation _ _ _ _ _ SystemFCa_sequent_join OrgFC OrgFC_SequentND_Relation.
189 Instance SystemFCa : @ProgrammingLanguage (LeveledHaskType Γ ★) _ :=
190 { pl_eqv := OrgFC_ContextND_Relation
191 ; pl_snd := SystemFCa_sequents
194 End HaskProgrammingLanguage.