1 (*********************************************************************************************************************************)
2 (* HaskProofCategory: *)
4 (* Natural Deduction proofs of the well-typedness of a Haskell term form a category *)
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 HaskKinds.
16 Require Import HaskCoreTypes.
17 Require Import HaskLiteralsAndTyCons.
18 Require Import HaskStrongTypes.
19 Require Import HaskProof.
20 Require Import NaturalDeduction.
21 Require Import NaturalDeductionCategory.
23 Require Import Algebras_ch4.
24 Require Import Categories_ch1_3.
25 Require Import Functors_ch1_4.
26 Require Import Isomorphisms_ch1_5.
27 Require Import ProductCategories_ch1_6_1.
28 Require Import OppositeCategories_ch1_6_2.
29 Require Import Enrichment_ch2_8.
30 Require Import Subcategories_ch7_1.
31 Require Import NaturalTransformations_ch7_4.
32 Require Import NaturalIsomorphisms_ch7_5.
33 Require Import MonoidalCategories_ch7_8.
34 Require Import Coherence_ch7_8.
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 Section HaskProofCategory.
47 Context (ndr_systemfc:@ND_Relation _ Rule).
49 (* Rules allowed in PCF; i.e. rules we know how to turn into GArrows *)
50 (* Rule_PCF consists of the rules allowed in flat PCF: everything except *)
51 (* AppT, AbsT, AppC, AbsC, Cast, Global, and some Case statements *)
52 Inductive Rule_PCF {Γ}{Δ} : ∀ h c, Rule (mapOptionTree (@UJudg2judg Γ Δ) h) (mapOptionTree (@UJudg2judg Γ Δ) c) -> Type :=
53 | PCF_RArrange : ∀ x y , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RCanL t a ))
54 | PCF_RCanR : ∀ t a , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RCanR t a ))
55 | PCF_RuCanL : ∀ t a , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RuCanL t a ))
56 | PCF_RuCanR : ∀ t a , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RuCanR t a ))
57 | PCF_RAssoc : ∀ t a b c , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RAssoc t a b c ))
58 | PCF_RCossa : ∀ t a b c , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RCossa t a b c ))
59 | PCF_RLeft : ∀ h c x , Rule (mapOptionTree (ext_tree_left x) h) (mapOptionTree (ext_tree_left x) c)
60 | PCF_RRight : ∀ h c x , Rule (mapOptionTree (ext_tree_right x) h) (mapOptionTree (ext_tree_right x) c)
61 | PCF_RExch : ∀ t a b , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RExch t a b ))
62 | PCF_RWeak : ∀ t a , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RWeak t a ))
63 | PCF_RCont : ∀ t a , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RURule (RCont t a ))
65 | PCF_RLit : ∀ Σ τ , Rule_PCF [ ] [_>>_>_|-_] (RLit Γ Δ Σ τ )
66 | PCF_RNote : ∀ Σ τ l n , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RNote Γ Δ Σ τ l n)
67 | PCF_RVar : ∀ σ l, Rule_PCF [ ] [_>>_>_|-_] (RVar Γ Δ σ l)
68 | PCF_RLam : ∀ Σ tx te q , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RLam Γ Δ Σ tx te q )
69 | PCF_RApp : ∀ Σ tx te p l, Rule_PCF ([_>>_>_|-_],,[_>>_>_|-_]) [_>>_>_|-_] (RApp Γ Δ Σ tx te p l)
70 | PCF_RLet : ∀ Σ σ₁ σ₂ p l, Rule_PCF ([_>>_>_|-_],,[_>>_>_|-_]) [_>>_>_|-_] (RLet Γ Δ Σ σ₁ σ₂ p l)
71 | PCF_RBindingGroup : ∀ b c d e , Rule_PCF ([_>>_>_|-_],,[_>>_>_|-_]) [_>>_>_|-_] (RBindingGroup _ _ b c d e)
72 | PCF_REmptyGroup : Rule_PCF [ ] [_>>_>_|-_] (REmptyGroup _ _ ).
74 (* | PCF_RLetRec : ∀ Σ₁ τ₁ τ₂ lev , Rule_PCF [_>>_>_|-_] [_>>_>_|-_] (RLetRec Γ Δ Σ₁ τ₁ τ₂ lev).*)
75 Implicit Arguments Rule_PCF [ ].
77 (* need int/boolean case *)
78 (* | PCF_RCase : ∀ T κlen κ θ l x , Rule_PCF (RCase Γ Δ T κlen κ θ l x) (* FIXME: only for boolean and int *)*)
80 Definition PCFR Γ Δ h c := { r:_ & Rule_PCF Γ Δ h c r }.
82 (* this wraps code-brackets, with the specified environment classifier, around a type *)
83 Definition brakifyType {Γ} (ec:HaskTyVar Γ ★)(lt:LeveledHaskType Γ ★) : LeveledHaskType Γ ★ :=
85 t @@ l => HaskBrak ec t @@ l
88 Definition brakifyu {Γ}{Δ}(v:HaskTyVar Γ ★)(j:UJudg Γ Δ) : UJudg Γ Δ :=
91 Γ >> Δ > mapOptionTree (brakifyType v) Σ |- mapOptionTree (brakifyType v) τ
95 (* An organized deduction has been reorganized into contiguous blocks whose
96 * hypotheses (if any) and conclusion have the same Γ and Δ and a fixed nesting depth. The boolean
97 * indicates if non-PCF rules have been used *)
98 Inductive OrgR : bool -> nat -> forall Γ Δ, Tree ??(UJudg Γ Δ) -> Tree ??(UJudg Γ Δ) -> Type :=
100 | org_pcf : forall n Γ Δ h c b,
101 PCFR Γ Δ h c -> OrgR b n Γ Δ h c
103 | org_fc : forall n Γ Δ h c,
104 ND Rule (mapOptionTree UJudg2judg h) (mapOptionTree UJudg2judg c) -> OrgR true n Γ Δ h c
106 | org_nest : forall n Γ Δ h c b v,
108 OrgR b (S n) _ _ (mapOptionTree (brakifyu v) h) (mapOptionTree (brakifyu v) c)
111 Definition OrgND b n Γ Δ := ND (OrgR b n Γ Δ).
113 Definition mkEsc {Γ}{Δ}(j:Tree ??(UJudg Γ Δ)) v h
115 (mapOptionTree (@UJudg2judg Γ Δ) h)
116 (mapOptionTree (fun j => @UJudg2judg Γ Δ (brakifyu v j)) h).
120 Definition mkBrak {Γ}{Δ}(j:Tree ??(UJudg Γ Δ)) v h
122 (mapOptionTree (fun j => @UJudg2judg Γ Δ (brakifyu v j)) h)
123 (mapOptionTree (@UJudg2judg Γ Δ ) h).
127 (* any proof in organized form can be "dis-organized" *)
128 Definition unOrgR b n Γ Δ : forall h c, OrgR b n Γ Δ h c ->
129 ND Rule (mapOptionTree (@UJudg2judg Γ Δ) h) (mapOptionTree (@UJudg2judg Γ Δ) c).
140 rewrite <- mapOptionTree_compose.
141 rewrite <- mapOptionTree_compose.
144 eapply nd_comp; [ idtac | apply (mkEsc c) ].
148 Definition unOrgND b n Γ Δ h c :
149 ND (OrgR b n Γ Δ) h c -> ND Rule (mapOptionTree (@UJudg2judg Γ Δ) h) (mapOptionTree (@UJudg2judg Γ Δ) c)
150 := nd_map' (@UJudg2judg Γ Δ) (unOrgR b n Γ Δ).
152 Instance OrgNDR b n Γ Δ : @ND_Relation _ (OrgR b n Γ Δ) :=
153 { ndr_eqv := fun a b f g => (unOrgND _ _ _ _ _ _ f) === (unOrgND _ _ _ _ _ _ g) }.
170 Hint Constructors Rule_Flat.
172 Definition SystemFC_SC n : @SequentCalculus _ (RuleSystemFCa n) _ (mkJudg Γ Δ).
173 apply Build_SequentCalculus.
179 apply sfc_flat with (r:=RVar _ _ _ _).
182 apply sfc_flat with (r:=REmptyGroup _ _).
184 eapply nd_comp; [ apply nd_llecnac | idtac ].
185 eapply nd_comp; [ eapply nd_prod | idtac ].
189 apply sfc_flat with (r:=RBindingGroup _ _ _ _ _ _ ).
193 Existing Instance SystemFC_SC.
195 Lemma systemfc_cut n : ∀a b c,
196 ND (RuleSystemFCa n) ([Γ > Δ > a |- b],, [Γ > Δ > b |- c]) [Γ > Δ > a |- c].
201 Lemma systemfc_cutrule n
202 : @CutRule _ (RuleSystemFCa n) _ (mkJudg Γ Δ) (ndr_systemfc n) (SystemFC_SC n).
203 apply Build_CutRule with (nd_cut:=systemfc_cut n).
209 Definition systemfc_left n a b c : ND (RuleSystemFCa n) [Γ > Δ > b |- c] [Γ > Δ > a,, b |- a,, c].
210 eapply nd_comp; [ apply nd_llecnac | idtac ].
211 eapply nd_comp; [ eapply nd_prod | idtac ].
214 apply sfc_flat with (r:=RBindingGroup _ _ _ _ _ _ ).
217 apply nd_seq_reflexive.
221 Definition systemfc_right n a b c : ND (RuleSystemFCa n) [Γ > Δ > b |- c] [Γ > Δ > b,,a |- c,,a].
222 eapply nd_comp; [ apply nd_rlecnac | idtac ].
223 eapply nd_comp; [ eapply nd_prod | idtac ].
225 apply (nd_seq_reflexive a).
227 apply sfc_flat with (r:=RBindingGroup _ _ _ _ _ _ ).
232 Definition systemfc_expansion n
233 : @SequentExpansion _ (RuleSystemFCa n) _ (mkJudg Γ Δ) (ndr_systemfca n) (SystemFC_SC n) (systemfc_cutrule n).
234 Check (@Build_SequentExpansion).
235 apply (@Build_SequentExpansion _ _ _ _ (ndr_systemfca n) _ _ (systemfc_left n) (systemfc_right n)).
236 refine {| se_expand_left:=systemfc_left n
237 ; se_expand_right:=systemfc_right n |}.
242 Instance SystemFCa n Γ Δ : @ProgrammingLanguage _ _ (@mkUJudg Γ Δ) (OrgR true n Γ Δ) :=
243 { pl_eqv := OrgNDR true n Γ Δ
244 ; pl_tsr := _ (*@TreeStructuralRules Judg Rule T sequent*)
247 ; pl_sequent_join := _
249 apply Build_TreeStructuralRules; intros; unfold eqv; unfold hom; simpl.
250 apply nd_rule; apply org_fc; apply nd_rule; simpl. apply (RURule _ _ _ _ (RCossa _ a b c)).
251 apply nd_rule; apply org_fc; apply nd_rule; simpl; apply (RURule _ _ _ _ (RAssoc _ a b c)).
252 apply nd_rule; apply org_fc; apply nd_rule; simpl; apply (RURule _ _ _ _ (RCanL _ a )).
253 apply nd_rule; apply org_fc; apply nd_rule; simpl; apply (RURule _ _ _ _ (RCanR _ a )).
254 apply nd_rule; apply org_fc; apply nd_rule; simpl; apply (RURule _ _ _ _ (RuCanL _ a )).
255 apply nd_rule; apply org_fc; apply nd_rule; simpl; apply (RURule _ _ _ _ (RuCanR _ a )).
258 (* "flat" SystemFC: no brackets allowed *)
259 Instance SystemFC Γ Δ : @ProgrammingLanguage _ _ (@mkUJudg Γ Δ) (OrgR true O Γ Δ) :=
260 { pl_eqv := OrgNDR true O Γ Δ
261 ; pl_tsr := _ (*@TreeStructuralRules Judg Rule T sequent*)
264 ; pl_sequent_join := _
269 Instance PCF n Γ Δ : @ProgrammingLanguage _ _ (@mkUJudg Γ Δ) (OrgR false n Γ Δ) :=
270 { pl_eqv := OrgNDR false n Γ Δ
271 ; pl_tsr := _ (*@TreeStructuralRules Judg Rule T sequent*)
274 ; pl_sequent_join := _
276 apply Build_TreeStructuralRules; intros; unfold eqv; unfold hom; simpl.
277 apply nd_rule; apply org_pcf; simpl; exists (RCossa _ a b c); apply (PCF_RURule [_>>_>_|-_] [_>>_>_|-_]).
278 apply nd_rule; apply org_pcf; simpl; exists (RAssoc _ a b c); apply (PCF_RURule [_>>_>_|-_] [_>>_>_|-_]).
279 apply nd_rule; apply org_pcf; simpl; exists (RCanL _ a ); apply (PCF_RURule [_>>_>_|-_] [_>>_>_|-_]).
280 apply nd_rule; apply org_pcf; simpl; exists (RCanR _ a ); apply (PCF_RURule [_>>_>_|-_] [_>>_>_|-_]).
281 apply nd_rule; apply org_pcf; simpl; exists (RuCanL _ a ); apply (PCF_RURule [_>>_>_|-_] [_>>_>_|-_]).
282 apply nd_rule; apply org_pcf; simpl; exists (RuCanR _ a ); apply (PCF_RURule [_>>_>_|-_] [_>>_>_|-_]).
286 Definition code2garrow Γ (ec t:RawHaskType Γ ★) :=
288 (* | TApp ★ ★ (TApp _ ★ TArrow tx) t' => code2garrow0 ec tx t'*)
289 | _ => code2garrow0 ec unitType t
292 Fixpoint typeMap {TV}{κ}(ty:@RawHaskType TV κ) : @RawHaskType TV κ :=
293 match ty as TY in RawHaskType _ K return RawHaskType TV K with
294 | TCode ec t => code2garrow _ ec t
295 | TApp _ _ t1 t2 => TApp (typeMap t1) (typeMap t2)
296 | TAll _ f => TAll _ (fun tv => typeMap (f tv))
297 | TCoerc _ t1 t2 t3 => TCoerc (typeMap t1) (typeMap t2) (typeMap t3)
301 | TyFunApp tf rhtl => (* FIXME *) TyFunApp tf rhtl
304 Definition typeMapL {Γ}(lht:LeveledHaskType Γ ★) : LeveledHaskType Γ ★ :=
306 (* | t @@ nil => (fun TV ite => typeMap (t TV ite)) @@ lev*)
307 | t @@ lev => (fun TV ite => typeMap (t TV ite)) @@ lev
311 (* gathers a tree of guest-language types into a single host-language types via the tensor *)
312 Definition tensorizeType {Γ} (lt:Tree ??(LeveledHaskType Γ ★)) : HaskType Γ ★.
316 Definition mkGA {Γ} : HaskType Γ ★ -> HaskType Γ ★ -> HaskType Γ ★.
320 Definition guestJudgmentAsGArrowType {Γ}{Δ} (lt:UJudg Γ Δ) : LeveledHaskType Γ ★ :=
323 (mkGA (tensorizeType x) (tensorizeType y)) @@ nil
326 Fixpoint obact n {Γ}{Δ}(X:Tree ??(UJudg Γ Δ)) : Tree ??(LeveledHaskType Γ ★) :=
328 | 0 => mapOptionTree guestJudgmentAsGArrowType X
329 | S n' => let t := obact n' X
330 in [guestJudgmentAsGArrowType (Γ >> Δ > [] |- t )]
334 * Here it is, what you've all been waiting for! When reading this,
335 * it might help to have the definition for "Inductive ND" (see
336 * NaturalDeduction.v) handy as a cross-reference.
338 Definition FlatteningFunctor_fmor {Γ}{Δ}
340 (h~~{JudgmentsL _ _ (PCF 0 Γ Δ)}~~>c) ->
341 ((obact 0 h)~~{TypesL _ _ (SystemFC Γ Δ)}~~>(obact 0 c)).
342 unfold hom; unfold ob; unfold ehom; simpl; unfold mon_i; unfold obact; intros.
346 (* the proof from no hypotheses of no conclusions (nd_id0) becomes REmptyGroup *)
347 apply nd_rule; apply org_fc; simpl. apply nd_rule. apply REmptyGroup.
349 (* the proof from hypothesis X of conclusion X (nd_id1) becomes RVar *)
350 apply nd_rule; apply org_fc; simpl. apply nd_rule. destruct (guestJudgmentAsGArrowType h). apply RVar.
352 (* the proof from hypothesis X of no conclusions (nd_weak) becomes RWeak;;REmptyGroup *)
353 apply nd_rule; apply org_fc; simpl.
354 eapply nd_comp; [ idtac | apply (nd_rule (RURule _ _ _ _ (RWeak _ _))) ].
355 apply nd_rule. apply REmptyGroup.
357 (* the proof from hypothesis X of two identical conclusions X,,X (nd_copy) becomes RVar;;RBindingGroup;;RCont *)
358 eapply nd_comp; [ idtac | eapply nd_rule; eapply org_fc; apply (nd_rule (RURule _ _ _ _ (RCont _ _))) ].
359 eapply nd_comp; [ apply nd_llecnac | idtac ].
360 set (nd_seq_reflexive(SequentCalculus:=@pl_sc _ _ _ _ (SystemFC Γ Δ)) (mapOptionTree guestJudgmentAsGArrowType h)) as q.
365 apply nd_rule; eapply org_fc.
370 (* nd_prod becomes nd_llecnac;;nd_prod;;RBindingGroup *)
372 apply (nd_llecnac ;; nd_prod IHX1 IHX2).
373 apply nd_rule; apply org_fc; simpl.
374 eapply nd_rule. apply RBindingGroup.
376 (* nd_comp becomes pl_subst (aka nd_cut) *)
378 apply (nd_llecnac ;; nd_prod IHX1 IHX2).
379 clear IHX1 IHX2 X1 X2.
380 apply (@nd_cut _ _ _ _ _ _ (@pl_subst _ _ _ _ (SystemFC Γ Δ))).
382 (* nd_cancell becomes RVar;;RuCanL *)
384 [ idtac | eapply nd_rule; apply org_fc; simpl; apply nd_rule; apply (RURule _ _ _ _ (RuCanL _ _)) ].
385 apply (nd_seq_reflexive(SequentCalculus:=@pl_sc _ _ _ _ (SystemFC Γ Δ))).
387 (* nd_cancelr becomes RVar;;RuCanR *)
389 [ idtac | eapply nd_rule; apply org_fc; simpl; apply nd_rule; apply (RURule _ _ _ _ (RuCanR _ _)) ].
390 apply (nd_seq_reflexive(SequentCalculus:=@pl_sc _ _ _ _ (SystemFC Γ Δ))).
392 (* nd_llecnac becomes RVar;;RCanL *)
394 [ idtac | eapply nd_rule; apply org_fc; simpl; apply nd_rule; apply (RURule _ _ _ _ (RCanL _ _)) ].
395 apply (nd_seq_reflexive(SequentCalculus:=@pl_sc _ _ _ _ (SystemFC Γ Δ))).
397 (* nd_rlecnac becomes RVar;;RCanR *)
399 [ idtac | eapply nd_rule; apply org_fc; simpl; apply nd_rule; apply (RURule _ _ _ _ (RCanR _ _)) ].
400 apply (nd_seq_reflexive(SequentCalculus:=@pl_sc _ _ _ _ (SystemFC Γ Δ))).
402 (* nd_assoc becomes RVar;;RAssoc *)
404 [ idtac | eapply nd_rule; apply org_fc; simpl; apply nd_rule; apply (RURule _ _ _ _ (RAssoc _ _ _ _)) ].
405 apply (nd_seq_reflexive(SequentCalculus:=@pl_sc _ _ _ _ (SystemFC Γ Δ))).
407 (* nd_coss becomes RVar;;RCossa *)
409 [ idtac | eapply nd_rule; apply org_fc; simpl; apply nd_rule; apply (RURule _ _ _ _ (RCossa _ _ _ _)) ].
410 apply (nd_seq_reflexive(SequentCalculus:=@pl_sc _ _ _ _ (SystemFC Γ Δ))).
412 (* now, the interesting stuff: the inference rules of Judgments(PCF) become GArrow-parameterized terms *)
413 refine (match r as R in OrgR B N G D H C return
416 | O => if B then True
417 else ND (OrgR true 0 G D)
419 [G >> D > mapOptionTree guestJudgmentAsGArrowType H |- mapOptionTree guestJudgmentAsGArrowType C]
421 | org_pcf n Γ Δ h c b r => _
422 | org_fc n Γ Δ h c r => _
423 | org_nest n Γ Δ h c b v q => _
424 end); destruct n; try destruct b; try apply I.
428 rename r0 into r; rename h0 into h; rename c0 into c; rename Γ0 into Γ; rename Δ0 into Δ.
430 refine (match r as R in Rule_PCF _ _ H C _ with
431 | PCF_RURule h c r => let case_RURule := tt in _
432 | PCF_RLit Σ τ => let case_RLit := tt in _
433 | PCF_RNote Σ τ l n => let case_RNote := tt in _
434 | PCF_RVar σ l=> let case_RVar := tt in _
435 | PCF_RLam Σ tx te q => let case_RLam := tt in _
436 | PCF_RApp Σ tx te p l=> let case_RApp := tt in _
437 | PCF_RLet Σ σ₁ σ₂ p l=> let case_RLet := tt in _
438 | PCF_RBindingGroup b c d e => let case_RBindingGroup := tt in _
439 | PCF_REmptyGroup => let case_REmptyGroup := tt in _
440 (* | PCF_RCase T κlen κ θ l x => let case_RCase := tt in _*)
441 (* | PCF_RLetRec Σ₁ τ₁ τ₂ lev => let case_RLetRec := tt in _*)
444 rename r0 into r; rename h0 into h; rename c0 into c.
446 destruct case_RURule.
448 | RLeft a b c r => let case_RLeft := tt in _
449 | RRight a b c r => let case_RRight := tt in _
450 | RCanL a b => let case_RCanL := tt in _
451 | RCanR a b => let case_RCanR := tt in _
452 | RuCanL a b => let case_RuCanL := tt in _
453 | RuCanR a b => let case_RuCanR := tt in _
454 | RAssoc a b c d => let case_RAssoc := tt in _
455 | RCossa a b c d => let case_RCossa := tt in _
456 | RExch a b c => let case_RExch := tt in _
457 | RWeak a b => let case_RWeak := tt in _
458 | RCont a b => let case_RCont := tt in _
469 destruct case_RuCanL.
473 destruct case_RuCanR.
477 destruct case_RAssoc.
481 destruct case_RCossa.
489 destruct case_RRight.
509 (* hey cool, I figured out how to pass CoreNote's through... *)
525 (* ga_curry, but try to avoid this someday in the future if the argument type isn't a function *)
533 (* ga_comp! perhaps this means the ga_curry avoidance can be done by turning lambdas into lets? *)
536 destruct case_RBindingGroup.
537 (* ga_first+ga_second; technically this assumes a specific evaluation order, which is bad *)
540 destruct case_REmptyGroup.
545 Instance FlatteningFunctor {n}{Γ}{Δ} : Functor (JudgmentsL _ _ (PCF n Γ Δ)) (TypesL _ _ (SystemFCa n Γ Δ)) obact :=
546 { fmor := FlatteningFunctor_fmor }.
547 unfold hom; unfold ob; unfold ehom; intros; simpl.
550 Definition productifyType {Γ} (lt:Tree ??(LeveledHaskType Γ ★)) : LeveledHaskType Γ ★.
554 Definition exponent {Γ} : LeveledHaskType Γ ★ -> LeveledHaskType Γ ★ -> LeveledHaskType Γ ★.
558 Definition brakify {Γ}(Σ τ:Tree ??(LeveledHaskType Γ ★)) := exponent (productifyType Σ) (productifyType τ).
560 Definition brakifyJudg (j:Judg) : Judg :=
563 Γ > Δ > [] |- [brakify Σ τ]
566 Definition brakifyUJudg (j:Judg) : Judg :=
569 Γ > Δ > [] |- [brakify Σ τ]
575 Context (ndr_pcf :forall n Γ Δ, @ND_Relation _ (@RulePCF Γ Δ n)).
578 Instance PCF n Γ Δ : @ProgrammingLanguage _ _ (mkJudg Γ Δ) (@RulePCF Γ Δ n) :=
580 ; pl_tsr := _ (*@TreeStructuralRules Judg Rule T sequent*)
581 ; pl_sc := _ (*@SequentCalculus Judg Rule _ sequent*)
582 ; pl_subst := _ (*@CutRule Judg Rule _ sequent pl_eqv pl_sc*)
583 ; pl_sequent_join := _ (*@SequentExpansion Judg Rule T sequent pl_eqv pl_sc pl_subst*)
587 Inductive RuleX : nat -> Tree ??Judg -> Tree ??Judg -> Type :=
588 | x_flat : forall n h c (r:Rule h c), Rule_Flat r -> RuleX n h c
589 | x_nest : forall n Γ Δ h c, ND (@RulePCF Γ Δ n) h c ->
590 RuleX (S n) (mapOptionTree brakifyJudg h) (mapOptionTree brakifyJudg c).
595 Context (ndr:@ND_Relation _ (RuleX (S n))).
597 Definition SystemFCa' := Judgments_Category ndr.
599 Definition ReificationFunctor_fmor Γ Δ
601 (h~~{JudgmentsL _ _ (PCF n Γ Δ)}~~>c) ->
602 ((mapOptionTree brakifyJudg h)~~{SystemFCa'}~~>(mapOptionTree brakifyJudg c)).
603 unfold hom; unfold ob; simpl.
610 Definition ReificationFunctor Γ Δ : Functor (JudgmentsL _ _ (PCF n Γ Δ)) SystemFCa' (mapOptionTree brakifyJudg).
611 refine {| fmor := ReificationFunctor_fmor Γ Δ |}; unfold hom; unfold ob; simpl ; intros.
612 unfold ReificationFunctor_fmor; simpl.
614 unfold ReificationFunctor_fmor; simpl.
616 unfold ReificationFunctor_fmor; simpl.
620 Definition FlatteningFunctor Γ Δ : Functor (JudgmentsL _ _ (PCF n Γ Δ)) SystemFCa' (mapOptionTree brakify).
621 refine {| fmor := ReificationFunctor_fmor Γ Δ |}; unfold hom; unfold ob; simpl ; intros.
622 unfold ReificationFunctor_fmor; simpl.
624 unfold ReificationFunctor_fmor; simpl.
626 unfold ReificationFunctor_fmor; simpl.
630 Definition PCF_SMME (n:nat)(Γ:TypeEnv)(Δ:CoercionEnv Γ) : ProgrammingLanguageSMME.
631 refine {| plsmme_pl := PCF n Γ Δ |}.
635 Definition SystemFCa_SMME (n:nat)(Γ:TypeEnv)(Δ:CoercionEnv Γ) : ProgrammingLanguageSMME.
636 refine {| plsmme_pl := SystemFCa n Γ Δ |}.
640 Definition ReificationFunctorMonoidal n : MonoidalFunctor (JudgmentsN n) (JudgmentsN (S n)) (ReificationFunctor n).
645 Definition PCF_SystemFCa_two_level n Γ Δ : TwoLevelLanguage (PCF_SMME n Γ Δ) (SystemFCa_SMME (S n) Γ Δ).
647 (* ... and the retraction exists *)
650 (* Any particular proof in HaskProof is only finitely large, so it uses only finitely many levels of nesting, so
651 * it falls within (SystemFCa n) for some n. This function calculates that "n" and performs the translation *)
653 Definition HaskProof_to_SystemFCa :
654 forall h c (pf:ND Rule h c),
655 { n:nat & h ~~{JudgmentsL (SystemFCa_SMME n)}~~> c }.
658 (* for every n we have a functor from the category of (n+1)-bounded proofs to the category of n-bounded proofs *)
661 Definition makeTree : Tree ??(LeveledHaskType Γ ★) -> HaskType Γ ★.
665 Definition flattenType n (j:JudgmentsN n) : TypesN n.
668 refine (mapOptionTree _ j).
670 destruct j as [ Γ' Δ' Σ τ ].
671 assert (Γ'=Γ). admit.
675 refine (HaskBrak _ ( (makeTree Σ) ---> (makeTree τ) )); intros.
679 Definition FlattenFunctor_fmor n :
681 (h~~{JudgmentsN n}~~>c) ->
682 ((flattenType n h)~~{TypesN n}~~>(flattenType n c)).
684 unfold hom in *; simpl.
692 Definition FlattenFunctor n : Functor (JudgmentsN n) (TypesN n) (flattenType n).
693 refine {| fmor := FlattenFunctor_fmor n |}; intros.
700 Implicit Arguments Rule_PCF [ [h] [c] ].
701 Implicit Arguments BoundedRule [ ].
705 Definition code2garrow0 {Γ}(ec t1 t2:RawHaskType Γ ★) : RawHaskType Γ ★.
708 Definition code2garrow Γ (ec t:RawHaskType Γ ★) :=
710 (* | TApp ★ ★ (TApp _ ★ TArrow tx) t' => code2garrow0 ec tx t'*)
711 | _ => code2garrow0 ec unitType t
714 Fixpoint typeMap {TV}{κ}(ty:@RawHaskType TV κ) : @RawHaskType TV κ :=
715 match ty as TY in RawHaskType _ K return RawHaskType TV K with
716 | TCode ec t => code2garrow _ ec t
717 | TApp _ _ t1 t2 => TApp (typeMap t1) (typeMap t2)
718 | TAll _ f => TAll _ (fun tv => typeMap (f tv))
719 | TCoerc _ t1 t2 t3 => TCoerc (typeMap t1) (typeMap t2) (typeMap t3)
723 | TyFunApp tf rhtl => (* FIXME *) TyFunApp tf rhtl
726 Definition typeMapL {Γ}(lht:LeveledHaskType Γ ★) : LeveledHaskType Γ ★ :=
728 (* | t @@ nil => (fun TV ite => typeMap (t TV ite)) @@ lev*)
729 | t @@ lev => (fun TV ite => typeMap (t TV ite)) @@ lev
732 Definition coMap {Γ}(ck:HaskCoercionKind Γ) :=
733 fun TV ite => match ck TV ite with
734 | mkRawCoercionKind _ t1 t2 => mkRawCoercionKind _ (typeMap t1) (typeMap t2)
737 Definition flattenCoercion {Γ}{Δ}{ck}(hk:HaskCoercion Γ Δ ck) : HaskCoercion Γ (map coMap Δ) (coMap ck).
741 Lemma update_typeMap Γ (lev:HaskLevel Γ) ξ v t
742 : (typeMap ○ (update_ξ ξ lev ((⟨v, t ⟩) :: nil)))
743 = ( update_ξ (typeMap ○ ξ) lev ((⟨v, typeMap_ t ⟩) :: nil)).
747 Lemma foo κ Γ σ τ : typeMap_ (substT σ τ) = substT(Γ:=Γ)(κ₁:=κ) (fun TV ite => typeMap ○ σ TV ite) τ.
751 Lemma lit_lemma lit Γ : typeMap_ (literalType lit) = literalType(Γ:=Γ) lit.
756 Definition flatten : forall h c, Rule h c -> @ND Judg Rule (mapOptionTree flattenJudgment h) (mapOptionTree flattenJudgment c).
758 refine (match r as R in Rule H C return ND Rule (mapOptionTree flattenJudgment H) (mapOptionTree flattenJudgment C) with
759 | RURule a b c d e => let case_RURule := tt in _
760 | RNote Γ Δ Σ τ l n => let case_RNote := tt in _
761 | RLit Γ Δ l _ => let case_RLit := tt in _
762 | RVar Γ Δ σ p => let case_RVar := tt in _
763 | RGlobal Γ Δ σ l wev => let case_RGlobal := tt in _
764 | RLam Γ Δ Σ tx te x => let case_RLam := tt in _
765 | RCast Γ Δ Σ σ τ γ x => let case_RCast := tt in _
766 | RAbsT Γ Δ Σ κ σ a => let case_RAbsT := tt in _
767 | RAppT Γ Δ Σ κ σ τ y => let case_RAppT := tt in _
768 | RAppCo Γ Δ Σ κ σ₁ σ₂ γ σ l => let case_RAppCo := tt in _
769 | RAbsCo Γ Δ Σ κ σ σ₁ σ₂ y => let case_RAbsCo := tt in _
770 | RApp Γ Δ Σ₁ Σ₂ tx te p => let case_RApp := tt in _
771 | RLet Γ Δ Σ₁ Σ₂ σ₁ σ₂ p => let case_RLet := tt in _
772 | RBindingGroup Γ p lri m x q => let case_RBindingGroup := tt in _
773 | REmptyGroup _ _ => let case_REmptyGroup := tt in _
774 | RBrak Σ a b c n m => let case_RBrak := tt in _
775 | REsc Σ a b c n m => let case_REsc := tt in _
776 | RCase Γ Δ lev tc Σ avars tbranches alts => let case_RCase := tt in _
777 | RLetRec Γ Δ lri x y t => let case_RLetRec := tt in _
780 destruct case_RURule.
792 eapply nd_rule. simpl. apply RNote; auto.
797 set (@RNote Γ Δ Σ τ l) as q.
800 Definition flatten' {h}{c} (pf:ND Rule h c) := nd_map' flattenJudgment flatten pf.
803 @ND Judgment1 Rule1 (mapOptionTree f h) (mapOptionTree f c).
805 refine (fix flatten : forall Γ Δ Σ τ
806 (pf:SCND Rule [] [Γ > Δ > Σ |- τ ]) :
807 SCND Rule [] [Γ > Δ > mapOptionTree typeMap Σ |- mapOptionTree typeMap τ ] :=
809 | scnd_comp : forall ht ct c , SCND ht ct -> Rule ct [c] -> SCND ht [c]
810 | scnd_weak : forall c , SCND c []
811 | scnd_leaf : forall ht c , SCND ht [c] -> SCND ht [c]
812 | scnd_branch : forall ht c1 c2, SCND ht c1 -> SCND ht c2 -> SCND ht (c1,,c2)
813 Expr Γ Δ ξ τ -> Expr Γ (map coMap Δ) (typeMap ○ ξ) (typeMap τ).
817 Lemma all_lemma Γ κ σ l :
819 (@HaskTApp (κ :: Γ) κ (@weakF Γ κ ★ σ) (@FreshHaskTyVar Γ κ) @@
820 @weakL Γ κ l)) = (@typeMap Γ (@HaskTAll Γ κ σ @@ l)).
824 Definition flatten : forall Γ Δ ξ τ, Expr Γ Δ ξ τ -> Expr Γ (map coMap Δ) (typeMap ○ ξ) (typeMap τ).
825 refine (fix flatten Γ' Δ' ξ' τ' (exp:Expr Γ' Δ' ξ' τ') : Expr Γ' (map coMap Δ') (typeMap ○ ξ') (typeMap τ') :=
826 match exp as E in Expr G D X T return Expr G (map coMap D) (typeMap ○ X) (typeMap T) with
827 | EGlobal Γ Δ ξ t wev => EGlobal _ _ _ _ wev
828 | EVar Γ Δ ξ ev => EVar _ _ _ ev
829 | ELit Γ Δ ξ lit lev => let case_ELit := tt in _
830 | EApp Γ Δ ξ t1 t2 lev e1 e2 => EApp _ _ _ _ _ _ (flatten _ _ _ _ e1) (flatten _ _ _ _ e2)
831 | ELam Γ Δ ξ t1 t2 lev v e => let case_ELam := tt in _
832 | ELet Γ Δ ξ tv t l ev elet ebody => let case_ELet := tt in _
833 | ELetRec Γ Δ ξ lev t tree branches ebody => let case_ELetRec := tt in _
834 | ECast Γ Δ ξ t1 t2 γ lev e => let case_ECast := tt in _
835 | ENote Γ Δ ξ t n e => ENote _ _ _ _ n (flatten _ _ _ _ e)
836 | ETyLam Γ Δ ξ κ σ l e => let case_ETyLam := tt in _
837 | ECoLam Γ Δ κ σ σ₁ σ₂ ξ l e => let case_ECoLam := tt in _
838 | ECoApp Γ Δ κ σ₁ σ₂ γ σ ξ l e => let case_ECoApp := tt in _
839 | ETyApp Γ Δ κ σ τ ξ l e => let case_ETyApp := tt in _
840 | ECase Γ Δ ξ l tc tbranches atypes e alts' => let case_ECase := tt in _
842 | EEsc Γ Δ ξ ec t lev e => let case_EEsc := tt in _
843 | EBrak Γ Δ ξ ec t lev e => let case_EBrak := tt in _
844 end); clear exp ξ' τ' Γ' Δ'.
852 set (flatten _ _ _ _ e) as q.
853 rewrite update_typeMap in q.
854 apply (@ELam _ _ _ _ _ _ _ _ v q).
857 set (flatten _ _ _ _ ebody) as ebody'.
858 set (flatten _ _ _ _ elet) as elet'.
859 rewrite update_typeMap in ebody'.
860 apply (@ELet _ _ _ _ _ _ _ _ _ elet' ebody').
871 apply flattenCoercion in γ.
874 destruct case_ETyApp.
877 unfold HaskTAll in e.
878 unfold typeMap_ in e.
884 destruct case_ECoLam.
887 set (@ECoLam _ _ _ _ _ _ _ _ _ _ e) as x.
894 destruct case_ECoApp.
898 unfold mkHaskCoercionKind in *.
900 apply flattenCoercion in γ.
901 unfold coMap in γ at 2.
905 destruct case_ETyLam.
907 set (@ETyLam Unique _ Γ (map coMap Δ) (typeMap ○ ξ) κ (fun ite x => typeMap (σ x ite))) as e'.
908 unfold HaskTAll in *.
909 unfold typeMap_ in *.
910 rewrite <- foo in e'.
911 unfold typeMap in e'.
915 Set Printing Implicit.
925 destruct case_ELetRec.
929 (* This proof will work for any dynamic semantics you like, so
930 * long as those semantics are an ND_Relation (associativity,
931 * neutrality, etc) *)
932 Context (dynamic_semantics : @ND_Relation _ Rule).
934 Section SystemFC_Category.
939 Definition Context := Tree ??(LeveledHaskType Γ ★).
941 Notation "a |= b" := (Γ >> Δ > a |- b).
947 SystemFCa_initial_GArrow
950 Context (nd_eqv:@ND_Relation _ (@URule Γ Δ)).
951 Check (@ProgrammingLanguage).
952 Context (PL:@ProgrammingLanguage (LeveledHaskType Γ ★)
953 (fun x y => match x with x1|=x2 => match y with y1|=y2 => @URule Γ Δ)).
954 Definition JudgmentsFC := @Judgments_Category_CartesianCat _ (@URule Γ Δ) nd_eqv.
955 Definition TypesFC := @TypesL _ (@URule Γ Δ) nd_eqv.
957 (* The full subcategory of SystemFC(Γ,Δ) consisting only of judgments involving types at a fixed level. Note that
958 * code types are still permitted! *)
960 Context (lev:HaskLevel Γ).
962 Inductive ContextAtLevel : Context -> Prop :=
963 | contextAtLevel_nil : ContextAtLevel []
964 | contextAtLevel_leaf : forall τ, ContextAtLevel [τ @@ lev]
965 | contextAtLevel_branch : forall b1 b2, ContextAtLevel b1 -> ContextAtLevel b2 -> ContextAtLevel (b1,,b2).
967 Inductive JudgmentsAtLevel : JudgmentsFC -> Prop :=
968 | judgmentsAtLevel_nil : JudgmentsAtLevel []
969 | judgmentsAtLevel_leaf : forall c1 c2, ContextAtLevel c1 -> ContextAtLevel c2 -> JudgmentsAtLevel [c1 |= c2]
970 | judgmentsAtLevel_branch : forall j1 j2, JudgmentsAtLevel j1 -> JudgmentsAtLevel j2 -> JudgmentsAtLevel (j1,,j2).
972 Definition JudgmentsFCAtLevel := FullSubcategory JudgmentsFC JudgmentsAtLevel.
973 Definition TypesFCAtLevel := FullSubcategory TypesFC ContextAtLevel.
976 End SystemFC_Category.
978 Implicit Arguments TypesFC [ ].
981 Section EscBrak_Functor.
985 (Σ₁:Tree ??(@LeveledHaskType V)).
987 Definition EscBrak_Functor_Fobj
988 : SystemFC_Cat_Flat ((Σ₁,n)::past) -> SystemFC_Cat past
989 := mapOptionTree (fun q:Tree ??(@CoreType V) * Tree ??(@CoreType V) =>
990 let (a,s):=q in (Σ₁,,(``a)^^^n,[`<[ n |- encodeTypeTree_flat s ]>])).
993 Definition EscBrak_Functor_Fmor
994 : forall a b (f:a~~{SystemFC_Cat_Flat ((Σ₁,n)::past)}~~>b),
995 (EscBrak_Functor_Fobj a)~~{SystemFC_Cat past}~~>(EscBrak_Functor_Fobj b).
1005 Lemma esc_then_brak_is_id : forall a,
1006 ndr_eqv(ND_Relation:=ml_dynamic_semantics V) (nd_comp prepend_esc append_brak)
1007 (nd_id (mapOptionTree (ob2judgment past) (EscBrak_Functor_Fobj a))).
1011 Lemma brak_then_esc_is_id : forall a,
1012 ndr_eqv(ND_Relation:=ml_dynamic_semantics V) (nd_comp append_brak prepend_esc)
1013 (nd_id (mapOptionTree (ob2judgment_flat (((Σ₁,n)::past))) a)).
1017 Instance EscBrak_Functor
1018 : Functor (SystemFC_Cat_Flat ((Σ₁,n)::past)) (SystemFC_Cat past) EscBrak_Functor_Fobj :=
1019 { fmor := fun a b f => EscBrak_Functor_Fmor a b f }.
1020 intros; unfold EscBrak_Functor_Fmor; simpl in *.
1021 apply ndr_comp_respects; try reflexivity.
1022 apply ndr_comp_respects; try reflexivity.
1024 intros; unfold EscBrak_Functor_Fmor; simpl in *.
1025 set (@ndr_comp_left_identity _ _ (ml_dynamic_semantics V)) as q.
1027 apply esc_then_brak_is_id.
1028 intros; unfold EscBrak_Functor_Fmor; simpl in *.
1029 set (@ndr_comp_associativity _ _ (ml_dynamic_semantics V)) as q.
1030 repeat setoid_rewrite q.
1031 apply ndr_comp_respects; try reflexivity.
1032 apply ndr_comp_respects; try reflexivity.
1033 repeat setoid_rewrite <- q.
1034 apply ndr_comp_respects; try reflexivity.
1035 setoid_rewrite brak_then_esc_is_id.
1037 set (@ndr_comp_left_identity _ _ (fc_dynamic_semantics V)) as q.
1042 End EscBrak_Functor.
1046 Ltac rule_helper_tactic' :=
1048 | [ H : ?A = ?A |- _ ] => clear H
1049 | [ H : [?A] = [] |- _ ] => inversion H; clear H
1050 | [ H : [] = [?A] |- _ ] => inversion H; clear H
1051 | [ H : ?A,,?B = [] |- _ ] => inversion H; clear H
1052 | [ H : ?A,,?B = [?Y] |- _ ] => inversion H; clear H
1053 | [ H: ?A :: ?B = ?B |- _ ] => apply symmetry in H; apply list_cannot_be_longer_than_itself in H; destruct H
1054 | [ H: ?B = ?A :: ?B |- _ ] => apply list_cannot_be_longer_than_itself in H; destruct H
1055 | [ H: ?A :: ?C :: ?B = ?B |- _ ] => apply symmetry in H; apply list_cannot_be_longer_than_itself' in H; destruct H
1056 | [ H: ?B = ?A :: ?C :: ?B |- _ ] => apply list_cannot_be_longer_than_itself' in H; destruct H
1057 (* | [ H : Sequent T |- _ ] => destruct H *)
1058 (* | [ H : ?D = levelize ?C (?A |= ?B) |- _ ] => inversion H; clear H*)
1059 | [ H : [?A] = [?B] |- _ ] => inversion H; clear H
1060 | [ H : [] = mapOptionTree ?B ?C |- _ ] => apply mapOptionTree_on_nil in H; subst
1061 | [ H : [?A] = mapOptionTree ?B ?C |- _ ] => destruct C as [C|]; simpl in H; [ | inversion H ]; destruct C; simpl in H; simpl
1062 | [ H : ?A,,?B = mapOptionTree ?C ?D |- _ ] => destruct D as [D|] ; [destruct D|idtac]; simpl in H; inversion H
1065 Lemma fixit : forall a b f c1 c2, (@mapOptionTree a b f c1),,(mapOptionTree f c2) = mapOptionTree f (c1,,c2).
1069 Lemma grak a b f c : @mapOptionTree a b f c = [] -> [] = c.
1073 Definition append_brak_to_id : forall {c},
1075 (mapOptionTree (ob2judgment ((⟨Σ₁,n⟩) :: past)) c )
1076 (mapOptionTree (ob2judgment past) (EscBrak_Functor_Fobj c)).
1080 Definition append_brak : forall {h c}
1083 (mapOptionTree (ob2judgment ((⟨Σ₁,n⟩) :: past)) c )),
1086 (mapOptionTree (ob2judgment past) (EscBrak_Functor_Fobj c)).
1088 refine (fix append_brak h c nd {struct nd} :=
1094 (C=mapOptionTree (ob2judgment ((⟨Σ₁,n⟩) :: past)) c) ->
1095 ND_FC h (mapOptionTree (ob2judgment past) (EscBrak_Functor_Fobj c))
1097 | nd_id0 => let case_nd_id0 := tt in _
1098 | nd_id1 h => let case_nd_id1 := tt in _
1099 | nd_weak h => let case_nd_weak := tt in _
1100 | nd_copy h => let case_nd_copy := tt in _
1101 | nd_prod _ _ _ _ lpf rpf => let case_nd_prod := tt in _
1102 | nd_comp _ _ _ top bot => let case_nd_comp := tt in _
1103 | nd_rule _ _ rule => let case_nd_rule := tt in _
1104 | nd_cancell _ => let case_nd_cancell := tt in _
1105 | nd_cancelr _ => let case_nd_cancelr := tt in _
1106 | nd_llecnac _ => let case_nd_llecnac := tt in _
1107 | nd_rlecnac _ => let case_nd_rlecnac := tt in _
1108 | nd_assoc _ _ _ => let case_nd_assoc := tt in _
1109 | nd_cossa _ _ _ => let case_nd_cossa := tt in _
1110 end) (refl_equal _) (refl_equal _)
1112 simpl in *; intros; subst; simpl in *; try (repeat (rule_helper_tactic' || subst)); subst; simpl in *.
1113 destruct case_nd_id0. apply nd_id0.
1114 destruct case_nd_id1. apply nd_rule. destruct p. apply RBrak.
1115 destruct case_nd_weak. apply nd_weak.
1117 destruct case_nd_copy.
1119 destruct c; try destruct o; simpl in *; try rule_helper_tactic'; try destruct p; try rule_helper_tactic'.
1120 inversion H0; subst.
1126 destruct case_nd_prod.
1128 apply (append_brak _ _ lpf).
1129 apply (append_brak _ _ rpf).
1131 destruct case_nd_comp.
1132 apply append_brak in bot.
1133 apply (nd_comp top bot).
1135 destruct case_nd_cancell.
1136 eapply nd_comp; [ apply nd_cancell | idtac ].
1137 apply append_brak_to_id.
1139 destruct case_nd_cancelr.
1140 eapply nd_comp; [ apply nd_cancelr | idtac ].
1141 apply append_brak_to_id.
1143 destruct case_nd_llecnac.
1144 eapply nd_comp; [ idtac | apply nd_llecnac ].
1145 apply append_brak_to_id.
1147 destruct case_nd_rlecnac.
1148 eapply nd_comp; [ idtac | apply nd_rlecnac ].
1149 apply append_brak_to_id.
1151 destruct case_nd_assoc.
1152 eapply nd_comp; [ apply nd_assoc | idtac ].
1153 repeat rewrite fixit.
1154 apply append_brak_to_id.
1156 destruct case_nd_cossa.
1157 eapply nd_comp; [ idtac | apply nd_cossa ].
1158 repeat rewrite fixit.
1159 apply append_brak_to_id.
1161 destruct case_nd_rule
1167 Definition append_brak {h c} : forall
1169 (fixify Γ ((⟨n, Σ₁ ⟩) :: past) h )
1172 (fixify Γ past (EscBrak_Functor_Fobj h))
1178 End HaskProofCategory.