From 9fb5bfc1591b4431865b67ca2fc8c54982279ea0 Mon Sep 17 00:00:00 2001 From: Chris Martens Date: Sun, 3 Jun 2012 14:36:54 -0400 Subject: [PATCH] added code --- src/README | 7 + src/canonical-explicit.elf | 141 + src/canonical-simple.elf | 173 + src/canonical.elf | 189 ++ src/complete.thm | 1560 +++++++++ src/constant.elf | 4 + src/convert-effect.thm | 201 ++ src/convert-explicit.thm | 1452 ++++++++ src/convert-fun.thm | 455 +++ src/convert-normal.thm | 198 ++ src/convert-reg-il.thm | 175 + src/convert-reg.thm | 362 ++ src/convert-sub.thm | 1399 ++++++++ src/convert.elf | 145 + src/efunctionality.thm | 547 +++ src/equality.thm | 1662 +++++++++ src/eregularity.thm | 1250 +++++++ src/estrengthen.thm | 876 +++++ src/esubstitution.thm | 378 +++ src/expand.elf | 18 + src/expand.thm | 1154 +++++++ src/explicit-lemmas-noncan.thm | 5844 ++++++++++++++++++++++++++++++++ src/explicit-lemmas.thm | 3760 ++++++++++++++++++++ src/false.thm | 269 ++ src/invert.thm | 188 + src/nat.elf | 14 + src/nat.thm | 48 + src/noncan-explicit.elf | 239 ++ src/noncan.elf | 256 ++ src/pi-inj.thm | 2251 ++++++++++++ src/reduce-equiv.thm | 301 ++ src/reduce-normal.elf | 82 + src/reduce.elf | 65 + src/regularity.thm | 173 + src/simp-lemmas.thm | 674 ++++ src/simple-regularity.thm | 173 + src/sound.thm | 681 ++++ src/sources.cfg | 51 + src/strengthen.thm | 425 +++ src/subst-effect.thm | 1744 ++++++++++ src/subst-fun.thm | 224 ++ src/substitution.thm | 3196 +++++++++++++++++ src/trans-explicit.thm | 1747 ++++++++++ src/trans-fun.thm | 312 ++ src/trans-reg.thm | 281 ++ src/trans-sub.thm | 683 ++++ src/translate.elf | 172 + 47 files changed, 36199 insertions(+) create mode 100644 src/README create mode 100644 src/canonical-explicit.elf create mode 100644 src/canonical-simple.elf create mode 100644 src/canonical.elf create mode 100644 src/complete.thm create mode 100644 src/constant.elf create mode 100644 src/convert-effect.thm create mode 100644 src/convert-explicit.thm create mode 100644 src/convert-fun.thm create mode 100644 src/convert-normal.thm create mode 100644 src/convert-reg-il.thm create mode 100644 src/convert-reg.thm create mode 100644 src/convert-sub.thm create mode 100644 src/convert.elf create mode 100644 src/efunctionality.thm create mode 100644 src/equality.thm create mode 100644 src/eregularity.thm create mode 100644 src/estrengthen.thm create mode 100644 src/esubstitution.thm create mode 100644 src/expand.elf create mode 100644 src/expand.thm create mode 100644 src/explicit-lemmas-noncan.thm create mode 100644 src/explicit-lemmas.thm create mode 100644 src/false.thm create mode 100644 src/invert.thm create mode 100644 src/nat.elf create mode 100644 src/nat.thm create mode 100644 src/noncan-explicit.elf create mode 100644 src/noncan.elf create mode 100644 src/pi-inj.thm create mode 100644 src/reduce-equiv.thm create mode 100644 src/reduce-normal.elf create mode 100644 src/reduce.elf create mode 100644 src/regularity.thm create mode 100644 src/simp-lemmas.thm create mode 100644 src/simple-regularity.thm create mode 100644 src/sound.thm create mode 100644 src/sources.cfg create mode 100644 src/strengthen.thm create mode 100644 src/subst-effect.thm create mode 100644 src/subst-fun.thm create mode 100644 src/substitution.thm create mode 100644 src/trans-explicit.thm create mode 100644 src/trans-fun.thm create mode 100644 src/trans-reg.thm create mode 100644 src/trans-sub.thm create mode 100644 src/translate.elf diff --git a/src/README b/src/README new file mode 100644 index 0000000..99a4a72 --- /dev/null +++ b/src/README @@ -0,0 +1,7 @@ +This comprises the working draft of LFinLF development, including soundness +and completeness of translation to canonical forms, family-level lambdas, +and constants. + +All code by Chris Martens + +Last updated 3/29/2011 diff --git a/src/canonical-explicit.elf b/src/canonical-explicit.elf new file mode 100644 index 0000000..3643fb5 --- /dev/null +++ b/src/canonical-explicit.elf @@ -0,0 +1,141 @@ +%%% ordered variables %%% + +isvar : atm -> nat -> type. +%%mode isvar *X1 *X2. + +- : (isvar _ _ -> isvar _ _) -> type. + + +precedes : atm -> atm -> type. + +precedes/i : precedes X Y + <- isvar X I + <- isvar Y J + <- lt I J. + + +%%% contexts %%% + +ctx : type. %name ctx G. + +nil : ctx. +cons : ctx -> atm -> tp -> ctx. + + +bounded : ctx -> atm -> type. + +bounded/nil : bounded nil X + <- isvar X _. +bounded/cons : bounded (cons G Y _) X + <- precedes Y X + <- bounded G Y. + + +ordered : ctx -> type. + +ordered/nil : ordered nil. +ordered/cons : ordered (cons G X _) + <- bounded G X. + + +lookup : ctx -> atm -> tp -> type. + +lookup/hit : lookup (cons G X A) X A. + +lookup/miss : lookup (cons G Y _) X A + <- lookup G X A. + + +csub : (atm -> ctx) -> tm -> ctx -> type. + +csub/nil : csub ([_] nil) _ nil. +csub/base : csub ([x] cons G x A) M G. +csub/cons : csub ([x] cons (G x) Y (A x)) M (cons G' Y A') + <- csub ([x] G x) M G' + <- tpsub ([x] A x) M A'. + + +append : ctx -> ctx -> ctx -> type. + +append/nil : append G nil G. +append/cons : append G1 (cons G2 X A) (cons G X A) + <- append G1 G2 G. + + +%%% typing with explicit contexts %%% + +ofe : ctx -> tm -> tp -> type. +at-ofe : ctx -> atm -> tp -> type. +kofe : ctx -> tp -> kind -> type. +at-kofe : ctx -> atp -> kind -> type. +wfkinde : ctx -> kind -> type. + +% objects + +at-ofe/closed : at-ofe G R A + <- at-of R A. + +at-ofe/const : at-ofe G (const C) A + <- cof C A + <- kofe G A ktype +% <- tclosed A + . + +at-ofe/var : at-ofe G X A + <- lookup G X A + <- kofe G A ktype. + +at-ofe/app : at-ofe G (app R M) B' + <- at-ofe G R (pi A ([x] B x)) + <- ofe G M A + <- tpsub ([x] B x) M B'. + +ofe/at : ofe G (at R) (base P) + <- at-ofe G R (base P). + +ofe/lam : ofe G (lam [x] M x) (pi A [x] B x) + <- ({x} ofe (cons G x A) (M x) (B x)) + <- kofe G A ktype. + +% families + +at-kofe/closed : at-kofe G P K + <- at-kof P K. + +at-kofe/const : at-kofe G (aconst A) K + <- ckof A K + <- wfkinde G K + . +% <- kclosed K. + +at-kofe/app : at-kofe G (aapp P M) K' + <- at-kofe G P (kpi B ([x] K x)) + <- ofe G M B + <- ksub ([x] K x) M K'. + +kofe/pi : kofe G (pi A ([x] B x)) ktype + <- kofe G A ktype + <- ({x} kofe (cons G x A) (B x) ktype). + +kofe/base : kofe G (base P) ktype + <- at-kofe G P ktype. + +kofe/lam : kofe G (alam ([x] B x)) (kpi A ([x] K x)) + <- kofe G A ktype + <- ({x} kofe (cons G x A) (B x) (K x)). + + +% kinds + +wfkinde/tp : wfkinde G ktype. + +wfkinde/pi : wfkinde G (kpi A ([x] K x)) + <- kofe G A ktype + <- ({x} wfkinde (cons G x A) (K x)). + + +%%% worlds %%% + + +%block ovar : some {n:nat} block {x:atm} {d:isvar x n}. + diff --git a/src/canonical-simple.elf b/src/canonical-simple.elf new file mode 100644 index 0000000..89dbd1f --- /dev/null +++ b/src/canonical-simple.elf @@ -0,0 +1,173 @@ + +%%% simple types %%% + +stp : type. %name stp T. + +o : stp. +arrow : stp -> stp -> stp. + + +simp : tp -> stp -> type. + +simp/pi : simp (pi A [x] B x) (arrow S T) + <- simp A S + <- ({x} simp (B x) T). + +simp/base : simp (base _) o. + +simp/lam : simp (alam ([x] A x)) T + <- ({x} simp (A x) T). + + +%%% simple kinds %%% + +skind : type. %name skind H. + +sktype : skind. +karrow : stp -> skind -> skind. + + +ksimp : kind -> skind -> type. + +ksimp/pi : ksimp (kpi A [x] K x) (karrow S H) + <- simp A S + <- ({x} ksimp (K x) H). + +ksimp/type : ksimp ktype sktype. + + +%%% leq relation on simple types %%% + +stp-leq : stp -> stp -> type. + +stp-leq/eq : stp-leq T T. +stp-leq/arr1 : stp-leq S (arrow T1 T2) + <- stp-leq S T1. +stp-leq/arr2 : stp-leq S (arrow T1 T2) + <- stp-leq S T2. + + +%%% simple contexts %%% + +sctx : type. %name sctx G. + +snil : sctx. +scons : sctx -> atm -> stp -> sctx. + + +sbounded : sctx -> atm -> type. + +sbounded/nil : sbounded snil X + <- isvar X _. +sbounded/cons : sbounded (scons G Y _) X + <- precedes Y X + <- sbounded G Y. + + +sordered : sctx -> type. + +sordered/nil : sordered snil. +sordered/cons : sordered (scons G X _) + <- sbounded G X. + + +slookup : sctx -> atm -> stp -> type. + +slookup/hit : slookup (scons G X T) X T. +slookup/miss : slookup (scons G Y _) X T + <- slookup G X T. + + +drop : (atm -> sctx) -> sctx -> type. + +drop/closed : drop ([_] G) G. +drop/base : drop ([x] scons (G x) x A) G' + <- drop ([x] G x) G'. +drop/cons : drop ([x] scons (G x) Y T) (scons G' Y T) + <- drop ([x] G x) G'. + +sappend : sctx -> sctx -> sctx -> type. + +sappend/nil : sappend G snil G. +sappend/cons : sappend G1 (scons G2 X A) (scons G X A) + <- sappend G1 G2 G. + + +%%% simplifying contexts %%% + +simpctx : ctx -> sctx -> type. + +simpctx/nil : simpctx nil snil. +simpctx/cons : simpctx (cons G X A) (scons G' X T) + <- simpctx G G' + <- simp A T. + + +%%% simple typing with explicit contexts %%% + +wfkindes : sctx -> kind -> type. +at-kofes : sctx -> atp -> skind -> type. +kofes : sctx -> tp -> skind -> type. +at-ofes : sctx -> atm -> stp -> type. +ofes : sctx -> tm -> stp -> type. + +at-ofes/closed : at-ofes G R T + <- at-of R A + <- simp A T. + +at-ofes/const : at-ofes G (const C) T + <- cof C A + <- kofes G A sktype +% <- tclosed A + <- simp A T. + +at-ofes/var : at-ofes G X T + <- slookup G X T. + +at-ofes/app : at-ofes G (app R M) T + <- at-ofes G R (arrow S T) + <- ofes G M S. + + +ofes/at : ofes G (at R) o + <- at-ofes G R o. + +ofes/lam : ofes G (lam [x] M x) (arrow S T) + <- ({x} ofes (scons G x S) (M x) T). + + +%% kofes/at-kofes. + +at-kofes/closed : at-kofes G P H + <- at-kof P K + <- ksimp K H. + +at-kofes/const : at-kofes G (aconst A) H + <- ckof A K + <- wfkindes G K +% <- kclosed K + <- ksimp K H. + +at-kofes/app : at-kofes G (aapp P M) H + <- at-kofes G P (karrow S H) + <- ofes G M S. + +kofes/base : kofes G (base P) sktype + <- at-kofes G P sktype. + +kofes/pi : kofes G (pi A1 [x] A2 x) sktype + <- kofes G A1 sktype + <- simp A1 T1 + <- ({x:atm} kofes (scons G x T1) (A2 x) sktype). + +kofes/lam : kofes G (alam ([x] B x)) (karrow T H) + <- ({x:atm} kofes (scons G x T) (B x) H). + +%% wfkindes + +wfkindes/type : wfkindes G ktype. + +wfkindes/pi : wfkindes G (kpi A ([x] K x)) + <- kofes G A sktype + <- simp A T + <- ({x} wfkindes (scons G x T) (K x)). diff --git a/src/canonical.elf b/src/canonical.elf new file mode 100644 index 0000000..113bff7 --- /dev/null +++ b/src/canonical.elf @@ -0,0 +1,189 @@ +%%% syntax %%% + +kind : type. %name kind K. + +tp : type. %name tp A. +atp : type. %name atp P. + +tm : type. %name tm M. +atm : type. %name atm R x. + +%% kinds %% + +ktype : kind. +kpi : tp -> (atm -> kind) -> kind. + + +%% families %% + +aconst : ctp -> atp. +aapp : atp -> tm -> atp. + +pi : tp -> (atm -> tp) -> tp. +base : atp -> tp. +alam : (atm -> tp) -> tp. + +%% objects %% + +const : ctm -> atm. +app : atm -> tm -> atm. + +lam : (atm -> tm) -> tm. +at : atm -> tm. + +%%% judgments %%% + +rrsub : (atm -> atm) -> tm -> atm -> type. +rmsub : (atm -> atm) -> tm -> tm -> type. +sub : (atm -> tm) -> tm -> tm -> type. +tpsub : (atm -> tp) -> tm -> tp -> type. +atpsub : (atm -> atp) -> tm -> atp -> type. +ksub : (atm -> kind) -> tm -> kind -> type. + +%% typing %% + +of : tm -> tp -> type. +cof : ctp -> tp -> type. +vof : atm -> tp -> type. +at-of : atm -> tp -> type. + +kof : tp -> kind -> type. +ckof : ctp -> kind -> type. +at-kof : atp -> kind -> type. + +wfkind : kind -> type. + +%% constants %% + +cof : ctm -> tp -> type. +ckof : ctp -> kind -> type. + +%{ +%% Constants should only be declared at closed types/kinds. +%% XXX fill in when needed -- may not be needed. +tclosed : tp -> type. +kclosed : kind -> type. +}% + +% We declare one term that's always in the signature so that vacuous +% substitutions may be applied. +unit : ctm. + +%% These blocks represent the signature. +%block csig : some {A:tp} + block {c:ctm} {d:cof c A}. +%block asig : some {K:kind} + block {a:ctp} {d:ckof a K}. + + +%%% typing %%% + +at-of/const : at-of (const C) A + <- cof C A + <- kof A ktype. + +at-of/var : at-of X A + <- vof X A + <- kof A ktype. + +at-of/app : at-of (app R1 M2) B1x + <- at-of R1 (pi A2 ([x] B1 x)) + <- of M2 A2 + <- tpsub ([x] B1 x) M2 B1x. + +of/at : of (at R) (base P) + <- at-of R (base P). + +of/lam : of (lam ([x] M x)) (pi A ([x] B x)) + <- ({x} vof x A -> of (M x) (B x)) + <- kof A ktype. + + +at-kof/const : at-kof (aconst A) K + <- ckof A K + <- wfkind K. + +at-kof/app : at-kof (aapp P M) K' + <- at-kof P (kpi B ([x] K x)) + <- of M B + <- ksub ([x] K x) M K'. + +kof/pi : kof (pi A1 ([x] A2 x)) ktype + <- kof A1 ktype + <- ({x} vof x A1 -> kof (A2 x) ktype). + +kof/base : kof (base P) ktype + <- at-kof P ktype. + +kof/lam : kof (alam ([x] B x)) (kpi A ([x] K x)) + <- kof A ktype + <- ({x} vof x A -> kof (B x) (K x)). + + +wfkind/tp : wfkind ktype. + +wfkind/pi : wfkind (kpi A ([x] K x)) + <- kof A ktype + <- ({x} vof x A -> wfkind (K x)). + +%%% substitution %%% + +rrsub/closed : rrsub ([_] R) _ R. + +rrsub/app : rrsub ([x] app (R x) (M x)) N (app R' M') + <- rrsub ([x] R x) N R' + <- sub ([x] M x) N M'. + +rmsub/var : rmsub ([x] x) M M. + +rmsub/app : rmsub ([x] app (R x) (M x)) N M1' + <- rmsub ([x] R x) N (lam M1) + <- sub ([x] M x) N M' + <- sub ([x] M1 x) M' M1'. + +sub/rr : sub ([x] at (R x)) M (at R') + <- rrsub ([x] R x) M R'. + +sub/rm : sub ([x] at (R x)) M (at R') + <- rmsub ([x] R x) M (at R'). % note restriction to 'at' + +sub/lam : sub ([x] lam ([y] M x y)) N (lam ([y] M' y)) + <- ({y} sub ([x] M x y) N (M' y)). + + +atpsub/closed : atpsub ([_] P) _ P. + +atpsub/app : atpsub ([x] aapp (P x) (M x)) N (aapp P' M') + <- atpsub ([x] P x) N P' + <- sub ([x] M x) N M'. + +tpsub/base : tpsub ([x] base (P x)) M (base P') + <- atpsub ([x] P x) M P'. + +tpsub/pi : tpsub ([x] pi (A x) ([y] B x y)) M (pi A' ([y] B' y)) + <- tpsub ([x] A x) M A' + <- ({y} tpsub ([x] B x y) M (B' y)). + +tpsub/lam : tpsub ([x] alam ([y] A x y)) M (alam ([y] A' y)) + <- ({y} tpsub ([x] A x y) M (A' y)). + +ksub/type : ksub ([_] ktype) _ ktype. + +ksub/pi : ksub ([x] kpi (A x) ([y] K x y)) M (kpi A' [y] K' y) + <- tpsub ([x] A x) M A' + <- ({y} ksub ([x] K x y) M (K' y)). + + + + +%%%% worlds %%%% + +%block var : block {x:atm}. + +%block bind : some {a:tp} block {x:atm} {d:vof x a}. + +%block ofblock : some {x:atm} {a:tp} block {d:vof x a}. + +%%%% a closed atom %%%% + +aca : atm = const unit. diff --git a/src/complete.thm b/src/complete.thm new file mode 100644 index 0000000..d9da97c --- /dev/null +++ b/src/complete.thm @@ -0,0 +1,1560 @@ + +%% it seems like output coverage should be able to figure this out, +%% but it doesn't. +of-lam-invert : of M (pi A ([x] B x)) + -> kof A ktype + -> ({x} vof x A -> of (L x) (B x)) + -> tm-eq M (lam ([x] L x)) -> type. +%mode of-lam-invert +X1 -X2 -X3 -X4. + +-lam : of-lam-invert + (of/lam DofA ([x] [d] DofL x d)) + DofA + DofL + tm-eq/i. + +%worlds (csig | asig | bind) (of-lam-invert _ _ _ _). +%total D (of-lam-invert D _ _ _). + +kof-lam-invert : kof C (kpi A ([x] K x)) + -> kof A ktype + -> ({x} vof x A -> kof (B x) (K x)) + -> tp-eq C (alam ([x] B x)) -> type. +%mode kof-lam-invert +X1 -X2 -X3 -X4. + +-lam : kof-lam-invert + (kof/lam ([x] [d] DofB x d) DofA) + DofA + DofB + tp-eq/i. + +%worlds (csig | asig | bind) (kof-lam-invert _ _ _ _). +%total D (kof-lam-invert D _ _ _). + + +%%% completeness %%% + +%% for constants + +cof-comp : ecof C EA + -> tptrans EA A ktype + -> cof C A -> type. +%mode cof-comp +X1 -X2 -X3. + +ckof-comp : eckof A EK + -> ktrans EK K + -> ckof A K -> type. +%mode ckof-comp +X1 -X2 -X3. + + +%block tcsig : some {EA:etp} {A:tp} {d_tptrans:tptrans EA A ktype} + block {c:ctm} {d:cof c A} {e:ecof c EA} + {thm:cof-comp e d_tptrans d}. +%block tasig : some {EK:ekind} {K:kind} {d_ktrans:ktrans EK K} + block {a:ctp} {d:ckof a K} {e:eckof a EK} + {thm:ckof-comp e d_ktrans d}. + +- : cof-comp deof_zero (tptrans/const tpexpand/type ksimp/type wfkind/tp dkof_nat) dof_zero. +- : ckof-comp dekof_nat ktrans/type dkof_nat. + +%worlds (bind | tbind | tcsig | tasig) (cof-comp _ _ _). +%total {} (cof-comp _ _ _). + +%worlds (bind | tbind | tcsig | tasig) (ckof-comp _ _ _). +%total {} (ckof-comp _ _ _). + +%% for the rest + +vof-comp : evof EX EA + -> tptrans EA A ktype + -> vtrans EX X + -> vof X A -> type. +%mode vof-comp +X1 -X2 -X3 -X4. + +of-comp : eof EM EA + -> tptrans EA A ktype + -> trans EM M A -> type. +%mode of-comp +X1 -X2 -X3. + +kof-comp : ekof EA EK + -> ktrans EK K + -> tptrans EA A K -> type. +%mode kof-comp +X1 -X2 -X3. + +wfkind-comp : ewfkind EK + -> ktrans EK K + -> wfkind K -> type. %% XXX should have by ktrans-reg +%mode wfkind-comp +X1 -X2 -X3. + +eqtm-comp : eqtm EM EN EA + -> tptrans EA A ktype + -> trans EM M A + -> trans EN M A -> type. +%mode eqtm-comp +X1 -X2 -X3 -X4. + +eqtp-comp : eqtp EA EB EK + -> ktrans EK K + -> tptrans EA A K + -> tptrans EB A K -> type. +%mode eqtp-comp +X1 -X2 -X3 -X4. + +eqkind-comp : eqkind EK EL + -> ktrans EK K + -> ktrans EL K -> type. +%mode eqkind-comp +X1 -X2 -X3. + +%block cbind + : some {EA:etp} {A:tp} {d_tptrans:tptrans EA A ktype} + block {x:atm} {d:vof x A} + {ex:etm} {ed:evof ex EA} + {xt:vtrans ex x} + {thm1:vof-comp ed d_tptrans xt d}. + +-var : of-comp + (eof/var + (DofEA : ekof EA ektype) + (Devof : evof EX EA)) +%% + DtransA + (trans/var DexpandX DsimpA DofA DofX DtransX) +%% + <- vof-comp Devof + (DtransA : tptrans EA A ktype) + (DtransX : vtrans EX X) + (DofX : vof X A) + <- can-simp A + (DsimpA : simp A T) + <- can-expand X T + (DexpandX : expand X T M) + <- kof-comp DofEA + _ (DtransA' : tptrans EA A' ktype) + <- tptrans-reg DtransA' (DofA' : kof A' ktype) + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) + _ + <- kof-resp DeqA'A kind-eq/i DofA' + (DofA : kof A ktype) + <- expand-reg (at-of/var DofA DofX) DsimpA DexpandX + (DofM : of M A). + +-const : of-comp + (eof/const + (DofEA : ekof EA ektype) + (DeofC : ecof C EA)) +%% + DtransA + (trans/const Dexpand DsimpA DofA DofC) +%% + <- kof-comp DofEA + _ (DtransA : tptrans EA A ktype) + <- tptrans-reg DtransA (DofA : kof A ktype) + <- can-simp A + (DsimpA : simp A T) + <- can-expand (const C) T + (Dexpand : expand (const C) T M) + <- cof-comp DeofC + (DtransA' : tptrans EA A' ktype) + (DofC' : cof C A') + %% + <- tptrans-fun DtransA' DtransA + (DeqA' : tp-eq A' A) + _ + <- cof-resp DeqA' DofC' + (DofC : cof C A). + +-app : of-comp + (eof/app + (DeofN : eof EN EA) + (DeofM : eof EM (epi EA ([ex] EB ex))) + : eof (eapp EM EN) (EB EN)) +%% + DtransBx + (trans/app + DsubB + DsubL + DtransN + DtransMLam) +%% + %% get translations + <- of-comp DeofN + (DtransA : tptrans EA A ktype) + (DtransN : trans EN N A) + <- of-comp DeofM + (tptrans/pi + ([x] [d] [ex] [xt] + DtransB x d ex xt : tptrans (EB ex) (B x) ktype) + (DtransA' : tptrans EA A' ktype)) + (DtransM' : trans EM M (pi A' ([x] B x))) + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) + _ + <- pi-compat DeqA'A ([_] tp-eq/i) + (DeqPi : tp-eq (pi A' ([x] B x)) (pi A ([x] B x))) + <- trans-resp DtransM' etm-eq/i tm-eq/i DeqPi + (DtransM : trans EM M (pi A ([x] B x))) + <- trans-reg DtransM (DofM : of M (pi A ([x] B x))) + <- of-lam-invert DofM + (DofA : kof A ktype) + ([x] [d:vof x A] DofL x d : of (L x) (B x)) + (DeqMLam : tm-eq M (lam ([x] L x))) + <- trans-resp DtransM etm-eq/i DeqMLam tp-eq/i + (DtransMLam : trans EM (lam ([x] L x)) (pi A ([x] B x))) + %% get substitutions + <- trans-reg DtransN (DofN : of N A) + <- can-sub DofL DofN + (DsubL : sub ([x] L x) N Lx) + %% invoke tptrans-sub + <- tp-eq-sym DeqA'A DeqAA' + <- trans-resp DtransN etm-eq/i tm-eq/i DeqAA' + (DtransN' : trans EN N A') + <- tptrans-sub DtransB DtransN' + (DsubB : tpsub ([x] B x) N Bx) + _ + (DtransBx : tptrans (EB EN) Bx ktype). + +-lam : of-comp + (eof/lam + (DofEA : ekof EA ektype) + ([ex] [dex:evof ex EA] + DofEM ex dex : eof (EM ex) (EB ex)) + : eof (elam EA ([ex] EM ex)) (epi EA ([ex] EB ex))) +%% + (tptrans/pi DtransEB DtransEA) + (trans/lam DtransEM DtransEA) +%% + <- kof-comp DofEA + _ (DtransEA : tptrans EA A ktype) + <- ({x} {d:vof x A} {ex} {ed:evof ex EA} {tr:vtrans ex x} + vof-comp ed DtransEA tr d + -> of-comp (DofEM ex ed) + (DtransEB x d ex tr : tptrans (EB ex) (B x) ktype) + (DtransEM x d ex tr : trans (EM ex) (M x) (B x))). + +-eqtp : of-comp + (eof/eqtp + (DeqEAEB : eqtp EA EB ektype) + (DofEM : eof EM EA) + : eof EM EB) +%% + DtransB + DtransM +%% + <- of-comp DofEM + (DtransA : tptrans EA A ktype) + (DtransM : trans EM M A) + <- eqtp-comp DeqEAEB + _ + (DtransA' : tptrans EA A' ktype) + (DtransB' : tptrans EB A' ktype) + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) + _ + <- tptrans-resp DtransB' etp-eq/i DeqA'A kind-eq/i + (DtransB : tptrans EB A ktype). + +-ext : of-comp + (eof/ext + ([ex] [dex] DofApp ex dex : eof (eapp EM ex) (EB ex)) + (DofEM : eof EM (epi EA ([ex] EB' ex))) + : eof EM (epi EA ([ex] EB ex))) +%% + (tptrans/pi DtransB DtransA) + DtransMLam +%% + %% come up with DtransA + <- of-comp DofEM + (tptrans/pi + ([x] [d:vof x A] [ex] [xt] + DtransB' x d ex xt : tptrans (EB' ex) (B' x) ktype) + (DtransA : tptrans EA A ktype)) + (DtransM : trans EM M (pi A B')) + <- trans-reg DtransM + (DofM' : of M (pi A ([x] B' x))) + <- of-lam-invert DofM' + _ + ([x] [d] DofL' x d : of (L x) (B' x)) + (DeqMLam : tm-eq M (lam ([x] L x))) + <- trans-resp DtransM etm-eq/i DeqMLam tp-eq/i + (DtransMLam' : trans EM (lam [x] L x) (pi A [x] B' x)) + %% come up with DtransB + <- ({x} {d:vof x A} {ex} {ed} {tr} + vof-comp ed DtransA tr d + -> of-comp (DofApp ex ed) + (DtransB x d ex tr : tptrans (EB ex) (B x) ktype) + (trans/app + (DsubB'' x : tpsub ([y] B'' x y) (X x) (B x)) + (DsubL' x : sub ([y] L' x y) (X x) (N x)) + (DtransX x d ex tr : trans ex (X x) _) + (DtransM' x d ex tr + : trans EM (lam [y] L' x y) (pi A' ([y] B'' x y))) + : trans (eapp EM ex) (N x) (B x))) + %% + <- ({x} {d} {ex} {xt} + trans-fun DtransMLam' (DtransM' x d ex xt) + (DeqLam x : tm-eq (lam [y] L y) (lam [y] L' x y)) + (DeqPi x : tp-eq (pi A [y] B' y) (pi A' [y] B'' x y))) + <- ({x} + pi-inj (DeqPi x) + (DeqAA' x : tp-eq A A') + ([y] DeqB'B'' x y : tp-eq (B' y) (B'' x y))) + %% argue that B'' is the same as B + <- can-simp A (Dsimp : simp A T) + <- ({x} + can-expand x T + (Dexpand x : expand x T (X' x))) + <- tptrans-reg DtransA (DofA : kof A ktype) + <- ({x} {d} {ex} {xt} + trans-fun + (DtransX x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX x : tm-eq (X x) (X' x)) + Underscore) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX x) tp-eq/i (DsubB'' x) + (DsubB''' x : tpsub ([y] B'' x y) (X' x) (B x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubB''' x) + (DeqBB'' x : tp-eq (B x) (B'' x x))) + <- ({x} + tp-eq-sym (DeqBB'' x) (DeqB''B x : tp-eq (B'' x x) (B x))) + %% + <- ({x} + tp-eq-trans (DeqB'B'' x x) (DeqB''B x) + (DeqB'B x : tp-eq (B' x) (B x))) + <- pi-compat tp-eq/i ([x] DeqB'B x) + (DeqPi* : tp-eq (pi A ([x] B' x)) (pi A ([x] B x))) + <- trans-resp DtransMLam' etm-eq/i tm-eq/i DeqPi* + (DtransMLam : trans EM (lam [x] L x) (pi A [x] B x)). + +%%%% + +-const : kof-comp + (ekof/const + (DofEA : ewfkind EA) + (DeofC : eckof C EA)) +%% + DtransA + (tptrans/const Dexpand DsimpA DofA DofC) +%% + <- wfkind-comp DofEA + (DtransA : ktrans EA A) + (DofA : wfkind A) + <- can-ksimp A + (DsimpA : ksimp A T) + <- can-tpexpand (aconst C) T + (Dexpand : tpexpand (aconst C) T M) + <- ckof-comp DeofC + (DtransA' : ktrans EA A') + (DofC' : ckof C A') + <- ktrans-fun DtransA' DtransA + (DeqA : kind-eq A' A) + <- ckof-resp DeqA DofC' + (DofC : ckof C A). + +-app : kof-comp + (ekof/app + (DeofN : eof EN EA) + (DeofM : ekof EM (ekpi EA ([ex] EB ex))) + : ekof (eaapp EM EN) (EB EN)) +%% + DtransBx + (tptrans/app + DsubB + DsubL + DtransN + DtransMLam) +%% + %% get translations + <- of-comp DeofN + (DtransA : tptrans EA A ktype) + (DtransN : trans EN N A) + <- kof-comp DeofM + (ktrans/pi + ([x] [d] [ex] [xt] + DtransB x d ex xt : ktrans (EB ex) (B x)) + (DtransA' : tptrans EA A' ktype)) + (DtransM' : tptrans EM M (kpi A' ([x] B x))) + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) + _ + <- kpi-compat DeqA'A ([_] kind-eq/i) + (DeqPi : kind-eq (kpi A' ([x] B x)) (kpi A ([x] B x))) + <- tptrans-resp DtransM' etp-eq/i tp-eq/i DeqPi + (DtransM : tptrans EM M (kpi A ([x] B x))) + <- tptrans-reg DtransM (DofM : kof M (kpi A ([x] B x))) + <- kof-lam-invert DofM + (DofA : kof A ktype) + ([x] [d:vof x A] DofL x d : kof (L x) (B x)) + (DeqMLam : tp-eq M (alam ([x] L x))) + <- tptrans-resp DtransM etp-eq/i DeqMLam kind-eq/i + (DtransMLam : tptrans EM (alam ([x] L x)) (kpi A ([x] B x))) + %% get substitutions + <- trans-reg DtransN (DofN : of N A) + <- can-tpsub DofL DofN + (DsubL : tpsub ([x] L x) N Lx) + %% invoke tptrans-sub + <- tp-eq-sym DeqA'A DeqAA' + <- trans-resp DtransN etm-eq/i tm-eq/i DeqAA' + (DtransN' : trans EN N A') + <- ktrans-sub DtransB DtransN' + (DsubB : ksub ([x] B x) N Bx) + (DtransBx : ktrans (EB EN) Bx). + +-pi : kof-comp + (ekof/pi + ([ex] [dex:evof ex EA] + DofEM ex dex : ekof (EM ex) ektype) + (DofEA : ekof EA ektype) + : ekof (epi EA ([ex] EM ex)) ektype) +%% + ktrans/type + (tptrans/pi DtransEM DtransEA) +%% + <- kof-comp DofEA + _ (DtransEA : tptrans EA A ktype) + <- ({x} {d:vof x A} {ex} {ed:evof ex EA} {tr:vtrans ex x} + vof-comp ed DtransEA tr d + -> kof-comp (DofEM ex ed) + ktrans/type + (DtransEM x d ex tr : tptrans (EM ex) (M x) ktype)). + +-lam : kof-comp + (ekof/lam + (DofEA : ekof EA ektype) + ([ex] [dex:evof ex EA] + DofEM ex dex : ekof (EM ex) (EB ex)) + : ekof (ealam EA ([ex] EM ex)) (ekpi EA ([ex] EB ex))) +%% + (ktrans/pi DtransEB DtransEA) + (tptrans/lam DtransEM DtransEA) +%% + <- kof-comp DofEA + _ (DtransEA : tptrans EA A ktype) + <- ({x} {d:vof x A} {ex} {ed:evof ex EA} {tr:vtrans ex x} + vof-comp ed DtransEA tr d + -> kof-comp (DofEM ex ed) + (DtransEB x d ex tr : ktrans (EB ex) (B x)) + (DtransEM x d ex tr : tptrans (EM ex) (M x) (B x))). +-eqkind : kof-comp + (ekof/eqkind + (DeqEAEB : eqkind EA EB) + (DofEM : ekof EM EA) + : ekof EM EB) +%% + DtransB + DtransM +%% + <- kof-comp DofEM + (DtransA : ktrans EA A) + (DtransM : tptrans EM M A) + <- eqkind-comp DeqEAEB + (DtransA' : ktrans EA A') + (DtransB' : ktrans EB A') + <- ktrans-fun DtransA' DtransA + (DeqA'A : kind-eq A' A) + <- ktrans-resp DtransB' ekind-eq/i DeqA'A + (DtransB : ktrans EB A). + +-ext : kof-comp + (ekof/ext + ([ex] [dex] DofApp ex dex : ekof (eaapp EM ex) (EB ex)) + (DofEM : ekof EM (ekpi EA ([ex] EB' ex))) + : ekof EM (ekpi EA ([ex] EB ex))) +%% + (ktrans/pi DtransB DtransA) + DtransMLam +%% + %% come up with DtransA + <- kof-comp DofEM + (ktrans/pi + ([x] [d:vof x A] [ex] [xt] + DtransB' x d ex xt : ktrans (EB' ex) (B' x)) + (DtransA : tptrans EA A ktype)) + (DtransM : tptrans EM M (kpi A B')) + <- tptrans-reg DtransM + (DofM' : kof M (kpi A ([x] B' x))) + <- kof-lam-invert DofM' + _ + ([x] [d] DofL' x d : kof (L x) (B' x)) + (DeqMLam : tp-eq M (alam ([x] L x))) + <- tptrans-resp DtransM etp-eq/i DeqMLam kind-eq/i + (DtransMLam' : tptrans EM (alam [x] L x) (kpi A [x] B' x)) + %% come up with DtransB + <- ({x} {d:vof x A} {ex} {ed} {tr} + vof-comp ed DtransA tr d + -> kof-comp (DofApp ex ed) + (DtransB x d ex tr : ktrans (EB ex) (B x)) + (tptrans/app + (DsubB'' x : ksub ([y] B'' x y) (X x) (B x)) + (DsubL' x : tpsub ([y] L' x y) (X x) (N x)) + (DtransX x d ex tr : trans ex (X x) _) + (DtransM' x d ex tr + : tptrans EM + (alam [y] L' x y) (kpi A' ([y] B'' x y))) + : tptrans (eaapp EM ex) (N x) (B x))) + %% + <- ({x} {d} {ex} {xt} + tptrans-fun DtransMLam' (DtransM' x d ex xt) + (DeqLam x : tp-eq (alam [y] L y) (alam [y] L' x y)) + (DeqPi x + : kind-eq (kpi A [y] B' y) (kpi A' [y] B'' x y))) + <- ({x} + kpi-inj (DeqPi x) + (DeqAA' x : tp-eq A A') + ([y] DeqB'B'' x y : kind-eq (B' y) (B'' x y))) + %% argue that B'' is the same as B + <- can-simp A (Dsimp : simp A T) + <- ({x} + can-expand x T + (Dexpand x : expand x T (X' x))) + <- tptrans-reg DtransA (DofA : kof A ktype) + <- ({x} {d} {ex} {xt} + trans-fun + (DtransX x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX x : tm-eq (X x) (X' x)) + Underscore) + <- ({x} + ksub-compat ([_] kind-eq/i) (DeqX x) kind-eq/i (DsubB'' x) + (DsubB''' x : ksub ([y] B'' x y) (X' x) (B x))) + <- ({x} + ksub-expand _ (Dexpand x) (DsubB''' x) + (DeqBB'' x : kind-eq (B x) (B'' x x))) + <- ({x} + kind-eq-sym (DeqBB'' x) + (DeqB''B x : kind-eq (B'' x x) (B x))) + %% + <- ({x} + kind-eq-trans (DeqB'B'' x x) (DeqB''B x) + (DeqB'B x : kind-eq (B' x) (B x))) + <- kpi-compat tp-eq/i ([x] DeqB'B x) + (DeqPi* : kind-eq (kpi A ([x] B' x)) (kpi A ([x] B x))) + <- tptrans-resp DtransMLam' etp-eq/i tp-eq/i DeqPi* + (DtransMLam : tptrans EM (alam [x] L x) (kpi A [x] B x)). + +%% + +-type : wfkind-comp ewfkind/tp ktrans/type wfkind/tp. + +-pi : wfkind-comp + (ewfkind/pi + ([ex] [dex:evof ex EA] + DofEM ex dex : ewfkind (EM ex)) + (DofEA : ekof EA ektype) + : ewfkind (ekpi EA ([ex] EM ex))) +%% + (ktrans/pi DtransEM DtransEA) + (wfkind/pi Dwfkind DofA) +%% + <- kof-comp DofEA + _ (DtransEA : tptrans EA A ktype) + <- tptrans-reg DtransEA (DofA : kof A ktype) + <- ({x} {d:vof x A} {ex} {ed:evof ex EA} {tr:vtrans ex x} + vof-comp ed DtransEA tr d + -> wfkind-comp (DofEM ex ed) + (DtransEM x d ex tr : ktrans (EM ex) (M x)) + (Dwfkind x d : wfkind (M x))). + +%%%% + +-app : eqtm-comp + (eqtm/app + (DeqEN : eqtm EN EN' EA) + (DeqEM : eqtm EM EM' (epi EA ([x] EB x))) + : eqtm (eapp EM EN) (eapp EM' EN') (EB EN)) +%% + DtransBx + (trans/app + DsubB + DsubL + DtransN + DtransMLam) + (trans/app + DsubB + DsubL + DtransN' + DtransM'Lam) +%% + <- eqtm-comp DeqEM + (tptrans/pi + ([x] [d:vof x A] [ex] [tr:vtrans ex x] + DtransB x d ex tr + : tptrans (EB ex) (B x) ktype) + (DtransA : tptrans EA A ktype)) + (DtransM : trans EM M (pi A ([x] B x))) + (DtransM' : trans EM' M (pi A ([x] B x))) + <- trans-reg DtransM (DofM : of M (pi A ([x] B x))) + <- of-lam-invert DofM + _ + ([x] [d] DofL x d : of (L x) (B x)) + (DeqMLam : tm-eq M (lam ([x] L x))) + <- trans-resp DtransM etm-eq/i DeqMLam tp-eq/i + (DtransMLam : trans EM (lam [x] L x) (pi A ([x] B x))) + <- trans-resp DtransM' etm-eq/i DeqMLam tp-eq/i + (DtransM'Lam : trans EM' (lam [x] L x) (pi A ([x] B x))) + <- eqtm-comp DeqEN + (DtransA' : tptrans EA A' ktype) + (DtransN^ : trans EN N A') + (DtransN'^ : trans EN' N A') + % get term substitution + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) + _ + <- trans-reg DtransN^ (DofN' : of N A') + <- of-resp tm-eq/i DeqA'A DofN' + (DofN : of N A) + <- can-sub ([x] [d] DofL x d) DofN + (DsubL : sub ([x] L x) N Lx) + <- trans-resp DtransN^ etm-eq/i tm-eq/i DeqA'A + (DtransN : trans EN N A) + <- trans-resp DtransN'^ etm-eq/i tm-eq/i DeqA'A + (DtransN' : trans EN' N A) + % get type substitution + <- tptrans-sub DtransB DtransN + (DsubB : tpsub ([x] B x) N Bx) + ksub/type + (DtransBx : tptrans (EB EN) Bx ktype). + +-lam : eqtm-comp + (eqtm/lam + ([ex] [ed:evof ex EA] + DeqEM ex ed : eqtm (EM ex) (EM' ex) (EB ex)) + (DeqEA : eqtp EA EA' ektype)) +%% + (tptrans/pi DtransB DtransA) + (trans/lam DtransM DtransA) + (trans/lam DtransM' DtransA') +%% + <- eqtp-comp DeqEA + ktrans/type + (DtransA : tptrans EA A ktype) + (DtransA' : tptrans EA' A ktype) + <- ({x} {d} {ex} {ed} {tr} + vof-comp ed DtransA tr d + -> eqtm-comp (DeqEM ex ed) + (DtransB x d ex tr : tptrans (EB ex) (B x) ktype) + (DtransM x d ex tr : trans (EM ex) (M x) (B x)) + (DtransM' x d ex tr : trans (EM' ex) (M x) (B x))). + +-ext : eqtm-comp + (eqtm/ext + ([ex] [ed:evof ex EA] + DeqApp ex ed + : eqtm (eapp EM ex) (eapp EN ex) (EB ex)) + (DofEN : eof EN (epi EA ([ex] EB'' ex))) + (DofEM : eof EM (epi EA ([ex] EB' ex)))) +%% + (tptrans/pi DtransB DtransA) + DtransMLamL + DtransNLamL +%% + <- of-comp DofEM + (tptrans/pi + ([x] [d:vof x A] [ex] [xt] + DtransB' x d ex xt + : tptrans (EB' ex) (B' x) ktype) + (DtransA : tptrans EA A ktype)) + (DtransM : trans EM M (pi A ([x] B' x))) + <- of-comp DofEN + (tptrans/pi + ([x] [d:vof x A'] [ex] [xt] + DtransB'' x d ex xt + : tptrans (EB'' ex) (B'' x) ktype) + (DtransA' : tptrans EA A' ktype)) + (DtransN' : trans EN N (pi A' ([x] B'' x))) + %% Fix DtransN' + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) _ + <- pi-compat DeqA'A ([x] tp-eq/i) + (DeqPiA'A : tp-eq (pi A' [x] B'' x) (pi A ([x] B'' x))) + <- trans-resp DtransN' etm-eq/i tm-eq/i DeqPiA'A + (DtransN : trans EN N (pi A ([x] B'' x))) + %% + <- ({x} {d} {ex} {ed} {xt} + vof-comp ed DtransA xt d + -> eqtm-comp (DeqApp ex ed) + (DtransB x d ex xt : tptrans (EB ex) (B x) ktype) + (trans/app + (DsubB1y x : tpsub ([y] B1 x y) (X1 x) (B x)) + (DsubL1y x : sub ([y] L1 x y) (X1 x) (L x)) + (DtransX1 x d ex xt : trans ex (X1 x) (A1 x)) + (DtransMLam x d ex xt + : trans EM (lam [y] L1 x y) + (pi (A1 x) ([y] B1 x y)))) + (trans/app + (DsubB2y x : tpsub ([y] B2 x y) (X2 x) (B x)) + (DsubL2y x : sub ([y] L2 x y) (X2 x) (L x)) + (DtransX2 x d ex xt : trans ex (X2 x) _) + (DtransNLam x d ex xt + : trans EN (lam ([y] L2 x y)) + (pi (A2 x) ([y] B2 x y))))) + %% + <- tptrans-reg DtransA (DofA : kof A ktype) + <- can-simp A (Dsimp : simp A T) + <- ({x} can-expand x T (Dexpand x : expand x T (X x))) + <- ({x} {d} {ex} {xt} + trans-fun (DtransX1 x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX1X x : tm-eq (X1 x) (X x)) + (DeqA1A* x : tp-eq (A1 x) A)) + <- ({x} + sub-compat ([_] tm-eq/i) (DeqX1X x) tm-eq/i (DsubL1y x) + (DsubL1X x : sub ([y] L1 x y) (X x) (L x))) + <- ({x} + sub-expand _ (Dexpand x) (DsubL1X x) + (DeqLL1 x : tm-eq (L x) (L1 x x))) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX1X x) tp-eq/i (DsubB1y x) + (DsubB1X x : tpsub ([y] B1 x y) (X x) (B x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubB1X x) + (DeqBB1 x : tp-eq (B x) (B1 x x))) + %% + <- trans-reg DtransM (DofM : of M (pi A ([x] B' x))) + <- of-lam-invert DofM _ + ([x] [d] DofL' x d : of (L' x) (B' x)) + (DeqMLam' : tm-eq M (lam ([x] L' x))) + <- trans-resp DtransM etm-eq/i DeqMLam' tp-eq/i + (DtransMLam' : trans EM (lam [x] L' x) (pi A ([x] B' x))) + <- ({x} {d} {ex} {xt} + trans-fun (DtransMLam x d ex xt) DtransMLam' + (DeqLamL1L' x + : tm-eq (lam ([y] L1 x y)) (lam ([y] L' y))) + (DeqPiB1B' x + : tp-eq (pi (A1 x) ([y] B1 x y)) (pi A ([y] B' y)))) + <- ({x} + lam-inj (DeqLamL1L' x) + ([y] DeqL1L' x y : tm-eq (L1 x y) (L' y))) + <- ({x} + pi-inj (DeqPiB1B' x) + (DeqA1A x : tp-eq (A1 x) A) + ([y] DeqB1B' x y : tp-eq (B1 x y) (B' y))) + %% + <- ({x} + tm-eq-trans (DeqLL1 x) (DeqL1L' x x) + (DeqLL' x : tm-eq (L x) (L' x))) + <- ({x} tm-eq-sym (DeqLL' x) (DeqL'L x : tm-eq (L' x) (L x))) + <- lam-compat DeqL'L + (DeqLamL'L : tm-eq (lam [x] L' x) (lam [x] L x)) + <- ({x} + tp-eq-trans (DeqBB1 x) (DeqB1B' x x) + (DeqBB' x : tp-eq (B x) (B' x))) + <- ({x} tp-eq-sym (DeqBB' x) (DeqB'B x : tp-eq (B' x) (B x))) + <- pi-compat tp-eq/i DeqB'B + (DeqPiB'B : tp-eq (pi A [x] B' x) (pi A [x] B x)) + <- trans-resp DtransMLam' etm-eq/i DeqLamL'L DeqPiB'B + (DtransMLamL : trans EM (lam [x] L x) (pi A ([x] B x))) + %% Now do the same thing for N + <- ({x} {d} {ex} {xt} + trans-fun (DtransX2 x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX2X x : tm-eq (X2 x) (X x)) + (DeqA2A* x : tp-eq (A2 x) A)) + <- ({x} + sub-compat ([_] tm-eq/i) (DeqX2X x) tm-eq/i (DsubL2y x) + (DsubL2X x : sub ([y] L2 x y) (X x) (L x))) + <- ({x} + sub-expand _ (Dexpand x) (DsubL2X x) + (DeqLL2 x : tm-eq (L x) (L2 x x))) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX2X x) tp-eq/i (DsubB2y x) + (DsubB2X x : tpsub ([y] B2 x y) (X x) (B x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubB2X x) + (DeqBB2 x : tp-eq (B x) (B2 x x))) + %% + <- trans-reg DtransN (DofN : of N (pi A ([x] B'' x))) + <- of-lam-invert DofN _ + ([x] [d] DofL'' x d : of (L'' x) (B'' x)) + (DeqNLam'' : tm-eq N (lam ([x] L'' x))) + <- trans-resp DtransN etm-eq/i DeqNLam'' tp-eq/i + (DtransNLam'' : trans EN (lam [x] L'' x) (pi A ([x] B'' x))) + <- ({x} {d} {ex} {xt} + trans-fun (DtransNLam x d ex xt) DtransNLam'' + (DeqLamL2L'' x + : tm-eq (lam ([y] L2 x y)) (lam ([y] L'' y))) + (DeqPiB2B'' x + : tp-eq (pi (A2 x) ([y] B2 x y)) (pi A ([y] B'' y)))) + <- ({x} + lam-inj (DeqLamL2L'' x) + ([y] DeqL2L'' x y : tm-eq (L2 x y) (L'' y))) + <- ({x} + pi-inj (DeqPiB2B'' x) + (DeqA2A x : tp-eq (A2 x) A) + ([y] DeqB2B'' x y : tp-eq (B2 x y) (B'' y))) + %% + <- ({x} + tm-eq-trans (DeqLL2 x) (DeqL2L'' x x) + (DeqLL'' x : tm-eq (L x) (L'' x))) + <- ({x} tm-eq-sym (DeqLL'' x) (DeqL''L x : tm-eq (L'' x) (L x))) + <- lam-compat DeqL''L + (DeqLamL''L : tm-eq (lam [x] L'' x) (lam [x] L x)) + <- ({x} + tp-eq-trans (DeqBB2 x) (DeqB2B'' x x) + (DeqBB'' x : tp-eq (B x) (B'' x))) + <- ({x} tp-eq-sym (DeqBB'' x) (DeqB''B x : tp-eq (B'' x) (B x))) + <- pi-compat tp-eq/i DeqB''B + (DeqPiB''B : tp-eq (pi A [x] B'' x) (pi A [x] B x)) + <- trans-resp DtransNLam'' etm-eq/i DeqLamL''L DeqPiB''B + (DtransNLamL : trans EN (lam [x] L x) (pi A ([x] B x))). + +-extw : eqtm-comp + (eqtm/extw + ([ex] [ed:evof ex EA] + DeqApp ex ed + : eqtm (eapp EM ex) (eapp EN ex) (EB ex)) + (DeqEMEN : eqtm EM EN (epi EA ([ex] EB' ex)))) +%% + (tptrans/pi DtransB DtransA) + DtransMLamL + DtransNLamL +%% + <- eqtm-comp DeqEMEN + (tptrans/pi + ([x] [d:vof x A] [ex] [xt] + DtransB' x d ex xt + : tptrans (EB' ex) (B' x) ktype) + (DtransA : tptrans EA A ktype)) + (DtransM : trans EM M (pi A ([x] B' x))) + (DtransN : trans EN M (pi A ([x] B' x))) + %% + <- ({x} {d} {ex} {ed} {xt} + vof-comp ed DtransA xt d + -> eqtm-comp (DeqApp ex ed) + (DtransB x d ex xt : tptrans (EB ex) (B x) ktype) + (trans/app % XXX output coverage? + (DsubB1y x : tpsub ([y] B1 x y) (X1 x) (B x)) + (DsubL1y x : sub ([y] L1 x y) (X1 x) (L x)) + (DtransX1 x d ex xt : trans ex (X1 x) (A1 x)) + (DtransMLam x d ex xt + : trans EM (lam [y] L1 x y) + (pi (A1 x) ([y] B1 x y)))) + (trans/app + (DsubB2y x : tpsub ([y] B2 x y) (X2 x) (B x)) + (DsubL2y x : sub ([y] L2 x y) (X2 x) (L x)) + (DtransX2 x d ex xt : trans ex (X2 x) _) + (DtransNLam x d ex xt + : trans EN (lam ([y] L2 x y)) + (pi (A2 x) ([y] B2 x y))))) + %% + <- tptrans-reg DtransA (DofA : kof A ktype) + <- can-simp A (Dsimp : simp A T) + <- ({x} can-expand x T (Dexpand x : expand x T (X x))) + <- ({x} {d} {ex} {xt} + trans-fun (DtransX1 x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX1X x : tm-eq (X1 x) (X x)) + (DeqA1A* x : tp-eq (A1 x) A)) + <- ({x} + sub-compat ([_] tm-eq/i) (DeqX1X x) tm-eq/i (DsubL1y x) + (DsubL1X x : sub ([y] L1 x y) (X x) (L x))) + <- ({x} + sub-expand _ (Dexpand x) (DsubL1X x) + (DeqLL1 x : tm-eq (L x) (L1 x x))) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX1X x) tp-eq/i (DsubB1y x) + (DsubB1X x : tpsub ([y] B1 x y) (X x) (B x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubB1X x) + (DeqBB1 x : tp-eq (B x) (B1 x x))) + %% + <- trans-reg DtransM (DofM : of M (pi A ([x] B' x))) + <- of-lam-invert DofM _ + ([x] [d] DofL' x d : of (L' x) (B' x)) + (DeqMLam' : tm-eq M (lam ([x] L' x))) + <- trans-resp DtransM etm-eq/i DeqMLam' tp-eq/i + (DtransMLam' : trans EM (lam [x] L' x) (pi A ([x] B' x))) + <- ({x} {d} {ex} {xt} + trans-fun (DtransMLam x d ex xt) DtransMLam' + (DeqLamL1L' x + : tm-eq (lam ([y] L1 x y)) (lam ([y] L' y))) + (DeqPiB1B' x + : tp-eq (pi (A1 x) ([y] B1 x y)) (pi A ([y] B' y)))) + <- ({x} + lam-inj (DeqLamL1L' x) + ([y] DeqL1L' x y : tm-eq (L1 x y) (L' y))) + <- ({x} + pi-inj (DeqPiB1B' x) + (DeqA1A x : tp-eq (A1 x) A) + ([y] DeqB1B' x y : tp-eq (B1 x y) (B' y))) + %% + <- ({x} + tm-eq-trans (DeqLL1 x) (DeqL1L' x x) + (DeqLL' x : tm-eq (L x) (L' x))) + <- ({x} tm-eq-sym (DeqLL' x) (DeqL'L x : tm-eq (L' x) (L x))) + <- lam-compat DeqL'L + (DeqLamL'L : tm-eq (lam [x] L' x) (lam [x] L x)) + <- ({x} + tp-eq-trans (DeqBB1 x) (DeqB1B' x x) + (DeqBB' x : tp-eq (B x) (B' x))) + <- ({x} tp-eq-sym (DeqBB' x) (DeqB'B x : tp-eq (B' x) (B x))) + <- pi-compat tp-eq/i DeqB'B + (DeqPiB'B : tp-eq (pi A [x] B' x) (pi A [x] B x)) + <- trans-resp DtransMLam' etm-eq/i DeqLamL'L DeqPiB'B + (DtransMLamL : trans EM (lam [x] L x) (pi A ([x] B x))) + %% Now do the same thing for N + <- ({x} {d} {ex} {xt} + trans-fun (DtransX2 x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX2X x : tm-eq (X2 x) (X x)) + (DeqA2A* x : tp-eq (A2 x) A)) + <- ({x} + sub-compat ([_] tm-eq/i) (DeqX2X x) tm-eq/i (DsubL2y x) + (DsubL2X x : sub ([y] L2 x y) (X x) (L x))) + <- ({x} + sub-expand _ (Dexpand x) (DsubL2X x) + (DeqLL2 x : tm-eq (L x) (L2 x x))) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX2X x) tp-eq/i (DsubB2y x) + (DsubB2X x : tpsub ([y] B2 x y) (X x) (B x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubB2X x) + (DeqBB2 x : tp-eq (B x) (B2 x x))) + %% + <- trans-resp DtransN etm-eq/i DeqMLam' tp-eq/i + (DtransNLam' : trans EN (lam [x] L' x) (pi A ([x] B' x))) + <- trans-resp DtransNLam' etm-eq/i DeqLamL'L DeqPiB'B + (DtransNLamL : trans EN (lam [x] L x) (pi A ([x] B x))). + +-beta : eqtm-comp + (eqtm/beta + (DofEN : eof EN EA) + ([ex] [dex:evof ex EA] + DofEM ex dex : eof (EM ex) (EB ex)) + : eqtm (eapp (elam EA ([ex] EM ex)) EN) (EM EN) (EB EN)) +%% + DtransBx + (trans/app + DsubB + DsubM + DtransN + (trans/lam + DtransM + DtransA)) + DtransMx +%% + <- of-comp DofEN + (DtransA : tptrans EA A ktype) + (DtransN : trans EN N A) + <- ({x} {d} {ex} {ed} {xt:vtrans ex x} + vof-comp ed DtransA xt d + -> of-comp (DofEM ex ed) + (DtransB x d ex xt : tptrans (EB ex) (B x) ktype) + (DtransM x d ex xt : trans (EM ex) (M x) (B x))) + %% + <- trans-sub DtransM DtransN + (DsubM : sub ([x] M x) N Mx) + (DsubB : tpsub ([x] B x) N Bx) + (DtransMx : trans (EM EN) Mx Bx) + <- tptrans-sub DtransB DtransN + (DsubB' : tpsub ([x] B x) N Bx') + _ + (DtransBx' : tptrans (EB EN) Bx' ktype) + <- tpsub-fun DsubB' DsubB + (DeqBx'Bx : tp-eq Bx' Bx) + <- tptrans-resp DtransBx' etp-eq/i DeqBx'Bx kind-eq/i + (DtransBx : tptrans (EB EN) Bx ktype). + +-sym : eqtm-comp + (eqtm/sym + (Deqtm : eqtm EN EM EA)) + DtransA + DtransM + DtransN + <- eqtm-comp Deqtm + (DtransA : tptrans EA A ktype) + (DtransN : trans EN N A) + (DtransM : trans EM N A). + +-trans : eqtm-comp + (eqtm/trans + (Deqtm2 : eqtm EN EO EA) + (Deqtm1 : eqtm EM EN EA)) + DtransA + DtransM + DtransO + <- eqtm-comp Deqtm1 + (DtransA : tptrans EA A ktype) + (DtransM : trans EM M A) + (DtransN : trans EN M A) + <- eqtm-comp Deqtm2 + (DtransA' : tptrans EA A' ktype) + (DtransN' : trans EN M' A') + (DtransO' : trans EO M' A') + <- trans-fun DtransN' DtransN + (DeqM'M : tm-eq M' M) + (DeqA'A : tp-eq A' A) + <- trans-resp DtransO' etm-eq/i DeqM'M DeqA'A + (DtransO : trans EO M A). + +-refl : eqtm-comp + (eqtm/refl + (Deof : eof EM EA)) + DtransA + DtransM + DtransM + <- of-comp Deof DtransA DtransM. + +-tcon : eqtm-comp + (eqtm/typecon + (DeqEAEB : eqtp EA EB ektype) + (DeqEMEN : eqtm EM EN EA)) +%% + DtransB + DtransM + DtransN +%% + <- eqtm-comp DeqEMEN + (DtransA : tptrans EA A ktype) + (DtransM : trans EM M A) + (DtransN : trans EN M A) + <- eqtp-comp DeqEAEB + ktrans/type + (DtransA' : tptrans EA A' ktype) + (DtransB' : tptrans EB A' ktype) + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) + _ + <- tptrans-resp DtransB' etp-eq/i DeqA'A kind-eq/i + (DtransB : tptrans EB A ktype). + +%%%% + +-app : eqtp-comp + (eqtp/app + (DeqEN : eqtm EN EN' EA) + (DeqEM : eqtp EM EM' (ekpi EA ([x] EB x))) + : eqtp (eaapp EM EN) (eaapp EM' EN') (EB EN)) +%% + DtransBx + (tptrans/app + DsubB + DsubL + DtransN + DtransMLam) + (tptrans/app + DsubB + DsubL + DtransN' + DtransM'Lam) +%% + <- eqtp-comp DeqEM + (ktrans/pi + ([x] [d:vof x A] [ex] [tr:vtrans ex x] + DtransB x d ex tr + : ktrans (EB ex) (B x)) + (DtransA : tptrans EA A ktype)) + (DtransM : tptrans EM M (kpi A ([x] B x))) + (DtransM' : tptrans EM' M (kpi A ([x] B x))) + <- tptrans-reg DtransM (DofM : kof M (kpi A ([x] B x))) + <- kof-lam-invert DofM + _ + ([x] [d] DofL x d : kof (L x) (B x)) + (DeqMLam : tp-eq M (alam ([x] L x))) + <- tptrans-resp DtransM etp-eq/i DeqMLam kind-eq/i + (DtransMLam : tptrans EM (alam [x] L x) (kpi A ([x] B x))) + <- tptrans-resp DtransM' etp-eq/i DeqMLam kind-eq/i + (DtransM'Lam : tptrans EM' (alam [x] L x) (kpi A ([x] B x))) + <- eqtm-comp DeqEN + (DtransA' : tptrans EA A' ktype) + (DtransN^ : trans EN N A') + (DtransN'^ : trans EN' N A') + % get type substitution + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) + _ + <- trans-reg DtransN^ (DofN' : of N A') + <- of-resp tm-eq/i DeqA'A DofN' + (DofN : of N A) + <- can-tpsub ([x] [d] DofL x d) DofN + (DsubL : tpsub ([x] L x) N Lx) + <- trans-resp DtransN^ etm-eq/i tm-eq/i DeqA'A + (DtransN : trans EN N A) + <- trans-resp DtransN'^ etm-eq/i tm-eq/i DeqA'A + (DtransN' : trans EN' N A) + % get kind substitution + <- ktrans-sub DtransB DtransN + (DsubB : ksub ([x] B x) N Bx) + (DtransBx : ktrans (EB EN) Bx). + +-lam : eqtp-comp + (eqtp/lam + ([ex] [ed:evof ex EA] + DeqEM ex ed : eqtp (EM ex) (EM' ex) (EB ex)) + (DeqEA : eqtp EA EA' ektype)) +%% + (ktrans/pi DtransB DtransA) + (tptrans/lam DtransM DtransA) + (tptrans/lam DtransM' DtransA') +%% + <- eqtp-comp DeqEA + ktrans/type + (DtransA : tptrans EA A ktype) + (DtransA' : tptrans EA' A ktype) + <- ({x} {d} {ex} {ed} {tr} + vof-comp ed DtransA tr d + -> eqtp-comp (DeqEM ex ed) + (DtransB x d ex tr : ktrans (EB ex) (B x)) + (DtransM x d ex tr : tptrans (EM ex) (M x) (B x)) + (DtransM' x d ex tr : tptrans (EM' ex) (M x) (B x))). + +-pi : eqtp-comp + (eqtp/pi + ([ex] [ed:evof ex EA] + DeqEM ex ed : eqtp (EM ex) (EM' ex) ektype) + (DeqEA : eqtp EA EA' ektype)) +%% + ktrans/type + (tptrans/pi DtransM DtransA) + (tptrans/pi DtransM' DtransA') +%% + <- eqtp-comp DeqEA + ktrans/type + (DtransA : tptrans EA A ktype) + (DtransA' : tptrans EA' A ktype) + <- ({x} {d} {ex} {ed} {tr} + vof-comp ed DtransA tr d + -> eqtp-comp (DeqEM ex ed) + ktrans/type + (DtransM x d ex tr : tptrans (EM ex) (M x) ktype) + (DtransM' x d ex tr : tptrans (EM' ex) (M x) ktype)). + +-ext : eqtp-comp + (eqtp/ext + ([ex] [ed:evof ex EA] + DeqApp ex ed + : eqtp (eaapp EM ex) (eaapp EN ex) (EB ex)) + (DofEN : ekof EN (ekpi EA ([ex] EB'' ex))) + (DofEM : ekof EM (ekpi EA ([ex] EB' ex)))) +%% + (ktrans/pi DtransB DtransA) + DtransMLamL + DtransNLamL +%% + <- kof-comp DofEM + (ktrans/pi + ([x] [d:vof x A] [ex] [xt] + DtransB' x d ex xt + : ktrans (EB' ex) (B' x)) + (DtransA : tptrans EA A ktype)) + (DtransM : tptrans EM M (kpi A ([x] B' x))) + <- kof-comp DofEN + (ktrans/pi + ([x] [d:vof x A'] [ex] [xt] + DtransB'' x d ex xt + : ktrans (EB'' ex) (B'' x)) + (DtransA' : tptrans EA A' ktype)) + (DtransN' : tptrans EN N (kpi A' ([x] B'' x))) + %% Fix DtransN' + <- tptrans-fun DtransA' DtransA + (DeqA'A : tp-eq A' A) _ + <- kpi-compat DeqA'A ([x] kind-eq/i) + (DeqPiA'A : kind-eq (kpi A' [x] B'' x) (kpi A ([x] B'' x))) + <- tptrans-resp DtransN' etp-eq/i tp-eq/i DeqPiA'A + (DtransN : tptrans EN N (kpi A ([x] B'' x))) + %% + <- ({x} {d} {ex} {ed} {xt} + vof-comp ed DtransA xt d + -> eqtp-comp (DeqApp ex ed) + (DtransB x d ex xt : ktrans (EB ex) (B x)) + (tptrans/app + (DsubB1y x : ksub ([y] B1 x y) (X1 x) (B x)) + (DsubL1y x : tpsub ([y] L1 x y) (X1 x) (L x)) + (DtransX1 x d ex xt : trans ex (X1 x) (A1 x)) + (DtransMLam x d ex xt + : tptrans EM (alam [y] L1 x y) + (kpi (A1 x) ([y] B1 x y)))) + (tptrans/app + (DsubB2y x : ksub ([y] B2 x y) (X2 x) (B x)) + (DsubL2y x : tpsub ([y] L2 x y) (X2 x) (L x)) + (DtransX2 x d ex xt : trans ex (X2 x) _) + (DtransNLam x d ex xt + : tptrans EN (alam ([y] L2 x y)) + (kpi (A2 x) ([y] B2 x y))))) + %% + <- tptrans-reg DtransA (DofA : kof A ktype) + <- can-simp A (Dsimp : simp A T) + <- ({x} can-expand x T (Dexpand x : expand x T (X x))) + <- ({x} {d} {ex} {xt} + trans-fun (DtransX1 x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX1X x : tm-eq (X1 x) (X x)) + (DeqA1A* x : tp-eq (A1 x) A)) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX1X x) tp-eq/i (DsubL1y x) + (DsubL1X x : tpsub ([y] L1 x y) (X x) (L x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubL1X x) + (DeqLL1 x : tp-eq (L x) (L1 x x))) + <- ({x} + ksub-compat ([_] kind-eq/i) (DeqX1X x) kind-eq/i (DsubB1y x) + (DsubB1X x : ksub ([y] B1 x y) (X x) (B x))) + <- ({x} + ksub-expand _ (Dexpand x) (DsubB1X x) + (DeqBB1 x : kind-eq (B x) (B1 x x))) + %% + <- tptrans-reg DtransM (DofM : kof M (kpi A ([x] B' x))) + <- kof-lam-invert DofM _ + ([x] [d] DofL' x d : kof (L' x) (B' x)) + (DeqMLam' : tp-eq M (alam ([x] L' x))) + <- tptrans-resp DtransM etp-eq/i DeqMLam' kind-eq/i + (DtransMLam' : tptrans EM (alam [x] L' x) (kpi A ([x] B' x))) + <- ({x} {d} {ex} {xt} + tptrans-fun (DtransMLam x d ex xt) DtransMLam' + (DeqLamL1L' x + : tp-eq (alam ([y] L1 x y)) (alam ([y] L' y))) + (DeqPiB1B' x + : kind-eq (kpi (A1 x) ([y] B1 x y)) (kpi A ([y] B' y)))) + <- ({x} + alam-inj (DeqLamL1L' x) + ([y] DeqL1L' x y : tp-eq (L1 x y) (L' y))) + <- ({x} + kpi-inj (DeqPiB1B' x) + (DeqA1A x : tp-eq (A1 x) A) + ([y] DeqB1B' x y : kind-eq (B1 x y) (B' y))) + %% + <- ({x} + tp-eq-trans (DeqLL1 x) (DeqL1L' x x) + (DeqLL' x : tp-eq (L x) (L' x))) + <- ({x} tp-eq-sym (DeqLL' x) (DeqL'L x : tp-eq (L' x) (L x))) + <- alam-compat DeqL'L + (DeqLamL'L : tp-eq (alam [x] L' x) (alam [x] L x)) + <- ({x} + kind-eq-trans (DeqBB1 x) (DeqB1B' x x) + (DeqBB' x : kind-eq (B x) (B' x))) + <- ({x} kind-eq-sym (DeqBB' x) (DeqB'B x : kind-eq (B' x) (B x))) + <- kpi-compat tp-eq/i DeqB'B + (DeqPiB'B : kind-eq (kpi A [x] B' x) (kpi A [x] B x)) + <- tptrans-resp DtransMLam' etp-eq/i DeqLamL'L DeqPiB'B + (DtransMLamL : tptrans EM (alam [x] L x) (kpi A ([x] B x))) + %% Now do the same thing for N + <- ({x} {d} {ex} {xt} + trans-fun (DtransX2 x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX2X x : tm-eq (X2 x) (X x)) + (DeqA2A* x : tp-eq (A2 x) A)) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX2X x) tp-eq/i (DsubL2y x) + (DsubL2X x : tpsub ([y] L2 x y) (X x) (L x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubL2X x) + (DeqLL2 x : tp-eq (L x) (L2 x x))) + <- ({x} + ksub-compat ([_] kind-eq/i) (DeqX2X x) kind-eq/i (DsubB2y x) + (DsubB2X x : ksub ([y] B2 x y) (X x) (B x))) + <- ({x} + ksub-expand _ (Dexpand x) (DsubB2X x) + (DeqBB2 x : kind-eq (B x) (B2 x x))) + %% + <- tptrans-reg DtransN (DofN : kof N (kpi A ([x] B'' x))) + <- kof-lam-invert DofN _ + ([x] [d] DofL'' x d : kof (L'' x) (B'' x)) + (DeqNLam'' : tp-eq N (alam ([x] L'' x))) + <- tptrans-resp DtransN etp-eq/i DeqNLam'' kind-eq/i + (DtransNLam'' : tptrans EN (alam [x] L'' x) (kpi A ([x] B'' x))) + <- ({x} {d} {ex} {xt} + tptrans-fun (DtransNLam x d ex xt) DtransNLam'' + (DeqLamL2L'' x + : tp-eq (alam ([y] L2 x y)) (alam ([y] L'' y))) + (DeqPiB2B'' x + : kind-eq (kpi (A2 x) ([y] B2 x y)) (kpi A ([y] B'' y)))) + <- ({x} + alam-inj (DeqLamL2L'' x) + ([y] DeqL2L'' x y : tp-eq (L2 x y) (L'' y))) + <- ({x} + kpi-inj (DeqPiB2B'' x) + (DeqA2A x : tp-eq (A2 x) A) + ([y] DeqB2B'' x y : kind-eq (B2 x y) (B'' y))) + %% + <- ({x} + tp-eq-trans (DeqLL2 x) (DeqL2L'' x x) + (DeqLL'' x : tp-eq (L x) (L'' x))) + <- ({x} tp-eq-sym (DeqLL'' x) (DeqL''L x : tp-eq (L'' x) (L x))) + <- alam-compat DeqL''L + (DeqLamL''L : tp-eq (alam [x] L'' x) (alam [x] L x)) + <- ({x} + kind-eq-trans (DeqBB2 x) (DeqB2B'' x x) + (DeqBB'' x : kind-eq (B x) (B'' x))) + <- ({x} kind-eq-sym (DeqBB'' x) (DeqB''B x : kind-eq (B'' x) (B x))) + <- kpi-compat tp-eq/i DeqB''B + (DeqPiB''B : kind-eq (kpi A [x] B'' x) (kpi A [x] B x)) + <- tptrans-resp DtransNLam'' etp-eq/i DeqLamL''L DeqPiB''B + (DtransNLamL : tptrans EN (alam [x] L x) (kpi A ([x] B x))). + +-extw : eqtp-comp + (eqtp/extw + ([ex] [ed:evof ex EA] + DeqApp ex ed + : eqtp (eaapp EM ex) (eaapp EN ex) (EB ex)) + (DeqEMEN : eqtp EM EN (ekpi EA ([ex] EB' ex)))) +%% + (ktrans/pi DtransB DtransA) + DtransMLamL + DtransNLamL +%% + <- eqtp-comp DeqEMEN + (ktrans/pi + ([x] [d:vof x A] [ex] [xt] + DtransB' x d ex xt + : ktrans (EB' ex) (B' x)) + (DtransA : tptrans EA A ktype)) + (DtransM : tptrans EM M (kpi A ([x] B' x))) + (DtransN : tptrans EN M (kpi A ([x] B' x))) + %% + <- ({x} {d} {ex} {ed} {xt} + vof-comp ed DtransA xt d + -> eqtp-comp (DeqApp ex ed) + (DtransB x d ex xt : ktrans (EB ex) (B x)) + (tptrans/app % XXX output coverage? + (DsubB1y x : ksub ([y] B1 x y) (X1 x) (B x)) + (DsubL1y x : tpsub ([y] L1 x y) (X1 x) (L x)) + (DtransX1 x d ex xt : trans ex (X1 x) (A1 x)) + (DtransMLam x d ex xt + : tptrans EM (alam [y] L1 x y) + (kpi (A1 x) ([y] B1 x y)))) + (tptrans/app + (DsubB2y x : ksub ([y] B2 x y) (X2 x) (B x)) + (DsubL2y x : tpsub ([y] L2 x y) (X2 x) (L x)) + (DtransX2 x d ex xt : trans ex (X2 x) _) + (DtransNLam x d ex xt + : tptrans EN (alam ([y] L2 x y)) + (kpi (A2 x) ([y] B2 x y))))) + %% + <- tptrans-reg DtransA (DofA : kof A ktype) + <- can-simp A (Dsimp : simp A T) + <- ({x} can-expand x T (Dexpand x : expand x T (X x))) + <- ({x} {d} {ex} {xt} + trans-fun (DtransX1 x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX1X x : tm-eq (X1 x) (X x)) + (DeqA1A* x : tp-eq (A1 x) A)) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX1X x) tp-eq/i (DsubL1y x) + (DsubL1X x : tpsub ([y] L1 x y) (X x) (L x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubL1X x) + (DeqLL1 x : tp-eq (L x) (L1 x x))) + <- ({x} + ksub-compat ([_] kind-eq/i) (DeqX1X x) kind-eq/i (DsubB1y x) + (DsubB1X x : ksub ([y] B1 x y) (X x) (B x))) + <- ({x} + ksub-expand _ (Dexpand x) (DsubB1X x) + (DeqBB1 x : kind-eq (B x) (B1 x x))) + %% + <- tptrans-reg DtransM (DofM : kof M (kpi A ([x] B' x))) + <- kof-lam-invert DofM _ + ([x] [d] DofL' x d : kof (L' x) (B' x)) + (DeqMLam' : tp-eq M (alam ([x] L' x))) + <- tptrans-resp DtransM etp-eq/i DeqMLam' kind-eq/i + (DtransMLam' : tptrans EM (alam [x] L' x) (kpi A ([x] B' x))) + <- ({x} {d} {ex} {xt} + tptrans-fun (DtransMLam x d ex xt) DtransMLam' + (DeqLamL1L' x + : tp-eq (alam ([y] L1 x y)) (alam ([y] L' y))) + (DeqPiB1B' x + : kind-eq (kpi (A1 x) ([y] B1 x y)) (kpi A ([y] B' y)))) + <- ({x} + alam-inj (DeqLamL1L' x) + ([y] DeqL1L' x y : tp-eq (L1 x y) (L' y))) + <- ({x} + kpi-inj (DeqPiB1B' x) + (DeqA1A x : tp-eq (A1 x) A) + ([y] DeqB1B' x y : kind-eq (B1 x y) (B' y))) + %% + <- ({x} + tp-eq-trans (DeqLL1 x) (DeqL1L' x x) + (DeqLL' x : tp-eq (L x) (L' x))) + <- ({x} tp-eq-sym (DeqLL' x) (DeqL'L x : tp-eq (L' x) (L x))) + <- alam-compat DeqL'L + (DeqLamL'L : tp-eq (alam [x] L' x) (alam [x] L x)) + <- ({x} + kind-eq-trans (DeqBB1 x) (DeqB1B' x x) + (DeqBB' x : kind-eq (B x) (B' x))) + <- ({x} kind-eq-sym (DeqBB' x) (DeqB'B x : kind-eq (B' x) (B x))) + <- kpi-compat tp-eq/i DeqB'B + (DeqPiB'B : kind-eq (kpi A [x] B' x) (kpi A [x] B x)) + <- tptrans-resp DtransMLam' etp-eq/i DeqLamL'L DeqPiB'B + (DtransMLamL : tptrans EM (alam [x] L x) (kpi A ([x] B x))) + %% Now do the same thing for N + <- ({x} {d} {ex} {xt} + trans-fun (DtransX2 x d ex xt) + (trans/var (Dexpand x) Dsimp DofA d xt) + (DeqX2X x : tm-eq (X2 x) (X x)) + (DeqA2A* x : tp-eq (A2 x) A)) + <- ({x} + tpsub-compat ([_] tp-eq/i) (DeqX2X x) tp-eq/i (DsubL2y x) + (DsubL2X x : tpsub ([y] L2 x y) (X x) (L x))) + <- ({x} + tpsub-expand _ (Dexpand x) (DsubL2X x) + (DeqLL2 x : tp-eq (L x) (L2 x x))) + <- ({x} + ksub-compat ([_] kind-eq/i) (DeqX2X x) kind-eq/i (DsubB2y x) + (DsubB2X x : ksub ([y] B2 x y) (X x) (B x))) + <- ({x} + ksub-expand _ (Dexpand x) (DsubB2X x) + (DeqBB2 x : kind-eq (B x) (B2 x x))) + %% + <- tptrans-resp DtransN etp-eq/i DeqMLam' kind-eq/i + (DtransNLam' : tptrans EN (alam [x] L' x) (kpi A ([x] B' x))) + <- tptrans-resp DtransNLam' etp-eq/i DeqLamL'L DeqPiB'B + (DtransNLamL : tptrans EN (alam [x] L x) (kpi A ([x] B x))). + +-beta : eqtp-comp + (eqtp/beta + (DofEN : eof EN EA) + ([ex] [dex:evof ex EA] + DofEM ex dex : ekof (EM ex) (EB ex)) + : eqtp (eaapp (ealam EA ([ex] EM ex)) EN) (EM EN) (EB EN)) +%% + DtransBx + (tptrans/app + DsubB + DsubM + DtransN + (tptrans/lam + DtransM + DtransA)) + DtransMx +%% + <- of-comp DofEN + (DtransA : tptrans EA A ktype) + (DtransN : trans EN N A) + <- ({x} {d} {ex} {ed} {xt:vtrans ex x} + vof-comp ed DtransA xt d + -> kof-comp (DofEM ex ed) + (DtransB x d ex xt : ktrans (EB ex) (B x)) + (DtransM x d ex xt : tptrans (EM ex) (M x) (B x))) + %% + <- tptrans-sub DtransM DtransN + (DsubM : tpsub ([x] M x) N Mx) + (DsubB : ksub ([x] B x) N Bx) + (DtransMx : tptrans (EM EN) Mx Bx) + <- ktrans-sub DtransB DtransN + (DsubB' : ksub ([x] B x) N Bx') + (DtransBx' : ktrans (EB EN) Bx') + <- ksub-fun DsubB' DsubB + (DeqBx'Bx : kind-eq Bx' Bx) + <- ktrans-resp DtransBx' ekind-eq/i DeqBx'Bx + (DtransBx : ktrans (EB EN) Bx). + +-sym : eqtp-comp + (eqtp/sym (Deqtm : eqtp EN EM EA)) + DtransA + DtransM + DtransN + <- eqtp-comp Deqtm + (DtransA : ktrans EA A) + (DtransN : tptrans EN N A) + (DtransM : tptrans EM N A). + +-trans : eqtp-comp + (eqtp/trans + (Deqtm2 : eqtp EN EO EA) + (Deqtm1 : eqtp EM EN EA)) + DtransA + DtransM + DtransO + <- eqtp-comp Deqtm1 + (DtransA : ktrans EA A) + (DtransM : tptrans EM M A) + (DtransN : tptrans EN M A) + <- eqtp-comp Deqtm2 + (DtransA' : ktrans EA A') + (DtransN' : tptrans EN M' A') + (DtransO' : tptrans EO M' A') + <- tptrans-fun DtransN' DtransN + (DeqM'M : tp-eq M' M) + (DeqA'A : kind-eq A' A) + <- tptrans-resp DtransO' etp-eq/i DeqM'M DeqA'A + (DtransO : tptrans EO M A). + +-refl : eqtp-comp + (eqtp/refl + (Deof : ekof EM EA)) + DtransA + DtransM + DtransM + <- kof-comp Deof DtransA DtransM. + +-tcon : eqtp-comp + (eqtp/kcon + (DeqEAEB : eqkind EA EB) + (DeqEMEN : eqtp EM EN EA)) +%% + DtransB + DtransM + DtransN +%% + <- eqtp-comp DeqEMEN + (DtransA : ktrans EA A) + (DtransM : tptrans EM M A) + (DtransN : tptrans EN M A) + <- eqkind-comp DeqEAEB + (DtransA' : ktrans EA A') + (DtransB' : ktrans EB A') + <- ktrans-fun DtransA' DtransA + (DeqA'A : kind-eq A' A) + <- ktrans-resp DtransB' ekind-eq/i DeqA'A + (DtransB : ktrans EB A). + +%%%% + +-tp : eqkind-comp eqkind/tp ktrans/type ktrans/type. + +-pi : eqkind-comp + (eqkind/pi + ([ex] [ed:evof ex EA] + DeqEM ex ed : eqkind (EM ex) (EM' ex)) + (DeqEA : eqtp EA EA' ektype)) +%% + (ktrans/pi DtransM DtransA) + (ktrans/pi DtransM' DtransA') +%% + <- eqtp-comp DeqEA + ktrans/type + (DtransA : tptrans EA A ktype) + (DtransA' : tptrans EA' A ktype) + <- ({x} {d} {ex} {ed} {tr} + vof-comp ed DtransA tr d + -> eqkind-comp (DeqEM ex ed) + (DtransM x d ex tr : ktrans (EM ex) (M x)) + (DtransM' x d ex tr : ktrans (EM' ex) (M x))). + +-sym : eqkind-comp + (eqkind/sym (Deqtm : eqkind EN EM)) + DtransM + DtransN + <- eqkind-comp Deqtm + (DtransN : ktrans EN N) + (DtransM : ktrans EM N). + +-trans : eqkind-comp + (eqkind/trans + (Deqtm2 : eqkind EN EO) + (Deqtm1 : eqkind EM EN)) + DtransM + DtransO + <- eqkind-comp Deqtm1 + (DtransM : ktrans EM M) + (DtransN : ktrans EN M) + <- eqkind-comp Deqtm2 + (DtransN' : ktrans EN M') + (DtransO' : ktrans EO M') + <- ktrans-fun DtransN' DtransN + (DeqM'M : kind-eq M' M) + <- ktrans-resp DtransO' ekind-eq/i DeqM'M + (DtransO : ktrans EO M). + +-refl : eqkind-comp + (eqkind/refl + (Deof : ewfkind EM)) + DtransM + DtransM + <- wfkind-comp Deof DtransM _. + +%worlds (bind | cbind | tcsig | tasig) + (vof-comp _ _ _ _) (of-comp _ _ _) (kof-comp _ _ _) (wfkind-comp _ _ _) + (eqtm-comp _ _ _ _) (eqtp-comp _ _ _ _) (eqkind-comp _ _ _). +%total (D0 D1 D2 D3 D4 D6 D7) + (vof-comp D0 _ _ _) (of-comp D1 _ _) (kof-comp D2 _ _) (wfkind-comp D3 _ _) + (eqtm-comp D7 _ _ _) (eqtp-comp D4 _ _ _) (eqkind-comp D6 _ _). diff --git a/src/constant.elf b/src/constant.elf new file mode 100644 index 0000000..2d6c16d --- /dev/null +++ b/src/constant.elf @@ -0,0 +1,4 @@ +%% Shared syntactic class of term and type constants. %% + +ctm : type. +ctp : type. diff --git a/src/convert-effect.thm b/src/convert-effect.thm new file mode 100644 index 0000000..0f1f26d --- /dev/null +++ b/src/convert-effect.thm @@ -0,0 +1,201 @@ +%% worlds %% + +%% for splitting +vof-const-contra : vof (const C) _ -> false -> type. +%mode vof-const-contra +X1 -X2. +%worlds (csig | asig | bind | var | ovar) (vof-const-contra _ _). +%total {} (vof-const-contra _ _). + +%% worlds invariants +convert-vof : vof X A + -> vtrans EX X + -> tpconvert A ktype EA + -> evof EX EA -> type. +%mode convert-vof +X1 -X2 -X3 -X4. + +vtrans-variable : vtrans EX X -> variable EX -> type. +%mode vtrans-variable +X1 -X2. + +%block sbind : some {A:tp} {EA:etp} {d_tpconvert:tpconvert A ktype EA} + block {x:atm} {d:vof x A} + {ex:etm} {dt:vtrans ex x} + {ed:evof ex EA} + {dv:variable ex} + {thm1:vtrans-variable dt dv} + {thm2:convert-vof d dt d_tpconvert ed}. + +%{ + same as sbind but w/o the some-bound tpconvert (and corresponding theorem + case). This is the world at which we'll actually prove the + vtrans-variable invariant since it causes Twelf to split correctly. +}% +%block sbind' : some {A:tp} {EA:etp} + block {x:atm} {d:vof x A} + {ex:etm} {dt:vtrans ex x} + {ed:evof ex EA} + {dv:variable ex} + {thm1:vtrans-variable dt dv}. + +%% another couple of worlds for later explicit contexts lemmas. +%block tvobind : some {I:nat} + block {x:atm} {d:isvar x I} + {ex:etm} {dt:vtrans ex x} + {dv:variable ex} + {thm:vtrans-variable dt dv}. +%block tvvar : block {x:atm} {ex:etm} {xt:vtrans ex x} + {dv:variable ex} + {thm:vtrans-variable xt dv}. + + +% get this to split +- : convert-vof (Dvof : vof aca _) + Dvtrans + Dtconvert + Devof + <- vof-const-contra Dvof Dfalse + <- false-implies-vtrans Dfalse Dvtrans + <- false-implies-tpconvert Dfalse Dtconvert + <- false-implies-evof Dfalse Devof. + +%worlds (csig-ei | asig-ei | sbind' | tvobind | tvvar | evvar | bind) (vtrans-variable _ _). +%total {} (vtrans-variable _ _). + +%worlds (csig-ei | asig-ei | sbind | tvar | tvvar) (convert-vof _ _ _ _). +%total {} (convert-vof _ _ _ _). + + +can-convert : of M A -> convert M A EM -> type. +%mode can-convert +X1 -X2. + +can-aconvert : at-of R A -> aconvert R A EM -> type. +%mode can-aconvert +X1 -X2. + +can-tpconvert : kof A K -> tpconvert A K EA -> type. +%mode can-tpconvert +X1 -X2. + +can-atpconvert : at-kof P K -> atpconvert P K EA -> type. +%mode can-atpconvert +X1 -X2. + +can-kconvert : wfkind K -> kconvert K EK -> type. +%mode can-kconvert +X1 -X2. + +-const : can-aconvert + (at-of/const + (DofA : kof A ktype) + (Dcof : cof C A)) + (aconvert/const DconvertA DofA Dcof) + <- can-tpconvert DofA DconvertA. + +-var : can-aconvert + (at-of/var + (Dkof : kof A ktype) + (Dvof : vof X A)) + (aconvert/var Dvtrans Dtpconvert Dkof Dvof) + <- convert-vof Dvof Dvtrans _ _ + <- can-tpconvert Dkof Dtpconvert. + +-app : can-aconvert + (at-of/app + (Dtpsub : tpsub ([x] B x) N Bx) + (DofN : of N A) + (DofR : at-of R (pi A ([x] B x)))) + (aconvert/app Dtpsub DconvertN DconvertR) + <- can-aconvert DofR DconvertR + <- can-convert DofN DconvertN. + +-at : can-convert + (of/at (DofR : at-of R (base P))) + (convert/at DconvertR) + <- can-aconvert DofR DconvertR. + +-lam : can-convert + (of/lam DofA ([x] [d:vof x A] DofM x d)) + (convert/lam DconvertM DconvertA) + <- can-tpconvert DofA DconvertA + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} + {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv -> + convert-vof d xt DconvertA ed + -> can-convert (DofM x d) + (DconvertM x d ex xt + : convert (M x) (B x) (EM ex))). + +%% + +-aconst : can-atpconvert + (at-kof/const + (Dwfkind : wfkind K) + (Dckof : ckof A K)) + (atpconvert/const Dkconvert Dwfkind Dckof) + <- can-kconvert Dwfkind Dkconvert. + +-app : can-atpconvert + (at-kof/app + (Dksub : ksub ([x] K x) M Kx) + (DofM : of M B) + (DofP : at-kof P (kpi B ([x] K x)))) + (atpconvert/app Dksub DconvertM DconvertP) + <- can-atpconvert DofP DconvertP + <- can-convert DofM DconvertM. + +-base : can-tpconvert + (kof/base (DofP : at-kof P ktype)) + (tpconvert/base DconvertP) + <- can-atpconvert DofP DconvertP. + +-lam : can-tpconvert + (kof/lam ([x] [d:vof x A] DofM x d) DofA) + (tpconvert/lam DconvertM DconvertA) + <- can-tpconvert DofA DconvertA + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} + {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv -> + convert-vof d xt DconvertA ed + -> can-tpconvert (DofM x d) + (DconvertM x d ex xt + : tpconvert (M x) (B x) (EM ex))). + +-pi : can-tpconvert + (kof/pi ([x] [d:vof x A] DofM x d) DofA) + (tpconvert/pi DconvertM DconvertA) + <- can-tpconvert DofA DconvertA + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} + {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv -> + convert-vof d xt DconvertA ed + -> can-tpconvert (DofM x d) + (DconvertM x d ex xt + : tpconvert (M x) ktype (EM ex))). + +%% + +-type : can-kconvert wfkind/tp kconvert/type. + +-pi : can-kconvert + (wfkind/pi ([x] [d:vof x A] DofM x d) DofA) + (kconvert/pi DconvertM DconvertA) + <- can-tpconvert DofA DconvertA + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} + {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv -> + convert-vof d xt DconvertA ed + -> can-kconvert (DofM x d) + (DconvertM x d ex xt + : kconvert (M x) (EM ex))). + +%worlds (csig-ei | asig-ei | tvar | tvvar | sbind) +(can-aconvert _ _) +(can-convert _ _) +(can-atpconvert _ _) +(can-tpconvert _ _) +(can-kconvert _ _). +%total (D1 D2 D3 D4 D5) +(can-aconvert D1 _) +(can-convert D2 _) +(can-atpconvert D3 _) +(can-tpconvert D4 _) +(can-kconvert D5 _). diff --git a/src/convert-explicit.thm b/src/convert-explicit.thm new file mode 100644 index 0000000..14996ec --- /dev/null +++ b/src/convert-explicit.thm @@ -0,0 +1,1452 @@ + +mconvert : convert M A _ -> metric -> type. +maconvert : aconvert R A _ -> metric -> type. +mtpconvert : tpconvert A K _ -> metric -> type. +matpconvert : atpconvert P K _ -> metric -> type. +mkconvert : kconvert K _ -> metric -> type. + +mconvert/at : mconvert (convert/at Daconvert) (msing M) + <- maconvert Daconvert M. + +mconvert/lam : mconvert + (convert/lam + ([x] [d] [ex] [xt] DconvertM x d ex xt) + DconvertA) + (mpair MM MA) + <- mtpconvert DconvertA MA + <- ({x} {d} {ex} {xt} + mconvert (DconvertM x d ex xt) MM). + +maconvert/const : maconvert (aconvert/const Dtpconvert Dkof _) + (mpair M M') + <- mkof Dkof M' + <- mtpconvert Dtpconvert M. + +maconvert/var : maconvert (aconvert/var _ Dtpconvert Dkof _) + % (mpair M M') + (msing M) + <- mkof Dkof M' + <- mtpconvert Dtpconvert M. + +maconvert/app : maconvert (aconvert/app _ Dconvert Daconvert) + (mpair MM MR) + <- maconvert Daconvert MR + <- mconvert Dconvert MM. + +mtpconvert/base : mtpconvert (tpconvert/base Datpconvert) (msing M) + <- matpconvert Datpconvert M. + +mtpconvert/pi : mtpconvert + (tpconvert/pi + ([x] [d] [ex] [xt] DconvertB x d ex xt) + DconvertA) + (mpair MB MA) + <- mtpconvert DconvertA MA + <- ({x} {d} {ex} {xt} + mtpconvert (DconvertB x d ex xt) MB). + +mtpconvert/lam : mtpconvert + (tpconvert/lam + ([x] [d] [ex] [xt] DconvertB x d ex xt) + DconvertA) + (mpair MB MA) + <- mtpconvert DconvertA MA + <- ({x} {d} {ex} {xt} + mtpconvert (DconvertB x d ex xt) MB). + +matpconvert/const : matpconvert + (atpconvert/const Dkconvert Dwf _) + (mpair M M') + <- mwfkind Dwf M' + <- mkconvert Dkconvert M. + +matpconvert/app : matpconvert + (atpconvert/app _ Dconv Datpconv) (mpair M1 M2) + <- matpconvert Datpconv M2 + <- mconvert Dconv M1. + +mkconvert/type : mkconvert kconvert/type munit. + +mkconvert/pi : mkconvert + (kconvert/pi + ([x] [d] [ex] [xt] Dkconvert x d ex xt) + Dtpconvert) + (mpair MK MA) + <- mtpconvert Dtpconvert MA + <- ({x} {d} {ex} {xt} + mkconvert (Dkconvert x d ex xt) MK). + +mconverte : converte G M A _ -> metric -> type. +maconverte : aconverte G R A _ -> metric -> type. +mtpconverte : tpconverte G A K _ -> metric -> type. +matpconverte : atpconverte G A K _ -> metric -> type. +mkconverte : kconverte G K _ -> metric -> type. + +mconverte/at : mconverte (converte/at Daconvert) (msing M) + <- maconverte Daconvert M. + +mconverte/lam : mconverte + (converte/lam + ([x] [ex] [xt] DconvertM x ex xt) + DconvertA) + (mpair MM MA) + <- mtpconverte DconvertA MA + <- ({x} {ex} {xt} + mconverte (DconvertM x ex xt) MM). + +maconverte/const : maconverte (aconverte/const Dtpconvert Dkof _) + (mpair M M') + <- mkof Dkof M' + <- mtpconverte Dtpconvert M. + +maconverte/var : maconverte (aconverte/var _ Dtpconvert _) (msing M) + <- mtpconverte Dtpconvert M. + +maconverte/vari : maconverte (aconverte/vari _ Dtpconvert Dkof _) + % (mpair M M') + (msing M) + <- mkof Dkof M' + <- mtpconverte Dtpconvert M. + +maconverte/app : maconverte (aconverte/app _ Dconvert Daconvert) + (mpair MM MR) + <- maconverte Daconvert MR + <- mconverte Dconvert MM. + +mtpconverte/base : mtpconverte (tpconverte/base Datpconvert) (msing M) + <- matpconverte Datpconvert M. + +mtpconverte/pi : mtpconverte + (tpconverte/pi + ([x] [ex] [xt] DconvertB x ex xt) + DconvertA) + (mpair MB MA) + <- mtpconverte DconvertA MA + <- ({x} {ex} {xt} + mtpconverte (DconvertB x ex xt) MB). + +mtpconverte/lam : mtpconverte + (tpconverte/lam + ([x] [ex] [xt] DconvertB x ex xt) + DconvertA) + (mpair MB MA) + <- mtpconverte DconvertA MA + <- ({x} {ex} {xt} + mtpconverte (DconvertB x ex xt) MB). + +matpconverte/const : matpconverte + (atpconverte/const Dkconvert Dwf _) + (mpair M M') + <- mwfkind Dwf M' + <- mkconverte Dkconvert M. + +matpconverte/app : matpconverte + (atpconverte/app _ Dconv Datpconv) (mpair M1 M2) + <- matpconverte Datpconv M2 + <- mconverte Dconv M1. + +mkconverte/type : mkconverte kconverte/type munit. + +mkconverte/pi : mkconverte + (kconverte/pi + ([x] [ex] [xt] Dkconvert x ex xt) + Dtpconvert) + (mpair MK MA) + <- mtpconverte Dtpconvert MA + <- ({x} {ex} {xt} + mkconverte (Dkconvert x ex xt) MK). + + +can-mconvert : {D:convert _ _ _} mconvert D M -> type. +%mode can-mconvert +X1 -X2. + +can-maconvert : {D:aconvert _ _ _} maconvert D M -> type. +%mode can-maconvert +X1 -X2. + +can-mtpconvert : {D:tpconvert _ _ _} mtpconvert D M -> type. +%mode can-mtpconvert +X1 -X2. + +can-matpconvert : {D:atpconvert _ _ _} matpconvert D M -> type. +%mode can-matpconvert +X1 -X2. + +can-mkconvert : {D:kconvert _ _} mkconvert D M -> type. +%mode can-mkconvert +X1 -X2. + +-at : can-mconvert (convert/at Daconv) (mconvert/at Dmaconv) + <- can-maconvert Daconv Dmaconv. + +-lam : can-mconvert + (convert/lam DconvM DconvA) + (mconvert/lam DmconvM DmconvA) + <- ({x} {d} {ex} {xt} + can-mconvert (DconvM x d ex xt) (DmconvM x d ex xt)) + <- can-mtpconvert DconvA DmconvA. + +-const : can-maconvert + (aconvert/const Dtconv Dwf Dcof) + (maconvert/const Dmtconv Dmwf) + <- can-mtpconvert Dtconv Dmtconv + <- can-mkof Dwf Dmwf. + +-var : can-maconvert + (aconvert/var _ Dtconv Dkof _) + (maconvert/var Dmtconv Dmkof) + <- can-mtpconvert Dtconv Dmtconv + <- can-mkof Dkof Dmkof. + +-app : can-maconvert + (aconvert/app _ Dconv Daconv) + (maconvert/app Dmconv Dmaconv) + <- can-maconvert Daconv Dmaconv + <- can-mconvert Dconv Dmconv. + +-base : can-mtpconvert + (tpconvert/base Daconv) + (mtpconvert/base Dmaconv) + <- can-matpconvert Daconv Dmaconv. + +-lam : can-mtpconvert + (tpconvert/lam DconvM DconvA) + (mtpconvert/lam DmconvM DmconvA) + <- ({x} {d} {ex} {xt} + can-mtpconvert (DconvM x d ex xt) (DmconvM x d ex xt)) + <- can-mtpconvert DconvA DmconvA. + +-pi : can-mtpconvert + (tpconvert/pi DconvM DconvA) + (mtpconvert/pi DmconvM DmconvA) + <- ({x} {d} {ex} {xt} + can-mtpconvert (DconvM x d ex xt) (DmconvM x d ex xt)) + <- can-mtpconvert DconvA DmconvA. + +-const : can-matpconvert + (atpconvert/const Dkconv Dwf _) + (matpconvert/const Dmkconv Dmwf) + <- can-mkconvert Dkconv Dmkconv + <- can-mwfkind Dwf Dmwf. + +-app : can-matpconvert + (atpconvert/app _ Dconv Daconv) + (matpconvert/app Dmconv Dmaconv) + <- can-matpconvert Daconv Dmaconv + <- can-mconvert Dconv Dmconv. + +-type : can-mkconvert kconvert/type mkconvert/type. + +-pi : can-mkconvert + (kconvert/pi DconvM DconvA) + (mkconvert/pi DmconvM DmconvA) + <- ({x} {d} {ex} {xt} + can-mkconvert (DconvM x d ex xt) (DmconvM x d ex xt)) + <- can-mtpconvert DconvA DmconvA. + +%worlds (csig-ei | asig-ei | bind | ovar | evvar | tvar | tbind | sbind') + (can-mconvert _ _) + (can-maconvert _ _) + (can-mtpconvert _ _) + (can-matpconvert _ _) + (can-mkconvert _ _). +%total (D1 D2 D3 D4 D5) + (can-mconvert D1 _) + (can-maconvert D2 _) + (can-mtpconvert D3 _) + (can-matpconvert D4 _) + (can-mkconvert D5 _). + + +can-mconverte : {D:converte _ _ _ _} mconverte D M -> type. +%mode can-mconverte +X1 -X2. + +can-maconverte : {D:aconverte _ _ _ _} maconverte D M -> type. +%mode can-maconverte +X1 -X2. + +can-mtpconverte : {D:tpconverte _ _ _ _} mtpconverte D M -> type. +%mode can-mtpconverte +X1 -X2. + +can-matpconverte : {D:atpconverte _ _ _ _} matpconverte D M -> type. +%mode can-matpconverte +X1 -X2. + +can-mkconverte : {D:kconverte _ _ _} mkconverte D M -> type. +%mode can-mkconverte +X2 -X3. + +-at : can-mconverte + (converte/at Daconverte) + (mconverte/at Dmaconverte) + <- can-maconverte Daconverte Dmaconverte. + +-lam : can-mconverte + (converte/lam + ([x] [ex] [xt] Dconv x ex xt) + Dtpconv) + (mconverte/lam + ([x] [ex] [xt] Dmconv x ex xt) + Dmtpconv) + <- can-mtpconverte Dtpconv Dmtpconv + <- ({x} {ex} {xt} + can-mconverte (Dconv x ex xt) (Dmconv x ex xt)). + +-const : can-maconverte + (aconverte/const Dtpconv Dkof _) + (maconverte/const Dmtpconv Dmkof) + <- can-mkof Dkof Dmkof + <- can-mtpconverte Dtpconv Dmtpconv. + +-var : can-maconverte + (aconverte/var _ Dtpconv _) + (maconverte/var Dmtpconv) + <- can-mtpconverte Dtpconv Dmtpconv. + +-vari : can-maconverte + (aconverte/vari _ Dtpconv Dkof _) + (maconverte/vari Dmtpconv Dmkof) + <- can-mkof Dkof Dmkof + <- can-mtpconverte Dtpconv Dmtpconv. + +-app : can-maconverte + (aconverte/app _ Dconv Daconv) + (maconverte/app Dmconv Dmaconv) + <- can-maconverte Daconv Dmaconv + <- can-mconverte Dconv Dmconv. + +-base : can-mtpconverte + (tpconverte/base D) + (mtpconverte/base D') + <- can-matpconverte D D'. + +-lam : can-mtpconverte + (tpconverte/lam Dconv Dtpconv) + (mtpconverte/lam Dmconv Dmtpconv) + <- can-mtpconverte Dtpconv Dmtpconv + <- ({x} {ex} {xt} + can-mtpconverte (Dconv x ex xt) (Dmconv x ex xt)). + +-pi : can-mtpconverte + (tpconverte/pi Dconv Dtpconv) + (mtpconverte/pi Dmconv Dmtpconv) + <- can-mtpconverte Dtpconv Dmtpconv + <- ({x} {ex} {xt} + can-mtpconverte (Dconv x ex xt) (Dmconv x ex xt)). + +-const : can-matpconverte + (atpconverte/const Dtpconv Dwf _) + (matpconverte/const Dmtpconv Dmwf) + <- can-mwfkind Dwf Dmwf + <- can-mkconverte Dtpconv Dmtpconv. + +-app : can-matpconverte + (atpconverte/app _ Dconv Daconv) + (matpconverte/app Dmconv Dmaconv) + <- can-matpconverte Daconv Dmaconv + <- can-mconverte Dconv Dmconv. + +-type : can-mkconverte kconverte/type mkconverte/type. + + +-pi : can-mkconverte + (kconverte/pi Dconv Dtpconv) + (mkconverte/pi Dmconv Dmtpconv) + <- can-mtpconverte Dtpconv Dmtpconv + <- ({x} {ex} {xt} + can-mkconverte (Dconv x ex xt) (Dmconv x ex xt)). + + +%worlds (csig-ei | asig-ei | bind | ovar | tvar | evvar | tvvar | tvobind | sbind') + (can-mconverte _ _) + (can-maconverte _ _) + (can-mtpconverte _ _) + (can-matpconverte _ _) + (can-mkconverte _ _). +%total (D1 D2 D3 D4 D5) + (can-mconverte D1 _) + (can-maconverte D2 _) + (can-mtpconverte D3 _) + (can-matpconverte D4 _) + (can-mkconverte D5 _). + + +%%%% Weakening %%%% + +weakeng-aconverte : {Rm} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:aconverte G R A EM} + maconverte D Rm +%% + -> aconverte G' R A EM -> type. +%mode weakeng-aconverte +X2 +X3 +X4 +X5 +X6 -X7. + +weakeng-converte : {Mm} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:converte G R A EM} + mconverte D Mm +%% + -> converte G' R A EM -> type. +%mode weakeng-converte +X2 +X3 +X4 +X5 +X6 -X7. + +weakeng-tpconverte : {Am} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:tpconverte G A K EA} + mtpconverte D Am +%% + -> tpconverte G' A K EA -> type. +%mode weakeng-tpconverte +X2 +X3 +X4 +X5 +X6 -X7. + +weakeng-atpconverte : {Pm} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:atpconverte G A K EA} + matpconverte D Pm +%% + -> atpconverte G' A K EA -> type. +%mode weakeng-atpconverte +X2 +X3 +X4 +X5 +X6 -X7. + +weakeng-kconverte : {Km} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:kconverte G K EK} + mkconverte D Km +%% + -> kconverte G' K EK -> type. +%mode weakeng-kconverte +X2 +X3 +X4 +X5 +X6 -X6. + +-const : weakeng-aconverte _ Dappend Dappend' + (aconverte/const Dconv Dwf Dcof) + (maconverte/const DM DM') + (aconverte/const Dconv' Dwf Dcof) + <- weakeng-tpconverte _ Dappend Dappend' Dconv DM Dconv'. + +-var : weakeng-aconverte _ Dappend Dappend' + (aconverte/var Dvtrans Dconv Dlook) + (maconverte/var DM) + (aconverte/var Dvtrans Dconv' Dlook') + <- weakeng-tpconverte _ Dappend Dappend' Dconv DM + Dconv' + <- weakeng-lookup Dappend Dappend' Dlook Dlook'. + +-vari : weakeng-aconverte _ Dappend Dappend' + (aconverte/vari Dvtrans Dconv Dkof Dvof) + (maconverte/vari Dmconv Dmkof) + (aconverte/vari Dvtrans Dconv' Dkof Dvof) + <- weakeng-tpconverte _ Dappend Dappend' Dconv Dmconv Dconv'. + +-app : weakeng-aconverte _ Dappend Dappend' + (aconverte/app Dsub Dconv2 Dconv1) + (maconverte/app DM2 DM1) + (aconverte/app Dsub Dconv2' Dconv1') + <- weakeng-aconverte _ Dappend Dappend' Dconv1 DM1 Dconv1' + <- weakeng-converte _ Dappend Dappend' Dconv2 DM2 Dconv2'. + +-at : weakeng-converte _ Dappend Dappend' + (converte/at D) (mconverte/at DM) + (converte/at D') + <- weakeng-aconverte _ Dappend Dappend' D DM D'. + +-lam : weakeng-converte _ Dappend Dappend' + (converte/lam + ([x] [ex] [xt] DconvM x ex xt) + DconvA) + (mconverte/lam + ([x] [ex] [xt] DMM x ex xt) + DMA) + (converte/lam DconvM' DconvA') + <- weakeng-tpconverte _ Dappend Dappend' DconvA DMA + DconvA' + <- ({x} {ex} {xt} + weakeng-converte X + (append/cons Dappend) (append/cons Dappend') + (DconvM x ex xt) (DMM x ex xt) + (DconvM' x ex xt)). + + +-base : weakeng-tpconverte _ Dappend Dappend' + (tpconverte/base D) + (mtpconverte/base DM) + (tpconverte/base D') + <- weakeng-atpconverte _ Dappend Dappend' D DM D'. + +-lam : weakeng-tpconverte _ Dappend Dappend' + (tpconverte/lam + ([x] [ex] [xt] DconvM x ex xt) + DconvA) + (mtpconverte/lam + ([x] [ex] [xt] DMM x ex xt) + DMA) + (tpconverte/lam DconvM' DconvA') + <- weakeng-tpconverte _ Dappend Dappend' DconvA DMA + DconvA' + <- ({x} {ex} {xt} + weakeng-tpconverte X + (append/cons Dappend) (append/cons Dappend') + (DconvM x ex xt) (DMM x ex xt) + (DconvM' x ex xt)). + +-pi : weakeng-tpconverte _ Dappend Dappend' + (tpconverte/pi + ([x] [ex] [xt] DconvM x ex xt) + DconvA) + (mtpconverte/pi + ([x] [ex] [xt] DMM x ex xt) + DMA) + (tpconverte/pi DconvM' DconvA') + <- weakeng-tpconverte _ Dappend Dappend' DconvA DMA + DconvA' + <- ({x} {ex} {xt} + weakeng-tpconverte X + (append/cons Dappend) (append/cons Dappend') + (DconvM x ex xt) (DMM x ex xt) + (DconvM' x ex xt)). + +-const : weakeng-atpconverte _ Dappend Dappend' + (atpconverte/const Dconv Dwf Dcof) + (matpconverte/const DM DM') + (atpconverte/const Dconv' Dwf Dcof) + <- weakeng-kconverte _ Dappend Dappend' Dconv DM Dconv'. + +-app : weakeng-atpconverte _ Dappend Dappend' + (atpconverte/app Dsub Dconv2 Dconv1) + (matpconverte/app DM2 DM1) + (atpconverte/app Dsub Dconv2' Dconv1') + <- weakeng-atpconverte _ Dappend Dappend' Dconv1 DM1 Dconv1' + <- weakeng-converte _ Dappend Dappend' Dconv2 DM2 Dconv2'. + +-type : weakeng-kconverte _ Dappend Dappend' + kconverte/type mkconverte/type kconverte/type. + +-pi : weakeng-kconverte _ Dappend Dappend' + (kconverte/pi + ([x] [ex] [xt] DconvM x ex xt) + DconvA) + (mkconverte/pi + ([x] [ex] [xt] DMM x ex xt) + DMA) + (kconverte/pi DconvM' DconvA') + <- weakeng-tpconverte _ Dappend Dappend' DconvA DMA + DconvA' + <- ({x} {ex} {xt} + weakeng-kconverte X + (append/cons Dappend) (append/cons Dappend') + (DconvM x ex xt) (DMM x ex xt) + (DconvM' x ex xt)). + +%worlds (csig-ei | asig-ei | bind | ovar | evvar | tvar | tvvar | tvobind | sbind') + (weakeng-converte _ _ _ _ _ _) + (weakeng-aconverte _ _ _ _ _ _) + (weakeng-tpconverte _ _ _ _ _ _) + (weakeng-atpconverte _ _ _ _ _ _) + (weakeng-kconverte _ _ _ _ _ _). +%total (Mm Rm Am Pm Km) + (weakeng-aconverte Rm _ _ _ _ _) + (weakeng-converte Mm _ _ _ _ _) + (weakeng-tpconverte Am _ _ _ _ _) + (weakeng-atpconverte Pm _ _ _ _ _) + (weakeng-kconverte Km _ _ _ _ _). + + +weaken-converte : converte G M A EM -> {B} {X} + converte (cons G X B) M A EM -> type. +%mode weaken-converte +X2 +B +X -X3. + +- : weaken-converte Dconv _ _ Dconv' + <- can-mconverte Dconv DM + <- weakeng-converte _ append/nil append/nil Dconv DM Dconv'. + +%worlds (csig-ei | asig-ei | bind | ovar | evvar | tvvar | tvobind | sbind') + (weaken-converte _ _ _ _). +%total {} (weaken-converte _ _ _ _). + +weaken-converte' : append G1 G2 G -> converte G1 M A EM + -> converte G M A EM -> type. +%mode weaken-converte' +X1 +X2 -X3. + +-nil : weaken-converte' append/nil D D. + +-cons : weaken-converte' (append/cons Dapp) D + D'' + <- weaken-converte' Dapp D D' + <- weaken-converte D' _ _ D''. + +%worlds (csig-ei | asig-ei | bind | ovar | evvar | tvvar | tvobind | sbind') + (weaken-converte' _ _ _). +%total D (weaken-converte' D _ _). + +%%%% Cut %%%% + +cut-convert-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + convert (M x) (B x) (EM ex)} + ({x} {d} {ex} {xt} + mconvert (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + converte (G x) (M x) (B x) (EM ex)} + ({x} {ex} {xt} mconverte (D' x ex xt) Mm) -> type. +%mode cut-convert-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-aconvert-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + aconvert (M x) (B x) (EM ex)} + ({x} {d} {ex} {xt} + maconvert (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + aconverte (G x) (M x) (B x) (EM ex)} + ({x} {ex} {xt} maconverte (D' x ex xt) Mm) -> type. +%mode cut-aconvert-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-tpconvert-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + tpconvert (M x) (B x) (EM ex)} + ({x} {d} {ex} {xt} + mtpconvert (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + tpconverte (G x) (M x) (B x) (EM ex)} + ({x} {ex} {xt} mtpconverte (D' x ex xt) Mm) -> type. +%mode cut-tpconvert-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-atpconvert-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + atpconvert (M x) (B x) (EM ex)} + ({x} {d} {ex} {xt} + matpconvert (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + atpconverte (G x) (M x) (B x) (EM ex)} + ({x} {ex} {xt} matpconverte (D' x ex xt) Mm) -> type. +%mode cut-atpconvert-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-kconvert-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + kconvert (K x) (EK ex)} + ({x} {d} {ex} {xt} + mkconvert (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + kconverte (G x) (K x) (EK ex)} + ({x} {ex} {xt} mkconverte (D' x ex xt) Mm) -> type. +%mode cut-kconvert-m +X1 +X2 +X3 +X4 -X5 -X6. + +%%%% + +cut-converte-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + converte (G x) (M x) (B x) (EM ex)} + ({x} {d} {ex} {xt} mconverte (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + converte (G x) (M x) (B x) (EM ex)} + ({x} {ex} {xt} mconverte (D' x ex xt) Mm) -> type. +%mode cut-converte-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-aconverte-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + aconverte (G x) (R x) (B x) (EM ex)} + ({x} {d} {ex} {xt} maconverte (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + aconverte (G x) (R x) (B x) (EM ex)} + ({x} {ex} {xt} maconverte (D' x ex xt) Mm) -> type. +%mode cut-aconverte-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-tpconverte-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + tpconverte (G x) (M x) (B x) (EM ex)} + ({x} {d} {ex} {xt} mtpconverte (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + tpconverte (G x) (M x) (B x) (EM ex)} + ({x} {ex} {xt} mtpconverte (D' x ex xt) Mm) -> type. +%mode cut-tpconverte-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-atpconverte-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + atpconverte (G x) (M x) (B x) (EM ex)} + ({x} {d} {ex} {xt} matpconverte (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + atpconverte (G x) (M x) (B x) (EM ex)} + ({x} {ex} {xt} matpconverte (D' x ex xt) Mm) -> type. +%mode cut-atpconverte-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-kconverte-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + kconverte (G x) (M x) (EM ex)} + ({x} {d} {ex} {xt} mkconverte (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + kconverte (G x) (M x) (EM ex)} + ({x} {ex} {xt} mkconverte (D' x ex xt) Mm) -> type. +%mode cut-kconverte-m +X1 +X2 +X3 +X4 -X5 -X6. + +-at : cut-convert-m _ + ([x] [d] [ex] [xt] + convert/at (Daconv x d ex xt)) + ([x] [d] [ex] [xt] + mconvert/at (Dmaconv x d ex xt)) + Dlook + ([x] [ex] [xt] converte/at (Daconve x ex xt)) + ([x] [ex] [xt] mconverte/at (Dmaconve x ex xt)) + <- cut-aconvert-m _ Daconv Dmaconv Dlook + Daconve + Dmaconve. + +-lam : cut-convert-m _ + ([x] [d] [ex] [xt] + convert/lam + ([y] [e] [ey] [yt] + (DconvM x d ex xt y e ey yt)) + (DconvA x d ex xt)) + ([x] [d] [ex] [xt] + mconvert/lam + ([y] [e] [ey] [yt] + DmconvM x d ex xt y e ey yt) + (DmconvA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + converte/lam (DconveM' x ex xt) (DconveA x ex xt)) + ([x] [ex] [xt] + mconverte/lam (DmconveM' x ex xt) (DmconveA x ex xt)) +%% + <- ({x} {d} {ex} {xt} + cut-convert-m _ + (DconvM x d ex xt) + (DmconvM x d ex xt) + ([y] lookup/hit) + ([y] [ey] [yt] + DconveM x d ex xt y ey yt + : converte (cons (G x) y (A x)) + (M x y) (B x y) (EM ex ey)) + ([y] [ey] [yt] DmconveM x d ex xt y ey yt)) + <- ({y} {ey} {yt} + cut-converte-m _ + ([x] [d] [ex] [xt] DconveM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmconveM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] + DconveM' x ex xt y ey yt) + ([x] [ex] [xt] + DmconveM' x ex xt y ey yt)) + <- cut-tpconvert-m _ DconvA DmconvA Dlook + DconveA DmconveA. + +-const : cut-aconvert-m _ + ([x] [d] [ex] [xt] + aconvert/const + (Dtconv x d ex xt : tpconvert B ktype (EB ex)) + (Dkof x d : kof B ktype) + (Dcof : cof C B)) + ([x] [d] [ex] [xt] + maconvert/const (Dmtconv x d ex xt) (Dmkof x d)) + Dlook + ([x] [ex] [xt] + aconverte/const + (Dtconve x ex xt) + Dkof'' + Dcof) + ([x] [ex] [xt] maconverte/const (Dmtconve x ex xt) Dmkof'') + <- strengthen-for-cut-kof _ Dkof Dmkof + Dkof'' + Dmkof'' + %% + <- cut-tpconvert-m _ Dtconv Dmtconv Dlook + Dtconve + Dmtconve. + +-varoth : cut-aconvert-m _ + ([x] [d] [ex] [xt] + aconvert/var + (Dvtrans : vtrans EY Y) + (Dtconv x d ex xt : tpconvert B ktype (EB ex)) + (Dkof x d : kof B ktype) + (Dvof : vof Y B)) + ([x] [d] [ex] [xt] + maconvert/var (Dmtconv x d ex xt) (Dmkof x d)) + Dlook + ([x] [ex] [xt] + aconverte/vari + Dvtrans + (Dtconve x ex xt) + Dkof' + Dvof) + ([x] [ex] [xt] maconverte/vari (Dmtconve x ex xt) Dmkof') + <- cut-tpconvert-m _ Dtconv Dmtconv Dlook + ([x] [ex] [xt] Dtconve x ex xt + : tpconverte (G x) B ktype (EB ex)) + ([x] [ex] [xt] Dmtconve x ex xt) + <- strengthen-for-cut-kof _ Dkof Dmkof + (Dkof' : kof B ktype) + Dmkof'. + +-varsam : cut-aconvert-m _ + ([x] [d:vof x A] [ex] [xt] + aconvert/var + xt + (Dtconv x d ex xt : tpconvert A ktype (EA ex)) + (Dkof x d : kof A ktype) + d) + ([x] [d] [ex] [xt] + maconvert/var (Dmtconv x d ex xt) (Dmkof x d)) + Dlook + ([x] [ex] [xt] + aconverte/var xt (Dtconve x ex xt) (Dlook x)) + ([x] [ex] [xt] + maconverte/var (Dmtconve x ex xt)) + <- cut-tpconvert-m _ Dtconv Dmtconv Dlook + ([x] [ex] [xt] Dtconve x ex xt + : tpconverte (G x) A ktype (EA ex)) + ([x] [ex] [xt] Dmtconve x ex xt) + <- strengthen-for-cut-kof _ Dkof Dmkof + (Dkof' : kof A ktype) + Dmkof'. + +-app : cut-aconvert-m _ + ([x] [d] [ex] [xt] + aconvert/app + (Dsub x) + (DconvN x d ex xt) + (DconvR x d ex xt)) + ([x] [d] [ex] [xt] + maconvert/app (DmconvN x d ex xt) (DmconvR x d ex xt)) + ([x] Dlook x) + ([x] [ex] [xt] + aconverte/app + (Dsub x) (DconveN x ex xt) (DconveR x ex xt)) + ([x] [ex] [xt] + maconverte/app + (DmconveN x ex xt) (DmconveR x ex xt)) + <- cut-aconvert-m _ DconvR DmconvR Dlook + ([x] [ex] [xt] DconveR x ex xt) + ([x] [ex] [xt] DmconveR x ex xt) + <- cut-convert-m _ DconvN DmconvN Dlook + ([x] [ex] [xt] DconveN x ex xt) + ([x] [ex] [xt] DmconveN x ex xt). + +%% + +-base : cut-tpconvert-m _ + ([x] [d] [ex] [xt] + tpconvert/base (Daconv x d ex xt)) + ([x] [d] [ex] [xt] + mtpconvert/base (Dmaconv x d ex xt)) + Dlook + ([x] [ex] [xt] tpconverte/base (Daconve x ex xt)) + ([x] [ex] [xt] mtpconverte/base (Dmaconve x ex xt)) + <- cut-atpconvert-m _ Daconv Dmaconv Dlook + Daconve + Dmaconve. + +-pi : cut-tpconvert-m _ + ([x] [d] [ex] [xt] + tpconvert/pi + ([y] [e] [ey] [yt] (DconvM x d ex xt y e ey yt)) + (DconvA x d ex xt)) + ([x] [d] [ex] [xt] + mtpconvert/pi + ([y] [e] [ey] [yt] DmconvM x d ex xt y e ey yt) + (DmconvA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + tpconverte/pi (DconveM' x ex xt) (DconveA x ex xt)) + ([x] [ex] [xt] + mtpconverte/pi (DmconveM' x ex xt) (DmconveA x ex xt)) +%% + <- ({x} {d} {ex} {xt} + cut-tpconvert-m _ + (DconvM x d ex xt) + (DmconvM x d ex xt) + ([y] lookup/hit) + ([y] [ey] [yt] DconveM x d ex xt y ey yt) + ([y] [ey] [yt] DmconveM x d ex xt y ey yt)) + <- ({y} {ey} {yt} + cut-tpconverte-m _ + ([x] [d] [ex] [xt] DconveM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmconveM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DconveM' x ex xt y ey yt) + ([x] [ex] [xt] DmconveM' x ex xt y ey yt)) + <- cut-tpconvert-m _ DconvA DmconvA Dlook + DconveA DmconveA. + +-lam : cut-tpconvert-m _ + ([x] [d] [ex] [xt] + tpconvert/lam + ([y] [e] [ey] [yt] (DconvM x d ex xt y e ey yt)) + (DconvA x d ex xt)) + ([x] [d] [ex] [xt] + mtpconvert/lam + ([y] [e] [ey] [yt] DmconvM x d ex xt y e ey yt) + (DmconvA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + tpconverte/lam (DconveM' x ex xt) (DconveA x ex xt)) + ([x] [ex] [xt] + mtpconverte/lam (DmconveM' x ex xt) (DmconveA x ex xt)) +%% + <- ({x} {d} {ex} {xt} + cut-tpconvert-m _ + (DconvM x d ex xt) + (DmconvM x d ex xt) + ([y] lookup/hit) + ([y] [ey] [yt] DconveM x d ex xt y ey yt) + ([y] [ey] [yt] DmconveM x d ex xt y ey yt)) + <- ({y} {ey} {yt} + cut-tpconverte-m _ + ([x] [d] [ex] [xt] DconveM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmconveM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DconveM' x ex xt y ey yt) + ([x] [ex] [xt] DmconveM' x ex xt y ey yt)) + <- cut-tpconvert-m _ DconvA DmconvA Dlook + DconveA DmconveA. + +-const : cut-atpconvert-m _ + ([x] [d] [ex] [xt] + atpconvert/const + (Dtconv x d ex xt : kconvert B (EB ex)) + (Dkof x d : wfkind B) + (Dcof : ckof C B)) + ([x] [d] [ex] [xt] + matpconvert/const (Dmtconv x d ex xt) (Dmkof x d)) + Dlook + ([x] [ex] [xt] + atpconverte/const + (Dtconve x ex xt) + Dkof'' + Dcof) + ([x] [ex] [xt] matpconverte/const (Dmtconve x ex xt) Dmkof'') + <- strengthen-for-cut-wfkind _ Dkof Dmkof + Dkof'' + Dmkof'' + %% + <- cut-kconvert-m _ Dtconv Dmtconv Dlook + Dtconve + Dmtconve. + +-app : cut-atpconvert-m _ + ([x] [d] [ex] [xt] + atpconvert/app + (Dsub x) + (DconvN x d ex xt) + (DconvR x d ex xt)) + ([x] [d] [ex] [xt] + matpconvert/app (DmconvN x d ex xt) (DmconvR x d ex xt)) + ([x] Dlook x) + ([x] [ex] [xt] + atpconverte/app + (Dsub x) (DconveN x ex xt) (DconveR x ex xt)) + ([x] [ex] [xt] + matpconverte/app + (DmconveN x ex xt) (DmconveR x ex xt)) + <- cut-atpconvert-m _ DconvR DmconvR Dlook + ([x] [ex] [xt] DconveR x ex xt) + ([x] [ex] [xt] DmconveR x ex xt) + <- cut-convert-m _ DconvN DmconvN Dlook + ([x] [ex] [xt] DconveN x ex xt) + ([x] [ex] [xt] DmconveN x ex xt). + +%% + +-type : cut-kconvert-m _ + ([x] [d] [ex] [xt] kconvert/type) + ([x] [d] [ex] [xt] mkconvert/type) + _ + ([x] [ex] [xt] kconverte/type) + ([x] [ex] [xt] mkconverte/type). + +-pi : cut-kconvert-m _ + ([x] [d] [ex] [xt] + kconvert/pi + ([y] [e] [ey] [yt] (DconvM x d ex xt y e ey yt)) + (DconvA x d ex xt)) + ([x] [d] [ex] [xt] + mkconvert/pi + ([y] [e] [ey] [yt] DmconvM x d ex xt y e ey yt) + (DmconvA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + kconverte/pi (DconveM' x ex xt) (DconveA x ex xt)) + ([x] [ex] [xt] + mkconverte/pi (DmconveM' x ex xt) (DmconveA x ex xt)) +%% + <- ({x} {d} {ex} {xt} + cut-kconvert-m _ + (DconvM x d ex xt) + (DmconvM x d ex xt) + ([y] lookup/hit) + ([y] [ey] [yt] DconveM x d ex xt y ey yt) + ([y] [ey] [yt] DmconveM x d ex xt y ey yt)) + <- ({y} {ey} {yt} + cut-kconverte-m _ + ([x] [d] [ex] [xt] DconveM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmconveM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DconveM' x ex xt y ey yt) + ([x] [ex] [xt] DmconveM' x ex xt y ey yt)) + <- cut-tpconvert-m _ DconvA DmconvA Dlook + DconveA DmconveA. + +%%%% + +-at : cut-converte-m _ + ([x] [d] [ex] [xt] + converte/at (Daconv x d ex xt)) + ([x] [d] [ex] [xt] + mconverte/at (Dmaconv x d ex xt)) + Dlook + ([x] [ex] [xt] converte/at (Daconve x ex xt)) + ([x] [ex] [xt] mconverte/at (Dmaconve x ex xt)) + <- cut-aconverte-m _ Daconv Dmaconv Dlook + Daconve Dmaconve. + +-lam : cut-converte-m _ + ([x] [d] [ex] [xt] + converte/lam + ([y] [ey] [yt] DconvM x d ex xt y ey yt) + (DconvA x d ex xt)) + ([x] [d] [ex] [xt] + mconverte/lam + ([y] [ey] [yt] DmconvM x d ex xt y ey yt) + (DmconvA x d ex xt)) + Dlook + ([x] [ex] [xt] + converte/lam (DconvM' x ex xt) (DconvA' x ex xt)) + ([x] [ex] [xt] + mconverte/lam (DmconvM' x ex xt) (DmconvA' x ex xt)) + <- ({y} {ey} {yt} + cut-converte-m _ + ([x] [d] [ex] [xt] DconvM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmconvM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DconvM' x ex xt y ey yt) + ([x] [ex] [xt] DmconvM' x ex xt y ey yt)) + <- cut-tpconverte-m _ DconvA DmconvA Dlook DconvA' DmconvA'. + +-const : cut-aconverte-m _ + ([x] [d] [ex] [xt] + aconverte/const + (Dtconv x d ex xt) + (Dkof x d) + Dcof) + ([x] [d] [ex] [xt] + maconverte/const (Dmtconv x d ex xt) (Dmkof x d)) + Dlook + ([x] [ex] [xt] + aconverte/const + (Dtconv' x ex xt) + Dkof'' + Dcof) + ([x] [ex] [xt] maconverte/const (Dmtconv' x ex xt) Dmkof'') + <- strengthen-for-cut-kof _ Dkof Dmkof + Dkof'' Dmkof'' + %% + <- cut-tpconverte-m _ Dtconv Dmtconv Dlook + Dtconv' Dmtconv'. + +-var : cut-aconverte-m _ + ([x] [d] [ex] [xt] + aconverte/var + (Dvtrans x ex xt : vtrans (EY ex) (Y x)) + (Dtconv x d ex xt : tpconverte (G x) (B x) ktype (EB ex)) + (DlookY x : lookup (G x) (Y x) (B x))) + ([x] [d] [ex] [xt] maconverte/var (Dmtconv x d ex xt)) + ([x] Dlook x : lookup (G x) x A) + ([x] [ex] [xt] + aconverte/var + (Dvtrans x ex xt) + (Dtconv' x ex xt) + (DlookY x)) + ([x] [ex] [xt] maconverte/var (Dmtconv' x ex xt)) + <- cut-tpconverte-m _ Dtconv Dmtconv Dlook + ([x] [ex] [xt] Dtconv' x ex xt) + ([x] [ex] [xt] Dmtconv' x ex xt). + +-varisam: cut-aconverte-m _ + ([x] [d] [ex] [xt] + aconverte/vari + xt + (Dtconv x d ex xt : tpconverte (G x) A ktype (EA ex)) + (Dkof x d : kof A ktype) + d) + ([x] [d] [ex] [xt] + maconverte/vari + (Dmtconv x d ex xt) + (Dmkof x d : mkof (Dkof x d) Mm)) + Dlook + ([x] [ex] [xt] + aconverte/var + xt + (Dtconv' x ex xt) + (Dlook x)) + ([x] [ex] [xt] maconverte/var (Dmtconv' x ex xt)) + <- cut-tpconverte-m _ Dtconv Dmtconv Dlook Dtconv' Dmtconv'. + +-varioth: cut-aconverte-m _ + ([x] [d] [ex] [xt] + aconverte/vari + (Dvtrans : vtrans EY Y) + (Dtconv x d ex xt : tpconverte (G x) B ktype (EB ex)) + (Dkof x d : kof B ktype) + (Dvof : vof Y B)) + ([x] [d] [ex] [xt] + maconverte/vari + (Dmtconv x d ex xt) + (Dmkof x d : mkof (Dkof x d) Mm)) + Dlook + ([x] [ex] [xt] + aconverte/vari + Dvtrans + (Dtconv' x ex xt) + Dkof' + Dvof) + ([x] [ex] [xt] maconverte/vari (Dmtconv' x ex xt) Dmkof') + <- cut-tpconverte-m _ Dtconv Dmtconv Dlook Dtconv' Dmtconv' + <- strengthen-for-cut-kof _ Dkof Dmkof Dkof' Dmkof'. + +-app : cut-aconverte-m _ + ([x] [d] [ex] [xt] + aconverte/app + (Dsub x) + (DconvN x d ex xt) + (DconvR x d ex xt)) + ([x] [d] [ex] [xt] + maconverte/app (DmconvN x d ex xt) (DmconvR x d ex xt)) + ([x] Dlook x) + ([x] [ex] [xt] + aconverte/app + (Dsub x) (DconveN x ex xt) (DconveR x ex xt)) + ([x] [ex] [xt] + maconverte/app + (DmconveN x ex xt) (DmconveR x ex xt)) + <- cut-aconverte-m _ DconvR DmconvR Dlook + ([x] [ex] [xt] DconveR x ex xt) + ([x] [ex] [xt] DmconveR x ex xt) + <- cut-converte-m _ DconvN DmconvN Dlook + ([x] [ex] [xt] DconveN x ex xt) + ([x] [ex] [xt] DmconveN x ex xt). + +-base : cut-tpconverte-m _ + ([x] [d] [ex] [xt] + tpconverte/base (Daconv x d ex xt)) + ([x] [d] [ex] [xt] + mtpconverte/base (Dmaconv x d ex xt)) + Dlook + ([x] [ex] [xt] tpconverte/base (Daconve x ex xt)) + ([x] [ex] [xt] mtpconverte/base (Dmaconve x ex xt)) + <- cut-atpconverte-m _ Daconv Dmaconv Dlook + Daconve Dmaconve. + +-pi : cut-tpconverte-m _ + ([x] [d] [ex] [xt] + tpconverte/pi + ([y] [ey] [yt] DconvM x d ex xt y ey yt) + (DconvA x d ex xt)) + ([x] [d] [ex] [xt] + mtpconverte/pi + ([y] [ey] [yt] DmconvM x d ex xt y ey yt) + (DmconvA x d ex xt)) + Dlook + ([x] [ex] [xt] + tpconverte/pi (DconvM' x ex xt) (DconvA' x ex xt)) + ([x] [ex] [xt] + mtpconverte/pi (DmconvM' x ex xt) (DmconvA' x ex xt)) + <- ({y} {ey} {yt} + cut-tpconverte-m _ + ([x] [d] [ex] [xt] DconvM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmconvM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DconvM' x ex xt y ey yt) + ([x] [ex] [xt] DmconvM' x ex xt y ey yt)) + <- cut-tpconverte-m _ DconvA DmconvA Dlook DconvA' DmconvA'. + +-lam : cut-tpconverte-m _ + ([x] [d] [ex] [xt] + tpconverte/lam + ([y] [ey] [yt] DconvM x d ex xt y ey yt) + (DconvA x d ex xt)) + ([x] [d] [ex] [xt] + mtpconverte/lam + ([y] [ey] [yt] DmconvM x d ex xt y ey yt) + (DmconvA x d ex xt)) + Dlook + ([x] [ex] [xt] + tpconverte/lam (DconvM' x ex xt) (DconvA' x ex xt)) + ([x] [ex] [xt] + mtpconverte/lam (DmconvM' x ex xt) (DmconvA' x ex xt)) + <- ({y} {ey} {yt} + cut-tpconverte-m _ + ([x] [d] [ex] [xt] DconvM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmconvM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DconvM' x ex xt y ey yt) + ([x] [ex] [xt] DmconvM' x ex xt y ey yt)) + <- cut-tpconverte-m _ DconvA DmconvA Dlook DconvA' DmconvA'. + +-const : cut-atpconverte-m _ + ([x] [d] [ex] [xt] + atpconverte/const + (Dtconv x d ex xt) + (Dkof x d) + Dcof) + ([x] [d] [ex] [xt] + matpconverte/const (Dmtconv x d ex xt) (Dmkof x d)) + Dlook + ([x] [ex] [xt] + atpconverte/const + (Dtconv' x ex xt) + Dkof'' + Dcof) + ([x] [ex] [xt] + matpconverte/const (Dmtconv' x ex xt) Dmkof'') + <- strengthen-for-cut-wfkind _ Dkof Dmkof + Dkof'' Dmkof'' + %% + <- cut-kconverte-m _ Dtconv Dmtconv Dlook + Dtconv' Dmtconv'. + +-app : cut-atpconverte-m _ + ([x] [d] [ex] [xt] + atpconverte/app + (Dsub x) + (DconvN x d ex xt) + (DconvR x d ex xt)) + ([x] [d] [ex] [xt] + matpconverte/app (DmconvN x d ex xt) (DmconvR x d ex xt)) + ([x] Dlook x) + ([x] [ex] [xt] + atpconverte/app + (Dsub x) (DconveN x ex xt) (DconveR x ex xt)) + ([x] [ex] [xt] + matpconverte/app + (DmconveN x ex xt) (DmconveR x ex xt)) + <- cut-atpconverte-m _ DconvR DmconvR Dlook + ([x] [ex] [xt] DconveR x ex xt) + ([x] [ex] [xt] DmconveR x ex xt) + <- cut-converte-m _ DconvN DmconvN Dlook + ([x] [ex] [xt] DconveN x ex xt) + ([x] [ex] [xt] DmconveN x ex xt). + +-type : cut-kconverte-m _ + ([x] [d] [ex] [xt] kconverte/type) + ([x] [d] [ex] [xt] mkconverte/type) + _ + ([x] [ex] [xt] kconverte/type) + ([x] [ex] [xt] mkconverte/type). + +-pi : cut-kconverte-m _ + ([x] [d] [ex] [xt] + kconverte/pi + ([y] [ey] [yt] DconvM x d ex xt y ey yt) + (DconvA x d ex xt)) + ([x] [d] [ex] [xt] + mkconverte/pi + ([y] [ey] [yt] DmconvM x d ex xt y ey yt) + (DmconvA x d ex xt)) + Dlook + ([x] [ex] [xt] + kconverte/pi (DconvM' x ex xt) (DconvA' x ex xt)) + ([x] [ex] [xt] + mkconverte/pi (DmconvM' x ex xt) (DmconvA' x ex xt)) + <- ({y} {ey} {yt} + cut-kconverte-m _ + ([x] [d] [ex] [xt] DconvM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmconvM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DconvM' x ex xt y ey yt) + ([x] [ex] [xt] DmconvM' x ex xt y ey yt)) + <- cut-tpconverte-m _ DconvA DmconvA Dlook DconvA' DmconvA'. + +%worlds (csig-ei | asig-ei | bind | ovar | tvar | tbind | sbind') + (cut-convert-m _ _ _ _ _ _) + (cut-aconvert-m _ _ _ _ _ _) + (cut-tpconvert-m _ _ _ _ _ _) + (cut-atpconvert-m _ _ _ _ _ _) + (cut-kconvert-m _ _ _ _ _ _) + (cut-converte-m _ _ _ _ _ _) + (cut-aconverte-m _ _ _ _ _ _) + (cut-tpconverte-m _ _ _ _ _ _) + (cut-atpconverte-m _ _ _ _ _ _) + (cut-kconverte-m _ _ _ _ _ _). +%total (M1 M2 M3 M4 M5 M6 M7 M8 M9 M10) + (cut-convert-m M1 _ _ _ _ _) + (cut-aconvert-m M2 _ _ _ _ _) + (cut-tpconvert-m M3 _ _ _ _ _) + (cut-atpconvert-m M4 _ _ _ _ _) + (cut-kconvert-m M5 _ _ _ _ _) + (cut-converte-m M6 _ _ _ _ _) + (cut-aconverte-m M7 _ _ _ _ _) + (cut-tpconverte-m M8 _ _ _ _ _) + (cut-atpconverte-m M9 _ _ _ _ _) + (cut-kconverte-m M10 _ _ _ _ _). + + +%%%% Translation from implicit to explicit %%%% + +convert1-to-converte : ({x} {d:vof x A} {ex} {xt:vtrans ex x} + convert (M x) (B x) (EM ex)) + -> ({x} {ex} {xt:vtrans ex x} + converte (cons nil x A) (M x) (B x) (EM ex)) + -> type. +%mode convert1-to-converte +X1 -X2. + +- : convert1-to-converte + ([x] [d] [ex] [xt] Dconv x d ex xt) + ([x] [ex] [xt] Dconve x ex xt) + <- ({x} {d} {ex} {xt} can-mconvert (Dconv x d ex xt) (Dmconv x d ex xt)) + <- cut-convert-m _ Dconv Dmconv ([_] lookup/hit) Dconve _. + +%worlds (csig-ei | asig-ei | bind | ovar | tvar | tbind | sbind') (convert1-to-converte _ _). +%total {} (convert1-to-converte _ _). + +tpconvert1-to-tpconverte : ({x} {d:vof x A} {ex} {xt:vtrans ex x} + tpconvert (M x) (B x) (EM ex)) + -> ({x} {ex} {xt:vtrans ex x} + tpconverte (cons nil x A) (M x) (B x) (EM ex)) + -> type. +%mode tpconvert1-to-tpconverte +X1 -X2. + +- : tpconvert1-to-tpconverte + ([x] [d] [ex] [xt] Dconv x d ex xt) + ([x] [ex] [xt] Dconve x ex xt) + <- ({x} {d} {ex} {xt} can-mtpconvert (Dconv x d ex xt) (Dmconv x d ex xt)) + <- cut-tpconvert-m _ Dconv Dmconv ([_] lookup/hit) Dconve _. + +%worlds (csig-ei | asig-ei | bind | ovar | tvar | tbind | sbind') (tpconvert1-to-tpconverte _ _). +%total {} (tpconvert1-to-tpconverte _ _). + +kconvert1-to-kconverte : ({x} {d:vof x A} {ex} {xt:vtrans ex x} + kconvert (M x) (EM ex)) + -> ({x} {ex} {xt:vtrans ex x} + kconverte (cons nil x A) (M x) (EM ex)) + -> type. +%mode kconvert1-to-kconverte +X1 -X2. + +- : kconvert1-to-kconverte + ([x] [d] [ex] [xt] Dconv x d ex xt) + ([x] [ex] [xt] Dconve x ex xt) + <- ({x} {d} {ex} {xt} can-mkconvert (Dconv x d ex xt) (Dmconv x d ex xt)) + <- cut-kconvert-m _ Dconv Dmconv ([_] lookup/hit) Dconve _. + +%worlds (csig-ei | asig-ei | bind | ovar | tvar | tbind | sbind') (kconvert1-to-kconverte _ _). +%total {} (kconvert1-to-kconverte _ _). + + +convert-to-converte-nil : convert M A EM -> converte nil M A EM -> type. +%mode convert-to-converte-nil +X1 -X2. + +aconvert-to-aconverte-nil : aconvert M A EM -> aconverte nil M A EM -> type. +%mode aconvert-to-aconverte-nil +X1 -X2. + +tpconvert-to-tpconverte-nil : tpconvert M A EM -> tpconverte nil M A EM -> type. +%mode tpconvert-to-tpconverte-nil +X1 -X2. + +atpconvert-to-atpconverte-nil : atpconvert M A EM + -> atpconverte nil M A EM -> type. +%mode atpconvert-to-atpconverte-nil +X1 -X2. + +kconvert-to-kconverte-nil : kconvert M EM -> kconverte nil M EM -> type. +%mode kconvert-to-kconverte-nil +X1 -X2. + + +-at : convert-to-converte-nil + (convert/at Daconv) + (converte/at Daconve) + <- aconvert-to-aconverte-nil Daconv Daconve. + +-lam : convert-to-converte-nil + (convert/lam Dconv Dtconv) + (converte/lam Dconve Dtconve) + <- convert1-to-converte Dconv Dconve + <- tpconvert-to-tpconverte-nil Dtconv Dtconve. + +-const : aconvert-to-aconverte-nil + (aconvert/const Dtconv Dkof Dcof) + (aconverte/const Dtconve Dkof Dcof) + <- tpconvert-to-tpconverte-nil Dtconv Dtconve. + +-var : aconvert-to-aconverte-nil + (aconvert/var Dvtrans Dtconv Dkof Dvof) + (aconverte/vari Dvtrans Dtconve Dkof Dvof) + <- tpconvert-to-tpconverte-nil Dtconv Dtconve. + +-app : aconvert-to-aconverte-nil + (aconvert/app Dsub Dconv Daconv) + (aconverte/app Dsub Dconve Daconve) + <- aconvert-to-aconverte-nil Daconv Daconve + <- convert-to-converte-nil Dconv Dconve. + +-base : tpconvert-to-tpconverte-nil + (tpconvert/base Daconv) + (tpconverte/base Daconve) + <- atpconvert-to-atpconverte-nil Daconv Daconve. + +-lam : tpconvert-to-tpconverte-nil + (tpconvert/lam Dconv Dtconv) + (tpconverte/lam Dconve Dtconve) + <- tpconvert1-to-tpconverte Dconv Dconve + <- tpconvert-to-tpconverte-nil Dtconv Dtconve. + +-pi : tpconvert-to-tpconverte-nil + (tpconvert/pi Dconv Dtconv) + (tpconverte/pi Dconve Dtconve) + <- tpconvert1-to-tpconverte Dconv Dconve + <- tpconvert-to-tpconverte-nil Dtconv Dtconve. + +-const : atpconvert-to-atpconverte-nil + (atpconvert/const Dtconv Dkof Dcof) + (atpconverte/const Dtconve Dkof Dcof) + <- kconvert-to-kconverte-nil Dtconv Dtconve. + +-app : atpconvert-to-atpconverte-nil + (atpconvert/app Dsub Dconv Daconv) + (atpconverte/app Dsub Dconve Daconve) + <- atpconvert-to-atpconverte-nil Daconv Daconve + <- convert-to-converte-nil Dconv Dconve. + +-type : kconvert-to-kconverte-nil kconvert/type kconverte/type. + +-pi : kconvert-to-kconverte-nil + (kconvert/pi Dconv Dtconv) + (kconverte/pi Dconve Dtconve) + <- kconvert1-to-kconverte Dconv Dconve + <- tpconvert-to-tpconverte-nil Dtconv Dtconve. + +%worlds (csig-ei | asig-ei | bind | ovar | tvar | tbind | sbind') + (convert-to-converte-nil _ _) + (aconvert-to-aconverte-nil _ _) + (tpconvert-to-tpconverte-nil _ _) + (atpconvert-to-atpconverte-nil _ _) + (kconvert-to-kconverte-nil _ _). +%total (D1 D2 D3 D4 D5) + (convert-to-converte-nil D1 _) + (aconvert-to-aconverte-nil D2 _) + (tpconvert-to-tpconverte-nil D3 _) + (atpconvert-to-atpconverte-nil D4 _) + (kconvert-to-kconverte-nil D5 _). + +convert-to-converte : {G} convert M A EM -> converte G M A EM -> type. +%mode convert-to-converte +X1 +X2 -X3. + +- : convert-to-converte G Dconv Dconve + <- convert-to-converte-nil Dconv Dconvenil + <- append-nil _ Dappend + <- weaken-converte' Dappend Dconvenil Dconve. + +%worlds (csig-ei | asig-ei | bind | ovar | sbind') (convert-to-converte _ _ _). +%total {} (convert-to-converte _ _ _). + diff --git a/src/convert-fun.thm b/src/convert-fun.thm new file mode 100644 index 0000000..3373818 --- /dev/null +++ b/src/convert-fun.thm @@ -0,0 +1,455 @@ +%block csig-ei : some {A:tp} {EA:etp} + block {c:ctm} {d:cof c A} {e:ecof c EA}. +%block asig-ei : some {K:kind} {EK:ekind} + block {a:ctp} {d:ckof a K} {e:eckof a EK}. + +convert-fun : convert M A EM -> convert M A EN + -> etm-eq EM EN -> type. +%mode convert-fun +X1 +X2 -X3. + +aconvert-fun : aconvert R A EM -> aconvert R B EN + -> tp-eq A B + -> etm-eq EM EN -> type. +%mode aconvert-fun +X1 +X2 -X3 -X4. + +tpconvert-fun : tpconvert A K EA -> tpconvert A K EA' + -> etp-eq EA EA' -> type. +%mode tpconvert-fun +X1 +X2 -X3. + +atpconvert-fun : atpconvert P K EA -> atpconvert P K' EA' + -> kind-eq K K' + -> etp-eq EA EA' -> type. +%mode atpconvert-fun +X1 +X2 -X3 -X4. + +-at : convert-fun + (convert/at (Daconvert : aconvert R (base P) EM)) + (convert/at (Daconvert' : aconvert R (base P) EM')) + Deq + <- aconvert-fun Daconvert Daconvert' _ Deq. + +-lam : convert-fun + (convert/lam + ([x] [d:vof x A] [ex] [xt] + DconvertM x d ex xt : convert (M x) (B x) (EM ex)) + (DconvertA : tpconvert A ktype EA)) + (convert/lam + ([x] [d:vof x A] [ex] [xt] + DconvertM' x d ex xt : convert (M x) (B x) (EM' ex)) + (DconvertA' : tpconvert A ktype EA')) + DeqLam + <- ({x} {d} {ex} {xt} + convert-fun (DconvertM x d ex xt) (DconvertM' x d ex xt) + (DeqEM ex : etm-eq (EM ex) (EM' ex))) + <- tpconvert-fun DconvertA DconvertA' + (DeqEA : etp-eq EA EA') + <- elam-compat DeqEA DeqEM + (DeqLam + : etm-eq (elam EA ([ex] EM ex)) (elam EA' ([ex] EM' ex))). + +-const : aconvert-fun + (aconvert/const + _ + (Dkof : kof A ktype) + (Dcof : cof C A)) + (aconvert/const + _ + (Dkof' : kof A' ktype) + (Dcof' : cof C A')) + DeqA + etm-eq/i + <- cof-fun Dcof Dcof' DeqA. + +-var : aconvert-fun + (aconvert/var + (Dvtrans : vtrans EX X) + _ + (Dkof : kof A ktype) + (Dvof : vof X A)) + (aconvert/var + (Dvtrans : vtrans EX X) + _ + (Dkof' : kof A ktype) + (Dvof : vof X A)) + tp-eq/i + etm-eq/i. + +-app : aconvert-fun + (aconvert/app + (Dsub : tpsub ([x] B x) N Bx) + (DconvertN : convert N A EN) + (DconvertR : aconvert R (pi A ([x] B x)) EM)) + (aconvert/app + (Dsub' : tpsub ([x] B' x) N Bx') + (DconvertN' : convert N A' EN') + (DconvertR' : aconvert R (pi A' ([x] B' x)) EM')) +%% + DeqBx + DeqApp +%% + <- aconvert-fun DconvertR DconvertR' + (Deqpi : tp-eq (pi A B) (pi A' B')) + (DeqEM : etm-eq EM EM') + %% + <- pi-inj Deqpi + (DeqA : tp-eq A A') + ([x] DeqB x : tp-eq (B x) (B' x)) + <- tp-eq-sym DeqA DeqA' + <- convert-resp DconvertN' tm-eq/i DeqA' etm-eq/i + (DconvertN'' : convert N A EN') + <- convert-fun DconvertN DconvertN'' + (DeqEN : etm-eq EN EN') + %% + <- eapp-compat DeqEM DeqEN + (DeqApp : etm-eq (eapp EM EN) (eapp EM' EN')) + %% getting Bx = Bx' + <- tpsub-compat DeqB tm-eq/i tp-eq/i Dsub + (Dsub'' : tpsub ([x] B' x) N Bx) + <- tpsub-fun Dsub'' Dsub' + (DeqBx : tp-eq Bx Bx'). + +%% + +-base : tpconvert-fun + (tpconvert/base (Datpconvert : atpconvert P ktype EA)) + (tpconvert/base (Datpconvert' : atpconvert P ktype EA')) + Deq + <- atpconvert-fun Datpconvert Datpconvert' _ Deq. + +-lam : tpconvert-fun + (tpconvert/lam + ([x] [d:vof x A] [ex] [xt] + DconvertM x d ex xt : tpconvert (M x) (B x) (EM ex)) + (DconvertA : tpconvert A ktype EA)) + (tpconvert/lam + ([x] [d:vof x A] [ex] [xt] + DconvertM' x d ex xt : tpconvert (M x) (B x) (EM' ex)) + (DconvertA' : tpconvert A ktype EA')) + DeqLam + <- ({x} {d} {ex} {xt} + tpconvert-fun (DconvertM x d ex xt) (DconvertM' x d ex xt) + (DeqEM ex : etp-eq (EM ex) (EM' ex))) + <- tpconvert-fun DconvertA DconvertA' + (DeqEA : etp-eq EA EA') + <- ealam-compat DeqEA DeqEM + (DeqLam + : etp-eq (ealam EA ([ex] EM ex)) (ealam EA' ([ex] EM' ex))). + +-pi : tpconvert-fun + (tpconvert/pi + ([x] [d:vof x A] [ex] [xt] + DconvertM x d ex xt : tpconvert (M x) ktype (EM ex)) + (DconvertA : tpconvert A ktype EA)) + (tpconvert/pi + ([x] [d:vof x A] [ex] [xt] + DconvertM' x d ex xt : tpconvert (M x) ktype (EM' ex)) + (DconvertA' : tpconvert A ktype EA')) + DeqLam + <- ({x} {d} {ex} {xt} + tpconvert-fun (DconvertM x d ex xt) (DconvertM' x d ex xt) + (DeqEM ex : etp-eq (EM ex) (EM' ex))) + <- tpconvert-fun DconvertA DconvertA' + (DeqEA : etp-eq EA EA') + <- epi-compat DeqEA DeqEM + (DeqLam + : etp-eq (epi EA ([ex] EM ex)) (epi EA' ([ex] EM' ex))). + +-const : atpconvert-fun + (atpconvert/const _ (Dkof : wfkind A) (Dcof : ckof C A)) + (atpconvert/const _ (Dkof' : wfkind A') (Dcof' : ckof C A')) + DeqA + etp-eq/i + <- ckof-fun Dcof Dcof' DeqA. + +-app : atpconvert-fun + (atpconvert/app + (Dsub : ksub ([x] B x) N Bx) + (DconvertN : convert N A EN) + (DconvertR : atpconvert R (kpi A ([x] B x)) EM)) + (atpconvert/app + (Dsub' : ksub ([x] B' x) N Bx') + (DconvertN' : convert N A' EN') + (DconvertR' : atpconvert R (kpi A' ([x] B' x)) EM')) +%% + DeqBx + DeqApp +%% + <- atpconvert-fun DconvertR DconvertR' + (Deqpi : kind-eq (kpi A B) (kpi A' B')) + (DeqEM : etp-eq EM EM') + %% + <- kpi-inj Deqpi + (DeqA : tp-eq A A') + ([x] DeqB x : kind-eq (B x) (B' x)) + <- tp-eq-sym DeqA DeqA' + <- convert-resp DconvertN' tm-eq/i DeqA' etm-eq/i + (DconvertN'' : convert N A EN') + <- convert-fun DconvertN DconvertN'' + (DeqEN : etm-eq EN EN') + %% + <- eaapp-compat DeqEM DeqEN + (DeqApp : etp-eq (eaapp EM EN) (eaapp EM' EN')) + %% getting Bx = Bx' + <- ksub-compat DeqB tm-eq/i kind-eq/i Dsub + (Dsub'' : ksub ([x] B' x) N Bx) + <- ksub-fun Dsub'' Dsub' + (DeqBx : kind-eq Bx Bx'). + +%worlds (csig-ei | asig-ei | tbind) + (convert-fun _ _ _) + (aconvert-fun _ _ _ _) + (tpconvert-fun _ _ _) + (atpconvert-fun _ _ _ _). +%total (D1 D2 D3 D4) + (convert-fun D1 _ _) + (aconvert-fun D2 _ _ _) + (tpconvert-fun D3 _ _) + (atpconvert-fun D4 _ _ _). + +kconvert-fun : kconvert K EK -> kconvert K EK' -> ekind-eq EK EK' -> type. +%mode kconvert-fun +X1 +X2 -X3. + +-type : kconvert-fun kconvert/type kconvert/type ekind-eq/i. + +-pi : kconvert-fun (kconvert/pi DconvK DconvA) (kconvert/pi DconvK' DconvA') + DeqPi + <- ({x} {d} {ex} {xt} + kconvert-fun (DconvK x d ex xt) (DconvK' x d ex xt) + (DeqEK ex)) + <- tpconvert-fun DconvA DconvA' DeqEA + <- ekpi-compat DeqEA DeqEK DeqPi. + +%worlds (csig-ei | asig-ei | tbind) (kconvert-fun _ _ _). +%total D (kconvert-fun D _ _). + + +converte-fun : ordered G -> converte G M A EM -> converte G M A EM' + -> etm-eq EM EM' -> type. +%mode converte-fun +X0 +X1 +X2 -X3. + +aconverte-fun : ordered G -> aconverte G R A EM -> aconverte G R A' EM' + -> tp-eq A A' + -> etm-eq EM EM' -> type. +%mode aconverte-fun +X0 +X1 +X2 -X3 -X4. + +tpconverte-fun : ordered G -> tpconverte G A K EA -> tpconverte G A K EA' + -> etp-eq EA EA' -> type. +%mode tpconverte-fun +X0 +X1 +X2 -X3. + +atpconverte-fun : ordered G + -> atpconverte G P K EA -> atpconverte G P K' EA' + -> kind-eq K K' + -> etp-eq EA EA' -> type. +%mode atpconverte-fun +X1 +X2 +X3 -X4 -X5. + +kconverte-fun : ordered G -> kconverte G K EK -> kconverte G K EK' + -> ekind-eq EK EK' -> type. +%mode kconverte-fun +X1 +X2 +X3 -X4. + +-at : converte-fun Dord + (converte/at Daconvert) + (converte/at Daconvert') + Deq + <- aconverte-fun Dord Daconvert Daconvert' _ Deq. + +-lam : converte-fun Dord + (converte/lam + ([x] [ex] [xt:vtrans ex x] + DconvertM x ex xt + : converte (cons G x A) (M x) (B x) (EM ex)) + (DconvertA : tpconverte G A ktype EA)) + (converte/lam + ([x] [ex] [xt] + DconvertM' x ex xt + : converte (cons G x A) (M x) (B x) (EM' ex)) + (DconvertA' : tpconverte G A ktype EA')) + Deq + <- extend-ordered _ Dord _ Dord' + <- ({x} {d} {ex} {xt} + converte-fun (Dord' x d) + (DconvertM x ex xt) (DconvertM' x ex xt) + (DeqEM ex : etm-eq (EM ex) (EM' ex))) + <- tpconverte-fun Dord DconvertA DconvertA' + (DeqEA : etp-eq EA EA') + <- elam-compat DeqEA DeqEM Deq. + +-const : aconverte-fun _ + (aconverte/const Dtconvert Dkof Dcof) + (aconverte/const Dtconvert' Dkof' Dcof') + DeqA + etm-eq/i + <- cof-fun Dcof Dcof' + (DeqA : tp-eq A A'). + +-var : aconverte-fun Dord + (aconverte/var Dvtrans Dtconvert Dlook) + (aconverte/var Dvtrans Dtconvert' Dlook') + DeqA + etm-eq/i + <- lookup-fun Dord Dlook Dlook' + (DeqA : tp-eq A A'). + +-varivar : aconverte-fun Dord + (aconverte/vari Dvtrans Dtconvert Dkof Dvof) + (aconverte/var Dvtrans Dtconvert' Dlook) + DeqA + Deq + <- lookup-isvar Dlook Dord Disvar + <- vof-isvar-contra Dvof Disvar Dfalse + <- false-implies-tp-eq Dfalse DeqA + <- false-implies-etm-eq Dfalse Deq. + +-vari : aconverte-fun Dord + (aconverte/vari Dvtrans Dtconvert Dkof Dvof) + (aconverte/vari Dvtrans' Dtconvert' Dkof' Dvof') + tp-eq/i + etm-eq/i. + +-varvari : aconverte-fun Dord + (aconverte/var Dvtrans Dtconvert Dlook) + (aconverte/vari Dvtrans Dtconvert' Dkof Dvof) + DeqA + Deq + <- lookup-isvar Dlook Dord Disvar + <- vof-isvar-contra Dvof Disvar Dfalse + <- false-implies-tp-eq Dfalse DeqA + <- false-implies-etm-eq Dfalse Deq. + +-app : aconverte-fun Dord + (aconverte/app + (Dtpsub : tpsub ([x] B x) N Bx) + (DconvertN : converte G N A EN) + (DconvertR : aconverte G R (pi A B) ER)) + (aconverte/app + (Dtpsub' : tpsub ([x] B' x) N Bx') + (DconvertN' : converte G N A' EN') + (DconvertR' : aconverte G R (pi A' B') ER')) + DeqBx + DeqApp + <- aconverte-fun Dord DconvertR DconvertR' + (Deqpi : tp-eq (pi A ([x] B x)) (pi A' ([x] B' x))) + (DeqER : etm-eq ER ER') + <- pi-inj Deqpi + (DeqA : tp-eq A A') + ([x] DeqB x : tp-eq (B x) (B' x)) + <- converte-resp DconvertN ctx-eq/i tm-eq/i DeqA etm-eq/i + (DconvertN'' : converte G N A' EN) + <- converte-fun Dord DconvertN'' DconvertN' + (DeqEN : etm-eq EN EN') + <- eapp-compat DeqER DeqEN DeqApp + %% + <- tpsub-compat DeqB tm-eq/i tp-eq/i Dtpsub + (Dtpsub'' : tpsub ([x] B' x) N Bx) + <- tpsub-fun Dtpsub'' Dtpsub' + (DeqBx : tp-eq Bx Bx'). + +-base : tpconverte-fun Dord + (tpconverte/base Daconv) + (tpconverte/base Daconv') + Deq + <- atpconverte-fun Dord Daconv Daconv' _ Deq. + +-lam : tpconverte-fun Dord + (tpconverte/lam + ([x] [ex] [xt:vtrans ex x] + DconvertM x ex xt + : tpconverte (cons G x A) (M x) (B x) (EM ex)) + (DconvertA : tpconverte G A ktype EA)) + (tpconverte/lam + ([x] [ex] [xt] + DconvertM' x ex xt + : tpconverte (cons G x A) (M x) (B x) (EM' ex)) + (DconvertA' : tpconverte G A ktype EA')) + Deq + <- extend-ordered _ Dord _ Dord' + <- ({x} {d} {ex} {xt} + tpconverte-fun (Dord' x d) + (DconvertM x ex xt) (DconvertM' x ex xt) + (DeqEM ex : etp-eq (EM ex) (EM' ex))) + <- tpconverte-fun Dord DconvertA DconvertA' + (DeqEA : etp-eq EA EA') + <- ealam-compat DeqEA DeqEM Deq. + +-pi : tpconverte-fun Dord + (tpconverte/pi + ([x] [ex] [xt:vtrans ex x] + DconvertM x ex xt + : tpconverte (cons G x A) (M x) ktype (EM ex)) + (DconvertA : tpconverte G A ktype EA)) + (tpconverte/pi + ([x] [ex] [xt] + DconvertM' x ex xt + : tpconverte (cons G x A) (M x) ktype (EM' ex)) + (DconvertA' : tpconverte G A ktype EA')) + Deq + <- extend-ordered _ Dord _ Dord' + <- ({x} {d} {ex} {xt} + tpconverte-fun (Dord' x d) + (DconvertM x ex xt) (DconvertM' x ex xt) + (DeqEM ex : etp-eq (EM ex) (EM' ex))) + <- tpconverte-fun Dord DconvertA DconvertA' + (DeqEA : etp-eq EA EA') + <- epi-compat DeqEA DeqEM Deq. + +-const : atpconverte-fun _ + (atpconverte/const Dkconv Dwf Dckof) + (atpconverte/const Dkconv' Dwf' Dckof') + Deq + etp-eq/i + <- ckof-fun Dckof Dckof' Deq. + +-app : atpconverte-fun Dord + (atpconverte/app + Dtpsub + DconvertN + DconvertR) + (atpconverte/app + Dtpsub' + DconvertN' + DconvertR') + DeqBx + DeqApp + <- atpconverte-fun Dord DconvertR DconvertR' + Deqpi + DeqER + <- kpi-inj Deqpi + (DeqA : tp-eq A A') + ([x] DeqB x : kind-eq (B x) (B' x)) + <- converte-resp DconvertN ctx-eq/i tm-eq/i DeqA etm-eq/i + (DconvertN'' : converte G N A' EN) + <- converte-fun Dord DconvertN'' DconvertN' + (DeqEN : etm-eq EN EN') + <- eaapp-compat DeqER DeqEN DeqApp + %% + <- ksub-compat DeqB tm-eq/i kind-eq/i Dtpsub + Dtpsub'' + <- ksub-fun Dtpsub'' Dtpsub' + DeqBx. + +-type : kconverte-fun _ kconverte/type kconverte/type ekind-eq/i. + +-pi : kconverte-fun Dord + (kconverte/pi DconvertM DconvertA) + (kconverte/pi DconvertM' DconvertA') + Deq + <- extend-ordered _ Dord _ Dord' + <- ({x} {d} {ex} {xt} + kconverte-fun (Dord' x d) + (DconvertM x ex xt) (DconvertM' x ex xt) + (DeqEM ex)) + <- tpconverte-fun Dord DconvertA DconvertA' + (DeqEA : etp-eq EA EA') + <- ekpi-compat DeqEA DeqEM Deq. + +%worlds (csig-ei | asig-ei | tvar | tbind | tobind) + (converte-fun _ _ _ _) + (aconverte-fun _ _ _ _ _) + (tpconverte-fun _ _ _ _) + (atpconverte-fun _ _ _ _ _) + (kconverte-fun _ _ _ _). +%total (D1 D2 D3 D4 D5) + (converte-fun _ D1 _ _) + (aconverte-fun _ D2 _ _ _) + (tpconverte-fun _ D3 _ _) + (atpconverte-fun _ D4 _ _ _) + (kconverte-fun _ D5 _ _). + diff --git a/src/convert-normal.thm b/src/convert-normal.thm new file mode 100644 index 0000000..9a78d0a --- /dev/null +++ b/src/convert-normal.thm @@ -0,0 +1,198 @@ +atomic : etm -> type. +normal : etm -> type. +tpatomic : etp -> type. +tpnormal : etp -> type. + +atomic/const : atomic (econst C). + +atomic/var : atomic X + <- variable X. + +atomic/app : atomic (eapp M N) + <- atomic M + <- normal N. + +normal/at : normal M + <- atomic M. + +normal/lam : normal (elam A M) + <- tpnormal A + <- ({x} variable x -> normal (M x)). + +tpatomic/const: tpatomic (eaconst C). + +tpatomic/app : tpatomic (eaapp A M) + <- tpatomic A + <- normal M. + +tpnormal/base : tpnormal A + <- tpatomic A. + +tpnormal/pi : tpnormal (epi A ([x] B x)) + <- tpnormal A + <- ({x} variable x -> tpnormal (B x)). + +tpnormal/lam : tpnormal (ealam A [x] B x) + <- tpnormal A + <- ({x} variable x -> tpnormal (B x)). + +aconverte-atomic : aconverte _ _ _ EM -> atomic EM -> type. +%mode aconverte-atomic +X1 -X2. + +converte-normal : converte _ _ _ EM -> normal EM -> type. +%mode converte-normal +X1 -X2. + +atpconverte-atomic: atpconverte _ _ _ EA -> tpatomic EA -> type. +%mode atpconverte-atomic +X1 -X2. + +tpconverte-normal : tpconverte _ _ _ EA -> tpnormal EA -> type. +%mode tpconverte-normal +X1 -X2. + +-const : aconverte-atomic (aconverte/const _ _ _) atomic/const. + +-var : aconverte-atomic (aconverte/var Dvtrans _ _) (atomic/var Dvar) + <- vtrans-variable Dvtrans Dvar. + +-vari : aconverte-atomic (aconverte/vari Dvtrans _ _ _) + (atomic/var Dvar) + <- vtrans-variable Dvtrans Dvar. + +-app : aconverte-atomic + (aconverte/app _ Dconvert Daconvert) + (atomic/app Dnormal Datomic) + <- converte-normal Dconvert Dnormal + <- aconverte-atomic Daconvert Datomic. + +-at : converte-normal + (converte/at Daconvert) + (normal/at Datomic) + <- aconverte-atomic Daconvert Datomic. + +-lam : converte-normal + (converte/lam + ([x] [ex] [xt:vtrans ex x] + DconvertM x ex xt + : converte (cons G x A) (M x) (B x) (EM ex)) + (DconvertA : tpconverte G A ktype EA)) + (normal/lam DnormalM DnormalA) + <- tpconverte-normal DconvertA DnormalA + <- ({x} {ex} {xt:vtrans ex x} {dv:variable ex} + vtrans-variable xt dv + -> converte-normal + (DconvertM x ex xt) + (DnormalM ex dv : normal (EM ex))). + +%% + +-const : atpconverte-atomic (atpconverte/const _ _ _) tpatomic/const. + +-app : atpconverte-atomic (atpconverte/app _ Dconvert Daconvert) + (tpatomic/app Dnormal Datomic) + <- converte-normal Dconvert Dnormal + <- atpconverte-atomic Daconvert Datomic. + +-base : tpconverte-normal + (tpconverte/base Daconvert) + (tpnormal/base Datomic) + <- atpconverte-atomic Daconvert Datomic. + +-pi : tpconverte-normal + (tpconverte/pi ([x] [ex] [xt] DconvertB x ex xt) DconvertA) + (tpnormal/pi DnormalB DnormalA) + <- tpconverte-normal DconvertA DnormalA + <- ({x} {ex} {xt} {dv:variable ex} vtrans-variable xt dv + -> tpconverte-normal (DconvertB x ex xt) + (DnormalB ex dv)). + +-lam : tpconverte-normal + (tpconverte/lam ([x] [ex] [xt] DconvertB x ex xt) DconvertA) + (tpnormal/lam DnormalB DnormalA) + <- tpconverte-normal DconvertA DnormalA + <- ({x} {ex} {xt} {dv:variable ex} vtrans-variable xt dv + -> tpconverte-normal (DconvertB x ex xt) + (DnormalB ex dv)). + +%worlds (bind | evvar | tvvar | tvobind | sbind') + (aconverte-atomic _ _) + (converte-normal _ _) + (atpconverte-atomic _ _) + (tpconverte-normal _ _). +%total (D1 D2 D3 D4) + (aconverte-atomic D1 _) + (converte-normal D2 _) + (atpconverte-atomic D3 _) + (tpconverte-normal D4 _). + + +atomic-reduce-refl : atomic M -> reduce M M -> type. +%mode atomic-reduce-refl +X1 -X2. + +normal-reduce-refl : normal M -> reduce M M -> type. +%mode normal-reduce-refl +X1 -X2. + +tpnormal-reduce-refl : tpnormal A -> tpreduce A A -> type. +%mode tpnormal-reduce-refl +X1 -X2. + +tpatomic-reduce-refl : tpatomic A -> tpreduce A A -> type. +%mode tpatomic-reduce-refl +X1 -X2. + +-const : atomic-reduce-refl atomic/const reduce/refl. + +-var : atomic-reduce-refl (atomic/var D) reduce/refl. + +-app : atomic-reduce-refl + (atomic/app Dnorm Datom) + (reduce/app D2 D1) + <- atomic-reduce-refl Datom D1 + <- normal-reduce-refl Dnorm D2. + +-at : normal-reduce-refl + (normal/at Datomic) + Dreduce + <- atomic-reduce-refl Datomic Dreduce. + +-lam : normal-reduce-refl + (normal/lam ([x] [dv] Dnormal x dv) Dtnormal) + (reduce/lam ([x] [dv] Dreduce x dv) Dtreduce) + <- ({x} {dv:variable x} + normal-reduce-refl (Dnormal x dv) + (Dreduce x dv)) + <- tpnormal-reduce-refl Dtnormal Dtreduce. + +%% + +-const : tpatomic-reduce-refl tpatomic/const tpreduce/const. + +-app : tpatomic-reduce-refl + (tpatomic/app Dnorm Datom) + (tpreduce/app Dred Dtpred) + <- tpatomic-reduce-refl Datom Dtpred + <- normal-reduce-refl Dnorm Dred. + +-base : tpnormal-reduce-refl + (tpnormal/base Datom) + Dreduce + <- tpatomic-reduce-refl Datom Dreduce. + +-pi : tpnormal-reduce-refl + (tpnormal/pi ([x] [d] DnormalB x d) DnormalA) + (tpreduce/pi ([x] [d] DreduceB x d) DreduceA) + <- tpnormal-reduce-refl DnormalA DreduceA + <- ({x} {d} tpnormal-reduce-refl (DnormalB x d) (DreduceB x d)). + +-lam : tpnormal-reduce-refl + (tpnormal/lam ([x] [d] DnormalB x d) DnormalA) + (tpreduce/lam ([x] [d] DreduceB x d) DreduceA) + <- tpnormal-reduce-refl DnormalA DreduceA + <- ({x} {d} tpnormal-reduce-refl (DnormalB x d) (DreduceB x d)). + +%worlds (tvvar | tvobind | evvar) + (normal-reduce-refl _ _) + (atomic-reduce-refl _ _) + (tpnormal-reduce-refl _ _) + (tpatomic-reduce-refl _ _). +%total (D1 D2 D3 D4) + (normal-reduce-refl D1 _) + (atomic-reduce-refl D2 _) + (tpnormal-reduce-refl D3 _) + (tpatomic-reduce-refl D4 _). diff --git a/src/convert-reg-il.thm b/src/convert-reg-il.thm new file mode 100644 index 0000000..476e7bd --- /dev/null +++ b/src/convert-reg-il.thm @@ -0,0 +1,175 @@ + +aconverte-reg-il : aconverte G R A _ -> at-ofe G R A -> type. +%mode aconverte-reg-il +X1 -X2. + +converte-reg-il : converte G M A _ -> ofe G M A -> type. +%mode converte-reg-il +X1 -X2. + +tpconverte-reg-il : tpconverte G A K _ -> kofe G A K -> type. +%mode tpconverte-reg-il +X1 -X2. + +atpconverte-reg-il: atpconverte G R A _ -> at-kofe G R A -> type. +%mode atpconverte-reg-il +X1 -X2. + +kconverte-reg-il : kconverte G K _ -> wfkinde G K -> type. +%mode kconverte-reg-il +X1 -X2. + +-const : aconverte-reg-il + (aconverte/const Dtpconvert _ Dcof) + (at-ofe/const Dkof Dcof) + <- tpconverte-reg-il Dtpconvert Dkof. + +-var : aconverte-reg-il + (aconverte/var _ Dtconvert Dlook) + (at-ofe/var Dkof Dlook) + <- tpconverte-reg-il Dtconvert Dkof. + +-vari : aconverte-reg-il + (aconverte/vari _ _ Dkof Dvof) + (at-ofe/closed (at-of/var Dkof Dvof)). + +-app : aconverte-reg-il + (aconverte/app Dsub Dconvert Daconvert) + (at-ofe/app Dsub Dof Datof) + <- converte-reg-il Dconvert Dof + <- aconverte-reg-il Daconvert Datof. + +-at : converte-reg-il + (converte/at Daconvert) + (ofe/at Datof) + <- aconverte-reg-il Daconvert Datof. + +-lam : converte-reg-il + (converte/lam + ([x] [ex] [xt] DconvertM x ex xt) + DconvertA) + (ofe/lam DofA DofM) + <- tpconverte-reg-il DconvertA DofA + <- ({x} {ex} {xt} + converte-reg-il (DconvertM x ex xt) + (DofM x)). + +%%%% + +-const : atpconverte-reg-il + (atpconverte/const Dkconvert _ Dckof) + (at-kofe/const Dwfkind Dckof) + <- kconverte-reg-il Dkconvert Dwfkind. + + +-app : atpconverte-reg-il + (atpconverte/app Dsub Dconvert Daconvert) + (at-kofe/app Dsub Dof Datof) + <- converte-reg-il Dconvert Dof + <- atpconverte-reg-il Daconvert Datof. + +-base : tpconverte-reg-il + (tpconverte/base Daconvert) + (kofe/base Datof) + <- atpconverte-reg-il Daconvert Datof. + +-lam : tpconverte-reg-il + (tpconverte/lam + ([x] [ex] [xt] DconvertM x ex xt) + DconvertA) + (kofe/lam DofM DofA) + <- tpconverte-reg-il DconvertA DofA + <- ({x} {ex} {xt} + tpconverte-reg-il (DconvertM x ex xt) + (DofM x)). + +-pi : tpconverte-reg-il + (tpconverte/pi + ([x] [ex] [xt] DconvertM x ex xt) + DconvertA) + (kofe/pi DofM DofA) + <- tpconverte-reg-il DconvertA DofA + <- ({x} {ex} {xt} + tpconverte-reg-il (DconvertM x ex xt) + (DofM x)). + +%%%% + +-type : kconverte-reg-il _ wfkinde/tp. + +-pi : kconverte-reg-il + (kconverte/pi + ([x] [ex] [xt] DconvertM x ex xt) + DconvertA) + (wfkinde/pi DofM DofA) + <- tpconverte-reg-il DconvertA DofA + <- ({x} {ex} {xt} + kconverte-reg-il (DconvertM x ex xt) + (DofM x)). + +%worlds +(csig-ei | asig-ei | bind | evvar | tvar | tbind | tobind | tvobind | sbind') + (aconverte-reg-il _ _) + (converte-reg-il _ _) + (atpconverte-reg-il _ _) + (tpconverte-reg-il _ _) + (kconverte-reg-il _ _). +%total (D1 D2 D3 D4 D5) + (aconverte-reg-il D1 _) + (converte-reg-il D2 _) + (atpconverte-reg-il D3 _) + (tpconverte-reg-il D4 _) + (kconverte-reg-il D5 _). + +%% Implicit contexts %% + +convert-reg-il : convert M A EM -> of M A -> type. +%mode convert-reg-il +X1 -X2. + +- : convert-reg-il Dconv Dof + <- convert-to-converte-nil Dconv Dconve + <- converte-reg-il Dconve Dofe + <- ofe-to-of Dofe Dof. + +%worlds (csig-ei | asig-ei | tvvar | tbind | sbind') (convert-reg-il _ _). +%total {} (convert-reg-il _ _). + +aconvert-reg-il : aconvert M A EM -> at-of M A -> type. +%mode aconvert-reg-il +X1 -X2. + +- : aconvert-reg-il Dconv Dof + <- aconvert-to-aconverte-nil Dconv Dconve + <- aconverte-reg-il Dconve Dofe + <- atofe-to-atof Dofe Dof. + +%worlds (csig-ei | asig-ei | tvvar | tbind | sbind') (aconvert-reg-il _ _). +%total {} (aconvert-reg-il _ _). + +atpconvert-reg-il : atpconvert M A EM -> at-kof M A -> type. +%mode atpconvert-reg-il +X1 -X2. + +- : atpconvert-reg-il Dconv Dof + <- atpconvert-to-atpconverte-nil Dconv Dconve + <- atpconverte-reg-il Dconve Dofe + <- atkofe-to-atkof Dofe Dof. + +%worlds (csig-ei | asig-ei | tvvar | tbind | sbind') (atpconvert-reg-il _ _). +%total {} (atpconvert-reg-il _ _). + +tpconvert-reg-il : tpconvert M A EM -> kof M A -> type. +%mode tpconvert-reg-il +X1 -X2. + +- : tpconvert-reg-il Dconv Dof + <- tpconvert-to-tpconverte-nil Dconv Dconve + <- tpconverte-reg-il Dconve Dofe + <- kofe-to-kof Dofe Dof. + +%worlds (csig-ei | asig-ei | tvvar | tbind | sbind') (tpconvert-reg-il _ _). +%total {} (tpconvert-reg-il _ _). + +kconvert-reg-il : kconvert M EM -> wfkind M -> type. +%mode kconvert-reg-il +X1 -X2. + +- : kconvert-reg-il Dconv Dof + <- kconvert-to-kconverte-nil Dconv Dconve + <- kconverte-reg-il Dconve Dofe + <- wfkinde-to-wfkind Dofe Dof. + +%worlds (csig-ei | asig-ei | tvvar | tbind | sbind') (kconvert-reg-il _ _). +%total {} (kconvert-reg-il _ _). + diff --git a/src/convert-reg.thm b/src/convert-reg.thm new file mode 100644 index 0000000..f0ff3a1 --- /dev/null +++ b/src/convert-reg.thm @@ -0,0 +1,362 @@ +%%%% Regularity %%%% + +convert-cof : cof C A -> tpconvert A ktype EA -> ecof C EA -> type. +%mode convert-cof +X1 -X2 -X3. + +convert-ckof : ckof C A -> kconvert A EA -> eckof C EA -> type. +%mode convert-ckof +X1 -X2 -X3. + +%block scsig : some {A:tp} {EA:etp} {d_conv:tpconvert A ktype EA} + block {c:ctm} {d:cof c A} {e:ecof c EA} + {thm:convert-cof d d_conv e}. + +%block sasig : some {K:kind} {EK:ekind} {d_conv:kconvert K EK} + block {a:ctp} {d:ckof a K} {e:eckof a EK} + {thm:convert-ckof d d_conv e}. + +- : convert-cof dof_zero + (tpconvert/base (atpconvert/const kconvert/type wfkind/tp dkof_nat)) + deof_zero. + +- : convert-ckof dkof_nat kconvert/type dekof_nat. + +%worlds (scsig | sasig | sbind) (convert-cof _ _ _). +%total {} (convert-cof _ _ _). + +%worlds (scsig | sasig | sbind) (convert-ckof _ _ _). +%total {} (convert-ckof _ _ _). + +vtrans-inj : vtrans EX X -> vtrans EX' X -> etm-eq EX EX' -> type. +%mode vtrans-inj +X1 +X2 -X3. + +- : vtrans-inj D D etm-eq/i. + +%block nbind : some {A:tp} {EA:etp} + block {x:atm} {d:vof x A} + {ex:etm} {xt:vtrans ex x} + {ed:evof ex EA}. +%worlds (scsig | sasig | nbind) (vtrans-inj _ _ _). +%total {} (vtrans-inj _ _ _). + + +convert-reg : convert M A EM -> tpconvert A ktype EA -> eof EM EA -> type. +%mode convert-reg +X1 +X2 -X3. + +aconvert-reg : aconvert R A EM -> tpconvert A ktype EA + -> eof EM EA -> type. +%mode aconvert-reg +X1 +X2 -X3. + +atpconvert-reg : atpconvert A K EA -> kconvert K EK -> ekof EA EK -> type. +%mode atpconvert-reg +X1 +X2 -X3. + +tpconvert-reg : tpconvert M A EM -> kconvert A EA -> ekof EM EA -> type. +%mode tpconvert-reg +X1 +X2 -X3. + +kconvert-reg : kconvert K EK -> ewfkind EK -> type. +%mode kconvert-reg +X1 -X2. + +-at : convert-reg + (convert/at (Daconvert : aconvert R (base P) EM)) + (tpconvert/base (Datpconvert : atpconvert P ktype EA)) + DofEM + <- aconvert-reg Daconvert (tpconvert/base Datpconvert) + (DofEM : eof EM EA). + +-lam : convert-reg + (convert/lam + ([x] [d:vof x A] + [ex] [dt:vtrans ex x] + DconvM x d ex dt : convert (M x) (B x) (EM ex)) + (DconvA : tpconvert A ktype EA)) + (tpconvert/pi + ([x] [d] [ex] [dt] + DconvB x d ex dt : tpconvert (B x) ktype (EB ex)) + (DconvA' : tpconvert A ktype EA')) +%% + Dof +%% + <- ({x} {d:vof x A} {ex} {dt:vtrans ex x} + {ed:evof ex EA} {dv:variable ex} + vtrans-variable dt dv -> + convert-vof d dt DconvA ed -> + convert-reg + (DconvM x d ex dt) + (DconvB x d ex dt) + (DofEM ex ed : eof (EM ex) (EB ex))) + <- tpconvert-reg DconvA kconvert/type + (DofEA : ekof EA ektype) + %% + <- tpconvert-fun DconvA DconvA' + (DeqEA : etp-eq EA EA') + <- epi-compat DeqEA ([x] etp-eq/i) + (DeqPi : etp-eq (epi EA EB) (epi EA' EB)) + <- eof-resp etm-eq/i DeqPi (eof/lam DofEA DofEM) + (Dof : eof (elam EA EM) (epi EA' EB)). + +%% + +-const : aconvert-reg + (aconvert/const + (DconvA : tpconvert A ktype EA) + (DofA : kof A ktype) + (Dcof : cof C A)) + (DconvA' : tpconvert A ktype EA') +%% + (eof/const DofEA' Decof) +%% + <- convert-cof Dcof + (DconvA'' : tpconvert A ktype EA'') + (Decof' : ecof C EA'') + <- tpconvert-fun DconvA'' DconvA' + (DeqA''A' : etp-eq EA'' EA') + <- ecof-resp DeqA''A' Decof' + (Decof : ecof C EA') + <- tpconvert-reg DconvA kconvert/type + (DofEA : ekof EA ektype) + <- tpconvert-fun DconvA DconvA' + (DeqEA : etp-eq EA EA') + <- ekof-resp DofEA DeqEA ekind-eq/i + (DofEA' : ekof EA' ektype). + +-var : aconvert-reg + (aconvert/var + (Dvtrans : vtrans EX X) + (DconvA : tpconvert A ktype EA) + _ + (Dvof : vof X A)) + (DconvA' : tpconvert A ktype EA') +%% + Dof +%% + <- convert-vof Dvof + (Dvtrans' : vtrans EX' X) + (DconvA'' : tpconvert A ktype EA'') + (Devof : evof EX' EA'') + <- vtrans-inj Dvtrans' Dvtrans + (DeqEX' : etm-eq EX' EX) + <- evof-resp Devof DeqEX' etp-eq/i + (Devof' : evof EX EA'') + <- tpconvert-fun DconvA'' DconvA + (DeqEA'' : etp-eq EA'' EA) + <- tpconvert-fun DconvA DconvA' + (DeqEA : etp-eq EA EA') + <- etp-eq-trans DeqEA'' DeqEA + (DeqEA''_EA' : etp-eq EA'' EA') + %% + <- tpconvert-reg DconvA kconvert/type + (DofEA : ekof EA ektype) + <- etp-eq-sym DeqEA'' + (DeqEA_EA'' : etp-eq EA EA'') + <- ekof-resp DofEA DeqEA_EA'' ekind-eq/i + (DofEA'' : ekof EA'' ektype) + %% + <- eof-resp etm-eq/i DeqEA''_EA' (eof/var DofEA'' Devof') + (Dof : eof EX EA'). + +-app : aconvert-reg + (aconvert/app + (DsubB : tpsub ([x] B x) N Bx) + (DconvN : convert N A EN) + (DconvR : aconvert R (pi A B) EM)) + (DconvBx : tpconvert Bx ktype EBx) +%% + (eof/eqtp DeqEBEN (eof/app DofEN DofEM)) +%% + %% get eof EM + <- aconvert-reg-il DconvR + (DofR : at-of R (pi A B)) + <- atof-reg DofR + (DofPi : kof (pi A B) ktype) + <- can-tpconvert DofPi + (tpconvert/pi + ([x] [d:vof x A] [ex] [dt:vtrans ex x] + (DconvB x d ex dt : tpconvert (B x) ktype (EB ex))) + (DconvA : tpconvert A ktype EA)) + <- aconvert-reg DconvR (tpconvert/pi DconvB DconvA) + (DofEM : eof EM (epi EA EB)) + %% get eof EN + <- convert-reg DconvN DconvA + (DofEN : eof EN EA) + %% (eof/app DofEN DofEM) : eof (eapp EM EN) (EB EN) + %% need to get that (EB EN) == EBx : ektype + <- convert-tpsub DconvB DconvN DsubB ksub/type + (DconvBx' : tpconvert Bx ktype EBx') + (DredBx' : tpreduce* (EB EN) EBx') + %% + <- tpconvert-fun DconvBx' DconvBx + (DeqEBx' : etp-eq EBx' EBx) + <- tpreduce*-resp DredBx' etp-eq/i DeqEBx' + (DredBx : tpreduce* (EB EN) EBx) + %% + <- eof-reg DofEM + (DofEpi : ekof (epi EA EB) ektype) + <- ekof-pi-invert DofEpi + DofEA + ([ex] [ed:evof ex EA] DofEB ex ed : ekof (EB ex) ektype) + <- esubst-kof DofEB DofEN + (DofEBx : ekof (EB EN) ektype) + <- tpreduce*-equiv DofEBx DredBx + (DeqEBEN : eqtp (EB EN) EBx ektype). + +%% + +-base : tpconvert-reg + (tpconvert/base (Daconvert : atpconvert R ktype EM)) + kconvert/type + DofEM + <- atpconvert-reg Daconvert kconvert/type + (DofEM : ekof EM ektype). + +-pi : tpconvert-reg + (tpconvert/pi + ([x] [d] [ex] [dt] DconvB x d ex dt) + DconvA) + kconvert/type +%% + (ekof/pi DofEB DofEA) +%% + <- ({x} {d:vof x A} {ex} {dt:vtrans ex x} + {ed:evof ex EA} {dv:variable ex} + vtrans-variable dt dv -> + convert-vof d dt DconvA ed -> + tpconvert-reg + (DconvB x d ex dt) + kconvert/type + (DofEB ex ed : ekof (EB ex) ektype)) + <- tpconvert-reg DconvA kconvert/type + (DofEA : ekof EA ektype). + +-lam : tpconvert-reg + (tpconvert/lam + ([x] [d:vof x A] + [ex] [dt:vtrans ex x] + DconvM x d ex dt : tpconvert (M x) (B x) (EM ex)) + (DconvA : tpconvert A ktype EA)) + (kconvert/pi + ([x] [d] [ex] [dt] + DconvB x d ex dt : kconvert (B x) (EB ex)) + (DconvA' : tpconvert A ktype EA')) +%% + Dof +%% + <- ({x} {d:vof x A} {ex} {dt:vtrans ex x} + {ed:evof ex EA} {dv:variable ex} + vtrans-variable dt dv -> + convert-vof d dt DconvA ed -> + tpconvert-reg + (DconvM x d ex dt) + (DconvB x d ex dt) + (DofEM ex ed : ekof (EM ex) (EB ex))) + <- tpconvert-reg DconvA kconvert/type + (DofEA : ekof EA ektype) + %% + <- tpconvert-fun DconvA DconvA' + (DeqEA : etp-eq EA EA') + <- ekpi-compat DeqEA ([x] ekind-eq/i) + (DeqPi : ekind-eq (ekpi EA EB) (ekpi EA' EB)) + <- ekof-resp (ekof/lam DofEA DofEM) etp-eq/i DeqPi + (Dof : ekof (ealam EA EM) (ekpi EA' EB)). + +%% + +-const : atpconvert-reg + (atpconvert/const + (DconvA : kconvert A EA) + (DofA : wfkind A) + (Dcof : ckof C A)) + (DconvA' : kconvert A EA') +%% + (ekof/const DofEA' Decof) +%% + <- convert-ckof Dcof DconvA'' + (Decof' : eckof C EA'') + %% + <- kconvert-fun DconvA'' DconvA' + DeqA''A' + <- eckof-resp DeqA''A' Decof' + Decof + %% + <- kconvert-reg DconvA + (DofEA : ewfkind EA) + <- kconvert-fun DconvA DconvA' + (DeqEA : ekind-eq EA EA') + <- ewfkind-resp DofEA DeqEA + (DofEA' : ewfkind EA'). + +-app : atpconvert-reg + (atpconvert/app + (DsubB : ksub ([x] B x) N Bx) + (DconvN : convert N A EN) + (DconvR : atpconvert R (kpi A B) EM)) + (DconvBx : kconvert Bx EBx) +%% + (ekof/eqkind DeqEBEN (ekof/app DofEN DofEM)) +%% + %% get eof EM + <- atpconvert-reg-il DconvR + (DofR : at-kof R (kpi A B)) + <- atkof-reg DofR + (DofPi : wfkind (kpi A B)) + <- can-kconvert DofPi + (kconvert/pi + ([x] [d:vof x A] [ex] [dt:vtrans ex x] + (DconvB x d ex dt : kconvert (B x) (EB ex))) + (DconvA : tpconvert A ktype EA)) + <- atpconvert-reg DconvR (kconvert/pi DconvB DconvA) + (DofEM : ekof EM (ekpi EA EB)) + %% get eof EN + <- convert-reg DconvN DconvA + (DofEN : eof EN EA) + %% (eof/app DofEN DofEM) : eof (eapp EM EN) (EB EN) + %% need to get that (EB EN) == EBx : ektype + <- convert-ksub DconvB DconvN DsubB + (DconvBx' : kconvert Bx EBx') + (DredBx' : kreduce* (EB EN) EBx') + %% + <- kconvert-fun DconvBx' DconvBx + (DeqEBx' : ekind-eq EBx' EBx) + <- kreduce*-resp DredBx' ekind-eq/i DeqEBx' + (DredBx : kreduce* (EB EN) EBx) + %% + <- ekof-reg DofEM + (ewfkind/pi + DofEB + DofEA) + <- esubst-wfkind DofEB DofEN + (DofEBx : ewfkind (EB EN)) + <- kreduce*-equiv DofEBx DredBx + (DeqEBEN : eqkind (EB EN) EBx). + +%% + +-type : kconvert-reg kconvert/type ewfkind/tp. + +-pi : kconvert-reg + (kconvert/pi + ([x] [d] [ex] [dt] DconvB x d ex dt) + DconvA) +%% + (ewfkind/pi DofEB DofEA) +%% + <- ({x} {d:vof x A} {ex} {dt:vtrans ex x} + {ed:evof ex EA} {dv:variable ex} + vtrans-variable dt dv -> + convert-vof d dt DconvA ed -> + kconvert-reg + (DconvB x d ex dt) + (DofEB ex ed : ewfkind (EB ex))) + <- tpconvert-reg DconvA kconvert/type + (DofEA : ekof EA ektype). + +%worlds (scsig | sasig | sbind) + (convert-reg _ _ _) + (aconvert-reg _ _ _) + (tpconvert-reg _ _ _) + (atpconvert-reg _ _ _) + (kconvert-reg _ _). +%total (D1 D2 D3 D4 D5) + (convert-reg D1 _ _) + (aconvert-reg D2 _ _) + (tpconvert-reg D3 _ _) + (atpconvert-reg D4 _ _) + (kconvert-reg D5 _). diff --git a/src/convert-sub.thm b/src/convert-sub.thm new file mode 100644 index 0000000..a65d573 --- /dev/null +++ b/src/convert-sub.thm @@ -0,0 +1,1399 @@ + +strengthen-vtrans : ({x} {ex} vtrans ex x -> vtrans (EX ex) X) + -> ({ex} etm-eq (EX ex) EX') + -> vtrans EX' X -> type. +%mode strengthen-vtrans +X1 -X2 -X3. + +- : strengthen-vtrans ([x] [ex] [d] D) ([ex] etm-eq/i) D. + +%worlds (csig | asig | bind | ovar | tvar | evar) (strengthen-vtrans _ _ _). +%total {} (strengthen-vtrans _ _ _). + +%%%% Lemmas about reduction and its transitive closure %%%% + +tpreduce-refl : {A} tpreduce A A -> type. +%mode tpreduce-refl +A -D. + +-const : tpreduce-refl (eaconst A) tpreduce/const. + +-pi : tpreduce-refl (epi A B) (tpreduce/pi DredB DredA) + <- tpreduce-refl A DredA + <- ({x} {dv} + tpreduce-refl (B x) + (DredB x dv : tpreduce (B x) (B x))). + +-lam : tpreduce-refl (ealam A B) (tpreduce/lam DredB DredA) + <- tpreduce-refl A DredA + <- ({x} {dv} + tpreduce-refl (B x) + (DredB x dv : tpreduce (B x) (B x))). + +-app : tpreduce-refl (eaapp A M) (tpreduce/app reduce/refl DredA) + <- tpreduce-refl A DredA. + +%worlds (ecsig | easig | evvar | tvar) (tpreduce-refl _ _). +%total A (tpreduce-refl A _). + +kreduce-refl : {K} kreduce K K -> type. +%mode kreduce-refl +K -D. + +-type : kreduce-refl ektype kreduce/type. + +-pi : kreduce-refl (ekpi A B) (kreduce/pi DredB DredA) + <- tpreduce-refl A DredA + <- ({x} {dv} + kreduce-refl (B x) + (DredB x dv : kreduce (B x) (B x))). + +%worlds (ecsig | easig | evvar) (kreduce-refl _ _). +%total A (kreduce-refl A _). + +%% Compatibility of reduce* %% + +reduce*-lam-compat : tpreduce* A A' + -> ({x} variable x -> reduce* (M x) (M' x)) + -> reduce* (elam A M) (elam A' M') -> type. +%mode reduce*-lam-compat +X1 +X2 -X3. + +-refl : reduce*-lam-compat + (tpreduce*/refl : tpreduce* A A) + ([x] [dv:variable x] reduce*/refl : reduce* (M x) (M x)) + (reduce*/trans + reduce*/refl + (reduce/lam ([x] [d] reduce/refl) D)) + <- tpreduce-refl _ D. + +-refl : reduce*-lam-compat + (tpreduce*/trans + (DredA' : tpreduce* A' A'') + (DredA : tpreduce A A') + : tpreduce* A A'') + ([x] [dv:variable x] reduce*/refl : reduce* (M x) (M x)) + (reduce*/trans + DredLam' + (reduce/lam ([x] [d] reduce/refl) DredA)) + <- reduce*-lam-compat DredA' ([x] [dv] reduce*/refl) + (DredLam' : reduce* (elam A' M) (elam A'' M)). + +-trans : reduce*-lam-compat + (Dtpreduce : tpreduce* A A') + ([x] [dv:variable x] + reduce*/trans + (Dred*M' x dv : reduce* (M' x) (M'' x)) + (DredM x dv : reduce (M x) (M' x))) + (reduce*/trans + Dred*Lam + (reduce/lam DredM DredA)) + <- reduce*-lam-compat Dtpreduce Dred*M' + (Dred*Lam : reduce* (elam A M') (elam A' M'')) + <- tpreduce-refl A DredA. + +%worlds (ecsig | easig | evvar | tbind) (reduce*-lam-compat _ _ _). +%total {D1 D2} (reduce*-lam-compat D1 D2 _). + +reduce*-app-compat : reduce* M M' -> reduce* N N' + -> reduce* (eapp M N) (eapp M' N') -> type. +%mode reduce*-app-compat +X1 +X2 -X3. + +-refl : reduce*-app-compat + (reduce*/refl : reduce* M M) + (reduce*/refl : reduce* N N) + reduce*/refl. + +-reflt : reduce*-app-compat + (reduce*/refl : reduce* M M) + (reduce*/trans + (Dred*N' : reduce* N' N'') + (DredN : reduce N N')) + (reduce*/trans + Dred*App' + (reduce/app DredN reduce/refl)) + <- reduce*-app-compat reduce*/refl Dred*N' + (Dred*App' : reduce* (eapp M N') (eapp M N'')). + +-trefl : reduce*-app-compat + (reduce*/trans + (Dred*M' : reduce* M' M'') + (DredM : reduce M M')) + (reduce*/refl : reduce* N N) + (reduce*/trans + Dred*App' + (reduce/app reduce/refl DredM)) + <- reduce*-app-compat Dred*M' reduce*/refl + (Dred*App' : reduce* (eapp M' N) (eapp M'' N)). + +-tt : reduce*-app-compat + (reduce*/trans + (Dred*M : reduce* M' M'') + (DredM : reduce M M')) + (reduce*/trans + (Dred*N : reduce* N' N'') + (DredN : reduce N N')) + (reduce*/trans + Dred*App + (reduce/app DredN DredM)) + <- reduce*-app-compat Dred*M Dred*N + (Dred*App : reduce* (eapp M' N') (eapp M'' N'')). + +%worlds (ecsig | easig | evvar) (reduce*-app-compat _ _ _). +%total {D1 D2} (reduce*-app-compat D1 D2 _). + +tpreduce-refl : {A} tpreduce A A -> type. +%mode tpreduce-refl +X1 -X2. + +-const : tpreduce-refl (eaconst A) tpreduce/const. + +-app : tpreduce-refl (eaapp A M) (tpreduce/app reduce/refl DredA) + <- tpreduce-refl A (DredA : tpreduce A A). + +-pi : tpreduce-refl (epi A B) (tpreduce/pi DredB DredA) + <- tpreduce-refl A DredA + <- ({x} {dv:variable x} + tpreduce-refl (B x) (DredB x dv)). + +-lam : tpreduce-refl (ealam A B) (tpreduce/lam DredB DredA) + <- tpreduce-refl A DredA + <- ({x} {dv:variable x} + tpreduce-refl (B x) (DredB x dv)). + +%worlds (ecsig | easig | evvar) (tpreduce-refl _ _). +%total D (tpreduce-refl D _). + +tpreduce*-app-compat : tpreduce* M M' -> reduce* N N' + -> tpreduce* (eaapp M N) (eaapp M' N') -> type. +%mode tpreduce*-app-compat +X1 +X2 -X3. + +-refl : tpreduce*-app-compat + (tpreduce*/refl : tpreduce* M M) + (reduce*/refl : reduce* N N) + tpreduce*/refl. + +-reflt : tpreduce*-app-compat + (tpreduce*/refl : tpreduce* M M) + (reduce*/trans + (Dred*N' : reduce* N' N'') + (DredN : reduce N N')) + (tpreduce*/trans + Dred*App' + (tpreduce/app DredN DredM)) + <- tpreduce*-app-compat tpreduce*/refl Dred*N' + (Dred*App' : tpreduce* (eaapp M N') (eaapp M N'')) + <- tpreduce-refl _ DredM. + +-trefl : tpreduce*-app-compat + (tpreduce*/trans + (Dred*M' : tpreduce* M' M'') + (DredM : tpreduce M M')) + (reduce*/refl : reduce* N N) + (tpreduce*/trans + Dred*App' + (tpreduce/app reduce/refl DredM)) + <- tpreduce*-app-compat Dred*M' reduce*/refl + (Dred*App' : tpreduce* (eaapp M' N) (eaapp M'' N)). + +-tt : tpreduce*-app-compat + (tpreduce*/trans + (Dred*M : tpreduce* M' M'') + (DredM : tpreduce M M')) + (reduce*/trans + (Dred*N : reduce* N' N'') + (DredN : reduce N N')) + (tpreduce*/trans + Dred*App + (tpreduce/app DredN DredM)) + <- tpreduce*-app-compat Dred*M Dred*N + (Dred*App : tpreduce* (eaapp M' N') (eaapp M'' N'')). + +%worlds (ecsig | easig | evvar) (tpreduce*-app-compat _ _ _). +%total {D1 D2} (tpreduce*-app-compat D1 D2 _). + +tpreduce*-lam-compat : tpreduce* A A' + -> ({x} variable x -> tpreduce* (M x) (M' x)) + -> tpreduce* (ealam A M) (ealam A' M') -> type. +%mode tpreduce*-lam-compat +X1 +X2 -X3. + +-refl : tpreduce*-lam-compat + (tpreduce*/refl : tpreduce* A A) + ([x] [dv:variable x] tpreduce*/refl : tpreduce* (M x) (M x)) + (tpreduce*/trans + tpreduce*/refl + (tpreduce/lam D' D)) + <- ({x} {d} tpreduce-refl _ (D' x d)) + <- tpreduce-refl _ D. + +-refl : tpreduce*-lam-compat + (tpreduce*/trans + (DredA' : tpreduce* A' A'') + (DredA : tpreduce A A') + : tpreduce* A A'') + ([x] [dv:variable x] tpreduce*/refl : tpreduce* (M x) (M x)) + (tpreduce*/trans + DredLam' + (tpreduce/lam Drefl DredA)) + <- ({x} {d} tpreduce-refl _ (Drefl x d)) + <- tpreduce*-lam-compat DredA' ([x] [dv] tpreduce*/refl) + (DredLam' : tpreduce* (ealam A' M) (ealam A'' M)). + +-trans : tpreduce*-lam-compat + (Dtpreduce : tpreduce* A A') + ([x] [dv:variable x] + tpreduce*/trans + (Dred*M' x dv : tpreduce* (M' x) (M'' x)) + (DredM x dv : tpreduce (M x) (M' x))) + (tpreduce*/trans + Dred*Lam + (tpreduce/lam DredM DredA)) + <- tpreduce*-lam-compat Dtpreduce Dred*M' + (Dred*Lam : tpreduce* (ealam A M') (ealam A' M'')) + <- tpreduce-refl A DredA. + +%worlds (ecsig | easig | evvar) (tpreduce*-lam-compat _ _ _). +%total {D1 D2} (tpreduce*-lam-compat D1 D2 _). + +tpreduce*-pi-compat : tpreduce* A A' + -> ({x} variable x -> tpreduce* (B x) (B' x)) +%% + -> tpreduce* (epi A B) (epi A' B') -> type. +%mode tpreduce*-pi-compat +X1 +X2 -X3. + +-refl : tpreduce*-pi-compat + (tpreduce*/refl : tpreduce* A A) + ([x] [dv:variable x] tpreduce*/refl : tpreduce* (M x) (M x)) + (tpreduce*/trans + tpreduce*/refl + (tpreduce/pi D' D)) + <- ({x} {d} tpreduce-refl _ (D' x d)) + <- tpreduce-refl _ D. + +-refl : tpreduce*-pi-compat + (tpreduce*/trans + (DredA' : tpreduce* A' A'') + (DredA : tpreduce A A') + : tpreduce* A A'') + ([x] [dv:variable x] tpreduce*/refl : tpreduce* (M x) (M x)) + (tpreduce*/trans + DredLam' + (tpreduce/pi Drefl DredA)) + <- ({x} {d} tpreduce-refl _ (Drefl x d)) + <- tpreduce*-pi-compat DredA' ([x] [dv] tpreduce*/refl) + (DredLam' : tpreduce* (epi A' M) (epi A'' M)). + +-trans : tpreduce*-pi-compat + (Dtpreduce : tpreduce* A A') + ([x] [dv:variable x] + tpreduce*/trans + (Dred*M' x dv : tpreduce* (M' x) (M'' x)) + (DredM x dv : tpreduce (M x) (M' x))) + (tpreduce*/trans + Dred*Lam + (tpreduce/pi DredM DredA)) + <- tpreduce*-pi-compat Dtpreduce Dred*M' + (Dred*Lam : tpreduce* (epi A M') (epi A' M'')) + <- tpreduce-refl A DredA. + +%worlds (ecsig | easig | evvar) (tpreduce*-pi-compat _ _ _). +%total {D1 D2} (tpreduce*-pi-compat D1 D2 _). + +kreduce*-pi-compat : tpreduce* A A' + -> ({x} variable x -> kreduce* (B x) (B' x)) +%% + -> kreduce* (ekpi A B) (ekpi A' B') -> type. +%mode kreduce*-pi-compat +X1 +X2 -X3. + +-refl : kreduce*-pi-compat + (tpreduce*/refl : tpreduce* A A) + ([x] [dv:variable x] kreduce*/refl : kreduce* (M x) (M x)) + (kreduce*/trans + kreduce*/refl + (kreduce/pi D' D)) + <- ({x} {d} kreduce-refl _ (D' x d)) + <- tpreduce-refl _ D. + +-refl : kreduce*-pi-compat + (tpreduce*/trans + (DredA' : tpreduce* A' A'') + (DredA : tpreduce A A') + : tpreduce* A A'') + ([x] [dv:variable x] kreduce*/refl : kreduce* (M x) (M x)) + (kreduce*/trans + DredLam' + (kreduce/pi Drefl DredA)) + <- ({x} {d} kreduce-refl _ (Drefl x d)) + <- kreduce*-pi-compat DredA' ([x] [dv] kreduce*/refl) + (DredLam' : kreduce* (ekpi A' M) (ekpi A'' M)). + +-trans : kreduce*-pi-compat + (Dkreduce : tpreduce* A A') + ([x] [dv:variable x] + kreduce*/trans + (Dred*M' x dv : kreduce* (M' x) (M'' x)) + (DredM x dv : kreduce (M x) (M' x))) + (kreduce*/trans + Dred*Lam + (kreduce/pi DredM DredA)) + <- kreduce*-pi-compat Dkreduce Dred*M' + (Dred*Lam : kreduce* (ekpi A M') (ekpi A' M'')) + <- tpreduce-refl A DredA. + +%worlds (ecsig | easig | evvar) (kreduce*-pi-compat _ _ _). +%total {D1 D2} (kreduce*-pi-compat D1 D2 _). + +%% Other notions of transitivity for reduce* %% + +reduce*-trans2 : reduce* M N -> reduce* N O -> reduce* M O -> type. +%mode reduce*-trans2 +X1 +X2 -X3. + +- : reduce*-trans2 reduce*/refl (DreduceN : reduce* N O) + DreduceN. + +- : reduce*-trans2 + (reduce*/trans (Dred*M' : reduce* M' N) (DredM : reduce M M')) + (Dred*N : reduce* N O) + (reduce*/trans Dred*M'O DredM) + <- reduce*-trans2 Dred*M' Dred*N + (Dred*M'O : reduce* M' O). + +%worlds (ecsig | easig | evvar) (reduce*-trans2 _ _ _). +%total D (reduce*-trans2 D _ _). + + +%%%% Explicit Contexts %%%% + +convert-sub-e : {T} simp A T + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G N Gx + -> ({x} {ex} vtrans ex x + -> converte (G x) (M x) (B x) (EM ex)) + -> converte G1 N A EN + -> sub ([x] M x) N Mx + -> tpsub ([x] B x) N Bx +%% + -> converte Gx Mx Bx EO + -> reduce* (EM EN) EO -> type. +%mode convert-sub-e +T +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 -X8 -X9. + +aconvert-rrsub-e : {T} simp A T + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G N Gx + -> ({x} {ex} vtrans ex x + -> aconverte (G x) (R x) (B x) (EM ex)) + -> converte G1 N A EN + -> rrsub ([x] R x) N Rx + -> tpsub ([x] B x) N Bx +%% + -> aconverte Gx Rx Bx EO + -> reduce* (EM EN) EO -> type. +%mode aconvert-rrsub-e +T +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 -X8 -X9. + +aconvert-rmsub-e : {T} simp A T + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G N Gx + -> ({x} {ex} vtrans ex x + -> aconverte (G x) (R x) (B x) (EM ex)) + -> converte G1 N A EN + -> rmsub ([x] R x) N Mx + -> tpsub ([x] B x) N Bx +%% + -> converte Gx Mx Bx EO + -> reduce* (EM EN) EO -> type. +%mode aconvert-rmsub-e +T +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 -X8 -X9. + +tpconvert-sub-e : {T} simp A T + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G N Gx + -> ({x} {ex} vtrans ex x + -> tpconverte (G x) (B x) (K x) (EB ex)) + -> converte G1 N A EN + -> tpsub ([x] B x) N Bx + -> ksub ([x] K x) N Kx +%% + -> tpconverte Gx Bx Kx EC + -> tpreduce* (EB EN) EC -> type. +%mode tpconvert-sub-e +T +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 -X8 -X9. + +atpconvert-sub-e : {T} simp A T + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G N Gx + -> ({x} {ex} vtrans ex x + -> atpconverte (G x) (B x) (K x) (EB ex)) + -> converte G1 N A EN + -> atpsub ([x] B x) N Bx + -> ksub ([x] K x) N Kx +%% + -> atpconverte Gx Bx Kx EC + -> tpreduce* (EB EN) EC -> type. +%mode atpconvert-sub-e +T +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 -X8 -X9. + +kconvert-sub-e : {T} simp A T + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G N Gx + -> ({x} {ex} vtrans ex x + -> kconverte (G x) (K x) (EK ex)) + -> converte G1 N A EN + -> ksub ([x] K x) N Kx +%% + -> kconverte Gx Kx EKx + -> kreduce* (EK EN) EKx -> type. +%mode kconvert-sub-e +T +X0 +X1 +X2 +X3 +X4 +X5 +X6 -X7 -X8. + +-rr : convert-sub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G N Gx) + ([x] [ex] [xt] + converte/at + (DconvertR x ex xt + : aconverte (G x) (R x) (base (P x)) (EM ex))) + (DconvertN : converte G1 N A EN) + (sub/rr (DsubR : rrsub ([x] R x) N Rx)) + (tpsub/base (DsubP : atpsub ([x] P x) N Px)) +%% + (converte/at DconvertRx) + DreduceEMx +%% + <- aconvert-rrsub-e _ Dsimp Dord Dappend Dcsub + DconvertR DconvertN DsubR (tpsub/base DsubP) + (DconvertRx : aconverte Gx Rx (base Px) EMx) + (DreduceEMx : reduce* (EM EN) EMx). + +-rm : convert-sub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G N Gx) + ([x] [ex] [xt] + converte/at + (DconvertR x ex xt + : aconverte (G x) (R x) (base (P x)) (EM ex))) + (DconvertN : converte G1 N A EN) + (sub/rm (DsubR : rmsub ([x] R x) N (at Rx))) + (tpsub/base (DsubP : atpsub ([x] P x) N Px)) +%% + DconvertLRx + DreduceEMx +%% + <- aconvert-rmsub-e _ Dsimp Dord Dappend Dcsub + DconvertR DconvertN DsubR (tpsub/base DsubP) + (DconvertLRx : converte Gx (at Rx) (base Px) EMx) + (DreduceEMx : reduce* (EM EN) EMx). + +-lam : convert-sub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G N Gx) + ([x] [ex] [xt] + converte/lam + ([y] [ey] [yt] + DconvertM x ex xt y ey yt + : converte (cons (G x) y (B x)) (M x y) (C x y) (EM ex ey)) + (DconvertB x ex xt : tpconverte (G x) (B x) ktype (EB ex))) + (DconvertN : converte G1 N A EN) + (sub/lam + ([y] DsubMx y : sub ([x] M x y) N (Mx y))) + (tpsub/pi + ([y] DsubC y : tpsub ([x] C x y) N (Cx y)) + (DsubB : tpsub ([x] B x) N Bx)) +%% + (converte/lam DconvertMx DconvertBx) + Dred*lam +%% + <- tpconvert-sub-e _ Dsimp Dord Dappend Dcsub + DconvertB DconvertN DsubB ksub/type + (DconvertBx : tpconverte Gx Bx ktype EBx) + (DreduceEBx : tpreduce* (EB EN) EBx) + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- ({y} {e} {ey} {yt} {dv} + vtrans-variable yt dv -> + convert-sub-e _ Dsimp + ([x] [d] Dord' x d y e) + ([x] append/cons (Dappend x)) + (csub/cons DsubB Dcsub) + ([x] [ex] [xt] DconvertM x ex xt y ey yt) + DconvertN + (DsubMx y) (DsubC y) + (DconvertMx y ey yt + : converte (cons Gx y Bx) (Mx y) (Cx y) (EMx ey)) + (DreduceEMx ey dv : reduce* (EM EN ey) (EMx ey))) + %% + <- reduce*-lam-compat DreduceEBx DreduceEMx + (Dred*lam : reduce* (elam (EB EN) (EM EN)) (elam EBx EMx)). + +%% + +-const : aconvert-rrsub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + aconverte/const + (Dtpconvert x ex xt + : tpconverte (G x) B ktype (EB ex)) + (DofB x : kof B ktype) + (Dcof : cof C B)) + (DconvertN : converte G1 N A EN) + _ + (DsubBx : tpsub ([x] B) N Bx) +%% + (aconverte/const DconvertBx DofBx Dcof') + (reduce*/trans reduce*/refl reduce/refl) +%% + <- tpsub-absent B N (DsubB : tpsub ([_] B) N B) + <- tpconvert-sub-e _ Dsimp Dord Dappend Dcsub Dtpconvert DconvertN + DsubB ksub/type + (DconvertB : tpconverte Gx B ktype EBx) + _ + <- tpsub-fun DsubB DsubBx + (DeqBBx : tp-eq B Bx) + <- kof-resp DeqBBx kind-eq/i (DofB aca) + (DofBx : kof Bx ktype) + <- cof-resp DeqBBx Dcof (Dcof' : cof C Bx) + %% + <- tpconverte-resp DconvertB ctx-eq/i DeqBBx kind-eq/i etp-eq/i + (DconvertBx : tpconverte Gx Bx ktype EBx). + +-var : aconvert-rrsub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + aconverte/var + (Dvtrans x ex xt : vtrans (EY ex) Y) + (DconvertB x ex xt : tpconverte (G x) (B x) ktype (EB ex)) + (Dlook x : lookup (G x) Y (B x))) + (DconvertN : converte G1 N A EN) + rrsub/closed + (DsubB : tpsub ([x] B x) N Bx) +%% + (aconverte/var Dvtrans' DconvertBx DlookGx) + Dreduce +%% + <- tpconvert-sub-e _ Dsimp Dord Dappend Dcsub DconvertB DconvertN + DsubB ksub/type + (DconvertBx : tpconverte Gx Bx ktype EBx) + (DreduceEBx : tpreduce* (EB EN) EBx) + <- csub-lookup Dcsub Dlook + (DsubB' : tpsub ([x] B x) N Bx') + (DlookGx' : lookup Gx Y Bx') + <- tpsub-fun DsubB' DsubB + (DeqB' : tp-eq Bx' Bx) + <- lookup-compat ctx-eq/i atm-eq/i DeqB' DlookGx' + (DlookGx : lookup Gx Y Bx) + %% + <- strengthen-vtrans Dvtrans + ([ex] Deq ex : etm-eq (EY ex) EY') + (Dvtrans' : vtrans EY' Y) + <- ({ex} + etm-eq-sym (Deq ex) + (Deq' ex : etm-eq EY' (EY ex))) + <- vtrans-variable Dvtrans' (Dvariable : variable EY') + <- reduce*-resp (reduce*/trans reduce*/refl reduce/refl) + (Deq' EN) etm-eq/i + (Dreduce : reduce* (EY EN) EY'). + + +-vari : aconvert-rrsub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + aconverte/vari + (Dvtrans x ex xt : vtrans (EY ex) Y) + (DconvertB x ex xt + : tpconverte (G x) (B x) ktype (EB ex)) + (DofB x : kof (B x) ktype) + (Dvof x : vof Y (B x))) + (DconvertN : converte G1 N A EN) + rrsub/closed + (DsubB : tpsub ([x] B x) N Bx) +%% + (aconverte/vari Dvtrans' DconvertBx DofBx Dvof'') + Dreduce +%% + %% Strengthen x out of B + <- vof-noassm Dvof + ([x] DeqB x : tp-eq (B x) B') + <- tpsub-compat DeqB tm-eq/i tp-eq/i DsubB + (DsubB'x : tpsub ([_] B') N Bx) + <- tpsub-absent B' N + (DsubB' : tpsub ([_] B') N B') + <- tpsub-fun DsubB' DsubB'x + (DeqB'Bx : tp-eq B' Bx) + %% DconvertBx + <- tpconvert-sub-e _ Dsimp Dord Dappend Dcsub DconvertB + DconvertN DsubB ksub/type + (DconvertBx : tpconverte Gx Bx ktype EBx) + _ + %% kof Bx ktype + <- kof-resp (DeqB aca) kind-eq/i (DofB aca) + (DofB' : kof B' ktype) + <- kof-resp DeqB'Bx kind-eq/i DofB' + (DofBx : kof Bx ktype) + %% vof Y Bx + <- vof-resp (Dvof aca) atm-eq/i (DeqB aca) + (Dvof' : vof Y B') + <- vof-resp Dvof' atm-eq/i DeqB'Bx + (Dvof'' : vof Y Bx) + %% variable EY' and reduce* (EY EN) EY' + <- strengthen-vtrans Dvtrans + ([ex] DeqEY ex : etm-eq (EY ex) EY') + (Dvtrans' : vtrans EY' Y) + <- vtrans-variable Dvtrans' + (Dvar : variable EY') + <- etm-eq-sym (DeqEY EN) + (DeqEY' : etm-eq EY' (EY EN)) + <- reduce*-resp (reduce*/trans reduce*/refl reduce/refl) + DeqEY' etm-eq/i + (Dreduce : reduce* (EY EN) EY'). + +-app : aconvert-rrsub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + aconverte/app + (DsubC x : tpsub ([y] C x y) (M x) (Cy x)) + (DconvertM x ex xt : converte (G x) (M x) (B x) (EM ex)) + (DconvertR x ex xt + : aconverte (G x) (R x) (pi (B x) ([y] C x y)) (EL ex)) + : aconverte (G x) + (app (R x) (M x)) (Cy x) (eapp (EL ex) (EM ex))) + (DconvertN : converte G1 N A EN) + (rrsub/app + (DsubM : sub ([x] M x) N Mx) + (DsubR : rrsub ([x] R x) N Rx)) + (DsubCy : tpsub ([x] Cy x) N Cyx) +%% + (aconverte/app DsubCx'' DconvertMx DconvertRx) + DreduceApp +%% + <- ({x} {ex} {xt} + aconverte-reg-il (DconvertR x ex xt) + (DofR x : at-ofe (G x) (R x) (pi (B x) ([y] C x y)))) + <- ({x} {d} + atofe-reg (Dord x d) (DofR x) + (kofe/pi + ([y] DofC x y : kofe (cons (G x) y (B x)) (C x y) ktype) + (DofB x : kofe (G x) (B x) ktype))) + <- converte-reg-il DconvertN + (DofN : ofe G1 N A) + %% + <- can-tpsub-e Dappend Dord DofB DofN + (DsubB : tpsub ([x] B x) N Bx) + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- ({y} {e} + can-tpsub-e + ([x] append/cons (Dappend x)) + ([x] [d] Dord' x d y e) + ([x] DofC x y) DofN + (DsubC' y : tpsub ([x] C x y) N (Cx y))) + <- aconvert-rrsub-e _ Dsimp Dord Dappend Dcsub DconvertR DconvertN + DsubR (tpsub/pi DsubC' DsubB) + (DconvertRx : aconverte Gx Rx (pi Bx ([y] Cx y)) EO) + (DreduceEOx : reduce* (EL EN) EO) + <- convert-sub-e _ Dsimp Dord Dappend Dcsub DconvertM DconvertN + DsubM DsubB + (DconvertMx : converte Gx Mx Bx EMx) + (DreduceEMx : reduce* (EM EN) EMx) + %% + <- ({x} {ex} {xt} + converte-reg-il (DconvertM x ex xt) + (DofM x : ofe (G x) (M x) (B x))) + <- tpsub-permute-e Dord Dappend DofN DofM DofC + DsubM DsubC DsubC' + (DsubCy' : tpsub ([x] Cy x) N Cxy) + (DsubCx' : tpsub ([y] Cx y) Mx Cxy) + <- tpsub-fun DsubCy' DsubCy + (DeqCxyCyx : tp-eq Cxy Cyx) + <- tpsub-compat ([y] tp-eq/i) tm-eq/i DeqCxyCyx DsubCx' + (DsubCx'' : tpsub ([y] Cx y) Mx Cyx) + %% + <- reduce*-app-compat DreduceEOx DreduceEMx + (DreduceApp : reduce* (eapp (EL EN) (EM EN)) (eapp EO EMx)). + +-appclo : aconvert-rrsub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + aconverte/app + (DsubC x : tpsub ([y] C x y) M (Cy x)) + (DconvertM x ex xt : converte (G x) M (B x) (EM ex)) + (DconvertR x ex xt + : aconverte (G x) R (pi (B x) ([y] C x y)) (EL ex)) + : aconverte (G x) (app R M) (Cy x) (eapp (EL ex) (EM ex))) + (DconvertN : converte G1 N A EN) + rrsub/closed + (DsubCy : tpsub ([x] Cy x) N Cyx) +%% + (aconverte/app DsubCx'' DconvertM' DconvertR') + Dred*App +%% + <- ({x} {ex} {xt} + aconverte-reg-il (DconvertR x ex xt) + (DofR x : at-ofe (G x) R (pi (B x) ([y] C x y)))) + <- ({x} {d} + atofe-reg (Dord x d) (DofR x) + (kofe/pi + ([y] DofC x y : kofe (cons (G x) y (B x)) (C x y) ktype) + (DofB x : kofe (G x) (B x) ktype))) + <- converte-reg-il DconvertN + (DofN : ofe G1 N A) + <- can-tpsub-e Dappend Dord DofB DofN + (DsubB : tpsub ([x] B x) N Bx) + <- sub-absent M N (DsubM : sub ([_] M) N M) + <- convert-sub-e _ Dsimp Dord Dappend Dcsub DconvertM DconvertN + DsubM DsubB + (DconvertM' : converte Gx M Bx EMx) + (DreduceEMx : reduce* (EM EN) EMx) + %% + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- ({y} {e} + can-tpsub-e + ([x] append/cons (Dappend x)) + ([x] [d] Dord' x d y e) + ([x] DofC x y) DofN + (DsubC' y : tpsub ([x] C x y) N (Cx y))) + <- aconvert-rrsub-e _ Dsimp Dord Dappend Dcsub DconvertR DconvertN + rrsub/closed (tpsub/pi DsubC' DsubB) + (DconvertR' : aconverte Gx R (pi Bx ([y] Cx y)) ELx) + (DreduceELx : reduce* (EL EN) ELx) + %% + <- ({x} {ex} {xt} + converte-reg-il (DconvertM x ex xt) + (DofM x : ofe (G x) M (B x))) + <- tpsub-permute-e Dord Dappend DofN DofM DofC DsubM + DsubC DsubC' + (DsubCy' : tpsub ([x] Cy x) N Cxy) + (DsubCx' : tpsub ([y] Cx y) M Cxy) + <- tpsub-fun DsubCy' DsubCy + (DeqCxyCyx : tp-eq Cxy Cyx) + <- tpsub-compat ([_]tp-eq/i) tm-eq/i DeqCxyCyx DsubCx' + (DsubCx'' : tpsub ([y] Cx y) M Cyx) + %% + <- reduce*-app-compat DreduceELx DreduceEMx + (Dred*App : reduce* (eapp (EL EN) (EM EN)) (eapp ELx EMx)). + +%%%% + +-var : aconvert-rmsub-e T + (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G N Gx) + ([x] [ex] [xt:vtrans ex x] + aconverte/var + xt + (DconvertA' x ex xt + : tpconverte (G x) (A' x) ktype (EA' ex)) + (Dlook' x : lookup (G x) x (A' x))) + (DconvertN : converte G1 N A EN) + (rmsub/var : rmsub ([x] x) N N) + (DsubA' : tpsub ([x] A' x) N Ax) +%% + DconvertN'' + reduce*/refl +%% + <- ({x} append-lookup (Dappend x) (Dlook x : lookup (G x) x A)) + <- ({x} {d} + lookup-fun (Dord x d) (Dlook' x) (Dlook x) + (DeqA'A x : tp-eq (A' x) A)) + <- tpsub-absent _ _ (DsubA : tpsub ([_] A) N A) + <- tpsub-compat DeqA'A tm-eq/i tp-eq/i DsubA' + (DsubA'' : tpsub ([x] A) N Ax) + <- tpsub-fun DsubA DsubA'' + (DeqAAx : tp-eq A Ax) + <- converte-resp DconvertN ctx-eq/i tm-eq/i DeqAAx etm-eq/i + (DconvertN' : converte G1 N Ax EN) + %% weaken G1 to Gx + <- ({x} {d} + ordered-append (Dappend x) (Dord x d) + (DordG1xA x d : ordered (cons G1 x A))) + <- ({x} {d} + ordered-cons (DordG1xA x d) + (DordG1 x d : ordered G1)) + <- csub-append Dcsub Dappend + (Dappend' : append G1 G2x Gx) + <- csub-ordered Dord Dcsub + (Dord' : ordered Gx) + <- weaken-converte' Dappend' DconvertN' + (DconvertN'' : converte Gx N Ax EN). + +-app : aconvert-rmsub-e T + (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G N Gx) + ([x] [ex] [xt:vtrans ex x] + aconverte/app + (DsubCy x : tpsub ([y] C x y) (M x) (Cy x)) + (DconvertM x ex xt + : converte (G x) (M x) (B x) (EM ex)) + (DconvertR x ex xt + : aconverte (G x) (R x) (pi (B x) ([y] C x y)) (ER ex))) + (DconvertN : converte G1 N A EN) + (rmsub/app + (DsubL : sub ([y] L y) Mx Ly) + (DsubM : sub ([x] M x) N Mx) + (DsubR : rmsub ([x] R x) N (lam ([y] L y)))) + (DsubCyx : tpsub ([x] Cy x) N Cyx) +%% + DconvertLy + DredApp +%% + <- converte-reg-il DconvertN (DofN : ofe G1 N A) + <- ({x} {ex} {xt} + aconverte-reg-il (DconvertR x ex xt) + (DofR x : at-ofe (G x) (R x) (pi (B x) ([y] C x y)))) + <- ({x} {d} + atofe-reg (Dord x d) (DofR x) + (kofe/pi + ([y] DofC x y : kofe (cons (G x) y (B x)) (C x y) ktype) + (DofB x : kofe (G x) (B x) ktype))) + <- can-tpsub-e Dappend Dord DofB DofN + (DsubB : tpsub ([x] B x) N Bx) + <- ({x} {d} + extend-ordered _ (Dord x d) _ + ([y] [e] Dord' x d y e: ordered (cons (G x) y (B x)))) + <- ({y} {e} + can-tpsub-e + ([x] append/cons (Dappend x)) + ([x] [d] Dord' x d y e) + ([x] DofC x y) DofN + (DsubCx y : tpsub ([x] C x y) N (Cx y))) + <- aconvert-rmsub-e _ Dsimp Dord Dappend Dcsub DconvertR DconvertN + DsubR (tpsub/pi DsubCx DsubB) + (converte/lam + ([y] [ey] [yt:vtrans ey y] + DconvertL y ey yt + : converte (cons Gx y Bx) (L y) (Cx y) (ELx ey)) + (DconvertBx : tpconverte Gx Bx ktype EBx)) + (DreduceERx : reduce* (ER EN) (elam EBx ([ey] ELx ey))) + %% + <- convert-sub-e _ Dsimp Dord Dappend Dcsub DconvertM DconvertN + DsubM DsubB + (DconvertMx : converte Gx Mx Bx EMx) + (DreduceEMx : reduce* (EM EN) EMx) + %% + <- ({x} {ex} {xt} + converte-reg-il (DconvertM x ex xt) + (DofM x : ofe (G x) (M x) (B x))) + <- tpsub-permute-e Dord Dappend DofN DofM DofC + DsubM DsubCy DsubCx + (DsubCyx' : tpsub ([x] Cy x) N Cxy) + (DsubCxy' : tpsub ([y] Cx y) Mx Cxy) + <- tpsub-fun DsubCyx' DsubCyx + (DeqCxyCyx : tp-eq Cxy Cyx) + <- tpsub-compat ([_]tp-eq/i) tm-eq/i DeqCxyCyx DsubCxy' + (DsubCxy : tpsub ([y] Cx y) Mx Cyx) + %% + <- csub-ordered Dord Dcsub + (Dordx : ordered Gx) + <- extend-ordered _ Dordx _ + ([y] [e] Dordx' y e : ordered (cons Gx y Bx)) + %% Convince twelf that S < T + <- ({x} can-simp (B x) (DsimpB x : simp (B x) S)) + <- ({x} {y} can-simp (C x y) (DsimpC x y : simp (C x y) U)) + <- ({x} can-simpctx _ (Dsimpctx x : simpctx (G x) (Gs x))) + <- ({x} + at-ofe-simp (Dsimpctx x) + (simp/pi ([y] DsimpC x y) (DsimpB x)) (DofR x) + (DofRsimp x : at-ofes (Gs x) (R x) (arrow S U))) + <- tpsub-preserves-simp DsubB DsimpB + (DsimpBx : simp Bx S) + <- rmsub-headvar DsubR (Dheadvar : headvar ([x] R x)) + <- ({x} {d} ordered-simpctx (Dsimpctx x) (Dord x d) (Dsord x d)) + <- ({x} append-lookup (Dappend x) (Dlook x : lookup (G x) x A)) + <- ({x} + lookup-simp (Dsimpctx x) Dsimp (Dlook x) + (Dslook x : slookup (Gs x) x T)) + <- headvar-stp-size Dsord Dslook DofRsimp Dheadvar + (Dleq : stp-leq (arrow S U) T) + <- employ-stp-leq (arrow S U) T Dleq + %% + <- convert-sub-e S DsimpBx Dordx' ([_]append/nil) csub/base + DconvertL DconvertMx DsubL DsubCxy + (DconvertLy : converte Gx Ly Cyx ELy) + (DreduceELy : reduce* (ELx EMx) ELy) + %% + <- reduce*-app-compat DreduceERx DreduceEMx + (DredApp1 : reduce* + (eapp (ER EN) (EM EN)) + (eapp (elam EBx ELx) EMx)) + <- reduce*-trans2 DredApp1 (reduce*/trans DreduceELy reduce/beta) + (DredApp : reduce* (eapp (ER EN) (EM EN)) ELy). + +%%%% + +-base : tpconvert-sub-e T Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + tpconverte/base + (Datpconverte x ex xt + : atpconverte (G x) (P x) ktype (EP ex))) + (DconvertN : converte G1 N A EN) + (tpsub/base (DsubP : atpsub ([x] P x) N Px)) + ksub/type +%% + (tpconverte/base DconvertPx) + DreduceEPx +%% + <- atpconvert-sub-e T Dsimp Dord Dappend Dcsub Datpconverte + DconvertN DsubP ksub/type + DconvertPx + DreduceEPx. + +-pi : tpconvert-sub-e T Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + tpconverte/pi + ([y] [ey] [yt:vtrans ey y] + DconvertC x ex xt y ey yt + : tpconverte (cons (G x) y (B x)) + (C x y) ktype (EC ex ey)) + (DconvertB x ex xt + : tpconverte (G x) (B x) ktype (EB ex))) + (DconvertN : converte G1 N A EN) + (tpsub/pi + ([y] DsubC y : tpsub ([x] C x y) N (Cx y)) + (DsubB : tpsub ([x] B x) N Bx)) + ksub/type +%% + (tpconverte/pi DconvertCx DconvertBx) + DreducePi +%% + <- ({x} {d} + extend-ordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- ({y} {e} {ey} {yt} {dv:variable ey} vtrans-variable yt dv + -> tpconvert-sub-e T Dsimp ([x] [d] Dord' x d y e) + ([x] append/cons (Dappend x)) (csub/cons DsubB Dcsub) + ([x] [ex] [xt] DconvertC x ex xt y ey yt) DconvertN + (DsubC y) ksub/type + (DconvertCx y ey yt + : tpconverte (cons Gx y Bx) (Cx y) ktype (ECx ey)) + (DreduceECx ey dv : tpreduce* (EC EN ey) (ECx ey))) + <- tpconvert-sub-e T Dsimp Dord Dappend Dcsub DconvertB + DconvertN DsubB ksub/type + (DconvertBx : tpconverte Gx Bx ktype EBx) + (DreduceEBx : tpreduce* (EB EN) EBx) + %% + <- tpreduce*-pi-compat DreduceEBx DreduceECx + DreducePi. + +-lam : tpconvert-sub-e T Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + tpconverte/lam + ([y] [ey] [yt:vtrans ey y] + DconvertC x ex xt y ey yt + : tpconverte (cons (G x) y (B x)) + (C x y) (K x y) (EC ex ey)) + (DconvertB x ex xt + : tpconverte (G x) (B x) ktype (EB ex))) + (DconvertN : converte G1 N A EN) + (tpsub/lam + ([y] DsubC y : tpsub ([x] C x y) N (Cx y))) + (ksub/pi + ([y] DsubK y : ksub ([x] K x y) N (Kx y)) + (DsubB : tpsub ([x] B x) N Bx)) +%% + (tpconverte/lam DconvertCx DconvertBx) + DredLam +%% + <- ({x} {d} + extend-ordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- ({y} {e} {ey} {yt} {dv:variable ey} vtrans-variable yt dv + -> tpconvert-sub-e T Dsimp ([x] [d] Dord' x d y e) + ([x] append/cons (Dappend x)) (csub/cons DsubB Dcsub) + ([x] [ex] [xt] DconvertC x ex xt y ey yt) DconvertN + (DsubC y) (DsubK y) + (DconvertCx y ey yt + : tpconverte (cons Gx y Bx) (Cx y) (Kx y) (ECx ey)) + (DreduceECx ey dv : tpreduce* (EC EN ey) (ECx ey))) + <- tpconvert-sub-e T Dsimp Dord Dappend Dcsub DconvertB + DconvertN DsubB ksub/type + (DconvertBx : tpconverte Gx Bx ktype EBx) + (DreduceEBx : tpreduce* (EB EN) EBx) + %% + <- tpreduce*-lam-compat DreduceEBx DreduceECx + DredLam. + +-const : atpconvert-sub-e T Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + atpconverte/const + (Dkconvert x ex xt + : kconverte (G x) K (EK ex)) + (DofK x : wfkind K) + (Dcof : ckof C K)) + (DconvertN : converte G1 N A EN) + _ + (DsubKx : ksub ([x] K) N Kx) +%% + (atpconverte/const DconvertKx DofKx Dcofx) + tpreduce*/refl +%% + <- ksub-absent K N (DsubK : ksub ([_] K) N K) + <- kconvert-sub-e _ Dsimp Dord Dappend Dcsub Dkconvert DconvertN + DsubK + (DconvertK : kconverte Gx K EKx) + _ + %% + <- ksub-fun DsubK DsubKx + (DeqKKx : kind-eq K Kx) + <- kconverte-resp DconvertK ctx-eq/i DeqKKx ekind-eq/i + (DconvertKx : kconverte Gx Kx EKx) + <- wfkind-resp DeqKKx (DofK aca) (DofKx : wfkind Kx) + <- ckof-resp DeqKKx Dcof (Dcofx : ckof C Kx). + +%% + +-app : atpconvert-sub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + atpconverte/app + (DsubC x : ksub ([y] C x y) (M x) (Cy x)) + (DconvertM x ex xt : converte (G x) (M x) (B x) (EM ex)) + (DconvertR x ex xt + : atpconverte (G x) (R x) (kpi (B x) ([y] C x y)) (EL ex)) + : atpconverte (G x) + (aapp (R x) (M x)) (Cy x) (eaapp (EL ex) (EM ex))) + (DconvertN : converte G1 N A EN) + (atpsub/app + (DsubM : sub ([x] M x) N Mx) + (DsubR : atpsub ([x] R x) N Rx)) + (DsubCy : ksub ([x] Cy x) N Cyx) +%% + (atpconverte/app DsubCx'' DconvertMx DconvertRx) + DreduceApp +%% + <- ({x} {ex} {xt} + atpconverte-reg-il (DconvertR x ex xt) + (DofR x : at-kofe (G x) (R x) (kpi (B x) ([y] C x y)))) + <- ({x} {d} + atkofe-reg (Dord x d) (DofR x) + (wfkinde/pi + ([y] DofC x y : wfkinde (cons (G x) y (B x)) (C x y)) + (DofB x : kofe (G x) (B x) ktype))) + <- converte-reg-il DconvertN + (DofN : ofe G1 N A) + %% + <- can-tpsub-e Dappend Dord DofB DofN + (DsubB : tpsub ([x] B x) N Bx) + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- ({y} {e} + can-ksub-e + ([x] append/cons (Dappend x)) + ([x] [d] Dord' x d y e) + ([x] DofC x y) DofN + (DsubC' y : ksub ([x] C x y) N (Cx y))) + <- atpconvert-sub-e _ Dsimp Dord Dappend Dcsub DconvertR DconvertN + DsubR (ksub/pi DsubC' DsubB) + (DconvertRx : atpconverte Gx Rx (kpi Bx ([y] Cx y)) EO) + (DreduceEOx : tpreduce* (EL EN) EO) + <- convert-sub-e _ Dsimp Dord Dappend Dcsub DconvertM DconvertN + DsubM DsubB + (DconvertMx : converte Gx Mx Bx EMx) + (DreduceEMx : reduce* (EM EN) EMx) + <- ({x} {ex} {xt} + converte-reg-il (DconvertM x ex xt) + (DofM x : ofe (G x) (M x) (B x))) + <- ksub-permute-e Dord Dappend DofN DofM DofC + DsubM DsubC DsubC' + (DsubCy' : ksub ([x] Cy x) N Cxy) + (DsubCx' : ksub ([y] Cx y) Mx Cxy) + <- ksub-fun DsubCy' DsubCy + (DeqCxyCyx : kind-eq Cxy Cyx) + <- ksub-compat ([y] kind-eq/i) tm-eq/i DeqCxyCyx DsubCx' + (DsubCx'' : ksub ([y] Cx y) Mx Cyx) + %% + <- tpreduce*-app-compat DreduceEOx DreduceEMx + (DreduceApp + : tpreduce* (eaapp (EL EN) (EM EN)) (eaapp EO EMx)). + +-appclo : atpconvert-sub-e _ Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + atpconverte/app + (DsubC x : ksub ([y] C x y) M (Cy x)) + (DconvertM x ex xt : converte (G x) M (B x) (EM ex)) + (DconvertR x ex xt + : atpconverte (G x) R (kpi (B x) ([y] C x y)) (EL ex)) + : atpconverte (G x) (aapp R M) (Cy x) (eaapp (EL ex) (EM ex))) + (DconvertN : converte G1 N A EN) + atpsub/closed + (DsubCy : ksub ([x] Cy x) N Cyx) +%% + (atpconverte/app DsubCx'' DconvertM' DconvertR') + DredApp +%% + <- ({x} {ex} {xt} + atpconverte-reg-il (DconvertR x ex xt) + (DofR x : at-kofe (G x) R (kpi (B x) ([y] C x y)))) + <- ({x} {d} + atkofe-reg (Dord x d) (DofR x) + (wfkinde/pi + ([y] DofC x y : wfkinde (cons (G x) y (B x)) (C x y)) + (DofB x : kofe (G x) (B x) ktype))) + <- converte-reg-il DconvertN + (DofN : ofe G1 N A) + <- can-tpsub-e Dappend Dord DofB DofN + (DsubB : tpsub ([x] B x) N Bx) + <- sub-absent M N (DsubM : sub ([_] M) N M) + <- convert-sub-e _ Dsimp Dord Dappend Dcsub DconvertM DconvertN + DsubM DsubB + (DconvertM' : converte Gx M Bx EMx) + (DreduceEMx : reduce* (EM EN) EMx) + %% + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- ({y} {e} + can-ksub-e + ([x] append/cons (Dappend x)) + ([x] [d] Dord' x d y e) + ([x] DofC x y) DofN + (DsubC' y : ksub ([x] C x y) N (Cx y))) + <- atpconvert-sub-e _ Dsimp Dord Dappend Dcsub DconvertR DconvertN + atpsub/closed (ksub/pi DsubC' DsubB) + (DconvertR' : atpconverte Gx R (kpi Bx ([y] Cx y)) ELx) + (DreduceELx : tpreduce* (EL EN) ELx) + %% + <- ({x} {ex} {xt} + converte-reg-il (DconvertM x ex xt) + (DofM x : ofe (G x) M (B x))) + <- ksub-permute-e Dord Dappend DofN DofM DofC DsubM + DsubC DsubC' + (DsubCy' : ksub ([x] Cy x) N Cxy) + (DsubCx' : ksub ([y] Cx y) M Cxy) + <- ksub-fun DsubCy' DsubCy + (DeqCxyCyx : kind-eq Cxy Cyx) + <- ksub-compat ([_] kind-eq/i) tm-eq/i DeqCxyCyx DsubCx' + (DsubCx'' : ksub ([y] Cx y) M Cyx) + %% + <- tpreduce*-app-compat DreduceELx DreduceEMx + DredApp. + +%%%% + +-type : kconvert-sub-e _ _ _ _ _ ([x] [ex] [xt] kconverte/type) _ + ksub/type + kconverte/type + kreduce*/refl. + +-pi : kconvert-sub-e T Dsimp + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) N Gx) + ([x] [ex] [xt:vtrans ex x] + kconverte/pi + ([y] [ey] [yt:vtrans ey y] + DconvertC x ex xt y ey yt + : kconverte (cons (G x) y (B x)) (C x y) (EC ex ey)) + (DconvertB x ex xt + : tpconverte (G x) (B x) ktype (EB ex))) + (DconvertN : converte G1 N A EN) + (ksub/pi + ([y] DsubC y : ksub ([x] C x y) N (Cx y)) + (DsubB : tpsub ([x] B x) N Bx)) +%% + (kconverte/pi DconvertCx DconvertBx) + DredPi +%% + <- ({x} {d} + extend-ordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- ({y} {e} {ey} {yt} {dv:variable ey} vtrans-variable yt dv + -> kconvert-sub-e T Dsimp ([x] [d] Dord' x d y e) + ([x] append/cons (Dappend x)) (csub/cons DsubB Dcsub) + ([x] [ex] [xt] DconvertC x ex xt y ey yt) DconvertN + (DsubC y) + (DconvertCx y ey yt + : kconverte (cons Gx y Bx) (Cx y) (ECx ey)) + (DreduceECx ey dv : kreduce* (EC EN ey) (ECx ey))) + <- tpconvert-sub-e T Dsimp Dord Dappend Dcsub DconvertB + DconvertN DsubB ksub/type + (DconvertBx : tpconverte Gx Bx ktype EBx) + (DreduceEBx : tpreduce* (EB EN) EBx) + %% + <- kreduce*-pi-compat DreduceEBx DreduceECx + DredPi. + +%worlds (csig-ei | asig-ei | sbind | evvar | tvvar | tvobind) + (convert-sub-e _ _ _ _ _ _ _ _ _ _ _) + (aconvert-rrsub-e _ _ _ _ _ _ _ _ _ _ _) + (aconvert-rmsub-e _ _ _ _ _ _ _ _ _ _ _) + (tpconvert-sub-e _ _ _ _ _ _ _ _ _ _ _) + (atpconvert-sub-e _ _ _ _ _ _ _ _ _ _ _) + (kconvert-sub-e _ _ _ _ _ _ _ _ _ _). +%total {(T1 T2 T3 T4 T5 T6) (D1 D2 D3 D4 D5 D6)} + (convert-sub-e T1 _ _ _ _ D1 _ _ _ _ _) + (aconvert-rrsub-e T2 _ _ _ _ D2 _ _ _ _ _) + (aconvert-rmsub-e T3 _ _ _ _ D3 _ _ _ _ _) + (tpconvert-sub-e T4 _ _ _ _ D4 _ _ _ _ _) + (atpconvert-sub-e T5 _ _ _ _ D5 _ _ _ _ _) + (kconvert-sub-e T6 _ _ _ _ D6 _ _ _ _). + + +%%%%% + +convert-sub : ({x} vof x A + -> {ex} vtrans ex x + -> convert (M x) (B x) (EM ex)) + -> convert N A EN + -> sub ([x] M x) N Mx + -> tpsub ([x] B x) N Bx +%% + -> convert Mx Bx EO + -> reduce* (EM EN) EO -> type. +%mode convert-sub +X1 +X2 +X3 +X4 -X5 -X6. + +- : convert-sub + ([x] [d:vof x A] [ex] [xt] DconvM x d ex xt) + DconvN + DsubM + DsubB +%% + DconvMx + DreduceEMx +%% + <- convert1-to-converte DconvM + ([x] [ex] [xt] + DconveM x ex xt : converte (cons nil x A) (M x) (B x) (EM ex)) + <- convert-to-converte-nil DconvN + (DconveN : converte nil N A EN) + <- can-simp _ (Dsimp : simp A T) + <- extend-ordered _ ordered/nil _ Dord + <- convert-sub-e _ Dsimp Dord ([_] append/nil) csub/base + DconveM DconveN DsubM DsubB + (DconveMx : converte nil Mx Bx EMx) + (DreduceEMx : reduce* (EM EN) EMx) + %% + <- ({x} {d} {ex} {xt} + convert-reg-il (DconvM x d ex xt) + (DofM x d : of (M x) (B x))) + <- convert-reg-il DconvN (DofN : of N A) + <- subst DsubM DsubB DofM DofN + (DofMx : of Mx Bx) + <- can-convert DofMx + (DconvMx' : convert Mx Bx EMx') + <- convert-to-converte-nil DconvMx' + (DconveMx' : converte nil Mx Bx EMx') + <- converte-fun ordered/nil DconveMx' DconveMx + (Deq : etm-eq EMx' EMx) + <- convert-resp DconvMx' tm-eq/i tp-eq/i Deq + (DconvMx : convert Mx Bx EMx). + +%worlds (csig-ei | asig-ei | sbind) (convert-sub _ _ _ _ _ _). +%total {} (convert-sub _ _ _ _ _ _). + + +convert-tpsub : ({x} vof x A + -> {ex} vtrans ex x + -> tpconvert (B x) (K x) (EB ex)) + -> convert N A EN + -> tpsub ([x] B x) N Bx + -> ksub ([x] K x) N Kx +%% + -> tpconvert Bx Kx EC + -> tpreduce* (EB EN) EC -> type. +%mode convert-tpsub +X0 +X1 +X2 +X3 -X4 -X5. + +- : convert-tpsub + ([x] [d:vof x A] [ex] [xt] DconvM x d ex xt) + DconvN + DsubM + DsubB +%% + DconvMx + DreduceEMx +%% + <- tpconvert1-to-tpconverte DconvM + ([x] [ex] [xt] DconveM x ex xt) + <- convert-to-converte-nil DconvN + (DconveN : converte nil N A EN) + <- can-simp _ (Dsimp : simp A T) + <- extend-ordered _ ordered/nil _ Dord + <- tpconvert-sub-e _ Dsimp Dord ([_] append/nil) csub/base + DconveM DconveN DsubM DsubB + DconveMx + DreduceEMx + %% + <- ({x} {d} {ex} {xt} + tpconvert-reg-il (DconvM x d ex xt) + (DofM x d)) + <- convert-reg-il DconvN (DofN : of N A) + <- tpsubst DsubM DsubB DofM DofN + (DofMx : kof Mx Bx) + <- can-tpconvert DofMx + (DconvMx' : tpconvert Mx Bx EMx') + <- tpconvert-to-tpconverte-nil DconvMx' + (DconveMx' : tpconverte nil Mx Bx EMx') + <- tpconverte-fun ordered/nil DconveMx' DconveMx + (Deq : etp-eq EMx' EMx) + <- tpconvert-resp DconvMx' tp-eq/i kind-eq/i Deq + (DconvMx : tpconvert Mx Bx EMx). + +%worlds (csig-ei | asig-ei | sbind) (convert-tpsub _ _ _ _ _ _). +%total {} (convert-tpsub _ _ _ _ _ _). + +convert-ksub : ({x} vof x A + -> {ex} vtrans ex x + -> kconvert (K x) (EK ex)) + -> convert N A EN + -> ksub ([x] K x) N Kx +%% + -> kconvert Kx EKx + -> kreduce* (EK EN) EKx -> type. +%mode convert-ksub +X1 +X2 +X3 -X4 -X5. + +- : convert-ksub DconvM DconvN DsubM DconvMx DredEMx + <- kconvert1-to-kconverte DconvM + ([x] [ex] [xt] DconveM x ex xt) + <- convert-to-converte-nil DconvN + (DconveN : converte nil N A EN) + <- can-simp _ (Dsimp : simp A T) + <- extend-ordered _ ordered/nil _ Dord + <- kconvert-sub-e _ Dsimp Dord ([_] append/nil) csub/base + DconveM DconveN DsubM + DconveMx DredEMx + <- ({x} {d} {ex} {xt} + kconvert-reg-il (DconvM x d ex xt) + (DofM x d)) + <- convert-reg-il DconvN (DofN : of N A) + <- ksubst DsubM DofM DofN DofMx + <- can-kconvert DofMx DconvMx' + <- kconvert-to-kconverte-nil DconvMx' DconveMx' + <- kconverte-fun ordered/nil DconveMx' DconveMx Deq + <- kconvert-resp DconvMx' kind-eq/i Deq + (DconvMx : kconvert Mx EMx). + +%worlds (csig-ei | asig-ei | sbind) (convert-ksub _ _ _ _ _). +%total {} (convert-ksub _ _ _ _ _). + diff --git a/src/convert.elf b/src/convert.elf new file mode 100644 index 0000000..36dc03f --- /dev/null +++ b/src/convert.elf @@ -0,0 +1,145 @@ + +convert : tm -> tp -> etm -> type. +aconvert : atm -> tp -> etm -> type. +tpconvert : tp -> kind -> etp -> type. +atpconvert : atp -> kind -> etp -> type. +kconvert : kind -> ekind -> type. + +convert/at : convert (at R) (base P) EM + <- aconvert R (base P) EM. + +convert/lam : convert (lam ([x] M x)) (pi A ([x] B x)) + (elam EA ([ex] EM ex)) + <- tpconvert A ktype EA + <- ({x} vof x A + -> {ex} vtrans ex x + -> convert (M x) (B x) (EM ex)). + +%{ +The tpconvert subgoals in these next two rules (and in atpconvert/const) are +needed for the proof of convert-reg for termination, because the induction is +over the conversion derivation, so the tpconvert has to be a subderivation +for the metric to get smaller. +}% + +aconvert/const : aconvert (const C) A (econst C) + <- cof C A + <- kof A ktype +% <- tclosed A + <- tpconvert A ktype _. + +aconvert/var : aconvert X A EX + <- vof X A + <- kof A ktype + <- tpconvert A ktype _ + <- vtrans EX X. + +aconvert/app : aconvert (app R N) Bx (eapp EM EN) + <- aconvert R (pi A ([x] B x)) EM + <- convert N A EN + <- tpsub ([x] B x) N Bx. + +tpconvert/base : tpconvert (base P) ktype EA + <- atpconvert P ktype EA. + +tpconvert/pi : tpconvert (pi A ([x] B x)) ktype + (epi EA ([ex] EB ex)) + <- tpconvert A ktype EA + <- ({x} vof x A + -> {ex} vtrans ex x + -> tpconvert (B x) ktype (EB ex)). + +tpconvert/lam : tpconvert (alam ([x] B x)) (kpi A ([x] K x)) + (ealam EA ([ex] EB ex)) + <- tpconvert A ktype EA + <- ({x} vof x A + -> {ex} vtrans ex x + -> tpconvert (B x) (K x) (EB ex)). + +atpconvert/const: atpconvert (aconst A) K (eaconst A) + <- ckof A K + <- wfkind K +% <- kclosed K + <- kconvert K _. + +atpconvert/app : atpconvert (aapp P M) Kx (eaapp EA EM) + <- atpconvert P (kpi A ([x] K x)) EA + <- convert M A EM + <- ksub ([x] K x) M Kx. + +kconvert/type : kconvert ktype ektype. + +kconvert/pi : kconvert (kpi A ([x] K x)) (ekpi EA ([ex] EK ex)) + <- tpconvert A ktype EA + <- ({x} vof x A + -> {ex} vtrans ex x + -> kconvert (K x) (EK ex)). + +%% Explicit Contexts %% + +converte : ctx -> tm -> tp -> etm -> type. +aconverte : ctx -> atm -> tp -> etm -> type. +tpconverte : ctx -> tp -> kind -> etp -> type. +atpconverte : ctx -> atp -> kind -> etp -> type. +kconverte : ctx -> kind -> ekind -> type. + + +converte/at : converte G (at R) (base P) EM + <- aconverte G R (base P) EM. + +converte/lam : converte G (lam M) (pi A B) (elam EA EM) + <- tpconverte G A ktype EA + <- ({x} {ex} vtrans ex x + -> converte (cons G x A) (M x) (B x) (EM ex)). + +aconverte/const : aconverte G (const C) A (econst C) + <- cof C A + <- kof A ktype + <- tpconverte G A ktype _. + +aconverte/var : aconverte G X A EX + <- lookup G X A + <- tpconverte G A ktype _ + <- vtrans EX X. + +aconverte/vari : aconverte G X A EX + <- vof X A + <- kof A ktype + <- tpconverte G A ktype _ + <- vtrans EX X. + +aconverte/app : aconverte G (app R N) Bx (eapp EM EN) + <- aconverte G R (pi A B) EM + <- converte G N A EN + <- tpsub B N Bx. + +tpconverte/base : tpconverte G (base P) ktype EA + <- atpconverte G P ktype EA. + +tpconverte/pi : tpconverte G (pi A B) ktype (epi EA EB) + <- tpconverte G A ktype EA + <- ({x} {ex} vtrans ex x + -> tpconverte (cons G x A) (B x) ktype (EB ex)). + +tpconverte/lam : tpconverte G (alam B) (kpi A K) (ealam EA EB) + <- tpconverte G A ktype EA + <- ({x} {ex} vtrans ex x + -> tpconverte (cons G x A) (B x) (K x) (EB ex)). + +atpconverte/const : atpconverte G (aconst A) K (eaconst A) + <- ckof A K + <- wfkind K + <- kconverte G K _. + +atpconverte/app : atpconverte G (aapp P M) Kx (eaapp EA EM) + <- atpconverte G P (kpi A K) EA + <- converte G M A EM + <- ksub K M Kx. + +kconverte/type : kconverte G ktype ektype. + +kconverte/pi : kconverte G (kpi A K) (ekpi EA EK) + <- tpconverte G A ktype EA + <- ({x} {ex} vtrans ex x + -> kconverte (cons G x A) (K x) (EK ex)). + diff --git a/src/efunctionality.thm b/src/efunctionality.thm new file mode 100644 index 0000000..3720ad5 --- /dev/null +++ b/src/efunctionality.thm @@ -0,0 +1,547 @@ +%{ +eqtme-extpi : eqtme G M N (epi A B') + -> ({x} eqtme (econs G x A) (eapp M x) (eapp N x) (B x)) +%% + -> eqtme G M N (epi A B) -> type. +%mode eqtme-extpi +X1 +X2 -X3. + +%worlds (evar | eovar) (eqtme-extpi _ _ _). +%total D (eqtme-extpi D _ _). +}% + +%% Functionality of EL substitution (substing equiv terms yields equiv terms) %% + +eqtm-sub-e : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) + -> eqtme G1 M N A + -> eofe G1 M A + -> eofe G1 N A + -> ({x} eofe (G x) (P x) (B x)) + -> ecsub ([x] G x) M G' +%% + -> eqtme G' (P M) (P N) (B M) -> type. +%mode eqtm-sub-e +X0 +X1 +X2 +X3 +X4 +X5 +X6 -X7. + +eqtm-tpsub-e : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) + -> eqtme G1 M N A + -> eofe G1 M A + -> eofe G1 N A + -> ({x} ekofe (G x) (B x) (K x)) + -> ecsub ([x] G x) M G' +%% + -> eqtpe G' (B M) (B N) (K M) -> type. +%mode eqtm-tpsub-e +X0 +X1 +X2 +X3 +X4 +X5 +X6 -X7. + +eqtm-ksub-e : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) + -> eqtme G1 M N A + -> eofe G1 M A + -> eofe G1 N A + -> ({x} ewfkinde (G x) (K x)) + -> ecsub ([x] G x) M G' +%% + -> eqkinde G' (K M) (K N) -> type. +%mode eqtm-ksub-e +X0 +X1 +X2 +X3 +X4 +X5 +X6 -X7. + +-vari : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] eofe/vari + (DofB x : ekofe (G x) B ektype) + (Dvof : evof Y B)) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (eqtme/refl (eofe/vari DofBx Dvof)) +%% + <- ekofe-sub Dord Dappend DofB DofM Dcsub + (DofBx : ekofe Gx B ektype). + +-const : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + eofe/const + (DofB x : ekofe (G x) B ektype) + (Dcof : ecof C B)) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (eqtme/refl (eofe/const DofBx Dcof)) +%% + <- ekofe-sub Dord Dappend DofB DofM Dcsub DofBx. + +-varsam : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + eofe/var + (DofA' x : ekofe (G x) (A' x) ektype) + (Dlook' x : elookup (G x) x (A' x))) + (Dcsub : ecsub ([x] G x) M Gx) +%% + Deqtme* +%% + <- ({x} + eappend-lookup (Dappend x) + (Dlook x : elookup (G x) x A)) + <- ({x} {d} + elookup-fun (Dord x d) (Dlook x) (Dlook' x) + (DeqAA' x : etp-eq A (A' x))) + <- ({x} + weaken-eqtme Deqtme x A + (Deqtme' x : eqtme (econs G1 x A) M N A)) + <- ({x} + weaken-eqtme' (Dappend x) (Deqtme' x) + (Deqtme'' x : eqtme (G x) M N A)) + <- ({x} + eqtme-resp ectx-eq/i etm-eq/i etm-eq/i (DeqAA' x) + (Deqtme'' x) + (Deqtme''' x : eqtme (G x) M N (A' x))) + <- eqtme-sub Dord Dappend Deqtme''' DofM Dcsub + (Deqtme* : eqtme Gx M N (A' M)). + +-varoth : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + eofe/var + (DofB x : ekofe (G x) (B x) ektype) + (Dlook x : elookup (G x) Y (B x))) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (eqtme/refl (eofe/var DofBx Dlookx)) +%% + <- ekofe-sub Dord Dappend DofB DofM Dcsub + (DofBx : ekofe Gx (B M) ektype) + <- ecsub-lookup Dcsub Dlook + (Dlookx : elookup Gx Y (B M)). + +-app : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + eofe/app + (DofP x : eofe (G x) (P x) (B x)) + (DofO x : eofe (G x) (O x) (epi (B x) ([y] C x y)))) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (eqtme/app DeqP DeqO) +%% + <- eqtm-sub-e Dord Dappend Deqtme DofM DofN DofP Dcsub + (DeqP : eqtme Gx (P M) (P N) (B M)) + <- eqtm-sub-e Dord Dappend Deqtme DofM DofN DofO Dcsub + (DeqO : eqtme Gx (O M) (O N) (epi (B M) ([y] C M y))). + +-appbad : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + eofe/var + (DofB x : ekofe (G x) (B x) ektype) + (Dlook x : elookup (G x) (eapp (O x) (P x)) (B x))) + _ +%% + Deq +%% + <- ({x} {d} + elookup-isvar (Dord x d) (Dlook x) + (Disvar x : eisvar (eapp (O x) (P x)) I)) + <- ({x} eisvar-app-contra (Disvar x) Dfalse) + <- false-implies-eqtme Dfalse Deq. + +-lam : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + eofe/lam + (DofB x : ekofe (G x) (B x) ektype) + ([y] DofP x y : eofe (econs (G x) y (B x)) (P x y) (C x y))) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (eqtme/lam DeqP DeqB) +%% + <- eqtm-tpsub-e Dord Dappend Deqtme DofM DofN DofB Dcsub + (DeqB : eqtpe Gx (B M) (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtm-sub-e + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + Deqtme DofM DofN ([x] DofP x y) + (ecsub/cons Dcsub) + (DeqP y + : eqtme (econs Gx y (B M)) (P M y) (P N y) (C M y))). + +-lambad : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + eofe/var + (DofB x : ekofe (G x) (B x) ektype) + (Dlook x : elookup (G x) (elam (D x) ([z] O x z)) (B x))) + _ +%% + Deq +%% + <- ({x} {d} + elookup-isvar (Dord x d) (Dlook x) + (Disvar x : eisvar (elam (D x) ([z] O x z)) I)) + <- ({x} + eisvar-lam-contra (Disvar x) Dfalse) + <- false-implies-eqtme Dfalse Deq. + +-ext : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] eofe/ext + ([y] DofApp x y + : eofe (econs (G x) y (B x)) (eapp (O x) y) (C x y)) + (DofO x : eofe (G x) (O x) (epi (B x) ([y] C' x y)))) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (eqtme/extw DeqApp DeqOx) +%% + <- eqtm-sub-e Dord Dappend Deqtme DofM DofN DofO Dcsub + (DeqOx : eqtme Gx (O M) (O N) (epi (B M) ([y] C' M y))) + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtm-sub-e + ([x] [d] Dord' x d y e) ([x] eappend/cons (Dappend x)) + Deqtme DofM DofN ([x] DofApp x y) + (ecsub/cons Dcsub) + (DeqApp y + : eqtme (econs Gx y (B M)) + (eapp (O M) y) (eapp (O N) y) (C M y))). + +-eqtp : eqtm-sub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + eofe/eqtp + (DeqBC x : eqtpe (G x) (B x) (C x) ektype) + (DofPB x : eofe (G x) (P x) (B x))) + Dcsub +%% + (eqtme/tcon DeqBx DeqPx) +%% + <- eqtm-sub-e Dord Dappend Deqtme DofM DofN DofPB Dcsub + (DeqPx : eqtme Gx (P M) (P N) (B M)) + <- eqtpe-sub Dord Dappend DeqBC DofM Dcsub + (DeqBx : eqtpe Gx (B M) (C M) ektype). + +%%%% + +-const : eqtm-tpsub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + ekofe/const + (Dwfkind x : ewfkinde (G x) K) + (Dckof : eckof C K)) + Dcsub +%% + (eqtpe/refl (ekofe/const DofKx Dckof)) +%% + <- ewfkinde-sub Dord Dappend Dwfkind DofM Dcsub DofKx. + +-app : eqtm-tpsub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + ekofe/app + (DofP x : eofe (G x) (P x) (B x)) + (DofC x : ekofe (G x) (C x) (ekpi (B x) ([y] D x y)))) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (eqtpe/app DeqP DeqC) +%% + <- eqtm-sub-e Dord Dappend Deqtme DofM DofN DofP Dcsub + (DeqP : eqtme Gx (P M) (P N) (B M)) + <- eqtm-tpsub-e Dord Dappend Deqtme DofM DofN DofC Dcsub + (DeqC : eqtpe Gx (C M) (C N) (ekpi (B M) ([y] D M y))). + +-pi : eqtm-tpsub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + ekofe/pi + (DofB x : ekofe (G x) (B x) ektype) + ([y] DofC x y + : ekofe (econs (G x) y (B x)) (C x y) ektype)) + Dcsub +%% + (eqtpe/pi DeqC DeqB) +%% + <- eqtm-tpsub-e Dord Dappend Deqtme DofM DofN DofB Dcsub + (DeqB : eqtpe Gx (B M) (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtm-tpsub-e + ([x] [d] Dord' x d y e) ([x] eappend/cons (Dappend x)) + Deqtme DofM DofN ([x] DofC x y) (ecsub/cons Dcsub) + (DeqC y + : eqtpe (econs Gx y (B M)) (C M y) (C N y) ektype)). + +-lam : eqtm-tpsub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + ekofe/lam + (DofB x : ekofe (G x) (B x) ektype) + ([y] DofD x y : ekofe (econs (G x) y (B x)) (D x y) (C x y))) + Dcsub +%% + (eqtpe/lam DeqD DeqB) +%% + <- eqtm-tpsub-e Dord Dappend Deqtme DofM DofN DofB Dcsub + (DeqB : eqtpe Gx (B M) (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtm-tpsub-e + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + Deqtme DofM DofN ([x] DofD x y) (ecsub/cons Dcsub) + (DeqD y + : eqtpe (econs Gx y (B M)) (D M y) (D N y) (C M y))). + +-ext : eqtm-tpsub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] ekofe/ext + ([y] DofApp x y + : ekofe (econs (G x) y (B x)) (eaapp (C x) y) (K x y)) + (DofC x : ekofe (G x) (C x) (ekpi (B x) ([y] K' x y)))) + Dcsub +%% + (eqtpe/extw DeqApp DeqCx) +%% + <- eqtm-tpsub-e Dord Dappend Deqtme DofM DofN DofC Dcsub + (DeqCx : eqtpe Gx (C M) (C N) (ekpi (B M) ([y] K' M y))) + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtm-tpsub-e + ([x] [d] Dord' x d y e) ([x] eappend/cons (Dappend x)) + Deqtme DofM DofN ([x] DofApp x y) (ecsub/cons Dcsub) + (DeqApp y + : eqtpe (econs Gx y (B M)) + (eaapp (C M) y) (eaapp (C N) y) (K M y))). + +-eqkind : eqtm-tpsub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + ekofe/eqkind + (Deqkind x : eqkinde (G x) (K x) (K' x)) + (DofBK x : ekofe (G x) (B x) (K x))) + Dcsub +%% + (eqtpe/kcon DeqKx DeqBx) % DeqBx DeqKx) +%% + <- eqtm-tpsub-e Dord Dappend Deqtme DofM DofN DofBK Dcsub + (DeqBx : eqtpe Gx (B M) (B N) (K M)) + <- eqkinde-sub Dord Dappend Deqkind DofM Dcsub + (DeqKx : eqkinde Gx (K M) (K' M)). + +%%%% + +-tp : eqtm-ksub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] ewfkinde/tp) + _ +%% + eqkinde/tp. + +-pi : eqtm-ksub-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtme : eqtme G1 M N A) + (DofM : eofe G1 M A) + (DofN : eofe G1 N A) + ([x] + ewfkinde/pi + (DofB x : ekofe (G x) (B x) ektype) + ([y] DofK x y : ewfkinde (econs (G x) y (B x)) (K x y))) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (eqkinde/pi DeqK DeqB) +%% + <- eqtm-tpsub-e Dord Dappend Deqtme DofM DofN DofB Dcsub + (DeqB : eqtpe Gx (B M) (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtm-ksub-e + ([x] [d] Dord' x d y e) ([x] eappend/cons (Dappend x)) + Deqtme DofM DofN ([x] DofK x y) (ecsub/cons Dcsub) + (DeqK y + : eqkinde (econs Gx y (B M)) (K M y) (K N y))). + +%worlds (ecsig | easig | evar | ebind | eovar) + (eqtm-sub-e _ _ _ _ _ _ _ _) + (eqtm-tpsub-e _ _ _ _ _ _ _ _) + (eqtm-ksub-e _ _ _ _ _ _ _ _). +%total (D1 D2 D3) + (eqtm-sub-e _ _ _ _ _ D1 _ _) + (eqtm-tpsub-e _ _ _ _ _ D2 _ _) + (eqtm-ksub-e _ _ _ _ _ D3 _ _). + +%{ +%block nbind : some {a:tp} {ea:etp} + block {x:atm} {d:vof x a} {ex:etm} {xt:vtrans ex x} {ed:evof ex ea}. +}% + +eqtm-sub : ({x} evof x A -> eof (O x) (B x)) + -> eqtm M N A + -> eof M A + -> eof N A +%% + -> eqtm (O M) (O N) (B M) -> type. +%mode eqtm-sub +X1 +X2 +X3 +X4 -X5. + +- : eqtm-sub + ([x] [d:evof x A] DofO x d : eof (O x) (B x)) + (DeqMN : eqtm M N A) + (DofM : eof M A) + (DofN : eof N A) + Deqtm + <- eqtm-to-eqtme DeqMN (DeqeMN : eqtme enil M N A) + <- eof-to-eofe DofM DofeM + <- eof-to-eofe DofN DofeN + <- eof1-to-eofe DofO + ([x] DofeO x : eofe (econs enil x A) (O x) (B x)) + <- extend-eordered _ eordered/nil _ + ([x] [d] Dord x d : eordered (econs enil x A)) + <- eqtm-sub-e Dord ([x] eappend/nil) + DeqeMN DofeM DofeN DofeO ecsub/base + (Deqtme : eqtme enil (O M) (O N) (B M)) + <- eqtme-to-eqtm Deqtme + (Deqtm : eqtm (O M) (O N) (B M)). + +%worlds (ecsig | easig | ebind) (eqtm-sub _ _ _ _ _). +%total {} (eqtm-sub _ _ _ _ _). + + +eqtm-tpsub : ({x} evof x A -> ekof (B x) (K x)) + -> eqtm M N A + -> eof M A + -> eof N A + -> eqtp (B M) (B N) (K M) -> type. +%mode eqtm-tpsub +X0 +X1 +X2 +X3 -X4. + +- : eqtm-tpsub + ([x] [d:evof x A] DofO x d : ekof (O x) (B x)) + (DeqMN : eqtm M N A) + (DofM : eof M A) + (DofN : eof N A) + Deqtp + <- eqtm-to-eqtme DeqMN (DeqeMN : eqtme enil M N A) + <- eof-to-eofe DofM DofeM + <- eof-to-eofe DofN DofeN + <- ekof1-to-ekofe DofO + ([x] DofeO x : ekofe (econs enil x A) (O x) (B x)) + <- extend-eordered _ eordered/nil _ + ([x] [d] Dord x d : eordered (econs enil x A)) + <- eqtm-tpsub-e Dord ([x] eappend/nil) + DeqeMN DofeM DofeN DofeO ecsub/base + (Deqtpe : eqtpe enil (O M) (O N) (B M)) + <- eqtpe-to-eqtp Deqtpe + (Deqtp : eqtp (O M) (O N) (B M)). + +%worlds (ecsig | easig | evar | ebind | tbind) (eqtm-tpsub _ _ _ _ _). +%total {} (eqtm-tpsub _ _ _ _ _). + + +eqtm-ksub : ({x} evof x A -> ewfkind (K x)) + -> eqtm M N A + -> eof M A + -> eof N A +%% + -> eqkind (K M) (K N) -> type. +%mode eqtm-ksub +K +X1 +X2 +X3 -X4. + +- : eqtm-ksub + ([x] [d:evof x A] DofK x d : ewfkind (K x)) + (DeqMN : eqtm M N A) + (DofM : eof M A) + (DofN : eof N A) + Deqkind + <- eqtm-to-eqtme DeqMN (DeqeMN : eqtme enil M N A) + <- eof-to-eofe DofM DofeM + <- eof-to-eofe DofN DofeN + <- ewfkind1-to-ewfkinde DofK + ([x] DofeK x : ewfkinde (econs enil x A) (K x)) + <- extend-eordered _ eordered/nil _ + ([x] [d] Dord x d : eordered (econs enil x A)) + <- eqtm-ksub-e Dord ([x] eappend/nil) + DeqeMN DofeM DofeN DofeK ecsub/base + (Deqkinde : eqkinde enil (K M) (K N)) + <- eqkinde-to-eqkind Deqkinde + (Deqkind : eqkind (K M) (K N)). + + +%worlds (ecsig | easig | evar | ebind | tbind) (eqtm-ksub _ _ _ _ _). +%total {} (eqtm-ksub _ _ _ _ _). + diff --git a/src/equality.thm b/src/equality.thm new file mode 100644 index 0000000..5275485 --- /dev/null +++ b/src/equality.thm @@ -0,0 +1,1662 @@ +%%%% equalities %%%% + +kind-eq : kind -> kind -> type. +kind-eq/i : kind-eq K K. + +tp-eq : tp -> tp -> type. +tp-eq/i : tp-eq A A. + +atp-eq : atp -> atp -> type. +atp-eq/i : atp-eq P P. + +tm-eq : tm -> tm -> type. +tm-eq/i : tm-eq M M. + +atm-eq : atm -> atm -> type. +atm-eq/i : atm-eq R R. + +ctp-eq : ctp -> ctp -> type. +ctp-eq/i : ctp-eq A A. + +ctm-eq : ctm -> ctm -> type. +ctm-eq/i : ctm-eq C C. + +ctx-eq : ctx -> ctx -> type. +ctx-eq/i : ctx-eq G G. + +stp-eq : stp -> stp -> type. +stp-eq/i : stp-eq T T. + +skind-eq : skind -> skind -> type. +skind-eq/i : skind-eq K K. + +sctx-eq : sctx -> sctx -> type. +sctx-eq/i : sctx-eq G G. + + +%%%% symmetry %%%% + +kind-eq-sym : kind-eq K1 K2 -> kind-eq K2 K1 -> type. +%mode kind-eq-sym +X1 -X2. + +- : kind-eq-sym kind-eq/i kind-eq/i. + +%worlds (csig | asig | var) (kind-eq-sym _ _). +%total {} (kind-eq-sym _ _). + + +tp-eq-sym : tp-eq A1 A2 -> tp-eq A2 A1 -> type. +%mode tp-eq-sym +X1 -X2. + +- : tp-eq-sym tp-eq/i tp-eq/i. + + +%worlds (csig | asig | var) (tp-eq-sym _ _). +%total {} (tp-eq-sym _ _). + + +atp-eq-sym : atp-eq P1 P2 -> atp-eq P2 P1 -> type. +%mode atp-eq-sym +X1 -X2. + +- : atp-eq-sym atp-eq/i atp-eq/i. + +%worlds (csig | asig | var) (atp-eq-sym _ _). +%total {} (atp-eq-sym _ _). + + +tm-eq-sym : tm-eq A1 A2 -> tm-eq A2 A1 -> type. +%mode tm-eq-sym +X1 -X2. + +- : tm-eq-sym tm-eq/i tm-eq/i. + +%worlds (csig | asig | var) (tm-eq-sym _ _). +%total {} (tm-eq-sym _ _). + + +atm-eq-sym : atm-eq P1 P2 -> atm-eq P2 P1 -> type. +%mode atm-eq-sym +X1 -X2. + +- : atm-eq-sym atm-eq/i atm-eq/i. + +%worlds (csig | asig | var) (atm-eq-sym _ _). +%total {} (atm-eq-sym _ _). + +stp-eq-sym : stp-eq T1 T2 -> stp-eq T2 T1 -> type. +%mode stp-eq-sym +X1 -X2. + +- : stp-eq-sym stp-eq/i stp-eq/i. + +%worlds (csig | asig | var | evar) (stp-eq-sym _ _). +%total {} (stp-eq-sym _ _). + +skind-eq-sym : skind-eq K1 K2 -> skind-eq K2 K1 -> type. +%mode skind-eq-sym +X1 -X2. + +- : skind-eq-sym skind-eq/i skind-eq/i. + +%worlds (csig | asig | var | evar) (skind-eq-sym _ _). +%total {} (skind-eq-sym _ _). + + +%%%% transitivity %%%% + +tm-eq-trans : tm-eq M N -> tm-eq N O -> tm-eq M O -> type. +%mode tm-eq-trans +X1 +X2 -X3. + +- : tm-eq-trans tm-eq/i tm-eq/i tm-eq/i. + +%worlds (csig | asig | var) (tm-eq-trans _ _ _). +%total {} (tm-eq-trans _ _ _). + +tp-eq-trans : tp-eq A B -> tp-eq B C -> tp-eq A C -> type. +%mode tp-eq-trans +X1 +X2 -X3. + +- : tp-eq-trans tp-eq/i tp-eq/i tp-eq/i. + +%worlds (csig | asig | var) (tp-eq-trans _ _ _). +%total {} (tp-eq-trans _ _ _). + +kind-eq-trans : kind-eq K1 K2 -> kind-eq K2 K3 -> kind-eq K1 K3 -> type. +%mode kind-eq-trans +X1 +X2 -X3. + +- : kind-eq-trans kind-eq/i kind-eq/i kind-eq/i. + +%worlds (csig | asig | var) (kind-eq-trans _ _ _). +%total {} (kind-eq-trans _ _ _). + + +stp-eq-trans : stp-eq T1 T2 -> stp-eq T2 T3 -> stp-eq T1 T3 -> type. +%mode stp-eq-trans +X1 +X2 -X3. + +- : stp-eq-trans stp-eq/i stp-eq/i stp-eq/i. + +%worlds (csig | asig | var | evar) (stp-eq-trans _ _ _). +%total {} (stp-eq-trans _ _ _). + +skind-eq-trans : skind-eq T1 T2 -> skind-eq T2 T3 -> skind-eq T1 T3 -> type. +%mode skind-eq-trans +X1 +X2 -X3. + +- : skind-eq-trans skind-eq/i skind-eq/i skind-eq/i. + +%worlds (csig | asig | var | evar) (skind-eq-trans _ _ _). +%total {} (skind-eq-trans _ _ _). + + + + + +%%%% compatibility %%%% + +%% atp-eq + +aapp-compat : atp-eq P P' + -> tm-eq M M' + -> atp-eq (aapp P M) (aapp P' M') + -> type. +%mode aapp-compat +X1 +X2 -X3. + +- : aapp-compat atp-eq/i tm-eq/i atp-eq/i. + +%worlds (csig | asig | var) (aapp-compat _ _ _). +%total {} (aapp-compat _ _ _). + +%% kind-eq + +kpi-compat : tp-eq A A' + -> ({x} kind-eq (K x) (K' x)) + -> kind-eq (kpi A ([x] K x)) (kpi A' ([y] K' y)) + -> type. +%mode kpi-compat +X1 +X2 -X3. + +- : kpi-compat tp-eq/i ([_] kind-eq/i) kind-eq/i. + +%worlds (csig | asig | var) (kpi-compat _ _ _). +%total {} (kpi-compat _ _ _). + + +%% tp-eq + +base-compat : atp-eq P P' -> tp-eq (base P) (base P') -> type. +%mode base-compat +X1 -X2. + +- : base-compat atp-eq/i tp-eq/i. + +%worlds (csig | asig | var) (base-compat _ _). +%total {} (base-compat _ _). + + +pi-compat : tp-eq A A' + -> ({x} tp-eq (B x) (B' x)) + -> tp-eq (pi A ([x] B x)) (pi A' ([y] B' y)) + -> type. +%mode pi-compat +X1 +X2 -X3. + +- : pi-compat tp-eq/i ([_] tp-eq/i) tp-eq/i. + +%worlds (csig | asig | var) (pi-compat _ _ _). +%total {} (pi-compat _ _ _). + +alam-compat : ({x} tp-eq (B x) (B' x)) + -> tp-eq (alam ([x] B x)) (alam ([x] B' x)) + -> type. +%mode alam-compat +X1 -X2. + +- : alam-compat ([_] tp-eq/i) tp-eq/i. + +%worlds (csig | asig | var) (alam-compat _ _). +%total {} (alam-compat _ _). + + +%% atm-eq + +app-compat : atm-eq R R' -> tm-eq M M' + -> atm-eq (app R M) (app R' M') -> type. +%mode app-compat +X1 +X2 -X3. + +- : app-compat atm-eq/i tm-eq/i atm-eq/i. + +%worlds (csig | asig | var) (app-compat _ _ _). +%total {} (app-compat _ _ _). + + +%% tm-eq + +lam-compat : ({x : atm} tm-eq (M x) (M' x)) + -> tm-eq (lam [x] M x) (lam [x] M' x) -> type. +%mode lam-compat +X1 -X2. + +- : lam-compat ([_] tm-eq/i) tm-eq/i. + +%worlds (csig | asig | var) (lam-compat _ _). +%total {} (lam-compat _ _). + + +at-compat : atm-eq R R' -> tm-eq (at R) (at R') -> type. +%mode at-compat +X1 -X2. + +- : at-compat atm-eq/i tm-eq/i. + +%worlds (csig | asig | var) (at-compat _ _). +%total {} (at-compat _ _). + + +%% stp + +stp-compat-stp : {T:stp -> stp} stp-eq T1 T2 -> stp-eq (T T1) (T T2) -> type. +%mode stp-compat-stp +X1 +X2 -X3. + +- : stp-compat-stp _ stp-eq/i stp-eq/i. + +%worlds (csig | asig | evar) (stp-compat-stp _ _ _). +%total {} (stp-compat-stp _ _ _). + +%% skind + +skind-compat-skind : {T:stp -> skind} stp-eq T1 T2 + -> skind-eq (T T1) (T T2) -> type. +%mode skind-compat-skind +X1 +X2 -X3. + +- : skind-compat-skind _ stp-eq/i skind-eq/i. + +%worlds (csig | asig | evar) (skind-compat-skind _ _ _). +%total {} (skind-compat-skind _ _ _). + +skind-compat-skind' : {T:skind -> skind} skind-eq K1 K2 + -> skind-eq (T K1) (T K2) -> type. +%mode skind-compat-skind' +X1 +X2 -X3. + +- : skind-compat-skind' _ skind-eq/i skind-eq/i. + +%worlds (csig | asig | evar) (skind-compat-skind' _ _ _). +%total {} (skind-compat-skind' _ _ _). + + +%% sctx + +sctx-compat-cons : {X} sctx-eq G1 G2 -> stp-eq T1 T2 + -> sctx-eq (scons G1 X T1) (scons G2 X T2) -> type. +%mode sctx-compat-cons +X +X1 +X2 -X3. + +- : sctx-compat-cons _ sctx-eq/i stp-eq/i sctx-eq/i. + +%worlds (csig | asig | var | evar) (sctx-compat-cons _ _ _ _). +%total {} (sctx-compat-cons _ _ _ _). + + +%%%% respects lemmas %%%% + +%% typing compatibility + +cof-resp : tp-eq A A' -> cof C A -> cof C A' -> type. +%mode cof-resp +X1 +X2 -X3. + +- : cof-resp tp-eq/i D D. + +%worlds (csig | asig | var) (cof-resp _ _ _). +%total {} (cof-resp _ _ _). + +ckof-resp : kind-eq K K' -> ckof P K -> ckof P K' -> type. +%mode ckof-resp +X1 +X2 -X3. + +- : ckof-resp kind-eq/i D D. + +%worlds (csig | asig | var) (ckof-resp _ _ _). +%total {} (ckof-resp _ _ _). + + +atkof-resp : atp-eq P P' -> kind-eq K K' -> at-kof P K -> at-kof P' K' -> type. +%mode atkof-resp +X1 +X2 +X3 -X4. + +- : atkof-resp atp-eq/i kind-eq/i D D. + +%worlds (csig | asig | var | bind) (atkof-resp _ _ _ _). +%total {} (atkof-resp _ _ _ _). + +kof-resp : tp-eq A A' -> kind-eq K K' -> kof A K -> kof A' K' -> type. +%mode kof-resp +X1 +X2 +X2-5 -X3. + +- : kof-resp tp-eq/i kind-eq/i D D. + +%worlds (csig | asig | var | bind) (kof-resp _ _ _ _). +%total {} (kof-resp _ _ _ _). + + +wfkind-resp : kind-eq K K' -> wfkind K -> wfkind K' -> type. +%mode wfkind-resp +X1 +X2 -X3. + +- : wfkind-resp kind-eq/i D D. + +%worlds (csig | asig | var | bind) (wfkind-resp _ _ _). +%total {} (wfkind-resp _ _ _). + + +atof-resp : atm-eq R R' -> tp-eq A A' -> at-of R A -> at-of R' A' -> type. +%mode atof-resp +X1 +X2 +X3 -X4. + +- : atof-resp atm-eq/i tp-eq/i D D. + +%worlds (csig | asig | var | bind) (atof-resp _ _ _ _). +%total {} (atof-resp _ _ _ _). + + +of-resp : tm-eq M M' -> tp-eq A A' -> of M A -> of M' A' -> type. +%mode of-resp +X0 +X1 +X2 -X3. + +- : of-resp tm-eq/i tp-eq/i D D. + +%worlds (csig | asig | var | bind) (of-resp _ _ _ _). +%total {} (of-resp _ _ _ _). + +of-bind-resp1 : ({y:atm} tp-eq (A y) (A' y)) + -> ({y} {x} vof x (A y) -> of (M x y) (B x y)) +%% + -> ({y} {x} vof x (A' y) -> of (M x y) (B x y)) -> type. +%mode of-bind-resp1 +X1 +X2 -X3. + +- : of-bind-resp1 ([_] tp-eq/i) D D. + +%worlds (csig | asig | var | bind) (of-bind-resp1 _ _ _). +%total {} (of-bind-resp1 _ _ _). +%reduces D = D' (of-bind-resp1 _ D D'). + + +atkof-resp-1 : ({x:atm} atp-eq (P x) (P' x)) + -> ({x:atm} kind-eq (K x) (K' x)) + -> ({x} {d:vof x A} at-kof (P x) (K x)) +%% + -> ({x} {d:vof x A} at-kof (P' x) (K' x)) -> type. +%mode atkof-resp-1 +X1 +X2 +X3 -X4. + +- : atkof-resp-1 ([_] atp-eq/i) ([_] kind-eq/i) D D. + +%worlds (csig | asig | var | bind) (atkof-resp-1 _ _ _ _). +%total {} (atkof-resp-1 _ _ _ _). +%reduces D = D' (atkof-resp-1 _ _ D D'). + + +kof-bind-resp1 : ({y:atm} tp-eq (A y) (A' y)) + -> ({y} {x} vof x (A y) -> kof (B x y) (K x y)) +%% + -> ({y} {x} vof x (A' y) -> kof (B x y) (K x y)) -> type. +%mode kof-bind-resp1 +X1 +X2 -X3. + +- : kof-bind-resp1 ([_] tp-eq/i) D D. + +%worlds (csig | asig | var | bind) (kof-bind-resp1 _ _ _). +%total {} (kof-bind-resp1 _ _ _). +%reduces D = D' (kof-bind-resp1 _ D D'). + +atkofes-resp : sctx-eq G G' -> atp-eq P P' -> skind-eq K K' -> at-kofes G P K + -> at-kofes G' P' K' -> type. +%mode atkofes-resp +X1 +X2 +X3 +X4 -X5. + +- : atkofes-resp sctx-eq/i atp-eq/i skind-eq/i D D. + +%worlds (csig | asig | var | bind | evar) (atkofes-resp _ _ _ _ _). +%total {} (atkofes-resp _ _ _ _ _). + +kofes-resp : sctx-eq G G' -> tp-eq A A' -> skind-eq K K' -> kofes G A K + -> kofes G' A' K' -> type. +%mode kofes-resp +X1 +X2 +X3 +X4 -X5. + +- : kofes-resp sctx-eq/i tp-eq/i skind-eq/i D D. + +%worlds (csig | asig | var | bind | evar) (kofes-resp _ _ _ _ _). +%reduces D2 = D1 (kofes-resp _ _ _ D1 D2). +%total {} (kofes-resp _ _ _ _ _). + +kofes-resp' : ({x:atm} sctx-eq (G x) (G' x)) -> ({x:atm} tp-eq (A x) (A' x)) + -> skind-eq K K' + -> ({x:atm} kofes (G x) (A x) K) + -> ({x:atm} kofes (G' x) (A' x) K') -> type. +%mode kofes-resp' +X0 +X1 +X2 +X3 -X4. + +- : kofes-resp' ([_] sctx-eq/i) ([_] tp-eq/i) skind-eq/i ([x] D x) D. + +%worlds (csig | asig | var | bind | evar) (kofes-resp' _ _ _ _ _). +%reduces D2 = D1 (kofes-resp' _ _ _ D1 D2). +%total {} (kofes-resp' _ _ _ _ _). + + +wfkindes-resp' : ({x:atm} sctx-eq (G x) (G' x)) -> ({x:atm} kind-eq (K x) (K' x)) + -> ({x:atm} wfkindes (G x) (K x)) + -> ({x:atm} wfkindes (G' x) (K' x)) -> type. +%mode wfkindes-resp' +X1 +X2 +X3 -X4. + +- : wfkindes-resp' ([_] sctx-eq/i) ([_] kind-eq/i) ([x] D x) D. + +%worlds (csig | asig | var | bind | evar) (wfkindes-resp' _ _ _ _). +%reduces D2 = D1 (wfkindes-resp' _ _ D1 D2). +%total {} (wfkindes-resp' _ _ _ _). + +kofe-resp : ctx-eq G G' -> tp-eq A A' -> kind-eq K K' -> kofe G A K + -> kofe G' A' K' -> type. +%mode kofe-resp +X1 +X2 +X3 +X4 -X5. + +- : kofe-resp ctx-eq/i tp-eq/i kind-eq/i D D. + +%worlds (csig | asig | var | bind) (kofe-resp _ _ _ _ _). +%total {} (kofe-resp _ _ _ _ _). + +atofe-resp : ctx-eq G G' -> atm-eq R R' -> tp-eq A A' -> at-ofe G R A + -> at-ofe G' R' A' -> type. +%mode atofe-resp +X1 +X2 +X3 +X4 -X5. + +- : atofe-resp ctx-eq/i atm-eq/i tp-eq/i D D. + +%worlds (csig | asig | var | bind | evar) (atofe-resp _ _ _ _ _). +%total {} (atofe-resp _ _ _ _ _). + + +atofes-resp : sctx-eq G G' -> atm-eq R R' -> stp-eq A A' -> at-ofes G R A + -> at-ofes G' R' A' -> type. +%mode atofes-resp +X1 +X2 +X3 +X4 -X5. + +- : atofes-resp sctx-eq/i atm-eq/i stp-eq/i D D. + +%worlds (csig | asig | var | bind | evar) (atofes-resp _ _ _ _ _). +%total {} (atofes-resp _ _ _ _ _). + + +ofe-resp : ctx-eq G G' -> tm-eq M M' -> tp-eq A A' -> ofe G M A + -> ofe G' M' A' -> type. +%mode ofe-resp +X1 +X2 +X3 +X4 -X5. + +- : ofe-resp ctx-eq/i tm-eq/i tp-eq/i D D. + +%worlds (csig | asig | var | ovar | bind) (ofe-resp _ _ _ _ _). +%total {} (ofe-resp _ _ _ _ _). + + +ofes-resp : sctx-eq G G' -> tm-eq M M' -> stp-eq T T' -> ofes G M T + -> ofes G' M' T' -> type. +%mode ofes-resp +X1 +X2 +X3 +X4 -X5. + +- : ofes-resp sctx-eq/i tm-eq/i stp-eq/i D D. + +%worlds (csig | asig | var | ovar | bind | evar) (ofes-resp _ _ _ _ _). +%total {} (ofes-resp _ _ _ _ _). + + + +%%%% injectivity lemmas %%%% + +app-inj-1 : atm-eq (app R _) (app R' _) -> atm-eq R R' -> type. +%mode app-inj-1 +X1 -X2. + +- : app-inj-1 atm-eq/i atm-eq/i. + +%worlds (csig | asig | var) (app-inj-1 _ _). +%total {} (app-inj-1 _ _). + + +app-inj-2 : atm-eq (app _ M) (app _ M') -> tm-eq M M' -> type. +%mode app-inj-2 +X1 -X2. + +- : app-inj-2 atm-eq/i tm-eq/i. + +%worlds (csig | asig | var) (app-inj-2 _ _). +%total {} (app-inj-2 _ _). + + +lam-inj : tm-eq (lam [x] M x) (lam [y] M' y) + -> ({z : atm} tm-eq (M z) (M' z)) -> type. +%mode lam-inj +X1 -X2. + +- : lam-inj tm-eq/i ([_] tm-eq/i). + +%worlds (csig | asig | var) (lam-inj _ _). +%total {} (lam-inj _ _). + +alam-inj : tp-eq (alam [x] A x) (alam [y] A' y) + -> ({z : atm} tp-eq (A z) (A' z)) -> type. +%mode alam-inj +X1 -X2. + +- : alam-inj tp-eq/i ([_] tp-eq/i). + +%worlds (csig | asig | var) (alam-inj _ _). +%total {} (alam-inj _ _). + + + +pi-inj : tp-eq (pi A [x] B x) (pi A' [x] B' x) + -> tp-eq A A' + -> ({x} tp-eq (B x) (B' x)) -> type. +%mode pi-inj +X1 -X2 -X3. + +- : pi-inj tp-eq/i tp-eq/i ([_] tp-eq/i). + +%worlds (csig | asig | var) (pi-inj _ _ _). +%total {} (pi-inj _ _ _). + +arrow-compat : stp-eq S S' -> stp-eq T T' + -> stp-eq (arrow S T) (arrow S' T') -> type. +%mode arrow-compat +X1 +X2 -X3. + +- : arrow-compat stp-eq/i stp-eq/i stp-eq/i. + +%worlds (csig | asig | var) (arrow-compat _ _ _). +%total {} (arrow-compat _ _ _). + +karrow-compat : stp-eq S S' -> skind-eq T T' + -> skind-eq (karrow S T) (karrow S' T') -> type. +%mode karrow-compat +X1 +X2 -X3. + +- : karrow-compat stp-eq/i skind-eq/i skind-eq/i. + +%worlds (csig | asig | var) (karrow-compat _ _ _). +%total {} (karrow-compat _ _ _). + + +arrow-inj : stp-eq (arrow S T) (arrow S' T') + -> stp-eq S S' + -> stp-eq T T' -> type. +%mode arrow-inj +X1 -X2 -X3. + +- : arrow-inj stp-eq/i stp-eq/i stp-eq/i. + +%worlds (csig | asig | var) (arrow-inj _ _ _). +%total {} (arrow-inj _ _ _). + + +tp-eq-pi-strengthen : ({x:atm} tp-eq (pi (A x) ([y] B x y)) C) + -> tp-eq C (pi A' B') -> type. +%mode tp-eq-pi-strengthen +X1 -X2. + +- : tp-eq-pi-strengthen ([x] tp-eq/i) tp-eq/i. + +%worlds (csig | asig | var) (tp-eq-pi-strengthen _ _). +%total {} (tp-eq-pi-strengthen _ _). + + +kpi-inj : kind-eq (kpi A [x] K x) (kpi A' [x] K' x) + -> tp-eq A A' -> ({x} kind-eq (K x) (K' x)) -> type. +%mode kpi-inj +X1 -X2 -X3. + +- : kpi-inj kind-eq/i tp-eq/i ([_] kind-eq/i). + +%worlds (csig | asig | var) (kpi-inj _ _ _). +%total {} (kpi-inj _ _ _). + +kind-eq-kpi-strengthen : ({x:atm} kind-eq (kpi (A x) ([y] K x y)) J) + -> kind-eq J (kpi A' K') -> type. +%mode kind-eq-kpi-strengthen +X1 -X2. + +- : kind-eq-kpi-strengthen ([x] kind-eq/i) kind-eq/i. + +%worlds (csig | asig | var) (kind-eq-kpi-strengthen _ _). +%total {} (kind-eq-kpi-strengthen _ _). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% More compat lemmas %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +rrsub-compat : ({x} atm-eq (R x) (R' x)) -> tm-eq M M' -> atm-eq S S' + -> rrsub R M S +%% + -> rrsub R' M' S' -> type. +%mode rrsub-compat +X1 +X2 +X3 +X4 -X5. + +- : rrsub-compat ([_] atm-eq/i) (tm-eq/i) (atm-eq/i) D D. + +%worlds (csig | asig | var) (rrsub-compat _ _ _ _ _). +%total {} (rrsub-compat _ _ _ _ _). + +rmsub-compat : ({x} atm-eq (R x) (R' x)) -> tm-eq M M' -> tm-eq N N' + -> rmsub R M N +%% + -> rmsub R' M' N' -> type. +%mode rmsub-compat +X1 +X2 +X3 +X4 -X5. + +- : rmsub-compat ([_] atm-eq/i) (tm-eq/i) (tm-eq/i) D D. + +%worlds (csig | asig | var) (rmsub-compat _ _ _ _ _). +%total {} (rmsub-compat _ _ _ _ _). + +sub-compat : ({x} tm-eq (O x) (O' x)) -> tm-eq M M' -> tm-eq N N' + -> sub O M N -> sub O' M' N' -> type. +%mode sub-compat +X1 +X2 +X3 +X4 -X5. + +- : sub-compat ([_] tm-eq/i) tm-eq/i tm-eq/i D D. + +%worlds (csig | asig | var) (sub-compat _ _ _ _ _). +%reduces D1 = D2 (sub-compat _ _ _ D1 D2). +%total {} (sub-compat _ _ _ _ _). + + +sub-compat1 : ({x:atm} {y} tm-eq (O x y) (O' x y)) + -> ({x} tm-eq (M x) (M' x)) + -> ({x} tm-eq (N x) (N' x)) + -> ({x} sub (O x) (M x) (N x)) +%% + -> ({x} sub (O' x) (M' x) (N' x)) -> type. +%mode sub-compat1 +X1 +X2 +X3 +X4 -X5. + +- : sub-compat1 ([_] [_] tm-eq/i) ([_] tm-eq/i) ([_] tm-eq/i) D D. + +%worlds (csig | asig | var) (sub-compat1 _ _ _ _ _). +%total {} (sub-compat1 _ _ _ _ _). +%reduces D = D' (sub-compat1 _ _ _ D D'). + + +atpsub-compat : ({x} atp-eq (P x) (P' x)) + -> tm-eq M M' + -> atp-eq Q Q' + -> atpsub ([x] P x) M Q +%% + -> atpsub ([x] P' x) M' Q' -> type. +%mode atpsub-compat +X1 +X2 +X3 +X4 -X5. + +- : atpsub-compat ([_] atp-eq/i) tm-eq/i atp-eq/i D D. + +%worlds (csig | asig | var) (atpsub-compat _ _ _ _ _). +%total {} (atpsub-compat _ _ _ _ _). + +tpsub-compat : ({x} tp-eq (A x) (A' x)) + -> tm-eq M M' + -> tp-eq B B' + -> tpsub ([x] A x) M B +%% + -> tpsub ([x] A' x) M' B' -> type. +%mode tpsub-compat +X1 +X2 +X3 +X4 -X5. + +- : tpsub-compat ([_] tp-eq/i) tm-eq/i tp-eq/i D D. + +%worlds (csig | asig | var) (tpsub-compat _ _ _ _ _). +%total {} (tpsub-compat _ _ _ _ _). + +ksub-compat : ({x} kind-eq (K x) (K' x)) + -> tm-eq M M' + -> kind-eq Kx Kx' + -> ksub ([x] K x) M Kx +%% + -> ksub ([x] K' x) M' Kx' -> type. +%mode ksub-compat +X1 +X2 +X3 +X4 -X5. + +- : ksub-compat ([_] kind-eq/i) tm-eq/i kind-eq/i D D. + +%worlds (csig | asig | var) (ksub-compat _ _ _ _ _). +%total {} (ksub-compat _ _ _ _ _). + +simp-compat : tp-eq A A' -> stp-eq T T' -> simp A T -> simp A' T' -> type. +%mode simp-compat +X1 +X2 +X3 -X4. + +- : simp-compat tp-eq/i stp-eq/i D D. + +%worlds (csig | asig | var | evar) (simp-compat _ _ _ _). +%total {} (simp-compat _ _ _ _). + + +ksimp-compat : kind-eq K K' -> skind-eq H H' -> ksimp K H -> ksimp K' H' -> type. +%mode ksimp-compat +X1 +X2 +X3 -X4. + +- : ksimp-compat kind-eq/i skind-eq/i D D. + +%worlds (csig | asig | var | evar) (ksimp-compat _ _ _ _). +%total {} (ksimp-compat _ _ _ _). + + +lookup-compat : ctx-eq G G' -> atm-eq X X' -> tp-eq A A' -> lookup G X A + -> lookup G' X' A' -> type. +%mode lookup-compat +X1 +X2 +X3 +X4 -X5. + +- : lookup-compat ctx-eq/i atm-eq/i tp-eq/i D D. + +%worlds (csig | asig | var) (lookup-compat _ _ _ _ _). +%total {} (lookup-compat _ _ _ _ _). + + +slookup-compat : sctx-eq G G' -> atm-eq X X' -> stp-eq T T' -> slookup G X T + -> slookup G' X' T' -> type. +%mode slookup-compat +X1 +X2 +X3 +X4 -X5. + +- : slookup-compat sctx-eq/i atm-eq/i stp-eq/i D D. + +%worlds (csig | asig | var | evar) (slookup-compat _ _ _ _ _). +%total {} (slookup-compat _ _ _ _ _). + +stp-leq-compat : stp-eq S S' -> stp-eq T T' -> stp-leq S T -> + stp-leq S' T' -> type. +%mode stp-leq-compat +X1 +X2 +X3 -X4. + +- : stp-leq-compat stp-eq/i stp-eq/i D D. + +%worlds (csig | asig | evar) (stp-leq-compat _ _ _ _). +%total {} (stp-leq-compat _ _ _ _). + +%% functionality %% + +tm-eq-fun : tm-eq M M1 -> tm-eq M M2 -> tm-eq M1 M2 -> type. +%mode tm-eq-fun +X1 +X2 -X3. + +- : tm-eq-fun tm-eq/i tm-eq/i tm-eq/i. + +%worlds (csig | asig | var | bind | ovar) (tm-eq-fun _ _ _). +%total {} (tm-eq-fun _ _ _). + +stp-eq-leq : stp-eq S T -> stp-leq S T -> type. +%mode stp-eq-leq +X1 -X2. + +- : stp-eq-leq stp-eq/i stp-leq/eq. + +%worlds (csig | asig | var | bind | ovar | evar) (stp-eq-leq _ _). +%total {} (stp-eq-leq _ _). + + +%%% for expansion %%% + +expand-resp : atm-eq R R' -> stp-eq T T' -> tm-eq M M' + -> expand R T M + -> expand R' T' M' -> type. +%mode expand-resp +X1 +X2 +X3 +X4 -X5. + +- : expand-resp atm-eq/i stp-eq/i tm-eq/i D D. + +%worlds (csig | asig | var | evar) (expand-resp _ _ _ _ _). +%total {} (expand-resp _ _ _ _ _). +%reduces D = D' (expand-resp _ _ _ D D'). + +tpexpand-resp : atp-eq P P' -> skind-eq H H' -> tp-eq A A' + -> tpexpand P H A -> tpexpand P' H' A' -> type. +%mode tpexpand-resp +X1 +X2 +X3 +X4 -X5. + +- : tpexpand-resp atp-eq/i skind-eq/i tp-eq/i D D. + +%worlds (csig | asig | var | evar) (tpexpand-resp _ _ _ _ _). +%total {} (tpexpand-resp _ _ _ _ _). +%reduces D = D' (tpexpand-resp _ _ _ D D'). + + +expand-resp-1 : ({x:atm} atm-eq (R x) (R' x)) + -> stp-eq T T' + -> ({x} tm-eq (M x) (M' x)) + -> ({x} expand (R x) T (M x)) + -> ({x} expand (R' x) T' (M' x)) -> type. +%mode expand-resp-1 +X1 +X2 +X3 +X4 -X5. + +- : expand-resp-1 ([_] atm-eq/i) stp-eq/i ([_] tm-eq/i) D D. + +%worlds (csig | asig | var) (expand-resp-1 _ _ _ _ _). +%total {} (expand-resp-1 _ _ _ _ _). +%reduces D = D' (expand-resp-1 _ _ _ D D'). + +expand-resp-2 : ({x:atm} {y:atm} atm-eq (R x y) (R' x y)) + -> stp-eq T T' + -> ({x} {y} tm-eq (M x y) (M' x y)) + -> ({x} {y} expand (R x y) T (M x y)) + -> ({x} {y} expand (R' x y) T' (M' x y)) -> type. +%mode expand-resp-2 +X1 +X2 +X3 +X4 -X5. + +- : expand-resp-2 ([_] [_] atm-eq/i) stp-eq/i ([_] [_] tm-eq/i) D D. + +%worlds (csig | asig | var) (expand-resp-2 _ _ _ _ _). +%total {} (expand-resp-2 _ _ _ _ _). +%reduces D = D' (expand-resp-2 _ _ _ D D'). + + +%% Noncanonical LF %% + +etm-eq : etm -> etm -> type. +etm-eq/i : etm-eq EM EM. + +etp-eq : etp -> etp -> type. +etp-eq/i : etp-eq EA EA. + +ekind-eq : ekind -> ekind -> type. +ekind-eq/i : ekind-eq EK EK. + + +etm-eq-sym : etm-eq A A' -> etm-eq A' A -> type. +%mode etm-eq-sym +X1 -X2. + +- : etm-eq-sym etm-eq/i etm-eq/i. + +%worlds (ecsig | easig | evar) (etm-eq-sym _ _). +%total {} (etm-eq-sym _ _). + + + +etp-eq-sym : etp-eq A A' -> etp-eq A' A -> type. +%mode etp-eq-sym +X1 -X2. + +- : etp-eq-sym etp-eq/i etp-eq/i. + +%worlds (ecsig | easig | evar) (etp-eq-sym _ _). +%total {} (etp-eq-sym _ _). + + +ekind-eq-sym : ekind-eq A A' -> ekind-eq A' A -> type. +%mode ekind-eq-sym +X1 -X2. + +- : ekind-eq-sym ekind-eq/i ekind-eq/i. + +%worlds (ecsig | easig | evar) (ekind-eq-sym _ _). +%total {} (ekind-eq-sym _ _). + + +etp-eq-trans : etp-eq A A' -> etp-eq A' A'' -> etp-eq A A'' -> type. +%mode etp-eq-trans +X1 +X2 -X3. + +- : etp-eq-trans etp-eq/i etp-eq/i etp-eq/i. + +%worlds (ecsig | easig | evar) (etp-eq-trans _ _ _). +%total {} (etp-eq-trans _ _ _). + + +ekind-eq-trans : ekind-eq A A' -> ekind-eq A' A'' -> ekind-eq A A'' -> type. +%mode ekind-eq-trans +X1 +X2 -X3. + +- : ekind-eq-trans ekind-eq/i ekind-eq/i ekind-eq/i. + +%worlds (ecsig | easig | evar) (ekind-eq-trans _ _ _). +%total {} (ekind-eq-trans _ _ _). + + +%% compatibility and injectivity %% + +elam-compat : etp-eq A A' -> ({x} etm-eq (M x) (M' x)) + -> etm-eq (elam A ([x] M x)) (elam A' ([x] M' x)) + -> type. +%mode elam-compat +X1 +X2 -X3. + +- : elam-compat etp-eq/i ([x] etm-eq/i) etm-eq/i. + +%worlds (ecsig | easig | evar) (elam-compat _ _ _). +%total {} (elam-compat _ _ _). + +eapp-compat : etm-eq A A' -> etm-eq M M' + -> etm-eq (eapp A M) (eapp A' M') -> type. +%mode eapp-compat +X1 +X2 -X3. + +- : eapp-compat etm-eq/i etm-eq/i etm-eq/i. + +%worlds (ecsig | easig | evar) (eapp-compat _ _ _). +%total {} (eapp-compat _ _ _). + + + +eaapp-compat : etp-eq A A' -> etm-eq M M' + -> etp-eq (eaapp A M) (eaapp A' M') -> type. +%mode eaapp-compat +X1 +X2 -X3. + +- : eaapp-compat etp-eq/i etm-eq/i etp-eq/i. + +%worlds (ecsig | easig | evar) (eaapp-compat _ _ _). +%total {} (eaapp-compat _ _ _). + +ealam-compat : etp-eq A A' -> ({x} etp-eq (B x) (B' x)) + -> etp-eq (ealam A ([x] B x)) (ealam A' ([x] B' x)) + -> type. +%mode ealam-compat +X1 +X2 -X3. + +- : ealam-compat etp-eq/i ([x] etp-eq/i) etp-eq/i. + +%worlds (ecsig | easig | evar) (ealam-compat _ _ _). +%total {} (ealam-compat _ _ _). + + +epi-compat : etp-eq A A' -> ({x} etp-eq (B x) (B' x)) + -> etp-eq (epi A ([x] B x)) (epi A' ([x] B' x)) -> type. +%mode epi-compat +X1 +X2 -X3. + +- : epi-compat etp-eq/i ([x] etp-eq/i) etp-eq/i. + +%worlds (ecsig | easig | evar) (epi-compat _ _ _). +%total {} (epi-compat _ _ _). + +ekpi-compat : etp-eq A A' -> ({x} ekind-eq (K x) (K' x)) + -> ekind-eq (ekpi A ([x] K x)) (ekpi A' ([x] K' x)) -> type. +%mode ekpi-compat +X1 +X2 -X3. + +- : ekpi-compat etp-eq/i ([x] ekind-eq/i) ekind-eq/i. + +%worlds (ecsig | easig | evar) (ekpi-compat _ _ _). +%total {} (ekpi-compat _ _ _). + + +eaapp-inj : etp-eq (eaapp A M) (eaapp A' M') + -> etp-eq A A' + -> etm-eq M M' -> type. +%mode eaapp-inj +X1 -X2 -X3. + +- : eaapp-inj etp-eq/i etp-eq/i etm-eq/i. + +%worlds (ecsig | easig | evar) (eaapp-inj _ _ _). +%total {} (eaapp-inj _ _ _). + +epi-inj : etp-eq (epi A ([x] K x)) (epi A' ([x] K' x)) + -> etp-eq A A' + -> ({x} etp-eq (K x) (K' x)) -> type. +%mode epi-inj +X1 -X2 -X3. + +- : epi-inj etp-eq/i etp-eq/i ([x] etp-eq/i). + +%worlds (ecsig | easig | evar) (epi-inj _ _ _). +%total {} (epi-inj _ _ _). + +ealam-inj : etp-eq (ealam A ([x] K x)) (ealam A' ([x] K' x)) + -> etp-eq A A' + -> ({x} etp-eq (K x) (K' x)) -> type. +%mode ealam-inj +X1 -X2 -X3. + +- : ealam-inj etp-eq/i etp-eq/i ([x] etp-eq/i). + +%worlds (ecsig | easig | evar) (ealam-inj _ _ _). +%total {} (ealam-inj _ _ _). + +ealam-inj-str : ({x:etm} etp-eq (ealam (A x) (B x)) C) + -> ({x} etp-eq (A x) A') + -> ({x} {y} etp-eq (B x y) (B' y)) -> type. +%mode ealam-inj-str +X1 -X2 -X3. + +- : ealam-inj-str ([x] etp-eq/i) ([x] etp-eq/i) ([x] [y] etp-eq/i). + +%worlds (ecsig | easig | evar) (ealam-inj-str _ _ _). +%total {} (ealam-inj-str _ _ _). + + +ekind-eq-pi-strengthen : ({x:etm} ekind-eq C (ekpi (A x) ([y] B x y))) + -> ({x} etp-eq A' (A x)) + -> ({x} {y} ekind-eq (B' y) (B x y)) -> type. +%mode ekind-eq-pi-strengthen +X1 -X2 -X3. + +- : ekind-eq-pi-strengthen ([x] ekind-eq/i) ([x] etp-eq/i) ([x] [y] ekind-eq/i). + +%worlds (ecsig | easig | evar) (ekind-eq-pi-strengthen _ _ _). +%total {} (ekind-eq-pi-strengthen _ _ _). + +etp-eq-pi-strengthen : ({x:etm} etp-eq C (epi (A x) ([y] B x y))) + -> ({x} etp-eq A' (A x)) + -> ({x} {y} etp-eq (B' y) (B x y)) -> type. +%mode etp-eq-pi-strengthen +X1 -X2 -X3. + +- : etp-eq-pi-strengthen ([x] etp-eq/i) ([x] etp-eq/i) ([x] [y] etp-eq/i). + +%worlds (ecsig | easig | evar) (etp-eq-pi-strengthen _ _ _). +%total {} (etp-eq-pi-strengthen _ _ _). + +etm-eq-app-strengthen : ({x:etm} etm-eq O (eapp (M x) (N x))) + -> ({x} etm-eq M' (M x)) + -> ({x} etm-eq N' (N x)) -> type. +%mode etm-eq-app-strengthen +X1 -X2 -X3. + +- : etm-eq-app-strengthen ([x] etm-eq/i) ([x] etm-eq/i) ([x] etm-eq/i). + +%worlds (ecsig | easig | evar) (etm-eq-app-strengthen _ _ _). +%total {} (etm-eq-app-strengthen _ _ _). + + +ekpi-inj : ekind-eq (ekpi A ([x] K x)) (ekpi A' ([x] K' x)) + -> etp-eq A A' + -> ({x} ekind-eq (K x) (K' x)) -> type. +%mode ekpi-inj +X1 -X2 -X3. + +- : ekpi-inj ekind-eq/i etp-eq/i ([x] ekind-eq/i). + +%worlds (ecsig | easig | evar) (ekpi-inj _ _ _). +%total {} (ekpi-inj _ _ _). + + +ekof-resp : ekof EA EK -> etp-eq EA EA' -> ekind-eq EK EK' + -> ekof EA' EK' -> type. +%mode ekof-resp +X1 +X2 +X3 -X4. + +- : ekof-resp D etp-eq/i ekind-eq/i D. + +%worlds (ecsig | easig | evar | ebind | eovar) (ekof-resp _ _ _ _). +%total {} (ekof-resp _ _ _ _). +%reduces D = D' (ekof-resp D _ _ D'). + +ewfkind-resp : ewfkind EK -> ekind-eq EK EK' + -> ewfkind EK' -> type. +%mode ewfkind-resp +X1 +X2 -X3. + +- : ewfkind-resp D ekind-eq/i D. + +%worlds (ecsig | easig | evar | ebind | eovar) (ewfkind-resp _ _ _). +%total {} (ewfkind-resp _ _ _). +%reduces D = D' (ewfkind-resp D _ D'). + + +ekof-resp-underbind : ({x} evof x A -> ekof (B x) (K x)) + -> etp-eq A A' + -> ({x} etp-eq (B x) (B' x)) + -> ({x} ekind-eq (K x) (K' x)) +%% + -> ({x} evof x A' -> ekof (B' x) (K' x)) -> type. +%mode ekof-resp-underbind +X1 +X2 +X3 +X4 -X5. + +- : ekof-resp-underbind + ([x] [d] D x d) etp-eq/i ([x] etp-eq/i) ([x] ekind-eq/i) + ([x] [d] D x d). + +%worlds (ecsig | easig | ebind | evar) (ekof-resp-underbind _ _ _ _ _). +%total {} (ekof-resp-underbind _ _ _ _ _). +%reduces D = D' (ekof-resp-underbind D _ _ _ D'). + +ekof-resp-underbind-1 : ({x:etm} + {y} evof y (A x) -> ekof (B x y) (K x y)) + -> ({x} etp-eq (A x) (A' x)) + -> ({x} {y} etp-eq (B x y) (B' x y)) + -> ({x} {y} ekind-eq (K x y) (K' x y)) +%% + -> ({x} + {y} evof y (A' x) + -> ekof (B' x y) (K' x y)) + -> type. +%mode ekof-resp-underbind-1 +X1 +X2 +X3 +X4 -X5. + +- : ekof-resp-underbind-1 + D ([x] etp-eq/i) ([x] [y] etp-eq/i) ([x] [y] ekind-eq/i) + D. + +%worlds (ecsig | easig | ebind | evar) (ekof-resp-underbind-1 _ _ _ _ _). +%total {} (ekof-resp-underbind-1 _ _ _ _ _). +%reduces D = D' (ekof-resp-underbind-1 D _ _ _ D'). + +ewfkind-resp-underbind-1 : ({x:etm} {y} evof y (A x) -> ewfkind (K x y)) + -> ({x} etp-eq (A x) (A' x)) + -> ({x} {y} ekind-eq (K x y) (K' x y)) +%% + -> ({x} {y} evof y (A' x) -> ewfkind (K' x y)) + -> type. +%mode ewfkind-resp-underbind-1 +X1 +X2 +X3 -X5. + +- : ewfkind-resp-underbind-1 D ([x] etp-eq/i) ([x] [y] ekind-eq/i) D. + +%worlds (ecsig | easig | ebind | evar) (ewfkind-resp-underbind-1 _ _ _ _). +%total {} (ewfkind-resp-underbind-1 _ _ _ _). +%reduces D = D' (ewfkind-resp-underbind-1 D _ _ D'). + + +eqkind-resp : eqkind EK1 EK2 -> ekind-eq EK1 EK1' -> ekind-eq EK2 EK2' + -> eqkind EK1' EK2' -> type. +%mode eqkind-resp +X1 +X2 +X3 -X4. + +- : eqkind-resp D ekind-eq/i ekind-eq/i D. + +%worlds (ecsig | easig | evar | tbind | ebind) (eqkind-resp _ _ _ _). +%total {} (eqkind-resp _ _ _ _). +%reduces D = D' (eqkind-resp D _ _ D'). + +eqtp-resp : eqtp EA1 EA2 EK -> etp-eq EA1 EA1' -> etp-eq EA2 EA2' + -> ekind-eq EK EK' +%% + -> eqtp EA1' EA2' EK' -> type. +%mode eqtp-resp +X0 +X1 +X2 +X3 -X4. + +- : eqtp-resp D etp-eq/i etp-eq/i ekind-eq/i D. + +%worlds (ecsig | easig | tbind | ebind) (eqtp-resp _ _ _ _ _). +%total {} (eqtp-resp _ _ _ _ _). +%reduces D = D' (eqtp-resp D _ _ _ D'). + +eqtm-resp : eqtm EA1 EA2 EK -> etm-eq EA1 EA1' -> etm-eq EA2 EA2' + -> etp-eq EK EK' +%% + -> eqtm EA1' EA2' EK' -> type. +%mode eqtm-resp +X0 +X1 +X2 +X3 -X4. + +- : eqtm-resp D etm-eq/i etm-eq/i etp-eq/i D. + +%worlds (ecsig | easig | tbind | eofblock | ebind) (eqtm-resp _ _ _ _ _). +%total {} (eqtm-resp _ _ _ _ _). +%reduces D = D' (eqtm-resp D _ _ _ D'). + +eqtp-resp-underbind-1 : ({x:etm} {y} evof y (A x) -> eqtp (C x y) (B x y) (K x y)) + -> ({x} etp-eq (A x) (A' x)) + -> ({x} {y} etp-eq (C x y) (C' x y)) + -> ({x} {y} etp-eq (B x y) (B' x y)) + -> ({x} {y} ekind-eq (K x y) (K' x y)) +%% + -> ({x} {y} evof y (A' x) + -> eqtp (C' x y) (B' x y) (K' x y)) + -> type. +%mode eqtp-resp-underbind-1 +X1 +X2 +X3 +X4 +X5 -X6. + +- : eqtp-resp-underbind-1 + D + ([x] etp-eq/i) ([x] [y] etp-eq/i) + ([x] [y] etp-eq/i) ([x] [y] ekind-eq/i) + D. + +%worlds (ecsig | easig | ebind | evar) (eqtp-resp-underbind-1 _ _ _ _ _ _). +%total {} (eqtp-resp-underbind-1 _ _ _ _ _ _). +%reduces D = D' (eqtp-resp-underbind-1 D _ _ _ _ D'). + + +eqtm-resp-underbind-1 : ({x:etm} {y} evof y (A x) -> eqtm (C x y) (B x y) (K x y)) + -> ({x} etp-eq (A x) (A' x)) + -> ({x} {y} etm-eq (C x y) (C' x y)) + -> ({x} {y} etm-eq (B x y) (B' x y)) + -> ({x} {y} etp-eq (K x y) (K' x y)) +%% + -> ({x} {y} evof y (A' x) + -> eqtm (C' x y) (B' x y) (K' x y)) + -> type. +%mode eqtm-resp-underbind-1 +X1 +X2 +X3 +X4 +X5 -X6. + +- : eqtm-resp-underbind-1 + D + ([x] etp-eq/i) ([x] [y] etm-eq/i) + ([x] [y] etm-eq/i) ([x] [y] etp-eq/i) + D. + +%worlds (ecsig | easig | ebind | evar) (eqtm-resp-underbind-1 _ _ _ _ _ _). +%total {} (eqtm-resp-underbind-1 _ _ _ _ _ _). +%reduces D = D' (eqtm-resp-underbind-1 D _ _ _ _ D'). + +eqkind-resp-underbind-1 : ({x:etm} {y} evof y (A x) -> eqkind (C x y) (B x y)) + -> ({x} etp-eq (A x) (A' x)) + -> ({x} {y} ekind-eq (C x y) (C' x y)) + -> ({x} {y} ekind-eq (B x y) (B' x y)) +%% + -> ({x} {y} evof y (A' x) + -> eqkind (C' x y) (B' x y)) + -> type. +%mode eqkind-resp-underbind-1 +X1 +X2 +X3 +X4 -X5. + +- : eqkind-resp-underbind-1 + D ([x] etp-eq/i) ([x] [y] ekind-eq/i) ([x] [y] ekind-eq/i) + D. + +%worlds (ecsig | easig | ebind | evar) (eqkind-resp-underbind-1 _ _ _ _ _). +%total {} (eqkind-resp-underbind-1 _ _ _ _ _). +%reduces D = D' (eqkind-resp-underbind-1 D _ _ _ D'). + + +% XXX needed? reproven elsewhere? +eqkind-ekind-eq : eqkind EK ektype -> ekind-eq EK ektype -> type. +%mode eqkind-ekind-eq +X1 -X2. + +eqkind-ekind-eq' : eqkind ektype EK -> ekind-eq EK ektype -> type. +%mode eqkind-ekind-eq' +X1 -X2. + +- : eqkind-ekind-eq eqkind/tp ekind-eq/i. + +- : eqkind-ekind-eq (eqkind/sym (Deqkind : eqkind ektype EK)) + Deq + <- eqkind-ekind-eq' Deqkind + (Deq : ekind-eq EK ektype). + +- : eqkind-ekind-eq + (eqkind/trans + (D1 : eqkind EK2 ektype) + (D2 : eqkind EK1 EK2)) + D' + <- eqkind-ekind-eq D1 + (D3 : ekind-eq EK2 ektype) + <- eqkind-resp D2 ekind-eq/i D3 + (D : eqkind EK1 ektype) + <- eqkind-ekind-eq D + (D' : ekind-eq EK1 ektype). + +- : eqkind-ekind-eq (eqkind/refl _) ekind-eq/i. + +%% + +- : eqkind-ekind-eq' eqkind/tp ekind-eq/i. + +- : eqkind-ekind-eq' (eqkind/sym (D: eqkind EK1 ektype)) + D' + <- eqkind-ekind-eq D + (D' : ekind-eq EK1 ektype). + +- : eqkind-ekind-eq' + (eqkind/trans + (D1 : eqkind EK2 EK1) + (D2 : eqkind ektype EK2)) + D + <- eqkind-ekind-eq' D2 + (D3 : ekind-eq EK2 ektype) + <- eqkind-resp D1 D3 ekind-eq/i + (D4 : eqkind ektype EK1) + <- eqkind-ekind-eq' D4 + (D : ekind-eq EK1 ektype). + +- : eqkind-ekind-eq' (eqkind/refl _) ekind-eq/i. + +%worlds (ecsig | easig | bind) (eqkind-ekind-eq _ _) (eqkind-ekind-eq' _ _). +%total (D1 D2) (eqkind-ekind-eq D1 _) (eqkind-ekind-eq' D2 _). + + +%% EL explicit contexts stuff %% + +ectx-eq : ectx -> ectx -> type. +ectx-eq/i : ectx-eq G G. + +ectx-eq-sym : ectx-eq G G' -> ectx-eq G' G -> type. +%mode ectx-eq-sym +X1 -X2. + +- : ectx-eq-sym ectx-eq/i ectx-eq/i. + +%worlds (ecsig | easig | evar | eovar) (ectx-eq-sym _ _). +%total {} (ectx-eq-sym _ _). + +econs-compat : ectx-eq G G' -> etm-eq X X' -> etp-eq A A' + -> ectx-eq (econs G X A) (econs G' X' A') -> type. +%mode econs-compat +X1 +X2 +X3 -X4. + +- : econs-compat ectx-eq/i etm-eq/i etp-eq/i ectx-eq/i. + +%worlds (ecsig | easig | evar | eovar) (econs-compat _ _ _ _). +%total {} (econs-compat _ _ _ _). + +ecsub-resp : ecsub G M Gx + -> ({x} ectx-eq (G x) (G' x)) + -> etm-eq M M' + -> ectx-eq Gx Gx' +%% + -> ecsub G' M' Gx' -> type. +%mode ecsub-resp +X1 +X2 +X3 +X4 -X5. + +- : ecsub-resp D ([x] ectx-eq/i) etm-eq/i ectx-eq/i D. + +%worlds (ecsig | easig | evar | eovar) (ecsub-resp _ _ _ _ _). +%total {} (ecsub-resp _ _ _ _ _). + +eappend-resp : ectx-eq G1 G1' -> ectx-eq G2 G2' -> ectx-eq G G' + -> eappend G1 G2 G + -> eappend G1' G2' G' -> type. +%mode eappend-resp +X1 +X2 +X3 +X4 -X5. + +- : eappend-resp ectx-eq/i ectx-eq/i ectx-eq/i D D. + +%worlds (ecsig | easig | evar | eovar) (eappend-resp _ _ _ _ _). +%total {} (eappend-resp _ _ _ _ _). + + +eqtpe-resp : ectx-eq G G' -> etp-eq A A' -> etp-eq B B' -> ekind-eq K K' + -> eqtpe G A B K -> eqtpe G' A' B' K' -> type. +%mode eqtpe-resp +X1 +X2 +X3 +X4 +X5 -X6. + +- : eqtpe-resp ectx-eq/i etp-eq/i etp-eq/i ekind-eq/i D D. + +%worlds (ecsig | easig | evar | ebind | eovar) (eqtpe-resp _ _ _ _ _ _). +%total {} (eqtpe-resp _ _ _ _ _ _). + +eqkinde-resp : ectx-eq G G' -> ekind-eq K K' -> ekind-eq L L' + -> eqkinde G K L -> eqkinde G' K' L' -> type. +%mode eqkinde-resp +X1 +X2 +X3 +X4 -X5. + +- : eqkinde-resp ectx-eq/i ekind-eq/i ekind-eq/i D D. + +%worlds (ecsig | easig | evar | ebind | eovar) (eqkinde-resp _ _ _ _ _). +%total {} (eqkinde-resp _ _ _ _ _). +%reduces D = D' (eqkinde-resp _ _ _ D D'). + + +eqtme-resp : ectx-eq G G' -> etm-eq A A' -> etm-eq B B' -> etp-eq K K' + -> eqtme G A B K -> eqtme G' A' B' K' -> type. +%mode eqtme-resp +X1 +X2 +X3 +X4 +X5 -X6. + +- : eqtme-resp ectx-eq/i etm-eq/i etm-eq/i etp-eq/i D D. + +%worlds (ecsig | easig | evar | ebind | eovar) (eqtme-resp _ _ _ _ _ _). +%total {} (eqtme-resp _ _ _ _ _ _). + + +ewfkinde-resp : ectx-eq G G' -> ekind-eq K K' -> ewfkinde G K + -> ewfkinde G' K' -> type. +%mode ewfkinde-resp +X1 +X2 +X3 -X5. + +- : ewfkinde-resp ectx-eq/i ekind-eq/i D D. + +%worlds (ecsig | easig | evar | ebind | eovar) (ewfkinde-resp _ _ _ _). +%total {} (ewfkinde-resp _ _ _ _). + + +ekofe-resp : ectx-eq G G' -> etp-eq A A' -> ekind-eq K K' -> ekofe G A K + -> ekofe G' A' K' -> type. +%mode ekofe-resp +X1 +X2 +X3 +X4 -X5. + +- : ekofe-resp ectx-eq/i etp-eq/i ekind-eq/i D D. + +%worlds (ecsig | easig | evar | ebind | eovar) (ekofe-resp _ _ _ _ _). +%total {} (ekofe-resp _ _ _ _ _). + +eof-resp : etm-eq M M' -> etp-eq A A' -> eof M A -> eof M' A' -> type. +%mode eof-resp +X2 +X3 +X4 -X5. + +- : eof-resp etm-eq/i etp-eq/i D D. + +%worlds (ecsig | easig | evar | ebind | eovar) (eof-resp _ _ _ _). +%total {} (eof-resp _ _ _ _). + +eof-resp-underbind-1 : ({x:etm} + {y} evof y (A x) -> eof (B x y) (K x y)) + -> ({x} etp-eq (A x) (A' x)) + -> ({x} {y} etm-eq (B x y) (B' x y)) + -> ({x} {y} etp-eq (K x y) (K' x y)) +%% + -> ({x} + {y} evof y (A' x) + -> eof (B' x y) (K' x y)) + -> type. +%mode eof-resp-underbind-1 +X1 +X2 +X3 +X4 -X5. + +- : eof-resp-underbind-1 + D ([x] etp-eq/i) ([x] [y] etm-eq/i) ([x] [y] etp-eq/i) + D. + +%worlds (ecsig | easig | ebind | evar) (eof-resp-underbind-1 _ _ _ _ _). +%total {} (eof-resp-underbind-1 _ _ _ _ _). +%reduces D = D' (eof-resp-underbind-1 D _ _ _ D'). + + +eofe-resp : ectx-eq G G' -> etm-eq M M' -> etp-eq A A' -> eofe G M A + -> eofe G' M' A' -> type. +%mode eofe-resp +X1 +X2 +X3 +X4 -X5. + +- : eofe-resp ectx-eq/i etm-eq/i etp-eq/i D D. + +%worlds (ecsig | easig | evar | ebind | eovar) (eofe-resp _ _ _ _ _). +%total {} (eofe-resp _ _ _ _ _). + +elookup-resp : elookup G X A -> ectx-eq G G' -> etm-eq X X' -> etp-eq A A' + -> elookup G' X' A' -> type. +%mode elookup-resp +X1 +X2 +X3 +X4 -X5. + +- : elookup-resp D ectx-eq/i etm-eq/i etp-eq/i D. + +%worlds (ecsig | easig | evar | ebind | eovar) (elookup-resp _ _ _ _ _). +%total {} (elookup-resp _ _ _ _ _). + +ecof-resp : etp-eq A A' -> ecof C A -> ecof C A' -> type. +%mode ecof-resp +X1 +X2 -X3. + +- : ecof-resp etp-eq/i D D. + +%worlds (ecsig | easig | evar) (ecof-resp _ _ _). +%total {} (ecof-resp _ _ _). + +eckof-resp : ekind-eq A A' -> eckof C A -> eckof C A' -> type. +%mode eckof-resp +X1 +X2 -X3. + +- : eckof-resp ekind-eq/i D D. + +%worlds (ecsig | easig | evar) (eckof-resp _ _ _). +%total {} (eckof-resp _ _ _). + + +cons-compat : ctx-eq G G' -> atm-eq X X' -> tp-eq S S' + -> ctx-eq (cons G X S) (cons G' X' S') -> type. +%mode cons-compat +X1 +X2 +X3 -X4. + +- : cons-compat ctx-eq/i atm-eq/i tp-eq/i ctx-eq/i. + +%worlds (csig | asig | var | evar) (cons-compat _ _ _ _). +%total {} (cons-compat _ _ _ _). + +scons-compat : sctx-eq G G' -> atm-eq X X' -> stp-eq S S' + -> sctx-eq (scons G X S) (scons G' X' S') -> type. +%mode scons-compat +X1 +X2 +X3 -X4. + +- : scons-compat sctx-eq/i atm-eq/i stp-eq/i sctx-eq/i. + +%worlds (csig | asig | var | evar) (scons-compat _ _ _ _). +%total {} (scons-compat _ _ _ _). + +append-resp : ctx-eq G1 G1' -> ctx-eq G2 G2' -> ctx-eq G G' + -> append G1 G2 G + -> append G1' G2' G' -> type. +%mode append-resp +X1 +X2 +X3 +X4 -X5. + +- : append-resp ctx-eq/i ctx-eq/i ctx-eq/i D D. + +%worlds (csig | asig | var | evar) (append-resp _ _ _ _ _). +%total {} (append-resp _ _ _ _ _). + +simpctx-resp : simpctx G Gs -> ctx-eq G G' -> sctx-eq Gs Gs' + -> simpctx G' Gs' -> type. +%mode simpctx-resp +X1 +X2 +X3 -X4. + +- : simpctx-resp D ctx-eq/i sctx-eq/i D. + +%worlds (csig | asig | var) (simpctx-resp _ _ _ _). +%total {} (simpctx-resp _ _ _ _). + +vof-resp : vof X A -> atm-eq X X' -> tp-eq A A' -> vof X' A' -> type. +%mode vof-resp +X1 +X2 +X3 -X4. + +- : vof-resp D atm-eq/i tp-eq/i D. + +%worlds (csig | asig | var | bind) (vof-resp _ _ _ _). +%total {} (vof-resp _ _ _ _). + +etpsubst-compat : ({x} etp-eq (M x) (M' x)) -> etm-eq N N' + -> etp-eq (M N) (M' N') -> type. +%mode etpsubst-compat +X1 +X2 -X3. + +- : etpsubst-compat ([_] etp-eq/i) etm-eq/i etp-eq/i. + +%worlds (ecsig | easig | evar) (etpsubst-compat _ _ _). +%total {} (etpsubst-compat _ _ _). + + +esubst-compat : ({x} etm-eq (M x) (M' x)) -> etm-eq N N' + -> etm-eq (M N) (M' N') -> type. +%mode esubst-compat +X1 +X2 -X3. + +- : esubst-compat ([_] etm-eq/i) etm-eq/i etm-eq/i. + +%worlds (ecsig | easig | evar) (esubst-compat _ _ _). +%total {} (esubst-compat _ _ _). + +eksubst-compat : ({x} ekind-eq (K x) (K' x)) -> etm-eq M M' + -> ekind-eq (K M) (K' M') -> type. +%mode eksubst-compat +X1 +X2 -X3. + +- : eksubst-compat ([_] ekind-eq/i) etm-eq/i ekind-eq/i. + +%worlds (ecsig | easig | evar) (eksubst-compat _ _ _). +%total {} (eksubst-compat _ _ _). + +evof-resp : evof X A -> etm-eq X X' -> etp-eq A A' -> evof X' A' -> type. +%mode evof-resp +X1 +X2 +X3 -X4. + +- : evof-resp D etm-eq/i etp-eq/i D. + +%worlds (ecsig | easig | var | bind | evar | ovar | tbind | eofblock) + (evof-resp _ _ _ _). +%total {} (evof-resp _ _ _ _). + + +%%%% for translation %%%% + +trans-resp : trans EM M A -> etm-eq EM EM' -> tm-eq M M' -> tp-eq A A' + -> trans EM' M' A' -> type. +%mode trans-resp +X1 +X2 +X3 +X4 -X5. + +- : trans-resp D etm-eq/i tm-eq/i tp-eq/i D. + +%worlds (csig | asig | bind | tbind) (trans-resp _ _ _ _ _). +%total {} (trans-resp _ _ _ _ _). + + +tptrans-resp : tptrans EA A K -> etp-eq EA EA' -> tp-eq A A' -> kind-eq K K' + -> tptrans EA' A' K' -> type. +%mode tptrans-resp +X1 +X2 +X3 +X4 -X5. + +- : tptrans-resp D etp-eq/i tp-eq/i kind-eq/i D. + +%worlds (csig | asig | var | bind | ovar | tbind) (tptrans-resp _ _ _ _ _). +%total {} (tptrans-resp _ _ _ _ _). + + +ktrans-resp : ktrans EK K -> ekind-eq EK EK' -> kind-eq K K' + -> ktrans EK' K' -> type. +%mode ktrans-resp +X1 +X2 +X3 -X4. + +- : ktrans-resp D ekind-eq/i kind-eq/i D. + +%worlds (csig | asig | bind | tbind) (ktrans-resp _ _ _ _). +%total {} (ktrans-resp _ _ _ _). + + +trans-resp-underbind : tp-eq A A' + -> ({x} vof x A + -> {ex} vtrans ex x + -> trans (EB ex) (B x) (K x)) + -> ({x} vof x A' -> {ex} vtrans ex x + -> trans (EB ex) (B x) (K x)) -> type. +%mode trans-resp-underbind +X1 +X2 -X3. + +- : trans-resp-underbind tp-eq/i D D. + +%worlds (csig | asig | var | bind | ovar | tbind) (trans-resp-underbind _ _ _). +%total {} (trans-resp-underbind _ _ _). + + +tptrans-resp-underbind : tp-eq A A' + -> ({x} vof x A + -> {ex} vtrans ex x + -> tptrans (EB ex) (B x) (K x)) + -> ({x} vof x A' -> {ex} vtrans ex x + -> tptrans (EB ex) (B x) (K x)) -> type. +%mode tptrans-resp-underbind +X1 +X2 -X3. + +- : tptrans-resp-underbind tp-eq/i D D. + +%worlds (csig | asig | var | bind | ovar | tbind) (tptrans-resp-underbind _ _ _). +%total {} (tptrans-resp-underbind _ _ _). + +ktrans-resp-underbind : tp-eq A A' + -> ({x} vof x A + -> {ex} vtrans ex x + -> ktrans (EK ex) (K x)) + -> ({x} vof x A' -> {ex} vtrans ex x + -> ktrans (EK ex) (K x)) -> type. +%mode ktrans-resp-underbind +X1 +X2 -X3. + +- : ktrans-resp-underbind tp-eq/i D D. + +%worlds (csig | asig | bind | tbind) (ktrans-resp-underbind _ _ _). +%total {} (ktrans-resp-underbind _ _ _). + + +transe-resp : ctx-eq G G' -> etm-eq EM EM' -> tm-eq M M' -> tp-eq A A' + -> transe G EM M A + -> transe G' EM' M' A' -> type. +%mode transe-resp +X1 +X2 +X3 +X4 +X5 -X6. + +- : transe-resp ctx-eq/i etm-eq/i tm-eq/i tp-eq/i D D. + +%worlds (csig | asig | bind | tbind | tobind) (transe-resp _ _ _ _ _ _). +%total {} (transe-resp _ _ _ _ _ _). +%reduces D = D' (transe-resp _ _ _ _ D D'). + +tptranse-resp : ctx-eq G G' -> etp-eq EA EA' -> tp-eq A A' -> kind-eq K K' + -> tptranse G EA A K + -> tptranse G' EA' A' K' -> type. +%mode tptranse-resp +X1 +X2 +X3 +X4 +X5 -X6. + +- : tptranse-resp ctx-eq/i etp-eq/i tp-eq/i kind-eq/i D D. + +%worlds (csig | asig | bind | tbind | tobind) (tptranse-resp _ _ _ _ _ _). +%total {} (tptranse-resp _ _ _ _ _ _). + +%%% for soundness %%% + +convert-resp : convert M A EM -> tm-eq M M' -> tp-eq A A' -> etm-eq EM EM' + -> convert M' A' EM' -> type. +%mode convert-resp +X1 +X2 +X3 +X4 -X5. + +- : convert-resp D tm-eq/i tp-eq/i etm-eq/i D. + +%worlds (csig | asig | tbind | tvar) (convert-resp _ _ _ _ _). +%total {} (convert-resp _ _ _ _ _). +%reduces D = D' (convert-resp D _ _ _ D'). + +tpconvert-resp : tpconvert M A EM -> tp-eq M M' -> kind-eq A A' -> etp-eq EM EM' + -> tpconvert M' A' EM' -> type. +%mode tpconvert-resp +X1 +X2 +X3 +X4 -X5. + +- : tpconvert-resp D tp-eq/i kind-eq/i etp-eq/i D. + +%worlds (csig | asig | tbind) (tpconvert-resp _ _ _ _ _). +%total {} (tpconvert-resp _ _ _ _ _). +%reduces D = D' (tpconvert-resp D _ _ _ D'). + +kconvert-resp : kconvert M EM -> kind-eq M M' -> ekind-eq EM EM' + -> kconvert M' EM' -> type. +%mode kconvert-resp +X1 +X2 +X3 -X4. + +- : kconvert-resp D kind-eq/i ekind-eq/i D. + +%worlds (csig | asig | tbind) (kconvert-resp _ _ _ _). +%total {} (kconvert-resp _ _ _ _). +%reduces D = D' (kconvert-resp D _ _ D'). + + +converte-resp : converte G A K EA + -> ctx-eq G G' + -> tm-eq A A' + -> tp-eq K K' + -> etm-eq EA EA' +%% + -> converte G' A' K' EA' -> type. +%mode converte-resp +X1 +X2 +X3 +X4 +X5 -X6. + +- : converte-resp D ctx-eq/i tm-eq/i tp-eq/i etm-eq/i D. + +%worlds (csig | asig | bind | evvar | tbind | tvar) (converte-resp _ _ _ _ _ _). +%total {} (converte-resp _ _ _ _ _ _). +%reduces D = D' (converte-resp D _ _ _ _ D'). + +tpconverte-resp : tpconverte G A K EA + -> ctx-eq G G' + -> tp-eq A A' + -> kind-eq K K' + -> etp-eq EA EA' +%% + -> tpconverte G' A' K' EA' -> type. +%mode tpconverte-resp +X1 +X2 +X3 +X4 +X5 -X6. + +- : tpconverte-resp D ctx-eq/i tp-eq/i kind-eq/i etp-eq/i D. + +%worlds (csig | asig | bind | tbind | tvar | evvar) (tpconverte-resp _ _ _ _ _ _). +%total {} (tpconverte-resp _ _ _ _ _ _). + +kconverte-resp : kconverte G A EA + -> ctx-eq G G' + -> kind-eq A A' + -> ekind-eq EA EA' +%% + -> kconverte G' A' EA' -> type. +%mode kconverte-resp +X1 +X2 +X3 +X4 -X5. + +- : kconverte-resp D ctx-eq/i kind-eq/i ekind-eq/i D. + +%worlds (csig | asig | bind | evvar | tbind | tvar) (kconverte-resp _ _ _ _ _). +%total {} (kconverte-resp _ _ _ _ _). + +reduce*-resp : reduce* M N -> etm-eq M M' -> etm-eq N N' + -> reduce* M' N' -> type. +%mode reduce*-resp +X1 +X2 +X3 -X4. + +- : reduce*-resp D etm-eq/i etm-eq/i D. + +%worlds (csig | asig | bind | evar | tvar | evvar | tbind) (reduce*-resp _ _ _ _). +%total {} (reduce*-resp _ _ _ _). + +tpreduce*-resp : tpreduce* M N -> etp-eq M M' -> etp-eq N N' + -> tpreduce* M' N' -> type. +%mode tpreduce*-resp +X1 +X2 +X3 -X4. + +- : tpreduce*-resp D etp-eq/i etp-eq/i D. + +%worlds (csig | asig | bind | evar | tvar | evvar | tbind) (tpreduce*-resp _ _ _ _). +%total {} (tpreduce*-resp _ _ _ _). + +kreduce*-resp : kreduce* M N -> ekind-eq M M' -> ekind-eq N N' + -> kreduce* M' N' -> type. +%mode kreduce*-resp +X1 +X2 +X3 -X4. + +- : kreduce*-resp D ekind-eq/i ekind-eq/i D. + +%worlds (csig | asig | bind | evar | tvar | evvar | tbind) (kreduce*-resp _ _ _ _). +%total {} (kreduce*-resp _ _ _ _). + diff --git a/src/eregularity.thm b/src/eregularity.thm new file mode 100644 index 0000000..b76e202 --- /dev/null +++ b/src/eregularity.thm @@ -0,0 +1,1250 @@ + +ekof-pi-invert : ekof (epi A [x] B x) K + -> ekof A ektype + -> ({x} evof x A -> ekof (B x) ektype) -> type. +%mode ekof-pi-invert +X1 -X2 -X3. + +-pi : ekof-pi-invert (ekof/pi D2 D1) D1 D2. + +-eqkind : ekof-pi-invert + (ekof/eqkind + (Deqkind : eqkind K L) + (Dof : ekof (epi A [x] B x) K)) + DofA + DofB + <- ekof-pi-invert Dof + (DofA : ekof A ektype) + ([x] [d] DofB x d : ekof (B x) ektype). + +-ext : ekof-pi-invert + (ekof/ext + ([x] [d] DofApp x d + : ekof (eaapp (epi A [y] B y) x) (K x)) + (DofPi : ekof (epi A [y] B y) (ekpi C [z] J z))) + DofA + DofB + <- ekof-pi-invert DofPi + (DofA : ekof A ektype) + ([x] [d] DofB x d : ekof (B x) ektype). + +%worlds (ecsig | easig | evar | ebind | tbind) (ekof-pi-invert _ _ _). +%total D (ekof-pi-invert D _ _). + +%%%% regularity %%%% + +eof-reg : eof M A -> ekof A ektype -> type. +%mode eof-reg +X1 -X2. + +ekof-reg : ekof A K -> ewfkind K -> type. +%mode ekof-reg +X1 -X2. + +eqkind-reg : eqkind K L -> ewfkind K -> ewfkind L -> type. +%mode eqkind-reg +X1 -X2 -X3. + +eqtp-reg : eqtp A B K -> ekof A K -> ekof B K -> ewfkind K -> type. +%mode eqtp-reg +X1 -X2 -X3 -X4. + +eqtm-reg : eqtm M N C -> eof M C -> eof N C -> ekof C ektype -> type. +%mode eqtm-reg +X1 -X2 -X3 -X4. + +%%%% + +-const : ekof-reg (ekof/const D _) D. + +-app : ekof-reg + (ekof/app + (DofM : eof M B) + (DofA : ekof A (ekpi B ([x] K x)))) +%% + DofKM +%% + <- ekof-reg DofA + (ewfkind/pi + ([x] [d:evof x B] DofK x d : ewfkind (K x)) + (DofB : ekof B ektype)) + <- esubst-wfkind DofK DofM + (DofKM : ewfkind (K M)). + +-pi : ekof-reg (ekof/pi _ _) ewfkind/tp. + +-lam : ekof-reg + (ekof/lam + (DofA : ekof A ektype) + ([x] [d] DofB x d : ekof (B x) (K x))) +%% + (ewfkind/pi + DofK + DofA) +%% + <- ({x} {d} + ekof-reg (DofB x d) + (DofK x d : ewfkind (K x))). + +-eqkd : ekof-reg (ekof/eqkind (Deqkind : eqkind K L) (DofA : ekof A K)) + DofL + <- eqkind-reg Deqkind _ DofL. + +-ext : ekof-reg + (ekof/ext + ([x] [d] DofApp x d : ekof (eaapp C x) (K x)) + (DofC : ekof C (ekpi A K'))) +%% + (ewfkind/pi DofK DofA) +%% + <- ekof-reg DofC + (ewfkind/pi _ (DofA : ekof A ektype)) + <- ({x} {d} + ekof-reg (DofApp x d) + (DofK x d : ewfkind (K x))). + +%%%% + +-var : eof-reg (eof/var DofA _) DofA. + +-const : eof-reg (eof/const DofA _) DofA. + +-app : eof-reg + (eof/app + (DofM2 : eof M2 A2) + (DofM1 : eof M1 (epi A2 ([x] A1 x)))) +%% + DofA1M2 +%% + <- eof-reg DofM1 + (DofPi : ekof (epi A2 ([x] A1 x)) ektype) + <- ekof-pi-invert DofPi + (DofA2 : ekof A2 ektype) + ([x] [d] DofA1 x d : ekof (A1 x) ektype) + <- esubst-kof ([x] [d] DofA1 x d) DofM2 + (DofA1M2 : ekof (A1 M2) ektype). + +-lam : eof-reg + (eof/lam + (DofA : ekof A ektype) + ([x] [d:evof x A] DofM x d : eof (M x) (B x))) +%% + (ekof/pi ([x] [d] DofB x d) DofA) +%% + <- ({x} {d} + eof-reg (DofM x d) + (DofB x d : ekof (B x) ektype)). + +-eqtp : eof-reg + (eof/eqtp + (Deqtp : eqtp A B ektype) + (DofM : eof M A)) +%% + DofB +%% + <- eof-reg DofM + (DofA : ekof A ektype) + <- eqtp-reg Deqtp + _ (DofB : ekof B ektype) _. + +-ext : eof-reg + (eof/ext + ([x] [d] DofApp x d : eof (eapp M x) (B x)) + (DofM : eof M (epi A B'))) +%% + (ekof/pi DofB DofA) +%% + <- eof-reg DofM + (DofPi : ekof (epi A ([x] B' x)) ektype) + <- ekof-pi-invert DofPi + (DofA : ekof A ektype) + _ + <- ({x} {d} + eof-reg (DofApp x d) + (DofB x d : ekof (B x) ektype)). + +%%%% + +-tp : eqkind-reg eqkind/tp ewfkind/tp ewfkind/tp. + +-pi : eqkind-reg + (eqkind/pi + ([x] [d:evof x A] DeqK x d : eqkind (K x) (K' x)) + (DeqA : eqtp A A' ektype)) +%% + (ewfkind/pi + ([x] [d] DofK x d) + DofA) + (ewfkind/pi + ([x] [d] DofK'' x d) + DofA') +%% + <- ({x} {d} + eqkind-reg (DeqK x d) + (DofK x d : ewfkind (K x)) + (DofK' x d : ewfkind (K' x))) + <- eqtp-reg DeqA DofA DofA' _ + <- ({x} {d} + esubst-wfkind + ([y] [e] DofK' y e) + (eof/eqtp (eqtp/sym DeqA) (eof/var DofA' d)) + (DofK'' x d : ewfkind (K' x))). + +-sym : eqkind-reg (eqkind/sym DeqLK) DofK DofL + <- eqkind-reg DeqLK DofL DofK. + +-trans : eqkind-reg (eqkind/trans DeqKL DeqJK) DofJ DofL + <- eqkind-reg DeqJK DofJ _ + <- eqkind-reg DeqKL _ DofL. + +-refl : eqkind-reg (eqkind/refl DofK) DofK DofK. + +%%%% + +-app : eqtp-reg + (eqtp/app + (DeqMN : eqtm M N C) + (DeqAB : eqtp A B (ekpi C ([x] K x)))) +%% + (ekof/app + DofM + DofA + : ekof (eaapp A M) (K M)) + (ekof/eqkind + (eqkind/sym DeqKMN) + (ekof/app + DofN + DofB)) + DofKM +%% + <- eqtp-reg DeqAB + (DofA : ekof A (ekpi C ([x] K x))) + (DofB : ekof B (ekpi C ([x] K x))) + (ewfkind/pi + ([x] [d] DofK x d : ewfkind (K x)) + _) + <- eqtm-reg DeqMN + (DofM : eof M C) + (DofN : eof N C) + _ + <- eqtm-ksub DofK DeqMN DofM DofN + (DeqKMN : eqkind (K M) (K N)) + <- esubst-wfkind DofK DofM + (DofKM : ewfkind (K M)). + +-pi : eqtp-reg + (eqtp/pi + ([x] [d:evof x A] + DeqB x d : eqtp (B x) (B' x) ektype) + (DeqA : eqtp A A' ektype)) +%% + (ekof/pi + ([x] [d] DofB x d) + DofA) + (ekof/pi + DofB'' + DofA') + ewfkind/tp +%% + <- ({x} {d} + eqtp-reg (DeqB x d) + (DofB x d : ekof (B x) ektype) + (DofB' x d : ekof (B' x) ektype) + _) + <- eqtp-reg DeqA + (DofA : ekof A ektype) + (DofA' : ekof A' ektype) + _ + <- ({x} {d} + esubst-kof + ([y] [e] DofB' y e) + (eof/eqtp (eqtp/sym DeqA) (eof/var DofA' d)) + (DofB'' x d : ekof (B' x) ektype)). + +-lam : eqtp-reg + (eqtp/lam + ([x] [d:evof x A] DeqB x d : eqtp (B x) (B' x) (K x)) + (DeqA : eqtp A A' ektype)) +%% + (ekof/lam DofA DofB) + (ekof/eqkind + (eqkind/sym + (eqkind/pi + ([x] [d] eqkind/refl (DofK x d)) + DeqA)) + (ekof/lam DofA' DofB'')) + (ewfkind/pi DofK DofA) +%% + <- eqtp-reg DeqA + (DofA : ekof A ektype) + (DofA' : ekof A' ektype) + _ + <- ({x} {d} + eqtp-reg (DeqB x d) + (DofB x d : ekof (B x) (K x)) + (DofB' x d : ekof (B' x) (K x)) + (DofK x d : ewfkind (K x))) + <- ({x} {d} + esubst-kof ([y] [e] DofB' y e) + (eof/eqtp (eqtp/sym DeqA) (eof/var DofA' d)) + (DofB'' x d : ekof (B' x) (K x))). + +-ext : eqtp-reg + (eqtp/ext + ([x] [d:evof x A] + DeqApp x d : eqtp (eaapp B x) (eaapp C x) (K x)) + (DofC : ekof C (ekpi A [x] K'' x)) + (DofB : ekof B (ekpi A [x] K' x))) +%% + (ekof/ext DofAppB DofB) + (ekof/ext DofAppC DofC) + (ewfkind/pi DofK DofA) +%% + <- ({x} {d} + eqtp-reg (DeqApp x d) + (DofAppB x d : ekof (eaapp B x) (K x)) + (DofAppC x d : ekof (eaapp C x) (K x)) + (DofK x d : ewfkind (K x))) + <- ekof-reg DofC + (ewfkind/pi + _ + (DofA : ekof A ektype)). + +-extw : eqtp-reg + (eqtp/extw + ([x] [d:evof x A] + DeqApp x d : eqtp (eaapp B x) (eaapp C x) (K x)) + (DeqBC : eqtp B C (ekpi A K'))) +%% + (ekof/ext DofAppB DofB) + (ekof/ext DofAppC DofC) + (ewfkind/pi DofK DofA) +%% + <- ({x} {d} + eqtp-reg (DeqApp x d) + (DofAppB x d : ekof (eaapp B x) (K x)) + (DofAppC x d : ekof (eaapp C x) (K x)) + (DofK x d : ewfkind (K x))) + <- eqtp-reg DeqBC DofB DofC + (ewfkind/pi _ DofA). + + +-beta : eqtp-reg + (eqtp/beta + (DofN : eof N A) + ([x] [d:evof x A] DofB x d : ekof (B x) (K x)) + : eqtp (eaapp (ealam A [x] B x) N) (B N) (K N)) +%% + (ekof/app + DofN + (ekof/lam DofA DofB)) + DofBN + DofKN +%% + <- eof-reg DofN DofA + <- esubst-kof DofB DofN (DofBN : ekof (B N) (K N)) + <- ({x} {d} + ekof-reg (DofB x d) (DofK x d : ewfkind (K x))) + <- esubst-wfkind DofK DofN (DofKN : ewfkind (K N)). + +-sym : eqtp-reg (eqtp/sym (DeqBA : eqtp B A K)) DofA DofB DofK + <- eqtp-reg DeqBA DofB DofA DofK. + +-trans : eqtp-reg + (eqtp/trans (DeqBC : eqtp B C K) (DeqAB : eqtp A B K)) +%% + DofA + DofC + DofK +%% + <- eqtp-reg DeqAB DofA _ DofK + <- eqtp-reg DeqBC _ DofC _. + +-refl : eqtp-reg (eqtp/refl Dkof) Dkof Dkof Dwfkind + <- ekof-reg Dkof Dwfkind. + +-kcon : eqtp-reg + (eqtp/kcon + (DeqKL : eqkind K L) + (DeqAB : eqtp A B K)) +%% + (ekof/eqkind + DeqKL + DofAK) + (ekof/eqkind + DeqKL + DofBK) + DofL +%% + <- eqtp-reg DeqAB + (DofAK : ekof A K) + (DofBK : ekof B K) + _ + <- eqkind-reg DeqKL _ (DofL : ewfkind L). + +%%%% + +-app : eqtm-reg + (eqtm/app + (DeqN : eqtm N N' A) + (DeqM : eqtm M M' (epi A ([x] B x))) + : eqtm (eapp M N) (eapp M' N') (B N)) +%% + (eof/app DofN DofM) + (eof/eqtp + (eqtp/sym DeqBN) + (eof/app DofN' DofM')) + DofBN +%% + <- eqtm-reg DeqN + (DofN : eof N A) + (DofN' : eof N' A) + _ + <- eqtm-reg DeqM + (DofM : eof M (epi A ([x] B x))) + (DofM' : eof M' (epi A ([x] B x))) + (DofPi : ekof (epi A ([x] B x)) ektype) + <- ekof-pi-invert DofPi _ + ([x] [d] DofB x d : ekof (B x) ektype) + <- eqtm-tpsub DofB DeqN DofN DofN' + (DeqBN : eqtp (B N) (B N') ektype) + <- esubst-kof DofB DofN + (DofBN : ekof (B N) ektype). + +-lam : eqtm-reg + (eqtm/lam + ([x] [d:evof x A] DeqM x d : eqtm (M x) (M' x) (B x)) + (DeqA : eqtp A A' ektype)) +%% + (eof/lam DofA DofM) + (eof/eqtp + (eqtp/sym + (eqtp/pi + ([x] [d] eqtp/refl (DofB x d)) + DeqA)) + (eof/lam DofA' DofM'')) + (ekof/pi DofB DofA) +%% + <- eqtp-reg DeqA + (DofA : ekof A ektype) + (DofA' : ekof A' ektype) + _ + <- ({x} {d} + eqtm-reg (DeqM x d) + (DofM x d : eof (M x) (B x)) + (DofM' x d : eof (M' x) (B x)) + (DofB x d : ekof (B x) ektype)) + <- ({x} {d} + esubst ([y] [e] DofM' y e) + (eof/eqtp (eqtp/sym DeqA) (eof/var DofA' d)) + (DofM'' x d)). + +-ext : eqtm-reg + (eqtm/ext + ([x] [d:evof x A] DeqApp x d + : eqtm (eapp M x) (eapp N x) (B x)) + (DofN : eof N (epi A [x] B'' x)) + (DofM : eof M (epi A [x] B' x))) +%% + (eof/ext DofAppM DofM) + (eof/ext DofAppN DofN) + (ekof/pi DofB DofA) +%% + <- ({x} {d} + eqtm-reg (DeqApp x d) + (DofAppM x d : eof (eapp M x) (B x)) + (DofAppN x d : eof (eapp N x) (B x)) + (DofB x d : ekof (B x) ektype)) + <- eof-reg DofN (DofPi : ekof (epi A B'') ektype) + <- ekof-pi-invert DofPi (DofA : ekof A ektype) _. + +-extw : eqtm-reg + (eqtm/extw + ([x] [d:evof x A] DeqApp x d + : eqtm (eapp M x) (eapp N x) (B x)) + (DeqMN : eqtm M N (epi A [x] B' x))) +%% + (eof/ext DofAppM DofM) + (eof/ext DofAppN DofN) + (ekof/pi DofB DofA) +%% + <- ({x} {d} + eqtm-reg (DeqApp x d) + (DofAppM x d : eof (eapp M x) (B x)) + (DofAppN x d : eof (eapp N x) (B x)) + (DofB x d : ekof (B x) ektype)) + <- eqtm-reg DeqMN + (DofM : eof M (epi A [x] B' x)) + (DofN : eof N (epi A [x] B' x)) + (DofPi : ekof (epi A B') ektype) + <- ekof-pi-invert DofPi (DofA : ekof A ektype) _. + + +-beta : eqtm-reg + (eqtm/beta + (DofN : eof N A) + ([x] [d:evof x A] DofM x d : eof (M x) (B x)) + : eqtm (eapp (elam A [x] M x) N) (M N) (B N)) +%% + (eof/app + DofN + (eof/lam DofA DofM)) + DofMN + DofBN +%% + <- eof-reg DofN (DofA : ekof A ektype) + <- esubst DofM DofN (DofMN : eof (M N) (B N)) + <- ({x} {d} + eof-reg (DofM x d) (DofB x d : ekof (B x) ektype)) + <- esubst-kof DofB DofN + (DofBN : ekof (B N) ektype). + +-sym : eqtm-reg + (eqtm/sym (DeqM'M : eqtm M' M A)) + DofM + DofM' + DofA + <- eqtm-reg DeqM'M DofM' DofM DofA. + +-trans : eqtm-reg + (eqtm/trans + (DeqNO : eqtm N O A) + (DeqMN : eqtm M N A)) + DofM + DofO + DofA + <- eqtm-reg DeqMN DofM _ DofA + <- eqtm-reg DeqNO _ DofO _. + +-refl : eqtm-reg (eqtm/refl DofM) DofM DofM DofA + <- eof-reg DofM DofA. + +-tpcon : eqtm-reg + (eqtm/typecon + (DeqA : eqtp A A' ektype) + (DeqM : eqtm M M' A) + : eqtm M M' A') +%% + (eof/eqtp DeqA DofM) + (eof/eqtp DeqA DofM') + DofA' +%% + <- eqtm-reg DeqM + (DofM : eof M A) + (DofM' : eof M' A) + _ + <- eqtp-reg DeqA _ (DofA' : ekof A' ektype) _. + +% XXX can we actually add evar to worlds here?? +%worlds (ecsig | easig | ebind | tbind | evar) + (eof-reg _ _) (ekof-reg _ _) + (eqkind-reg _ _ _) (eqtp-reg _ _ _ _) (eqtm-reg _ _ _ _). +%total (D1 D2 D3 D4 D5) + (eof-reg D1 _) (ekof-reg D2 _) + (eqkind-reg D3 _ _) (eqtp-reg D4 _ _ _) (eqtm-reg D5 _ _ _). + +%% Explicit Contexts %% + +ekofe-pi-invert : ekofe G (epi A [x] B x) K + -> ekofe G A ektype + -> ({x} ekofe (econs G x A) (B x) ektype) -> type. +%mode ekofe-pi-invert +X1 -X2 -X3. + +-pi : ekofe-pi-invert (ekofe/pi D1 D2) D1 D2. + +-eqkind : ekofe-pi-invert + (ekofe/eqkind + (Deqkind : eqkinde G K L) + (Dof : ekofe G (epi A [x] B x) K)) + DofA + DofB + <- ekofe-pi-invert Dof + (DofA : ekofe G A ektype) + ([x] DofB x : ekofe (econs G x A) (B x) ektype). + +-ext : ekofe-pi-invert + (ekofe/ext + ([x] DofApp x + : ekofe (econs G x _) (eaapp (epi A [y] B y) x) (K x)) + (DofPi : ekofe G (epi A [y] B y) (ekpi C [z] J z))) + DofA + DofB + <- ekofe-pi-invert DofPi + (DofA : ekofe G A ektype) + ([x] DofB x : ekofe (econs G x _) (B x) ektype). + +%worlds (ecsig | easig | evar | ebind | tbind) (ekofe-pi-invert _ _ _). +%total D (ekofe-pi-invert D _ _). + +%% earlier version of this for staging + +ekofe-tcon-bind' : ({x} eisvar x I -> eordered (econs G x A)) + -> eqtpe G A A' ektype + -> ekofe G A' ektype + -> ({x} ekofe (econs G x A) (B x) (K x)) +%% + -> ({x} ekofe (econs G x A') (B x) (K x)) -> type. +%mode ekofe-tcon-bind' +X0 +X1 +X2 +X3 -X4. + +- : ekofe-tcon-bind' + ([x] [d] Dord x d : eordered (econs G x A)) + (Deqtp : eqtpe G A A' ektype) + (DofA' : ekofe G A' ektype) + ([x] Dof x : ekofe (econs G x A) (B x) (K x)) + Dof'' + <- ({x} {x'} + weakeng-ekofe (eappend/cons eappend/nil) (eappend/cons eappend/nil) + (Dof x) + (Dof' x x' : ekofe (econs (econs G x' A') x A) (B x) (K x))) + <- ({x} {d} + eordered-cons (Dord x d) + (DordG_ x d : eordered G)) + <- strengthen-eordered DordG_ + (DordG : eordered G) + <- extend-eordered _ DordG _1 + ([x'] [d'] DordG' x' d' : eordered (econs G x' A')) + <- ({x'} {d'} + extend-eordered _ (DordG' x' d') _2 + ([x] [d] DordG'' x' d' x d + : eordered (econs (econs G x' A') x A))) + <- ({x'} + weaken-eqtpe Deqtp _ _ + (Deqtp' x' : eqtpe (econs G x' A') A A' ektype)) + <- ({x'} + weakeng-ekofe eappend/nil eappend/nil DofA' + (DofA'* x' : ekofe (econs G x' A') A' ektype)) + <- ({x'} {d'} + ekofe-sub ([x] [d] DordG'' x' d' x d) + ([_] eappend/nil) + ([x] Dof' x x') + (eofe/eqtp + (eqtpe/sym (Deqtp' x')) + (eofe/var (DofA'* x') elookup/hit)) + ecsub/base + (Dof'' x' : ekofe (econs G x' A') (B x') (K x'))). + +%worlds (ecsig | easig | evar | eovar | ebind) (ekofe-tcon-bind' _ _ _ _ _). +%total {} (ekofe-tcon-bind' _ _ _ _ _). + +ewfkinde-tcon-bind' : ({x} eisvar x I -> eordered (econs G x A)) + -> eqtpe G A A' ektype + -> ekofe G A' ektype + -> ({x} ewfkinde (econs G x A) (K x)) +%% + -> ({x} ewfkinde (econs G x A') (K x)) -> type. +%mode ewfkinde-tcon-bind' +X0 +X1 +X2 +X3 -X4. + +- : ewfkinde-tcon-bind' + ([x] [d] Dord x d : eordered (econs G x A)) + (Deqtp : eqtpe G A A' ektype) + (DofA' : ekofe G A' ektype) + ([x] Dof x : ewfkinde (econs G x A) (K x)) + Dof'' + <- ({x} {x'} + weakeng-ewfkinde (eappend/cons eappend/nil) (eappend/cons eappend/nil) + (Dof x) + (Dof' x x' : ewfkinde (econs (econs G x' A') x A) (K x))) + <- ({x} {d} + eordered-cons (Dord x d) + (DordG_ x d : eordered G)) + <- strengthen-eordered DordG_ + (DordG : eordered G) + <- extend-eordered _ DordG _1 + ([x'] [d'] DordG' x' d' : eordered (econs G x' A')) + <- ({x'} {d'} + extend-eordered _ (DordG' x' d') _2 + ([x] [d] DordG'' x' d' x d + : eordered (econs (econs G x' A') x A))) + <- ({x'} + weaken-eqtpe Deqtp _ _ + (Deqtp' x' : eqtpe (econs G x' A') A A' ektype)) + <- ({x'} + weakeng-ekofe eappend/nil eappend/nil DofA' + (DofA'* x' : ekofe (econs G x' A') A' ektype)) + <- ({x'} {d'} + ewfkinde-sub ([x] [d] DordG'' x' d' x d) + ([_] eappend/nil) + ([x] Dof' x x') + (eofe/eqtp + (eqtpe/sym (Deqtp' x')) + (eofe/var (DofA'* x') elookup/hit)) + ecsub/base + (Dof'' x' : ewfkinde (econs G x' A') (K x'))). + +%worlds (ecsig | easig | evar | eovar | ebind) (ewfkinde-tcon-bind' _ _ _ _ _). +%total {} (ewfkinde-tcon-bind' _ _ _ _ _). + + +eofe-tcon-bind' : ({x} eisvar x I -> eordered (econs G x A)) + -> eqtpe G A A' ektype + -> ekofe G A' ektype + -> ({x} eofe (econs G x A) (B x) (K x)) +%% + -> ({x} eofe (econs G x A') (B x) (K x)) -> type. +%mode eofe-tcon-bind' +X0 +X1 +X2 +X3 -X4. + +- : eofe-tcon-bind' + ([x] [d] Dord x d : eordered (econs G x A)) + (Deqtp : eqtpe G A A' ektype) + (DofA' : ekofe G A' ektype) + ([x] Dof x : eofe (econs G x A) (B x) (K x)) + Dof'' + <- ({x} {x'} + weakeng-eofe (eappend/cons eappend/nil) (eappend/cons eappend/nil) + (Dof x) + (Dof' x x' : eofe (econs (econs G x' A') x A) (B x) (K x))) + <- ({x} {d} + eordered-cons (Dord x d) + (DordG_ x d : eordered G)) + <- strengthen-eordered DordG_ + (DordG : eordered G) + <- extend-eordered _ DordG _1 + ([x'] [d'] DordG' x' d' : eordered (econs G x' A')) + <- ({x'} {d'} + extend-eordered _ (DordG' x' d') _2 + ([x] [d] DordG'' x' d' x d + : eordered (econs (econs G x' A') x A))) + <- ({x'} + weaken-eqtpe Deqtp _ _ + (Deqtp' x' : eqtpe (econs G x' A') A A' ektype)) + <- ({x'} + weakeng-ekofe eappend/nil eappend/nil DofA' + (DofA'* x' : ekofe (econs G x' A') A' ektype)) + <- ({x'} {d'} + eofe-sub ([x] [d] DordG'' x' d' x d) + ([_] eappend/nil) + ([x] Dof' x x') + (eofe/eqtp + (eqtpe/sym (Deqtp' x')) + (eofe/var (DofA'* x') elookup/hit)) + ecsub/base + (Dof'' x' : eofe (econs G x' A') (B x') (K x'))). + +%worlds (ecsig | easig | evar | eovar | ebind) (eofe-tcon-bind' _ _ _ _ _). +%total {} (eofe-tcon-bind' _ _ _ _ _). + + +eofe-reg : eordered G -> eofe G M A -> ekofe G A ektype -> type. +%mode eofe-reg +X0 +X1 -X2. + +ekofe-reg : eordered G -> ekofe G A K -> ewfkinde G K -> type. +%mode ekofe-reg +X0 +X1 -X2. + +eqtme-reg : eordered G -> eqtme G M N A + -> eofe G M A -> eofe G N A -> ekofe G A ektype -> type. +%mode eqtme-reg +X0 +X1 -X2 -X3 -X4. + +eqtpe-reg : eordered G -> eqtpe G M N A + -> ekofe G M A -> ekofe G N A -> ewfkinde G A -> type. +%mode eqtpe-reg +X0 +X1 -X2 -X3 -X4. + +eqkinde-reg : eordered G -> eqkinde G K L + -> ewfkinde G K -> ewfkinde G L -> type. +%mode eqkinde-reg +X1 +X2 -X3 -X4. + +-vari : eofe-reg _ (eofe/vari DofA _) DofA. + +-var : eofe-reg _ (eofe/var DofA _) DofA. + +-const : eofe-reg _ (eofe/const DofA _) DofA. + +-app : eofe-reg Dord (eofe/app DofN DofM) + DofBx + <- eofe-reg Dord DofM + (DofPi : ekofe G (epi A B) ektype) + <- ekofe-pi-invert DofPi + (DofA : ekofe G A ektype) + ([x] DofB x : ekofe (econs G x A) (B x) ektype) + <- extend-eordered _ Dord _ Dord' + <- ekofe-sub Dord' ([x] eappend/nil) DofB DofN ecsub/base + (DofBx : ekofe G (B M) ektype). + +-lam : eofe-reg Dord + (eofe/lam DofA DofM) + (ekofe/pi DofA DofB) + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eofe-reg (Dord' x d) (DofM x) + (DofB x)). + +-eqtp : eofe-reg Dord + (eofe/eqtp Deqtp DofM) + DofB + <- eofe-reg Dord DofM DofA + <- eqtpe-reg Dord Deqtp _ DofB _. + +-ext : eofe-reg Dord + (eofe/ext ([x] DofApp x) DofM) + (ekofe/pi DofA DofB) + <- eofe-reg Dord DofM DofPi + <- ekofe-pi-invert DofPi DofA _ + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eofe-reg (Dord' x d) (DofApp x) + (DofB x)). + +%% + +-const : ekofe-reg _ (ekofe/const DofA _) DofA. + +-app : ekofe-reg Dord (ekofe/app DofN DofM) + DofBx + <- ekofe-reg Dord DofM + (ewfkinde/pi + (DofA : ekofe G A ektype) + ([x] DofB x : ewfkinde (econs G x A) (K x))) + <- extend-eordered _ Dord _ Dord' + <- ewfkinde-sub Dord' ([x] eappend/nil) DofB DofN ecsub/base + (DofBx : ewfkinde G (K M)). + +-pi : ekofe-reg Dord + (ekofe/pi DofA DofB) + ewfkinde/tp. + +-lam : ekofe-reg Dord + (ekofe/lam DofA DofM) + (ewfkinde/pi DofA DofB) + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + ekofe-reg (Dord' x d) (DofM x) + (DofB x)). + +-eqtp : ekofe-reg Dord + (ekofe/eqkind Deqtp DofM) + DofB + <- ekofe-reg Dord DofM DofA + <- eqkinde-reg Dord Deqtp _ DofB. + +-ext : ekofe-reg Dord + (ekofe/ext ([x] DofApp x) DofM) + (ewfkinde/pi DofA DofB) + <- ekofe-reg Dord DofM (ewfkinde/pi DofA _) + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + ekofe-reg (Dord' x d) (DofApp x) + (DofB x)). + +%% + +-app : eqtme-reg Dord + (eqtme/app + (DeqN : eqtme G N N' A) + (DeqM : eqtme G M M' (epi A B))) +%% + (eofe/app DofN DofM) + (eofe/eqtp + (eqtpe/sym DeqBN_BN') + (eofe/app DofN' DofM')) + DofBN +%% + <- eqtme-reg Dord DeqN DofN DofN' DofA + <- eqtme-reg Dord DeqM DofM DofM' + (DofPi : ekofe G (epi A B) ektype) + <- ekofe-pi-invert DofPi _ DofB + <- extend-eordered _ Dord _ Dord' + <- eqtm-tpsub-e Dord' ([_] eappend/nil) DeqN DofN DofN' DofB + ecsub/base + (DeqBN_BN' : eqtpe G (B N) (B N') ektype) + <- ekofe-sub Dord' ([_] eappend/nil) DofB DofN ecsub/base + (DofBN : ekofe G (B N) ektype). + +-lam : eqtme-reg Dord + (eqtme/lam + ([x] DeqM x : eqtme (econs G x A) (M x) (M' x) (B x)) + (DeqA : eqtpe G A A' ektype)) +%% + (eofe/lam DofA DofM) + (eofe/eqtp + (eqtpe/sym + (eqtpe/pi + ([x] eqtpe/refl (DofB x)) + DeqA)) + (eofe/lam DofA' DofM'*)) + (ekofe/pi DofA DofB) +%% + <- eqtpe-reg Dord DeqA + (DofA : ekofe G A ektype) + (DofA' : ekofe G A' ektype) + _ + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eqtme-reg (Dord' x d) (DeqM x) + (DofM x : eofe (econs G x A) (M x) (B x)) + (DofM' x : eofe (econs G x A) (M' x) (B x)) + (DofB x : ekofe (econs G x A) (B x) ektype)) + <- eofe-tcon-bind' Dord' DeqA DofA' DofM' + ([x] DofM'* x : eofe (econs G x A') (M' x) (B x)). + +-ext : eqtme-reg Dord + (eqtme/ext + ([x] DeqApp x + : eqtme (econs G x A) (eapp M x) (eapp N x) (B x)) + (DofN : eofe G N (epi A B'')) + (DofM : eofe G M (epi A B'))) +%% + (eofe/ext DofAppM DofM) + (eofe/ext DofAppN DofN) + (ekofe/pi DofA DofB) +%% + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eqtme-reg (Dord' x d) (DeqApp x) + (DofAppM x : eofe (econs G x A) (eapp M x) (B x)) + (DofAppN x : eofe (econs G x A) (eapp N x) (B x)) + (DofB x : ekofe (econs G x A) (B x) ektype)) + <- eofe-reg Dord DofN DofPi + <- ekofe-pi-invert DofPi DofA _. + +-extw : eqtme-reg Dord + (eqtme/extw + ([x] DeqApp x + : eqtme (econs G x A) (eapp M x) (eapp N x) (B x)) + (DeqMN : eqtme G M N (epi A [x] B' x))) +%% + (eofe/ext DofAppM DofM) + (eofe/ext DofAppN DofN) + (ekofe/pi DofA DofB) +%% + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eqtme-reg (Dord' x d) (DeqApp x) + (DofAppM x : eofe (econs G x A) (eapp M x) (B x)) + (DofAppN x : eofe (econs G x A) (eapp N x) (B x)) + (DofB x : ekofe (econs G x A) (B x) ektype)) + <- eqtme-reg Dord DeqMN + (DofM : eofe G M (epi A [x] B' x)) + (DofN : eofe G N (epi A [x] B' x)) + (DofPi : ekofe G (epi A B') ektype) + <- ekofe-pi-invert DofPi (DofA : ekofe G A ektype) _. + +-beta : eqtme-reg Dord + (eqtme/beta + (DofN : eofe G N A) + ([x] DofM x : eofe (econs G x A) (M x) (B x)) + : eqtme G (eapp (elam A [x] M x) N) (M N) (B N)) +%% + (eofe/app DofN (eofe/lam DofA DofM)) + DofMN + DofBN +%% + <- eofe-reg Dord DofN (DofA : ekofe G A ektype) + <- extend-eordered _ Dord _ Dord' + <- eofe-sub Dord' ([_]eappend/nil) DofM DofN ecsub/base + (DofMN : eofe G (M N) (B N)) + <- ({x} {d} + eofe-reg (Dord' x d) (DofM x) + (DofB x : ekofe (econs G x A) (B x) ektype)) + <- ekofe-sub Dord' ([_]eappend/nil) DofB DofN ecsub/base + (DofBN : ekofe G (B N) ektype). + +-sym : eqtme-reg Dord (eqtme/sym Deq) + DofM + DofM' + DofA + <- eqtme-reg Dord Deq DofM' DofM DofA. + +-trans : eqtme-reg Dord (eqtme/trans DeqNO DeqMN) + DofM + DofO + DofA + <- eqtme-reg Dord DeqMN DofM _ DofA + <- eqtme-reg Dord DeqNO _ DofO _. + +-ref : eqtme-reg Dord (eqtme/refl Dof) Dof Dof Dkof + <- eofe-reg Dord Dof Dkof. + +-tcon : eqtme-reg Dord (eqtme/tcon DeqA DeqM) + (eofe/eqtp DeqA DofM) + (eofe/eqtp DeqA DofM') + DofA' + <- eqtme-reg Dord DeqM DofM DofM' _ + <- eqtpe-reg Dord DeqA _ DofA' _. + +%% + +-app : eqtpe-reg Dord + (eqtpe/app + (DeqN : eqtme G N N' A) + (DeqM : eqtpe G M M' (ekpi A B))) +%% + (ekofe/app DofN DofM) + (ekofe/eqkind + (eqkinde/sym DeqBN_BN') + (ekofe/app DofN' DofM')) + DofBN +%% + <- eqtme-reg Dord DeqN DofN DofN' DofA + <- eqtpe-reg Dord DeqM DofM DofM' + (ewfkinde/pi _ DofB) + <- extend-eordered _ Dord _ Dord' + <- eqtm-ksub-e Dord' ([_] eappend/nil) DeqN DofN DofN' DofB + ecsub/base + (DeqBN_BN' : eqkinde G (B N) (B N')) + <- ewfkinde-sub Dord' ([_] eappend/nil) DofB DofN ecsub/base + (DofBN : ewfkinde G (B N)). + +-lam : eqtpe-reg Dord + (eqtpe/lam + ([x] DeqM x : eqtpe (econs G x A) (M x) (M' x) (B x)) + (DeqA : eqtpe G A A' ektype)) +%% + (ekofe/lam DofA DofM) + (ekofe/eqkind + (eqkinde/sym + (eqkinde/pi + ([x] eqkinde/refl (DofB x)) + DeqA)) + (ekofe/lam DofA' DofM'*)) + (ewfkinde/pi DofA DofB) +%% + <- eqtpe-reg Dord DeqA + (DofA : ekofe G A ektype) + (DofA' : ekofe G A' ektype) + _ + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eqtpe-reg (Dord' x d) (DeqM x) + (DofM x : ekofe (econs G x A) (M x) (B x)) + (DofM' x : ekofe (econs G x A) (M' x) (B x)) + (DofB x : ewfkinde (econs G x A) (B x))) + <- ekofe-tcon-bind' Dord' DeqA DofA' DofM' + ([x] DofM'* x : ekofe (econs G x A') (M' x) (B x)). + +-pi : eqtpe-reg Dord + (eqtpe/pi + ([x] DeqM x : eqtpe (econs G x A) (M x) (M' x) ektype) + (DeqA : eqtpe G A A' ektype)) +%% + (ekofe/pi DofA DofM) + (ekofe/pi DofA' DofM'*) + ewfkinde/tp +%% + <- eqtpe-reg Dord DeqA + (DofA : ekofe G A ektype) + (DofA' : ekofe G A' ektype) + _ + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eqtpe-reg (Dord' x d) (DeqM x) + (DofM x : ekofe (econs G x A) (M x) ektype) + (DofM' x : ekofe (econs G x A) (M' x) ektype) + (DofB x : ewfkinde (econs G x A) ektype)) + <- ekofe-tcon-bind' Dord' DeqA DofA' DofM' + ([x] DofM'* x : ekofe (econs G x A') (M' x) ektype). + +-ext : eqtpe-reg Dord + (eqtpe/ext + ([x] DeqApp x + : eqtpe (econs G x A) (eaapp M x) (eaapp N x) (B x)) + (DofN : ekofe G N (ekpi A B'')) + (DofM : ekofe G M (ekpi A B'))) +%% + (ekofe/ext DofAppM DofM) + (ekofe/ext DofAppN DofN) + (ewfkinde/pi DofA DofB) +%% + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eqtpe-reg (Dord' x d) (DeqApp x) + (DofAppM x : ekofe (econs G x A) (eaapp M x) (B x)) + (DofAppN x : ekofe (econs G x A) (eaapp N x) (B x)) + (DofB x : ewfkinde (econs G x A) (B x))) + <- ekofe-reg Dord DofN (ewfkinde/pi DofA _). + +-extw : eqtpe-reg Dord + (eqtpe/extw + ([x] DeqApp x + : eqtpe (econs G x A) (eaapp M x) (eaapp N x) (B x)) + (DeqMN : eqtpe G M N (ekpi A [x] B' x))) +%% + (ekofe/ext DofAppM DofM) + (ekofe/ext DofAppN DofN) + (ewfkinde/pi DofA DofB) +%% + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eqtpe-reg (Dord' x d) (DeqApp x) + (DofAppM x : ekofe (econs G x A) (eaapp M x) (B x)) + (DofAppN x : ekofe (econs G x A) (eaapp N x) (B x)) + (DofB x : ewfkinde (econs G x A) (B x))) + <- eqtpe-reg Dord DeqMN + (DofM : ekofe G M (ekpi A [x] B' x)) + (DofN : ekofe G N (ekpi A [x] B' x)) + (ewfkinde/pi DofA _). + +-beta : eqtpe-reg Dord + (eqtpe/beta + (DofN : eofe G N A) + ([x] DofM x : ekofe (econs G x A) (M x) (B x)) + : eqtpe G (eaapp (ealam A [x] M x) N) (M N) (B N)) +%% + (ekofe/app DofN (ekofe/lam DofA DofM)) + DofMN + DofBN +%% + <- eofe-reg Dord DofN (DofA : ekofe G A ektype) + <- extend-eordered _ Dord _ Dord' + <- ekofe-sub Dord' ([_]eappend/nil) DofM DofN ecsub/base + (DofMN : ekofe G (M N) (B N)) + <- ({x} {d} + ekofe-reg (Dord' x d) (DofM x) + (DofB x : ewfkinde (econs G x A) (B x))) + <- ewfkinde-sub Dord' ([_] eappend/nil) DofB DofN ecsub/base + (DofBN : ewfkinde G (B N)). + +-sym : eqtpe-reg Dord (eqtpe/sym Deq) + DofM + DofM' + DofA + <- eqtpe-reg Dord Deq DofM' DofM DofA. + +-trans : eqtpe-reg Dord (eqtpe/trans DeqNO DeqMN) + DofM + DofO + DofA + <- eqtpe-reg Dord DeqMN DofM _ DofA + <- eqtpe-reg Dord DeqNO _ DofO _. + +-ref : eqtpe-reg Dord (eqtpe/refl Dof) Dof Dof Dkof + <- ekofe-reg Dord Dof Dkof. + +-kcon : eqtpe-reg Dord (eqtpe/kcon DeqA DeqM) + (ekofe/eqkind DeqA DofM) + (ekofe/eqkind DeqA DofM') + DofA' + <- eqtpe-reg Dord DeqM DofM DofM' _ + <- eqkinde-reg Dord DeqA _ DofA'. + +%% + +-tp : eqkinde-reg Dord eqkinde/tp ewfkinde/tp ewfkinde/tp. + +-pi : eqkinde-reg Dord + (eqkinde/pi DeqK DeqA) +%% + (ewfkinde/pi DofA DofK) + (ewfkinde/pi DofA' DofK'') +%% + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + eqkinde-reg (Dord' x d) (DeqK x) + (DofK x) + (DofK' x)) + <- eqtpe-reg Dord DeqA DofA DofA' _ + <- ewfkinde-tcon-bind' Dord' DeqA DofA' DofK' + ([x] DofK'' x : ewfkinde (econs G x A') (K' x)). + +-sym : eqkinde-reg Dord (eqkinde/sym Deq) + DofM + DofM' + <- eqkinde-reg Dord Deq DofM' DofM. + +-trans : eqkinde-reg Dord (eqkinde/trans DeqNO DeqMN) + DofM + DofO + <- eqkinde-reg Dord DeqMN DofM _ + <- eqkinde-reg Dord DeqNO _ DofO. + +-ref : eqkinde-reg Dord (eqkinde/refl Dof) Dof Dof. + +%worlds (ecsig | easig | evar | eovar | ebind) + (eofe-reg _ _ _) + (ekofe-reg _ _ _) + (eqtme-reg _ _ _ _ _) + (eqtpe-reg _ _ _ _ _) + (eqkinde-reg _ _ _ _). +%total (D1 D2 D3 D4 D5) + (eofe-reg _ D1 _) + (ekofe-reg _ D2 _) + (eqtme-reg _ D3 _ _ _) + (eqtpe-reg _ D4 _ _ _) + (eqkinde-reg _ D5 _ _). + +%% Lemma that needs to be here instead of in explicit lemmas 'cause it +% needs regularity + +ekofe-tcon-bind : ({x} eisvar x I -> eordered (econs G x A)) + -> eqtpe G A A' ektype + -> ({x} ekofe (econs G x A) (B x) (K x)) +%% + -> ({x} ekofe (econs G x A') (B x) (K x)) -> type. +%mode ekofe-tcon-bind +X1 +X2 +X3 -X4. + +- : ekofe-tcon-bind + ([x] [d] Dord x d : eordered (econs G x A)) + (Deqtp : eqtpe G A A' ektype) + ([x] Dof x : ekofe (econs G x A) (B x) (K x)) + Dof'' + <- ({x} {x'} + weakeng-ekofe (eappend/cons eappend/nil) (eappend/cons eappend/nil) + (Dof x) + (Dof' x x' : ekofe (econs (econs G x' A') x A) (B x) (K x))) + <- ({x} {d} + eordered-cons (Dord x d) + (DordG_ x d : eordered G)) + <- strengthen-eordered DordG_ + (DordG : eordered G) + <- extend-eordered _ DordG _1 + ([x'] [d'] DordG' x' d' : eordered (econs G x' A')) + <- ({x'} {d'} + extend-eordered _ (DordG' x' d') _2 + ([x] [d] DordG'' x' d' x d + : eordered (econs (econs G x' A') x A))) + <- ({x'} + weaken-eqtpe Deqtp _ _ + (Deqtp' x' : eqtpe (econs G x' A') A A' ektype)) + <- ({x'} {d'} + eqtpe-reg (DordG' x' d') (Deqtp' x') (_3 x') + (DofA' x' : ekofe (econs G x' A') A' ektype) (_4 x')) + <- ({x'} {d'} + ekofe-sub ([x] [d] DordG'' x' d' x d) + ([_] eappend/nil) + ([x] Dof' x x') + (eofe/eqtp + (eqtpe/sym (Deqtp' x')) + (eofe/var (DofA' x') elookup/hit)) + ecsub/base + (Dof'' x' : ekofe (econs G x' A') (B x') (K x'))). + +%worlds (ecsig | easig | evar | eovar | ebind) (ekofe-tcon-bind _ _ _ _). +%total {} (ekofe-tcon-bind _ _ _ _). + +eqkinde-tcon-bind : ({x} eisvar x I -> eordered (econs G x A)) + -> eqtpe G A A' ektype + -> ({x} eqkinde (econs G x A) (K1 x) (K2 x)) +%% + -> ({x} eqkinde (econs G x A') (K1 x) (K2 x)) -> type. +%mode eqkinde-tcon-bind +X1 +X2 +X3 -X4. + +- : eqkinde-tcon-bind + ([x] [d] Dord x d : eordered (econs G x A)) + (Deqtp : eqtpe G A A' ektype) + ([x] Dof x : eqkinde (econs G x A) (K x) (K' x)) + Dof'' + <- ({x} {x'} + weakeng-eqkinde (eappend/cons eappend/nil) (eappend/cons eappend/nil) + (Dof x) + (Dof' x x' : eqkinde (econs (econs G x' A') x A) (K x) (K' x))) + <- ({x} {d} + eordered-cons (Dord x d) + (DordG_ x d : eordered G)) + <- strengthen-eordered DordG_ + (DordG : eordered G) + <- extend-eordered _ DordG _1 + ([x'] [d'] DordG' x' d' : eordered (econs G x' A')) + <- ({x'} {d'} + extend-eordered _ (DordG' x' d') _2 + ([x] [d] DordG'' x' d' x d + : eordered (econs (econs G x' A') x A))) + <- ({x'} + weaken-eqtpe Deqtp _ _ + (Deqtp' x' : eqtpe (econs G x' A') A A' ektype)) + <- ({x'} {d'} + eqtpe-reg (DordG' x' d') (Deqtp' x') (_3 x') + (DofA' x' : ekofe (econs G x' A') A' ektype) (_4 x')) + <- ({x'} {d'} + eqkinde-sub ([x] [d] DordG'' x' d' x d) + ([_] eappend/nil) + ([x] Dof' x x') + (eofe/eqtp + (eqtpe/sym (Deqtp' x')) + (eofe/var (DofA' x') elookup/hit)) + ecsub/base + (Dof'' x' : eqkinde (econs G x' A') (K x') (K' x'))). + +%worlds (ecsig | easig | evar | eovar | ebind) (eqkinde-tcon-bind _ _ _ _). +%total {} (eqkinde-tcon-bind _ _ _ _). diff --git a/src/estrengthen.thm b/src/estrengthen.thm new file mode 100644 index 0000000..e0a13c3 --- /dev/null +++ b/src/estrengthen.thm @@ -0,0 +1,876 @@ +%% noassm %% + +evof-noassm : ({x:etm} evof Y (B x)) -> ({x:etm} etp-eq (B x) B') -> type. +%mode evof-noassm +X1 -X2. + +- : evof-noassm _ ([_] etp-eq/i). + +%worlds (evar | ebind) (evof-noassm _ _). +%total {} (evof-noassm _ _). + + +eof-noassm : ({x:etm} eof (M x) (A x)) + -> ({x} etm-eq M' (M x)) + -> ({x} etp-eq A' (A x)) -> type. +%mode eof-noassm +X1 -X2 -X3. + +ekof-noassm : ({x:etm} ekof (A x) (K x)) + -> ({x} etp-eq A' (A x)) + -> ({x} ekind-eq K' (K x)) -> type. +%mode ekof-noassm +X1 -X2 -X3. + +ewfkind-noassm : ({x:etm} ewfkind (K x)) + -> ({x} ekind-eq K' (K x)) -> type. +%mode ewfkind-noassm +X1 -X2. + +eqtm-noassm : ({x:etm} eqtm (M x) (N x) (A x)) + -> ({x} etm-eq M' (M x)) + -> ({x} etm-eq N' (N x)) + -> ({x} etp-eq A' (A x)) -> type. +%mode eqtm-noassm +X1 -X2 -X3 -X4. + +eqtp-noassm : ({x:etm} eqtp (A x) (B x) (K x)) + -> ({x} etp-eq A' (A x)) + -> ({x} etp-eq B' (B x)) + -> ({x} ekind-eq K' (K x)) -> type. +%mode eqtp-noassm +X1 -X2 -X3 -X4. + +eqkind-noassm : ({x:etm} eqkind (K x) (L x)) + -> ({x} ekind-eq K' (K x)) + -> ({x} ekind-eq L' (L x)) -> type. +%mode eqkind-noassm +X1 -X2 -X3. + +-const : eof-noassm + ([x] eof/const + (DofA x : ekof A ektype) + (Dcof : ecof C A)) + ([_] etm-eq/i) + ([_] etp-eq/i). + +-var : eof-noassm + ([x] eof/var + (DofA x : ekof A ektype) + (Dvof : evof Y A)) + ([_] etm-eq/i) + ([_] etp-eq/i). + +-app : eof-noassm + ([x] eof/app + (DofN x : eof (N x) (B x)) + (DofM x : eof (M x) (epi (B x) ([y] A x y)))) + DeqApp + Deq + <- eof-noassm DofM + ([x] DeqM x : etm-eq M' (M x)) + ([x] DeqPi x + : etp-eq (epi B' ([y] A' y)) (epi (B x) ([y] A x y))) + <- eof-noassm DofN + ([x] DeqN x : etm-eq N' (N x)) + _ + <- ({x} + epi-inj (DeqPi x) + (DeqB x : etp-eq B' (B x)) + ([y] DeqA x y : etp-eq (A' y) (A x y))) + <- ({x} + eapp-compat (DeqM x) (DeqN x) + (DeqApp x : etm-eq (eapp M' N') (eapp (M x) (N x)))) + <- ({x} + etpsubst-compat ([y] DeqA x y) (DeqN x) + (Deq x : etp-eq (A' N') (A x (N x)))). + +-lam : eof-noassm + ([x] eof/lam + (DofA x : ekof (A x) ektype) + ([y] [e:evof y (A x)] DofM x y e : eof (M x y) (B x y))) + DeqLam + DeqPi + <- ekof-noassm DofA + ([x] DeqA x : etp-eq A' (A x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA' x)) + <- eof-resp-underbind-1 DofM DeqA' + ([_][_] etm-eq/i) ([_][_]etp-eq/i) + ([x] [y] [e:evof y A'] + DofM' x y e : eof (M x y) (B x y)) + <- ({y} {e:evof y A'} + eof-noassm ([x] DofM' x y e) + ([x] DeqM x y : etm-eq (M' y) (M x y)) + ([x] DeqB x y : etp-eq (B' y) (B x y))) + %% + <- ({x} + elam-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : etm-eq (elam A' ([y] M' y)) (elam (A x) ([y] M x y)))) + <- ({x} + epi-compat (DeqA x) ([y] DeqB x y) + (DeqPi x : etp-eq (epi A' B') (epi (A x) (B x)))). + +-eqtp : eof-noassm + ([x] eof/eqtp + (Deqtp x : eqtp (A x) (B x) ektype) + (Dof x : eof (M x) (A x))) + DeqM + DeqB + <- eof-noassm Dof + ([x] DeqM x : etm-eq M' (M x)) + _ + <- eqtp-noassm Deqtp + _ + ([x] DeqB x: etp-eq B' (B x)) + _. + +-ext : eof-noassm + ([x] eof/ext + ([y] [e:evof y (B x)] + DofApp x y e : eof (eapp (C x) y) (K x y)) + (DofC x : eof (C x) (epi (B x) ([y] K' x y)))) + ([x] DeqC x) + ([x] DeqPi' x) + <- eof-noassm DofC + ([x] DeqC x : etm-eq C' (C x)) + ([x] DeqPi x + : etp-eq (epi B' ([y] K'' y)) (epi (B x) ([y] K' x y))) + <- ({x} + epi-inj (DeqPi x) + (DeqB x : etp-eq B' (B x)) + _) + <- ({x} etp-eq-sym (DeqB x) (DeqB' x : etp-eq (B x) B')) + <- eof-resp-underbind-1 DofApp DeqB' + ([_][_] etm-eq/i) ([_][_] etp-eq/i) + ([x] [y] [e:evof y B'] + DofApp' x y e : eof (eapp (C x) y) (K x y)) + <- ({y} {e:evof y B'} + eof-noassm ([x] DofApp' x y e) + ([x] Dontcare x y) + ([x] DeqK x y : etp-eq (K* y) (K x y))) + <- ({x} + epi-compat (DeqB x) ([y] DeqK x y) + (DeqPi' x + : etp-eq + (epi B' ([y] K* y)) (epi (B x) ([y] K x y)))). +%% + +-const : ekof-noassm + ([x] ekof/const + (Dwfkind x : ewfkind K) + (Dckof : eckof C K)) + ([x] etp-eq/i) + ([x] ekind-eq/i). + +-app : ekof-noassm + ([x] ekof/app + (Dof x : eof (M x) (B x)) + (Dkof x : ekof (A x) (ekpi (B x) ([y] K x y)))) + ([x] DeqApp x) + ([x] DeqK' x) + <- ekof-noassm Dkof + ([x] DeqA x : etp-eq A' (A x)) + ([x] DeqPi x + : ekind-eq (ekpi B' ([y] K' y)) (ekpi (B x) ([y] K x y))) + <- eof-noassm Dof + ([x] DeqM x : etm-eq M' (M x)) + _ + <- ({x} + eaapp-compat (DeqA x) (DeqM x) + (DeqApp x : etp-eq (eaapp A' M') (eaapp (A x) (M x)))) + <- ({x} + ekpi-inj (DeqPi x) + (DeqB x : etp-eq B' (B x)) + ([y] DeqK x y : ekind-eq (K' y) (K x y))) + <- ({x} + eksubst-compat ([y] DeqK x y) (DeqM x) + (DeqK' x : ekind-eq (K' M') (K x (M x)))). + +-pi : ekof-noassm + ([x] ekof/pi + ([y] [e:evof y (A x)] DofM x y e : ekof (M x y) ektype) + (DofA x : ekof (A x) ektype)) + DeqLam + ([_] ekind-eq/i) + <- ekof-noassm DofA + ([x] DeqA x : etp-eq A' (A x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA' x)) + <- ekof-resp-underbind-1 DofM DeqA' + ([_][_] etp-eq/i) ([_][_]ekind-eq/i) + ([x] [y] [e:evof y A'] + DofM' x y e : ekof (M x y) ektype) + <- ({y} {e:evof y A'} + ekof-noassm ([x] DofM' x y e) + ([x] DeqM x y : etp-eq (M' y) (M x y)) + ([x] Dontcare x y)) + %% + <- ({x} + epi-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : etp-eq (epi A' ([y] M' y)) (epi (A x) ([y] M x y)))). + + +-lam : ekof-noassm + ([x] ekof/lam + (DofA x : ekof (A x) ektype) + ([y] [e:evof y (A x)] DofM x y e : ekof (M x y) (B x y))) + DeqLam + DeqPi + <- ekof-noassm DofA + ([x] DeqA x : etp-eq A' (A x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA' x)) + <- ekof-resp-underbind-1 DofM DeqA' + ([_][_] etp-eq/i) ([_][_]ekind-eq/i) + ([x] [y] [e:evof y A'] + DofM' x y e : ekof (M x y) (B x y)) + <- ({y} {e:evof y A'} + ekof-noassm ([x] DofM' x y e) + ([x] DeqM x y : etp-eq (M' y) (M x y)) + ([x] DeqB x y : ekind-eq (B' y) (B x y))) + %% + <- ({x} + ealam-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : etp-eq (ealam A' ([y] M' y)) (ealam (A x) ([y] M x y)))) + <- ({x} + ekpi-compat (DeqA x) ([y] DeqB x y) + (DeqPi x : ekind-eq (ekpi A' B') (ekpi (A x) (B x)))). + + +-eqkind : ekof-noassm + ([x] ekof/eqkind + (Deqkind x : eqkind (K x) (L x)) + (Dkof x : ekof (A x) (K x))) + DeqA + DeqL + <- ekof-noassm Dkof + ([x] DeqA x : etp-eq A' (A x)) + _ + <- eqkind-noassm Deqkind + ([x] DeqK x : ekind-eq K' (K x)) + ([x] DeqL x : ekind-eq L' (L x)). + +-ext : ekof-noassm + ([x] ekof/ext + ([y] [e:evof y (B x)] + DofApp x y e : ekof (eaapp (C x) y) (K x y)) + (DofC x : ekof (C x) (ekpi (B x) ([y] K' x y)))) + ([x] DeqC x) + ([x] DeqPi' x) + <- ekof-noassm DofC + ([x] DeqC x : etp-eq C' (C x)) + ([x] DeqPi x + : ekind-eq (ekpi B' ([y] K'' y)) (ekpi (B x) ([y] K' x y))) + <- ({x} + ekpi-inj (DeqPi x) + (DeqB x : etp-eq B' (B x)) + _) + <- ({x} etp-eq-sym (DeqB x) (DeqB' x : etp-eq (B x) B')) + <- ekof-resp-underbind-1 DofApp DeqB' + ([_][_] etp-eq/i) ([_][_] ekind-eq/i) + ([x] [y] [e:evof y B'] + DofApp' x y e : ekof (eaapp (C x) y) (K x y)) + <- ({y} {e:evof y B'} + ekof-noassm ([x] DofApp' x y e) + ([x] Dontcare x y) + ([x] DeqK x y : ekind-eq (K* y) (K x y))) + <- ({x} + ekpi-compat (DeqB x) ([y] DeqK x y) + (DeqPi' x + : ekind-eq + (ekpi B' ([y] K* y)) (ekpi (B x) ([y] K x y)))). +%% + +-type : ewfkind-noassm ([_] ewfkind/tp) ([_] ekind-eq/i). + +-pi : ewfkind-noassm + ([x] ewfkind/pi + ([y] [e:evof y (A x)] DofM x y e : ewfkind (M x y)) + (DofA x : ekof (A x) ektype)) + DeqLam + <- ekof-noassm DofA + ([x] DeqA x : etp-eq A' (A x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA' x)) + <- ewfkind-resp-underbind-1 DofM DeqA' + ([_][_] ekind-eq/i) + ([x] [y] [e:evof y A'] + DofM' x y e : ewfkind (M x y)) + <- ({y} {e:evof y A'} + ewfkind-noassm ([x] DofM' x y e) + ([x] DeqM x y : ekind-eq (M' y) (M x y))) + %% + <- ({x} + ekpi-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : ekind-eq + (ekpi A' ([y] M' y)) (ekpi (A x) ([y] M x y)))). + +%% + +-app : eqtm-noassm + ([x] eqtm/app + (DeqtmN x : eqtm (N x) (N' x) (B x)) + (DeqtmM x : eqtm (M x) (M' x) (epi (B x) ([y] A x y)))) +%% + DeqApp + DeqApp' + DeqAy +%% + <- eqtm-noassm DeqtmM + ([x] DeqM x : etm-eq M* (M x)) + ([x] DeqM' x : etm-eq M'* (M' x)) + ([x] DeqPi x : etp-eq C (epi (B x) ([y] A x y))) + <- eqtm-noassm DeqtmN + ([x] DeqN x : etm-eq N* (N x)) + ([x] DeqN' x : etm-eq N'* (N' x)) + _ + <- ({x} eapp-compat (DeqM x) (DeqN x) + (DeqApp x : etm-eq (eapp M* N*) (eapp (M x) (N x)))) + <- ({x} eapp-compat (DeqM' x) (DeqN' x) + (DeqApp' x : etm-eq (eapp M'* N'*) (eapp (M' x) (N' x)))) + %% + <- etp-eq-pi-strengthen DeqPi + ([x] DeqB x : etp-eq B* (B x)) + ([x] [y] DeqA x y : etp-eq (A* y) (A x y)) + <- ({x} + etpsubst-compat ([y] DeqA x y) (DeqN x) + (DeqAy x : etp-eq (A* N*) (A x (N x)))). + +-lam : eqtm-noassm + ([x] eqtm/lam + ([y] [e:evof y (A x)] + DeqtmM x y e : eqtm (M x y) (M' x y) (B x y)) + (DeqtpA x : eqtp (A x) (A' x) ektype)) +%% + DeqLam + DeqLam' + DeqPi +%% + <- eqtp-noassm DeqtpA + ([x] DeqA x : etp-eq A* (A x)) + ([x] DeqA' x : etp-eq A'* (A' x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA* x : etp-eq (A x) A*)) + <- eqtm-resp-underbind-1 DeqtmM DeqA* + ([x][y]etm-eq/i) ([x][y]etm-eq/i) ([x][y]etp-eq/i) + ([x] [y] [e:evof y A*] + DeqtmM' x y e : eqtm (M x y) (M' x y) (B x y)) + <- ({y} {e:evof y A*} + eqtm-noassm ([x] DeqtmM' x y e) + ([x] DeqM x y : etm-eq (M* y) (M x y)) + ([x] DeqM' x y : etm-eq (M'* y) (M' x y)) + ([x] DeqB x y : etp-eq (B* y) (B x y))) + <- ({x} + elam-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : etm-eq (elam A* ([y] M* y)) (elam (A x) ([y] M x y)))) + <- ({x} + elam-compat (DeqA' x) ([y] DeqM' x y) + (DeqLam' x + : etm-eq (elam A'* ([y] M'* y)) (elam (A' x) ([y] M' x y)))) + <- ({x} + epi-compat (DeqA x) ([y] DeqB x y) + (DeqPi x + : etp-eq (epi A* ([y] B* y)) (epi (A x) ([y] B x y)))). + +-ext : eqtm-noassm + ([x] eqtm/ext + ([y] [e:evof y (A x)] + DeqtmApp x y e + : eqtm (eapp (M x) y) (eapp (N x) y) (B x y)) + (DofN x : eof (N x) (epi (A x) ([y] B2 x y))) + (DofM x : eof (M x) (epi (A x) ([y] B1 x y)))) +%% + DeqM + DeqN + DeqPi +%% + <- eof-noassm DofM + ([x] DeqM x : etm-eq M' (M x)) + ([x] DeqPi1 x : etp-eq Pi1 (epi (A x) ([y] B1 x y))) + <- eof-noassm DofN + ([x] DeqN x : etm-eq N' (N x)) + _ + <- etp-eq-pi-strengthen DeqPi1 + ([x] DeqA x : etp-eq A' (A x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA' x : etp-eq (A x) A')) + <- eqtm-resp-underbind-1 DeqtmApp DeqA' + ([_][_]etm-eq/i) ([_][_]etm-eq/i) ([_][_]etp-eq/i) + ([x] [y] [e:evof y A'] + DeqApp' x y e : eqtm (eapp (M x) y) (eapp (N x) y) (B x y)) + <- ({y} {e:evof y A'} + eqtm-noassm ([x] DeqApp' x y e) + ([x] DeqAppM x y : etm-eq (MApp y) (eapp (M x) y)) + ([x] DeqAppN x y : etm-eq (NApp y) (eapp (N x) y)) + ([x] DeqB x y : etp-eq (B' y) (B x y))) + <- ({x} + epi-compat (DeqA x) ([y] DeqB x y) + (DeqPi x)). + +-extw : eqtm-noassm + ([x] eqtm/extw + ([y] [e:evof y (A x)] + DeqtmApp x y e + : eqtm (eapp (M x) y) (eapp (N x) y) (B x y)) + (Deqtm x : eqtm (M x) (N x) (epi (A x) ([y] B' x y)))) +%% + DeqM + DeqN + DeqPi +%% + <- eqtm-noassm Deqtm + ([x] DeqM x : etm-eq M' (M x)) + ([x] DeqN x : etm-eq N' (N x)) + ([x] DeqPi' x : etp-eq Pi (epi (A x) ([y] B' x y))) + <- etp-eq-pi-strengthen DeqPi' + ([x] DeqA x : etp-eq A' (A x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA' x : etp-eq (A x) A')) + <- eqtm-resp-underbind-1 DeqtmApp DeqA' + ([_][_]etm-eq/i) ([_][_]etm-eq/i) ([_][_]etp-eq/i) + ([x] [y] [e:evof y A'] + DeqApp' x y e :eqtm (eapp (M x) y) (eapp (N x) y) (B x y)) + <- ({y} {e:evof y A'} + eqtm-noassm ([x] DeqApp' x y e) + ([x] DeqAppM x y : etm-eq (MApp y) (eapp (M x) y)) + ([x] DeqAppN x y : etm-eq (NApp y) (eapp (N x) y)) + ([x] DeqB x y : etp-eq (B* y) (B x y))) + <- ({x} + epi-compat (DeqA x) ([y] DeqB x y) + (DeqPi x)). + +-beta : eqtm-noassm + ([x] eqtm/beta + (DofN x : eof (N x) (A x)) + ([y] [e:evof y (A x)] DofM x y e : eof (M x y) (B x y))) +%% + DeqApp + DeqMy + DeqBy +%% + <- eof-noassm DofN + ([x] DeqN x : etm-eq N' (N x)) + ([x] DeqA x : etp-eq A' (A x)) + <- ({x} etp-eq-sym (DeqA x) (DeqA' x : etp-eq (A x) A')) + <- eof-resp-underbind-1 DofM DeqA' + ([x] [y] etm-eq/i) ([x] [y] etp-eq/i) + ([x] [y] [e:evof y A'] DofM' x y e : eof (M x y) (B x y)) + <- ({y} {e:evof y A'} + eof-noassm ([x] DofM' x y e) + ([x] DeqM x y : etm-eq (M' y) (M x y)) + ([x] DeqB x y : etp-eq (B' y) (B x y))) + <- ({x} + elam-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : etm-eq (elam A' ([y] M' y)) (elam (A x) ([y] M x y)))) + <- ({x} + eapp-compat (DeqLam x) (DeqN x) + (DeqApp x)) + <- ({x} + esubst-compat ([y] DeqM x y) (DeqN x) + (DeqMy x : etm-eq (M' N') (M x (N x)))) + <- ({x} + etpsubst-compat ([y] DeqB x y) (DeqN x) + (DeqBy x : etp-eq (B' N') (B x (N x)))). + +-sym : eqtm-noassm + ([x] eqtm/sym + (Deqtm x : eqtm (M x) (N x) (A x))) +%% + DeqN + DeqM + DeqA +%% + <- eqtm-noassm Deqtm + ([x] DeqM x : etm-eq M' (M x)) + ([x] DeqN x : etm-eq N' (N x)) + ([x] DeqA x : etp-eq A' (A x)). + +-trans : eqtm-noassm + ([x] eqtm/trans + (DeqtmNO x : eqtm (N x) (O x) (A x)) + (DeqtmMN x : eqtm (M x) (N x) (A x))) +%% + DeqM + DeqO + DeqA +%% + <- eqtm-noassm DeqtmMN + ([x] DeqM x : etm-eq M' (M x)) + ([x] DeqN x : etm-eq N' (N x)) + ([x] DeqA x : etp-eq A' (A x)) + <- eqtm-noassm DeqtmNO + _ + ([x] DeqO x : etm-eq O' (O x)) + _. + +-refl : eqtm-noassm + ([x] eqtm/refl + (Dof x : eof (M x) (A x))) + DeqM + DeqM + DeqA + <- eof-noassm Dof + ([x] DeqM x : etm-eq M' (M x)) + ([x] DeqA x : etp-eq A' (A x)). + +-eqtp : eqtm-noassm + ([x] eqtm/typecon + (Deqtp x : eqtp (A x) (B x) ektype) + (Deqtm x : eqtm (M x) (N x) (A x))) +%% + DeqM + DeqN + DeqB +%% + <- eqtm-noassm Deqtm + ([x] DeqM x : etm-eq M' (M x)) + ([x] DeqN x : etm-eq N' (N x)) + _ + <- eqtp-noassm Deqtp + _ + ([x] DeqB x : etp-eq B' (B x)) + _. + +%% + +-app : eqtp-noassm + ([x] eqtp/app + (DeqtmN x : eqtm (N x) (N' x) (B x)) + (DeqtmM x : eqtp (M x) (M' x) (ekpi (B x) ([y] A x y)))) +%% + DeqApp + DeqApp' + DeqAy +%% + <- eqtp-noassm DeqtmM + ([x] DeqM x : etp-eq M* (M x)) + ([x] DeqM' x : etp-eq M'* (M' x)) + ([x] DeqPi x : ekind-eq C (ekpi (B x) ([y] A x y))) + <- eqtm-noassm DeqtmN + ([x] DeqN x : etm-eq N* (N x)) + ([x] DeqN' x : etm-eq N'* (N' x)) + _ + <- ({x} eaapp-compat (DeqM x) (DeqN x) + (DeqApp x : etp-eq (eaapp M* N*) (eaapp (M x) (N x)))) + <- ({x} eaapp-compat (DeqM' x) (DeqN' x) + (DeqApp' x : etp-eq (eaapp M'* N'*) (eaapp (M' x) (N' x)))) + %% + <- ekind-eq-pi-strengthen DeqPi + ([x] DeqB x : etp-eq B* (B x)) + ([x] [y] DeqA x y : ekind-eq (A* y) (A x y)) + <- ({x} + eksubst-compat ([y] DeqA x y) (DeqN x) + (DeqAy x : ekind-eq (A* N*) (A x (N x)))). + +-pi : eqtp-noassm + ([x] eqtp/pi + ([y] [e:evof y (A x)] + DeqtmM x y e : eqtp (M x y) (M' x y) ektype) + (DeqtpA x : eqtp (A x) (A' x) ektype)) +%% + DeqLam + DeqLam' + ([_] ekind-eq/i) +%% + <- eqtp-noassm DeqtpA + ([x] DeqA x : etp-eq A* (A x)) + ([x] DeqA' x : etp-eq A'* (A' x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA* x : etp-eq (A x) A*)) + <- eqtp-resp-underbind-1 DeqtmM DeqA* + ([x][y]etp-eq/i) ([x][y]etp-eq/i) ([x][y]ekind-eq/i) + ([x] [y] [e:evof y A*] + DeqtmM' x y e : eqtp (M x y) (M' x y) ektype) + <- ({y} {e:evof y A*} + eqtp-noassm ([x] DeqtmM' x y e) + ([x] DeqM x y : etp-eq (M* y) (M x y)) + ([x] DeqM' x y : etp-eq (M'* y) (M' x y)) + ([x] Dontcare x y)) + <- ({x} + epi-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : etp-eq + (epi A* ([y] M* y)) (epi (A x) ([y] M x y)))) + <- ({x} + epi-compat (DeqA' x) ([y] DeqM' x y) + (DeqLam' x + : etp-eq + (epi A'* ([y] M'* y)) (epi (A' x) ([y] M' x y)))). + +-lam : eqtp-noassm + ([x] eqtp/lam + ([y] [e:evof y (A x)] + DeqtmM x y e : eqtp (M x y) (M' x y) (B x y)) + (DeqtpA x : eqtp (A x) (A' x) ektype)) +%% + DeqLam + DeqLam' + DeqPi +%% + <- eqtp-noassm DeqtpA + ([x] DeqA x : etp-eq A* (A x)) + ([x] DeqA' x : etp-eq A'* (A' x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA* x : etp-eq (A x) A*)) + <- eqtp-resp-underbind-1 DeqtmM DeqA* + ([x][y]etp-eq/i) ([x][y]etp-eq/i) ([x][y]ekind-eq/i) + ([x] [y] [e:evof y A*] + DeqtmM' x y e : eqtp (M x y) (M' x y) (B x y)) + <- ({y} {e:evof y A*} + eqtp-noassm ([x] DeqtmM' x y e) + ([x] DeqM x y : etp-eq (M* y) (M x y)) + ([x] DeqM' x y : etp-eq (M'* y) (M' x y)) + ([x] DeqB x y : ekind-eq (B* y) (B x y))) + <- ({x} + ealam-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : etp-eq + (ealam A* ([y] M* y)) (ealam (A x) ([y] M x y)))) + <- ({x} + ealam-compat (DeqA' x) ([y] DeqM' x y) + (DeqLam' x + : etp-eq + (ealam A'* ([y] M'* y)) (ealam (A' x) ([y] M' x y)))) + <- ({x} + ekpi-compat (DeqA x) ([y] DeqB x y) + (DeqPi x + : ekind-eq + (ekpi A* ([y] B* y)) (ekpi (A x) ([y] B x y)))). + +-ext : eqtp-noassm + ([x] eqtp/ext + ([y] [e:evof y (A x)] + DeqtmApp x y e + : eqtp (eaapp (M x) y) (eaapp (N x) y) (B x y)) + (DofN x : ekof (N x) (ekpi (A x) ([y] B2 x y))) + (DofM x : ekof (M x) (ekpi (A x) ([y] B1 x y)))) +%% + DeqM + DeqN + DeqPi +%% + <- ekof-noassm DofM + ([x] DeqM x : etp-eq M' (M x)) + ([x] DeqPi1 x : ekind-eq Pi1 (ekpi (A x) ([y] B1 x y))) + <- ekof-noassm DofN + ([x] DeqN x : etp-eq N' (N x)) + _ + <- ekind-eq-pi-strengthen DeqPi1 + ([x] DeqA x : etp-eq A' (A x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA' x : etp-eq (A x) A')) + <- eqtp-resp-underbind-1 DeqtmApp DeqA' + ([_][_]etp-eq/i) ([_][_]etp-eq/i) ([_][_]ekind-eq/i) + ([x] [y] [e:evof y A'] + DeqApp' x y e : eqtp (eaapp (M x) y) (eaapp (N x) y) (B x y)) + <- ({y} {e:evof y A'} + eqtp-noassm ([x] DeqApp' x y e) + ([x] DeqAppM x y : etp-eq (MApp y) (eaapp (M x) y)) + ([x] DeqAppN x y : etp-eq (NApp y) (eaapp (N x) y)) + ([x] DeqB x y : ekind-eq (B' y) (B x y))) + <- ({x} + ekpi-compat (DeqA x) ([y] DeqB x y) + (DeqPi x)). + +-ext : eqtp-noassm + ([x] eqtp/extw + ([y] [e:evof y (A x)] + DeqtmApp x y e + : eqtp (eaapp (M x) y) (eaapp (N x) y) (B x y)) + (Deqtm x : eqtp (M x) (N x) (ekpi (A x) ([y] B1 x y)))) +%% + DeqM + DeqN + DeqPi +%% + <- eqtp-noassm Deqtm + ([x] DeqM x : etp-eq M' (M x)) + ([x] DeqN x : etp-eq N' (N x)) + ([x] DeqPi1 x : ekind-eq Pi1 (ekpi (A x) ([y] B1 x y))) + <- ekind-eq-pi-strengthen DeqPi1 + ([x] DeqA x : etp-eq A' (A x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA' x : etp-eq (A x) A')) + <- eqtp-resp-underbind-1 DeqtmApp DeqA' + ([_][_]etp-eq/i) ([_][_]etp-eq/i) ([_][_]ekind-eq/i) + ([x] [y] [e:evof y A'] + DeqApp' x y e : eqtp (eaapp (M x) y) (eaapp (N x) y) (B x y)) + <- ({y} {e:evof y A'} + eqtp-noassm ([x] DeqApp' x y e) + ([x] DeqAppM x y : etp-eq (MApp y) (eaapp (M x) y)) + ([x] DeqAppN x y : etp-eq (NApp y) (eaapp (N x) y)) + ([x] DeqB x y : ekind-eq (B' y) (B x y))) + <- ({x} + ekpi-compat (DeqA x) ([y] DeqB x y) + (DeqPi x)). + + +-beta : eqtp-noassm + ([x] eqtp/beta + (DofN x : eof (N x) (A x)) + ([y] [e:evof y (A x)] DofM x y e : ekof (M x y) (B x y))) +%% + DeqApp + DeqMy + DeqBy +%% + <- eof-noassm DofN + ([x] DeqN x : etm-eq N' (N x)) + ([x] DeqA x : etp-eq A' (A x)) + <- ({x} etp-eq-sym (DeqA x) (DeqA' x : etp-eq (A x) A')) + <- ekof-resp-underbind-1 DofM DeqA' + ([x] [y] etp-eq/i) ([x] [y] ekind-eq/i) + ([x] [y] [e:evof y A'] DofM' x y e : ekof (M x y) (B x y)) + <- ({y} {e:evof y A'} + ekof-noassm ([x] DofM' x y e) + ([x] DeqM x y : etp-eq (M' y) (M x y)) + ([x] DeqB x y : ekind-eq (B' y) (B x y))) + <- ({x} + ealam-compat (DeqA x) ([y] DeqM x y) + (DeqLam x + : etp-eq (ealam A' ([y] M' y)) (ealam (A x) ([y] M x y)))) + <- ({x} + eaapp-compat (DeqLam x) (DeqN x) + (DeqApp x)) + <- ({x} + etpsubst-compat ([y] DeqM x y) (DeqN x) + (DeqMy x : etp-eq (M' N') (M x (N x)))) + <- ({x} + eksubst-compat ([y] DeqB x y) (DeqN x) + (DeqBy x : ekind-eq (B' N') (B x (N x)))). + +-sym : eqtp-noassm + ([x] eqtp/sym + (Deqtp x : eqtp (M x) (N x) (A x))) + DeqN + DeqM + DeqA + <- eqtp-noassm Deqtp + ([x] DeqM x : etp-eq M' (M x)) + ([x] DeqN x : etp-eq N' (N x)) + ([x] DeqA x : ekind-eq A' (A x)). + +-trans : eqtp-noassm + ([x] eqtp/trans + (DeqtpNO x : eqtp (N x) (O x) (A x)) + (DeqtpMN x : eqtp (M x) (N x) (A x))) + DeqM + DeqO + DeqA + <- eqtp-noassm DeqtpMN + ([x] DeqM x : etp-eq M' (M x)) + ([x] DeqN x : etp-eq N' (N x)) + ([x] DeqA x : ekind-eq A' (A x)) + <- eqtp-noassm DeqtpNO + _ + ([x] DeqO x : etp-eq O' (O x)) + _. + +-refl : eqtp-noassm + ([x] eqtp/refl + (Dof x : ekof (M x) (A x))) + DeqM + DeqM + DeqA + <- ekof-noassm Dof + ([x] DeqM x : etp-eq M' (M x)) + ([x] DeqA x : ekind-eq A' (A x)). + +-eqkind : eqtp-noassm + ([x] eqtp/kcon + (Deqkind x : eqkind (K x) (L x)) + (Deqtp x : eqtp (A x) (B x) (K x))) +%% + DeqA + DeqB + DeqL +%% + <- eqtp-noassm Deqtp + ([x] DeqA x : etp-eq A' (A x)) + ([x] DeqB x : etp-eq B' (B x)) + _ + <- eqkind-noassm Deqkind + ([x] DeqK x : ekind-eq K' (K x)) + ([x] DeqL x : ekind-eq L' (L x)). + +%% + +-type : eqkind-noassm ([_] eqkind/tp) ([_] ekind-eq/i) ([_] ekind-eq/i). + +-pi : eqkind-noassm + ([x] eqkind/pi + ([y] [e:evof y (A x)] + DeqtmM x y e : eqkind (M x y) (M' x y)) + (DeqtpA x : eqtp (A x) (A' x) ektype)) +%% + DeqPi + DeqPi' +%% + <- eqtp-noassm DeqtpA + ([x] DeqA x : etp-eq A* (A x)) + ([x] DeqA' x : etp-eq A'* (A' x)) + _ + <- ({x} etp-eq-sym (DeqA x) (DeqA* x : etp-eq (A x) A*)) + <- eqkind-resp-underbind-1 DeqtmM DeqA* + ([x][y]ekind-eq/i) ([x][y]ekind-eq/i) + ([x] [y] [e:evof y A*] + DeqtmM' x y e : eqkind (M x y) (M' x y)) + <- ({y} {e:evof y A*} + eqkind-noassm ([x] DeqtmM' x y e) + ([x] DeqM x y : ekind-eq (M* y) (M x y)) + ([x] DeqM' x y : ekind-eq (M'* y) (M' x y))) + <- ({x} + ekpi-compat (DeqA x) ([y] DeqM x y) + (DeqPi x + : ekind-eq + (ekpi A* ([y] M* y)) (ekpi (A x) ([y] M x y)))) + <- ({x} + ekpi-compat (DeqA' x) ([y] DeqM' x y) + (DeqPi' x + : ekind-eq + (ekpi A'* ([y] M'* y)) (ekpi (A' x) ([y] M' x y)))). + +-sym : eqkind-noassm + ([x] eqkind/sym (Deqkind x : eqkind (M x) (N x))) + DeqN + DeqM + <- eqkind-noassm Deqkind + ([x] DeqM x : ekind-eq M' (M x)) + ([x] DeqN x : ekind-eq N' (N x)). + +-trans : eqkind-noassm + ([x] eqkind/trans + (DeqkindNO x : eqkind (N x) (O x)) + (DeqkindMN x : eqkind (M x) (N x))) + DeqM + DeqO + <- eqkind-noassm DeqkindMN + ([x] DeqM x : ekind-eq M' (M x)) + ([x] DeqN x : ekind-eq N' (N x)) + <- eqkind-noassm DeqkindNO + _ + ([x] DeqO x : ekind-eq O' (O x)). + +-refl : eqkind-noassm + ([x] eqkind/refl + (Dof x : ewfkind (M x))) + DeqM + DeqM + <- ewfkind-noassm Dof + ([x] DeqM x : ekind-eq M' (M x)). + +%worlds (ecsig | easig | ebind | evar) + (eof-noassm _ _ _) + (ekof-noassm _ _ _) + (ewfkind-noassm _ _) + (eqtm-noassm _ _ _ _) + (eqtp-noassm _ _ _ _) + (eqkind-noassm _ _ _). +%total (D1 D2 D3 D4 D5 D6) + (eof-noassm D1 _ _) + (ekof-noassm D2 _ _) + (ewfkind-noassm D3 _) + (eqtm-noassm D4 _ _ _) + (eqtp-noassm D5 _ _ _) + (eqkind-noassm D6 _ _). + diff --git a/src/esubstitution.thm b/src/esubstitution.thm new file mode 100644 index 0000000..7c90c5c --- /dev/null +++ b/src/esubstitution.thm @@ -0,0 +1,378 @@ + +esubst-of-gen : (evof M A -> eof N B) + -> (eof M A -> eof N B) -> type. +%mode esubst-of-gen +X1 -X2. + +esubst-kof-gen : (evof M A -> ekof B K) + -> (eof M A -> ekof B K) -> type. +%mode esubst-kof-gen +X1 -X2. + +esubst-wfkind-gen : (evof M A -> ewfkind K) + -> (eof M A -> ewfkind K) -> type. +%mode esubst-wfkind-gen +X1 -X2. + +esubst-eqtm-gen : (evof M A -> eqtm N N' B) + -> (eof M A -> eqtm N N' B) -> type. +%mode esubst-eqtm-gen +X1 -X2. + +esubst-eqtp-gen : (evof M A -> eqtp B C K) + -> (eof M A -> eqtp B C K) -> type. +%mode esubst-eqtp-gen +X1 -X2. + +esubst-eqkind-gen : (evof M A -> eqkind B C) + -> (eof M A -> eqkind B C) -> type. +%mode esubst-eqkind-gen +X1 -X2. + +-varoth : esubst-of-gen + ([dv:evof M A] + eof/var + (DofB dv : ekof B ektype) + (DofX : evof X B)) + ([d] eof/var (DofB' d) DofX) + <- esubst-kof-gen ([dv] DofB dv) + ([d] DofB' d : ekof B ektype). + +-varsam : esubst-of-gen + ([dv:evof M A] + eof/var + (DofA dv : ekof A ektype) + dv) + ([d] d). + +-const : esubst-of-gen + ([dv:evof M A] + eof/const + (DofB dv : ekof B ektype) + (DofC : ecof C B)) + ([d] eof/const (DofB' d) DofC) + <- esubst-kof-gen ([dv] DofB dv) + ([d] DofB' d : ekof B ektype). + +-app : esubst-of-gen + ([dv] eof/app (DofM2 dv) (DofN1 dv)) + ([d] eof/app (DofM2' d) (DofN1' d)) + <- esubst-of-gen DofN1 DofN1' + <- esubst-of-gen DofM2 DofM2'. + +-lam : esubst-of-gen + ([dv] eof/lam (D1 dv) (D2 dv)) + ([d] eof/lam (D1' d) (D2' d)) + <- esubst-kof-gen D1 D1' + <- ({y} {e} esubst-of-gen ([dv] D2 dv y e) ([d] D2' d y e)). + +-eqtp : esubst-of-gen + ([dv:evof M A] + eof/eqtp + (DeqBC dv : eqtp B C ektype) + (DofN dv : eof N B)) +%% + ([d:eof M A] + eof/eqtp + (DeqBC' d) + (DofN' d)) +%% + <- esubst-of-gen ([dv] DofN dv) + ([d] DofN' d : eof N B) + <- esubst-eqtp-gen ([dv] DeqBC dv) + ([d] DeqBC' d : eqtp B C ektype). + +-ext : esubst-of-gen + ([dv:evof M A] + eof/ext + ([x] [dx] DofApp dv x dx : eof (eapp N x) (C x)) + (DofN dv : eof N (epi B C'))) +%% + ([d] + eof/ext + (DofApp' d) + (DofN' d)) +%% + <- esubst-of-gen DofN + ([d] DofN' d : eof N (epi B C')) + <- ({x} {dx} + esubst-of-gen ([dv] DofApp dv x dx) + ([d] DofApp' d x dx : eof (eapp N x) (C x))). + +%% + +-const : esubst-kof-gen + ([dv] ekof/const (Dwfkind dv) Dckof) + ([d] ekof/const (Dwfkind' d) Dckof) + <- esubst-wfkind-gen Dwfkind Dwfkind'. + +-app : esubst-kof-gen + ([dv] ekof/app (DofM dv) (DofA dv)) + ([d] ekof/app (DofM' d) (DofA' d)) + <- esubst-of-gen DofM DofM' + <- esubst-kof-gen DofA DofA'. + +-pi : esubst-kof-gen + ([dv] ekof/pi ([x] [dx] D2 dv x dx) (D1 dv)) + ([d] ekof/pi ([x] [dx] D2' d x dx) (D1' d)) + <- esubst-kof-gen D1 D1' + <- ({x} {dx} + esubst-kof-gen ([dv] D2 dv x dx) ([d] D2' d x dx)). + +-lam : esubst-kof-gen + ([dv] ekof/lam (D1 dv) (D2 dv)) + ([d] ekof/lam (D1' d) (D2' d)) + <- esubst-kof-gen D1 D1' + <- ({y} {e} esubst-kof-gen ([dv] D2 dv y e) ([d] D2' d y e)). + +-eqkind : esubst-kof-gen + ([dv] ekof/eqkind (Deqkind dv) (Dkof dv)) + ([d] ekof/eqkind (Deqkind' d) (Dkof' d)) + <- esubst-kof-gen Dkof Dkof' + <- esubst-eqkind-gen Deqkind Deqkind'. + +-ext : esubst-kof-gen + ([dv] ekof/ext ([y] [e] Dkof dv y e) (Deof dv)) + ([d] ekof/ext ([y] [e] Dkof' d y e) (Deof' d)) + <- esubst-kof-gen Deof Deof' + <- ({y} {e} esubst-kof-gen + ([dv] Dkof dv y e) ([d] Dkof' d y e)). + +%% + +-tp : esubst-wfkind-gen ([dv] ewfkind/tp) ([d] ewfkind/tp). + +-pi : esubst-wfkind-gen + ([dv] ewfkind/pi ([y] [e] D2 dv y e) (D1 dv)) + ([d] ewfkind/pi ([y] [e] D2' d y e) (D1' d)) + <- esubst-kof-gen D1 D1' + <- ({y} {e} + esubst-wfkind-gen ([dv] D2 dv y e) ([d] D2' d y e)). + +%% + +-app : esubst-eqtm-gen + ([dv] eqtm/app (Deq2 dv) (Deq1 dv)) + ([d] eqtm/app (Deq2' d) (Deq1' d)) + <- esubst-eqtm-gen Deq1 Deq1' + <- esubst-eqtm-gen Deq2 Deq2'. + +-lam : esubst-eqtm-gen + ([dv] eqtm/lam ([y] [e] Deqtm dv y e) (Deqtp dv)) + ([d] eqtm/lam ([y] [e] Deqtm' d y e) (Deqtp' d)) + <- esubst-eqtp-gen Deqtp Deqtp' + <- ({y} {e} + esubst-eqtm-gen ([dv] Deqtm dv y e) ([d] Deqtm' d y e)). + +-ext : esubst-eqtm-gen + ([dv] eqtm/ext ([y] [e] DeqtmApp dv y e) (DofN dv) (DofM dv)) + ([d] eqtm/ext ([y] [e] DeqtmApp' d y e) (DofN' d) (DofM' d)) + <- ({y} {e} + esubst-eqtm-gen ([dv] DeqtmApp dv y e) + ([d] DeqtmApp' d y e)) + <- esubst-of-gen DofN DofN' + <- esubst-of-gen DofM DofM'. + +-extw : esubst-eqtm-gen + ([dv] eqtm/extw ([y] [e] DeqtmApp dv y e) (Deqtm dv)) + ([d] eqtm/extw ([y] [e] DeqtmApp' d y e) (Deqtm' d)) + <- ({y} {e} + esubst-eqtm-gen ([dv] DeqtmApp dv y e) + ([d] DeqtmApp' d y e)) + <- esubst-eqtm-gen Deqtm Deqtm'. + +-beta : esubst-eqtm-gen + ([dv] eqtm/beta (DofN dv) ([y] [e] DofM dv y e)) + ([d] eqtm/beta (DofN' d) ([y] [e] DofM' d y e)) + <- esubst-of-gen DofN DofN' + <- ({y} {e} + esubst-of-gen ([dv] DofM dv y e) ([d] DofM' d y e)). + +-sym : esubst-eqtm-gen + ([dv] eqtm/sym (Deqtm dv)) + ([dv] eqtm/sym (Deqtm' dv)) + <- esubst-eqtm-gen Deqtm Deqtm'. + +-trans : esubst-eqtm-gen + ([dv] eqtm/trans (D2 dv) (D1 dv)) + ([d] eqtm/trans (D2' d) (D1' d)) + <- esubst-eqtm-gen D1 D1' + <- esubst-eqtm-gen D2 D2'. + +-refl : esubst-eqtm-gen + ([dv] eqtm/refl (Dof dv)) + ([d] eqtm/refl (Dof' d)) + <- esubst-of-gen Dof Dof'. + +-tpcon : esubst-eqtm-gen + ([dv] eqtm/typecon (Deqtp dv) (Deqtm dv)) + ([d] eqtm/typecon (Deqtp' d) (Deqtm' d)) + <- esubst-eqtp-gen Deqtp Deqtp' + <- esubst-eqtm-gen Deqtm Deqtm'. + +%% + +-app : esubst-eqtp-gen + ([dv] eqtp/app (Deqtm dv) (Deqtp dv)) + ([d] eqtp/app (Deqtm' d) (Deqtp' d)) + <- esubst-eqtp-gen Deqtp Deqtp' + <- esubst-eqtm-gen Deqtm Deqtm'. + +-pi : esubst-eqtp-gen + ([dv] eqtp/pi ([y] [e] D2 dv y e) (D1 dv)) + ([d] eqtp/pi ([y] [e] D2' d y e) (D1' d)) + <- esubst-eqtp-gen D1 D1' + <- ({y} {e} + esubst-eqtp-gen ([dv] D2 dv y e) ([d] D2' d y e)). + +-lam : esubst-eqtp-gen + ([dv] eqtp/lam (D2 dv) (D1 dv)) + ([d] eqtp/lam (D2' d) (D1' d)) + <- esubst-eqtp-gen D1 D1' + <- ({y} {e} esubst-eqtp-gen ([dv] D2 dv y e) ([d] D2' d y e)). + +-ext : esubst-eqtp-gen + ([dv] eqtp/ext ([y] [e] DeqtpApp dv y e) (DofB dv) (DofA dv)) + ([d] eqtp/ext ([y] [e] DeqtpApp' d y e) (DofB' d) (DofA' d)) + <- ({y} {e} + esubst-eqtp-gen ([dv] DeqtpApp dv y e) + ([d] DeqtpApp' d y e)) + <- esubst-kof-gen DofB DofB' + <- esubst-kof-gen DofA DofA'. + +-extw : esubst-eqtp-gen + ([dv] eqtp/extw ([y] [e] DeqtmApp dv y e) (Deqtm dv)) + ([d] eqtp/extw ([y] [e] DeqtmApp' d y e) (Deqtm' d)) + <- ({y} {e} + esubst-eqtp-gen ([dv] DeqtmApp dv y e) + ([d] DeqtmApp' d y e)) + <- esubst-eqtp-gen Deqtm Deqtm'. + + +-beta : esubst-eqtp-gen + ([dv] eqtp/beta (DofN dv) ([y] [e] DofB dv y e)) + ([d] eqtp/beta (DofN' d) ([y] [e] DofB' d y e)) + <- esubst-of-gen DofN DofN' + <- ({y} {e} + esubst-kof-gen ([dv] DofB dv y e) ([d] DofB' d y e)). + +-sym : esubst-eqtp-gen + ([dv] eqtp/sym (Deqtp dv)) + ([dv] eqtp/sym (Deqtp' dv)) + <- esubst-eqtp-gen Deqtp Deqtp'. + +-trans : esubst-eqtp-gen + ([dv] eqtp/trans (D2 dv) (D1 dv)) + ([d] eqtp/trans (D2' d) (D1' d)) + <- esubst-eqtp-gen D1 D1' + <- esubst-eqtp-gen D2 D2'. + +-refl : esubst-eqtp-gen + ([dv] eqtp/refl (Dof dv)) + ([d] eqtp/refl (Dof' d)) + <- esubst-kof-gen Dof Dof'. + +-kcon : esubst-eqtp-gen + ([dv] eqtp/kcon (Deqkind dv) (Deqtp dv)) + ([d] eqtp/kcon (Deqkind' d) (Deqtp' d)) + <- esubst-eqkind-gen Deqkind Deqkind' + <- esubst-eqtp-gen Deqtp Deqtp'. + +%% + +-tp : esubst-eqkind-gen ([dv] eqkind/tp) ([d] eqkind/tp). + +-pi : esubst-eqkind-gen + ([dv] eqkind/pi ([y] [e] Deqkind dv y e) (Deqtp dv)) + ([d] eqkind/pi ([y] [e] Deqkind' d y e) (Deqtp' d)) + <- ({y} {e} + esubst-eqkind-gen ([dv] Deqkind dv y e) + ([d] Deqkind' d y e)) + <- esubst-eqtp-gen Deqtp Deqtp'. + +-sym : esubst-eqkind-gen + ([dv] eqkind/sym (Deqkind dv)) + ([dv] eqkind/sym (Deqkind' dv)) + <- esubst-eqkind-gen Deqkind Deqkind'. + +-trans : esubst-eqkind-gen + ([dv] eqkind/trans (D2 dv) (D1 dv)) + ([d] eqkind/trans (D2' d) (D1' d)) + <- esubst-eqkind-gen D1 D1' + <- esubst-eqkind-gen D2 D2'. + +-refl : esubst-eqkind-gen + ([dv] eqkind/refl (Dof dv)) + ([d] eqkind/refl (Dof' d)) + <- esubst-wfkind-gen Dof Dof'. + +%worlds (ecsig | easig | evar | ebind) + (esubst-of-gen _ _) (esubst-kof-gen _ _) (esubst-wfkind-gen _ _) + (esubst-eqtm-gen _ _) (esubst-eqtp-gen _ _) (esubst-eqkind-gen _ _). +%total (D1 D2 D3 D4 D5 D6) + (esubst-of-gen D1 _) (esubst-kof-gen D2 _) (esubst-wfkind-gen D3 _) + (esubst-eqtm-gen D4 _) (esubst-eqtp-gen D5 _) (esubst-eqkind-gen D6 _). + +esubst-eqtp : ({x} evof x A -> eqtp (B x) (B' x) (K x)) + -> eof N A + -> eqtp (B N) (B' N) (K N) -> type. +%mode esubst-eqtp +X1 +X2 -X3. + +- : esubst-eqtp D1 D2 (D1' D2) + <- esubst-eqtp-gen (D1 _) D1'. + +%worlds (ecsig | easig | evar | ebind) (esubst-eqtp _ _ _). +%total {} (esubst-eqtp _ _ _). + + +esubst-eqkind : ({x} evof x A -> eqkind (K x) (K' x)) + -> eof N A + -> eqkind (K N) (K' N) -> type. +%mode esubst-eqkind +X1 +X2 -X3. + +- : esubst-eqkind D1 D2 (D1' D2) + <- esubst-eqkind-gen (D1 _) D1'. + +%worlds (ecsig | easig | evar | ebind) (esubst-eqkind _ _ _). +%total {} (esubst-eqkind _ _ _). + + +esubst-wfkind : ({x} evof x A -> ewfkind (K x)) + -> eof N A + -> ewfkind (K N) -> type. +%mode esubst-wfkind +X1 +X2 -X3. + +- : esubst-wfkind D1 D2 (D1' D2) + <- esubst-wfkind-gen (D1 _) D1'. + +%worlds (ecsig | easig | evar | ebind) (esubst-wfkind _ _ _). +%total {} (esubst-wfkind _ _ _). + +esubst-kof : ({x} evof x A -> ekof (B x) (K x)) + -> eof N A + -> ekof (B N) (K N) -> type. +%mode esubst-kof +X1 +X2 -X3. + +- : esubst-kof D1 D2 (D1' D2) + <- esubst-kof-gen (D1 _) D1'. + +%worlds (ecsig | easig | evar | ebind) (esubst-kof _ _ _). +%total {} (esubst-kof _ _ _). + +esubst : ({x} evof x A -> eof (M x) (B x)) + -> eof N A + -> eof (M N) (B N) -> type. +%mode esubst +X1 +X2 -X3. + +- : esubst D1 D2 (D1' D2) + <- esubst-of-gen (D1 _) D1'. + +%worlds (ecsig | easig | evar | ebind) (esubst _ _ _). +%total D (esubst D _ _). + +esubst-eqtm : ({x} evof x A -> eqtm (B x) (C x) (K x)) + -> eof N A + -> eqtm (B N) (C N) (K N) -> type. +%mode esubst-eqtm +X1 +X2 -X3. + +- : esubst-eqtm D1 D2 (D1' D2) + <- esubst-eqtm-gen (D1 _) D1'. + +%worlds (ecsig | easig | evar | ebind) (esubst-eqtm _ _ _). +%total {} (esubst-eqtm _ _ _). + + diff --git a/src/expand.elf b/src/expand.elf new file mode 100644 index 0000000..8653699 --- /dev/null +++ b/src/expand.elf @@ -0,0 +1,18 @@ +%%%% expansion %%%% + +expand : atm -> stp -> tm -> type. + +expand/o : expand R o (at R). + +expand/arr : expand R (arrow S T) (lam [x] N x) + <- ({x} expand x S (M x)) + <- ({x} expand (app R (M x)) T (N x)). + + +tpexpand : atp -> skind -> tp -> type. + +tpexpand/type : tpexpand P sktype (base P). + +tpexpand/arr : tpexpand P (karrow T H) (alam [x] A x) + <- ({x} expand x T (M x)) + <- ({x} tpexpand (aapp P (M x)) H (A x)). diff --git a/src/expand.thm b/src/expand.thm new file mode 100644 index 0000000..3b73cb3 --- /dev/null +++ b/src/expand.thm @@ -0,0 +1,1154 @@ +%%%% + +kofe-lam-type-contra : kofe G (alam _) ktype -> false -> type. +%mode kofe-lam-type-contra +X2 -X3. + +%worlds (csig | asig | bind | ovar | var) (kofe-lam-type-contra _ _). +%total D (kofe-lam-type-contra D _). + +kof-lam-type-contra : kof (alam _) ktype -> false -> type. +%mode kof-lam-type-contra +X2 -X3. + +%worlds (csig | asig | bind | ovar | var) (kof-lam-type-contra _ _). +%total D (kof-lam-type-contra D _). + +atof-lam-contra : at-of R (alam _) -> false -> type. +%mode atof-lam-contra +X1 -X2. + +-app : atof-lam-contra + (at-of/app + (Dsub : tpsub ([x] B x) M (alam ([y] C y))) + (DofM : of M A) + (DofR : at-of R (pi A ([x] B x))) + : at-of (app R M) (alam ([y] C y))) +%% + D +%% + <- atof-reg DofR + (kof/pi + ([x] [d] DofB x d : kof (B x) ktype) _) + <- tpsubst Dsub ksub/type DofB DofM + (Doflam : kof (alam [y] C y) ktype) + <- kof-lam-type-contra Doflam D. + +%worlds (csig | asig | bind | ovar | var) (atof-lam-contra _ _). +%total D (atof-lam-contra D _). + +atofe-lam-contra : ordered G -> at-ofe G R (alam _) -> false -> type. +%mode atofe-lam-contra +X0 +X1 -X2. + +-closed : atofe-lam-contra _ (at-ofe/closed D) Dfalse + <- atof-lam-contra D Dfalse. + +-app : atofe-lam-contra + (Dord : ordered G) + (at-ofe/app + (Dsub : tpsub ([x] B x) M (alam ([y] C y))) + (DofM : ofe G M A) + (DofR : at-ofe G R (pi A ([x] B x)))) +%% + Dfalse +%% + <- atofe-reg Dord DofR + (kofe/pi + ([x] DofB x : kofe (cons G x A) (B x) ktype) + (DofA : kofe G A ktype)) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x A)) + <- tpsubst-e ([x] [d] Dord' x d) ([_] append/nil) csub/base + DofM Dsub DofB ksub/type + (Dofalam : kofe G (alam ([y] C y)) ktype) + <- kofe-lam-type-contra Dofalam Dfalse. + +%worlds (csig | asig | bind | ovar | var) (atofe-lam-contra _ _ _). +%total D (atofe-lam-contra _ D _). + + +%%%% expansion effectiveness/functionality %%%% + +can-expand : {R} {T} expand R T M -> type. +%mode can-expand +R +T -Dexpand. + +- : can-expand _ o expand/o. + +- : can-expand _ (arrow S T) (expand/arr DexpandT DexpandS) + <- ({x} can-expand _ S (DexpandS x : expand _ S (M1 x))) + <- ({x} can-expand _ T (DexpandT x : expand _ T (M2 x))). + +%worlds (csig | asig | var | bind) (can-expand _ _ _). +%total A (can-expand _ A _). + + +can-tpexpand : {P} {H} tpexpand P H A -> type. +%mode can-tpexpand +P +M -Dexpand. + +- : can-tpexpand _ sktype tpexpand/type. + +- : can-tpexpand _ (karrow T H) (tpexpand/arr DexpandH DexpandT) + <- ({x} can-expand _ T (DexpandT x : expand _ T (M x))) + <- ({x} can-tpexpand _ H (DexpandH x : tpexpand _ H (A x))). + +%worlds (csig | asig | var | bind) (can-tpexpand _ _ _). +%total H (can-tpexpand _ H _). + + +expand-fun : expand R T M -> expand R T M' -> tm-eq M M' -> type. +%mode expand-fun +X1 +X2 -X3. + +- : expand-fun expand/o expand/o Deq + <- at-compat atm-eq/i Deq. + +- : expand-fun + (expand/arr + ([x] DexT x : expand (app R (M x)) T (N x)) + ([x] DexS x : expand x S (M x))) + (expand/arr + ([x] DexT' x : expand (app R (M' x)) T (N' x)) + ([x] DexS' x : expand x S (M' x))) + Deq + <- ({x} + expand-fun (DexS x) (DexS' x) + (DeqMM' x : tm-eq (M x) (M' x))) + <- ({x} + app-compat atm-eq/i (DeqMM' x) + (DeqApp x : atm-eq (app R (M x)) (app R (M' x)))) + <- ({x} + expand-resp (DeqApp x) stp-eq/i tm-eq/i (DexT x) + (DexT'' x : expand (app R (M' x)) T (N x))) + <- ({x} + expand-fun (DexT'' x) (DexT' x) + (DeqNN' x : tm-eq (N x) (N' x))) + <- lam-compat ([x] DeqNN' x) Deq. + +%worlds (csig | asig | var | bind | evar) (expand-fun _ _ _). +%total D (expand-fun _ D _). + + +tpexpand-fun : tpexpand P H A -> tpexpand P H A' -> tp-eq A A' -> type. +%mode tpexpand-fun +X1 +X2 -X3. + +- : tpexpand-fun tpexpand/type tpexpand/type Deq + <- base-compat atp-eq/i Deq. + +- : tpexpand-fun + (tpexpand/arr + ([x] DexApp x : tpexpand (aapp P (M x)) H (A x)) + ([x] DexX x : expand x T (M x))) + (tpexpand/arr + ([x] DexApp' x : tpexpand (aapp P (M' x)) H (A' x)) + ([x] DexX' x : expand x T (M' x))) + Deq + <- ({x} + expand-fun (DexX x) (DexX' x) + (DeqMM' x : tm-eq (M x) (M' x))) + <- ({x} + aapp-compat atp-eq/i (DeqMM' x) + (DeqApp x : atp-eq (aapp P (M x)) (aapp P (M' x)))) + <- ({x} + tpexpand-resp (DeqApp x) skind-eq/i tp-eq/i (DexApp x) + (DexApp'' x : tpexpand (aapp P (M' x)) H (A x))) + <- ({x} + tpexpand-fun (DexApp'' x) (DexApp' x) + (DeqAA' x : tp-eq (A x) (A' x))) + <- alam-compat ([x] DeqAA' x) Deq. + +%worlds (csig | asig | var | bind | evar) (tpexpand-fun _ _ _). +%total D (tpexpand-fun _ D _). + +%% expansion preserves freevars %% +expand-freevar : ({x:atm} expand R T (M x)) + -> expand R T M' -> ({x} tm-eq (M x) M') -> type. +%mode expand-freevar +X1 -X2 -X3. + +- : expand-freevar ([_] expand/o) expand/o ([_] tm-eq/i). + +- : expand-freevar + ([x] expand/arr + ([y] DexpApp x y : expand (app R (M x y)) T (N x y)) + ([y] DexpY x y : expand y S (M x y))) + (expand/arr ([y] DexpApp'' y) ([y] DexpY' y)) + ([x] DeqLam x) + <- ({y} + expand-freevar + ([x] DexpY x y) + (DexpY' y : expand y S (M' y)) + ([x] DeqMM' x y : tm-eq (M x y) (M' y))) + <- ({x} {y} + app-compat atm-eq/i (DeqMM' x y) + (DeqApp x y : atm-eq (app R (M x y)) (app R (M' y)))) + <- expand-resp-2 + ([x] [y] DeqApp x y) stp-eq/i ([_] [_] tm-eq/i) ([x] [y] DexpApp x y) + ([x] [y] DexpApp' x y : expand (app R (M' y)) T (N x y)) + <- ({y} + expand-freevar + ([x] DexpApp' x y) + (DexpApp'' y : expand (app R (M' y)) T (N' y)) + ([x] DeqNN' x y : tm-eq (N x y) (N' y))) + <- ({x} + lam-compat ([y] DeqNN' x y) + (DeqLam x : tm-eq (lam [y] N x y) (lam [y] N' y))). + + +%worlds (csig | asig | bind | var) (expand-freevar _ _ _). +%total D (expand-freevar D _ _). + +expand-arr-invert : expand R (arrow T1 T2) (lam [y] L y) +%% + -> ({y} expand (app R (Y y)) T2 (L y)) + -> ({y} expand y T1 (Y y)) -> type. +%mode expand-arr-invert +X1 -X2 -X3. + +- : expand-arr-invert (expand/arr DexpApp DexpY) + DexpApp + DexpY. + +%worlds (csig | asig | bind | var | ovar) (expand-arr-invert _ _ _). +%total D (expand-arr-invert D _ _). + + +%%%% more headvar definitions %%%% + +notheadvar : (atm -> atm) -> type. + +notheadvar/closed : notheadvar ([x] R). +notheadvar/app : notheadvar ([x] app (R x) (M x)) + <- notheadvar ([x] R x). + +headvar-notheadvar-contra : headvar ([x] R x) -> notheadvar ([x] R x) + -> false -> type. +%mode headvar-notheadvar-contra +X1 +X2 -X3. + +- : headvar-notheadvar-contra Dheadvar notheadvar/closed + Dfalse + <- headvar-closed-contra Dheadvar Dfalse. + +- : headvar-notheadvar-contra (headvar/app Dheadvar) (notheadvar/app Dnot) + Dfalse + <- headvar-notheadvar-contra Dheadvar Dnot Dfalse. + +%worlds (csig | asig | bind | var | ovar) (headvar-notheadvar-contra _ _ _). +%total D (headvar-notheadvar-contra D _ _). + + +%%%% expansion commutes with substitution %%%% + +expand-rrsub : {T} + ({x} expand (R x) T (N x)) + -> sub ([x] N x) M Nx + -> notheadvar ([x] R x) +%% + -> rrsub ([x] R x) M Rx + -> expand Rx T Nx -> type. +%mode expand-rrsub +T +X1 +X2 +X3 -X4 -X5. + +expand-rmsub : {T} + ({x} expand (R x) T (N x)) + -> sub ([x] N x) M N' + -> headvar ([x] R x) +%% + -> rmsub ([x] R x) M N' -> type. +%mode expand-rmsub +T +X0 +X1 +X2 -X3. + +rrsub-expand : {T} + expand R T XR + -> rrsub ([x] Q x) XR Qx +%% + -> atm-eq Qx (Q R) -> type. +%mode rrsub-expand +T +X1 +X2 -X3. + +rmsub-expand : {T} + expand R T XR + -> rmsub ([x] Q x) XR LQx +%% + -> {S} expand (Q R) S LQx -> type. +%mode rmsub-expand +T +X1 +X2 -S -X3. + +sub-expand : {T} + expand R T XR + -> sub ([x] M x) XR Mx +%% + -> tm-eq Mx (M R) -> type. +%mode sub-expand +T +X1 +X2 -X3. + +%{ +sub-expand-var : {T} + ({x} expand x T (X x)) + -> ({x} sub ([x] M x) (X x) (M' x)) +%% + -> ({x} tm-eq (M x) (M' x)) -> type. +%mode sub-expand-var +T +X1 +X2 -X3. +}% + +%% expand-rrsub + +-o : expand-rrsub o + ([x] expand/o : expand (R x) o (at (R x))) + (sub/rr (Drrsub : rrsub ([x] R x) M Rx)) + _ +%% + Drrsub + expand/o. + +-obad : expand-rrsub o + ([x] expand/o : expand (R x) o (at (R x))) + (sub/rm (Drmsub : rmsub ([x] R x) M (at Rx))) + (Dnotheadvar : notheadvar ([x] R x)) +%% + Drrsub + Dexpand +%% + <- rmsub-headvar Drmsub Dheadvar + <- headvar-notheadvar-contra Dheadvar Dnotheadvar Dfalse + <- false-implies-rrsub Dfalse + (Drrsub : rrsub ([x] R x) M aca) + <- false-implies-expand Dfalse + (Dexpand : expand aca o (at Rx)). + +-arr : expand-rrsub (arrow S T) + ([x] expand/arr + ([y] DexpApp x y : expand (app (R x) (Y x y)) T (O x y)) + ([y] DexpY x y : expand y S (Y x y)) + : expand (R x) (arrow S T) (lam [y] O x y)) + (sub/lam + ([y] DsubO y : sub ([x] O x y) M (Ox y)) + : sub ([x] lam [y] O x y) M (lam [y] Ox y)) + (Dnotheadvar : notheadvar ([x] R x)) +%% + (DsubR' aca) + (expand/arr (DexpApp' aca) DexpY') +%% + <- ({y} + expand-rrsub T ([x] DexpApp x y) (DsubO y) + (notheadvar/app Dnotheadvar) + (DsubApp y + : rrsub ([x] app (R x) (Y x y)) M (app (Rx y) (Yx y))) + (DexpAppx y + : expand (app (Rx y) (Yx y)) T (Ox y))) + <- ({y} + app-rrsub-invert (DsubApp y) + (DsubR y : rrsub ([x] R x) M (Rx y)) + (DsubY y : sub ([x] Y x y) M (Yx y))) + <- rrsub-closed ([y] DsubR y) + ([y] DeqRxR' y : atm-eq (Rx y) R') + <- ({y} + rrsub-compat ([_] atm-eq/i) tm-eq/i (DeqRxR' y) (DsubR y) + (DsubR' y : rrsub ([x] R x) M R')) + %% come up with expanding Y doesn't mention extra vars + <- ({y} + expand-freevar ([x] DexpY x y) + (DexpY' y : expand y S (Y' y)) + ([x] DeqYY' x y : tm-eq (Y x y) (Y' y))) + <- ({x} {y} + tm-eq-sym (DeqYY' x y) (DeqY'Y x y)) + <- ({y} + sub-absent _ _ + (DsubY' y : sub ([_] Y' y) M (Y' y))) + <- ({y} + sub-compat ([x] DeqY'Y x y) tm-eq/i tm-eq/i (DsubY' y) + (DsubYClosed y : sub ([x] Y x y) M (Y' y))) + <- ({y} + sub-fun (DsubY y) (DsubYClosed y) + (DeqYxY' y : tm-eq (Yx y) (Y' y))) + %% finish + <- ({y} + app-compat (DeqRxR' y) (DeqYxY' y) + (DeqApp y : atm-eq (app (Rx y) (Yx y)) (app R' (Y' y)))) + <- expand-resp-2 ([_] [y] DeqApp y) stp-eq/i ([_] [_] tm-eq/i) + ([_] [y] DexpAppx y) + ([x] [y] DexpApp' x y). + +%{ XXX proof for obsoleted definition + +-base : expand-rrsub o + ([x] + expand/o : expand (R x) o (at (R x))) + (DsubR : rrsub ([x] R x) M Rx) + expand/o +%% + (sub/rr DsubR). + +-arr : expand-rrsub (arrow T1 T2) + ([x] + expand/arr + ([y] DexpR x y + : expand (app (R x) (N x y)) T2 (N' x y)) + ([y] Dexpy x y + : expand y T1 (N x y))) + (DsubR : rrsub ([x] R x) M Rx) + (expand/arr + ([y] DexpRx y + : expand (app Rx (Nx y)) T2 (N'x y)) + ([y] Dexpy' y + : expand y T1 (Nx y))) +%% + (sub/lam ([y] DsubN' y)) +%% + %% come up with Dsuby : rrsub ([y] x) M x + <- ({y} + rrsub-absent y M (Dsuby y : rrsub ([x] y) M y)) + %% induct + <- ({y} + expand-rrsub _ + ([x] Dexpy x y) (Dsuby y) (Dexpy' y) + (DsubN y : sub ([x] N x y) M (Nx y))) + %% induct + <- ({y} + expand-rrsub T2 + ([x] DexpR x y) + (rrsub/app (DsubN y) DsubR) + (DexpRx y) + (DsubN' y : sub ([x] N' x y) M (N'x y))). +}% + +%% expand-rmsub + +-o : expand-rmsub o + ([x] expand/o : expand (R x) o (at (R x))) + (sub/rm (Drmsub : rmsub ([x] R x) M (at Rx))) + _ +%% + Drmsub. + +-obad : expand-rmsub o + ([x] expand/o) + (sub/rr (Drrsub : rrsub ([x] R x) M R')) + (Dheadvar : headvar ([x] R x)) +%% + Drmsub +%% + <- headvar-rrsub-contra Dheadvar Drrsub Dfalse + <- false-implies-rmsub Dfalse Drmsub. + +-arrow : expand-rmsub (arrow S T) + ([x] expand/arr + ([y] DexpApp x y : expand (app (R x) (Y x y)) T (O x y)) + ([y] DexpY x y : expand y S (Y x y)) + : expand (R x) (arrow S T) (lam [y] O x y)) + (sub/lam + ([y] DsubO y : sub ([x] O x y) M (Ox y)) + : sub ([x] lam [y] O x y) M (lam [y] Ox y)) + (Dheadvar : headvar ([x] R x)) +%% + (Dsub aca) +%% + %% induct to get a bunch of stuff + <- ({y} + expand-freevar ([x] DexpY x y) + (DexpY' y : expand y S (Y' y)) + ([x] DeqYY' x y : tm-eq (Y x y) (Y' y))) + <- ({x} {y} + app-compat atm-eq/i (DeqYY' x y) + (DeqApp x y : atm-eq (app (R x) (Y x y)) (app (R x) (Y' y)))) + <- expand-resp-2 ([x] [y] DeqApp x y) stp-eq/i ([_] [_] tm-eq/i) + ([x] [y] DexpApp x y) + ([x] [y] DexpApp' x y : expand (app (R x) (Y' y)) T (O x y)) + <- ({y} + expand-rmsub T + ([x] DexpApp' x y) + (DsubO y) + (headvar/app Dheadvar) + (rmsub/app + (DsubO' y : sub ([z] O' y z) (Yx y) (Ox y)) + (DsubY' y : sub ([x] Y' y) M (Yx y)) + (DsubR y : rmsub ([x] R x) M (lam [z] O' y z)) + : rmsub ([x] app (R x) (Y' y)) M (Ox y))) + %% Yx turns out to be Y' + <- ({y} + sub-absent _ _ + (DsubY'Y' y : sub ([x] Y' y) M (Y' y))) + <- ({y} + sub-fun (DsubY' y) (DsubY'Y' y) + (DeqYxY' y : tm-eq (Yx y) (Y' y))) + %% O' can't mention y + <- rmsub-closed ([y] DsubR y) + ([y] DeqLam y : tm-eq (lam [z] O' y z) (lam [z] O'' z)) + <- ({y} + lam-inj (DeqLam y) + ([z] DeqO'O'' y z : tm-eq (O' y z) (O'' z))) + %% congruence to get new substitution + <- sub-compat1 ([y] [z] DeqO'O'' y z) ([y] DeqYxY' y) ([_] tm-eq/i) + ([y] DsubO' y) + ([y] DsubO''Y' y : sub ([z] O'' z) (Y' y) (Ox y)) + %{ + <- sub-expand-var _ ([y] DexpY' y) ([y] DsubO''Y' y) + ([y] DeqO''Ox y : tm-eq (O'' y) (Ox y)) + %{ ([y] DsubO''O'' y : sub ([z] O'' z) (Y' y) (O'' y))}% + %{ + %% O'' = Ox + <- ({y} + sub-fun (DsubO''O'' y) (DsubO''Y' y) + (DeqO''Ox y : tm-eq (O'' y) (Ox y))) + }% + }% + <- ({y} + sub-expand _ (DexpY' y) (DsubO''Y' y) + (DeqOxO'' y : tm-eq (Ox y) (O'' y))) + <- ({y} tm-eq-sym (DeqOxO'' y) + (DeqO''Ox y : tm-eq (O'' y) (Ox y))) + %% O' = Ox + <- ({y} {z} + tm-eq-trans (DeqO'O'' y z) (DeqO''Ox z) + (DeqO'Ox y z : tm-eq (O' y z) (Ox z))) + %% wrap in lam + <- ({y} + lam-compat ([z] DeqO'Ox y z) + (DeqLam' y : tm-eq (lam [z] O' y z) (lam [z] Ox z))) + %% eq into DsubR + <- ({y} + rmsub-compat ([_] atm-eq/i) tm-eq/i (DeqLam' y) + (DsubR y) + (Dsub y : rmsub ([x] R x) M (lam [z] Ox z))). + +%% rrsub-expand + +-closed : rrsub-expand _ _ rrsub/closed + atm-eq/i. + +-app : rrsub-expand T + (Dexpand : expand R T XR) + (rrsub/app + (DsubM : sub ([x] M x) XR Mx) + (DsubQ : rrsub ([x] Q x) XR Qx)) +%% + Deq +%% + <- sub-expand T Dexpand DsubM + (DeqM : tm-eq Mx (M R)) + <- rrsub-expand T Dexpand DsubQ + (DeqQ : atm-eq Qx (Q R)) + <- app-compat DeqQ DeqM + (Deq : atm-eq (app Qx Mx) (app (Q R) (M R))). + +%% sub-expand + +-rr : sub-expand T + (Dexpand : expand R T XR) + (sub/rr + (DsubQ : rrsub ([x] Q x) XR Qx)) +%% + Deq +%% + <- rrsub-expand T Dexpand DsubQ + (DeqQ : atm-eq Qx (Q R)) + <- at-compat DeqQ + (Deq : tm-eq (at Qx) (at (Q R))). + +-rm : sub-expand T + (Dexpand : expand R T XR) + (sub/rm + (DsubQ : rmsub ([x] Q x) XR (at Qx))) +%% + Deq +%% + <- rmsub-expand T Dexpand DsubQ + _ (DexpQR : expand (Q R) o (at Qx)) + <- expand-fun DexpQR expand/o + Deq. + +-lam : sub-expand T + (Dexpand : expand R T XR) + (sub/lam + ([y] DsubM y : sub ([x] M x y) XR (Mx y))) +%% + Deq +%% + <- ({y} + sub-expand T Dexpand (DsubM y) + (DeqM y : tm-eq (Mx y) (M R y))) + <- lam-compat DeqM + (Deq : tm-eq (lam [y] Mx y) (lam [y] M R y)). + + +%% rmsub-expand + +-var : rmsub-expand T + (Dexpand : expand R T XR) + rmsub/var + T + Dexpand. + +-app : rmsub-expand T + (Dexpand : expand R T XR) + (rmsub/app + (DsubL : sub ([y] L y) Mx Ly) + (DsubM : sub ([x] M x) XR Mx) + (DsubQ : rmsub ([x] Q x) XR (lam [y] L y)) + : rmsub ([x] app (Q x) (M x)) XR Ly) +%% + T2 + Dexp +%% + <- rmsub-expand T Dexpand DsubQ + (arrow T1 T2) + (DexpQR : expand (Q R) (arrow T1 T2) (lam [y] L y)) + %{ + (expand/arr + ([y] DexpApp y : expand (app (Q R) (Y y)) T2 (L y)) + ([y] DexpY y : expand y T1 (Y y)) + : expand (Q R) (arrow T1 T2) (lam [y] L y)) + }% + <- expand-arr-invert DexpQR + ([y] DexpApp y : expand (app (Q R) (Y y)) T2 (L y)) + ([y] DexpY y : expand y T1 (Y y)) + <- sub-expand T Dexpand DsubM + (DeqM : tm-eq Mx (M R)) + <- expand-rrsub T2 ([y] DexpApp y) DsubL + (notheadvar/app notheadvar/closed) + (DsubApp : rrsub ([y] app (Q R) (Y y)) Mx (app QRy Yy)) + %{ + (rrsub/app + (DsubY : sub ([y] Y y) Mx Yy) + (DsubQR : rrsub ([y] Q R) Mx QRy) + : rrsub ([y] app (Q R) (Y y)) Mx (app QRy Yy)) + }% + (DexpQRy : expand (app QRy Yy) T2 Ly) + <- app-rrsub-invert DsubApp + (DsubQR : rrsub ([y] Q R) Mx QRy) + (DsubY : sub ([y] Y y) Mx Yy) + <- rrsub-fun DsubQR rrsub/closed + (DeqQRy : atm-eq QRy (Q R)) + %% come up with DeqYM : tm-eq Yy (M R) %% + <- expand-rmsub T1 ([y] DexpY y) DsubY headvar/var + (Dsuby : rmsub ([y] y) Mx Yy) + <- rmsub-fun Dsuby rmsub/var + (DeqYyMx : tm-eq Yy Mx) + <- tm-eq-trans DeqYyMx DeqM + (DeqYM : tm-eq Yy (M R)) + %% push the equalities through + <- app-compat DeqQRy DeqYM + (DeqApp : atm-eq (app QRy Yy) (app (Q R) (M R))) + <- expand-resp DeqApp stp-eq/i tm-eq/i DexpQRy + (Dexp : expand (app (Q R) (M R)) T2 Ly). + + + %{ + %%% come up with DsubYy : [M/y] eta(Y) = M %%% + %% come up with DsubQxy + <- expand-rrsub _ + ([y] DexpApp y) + (rrsub/app DsubYy DsubQxy + : rrsub ([y] app (Q R) (Y y)) (M R) (app (Q R) (M R))) + DexpQM + (DsubL' : sub ([y] L y) (M R) XQM) + <- sub-compat ([_] tm-eq/i) DeqM tm-eq/i DsubL + (DsubL'' : sub ([y] L y) (M R) Ly) + <- sub-fun DsubL' DsubL'' + (DeqL : tm-eq XQM Ly) + <- expand-resp atm-eq/i stp-eq/i DeqL DexpQM + (DexpQM' : expand (app (Q R) (M R)) T2 Ly). + }% + +%% sub-expand-var +%{ +- : sub-expand-var T + ([x] Dexpand x : expand x T (X x)) + ([x] DsubM x : sub ([x] M x) (X x) (M' x)) +%% + Deq' +%% + <- ({x} + sub-expand T (Dexpand x) (DsubM x) + (Deq x)) + <- ({x} tm-eq-sym (Deq x) (Deq' x)). +}% + +%worlds (csig | asig | bind | ovar | var) +(expand-rrsub _ _ _ _ _ _) +(expand-rmsub _ _ _ _ _) +(rrsub-expand _ _ _ _) +(rmsub-expand _ _ _ _ _) +(sub-expand _ _ _ _). +% (sub-expand-var _ _ _ _). +%reduces S <= T (rmsub-expand T _ _ S _). +%total {(T1 T2 T3 T4 T5) (D1 D2 D3 D4 D5)} +(expand-rrsub T1 _ _ D1 _ _) +(expand-rmsub T2 _ D2 _ _) +(rrsub-expand T3 _ D3 _) +(rmsub-expand T4 _ D4 _ _) +(sub-expand T5 _ D5 _). + + +%%%% more lemmas - atp %%%% + +atpsub-expand : {T} + expand R T XR + -> atpsub ([x] P x) XR Px +%% + -> atp-eq Px (P R) -> type. +%mode atpsub-expand +T +X1 +X2 -X3. + +-closed : atpsub-expand _ _ + (atpsub/closed : atpsub ([x] P) M P) + atp-eq/i. + +-aapp : atpsub-expand T + (Dexpand : expand R T XR) + (atpsub/app + (DsubM : sub ([x] M x) XR Mx) + (DsubP : atpsub ([x] P x) XR Px)) +%% + Deq +%% + <- atpsub-expand T Dexpand DsubP + (DeqP : atp-eq Px (P R)) + <- sub-expand T Dexpand DsubM + (DeqM : tm-eq Mx (M R)) + <- aapp-compat DeqP DeqM + (Deq : atp-eq (aapp Px Mx) (aapp (P R) (M R))). + +%worlds (csig | asig | var | bind | ovar) (atpsub-expand _ _ _ _). +%total {T D} (atpsub-expand T _ D _). + + +%%%% more lemmas - tp %%%% + +tpsub-expand : {T} + expand R T XR + -> tpsub ([x] B x) XR Bx +%% + -> tp-eq Bx (B R) -> type. +%mode tpsub-expand +T +X1 +X2 -X3. + +-base : tpsub-expand T + (Dexpand : expand R T XR) + (tpsub/base (DsubP : atpsub ([x] P x) XR Px) + : tpsub ([x] base (P x)) XR (base Px)) +%% + Deq +%% + <- atpsub-expand T Dexpand DsubP + (DeqP : atp-eq Px (P R)) + <- base-compat DeqP + (Deq : tp-eq (base Px) (base (P R))). + +-pi : tpsub-expand T + (Dexpand : expand R T XR) + (tpsub/pi + ([y] DsubB y : tpsub ([x] B x y) XR (Bx y)) + (DsubA : tpsub ([x] A x) XR Ax)) +%% + Deq +%% + <- tpsub-expand T Dexpand DsubA + (DeqA : tp-eq Ax (A R)) + <- ({y} + tpsub-expand T Dexpand (DsubB y) + (DeqB y : tp-eq (Bx y) (B R y))) + <- pi-compat DeqA ([y] DeqB y) + (Deq : tp-eq (pi Ax ([y] Bx y)) (pi (A R) ([y] B R y))). + +-alam : tpsub-expand T + (Dexpand : expand R T XR) + (tpsub/lam + ([y] DsubB y : tpsub ([x] B x y) XR (Bx y))) +%% + Deq +%% + <- ({y} + tpsub-expand T Dexpand (DsubB y) + (DeqB y : tp-eq (Bx y) (B R y))) + <- alam-compat ([x] DeqB x) + (Deq : tp-eq (alam ([x] Bx x)) (alam ([x] B R x))). + + +%worlds (csig | asig | var | bind | ovar) (tpsub-expand _ _ _ _). +%total {T D} (tpsub-expand T _ D _). + + +ksub-expand : {T} + expand R T XR + -> ksub ([x] K x) XR Kx +%% + -> kind-eq Kx (K R) -> type. +%mode ksub-expand +T +X1 +X2 -X3. + +-type : ksub-expand T _ ksub/type kind-eq/i. + +-pi : ksub-expand T + (Dexpand : expand R T XR) + (ksub/pi + ([y] DsubK y : ksub ([x] K x y) XR (Kx y)) + (DsubA : tpsub ([x] A x) XR Ax)) +%% + Deq +%% + <- tpsub-expand T Dexpand DsubA + (DeqA : tp-eq Ax (A R)) + <- ({y} + ksub-expand T Dexpand (DsubK y) + (DeqK y : kind-eq (Kx y) (K R y))) + <- kpi-compat DeqA ([y] DeqK y) + (Deq + : kind-eq (kpi Ax ([y] Kx y)) (kpi (A R) ([y] K R y))). + +%worlds (csig | asig | var | bind | ovar) (ksub-expand _ _ _ _). +%total {T D} (ksub-expand T _ D _). + + +%% XXX not needed +%{ +tpsub-expand-var : {T} {B} + ({x} expand x T (X x)) +%% + -> ({x} tpsub ([x] B x) (X x) (B x)) -> type. +%mode tpsub-expand-var +T +B +X2 -X3. + + +%worlds (csig | asig | var | bind | ovar) (tpsub-expand-var _ _ _ _). +%total {T D} (tpsub-expand-var T _ D _). +}% + + +%%% expansion (explicit contexts) %%% + +expand-reg-em : {T} + simp A T + -> ordered G + -> at-ofe G R A + -> expand R T M +%% + -> ofe G M A -> type. +%mode expand-reg-em +T +X0 +X1 +X2 +X3 -X4. + +-base : expand-reg-em _ _ _ Datof expand/o (ofe/at Datof). + +-pi : expand-reg-em _ + (simp/pi + ([x] DsimpB x : simp (B x) T) + (DsimpA : simp A S)) + (Dord : ordered G) + (DofR : at-ofe G R (pi A [x] B x)) + (expand/arr + ([x] Dexpand2 x : expand (app R (M x)) T (N x)) + ([x] Dexpand1 x : expand x S (M x))) +%% + (ofe/lam DkofA ([x] DofN x)) +%% + <- atofe-reg Dord DofR + (kofe/pi + ([x] DkofB x : kofe (cons G x A) (B x) ktype) + (DkofA : kofe G A ktype)) + % weaken the context with the pi-bound variable + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x A)) + <- ({x} + weaken-kofe DkofA A x + (DkofA' x : kofe (cons G x A) A ktype)) + % induct to get typing for expansion of the variable + <- ({x} {d} + expand-reg-em S DsimpA (Dord' x d) + (at-ofe/var (DkofA' x) lookup/hit) (Dexpand1 x) + (DofM x : ofe (cons G x A) (M x) A)) + % weaken some more stuff + <- ({x} + weaken-atofe DofR A x + (DofR' x : at-ofe (cons G x A) R (pi A [y] B y))) + <- weaken-kofe-insert1 Dord ([x] DkofB x) _ + ([x] [y] DkofB' x y : kofe (cons (cons G x A) y A) (B y) ktype) + % NTS: substing [expansion of x] for x in B is B + % (for the app typing rule in the inductive call) + <- can-tpsub-context-e Dord ([x] DofM x) ([x] DkofB x) + ([x] Dtpsub x : tpsub ([y] B y) (M x) (B' x)) + <- ({x} + tpsub-expand _ (Dexpand1 x) (Dtpsub x) + (Deq x : tp-eq (B' x) (B x))) + <- ({x} + tpsub-compat ([_] tp-eq/i) tm-eq/i (Deq x) (Dtpsub x) + (Dtpsub' x : tpsub ([x] B x) (M x) (B x))) + % induct on the expansion of the application of R + % to the expansion of x + <- ({x} {d} + expand-reg-em T (DsimpB x) (Dord' x d) + (at-ofe/app (Dtpsub' x) (DofM x) (DofR' x)) + (Dexpand2 x) + (DofN x : ofe (cons G x A) (N x) (B x))). + +-alam : expand-reg-em _ + (simp/lam ([x] DsimpB x : simp (B x) T) : simp (alam B) T) + (Dord : ordered G) + (DofR : at-ofe G R (alam ([x] B x))) + (Dexpand : expand R T M) +%% + D +%% + <- atofe-lam-contra Dord DofR Dfalse + <- false-implies-ofe Dfalse D. + +%worlds (bind | ovar | var | csig | asig) (expand-reg-em _ _ _ _ _ _). +%total {T D} (expand-reg-em T _ _ _ D _). + +tpexpand-reg-em : {H} + ksimp K H + -> ordered G + -> at-kofe G P K + -> tpexpand P H A +%% + -> kofe G A K -> type. +%mode tpexpand-reg-em +H +X0 +X1 +X2 +X3 -X4. + +-type : tpexpand-reg-em _ + ksimp/type + (Dord : ordered G) + (DofP : at-kofe G P ktype) + tpexpand/type + (kofe/base DofP). + +-arr : tpexpand-reg-em _ + (ksimp/pi + ([x] DsimpK x : ksimp (K x) H) + (DsimpA : simp A T) + : ksimp (kpi A [x] K x) (karrow T H)) + (Dord : ordered G) + (DofP : at-kofe G P (kpi A [x] K x)) + (tpexpand/arr + ([x] DexpandApp x : tpexpand (aapp P (X x)) H (B x)) + ([x] DexpandX x : expand x T (X x))) +%% + (kofe/lam + ([x] DofB x) + DofA) +%% + <- atkofe-reg Dord DofP + (wfkinde/pi + ([x] DofK x : wfkinde (cons G x A) (K x)) + (DofA : kofe G A ktype)) + % weaken + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x A)) + <- ({x} + weaken-kofe DofA A x + (DofA' x : kofe (cons G x A) A ktype)) + <- ({x} {d} + expand-reg-em T DsimpA (Dord' x d) + (at-ofe/var (DofA' x) lookup/hit) (DexpandX x) + (DofX x : ofe (cons G x A) (X x) A)) + <- ({x} + weaken-atkofe DofP A x + (DofP' x : at-kofe (cons G x A) P (kpi A [y] K y))) + % get substitution into K + <- can-ksub-context-e Dord ([x] DofX x) ([x] DofK x) + ([x] DsubK x : ksub ([y] K y) (X x) (K' x)) + <- ({x} + ksub-expand _ (DexpandX x) (DsubK x) + (DeqK'K x : kind-eq (K' x) (K x))) + <- ({x} + ksub-compat ([_] kind-eq/i) tm-eq/i (DeqK'K x) (DsubK x) + (DsubK' x : ksub ([y] K y) (X x) (K x))) + % induct on the DexpandApp + <- ({x} {d} + tpexpand-reg-em H (DsimpK x) (Dord' x d) + (at-kofe/app (DsubK' x) (DofX x) (DofP' x)) (DexpandApp x) + (DofB x : kofe (cons G x A) (B x) (K x))). + +%worlds (bind | ovar | var | csig | asig) (tpexpand-reg-em _ _ _ _ _ _). +%total {H D} (tpexpand-reg-em H _ _ _ D _). + + +expand-reg-e : ordered G + -> at-ofe G R A + -> simp A T + -> expand R T M +%% + -> ofe G M A -> type. +%mode expand-reg-e +X0 +X1 +X2 +X3 -X4. + +- : expand-reg-e Dord Datof Dsimp Dexpand Dof + <- expand-reg-em _ Dsimp Dord Datof Dexpand Dof. + +%worlds (bind | ovar | var | csig | asig) (expand-reg-e _ _ _ _ _). +%total {} (expand-reg-e _ _ _ _ _). + +tpexpand-reg-e : ordered G + -> at-kofe G P K + -> ksimp K H + -> tpexpand P H A +%% + -> kofe G A K -> type. +%mode tpexpand-reg-e +X0 +X2 +X2 +X3 -X4. + +- : tpexpand-reg-e Dord Datof Dsimp Dexpand Dof + <- tpexpand-reg-em _ Dsimp Dord Datof Dexpand Dof. + +%worlds (bind | ovar | var | csig | asig) (tpexpand-reg-e _ _ _ _ _). +%total {} (tpexpand-reg-e _ _ _ _ _). + + +%%%% expansion (implicit context) %%%% + +expand-reg : at-of R A + -> simp A T + -> expand R T M +%% + -> of M A -> type. +%mode expand-reg +X0 +X1 +X2 -X3. + +- : expand-reg Datof Dsimp Dexpand Dof + <- atof-to-atofe Datof Datofe + <- expand-reg-e ordered/nil Datofe Dsimp Dexpand Dofe + <- ofe-to-of Dofe Dof. + +%worlds (bind | var | ovar | csig | asig) (expand-reg _ _ _ _). +%total {} (expand-reg _ _ _ _). + + +tpexpand-reg : at-kof P K + -> ksimp K H + -> tpexpand P H A +%% + -> kof A K -> type. +%mode tpexpand-reg +X0 +X1 +X2 -X3. + +- : tpexpand-reg Datof Dsimp Dexpand Dof + <- atkof-to-atkofe Datof Datofe + <- tpexpand-reg-e ordered/nil Datofe Dsimp Dexpand Dofe + <- kofe-to-kof Dofe Dof. + +%worlds (csig | asig | bind | var | ovar) (tpexpand-reg _ _ _ _). +%total {} (tpexpand-reg _ _ _ _). + +%% misc %% + +strengthen-expand : ({x:atm} expand R T (M x)) + -> ({x} tm-eq (M x) M') -> type. +%mode strengthen-expand +X1 -X2. + +- : strengthen-expand Dexpand Deq + <- can-expand R T Dexpand' + <- ({x} + expand-fun (Dexpand x) Dexpand' (Deq x)). + +%worlds (csig | asig | var) (strengthen-expand _ _). +%total {} (strengthen-expand _ _). + +strengthen-tpexpand : ({x:atm} tpexpand P K (A x)) + -> ({x} tp-eq (A x) A') -> type. +%mode strengthen-tpexpand +X1 -X2. + +- : strengthen-tpexpand Dexpand Deq + <- can-tpexpand P K Dexpand' + <- ({x} tpexpand-fun (Dexpand x) Dexpand' (Deq x)). + +%worlds (csig | asig | var) (strengthen-tpexpand _ _). +%total {} (strengthen-tpexpand _ _). + + +%% simple types version %% + +expand-reg-es : sordered G + -> at-ofes G R T + -> expand R T M +%% + -> ofes G M T -> type. +%mode expand-reg-es +X1 +X2 +X3 -X4. + +-o : expand-reg-es _ (Datofes : at-ofes G R o) expand/o + (ofes/at Datofes). + +-arr : expand-reg-es + (Dord : sordered G) + (DofR : at-ofes G R (arrow S T)) + (expand/arr + ([x] Dexp2 x : expand (app R (M x)) T (N x)) + ([x] Dexp1 x : expand x S (M x))) +%% + (ofes/lam ([x] DofN x)) +%% + <- extend-sordered _ Dord _ + ([x] [d] Dord' x d : sordered (scons G x S)) + <- ({x} + weaken-atofes DofR x S + (DofR' x : at-ofes (scons G x S) R (arrow S T))) + <- ({x} {d} + expand-reg-es (Dord' x d) + (at-ofes/var slookup/hit) (Dexp1 x) + (DofM x : ofes (scons G x S) (M x) S)) + <- ({x} {d} + expand-reg-es (Dord' x d) + (at-ofes/app (DofM x) (DofR' x)) + (Dexp2 x) + (DofN x : ofes (scons G x S) (N x) T)). + +%worlds (csig | asig | var | ovar | bind) (expand-reg-es _ _ _ _). +%total D (expand-reg-es _ _ D _). + +tpexpand-reg-es : sordered G + -> at-kofes G P K + -> tpexpand P K A +%% + -> kofes G A K -> type. +%mode tpexpand-reg-es +X1 +X2 +X3 -X4. + +-tp : tpexpand-reg-es _ (Datkofes : at-kofes G P sktype) tpexpand/type + (kofes/base (Datkofes)). + +-arr : tpexpand-reg-es + (Dord : sordered G) + (DofP : at-kofes G P (karrow T H)) + (tpexpand/arr + ([x] Dtpexpand x : tpexpand (aapp P (M x)) H (A x)) + ([x] Dexpand x : expand x T (M x))) +%% + (kofes/lam ([x] DofA x)) +%% + <- extend-sordered _ Dord _ + ([x] [d] Dord' x d : sordered (scons G x T)) + <- ({x} + weaken-atkofes DofP x T + (DofP' x : at-kofes (scons G x T) P (karrow T H))) + <- ({x} {d} + expand-reg-es (Dord' x d) + (at-ofes/var slookup/hit) (Dexpand x) + (DofM x : ofes (scons G x T) (M x) T)) + <- ({x} {d} + tpexpand-reg-es (Dord' x d) + (at-kofes/app (DofM x) (DofP' x)) + (Dtpexpand x) + (DofA x : kofes (scons G x T) (A x) H)). + +%worlds (csig | asig | var | ovar | bind) (tpexpand-reg-es _ _ _ _). +%total D (tpexpand-reg-es _ _ D _). + + +expand-simp : tpexpand P K A -> simp A o -> type. +%mode expand-simp +X1 -X2. + +-tp : expand-simp tpexpand/type simp/base. + +-arr : expand-simp + (tpexpand/arr + ([x] Dtpexpand x : tpexpand (aapp P (M x)) H (A x)) + _) + (simp/lam ([x] DsimpA x)) + <- ({x} + expand-simp (Dtpexpand x) + (DsimpA x : simp (A x) o)). + +%worlds (csig | asig | var | bind) (expand-simp _ _). +%total D (expand-simp D _). + +expand-rmsub' : ({x} expand (R x) T (N x)) + -> rmsub ([x] R x) M N' + -> headvar ([x] R x) + -> ({x} {d:vof x A} of (N x) (B x)) + -> of M A +%% + -> sub ([x] N x) M N' -> type. +%mode expand-rmsub' +X1 +X2 +X3 +X4 +X5 -X6. + +- : expand-rmsub' + ([x] Dexpand x : expand (R x) T (N x)) + (Drmsub : rmsub ([x] R x) M N') + (Dheadvar : headvar ([x] R x)) + ([x] [d] DofN x d : of (N x) (B x)) + (DofM : of M A) + Dsub' + <- can-sub DofN DofM (Dsub : sub ([x] N x) M N'') + <- expand-rmsub T Dexpand Dsub Dheadvar + (Drmsub' : rmsub ([x] R x) M N'') + <- rmsub-fun Drmsub' Drmsub + (DeqN'' : tm-eq N'' N') + <- sub-compat ([x] tm-eq/i) tm-eq/i DeqN'' Dsub + (Dsub' : sub ([x] N x) M N'). + +%worlds (csig | asig | bind | var) (expand-rmsub' _ _ _ _ _ _). +%total {} (expand-rmsub' _ _ _ _ _ _). diff --git a/src/explicit-lemmas-noncan.thm b/src/explicit-lemmas-noncan.thm new file mode 100644 index 0000000..82e27a8 --- /dev/null +++ b/src/explicit-lemmas-noncan.thm @@ -0,0 +1,5844 @@ + +extend-eordered : {A} + eordered G + -> {I} + ({x:etm} eisvar x I -> eordered (econs G x A)) + -> type. +%mode extend-eordered +X1 +X2 -X3 -X4. + +- : extend-eordered _ eordered/nil + 0 ([x] [d] eordered/cons (ebounded/nil d)). + +- : extend-eordered _ (eordered/cons (ebounded/nil (DeisvarY : eisvar Y I))) + (s I) + ([x] [d] eordered/cons + (ebounded/cons + (ebounded/nil DeisvarY) + (eprecedes/i Dlt d DeisvarY))) + <- lt-succ I Dlt. + +- : extend-eordered _ + (eordered/cons + (ebounded/cons D1 (eprecedes/i D2 (DeisvarY:eisvar Y I) D3))) + (s I) + ([x] [d] eordered/cons + (ebounded/cons + (ebounded/cons D1 (eprecedes/i D2 (DeisvarY:eisvar Y I) D3)) + (eprecedes/i Dlt d DeisvarY))) + <- lt-succ I Dlt. + +%worlds (ecsig | easig | evar | eovar) (extend-eordered _ _ _ _). +%total {} (extend-eordered _ _ _ _). + +eisvar-fun : eisvar X I -> eisvar X J -> nat-eq I J -> type. +%mode eisvar-fun +X1 +X2 -X3. + +- : eisvar-fun D D nat-eq/i. + +%worlds (ecsig | easig | evar | eovar) (eisvar-fun _ _ _). +%total {} (eisvar-fun _ _ _). + +eprecedes-trans : eprecedes X Y -> eprecedes Y Z -> eprecedes X Z -> type. +%mode eprecedes-trans +X1 +X2 -X3. + +- : eprecedes-trans + (eprecedes/i DltIJ (DisvarY : eisvar Y J) (DisvarX : eisvar X I)) + (eprecedes/i DltJ'K (DisvarZ : eisvar Z K) (DisvarY' : eisvar Y J')) + (eprecedes/i DltIK DisvarZ DisvarX) + <- eisvar-fun DisvarY DisvarY' (Deq : nat-eq J J') + <- lt-resp nat-eq/i Deq DltIJ DltIJ' + <- lt-trans DltIJ' DltJ'K DltIK. + +%worlds (ecsig | easig | evar | eovar) (eprecedes-trans _ _ _). +%total {} (eprecedes-trans _ _ _). + + +eprecedes-antisymm : eprecedes X X -> false -> type. +%mode eprecedes-antisymm +X1 -X2. + +- : eprecedes-antisymm + (eprecedes/i (Dlt : lt I J) (Disvar' : eisvar X J) (Disvar : eisvar X I)) + Dfalse + <- eisvar-fun Disvar Disvar' (Deq : nat-eq I J) + <- lt-resp Deq nat-eq/i Dlt (Dlt' : lt J J) + <- lt-antisymm Dlt' Dfalse. + +%worlds (ecsig | easig | evar | eovar) (eprecedes-antisymm _ _). +%total {} (eprecedes-antisymm _ _). + +eordered-cons : eordered (econs G X A) -> eordered G -> type. +%mode eordered-cons +X1 -X2. + +-nil : eordered-cons + (eordered/cons (ebounded/nil Disvar : ebounded enil X)) + eordered/nil. + +-cons : eordered-cons + (eordered/cons (ebounded/cons Dbound _)) + (eordered/cons Dbound). + +%worlds (ecsig | easig | evar | eovar) (eordered-cons _ _). +%total D (eordered-cons D _). + +eordered-append : eappend G1 G2 G -> eordered G + -> eordered G1 -> type. +%mode eordered-append +X1 +X2 -X3. + +-nil : eordered-append (eappend/nil) Dord Dord. + +-cons : eordered-append (eappend/cons Dapp) Dord Dord1 + <- eordered-cons Dord Dord' + <- eordered-append Dapp Dord' Dord1. + +%worlds (ecsig | easig | evar | ebind | eovar) (eordered-append _ _ _). +%total D (eordered-append D _ _). + +strengthen-ebounded : ({x} eisvar x I -> ebounded G Y) + -> ebounded G Y -> type. +%mode strengthen-ebounded +X1 -X2. + +- : strengthen-ebounded ([x] [d] ebounded/nil D) (ebounded/nil D). + +- : strengthen-ebounded + ([x] [d] ebounded/cons (Dbound x d) Dprec) + (ebounded/cons Dbound' Dprec) + <- strengthen-ebounded Dbound Dbound'. + +%worlds (ecsig | easig | evar | ebind | eovar) (strengthen-ebounded _ _). +%total D (strengthen-ebounded D _). + +strengthen-eordered : ({x} eisvar x I -> eordered G) + -> eordered G -> type. +%mode strengthen-eordered +X1 -X2. + +- : strengthen-eordered ([x] [d] eordered/nil) eordered/nil. + +- : strengthen-eordered ([x] [d] eordered/cons (Dbound x d : ebounded G X)) + (eordered/cons Dbound') + <- strengthen-ebounded Dbound + (Dbound' : ebounded G X). + +%worlds (ecsig | easig | evar | ebind | eovar) (strengthen-eordered _ _). +%total D (strengthen-eordered D _). + + +ebounded-increase-bound : ebounded G X -> eprecedes X Y -> ebounded G Y -> type. +%mode ebounded-increase-bound +X1 +X2 -X3. + +- : ebounded-increase-bound (ebounded/nil _) (eprecedes/i _ D _) + (ebounded/nil D). + +- : ebounded-increase-bound (ebounded/cons Dbounded Dprecedes) Dprecedes' + (ebounded/cons Dbounded Dprecedes'') + <- eprecedes-trans Dprecedes Dprecedes' Dprecedes''. + +%worlds (ecsig | easig | evar | eovar) (ebounded-increase-bound _ _ _). +%total {} (ebounded-increase-bound _ _ _). + +ebounded-is-ordered : ebounded G X -> eordered G -> type. +%mode ebounded-is-ordered +X1 -X2. + +- : ebounded-is-ordered (ebounded/nil _) eordered/nil. +- : ebounded-is-ordered (ebounded/cons D _) (eordered/cons D). + +%worlds (ecsig | easig | evar | ebind | eovar) (ebounded-is-ordered _ _). +%total {} (ebounded-is-ordered _ _). + +ebounded-is-eordered-strengthen : ({x} eisvar x I -> ebounded G x) + -> eordered G -> type. +%mode ebounded-is-eordered-strengthen +X1 -X2. + +- : ebounded-is-eordered-strengthen ([x] [d] ebounded/nil d) eordered/nil. +- : ebounded-is-eordered-strengthen + ([x] [d] ebounded/cons (D x d) (eprecedes/i Dlt d Deisvar)) + (eordered/cons D') + <- strengthen-ebounded D D'. + +%worlds (ecsig | easig | evar | ebind | eovar) (ebounded-is-eordered-strengthen _ _). +%total {} (ebounded-is-eordered-strengthen _ _). + +elookup-bounded-contra : elookup G X A -> ebounded G X -> false -> type. +%mode elookup-bounded-contra +X1 +X2 -X3. + +- : elookup-bounded-contra elookup/hit (ebounded/cons _ Dprec) Dfalse + <- eprecedes-antisymm Dprec Dfalse. + +- : elookup-bounded-contra (elookup/miss Dlook) (ebounded/cons Dbound Dprec) + Dfalse + <- ebounded-increase-bound Dbound Dprec Dbound' + <- elookup-bounded-contra Dlook Dbound' Dfalse. + +%worlds (ecsig | easig | evar | eovar) (elookup-bounded-contra _ _ _). +%total D (elookup-bounded-contra D _ _). + + +elookup-fun : eordered G -> elookup G X A -> elookup G X B + -> etp-eq A B -> type. +%mode elookup-fun +X1 +X2 +X3 -X4. + +- : elookup-fun _ elookup/hit elookup/hit etp-eq/i. + +- : elookup-fun + (Dord : eordered (econs G Y B)) + (elookup/miss + (Dlook1 : elookup G X A)) + (elookup/miss + (Dlook2 : elookup G X A')) + D + <- eordered-cons Dord + (Dord' : eordered G) + <- elookup-fun Dord' Dlook1 Dlook2 D. + +- : elookup-fun + (eordered/cons (Dbound : ebounded G Y) : eordered (econs G Y S)) + (elookup/miss (Dlook : elookup G Y A)) + elookup/hit + Deq + <- elookup-bounded-contra Dlook Dbound Dfalse + <- false-implies-etp-eq Dfalse Deq. + +- : elookup-fun + (eordered/cons (Dbound : ebounded G Y) : eordered (econs G Y S)) + elookup/hit + (elookup/miss (Dlook : elookup G Y A)) + Deq + <- elookup-bounded-contra Dlook Dbound Dfalse + <- false-implies-etp-eq Dfalse Deq. + + +%worlds (ecsig | easig | evar | eovar) (elookup-fun _ _ _ _). +%total D (elookup-fun _ D _ _). + +weaken-elookup : elookup G Y A -> {X} {B} elookup (econs G X B) Y A -> type. +%mode weaken-elookup +X1 +X2 +X3 -X4. + +- : weaken-elookup Dlook _ _ (elookup/miss Dlook). + +%worlds (ecsig | easig | evar | eovar) (weaken-elookup _ _ _ _). +%total {} (weaken-elookup _ _ _ _). + + +eappend-nil : {G} eappend enil G G -> type. +%mode eappend-nil +X1 -X2. + +- : eappend-nil enil eappend/nil. + +- : eappend-nil (econs G X A) (eappend/cons D) + <- eappend-nil G D. + +%worlds (ecsig | easig | var) (eappend-nil _ _). +%total G (eappend-nil G _). + + + +eappend-lookup : eappend (econs G1 X T) G2 G + -> elookup G X T -> type. +%mode eappend-lookup +X1 -X2. + +- : eappend-lookup eappend/nil elookup/hit. + +- : eappend-lookup (eappend/cons (Dappend : eappend (econs G1 X T) G2 G)) + (elookup/miss Dlook) + <- eappend-lookup Dappend + (Dlook : elookup G X T). + +%worlds (ecsig | easig | evar | eovar) (eappend-lookup _ _). +%total D (eappend-lookup D _). + +strengthen-elookup : ({x:etm} elookup G Y (B x)) + -> elookup G Y B' -> ({x} etp-eq (B x) B') -> type. +%mode strengthen-elookup +X1 -X2 -X3. + +- : strengthen-elookup ([_] elookup/hit) elookup/hit ([_] etp-eq/i). + +- : strengthen-elookup ([x] elookup/miss (Dlook x)) + (elookup/miss Dlook') Deq + <- strengthen-elookup Dlook Dlook' Deq. + +%worlds (ecsig | easig | evar | ebind | eovar) (strengthen-elookup _ _ _). +%total D (strengthen-elookup D _ _). + +ebounded-isvar : ebounded G X -> eisvar X I -> type. +%mode ebounded-isvar +X1 -X2. + +- : ebounded-isvar (ebounded/nil (Disvar : eisvar X I) : ebounded enil X) + Disvar. + +- : ebounded-isvar (ebounded/cons _ (eprecedes/i _ Disvar _)) + Disvar. + +%worlds (ecsig | easig | evar | eovar) (ebounded-isvar _ _). +%total D (ebounded-isvar D _). + + +elookup-isvar : eordered G -> elookup G X _ -> eisvar X I -> type. +%mode elookup-isvar +X1 +X2 -X3. + +- : elookup-isvar + (eordered/cons (Dsbounded : ebounded G X) : eordered (econs G X T)) + (elookup/hit : elookup (econs G X T) X T) + Disvar + <- ebounded-isvar Dsbounded + (Disvar : eisvar X I). + +- : elookup-isvar + (eordered/cons ((ebounded/cons Dsbounded _))) + (elookup/miss (Dslookup)) + Disvar + <- elookup-isvar (eordered/cons Dsbounded) Dslookup + (Disvar : eisvar X I). + +%worlds (ecsig | easig | evar | eovar) (elookup-isvar _ _ _). +%total D (elookup-isvar _ D _). + + +eisvar-const-contra : eisvar (econst _) _ -> false -> type. +%mode eisvar-const-contra +X1 -X2. +%worlds (ecsig | easig | evar | eovar) (eisvar-const-contra _ _). +%total {} (eisvar-const-contra _ _). + +eisvar-lam-contra : eisvar (elam _ _) _ -> false -> type. +%mode eisvar-lam-contra +X1 -X2. +%worlds (ecsig | easig | evar | eovar) (eisvar-lam-contra _ _). +%total {} (eisvar-lam-contra _ _). + +eisvar-app-contra : eisvar (eapp _ _) _ -> false -> type. +%mode eisvar-app-contra +X1 -X2. +%worlds (ecsig | easig | evar | eovar) (eisvar-app-contra _ _). +%total {} (eisvar-app-contra _ _). + + +%% weakening %% + +weakeng-elookup : eappend G1 G2 G + -> eappend (econs G1 X B) G2 G' + -> elookup G Y A +%% + -> elookup G' Y A -> type. +%mode weakeng-elookup +X1 +X2 +X3 -X4. + +-hit : weakeng-elookup + (eappend/cons _) + (eappend/cons _) + elookup/hit +%% + elookup/hit. + +-miss : weakeng-elookup + (eappend/cons Dapp1) + (eappend/cons Dapp2) + (elookup/miss Dlook) +%% + (elookup/miss Dlook') +%%% + <- weakeng-elookup Dapp1 Dapp2 Dlook Dlook'. + +-nil : weakeng-elookup eappend/nil eappend/nil Dlook +%% + (elookup/miss Dlook). + +%worlds (ecsig | easig | evar | ebind) (weakeng-elookup _ _ _ _). +%total D (weakeng-elookup _ _ D _). + + +weakeng-eofe : eappend G1 G2 G + -> eappend (econs G1 X B) G2 G' + -> eofe G M A +%% + -> eofe G' M A -> type. +%mode weakeng-eofe +X1 +X2 +X3 -X4. + +weakeng-ekofe : eappend G1 G2 G + -> eappend (econs G1 X B) G2 G' + -> ekofe G A K +%% + -> ekofe G' A K -> type. +%mode weakeng-ekofe +X1 +X2 +X3 -X4. + +weakeng-ewfkinde : eappend G1 G2 G + -> eappend (econs G1 X B) G2 G' + -> ewfkinde G K +%% + -> ewfkinde G' K -> type. +%mode weakeng-ewfkinde +X1 +X2 +X3 -X4. + +weakeng-eqtme : eappend G1 G2 G + -> eappend (econs G1 X C) G2 G' + -> eqtme G M N A +%% + -> eqtme G' M N A -> type. +%mode weakeng-eqtme +X1 +X2 +X3 -X4. + +weakeng-eqtpe : eappend G1 G2 G + -> eappend (econs G1 X C) G2 G' + -> eqtpe G A B K +%% + -> eqtpe G' A B K -> type. +%mode weakeng-eqtpe +X1 +X2 +X3 -X4. + +weakeng-eqkinde : eappend G1 G2 G + -> eappend (econs G1 X C) G2 G' + -> eqkinde G K K' +%% + -> eqkinde G' K K' -> type. +%mode weakeng-eqkinde +X1 +X2 +X3 -X4. + + +-closed : weakeng-eofe Dappend Dappend' + (eofe/vari Dkofe Dvof) + (eofe/vari Dkofe' Dvof) + <- weakeng-ekofe Dappend Dappend' Dkofe Dkofe'. + +-const : weakeng-eofe Dappend Dappend' + (eofe/const + (DofA : ekofe G A ektype) + (DofC : ecof C A)) + (eofe/const DofA' DofC) + <- weakeng-ekofe Dappend Dappend' DofA DofA'. + +-var : weakeng-eofe Dappend Dappend' + (eofe/var + (DofA : ekofe G A ektype) + (Dlook : elookup G X A)) + (eofe/var DofA' Dlook') + <- weakeng-elookup Dappend Dappend' Dlook Dlook' + <- weakeng-ekofe Dappend Dappend' DofA DofA'. + +-app : weakeng-eofe Dappend Dappend' (eofe/app DofN DofM) + (eofe/app DofN' DofM') + <- weakeng-eofe Dappend Dappend' DofN DofN' + <- weakeng-eofe Dappend Dappend' DofM DofM'. + +-lam : weakeng-eofe Dappend Dappend' + (eofe/lam + (DofA : ekofe G A ektype) + ([x] DofM x : eofe (econs G x A) (M x) (B x))) + (eofe/lam DofA' ([x] DofM' x)) + <- weakeng-ekofe Dappend Dappend' DofA DofA' + <- ({x} + weakeng-eofe (eappend/cons Dappend) (eappend/cons Dappend') + (DofM x) + (DofM' x : eofe (econs G' x A) (M x) (B x))). + +-eqtp : weakeng-eofe Dappend Dappend' + (eofe/eqtp Deqtp Deofe) + (eofe/eqtp Deqtp' Deofe') + <- weakeng-eofe Dappend Dappend' Deofe Deofe' + <- weakeng-eqtpe Dappend Dappend' Deqtp Deqtp'. + +-ext : weakeng-eofe Dappend Dappend' + (eofe/ext ([x] DofApp x) DofM) + (eofe/ext ([x] DofApp' x) DofM') + <- weakeng-eofe Dappend Dappend' DofM DofM' + <- ({x} + weakeng-eofe (eappend/cons Dappend) (eappend/cons Dappend') + (DofApp x) (DofApp' x)). + +%% + +-const : weakeng-ekofe Dappend Dappend' (ekofe/const Dwf Dckof) + (ekofe/const Dwf' Dckof) + <- weakeng-ewfkinde Dappend Dappend' Dwf Dwf'. + +-app : weakeng-ekofe Dappend Dappend' (ekofe/app Dof Dkof) + (ekofe/app Dof' Dkof') + <- weakeng-ekofe Dappend Dappend' Dkof Dkof' + <- weakeng-eofe Dappend Dappend' Dof Dof'. + +-pi : weakeng-ekofe Dappend Dappend' (ekofe/pi DofA ([x] DofB x)) + (ekofe/pi DofA' ([x] DofB' x)) + <- weakeng-ekofe Dappend Dappend' DofA DofA' + <- ({x} + weakeng-ekofe (eappend/cons Dappend) (eappend/cons Dappend') + (DofB x) + (DofB' x)). + +-lam : weakeng-ekofe Dappend Dappend' (ekofe/lam DofA ([x] DofB x)) + (ekofe/lam DofA' ([x] DofB' x)) + <- weakeng-ekofe Dappend Dappend' DofA DofA' + <- ({x} + weakeng-ekofe (eappend/cons Dappend) (eappend/cons Dappend') + (DofB x) + (DofB' x)). + +-eqkind : weakeng-ekofe Dappend Dappend' (ekofe/eqkind Deq Dkof) + (ekofe/eqkind Deq' Dkof') + <- weakeng-ekofe Dappend Dappend' Dkof Dkof' + <- weakeng-eqkinde Dappend Dappend' Deq Deq'. + +-ext : weakeng-ekofe Dappend Dappend' (ekofe/ext ([x] D2 x) D1) + (ekofe/ext D2' D1') + <- weakeng-ekofe Dappend Dappend' D1 D1' + <- ({x} + weakeng-ekofe (eappend/cons Dappend) (eappend/cons Dappend') + (D2 x) (D2' x)). + +%% + +-tp : weakeng-ewfkinde _ _ ewfkinde/tp ewfkinde/tp. + +-pi : weakeng-ewfkinde Dapp Dapp' (ewfkinde/pi DofA DofK) + (ewfkinde/pi DofA' DofK') + <- ({x} weakeng-ewfkinde (eappend/cons Dapp) (eappend/cons Dapp') + (DofK x) (DofK' x)) + <- weakeng-ekofe Dapp Dapp' DofA DofA'. + +%% + +-app : weakeng-eqtme Dapp Dapp' (eqtme/app DeqN DeqM) + (eqtme/app DeqN' DeqM') + <- weakeng-eqtme Dapp Dapp' DeqN DeqN' + <- weakeng-eqtme Dapp Dapp' DeqM DeqM'. + +-lam : weakeng-eqtme Dapp Dapp' (eqtme/lam Deqtm Deqtp) + (eqtme/lam Deqtm' Deqtp') + <- ({x} + weakeng-eqtme (eappend/cons Dapp) (eappend/cons Dapp') + (Deqtm x) + (Deqtm' x)) + <- weakeng-eqtpe Dapp Dapp' Deqtp Deqtp'. + +-ext : weakeng-eqtme Dapp Dapp' (eqtme/ext ([x] Deq x) Dof1 Dof2) + (eqtme/ext ([x] Deq' x) Dof1' Dof2') + <- ({x} + weakeng-eqtme (eappend/cons Dapp) (eappend/cons Dapp') + (Deq x) + (Deq' x)) + <- weakeng-eofe Dapp Dapp' Dof1 Dof1' + <- weakeng-eofe Dapp Dapp' Dof2 Dof2'. + +-extw : weakeng-eqtme Dapp Dapp' (eqtme/extw ([x] Deq x) Deq2) + (eqtme/extw ([x] Deq' x) Deq2') + <- ({x} + weakeng-eqtme (eappend/cons Dapp) (eappend/cons Dapp') + (Deq x) + (Deq' x)) + <- weakeng-eqtme Dapp Dapp' Deq2 Deq2'. + +-beta : weakeng-eqtme Dapp Dapp' (eqtme/beta Dof2 ([x] Dof1 x)) + (eqtme/beta Dof2' Dof1') + <- ({x} + weakeng-eofe (eappend/cons Dapp) (eappend/cons Dapp') + (Dof1 x) (Dof1' x)) + <- weakeng-eofe Dapp Dapp' Dof2 Dof2'. + +-sym : weakeng-eqtme Dapp Dapp' (eqtme/sym Deq) (eqtme/sym Deq') + <- weakeng-eqtme Dapp Dapp' Deq Deq'. + +-refl : weakeng-eqtme Dapp Dapp' (eqtme/refl Dof) (eqtme/refl Dof') + <- weakeng-eofe Dapp Dapp' Dof Dof'. + +-trans : weakeng-eqtme Dapp Dapp' (eqtme/trans Deq2 Deq1) + (eqtme/trans Deq2' Deq1') + <- weakeng-eqtme Dapp Dapp' Deq1 Deq1' + <- weakeng-eqtme Dapp Dapp' Deq2 Deq2'. + +-tcon : weakeng-eqtme Dapp Dapp' (eqtme/tcon Deqtp Deqtm) + (eqtme/tcon Deqtp' Deqtm') + <- weakeng-eqtpe Dapp Dapp' Deqtp Deqtp' + <- weakeng-eqtme Dapp Dapp' Deqtm Deqtm'. + +%% + +-app : weakeng-eqtpe Dapp Dapp' (eqtpe/app DeqN DeqM) + (eqtpe/app DeqN' DeqM') + <- weakeng-eqtme Dapp Dapp' DeqN DeqN' + <- weakeng-eqtpe Dapp Dapp' DeqM DeqM'. + +-pi : weakeng-eqtpe Dapp Dapp' (eqtpe/pi DeqB DeqA) + (eqtpe/pi DeqB' DeqA') + <- weakeng-eqtpe Dapp Dapp' DeqA DeqA' + <- ({x} + weakeng-eqtpe (eappend/cons Dapp) (eappend/cons Dapp') + (DeqB x) (DeqB' x)). + +-lam : weakeng-eqtpe Dapp Dapp' (eqtpe/lam Deqtm Deqtp) + (eqtpe/lam Deqtm' Deqtp') + <- ({x} + weakeng-eqtpe (eappend/cons Dapp) (eappend/cons Dapp') + (Deqtm x) + (Deqtm' x)) + <- weakeng-eqtpe Dapp Dapp' Deqtp Deqtp'. + +-ext : weakeng-eqtpe Dapp Dapp' (eqtpe/ext ([x] Deq x) Dof1 Dof2) + (eqtpe/ext ([x] Deq' x) Dof1' Dof2') + <- ({x} + weakeng-eqtpe (eappend/cons Dapp) (eappend/cons Dapp') + (Deq x) + (Deq' x)) + <- weakeng-ekofe Dapp Dapp' Dof1 Dof1' + <- weakeng-ekofe Dapp Dapp' Dof2 Dof2'. + +-extw : weakeng-eqtpe Dapp Dapp' (eqtpe/extw ([x] Deq x) Deq2) + (eqtpe/extw ([x] Deq' x) Deq2') + <- ({x} + weakeng-eqtpe (eappend/cons Dapp) (eappend/cons Dapp') + (Deq x) + (Deq' x)) + <- weakeng-eqtpe Dapp Dapp' Deq2 Deq2'. + +-beta : weakeng-eqtpe Dapp Dapp' (eqtpe/beta Dof2 ([x] Dof1 x)) + (eqtpe/beta Dof2' Dof1') + <- ({x} + weakeng-ekofe (eappend/cons Dapp) (eappend/cons Dapp') + (Dof1 x) (Dof1' x)) + <- weakeng-eofe Dapp Dapp' Dof2 Dof2'. + +-sym : weakeng-eqtpe Dapp Dapp' (eqtpe/sym Deq) (eqtpe/sym Deq') + <- weakeng-eqtpe Dapp Dapp' Deq Deq'. + +-refl : weakeng-eqtpe Dapp Dapp' (eqtpe/refl Dof) (eqtpe/refl Dof') + <- weakeng-ekofe Dapp Dapp' Dof Dof'. + +-trans : weakeng-eqtpe Dapp Dapp' (eqtpe/trans Deq2 Deq1) + (eqtpe/trans Deq2' Deq1') + <- weakeng-eqtpe Dapp Dapp' Deq1 Deq1' + <- weakeng-eqtpe Dapp Dapp' Deq2 Deq2'. + +-kcon : weakeng-eqtpe Dapp Dapp' (eqtpe/kcon Deqkind Deqtp) + (eqtpe/kcon Deqkind' Deqtp') + <- weakeng-eqtpe Dapp Dapp' Deqtp Deqtp' + <- weakeng-eqkinde Dapp Dapp' Deqkind Deqkind'. + +%% + +-tp : weakeng-eqkinde _ _ eqkinde/tp eqkinde/tp. + +-pi : weakeng-eqkinde Dapp Dapp' (eqkinde/pi DeqB DeqA) + (eqkinde/pi DeqB' DeqA') + <- weakeng-eqtpe Dapp Dapp' DeqA DeqA' + <- ({x} + weakeng-eqkinde (eappend/cons Dapp) (eappend/cons Dapp') + (DeqB x) (DeqB' x)). + +-sym : weakeng-eqkinde Dapp Dapp' (eqkinde/sym Deq) (eqkinde/sym Deq') + <- weakeng-eqkinde Dapp Dapp' Deq Deq'. + +-refl : weakeng-eqkinde Dapp Dapp' (eqkinde/refl Dof) (eqkinde/refl Dof') + <- weakeng-ewfkinde Dapp Dapp' Dof Dof'. + +-trans : weakeng-eqkinde Dapp Dapp' (eqkinde/trans Deq2 Deq1) + (eqkinde/trans Deq2' Deq1') + <- weakeng-eqkinde Dapp Dapp' Deq1 Deq1' + <- weakeng-eqkinde Dapp Dapp' Deq2 Deq2'. + +%worlds (ecsig | easig | evar | ebind) + (weakeng-eofe _ _ _ _) + (weakeng-ekofe _ _ _ _) + (weakeng-ewfkinde _ _ _ _) + (weakeng-eqtme _ _ _ _) + (weakeng-eqtpe _ _ _ _) + (weakeng-eqkinde _ _ _ _). +%total (D1 D2 D3 D4 D5 D6) + (weakeng-eofe _ _ D1 _) + (weakeng-ekofe _ _ D2 _) + (weakeng-ewfkinde _ _ D3 _) + (weakeng-eqtme _ _ D4 _) + (weakeng-eqtpe _ _ D5 _) + (weakeng-eqkinde _ _ D6 _). + + +weaken-eofe : eofe G M A + -> {X} {B} eofe (econs G X B) M A -> type. +%mode weaken-eofe +X2 +X +B -X3. + +- : weaken-eofe (Dof : eofe G M A) X B + Dof' + <- weakeng-eofe eappend/nil eappend/nil Dof Dof'. + +%worlds (ecsig | easig | evar | ebind | eovar) (weaken-eofe _ _ _ _). +%total {} (weaken-eofe _ _ _ _). + +weaken-eofe' : eappend G1 G2 G -> eofe G1 EM EA + -> eofe G EM EA -> type. +%mode weaken-eofe' +X2 +X3 -X4. + +-nil : weaken-eofe' eappend/nil D D. + +-cons : weaken-eofe' (eappend/cons (Dapp : eappend G1 G2' G')) Dof + Dof'' + <- weaken-eofe' Dapp Dof Dof' + <- weaken-eofe Dof' X B Dof''. + +%worlds (ecsig | easig | evar | eovar) (weaken-eofe' _ _ _). +%total D (weaken-eofe' D _ _). + +weaken-eqtpe : eqtpe G M N A + -> {X} {B} eqtpe (econs G X B) M N A -> type. +%mode weaken-eqtpe +X2 +X +B -X3. + +- : weaken-eqtpe Deq X B Deq' + <- weakeng-eqtpe eappend/nil eappend/nil Deq Deq'. + +%worlds (ecsig | easig | evar | ebind | eovar) (weaken-eqtpe _ _ _ _). +%total {} (weaken-eqtpe _ _ _ _). + +weaken-eqtpe' : eappend G1 G2 G -> eqtpe G1 EM EN EA + -> eqtpe G EM EN EA -> type. +%mode weaken-eqtpe' +X2 +X3 -X4. + +-nil : weaken-eqtpe' eappend/nil D D. + +-cons : weaken-eqtpe' (eappend/cons Dapp) Deq + Deq'' + <- weaken-eqtpe' Dapp Deq Deq' + <- weaken-eqtpe Deq' _ _ Deq''. + +%worlds (ecsig | easig | evar | ebind | eovar) (weaken-eqtpe' _ _ _). +%total D (weaken-eqtpe' D _ _). + +weaken-eqtme : eqtme G M N A + -> {X} {B} eqtme (econs G X B) M N A -> type. +%mode weaken-eqtme +X2 +X +B -X3. + +- : weaken-eqtme Deq X B Deq' + <- weakeng-eqtme eappend/nil eappend/nil Deq Deq'. + +%worlds (ecsig | easig | evar | ebind | eovar) (weaken-eqtme _ _ _ _). +%total {} (weaken-eqtme _ _ _ _). + +weaken-eqtme' : eappend G1 G2 G -> eqtme G1 EM EN EA + -> eqtme G EM EN EA -> type. +%mode weaken-eqtme' +X2 +X3 -X4. + +-nil : weaken-eqtme' eappend/nil D D. + +-cons : weaken-eqtme' (eappend/cons Dapp) Deq + Deq'' + <- weaken-eqtme' Dapp Deq Deq' + <- weaken-eqtme Deq' _ _ Deq''. + +%worlds (ecsig | easig | evar | ebind | eovar) (weaken-eqtme' _ _ _). +%total D (weaken-eqtme' D _ _). + + +evof-isvar-contra : evof EX EA -> vtrans EX X -> isvar X _ -> false -> type. +%mode evof-isvar-contra +X1 +X2 +X3 -X4. +%worlds (ecsig | easig | bind | ovar | tbind) + (evof-isvar-contra _ _ _ _). +%total {} (evof-isvar-contra _ _ _ _). + +evof-fun : evof EX EA -> evof EX EA' -> etp-eq EA EA' -> type. +%mode evof-fun +X1 +X2 -X3. + +- : evof-fun D D' etp-eq/i. + +%worlds (ecsig | easig | bind | ovar | tbind) + (evof-fun _ _ _). +%total {} (evof-fun _ _ _). + + +%% common metric for implicit and explicit typing derivations + +meof : eof M A -> metric -> type. +mekof : ekof A K -> metric -> type. +mewfkind : ewfkind K -> metric -> type. +meqtm : eqtm M N A -> metric -> type. +meqtp : eqtp A B K -> metric -> type. +meqkind : eqkind K J -> metric -> type. + +meof/var : meof (eof/var Dkof _) (msing Mm) + <- mekof Dkof Mm. + +meof/const : meof (eof/const Dkof _) (msing Dkof') + <- mekof Dkof Dkof'. + +meof/app : meof (eof/app Dof2 Dof1) (mpair M2 M1) + <- meof Dof1 M1 + <- meof Dof2 M2. + +meof/lam : meof (eof/lam Dkof ([x] [d] Dof x d)) (mpair M1 M2) + <- ({x} {d} meof (Dof x d) M1) + <- mekof Dkof M2. + +meof/eqtp : meof (eof/eqtp Deqtp Dof) (mpair M2 M1) + <- meof Dof M1 + <- meqtp Deqtp M2. + +meof/ext : meof (eof/ext ([x] [d] Dof2 x d) Dof1) (mpair M1 M2) + <- meof Dof1 M1 + <- ({x} {d} meof (Dof2 x d) M2). + +mekof/const : mekof (ekof/const Dwf _) (msing M) + <- mewfkind Dwf M. + +mekof/app : mekof (ekof/app Dof Dkof) (mpair Dof' Dkof') + <- mekof Dkof Dkof' + <- meof Dof Dof'. + +mekof/pi : mekof (ekof/pi ([x] [d] DkofB x d) DkofA) (mpair DkofB' DkofA') + <- mekof DkofA DkofA' + <- ({x} {d} mekof (DkofB x d) DkofB'). + +mekof/lam : mekof (ekof/lam D1 ([x] [d] D2 x d)) (mpair D1' D2') + <- ({x} {d} mekof (D2 x d) D2') + <- mekof D1 D1'. + +mekof/eqk : mekof (ekof/eqkind Deqk Dkof) (mpair Meqk Mkof) + <- mekof Dkof Mkof + <- meqkind Deqk Meqk. + +mekof/ext : mekof (ekof/ext ([x] [d] D2 x d) D1) (mpair D1' D2') + <- mekof D1 D1' + <- ({x} {d} mekof (D2 x d) D2'). + +mewfkind/tp : mewfkind ewfkind/tp munit. + +mewfkind/pi : mewfkind (ewfkind/pi ([x] [d] Dwf x d) Dkof) (mpair Dwf' Dkof') + <- mekof Dkof Dkof' + <- ({x} {d} mewfkind (Dwf x d) Dwf'). + +%% + +meqtm/app : meqtm (eqtm/app Deqtm2 Deqtm1) (mpair Mtm2 Mtm1) + <- meqtm Deqtm1 Mtm1 + <- meqtm Deqtm2 Mtm2. + +meqtm/lam : meqtm (eqtm/lam ([x] [d] DeqB x d) DeqA) (mpair Bm Am) + <- meqtp DeqA Am + <- ({x} {d} meqtm (DeqB x d) Bm). + + +meqtm/ext : meqtm (eqtm/ext ([x] [d] Deqtm x d) Dof2 Dof1) + (mpair (mpair M1 M2) M3) + <- meof Dof1 M1 + <- meof Dof2 M2 + <- ({x} {d} meqtm (Deqtm x d) M3). + +meqtm/extw : meqtm (eqtm/extw ([x] [d] Deqtm x d) Deqtm') (mpair M1 M2) + <- meqtm Deqtm' M1 + <- ({x} {d} meqtm (Deqtm x d) M2). + +meqtm/beta : meqtm (eqtm/beta DofN ([x] [d] DofB x d)) (mpair Nm Bm) + <- ({x} {d} meof (DofB x d) Bm) + <- meof DofN Nm. + +meqtm/sym : meqtm (eqtm/sym Deq) (msing M) + <- meqtm Deq M. + +meqtm/trans : meqtm (eqtm/trans Deq1 Deq2) (mpair M2 M1) + <- meqtm Deq2 M2 + <- meqtm Deq1 M1. + +meqtm/refl : meqtm (eqtm/refl Dkof) (msing M) + <- meof Dkof M. + +meqtm/tcon : meqtm (eqtm/typecon Deqtp Deqtm) (mpair M2 M1) + <- meqtm Deqtm M2 + <- meqtp Deqtp M1. + +%% + +meqtp/app : meqtp (eqtp/app Deqtm Deqtp) (mpair Mtm Mtp) + <- meqtp Deqtp Mtp + <- meqtm Deqtm Mtm. + +meqtp/pi : meqtp (eqtp/pi ([x] [d] DeqtpB x d) DeqtpA) (mpair Bm Am) + <- meqtp DeqtpA Am + <- ({x} {d} meqtp (DeqtpB x d) Bm). + +meqtp/lam : meqtp (eqtp/lam ([x] [d] DeqB x d) DeqA) (mpair Bm Am) + <- meqtp DeqA Am + <- ({x} {d} meqtp (DeqB x d) Bm). + +meqtp/ext : meqtp (eqtp/ext ([x] [d] Deqtp x d) Dkof2 Dkof1) + (mpair (mpair M1 M2) M3) + <- mekof Dkof1 M1 + <- mekof Dkof2 M2 + <- ({x} {d} meqtp (Deqtp x d) M3). + +meqtp/extw : meqtp (eqtp/extw ([x] [d] Deqtp x d) Deqtp') (mpair M1 M2) + <- meqtp Deqtp' M1 + <- ({x} {d} meqtp (Deqtp x d) M2). + +meqtp/beta : meqtp (eqtp/beta DofN ([x] [d] DofB x d)) (mpair Nm Bm) + <- ({x} {d} mekof (DofB x d) Bm) + <- meof DofN Nm. + +meqtp/sym : meqtp (eqtp/sym Deq) (msing M) + <- meqtp Deq M. + +meqtp/trans : meqtp (eqtp/trans Deq1 Deq2) (mpair M2 M1) + <- meqtp Deq2 M2 + <- meqtp Deq1 M1. + +meqtp/refl : meqtp (eqtp/refl Dkof) (msing M) + <- mekof Dkof M. + +meqtp/kcon : meqtp (eqtp/kcon Deqkind Deqtp) (mpair M1 M2) + <- meqtp Deqtp M1 + <- meqkind Deqkind M2. + +%% + +meqkind/tp : meqkind eqkind/tp munit. + +meqkind/pi : meqkind (eqkind/pi ([x] [d] Deqkind x d) Deqtp) + (mpair Km Am) + <- meqtp Deqtp Am + <- ({x} {d} meqkind (Deqkind x d) Km). + +meqkind/sym : meqkind (eqkind/sym Deqkind) (msing Km) + <- meqkind Deqkind Km. + +meqkind/trn : meqkind (eqkind/trans Deq1 Deq2) (mpair M1 M2) + <- meqkind Deq2 M2 + <- meqkind Deq1 M1. + +meqkind/ref : meqkind (eqkind/refl Dwf) (msing Km) + <- mewfkind Dwf Km. + +%% + + +can-meof : {D:eof M A} meof D Mm -> type. +%mode can-meof +X1 -X2. + +can-mekof : {D:ekof A K} mekof D Am -> type. +%mode can-mekof +X1 -X2. + +can-mewfkind : {D:ewfkind K} mewfkind D Km -> type. +%mode can-mewfkind +X1 -X2. + +can-meqtp : {D:eqtp A B K} meqtp D Am -> type. +%mode can-meqtp +X1 -X2. + +can-meqtm : {D:eqtm M N A} meqtm D Mm -> type. +%mode can-meqtm +X1 -X2. + +can-meqkind : {D:eqkind K K'} meqkind D Km -> type. +%mode can-meqkind +X1 -X2. + +- : can-meof (eof/var Dkof _) (meof/var Dkof') + <- can-mekof Dkof Dkof'. + +- : can-meof (eof/const Dkof _) (meof/const Dkof') + <- can-mekof Dkof Dkof'. + +- : can-meof (eof/app Dof2 Dof1) (meof/app Dof2' Dof1') + <- can-meof Dof1 Dof1' + <- can-meof Dof2 Dof2'. + +- : can-meof (eof/lam Dkof ([x] [d] Dof x d)) (meof/lam Dkof' Dof') + <- can-mekof Dkof Dkof' + <- ({x} {d} can-meof (Dof x d) (Dof' x d)). + +- : can-meof (eof/eqtp Deqtp Dof) (meof/eqtp Deqtp' Dof') + <- can-meof Dof Dof' + <- can-meqtp Deqtp Deqtp'. + +- : can-meof (eof/ext ([x] [d] Dof2 x d) Dof1) + (meof/ext ([x] [d] Dof2' x d) Dof1') + <- can-meof Dof1 Dof1' + <- ({x} {d} can-meof (Dof2 x d) (Dof2' x d)). + +%% + +- : can-mekof (ekof/const Dwf _) (mekof/const Dwf') + <- can-mewfkind Dwf Dwf'. + +- : can-mekof (ekof/app Dof Dkof) (mekof/app Dof' Dkof') + <- can-meof Dof Dof' + <- can-mekof Dkof Dkof'. + +- : can-mekof (ekof/pi ([x] [d] DofB x d) DofA) (mekof/pi DofB' DofA') + <- can-mekof DofA DofA' + <- ({x} {d} can-mekof (DofB x d) (DofB' x d)). + +- : can-mekof (ekof/lam D1 ([x] [d] D2 x d)) (mekof/lam D1' D2') + <- can-mekof D1 D1' + <- ({x} {d} can-mekof (D2 x d) (D2' x d)). + +- : can-mekof (ekof/eqkind Deqk Dkof) (mekof/eqk Deqk' Dkof') + <- can-mekof Dkof Dkof' + <- can-meqkind Deqk Deqk'. + +- : can-mekof (ekof/ext ([x] [d] Dkof2 x d) Dkof) + (mekof/ext ([x] [d] Dkof2' x d) Dkof') + <- can-mekof Dkof Dkof' + <- ({x} {d} can-mekof (Dkof2 x d) (Dkof2' x d)). + +%% + +- : can-mewfkind ewfkind/tp mewfkind/tp. + +- : can-mewfkind (ewfkind/pi ([x] [d] Dwf x d) Dkof) + (mewfkind/pi Dwf' Dkof') + <- can-mekof Dkof Dkof' + <- ({x} {d} can-mewfkind (Dwf x d) (Dwf' x d)). + +%% + +- : can-meqtp (eqtp/app Deqtm Deqtp) (meqtp/app Deqtm' Deqtp') + <- can-meqtm Deqtm Deqtm' + <- can-meqtp Deqtp Deqtp'. + +- : can-meqtp (eqtp/pi ([x] [d] Deqtp2 x d) Deqtp1) + (meqtp/pi ([x] [d] Deqtp2' x d) Deqtp1') + <- can-meqtp Deqtp1 Deqtp1' + <- ({x} {d} can-meqtp (Deqtp2 x d) (Deqtp2' x d)). + +- : can-meqtp (eqtp/lam ([x] [d] Deqtp2 x d) Deqtp1) + (meqtp/lam ([x] [d] Deqtp2' x d) Deqtp1') + <- can-meqtp Deqtp1 Deqtp1' + <- ({x} {d} can-meqtp (Deqtp2 x d) (Deqtp2' x d)). + +- : can-meqtp (eqtp/ext ([x] [d] Deqtp x d) Dkof2 Dkof1) + (meqtp/ext ([x] [d] Deqtp' x d) Dkof2' Dkof1') + <- can-mekof Dkof1 Dkof1' + <- can-mekof Dkof2 Dkof2' + <- ({x} {d} can-meqtp (Deqtp x d) (Deqtp' x d)). + +- : can-meqtp (eqtp/extw ([x] [d] Deqtp2 x d) Deqtp1) + (meqtp/extw ([x] [d] Deqtp2' x d) Deqtp1') + <- can-meqtp Deqtp1 Deqtp1' + <- ({x} {d} can-meqtp (Deqtp2 x d) (Deqtp2' x d)). + +- : can-meqtp (eqtp/beta Dof ([x] [d] Dkof x d)) + (meqtp/beta Dof' ([x] [d] Dkof' x d)) + <- can-meof Dof Dof' + <- ({x} {d} can-mekof (Dkof x d) (Dkof' x d)). + +- : can-meqtp (eqtp/sym Deqtp) (meqtp/sym Deqtp') + <- can-meqtp Deqtp Deqtp'. + +- : can-meqtp (eqtp/trans D1 D2) (meqtp/trans D1' D2') + <- can-meqtp D1 D1' + <- can-meqtp D2 D2'. + +- : can-meqtp (eqtp/refl Dkof) (meqtp/refl Dkof') + <- can-mekof Dkof Dkof'. + +- : can-meqtp (eqtp/kcon Deqkind Deqtp) (meqtp/kcon Deqkind' Deqtp') + <- can-meqkind Deqkind Deqkind' + <- can-meqtp Deqtp Deqtp'. + +%% + +- : can-meqtm (eqtm/app Deqtm2 Deqtm1) (meqtm/app Deqtm2' Deqtm1') + <- can-meqtm Deqtm1 Deqtm1' + <- can-meqtm Deqtm2 Deqtm2'. + +- : can-meqtm (eqtm/lam ([x] [d] Deqtm x d) Deqtp) + (meqtm/lam ([x] [d] Deqtm' x d) Deqtp') + <- can-meqtp Deqtp Deqtp' + <- ({x} {d} can-meqtm (Deqtm x d) (Deqtm' x d)). + +- : can-meqtm (eqtm/ext ([x] [d] Deqtm x d) Dof2 Dof1) + (meqtm/ext ([x] [d] Deqtm' x d) Dof2' Dof1') + <- can-meof Dof1 Dof1' + <- can-meof Dof2 Dof2' + <- ({x} {d} can-meqtm (Deqtm x d) (Deqtm' x d)). + +- : can-meqtm (eqtm/extw ([x] [d] Deqtm x d) Deqtm2) + (meqtm/extw ([x] [d] Deqtm' x d) Deqtm2') + <- can-meqtm Deqtm2 Deqtm2' + <- ({x} {d} can-meqtm (Deqtm x d) (Deqtm' x d)). + +- : can-meqtm (eqtm/beta Dof1 ([x] [d] Dof2 x d)) + (meqtm/beta Dof1' ([x] [d] Dof2' x d)) + <- can-meof Dof1 Dof1' + <- ({x} {d} can-meof (Dof2 x d) (Dof2' x d)). + +- : can-meqtm (eqtm/sym Deq) (meqtm/sym Deq') + <- can-meqtm Deq Deq'. + +- : can-meqtm (eqtm/trans D1 D2) (meqtm/trans D1' D2') + <- can-meqtm D1 D1' + <- can-meqtm D2 D2'. + +- : can-meqtm (eqtm/refl Dof) (meqtm/refl Dof') + <- can-meof Dof Dof'. + +- : can-meqtm (eqtm/typecon Deqtp Deqtm) (meqtm/tcon Deqtp' Deqtm') + <- can-meqtp Deqtp Deqtp' + <- can-meqtm Deqtm Deqtm'. + +%% + +- : can-meqkind eqkind/tp meqkind/tp. + +- : can-meqkind (eqkind/pi ([x] [d] Deqk x d) Deqt) + (meqkind/pi ([x] [d] Deqk' x d) Deqt') + <- ({x} {d} can-meqkind (Deqk x d) (Deqk' x d)) + <- can-meqtp Deqt Deqt'. + +- : can-meqkind (eqkind/sym Deq) (meqkind/sym Deq') + <- can-meqkind Deq Deq'. + +- : can-meqkind (eqkind/trans D1 D2) (meqkind/trn D1' D2') + <- can-meqkind D1 D1' + <- can-meqkind D2 D2'. + +- : can-meqkind (eqkind/refl Dwf) (meqkind/ref Dwf') + <- can-mewfkind Dwf Dwf'. + + +%worlds (ecsig | easig | evar | eovar | ebind) + (can-meof _ _) (can-mekof _ _) (can-mewfkind _ _) + (can-meqtp _ _) (can-meqtm _ _) (can-meqkind _ _). +%total (D1 D2 D3 D4 D5 D6) + (can-meof D1 _) (can-mekof D2 _) (can-mewfkind D3 _) + (can-meqtp D4 _) (can-meqtm D5 _) (can-meqkind D6 _). + +meofe : eofe G M A -> metric -> type. +mekofe : ekofe G A K -> metric -> type. +mewfkinde : ewfkinde G K -> metric -> type. +meqtpe : eqtpe G A B K -> metric -> type. +meqtme : eqtme G M N A -> metric -> type. +meqkinde : eqkinde G K K' -> metric -> type. + +meofe/vari : meofe (eofe/vari Dkofe Dvof) (msing Dkofe') + <- mekofe Dkofe Dkofe'. + +meofe/const : meofe (eofe/const Dkofe _) (msing Dkofe') + <- mekofe Dkofe Dkofe'. + +meofe/var : meofe (eofe/var Dkofe _) (msing Dkofe') + <- mekofe Dkofe Dkofe'. + +meofe/app : meofe (eofe/app D2 D1) (mpair D2' D1') + <- meofe D1 D1' + <- meofe D2 D2'. + +meofe/lam : meofe (eofe/lam Dkofe ([x] Deofe x)) (mpair De' Dk') + <- ({x} meofe (Deofe x) De') + <- mekofe Dkofe Dk'. + +meofe/eqtp : meofe (eofe/eqtp Deqtpe Dofe) (mpair Deqtpe' Dofe') + <- meofe Dofe Dofe' + <- meqtpe Deqtpe Deqtpe'. + +meofe/ext : meofe (eofe/ext ([x] Dof2 x) Dof1) (mpair M1 M2) + <- meofe Dof1 M1 + <- ({x} meofe (Dof2 x) M2). + +mekofe/const : mekofe (ekofe/const Dwfe _) (msing Dwfe') + <- mewfkinde Dwfe Dwfe'. + +mekofe/app : mekofe (ekofe/app Dofe Dkofe) (mpair Dofe' Dkofe') + <- mekofe Dkofe Dkofe' + <- meofe Dofe Dofe'. + +mekofe/pi : mekofe (ekofe/pi D1 ([x] D2 x)) (mpair D2' D1') + <- ({x} mekofe (D2 x) D2') + <- mekofe D1 D1'. + +mekofe/lam : mekofe (ekofe/lam D1 ([x] D2 x)) (mpair D1' D2') + <- ({x} mekofe (D2 x) D2') + <- mekofe D1 D1'. + +mekofe/eqk : mekofe (ekofe/eqkind Deqk Dkofe) (mpair Deqk' Dkofe') + <- mekofe Dkofe Dkofe' + <- meqkinde Deqk Deqk'. + +mekofe/ext : mekofe (ekofe/ext ([x] Dof2 x) Dof1) (mpair M1 M2) + <- mekofe Dof1 M1 + <- ({x} mekofe (Dof2 x) M2). + +mewfkinde/tp : mewfkinde ewfkinde/tp munit. + +mewfkinde/pi : mewfkinde (ewfkinde/pi Dkof ([x] Dwf x)) (mpair Dwf' Dkof') + <- ({x} mewfkinde (Dwf x) Dwf') + <- mekofe Dkof Dkof'. + +%% + +meqtme/app : meqtme (eqtme/app D2 D1) (mpair M2 M1) + <- meqtme D1 M1 + <- meqtme D2 M2. + +meqtme/lam : meqtme (eqtme/lam ([x] Deqtm x) Deqtp) (mpair M1 M2) + <- meqtpe Deqtp M2 + <- ({x} meqtme (Deqtm x) M1). + +meqtme/ext : meqtme (eqtme/ext ([x] Deqtme x) Dof2 Dof1) + (mpair (mpair M1 M2) M3) + <- meofe Dof1 M1 + <- meofe Dof2 M2 + <- ({x} meqtme (Deqtme x) M3). + +meqtme/extw : meqtme (eqtme/extw ([x] Deqtme x) Deqtme2) + (mpair M1 M2) + <- meqtme Deqtme2 M1 + <- ({x} meqtme (Deqtme x) M2). + +meqtme/beta : meqtme (eqtme/beta DofeN ([x] DofB x)) (mpair Nm Bm) + <- ({x} meofe (DofB x) Bm) + <- meofe DofeN Nm. + +meqtme/sym : meqtme (eqtme/sym Deq) (msing M) + <- meqtme Deq M. + +meqtme/trans : meqtme (eqtme/trans Deq1 Deq2) (mpair M2 M1) + <- meqtme Deq2 M2 + <- meqtme Deq1 M1. + +meqtme/refl : meqtme (eqtme/refl Dkofe) (msing M) + <- meofe Dkofe M. + +meqtme/tcon : meqtme (eqtme/tcon Deqtpe Deqtme) (mpair M2 M1) + <- meqtme Deqtme M2 + <- meqtpe Deqtpe M1. + +%% + +meqtpe/app : meqtpe (eqtpe/app Deqtme Deqtpe) (mpair Mtm Mtp) + <- meqtpe Deqtpe Mtp + <- meqtme Deqtme Mtm. + +meqtpe/pi : meqtpe (eqtpe/pi ([x] DeqtpeB x) DeqtpeA) (mpair Bm Am) + <- meqtpe DeqtpeA Am + <- ({x} meqtpe (DeqtpeB x) Bm). + +meqtpe/lam : meqtpe (eqtpe/lam ([x] DeqB x) DeqA) (mpair Bm Am) + <- meqtpe DeqA Am + <- ({x} meqtpe (DeqB x) Bm). + +meqtpe/ext : meqtpe (eqtpe/ext ([x] Deqtpe x) Dkof2 Dkof1) + (mpair (mpair M1 M2) M3) + <- mekofe Dkof1 M1 + <- mekofe Dkof2 M2 + <- ({x} meqtpe (Deqtpe x) M3). + +meqtpe/extw : meqtpe (eqtpe/extw ([x] Deqtpe x) Deqtpe') + (mpair M1 M2) + <- meqtpe Deqtpe' M1 + <- ({x} meqtpe (Deqtpe x) M2). + +meqtpe/beta : meqtpe (eqtpe/beta DofN ([x] DofB x)) (mpair Nm Bm) + <- ({x} mekofe (DofB x) Bm) + <- meofe DofN Nm. + +meqtpe/sym : meqtpe (eqtpe/sym Deq) (msing M) + <- meqtpe Deq M. + +meqtpe/trans : meqtpe (eqtpe/trans Deq1 Deq2) (mpair M2 M1) + <- meqtpe Deq2 M2 + <- meqtpe Deq1 M1. + +meqtpe/refl : meqtpe (eqtpe/refl Dkof) (msing M) + <- mekofe Dkof M. + +meqtpe/kcon : meqtpe (eqtpe/kcon Deqkinde Deqtpe) (mpair M1 M2) + <- meqtpe Deqtpe M1 + <- meqkinde Deqkinde M2. + +%% + +meqkinde/tp : meqkinde eqkinde/tp munit. + +meqkinde/pi : meqkinde (eqkinde/pi ([x] Deqkinde x) Deqtpe) + (mpair Km Am) + <- meqtpe Deqtpe Am + <- ({x} meqkinde (Deqkinde x) Km). + +meqkinde/sym : meqkinde (eqkinde/sym Deqkinde) (msing Km) + <- meqkinde Deqkinde Km. + +meqkinde/trn : meqkinde (eqkinde/trans Deq1 Deq2) (mpair M1 M2) + <- meqkinde Deq2 M2 + <- meqkinde Deq1 M1. + +meqkinde/ref : meqkinde (eqkinde/refl Dwf) (msing Km) + <- mewfkinde Dwf Km. + + +%% respects lemmas %% + +meof-resp : etm-eq M M' -> etp-eq A A' -> {D:eof M A} meof D Mm + -> {D':eof M' A'} meof D' Mm -> type. +%mode meof-resp +X0 +X1 +X2 +X3 -X4 -X5. + +- : meof-resp etm-eq/i etp-eq/i D Dm D Dm. + +%worlds (ecsig | easig | evar | ebind) (meof-resp _ _ _ _ _ _). +%total {} (meof-resp _ _ _ _ _ _). + +mekof-resp : etp-eq A A' -> ekind-eq K K' -> {D:ekof A K} mekof D Am + -> {D':ekof A' K'} mekof D' Am -> type. +%mode mekof-resp +X1 +X2 +X3 +X4 -X5 -X6. + +- : mekof-resp etp-eq/i ekind-eq/i D Dm D Dm. + +%worlds (ecsig | easig | evar | ebind) (mekof-resp _ _ _ _ _ _). +%total {} (mekof-resp _ _ _ _ _ _). + +mewfkind-resp : ekind-eq K K' -> {D:ewfkind K} mewfkind D Km + -> {D':ewfkind K'} mewfkind D' Km -> type. +%mode mewfkind-resp +X1 +X2 +X3 -X4 -X5. + +- : mewfkind-resp ekind-eq/i D Dm D Dm. + +%worlds (ecsig | easig | evar | ebind) (mewfkind-resp _ _ _ _ _). +%total {} (mewfkind-resp _ _ _ _ _). + +meqtp-resp : etp-eq A A' -> etp-eq B B' -> ekind-eq K K' + -> {D:eqtp A B K} meqtp D Km + -> {D':eqtp A' B' K'} meqtp D' Km -> type. +%mode meqtp-resp +X0 +X1 +X2 +X3 +X4 -X5 -X6. + +- : meqtp-resp etp-eq/i etp-eq/i ekind-eq/i D Dm D Dm. + +%worlds (ecsig | easig | evar | ebind) (meqtp-resp _ _ _ _ _ _ _). +%total {} (meqtp-resp _ _ _ _ _ _ _). + +meqkind-resp : ekind-eq K K' -> ekind-eq L L' -> {D:eqkind K L} meqkind D Km + -> {D':eqkind K' L'} meqkind D' Km -> type. +%mode meqkind-resp +X1 +X2 +X3 +X4 -X5 -X6. + +- : meqkind-resp ekind-eq/i ekind-eq/i D Dm D Dm. + +%worlds (ecsig | easig | evar | ebind) (meqkind-resp _ _ _ _ _ _). +%total {} (meqkind-resp _ _ _ _ _ _). + + +meof-resp-underbind : {D : {y} {e:evof y A} eof (B y) (K y)} + ({y} {e} meof (D y e) Bm) + -> etp-eq A A' + -> ({y} etm-eq (B y) (B' y)) + -> ({y} etp-eq (K y) (K' y)) +%% + -> {D' : {y} {e':evof y A'} eof (B' y) (K' y)} + ({y} {e'} meof (D' y e') Bm) -> type. +%mode meof-resp-underbind +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +- : meof-resp-underbind D Dm etp-eq/i ([y] etm-eq/i) ([y] etp-eq/i) + D Dm. + +%worlds (ecsig | easig | evar | ebind) (meof-resp-underbind _ _ _ _ _ _ _). +%total {} (meof-resp-underbind _ _ _ _ _ _ _). + + +mekof-resp-underbind : {D : {y} {e:evof y A} ekof (B y) (K y)} + ({y} {e} mekof (D y e) Bm) + -> etp-eq A A' + -> ({y} etp-eq (B y) (B' y)) + -> ({y} ekind-eq (K y) (K' y)) +%% + -> {D' : {y} {e':evof y A'} ekof (B' y) (K' y)} + ({y} {e'} mekof (D' y e') Bm) -> type. +%mode mekof-resp-underbind +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +- : mekof-resp-underbind D Dm etp-eq/i ([y] etp-eq/i) ([y] ekind-eq/i) + D Dm. + +%worlds (ecsig | easig | evar | ebind) (mekof-resp-underbind _ _ _ _ _ _ _). +%total {} (mekof-resp-underbind _ _ _ _ _ _ _). + +meqtp-resp-underbind : {D : {y} {e:evof y A} eqtp (B y) (C y) (K y)} + ({y} {e} meqtp (D y e) Bm) + -> etp-eq A A' + -> ({y} etp-eq (B y) (B' y)) + -> ({y} etp-eq (C y) (C' y)) + -> ({y} ekind-eq (K y) (K' y)) +%% + -> {D' : {y} {e':evof y A'} eqtp (B' y) (C' y) (K' y)} + ({y} {e'} meqtp (D' y e') Bm) -> type. +%mode meqtp-resp-underbind +X0 +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +- : meqtp-resp-underbind D Dm etp-eq/i + ([y] etp-eq/i) ([y] etp-eq/i) ([y] ekind-eq/i) D Dm. + +%worlds (ecsig | easig | evar | ebind) (meqtp-resp-underbind _ _ _ _ _ _ _ _). +%total {} (meqtp-resp-underbind _ _ _ _ _ _ _ _). + + +%%% cut %%% + +cut-eof-m : {Mm} + {D : {x} {d:evof x A} eof (M x) (B x)} + ({x} {d} meof (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} eofe (G x) (M x) (B x)} + ({x} meofe (D' x) Mm) -> type. +%mode cut-eof-m +Mm +X1 +X2 +X3 -X4 -X5. + +cut-ekof-m : {Mm} + {D : {x} {d:evof x A} ekof (B x) (K x)} + ({x} {d} mekof (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} ekofe (G x) (B x) (K x)} + ({x} mekofe (D' x) Mm) -> type. +%mode cut-ekof-m +Mm +X1 +X2 +X3 -X4 -X5. + +cut-ewfkind-m : {Mm} + {D : {x} {d:evof x A} ewfkind (K x)} + ({x} {d} mewfkind (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} ewfkinde (G x) (K x)} + ({x} mewfkinde (D' x) Mm) -> type. +%mode cut-ewfkind-m +Mm +X1 +X2 +X3 -X4 -X5. + +cut-eqtp-m : {Mm} + {D : {x} {d:evof x A} eqtp (B x) (C x) (K x)} + ({x} {d} meqtp (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} eqtpe (G x) (B x) (C x) (K x)} + ({x} meqtpe (D' x) Mm) -> type. +%mode cut-eqtp-m +Mm +X1 +X2 +X3 -X4 -X5. + +cut-eqtm-m : {Mm} + {D:{x} {d:evof x A} eqtm (M x) (N x) (B x)} + ({x} {d} meqtm (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} eqtme (G x) (M x) (N x) (B x)} + ({x} meqtme (D' x) Mm) -> type. +%mode cut-eqtm-m +Mm +X1 +X2 +X3 -X4 -X5. + +cut-eqkind-m: {Mm} + {D:{x} {d:evof x A} eqkind (K x) (K' x)} + ({x} {d} meqkind (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} eqkinde (G x) (K x) (K' x)} + ({x} meqkinde (D' x) Mm) -> type. +%mode cut-eqkind-m +Mm +X1 +X2 +X3 -X4 -X5. + +%% + +cut-eofe-m : {Mm} + {D : {x} {d:evof x A} eofe (G x) (M x) (B x)} + ({x} {d} meofe (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} eofe (G x) (M x) (B x)} + ({x} meofe (D' x) Mm) -> type. +%mode cut-eofe-m +Mm +D +X3 +X4 -X5 -X6. + +cut-ekofe-m : {Mm} + {D : {x} {d:evof x A} ekofe (G x) (M x) (B x)} + ({x} {d} mekofe (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} ekofe (G x) (M x) (B x)} + ({x} mekofe (D' x) Mm) -> type. +%mode cut-ekofe-m +Mm +D +X3 +X4 -X5 -X6. + +cut-ewfkinde-m : {Mm} + {D : {x} {d:evof x A} ewfkinde (G x) (K x)} + ({x} {d} mewfkinde (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} ewfkinde (G x) (K x)} + ({x} mewfkinde (D' x) Mm) -> type. +%mode cut-ewfkinde-m +Mm +D +X3 +X4 -X5 -X6. + +cut-eqtpe-m : {Mm} + {D : {x} {d:evof x A} eqtpe (G x) (B x) (B' x) (K x)} + ({x} {d} meqtpe (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} eqtpe (G x) (B x) (B' x) (K x)} + ({x} meqtpe (D' x) Mm) -> type. +%mode cut-eqtpe-m +Mm +X1 +X2 +X3 -X4 -X5. + +cut-eqtme-m : {Mm} + {D : {x} {d:evof x A} eqtme (G x) (B x) (B' x) (K x)} + ({x} {d} meqtme (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} eqtme (G x) (B x) (B' x) (K x)} + ({x} meqtme (D' x) Mm) -> type. +%mode cut-eqtme-m +Mm +X1 +X2 +X3 -X4 -X5. + +cut-eqkinde-m : {Mm} + {D : {x} {d:evof x A} eqkinde (G x) (B x) (B' x)} + ({x} {d} meqkinde (D x d) Mm) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} eqkinde (G x) (B x) (B' x)} + ({x} meqkinde (D' x) Mm) -> type. +%mode cut-eqkinde-m +Mm +X1 +X2 +X3 -X4 -X5. + + +-varsam : cut-eof-m _ + ([x] [d] + eof/var + (DofA x d : ekof A ektype) + d) + ([x] [d] + meof/var + (DmofA x d : mekof (DofA x d) Am)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/var (DofeA x) (Dlook x)) + ([x] meofe/var (DmofeA x)) +%% + <- cut-ekof-m _ + ([x] [d] DofA x d) ([x] [d] DmofA x d) ([x] Dlook x) + ([x] DofeA x : ekofe (G x) A ektype) + ([x] DmofeA x : mekofe (DofeA x) Am). + +-varoth : cut-eof-m _ + ([x] [d] + eof/var + (DofB x d : ekof B ektype) + (DofY : evof Y B)) + ([x] [d] + meof/var + (DmofB x d : mekof (DofB x d) Bm)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/vari (DofB' x) DofY) + ([x] meofe/vari (DmofB' x)) +%% + <- cut-ekof-m _ DofB DmofB Dlook + ([x] DofB' x : ekofe (G x) B ektype) + ([x] DmofB' x). + +-const : cut-eof-m _ + ([x] [d] + eof/const + (DofB x d : ekof (B x) ektype) + (DofC x : ecof C (B x))) + ([x] [d] + meof/const + (DmofB x d : mekof (DofB x d) Bm)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/const (DofeB x) (DofC x)) + ([x] meofe/const (DmofeB x)) +%% + <- cut-ekof-m _ ([x] [d] DofB x d) ([x] [d] DmofB x d) + ([x] Dlook x) + ([x] DofeB x : ekofe (G x) (B x) ektype) + ([x] DmofeB x : mekofe (DofeB x) Bm). + +-app : cut-eof-m _ + ([x] [d] + eof/app + (DofN x d : eof (N x) (B x)) + (DofM x d : eof (M x) (epi (B x) ([y] C x y)))) + ([x] [d] + meof/app + (DmofN x d : meof (DofN x d) Nm) + (DmofM x d : meof (DofM x d) Mm)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/app (DofeN x) (DofeM x)) + ([x] meofe/app (DmofeN x) (DmofeM x)) +%% + <- cut-eof-m _ + DofN DmofN Dlook DofeN ([x] DmofeN x : meofe (DofeN x) Nm) + <- cut-eof-m _ + DofM DmofM Dlook + ([x] DofeM x : eofe (G x) (M x) (epi (B x) ([y] C x y))) + ([x] DmofeM x : meofe (DofeM x) Mm). + +-lam : cut-eof-m _ + ([x] [d:evof x A] + eof/lam + (DofB x d : ekof (B x) ektype) + ([y] [e:evof y (B x)] DofM x d y e : eof (M x y) (C x y))) + ([x] [d] + meof/lam + (DmofB x d : mekof (DofB x d) Bm) + ([y] [e] DmofM x d y e : meof (DofM x d y e) Mm)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/lam (DofeB x) ([y] DofeM' x y)) + ([x] meofe/lam (DmofeB x) ([y] DmofeM' x y)) +%% + <- cut-ekof-m _ DofB DmofB Dlook + ([x] DofeB x : ekofe (G x) (B x) ektype) + ([x] DmofeB x) + <- ({x} {d:evof x A} + cut-eof-m _ + ([y] [e] DofM x d y e) ([y] [e] DmofM x d y e) + ([y] elookup/hit) + ([y] DofeM x d y + : eofe (econs (G x) y (B x)) (M x y) (C x y)) + ([y] DmofeM x d y + : meofe (DofeM x d y) Mm)) + <- ({x} {y} + weaken-elookup (Dlook x) y (B x) + (Dlook' x y : elookup (econs (G x) y (B x)) x A)) + <- ({y} + cut-eofe-m _ + ([x] [d] DofeM x d y) ([x] [d] DmofeM x d y) + ([x] Dlook' x y) + ([x] DofeM' x y) + ([x] DmofeM' x y : meofe (DofeM' x y) Mm)). + +-eqtp : cut-eof-m _ + ([x] [d] + eof/eqtp + (Deqtp x d : eqtp (B x) (C x) ektype) + (DofMB x d : eof (M x) (B x))) + ([x] [d] + meof/eqtp + (Dmeqtp x d : meqtp (Deqtp x d) M2) + (DmofMB x d : meof (DofMB x d) M1)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/eqtp (Deqtpe x) (DofeMB x)) + ([x] meofe/eqtp (Dmeqtpe x) (DmeofeMB x)) +%% + <- cut-eof-m _ DofMB DmofMB Dlook + ([x] DofeMB x : eofe (G x) (M x) (B x)) + ([x] DmeofeMB x : meofe (DofeMB x) M1) + <- cut-eqtp-m _ Deqtp Dmeqtp Dlook + ([x] Deqtpe x : eqtpe (G x) (B x) (C x) ektype) + ([x] Dmeqtpe x : meqtpe (Deqtpe x) M2). + +-ext : cut-eof-m (mpair MM MApp) + ([x] [d] + eof/ext + ([y] [e] + DofApp x d y e : eof (eapp (M x) y) (B x y)) + (DofM x d : eof (M x) (epi (A x) ([y] B' x y)))) + ([x] [d] + meof/ext + ([y] [e] DmofApp x d y e + : meof (DofApp x d y e) MApp) + (DmofM x d : meof (DofM x d) MM)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eofe/ext ([y] DofeApp' x y) (DofeM x)) + ([x] meofe/ext ([y] DmofeApp' x y) (DmofeM x)) +%% + <- cut-eof-m _ DofM DmofM Dlook + ([x] DofeM x : eofe (G x) (M x) (epi (A x) ([y] B' x y))) + ([x] DmofeM x : meofe (DofeM x) MM) + <- ({x} {d:evof x C} + cut-eof-m _ + ([y] [e] DofApp x d y e) ([y] [e] DmofApp x d y e) + ([y] elookup/hit) + ([y] DofeApp x d y + : eofe (econs (G x) y (A x)) (eapp (M x) y) (B x y)) + ([y] DmofeApp x d y + : meofe (DofeApp x d y) MApp)) + <- ({y} + cut-eofe-m _ + ([x] [d] DofeApp x d y) ([x] [d] DmofeApp x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofeApp' x y + : eofe (econs (G x) y (A x)) (eapp (M x) y) (B x y)) + ([x] DmofeApp' x y + : meofe (DofeApp' x y) MApp)). + +%%%% + +-const : cut-ekof-m (msing M) + ([x] [d] + ekof/const + (Dwfkind x d : ewfkind (K x)) + (Deckof x : eckof B (K x))) + ([x] [d] + mekof/const + (Dmwfkind x d : mewfkind (Dwfkind x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] ekofe/const (Dwfkinde x) (Deckof x)) + ([x] mekofe/const (Dmwfkinde x)) +%% + <- cut-ewfkind-m M Dwfkind Dmwfkind Dlook Dwfkinde Dmwfkinde. + +-app : cut-ekof-m (mpair Mof Mkof) + ([x] [d] + ekof/app + (Dof x d : eof (M x) (B x)) + (Dkof x d : ekof (A x) (ekpi (B x) ([y] K x y)))) + ([x] [d] + mekof/app + (Dmof x d : meof (Dof x d) Mof) + (Dmkof x d : mekof (Dkof x d) Mkof)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ekofe/app (Dofe x) (Dkofe x)) + ([x] mekofe/app (Dmofe x) (Dmkofe x)) +%% + <- cut-eof-m Mof Dof Dmof Dlook + ([x] Dofe x : eofe (G x) (M x) (B x)) + ([x] Dmofe x : meofe (Dofe x) Mof) + <- cut-ekof-m Mkof Dkof Dmkof Dlook + ([x] Dkofe x : ekofe (G x) (A x) (ekpi (B x) ([y] K x y))) + ([x] Dmkofe x : mekofe (Dkofe x) Mkof). + +-pi : cut-ekof-m (mpair Bm Am) + ([x] [d] + ekof/pi + ([y] [e:evof y (A x)] + DofB x d y e : ekof (B x y) ektype) + (DofA x d : ekof (A x) ektype)) + ([x] [d] + mekof/pi + ([y] [e] + DmofB x d y e : mekof (DofB x d y e) Bm) + (DmofA x d : mekof (DofA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ekofe/pi (DofeA x) ([y] DofeB' x y)) + ([x] mekofe/pi (DmofeA x) ([y] DmofeB' x y)) +%% + <- cut-ekof-m Am DofA DmofA Dlook + ([x] DofeA x : ekofe (G x) (A x) ektype) + ([x] DmofeA x : mekofe (DofeA x) Am) + <- ({x} {d} + cut-ekof-m Bm ([y] [e] DofB x d y e) ([y] [e] DmofB x d y e) + ([y] elookup/hit) + ([y] DofeB x d y) + ([y] DmofeB x d y)) + <- ({y} + cut-ekofe-m Bm ([x] [d] DofeB x d y) ([x] [d] DmofeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofeB' x y) + ([x] DmofeB' x y)). + +-lam : cut-ekof-m (mpair Am Bm) + ([x] [d] + ekof/lam + (DofA x d : ekof (A x) ektype) + ([y] [e:evof y (A x)] + DofB x d y e : ekof (B x y) (K x y))) + ([x] [d] + mekof/lam + (DmofA x d : mekof (DofA x d) Am) + ([y] [e] + DmofB x d y e : mekof (DofB x d y e) Bm)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ekofe/lam (DofeA x) ([y] DofeB' x y)) + ([x] mekofe/lam (DmofeA x) ([y] DmofeB' x y)) +%% + <- cut-ekof-m Am DofA DmofA Dlook + ([x] DofeA x : ekofe (G x) (A x) ektype) + ([x] DmofeA x : mekofe (DofeA x) Am) + <- ({x} {d} + cut-ekof-m Bm ([y] [e] DofB x d y e) ([y] [e] DmofB x d y e) + ([y] elookup/hit) + ([y] DofeB x d y) + ([y] DmofeB x d y)) + <- ({y} + cut-ekofe-m Bm ([x] [d] DofeB x d y) ([x] [d] DmofeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofeB' x y) + ([x] DmofeB' x y)). + +-eqkind : cut-ekof-m (mpair Meq Mof) + ([x] [d] + ekof/eqkind + (Deqkind x d : eqkind (K x) (L x)) + (Dekof x d : ekof (B x) (K x))) + ([x] [d] + mekof/eqk + (Dmeqkind x d : meqkind (Deqkind x d) Meq) + (Dmekof x d : mekof (Dekof x d) Mof)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ekofe/eqkind (Deqkinde x) (Dekofe x)) + ([x] mekofe/eqk (Dmeqkinde x) (Dmekofe x)) +%% + <- cut-ekof-m Mof Dekof Dmekof Dlook Dekofe Dmekofe + <- cut-eqkind-m Meq Deqkind Dmeqkind Dlook Deqkinde Dmeqkinde. + +-ext : cut-ekof-m (mpair Mm1 Mm2) + ([x] [d] + ekof/ext + ([y] [e] DofApp x d y e : ekof (eaapp (C x) y) (K x y)) + (DofC x d : ekof (C x) (ekpi (B x) ([y] K' x y)))) + ([x] [d] + mekof/ext + ([y] [e] DmofApp x d y e : mekof (DofApp x d y e) Mm2) + (DmofC x d : mekof (DofC x d) Mm1)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] ekofe/ext ([y] DofeApp' x y) (DofeC x)) + ([x] mekofe/ext ([y] DmofeApp' x y) (DmofeC x)) +%% + <- cut-ekof-m Mm1 DofC DmofC Dlook DofeC DmofeC + <- ({x} {d} + cut-ekof-m Mm2 ([y] [e] DofApp x d y e) + ([y] [e] DmofApp x d y e) ([y] elookup/hit) + ([y] DofeApp x d y) ([y] DmofeApp x d y)) + <- ({y} + cut-ekofe-m Mm2 ([x] [d] DofeApp x d y) + ([x] [d] DmofeApp x d y) ([x] elookup/miss (Dlook x)) + ([x] DofeApp' x y) ([x] DmofeApp' x y)). + +%%%% + +-tp : cut-ewfkind-m munit ([_] [_] ewfkind/tp) ([_] [_] mewfkind/tp) + ([x] Dlook x) ([_] ewfkinde/tp) ([_] mewfkinde/tp). + +-pi : cut-ewfkind-m (mpair Mwf Mkof) + ([x] [d] ewfkind/pi + ([y] [e] Dwf x d y e) + (Dkof x d)) + ([x] [d] mewfkind/pi + ([y] [e] Dmwf x d y e) + (Dmkof x d)) + ([x] Dlook x) +%% + ([x] ewfkinde/pi (Dkofe x) ([y] Dwfe' x y)) + ([x] mewfkinde/pi (Dmkofe x) ([y] Dmwfe' x y)) +%% + <- cut-ekof-m Mkof Dkof Dmkof Dlook Dkofe Dmkofe + <- ({x} {d} + cut-ewfkind-m Mwf ([y] [e] Dwf x d y e) + ([y] [e] Dmwf x d y e) ([y] elookup/hit) + ([y] Dwfe x d y) ([y] Dmwfe x d y)) + <- ({y} + cut-ewfkinde-m Mwf ([x] [d] Dwfe x d y) + ([x] [d] Dmwfe x d y) ([x] elookup/miss (Dlook x)) + ([x] Dwfe' x y) ([x] Dmwfe' x y)). + +%%%% + +-app : cut-eqtp-m (mpair Mtm Mtp) + ([x] [d] + eqtp/app + (Deqtm x d : eqtm (M x) (N x) (C x)) + (Deqtp x d : eqtp (A x) (B x) (ekpi (C x) ([y] K x y)))) + ([x] [d] + meqtp/app + (Dmeqtm x d : meqtm (Deqtm x d) Mtm) + (Dmeqtp x d : meqtp (Deqtp x d) Mtp)) + ([x] Dlook x : elookup (G x) x D) +%% + ([x] eqtpe/app (Deqtme x) (Deqtpe x)) + ([x] meqtpe/app (Dmeqtme x) (Dmeqtpe x)) +%% + <- cut-eqtm-m Mtm Deqtm Dmeqtm Dlook + ([x] Deqtme x : eqtme (G x) (M x) (N x) (C x)) + ([x] Dmeqtme x : meqtme (Deqtme x) Mtm) + <- cut-eqtp-m Mtp Deqtp Dmeqtp Dlook + ([x] Deqtpe x + : eqtpe (G x) (A x) (B x) (ekpi (C x) ([y] K x y))) + ([x] Dmeqtpe x : meqtpe (Deqtpe x) Mtp). + +-pi : cut-eqtp-m (mpair Bm Am) + ([x] [d] + eqtp/pi + ([y] [e] DeqB x d y e : eqtp (B x y) (B' x y) ektype) + (DeqA x d : eqtp (A x) (A' x) ektype)) + ([x] [d] + meqtp/pi + ([y] [e] DmeqB x d y e : meqtp (DeqB x d y e) Bm) + (DmeqA x d : meqtp (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/pi ([y] DeqeB' x y) (DeqeA x)) + ([x] meqtpe/pi ([y] DmeqeB' x y) (DmeqeA x)) +%% + <- cut-eqtp-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({x} {d} + cut-eqtp-m Bm ([y] [e] DeqB x d y e) ([y] [e] DmeqB x d y e) + ([y] elookup/hit) + ([y] DeqeB x d y + : eqtpe (econs (G x) y (A x)) (B x y) (B' x y) ektype) + ([y] DmeqeB x d y + : meqtpe (DeqeB x d y) Bm)) + <- ({y} + cut-eqtpe-m Bm ([x] [d] DeqeB x d y) ([x] [d] DmeqeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqtpe (econs (G x) y (A x)) (B x y) (B' x y) ektype) + ([x] DmeqeB' x y + : meqtpe (DeqeB' x y) Bm)). + +-lam : cut-eqtp-m (mpair Bm Am) + ([x] [d] + eqtp/lam + ([y] [e] DeqB x d y e : eqtp (B x y) (B' x y) (K x y)) + (DeqA x d : eqtp (A x) (A' x) ektype)) + ([x] [d] + meqtp/lam + ([y] [e] DmeqB x d y e : meqtp (DeqB x d y e) Bm) + (DmeqA x d : meqtp (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/lam ([y] DeqeB' x y) (DeqeA x)) + ([x] meqtpe/lam ([y] DmeqeB' x y) (DmeqeA x)) +%% + <- cut-eqtp-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({x} {d} + cut-eqtp-m Bm ([y] [e] DeqB x d y e) ([y] [e] DmeqB x d y e) + ([y] elookup/hit) + ([y] DeqeB x d y + : eqtpe (econs (G x) y (A x)) (B x y) (B' x y) (K x y)) + ([y] DmeqeB x d y + : meqtpe (DeqeB x d y) Bm)) + <- ({y} + cut-eqtpe-m Bm ([x] [d] DeqeB x d y) ([x] [d] DmeqeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqtpe (econs (G x) y (A x)) (B x y) (B' x y) (K x y)) + ([x] DmeqeB' x y + : meqtpe (DeqeB' x y) Bm)). + +-ext : cut-eqtp-m (mpair (mpair M1 M2) M3) + ([x] [d] + eqtp/ext + ([y] [e] Deqtp x d y e + : eqtp (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + (DofB' x d : ekof (B' x) (ekpi (A x) ([y] K'' x y))) + (DofB x d : ekof (B x) (ekpi (A x) ([y] K' x y)))) + ([x] [d] + meqtp/ext + ([y] [e] Dmeqtp x d y e + : meqtp (Deqtp x d y e) M3) + (DmofB' x d : mekof (DofB' x d) M2) + (DmofB x d : mekof (DofB x d) M1)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/ext ([y] Deqtpe' x y) (DofeB' x) (DofeB x)) + ([x] meqtpe/ext ([y] Dmeqtpe' x y) (DmofeB' x) (DmofeB x)) +%% + <- cut-ekof-m M1 DofB DmofB Dlook + ([x] DofeB x : ekofe (G x) (B x) (ekpi (A x) ([y] K' x y))) + ([x] DmofeB x : mekofe (DofeB x) M1) + <- cut-ekof-m M2 DofB' DmofB' Dlook + ([x] DofeB' x : ekofe (G x) (B' x) (ekpi (A x) ([y] K'' x y))) + ([x] DmofeB' x : mekofe (DofeB' x) M2) + <- ({x} {d} + cut-eqtp-m M3 ([y] [e] Deqtp x d y e) + ([y] [e] Dmeqtp x d y e) ([y] elookup/hit) + ([y] Deqtpe x d y + : eqtpe (econs (G x) y (A x)) + (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + ([y] Dmeqtpe x d y + : meqtpe (Deqtpe x d y) M3)) + <- ({y} + cut-eqtpe-m M3 ([x] [d] Deqtpe x d y) + ([x] [d] Dmeqtpe x d y) ([x] elookup/miss (Dlook x)) + ([x] Deqtpe' x y + : eqtpe (econs (G x) y (A x)) + (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + ([x] Dmeqtpe' x y + : meqtpe (Deqtpe' x y) M3)). + +-extw : cut-eqtp-m (mpair M1 M2) + ([x] [d] + eqtp/extw + ([y] [e] Deqtp x d y e + : eqtp (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + (DeqtpB x d : eqtp (B x) (B' x) (ekpi (A x) ([y] K' x y)))) + ([x] [d] + meqtp/extw + ([y] [e] Dmeqtp x d y e : meqtp (Deqtp x d y e) M2) + (DmeqtpB x d : meqtp (DeqtpB x d) M1)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/extw ([y] Deqtpe' x y) (DeqtpeB x)) + ([x] meqtpe/extw ([y] Dmeqtpe' x y) (DmeqtpeB x)) +%% + <- cut-eqtp-m M1 DeqtpB DmeqtpB Dlook + ([x] DeqtpeB x + : eqtpe (G x) (B x) (B' x) (ekpi (A x) ([y] K' x y))) + ([x] DmeqtpeB x : meqtpe (DeqtpeB x) M1) + <- ({x} {d} + cut-eqtp-m M2 ([y] [e] Deqtp x d y e) + ([y] [e] Dmeqtp x d y e) ([y] elookup/hit) + ([y] Deqtpe x d y + : eqtpe (econs (G x) y (A x)) + (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + ([y] Dmeqtpe x d y + : meqtpe (Deqtpe x d y) M2)) + <- ({y} + cut-eqtpe-m M2 ([x] [d] Deqtpe x d y) + ([x] [d] Dmeqtpe x d y) ([x] elookup/miss (Dlook x)) + ([x] Deqtpe' x y + : eqtpe (econs (G x) y (A x)) + (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + ([x] Dmeqtpe' x y + : meqtpe (Deqtpe' x y) M2)). + +-beta : cut-eqtp-m (mpair Nm Bm) + ([x] [d] + eqtp/beta + (DofN x d: eof (N x) (A x)) + ([y] [e] DofB x d y e : ekof (B x y) (K x y))) + ([x] [d] + meqtp/beta + (DmofN x d : meof (DofN x d) Nm) + ([y] [e] DmofB x d y e : mekof (DofB x d y e) Bm)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/beta (DofeN x) ([y] DofeB' x y)) + ([x] meqtpe/beta (DmofeN x) ([y] DmofeB' x y)) +%% + <- cut-eof-m Nm DofN DmofN Dlook + ([x] DofeN x : eofe (G x) (N x) (A x)) + ([x] DmofeN x : meofe (DofeN x) Nm) + <- ({x} {d} + cut-ekof-m Bm ([y] [e] DofB x d y e) + ([y] [e] DmofB x d y e) ([y] elookup/hit) + ([y] DofeB x d y + : ekofe (econs (G x) y (A x)) (B x y) (K x y)) + ([y] DmofeB x d y + : mekofe (DofeB x d y) Bm)) + <- ({y} + cut-ekofe-m Bm ([x] [d] DofeB x d y) ([x] [d] DmofeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofeB' x y + : ekofe (econs (G x) y (A x)) (B x y) (K x y)) + ([x] DmofeB' x y + : mekofe (DofeB' x y) Bm)). + +-sym : cut-eqtp-m (msing M) + ([x] [d] + eqtp/sym (Deqtp x d : eqtp (B x) (B' x) (K x))) + ([x] [d] + meqtp/sym (Dmeqtp x d : meqtp (Deqtp x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtpe/sym (Deqtpe x)) + ([x] meqtpe/sym (Dmeqtpe x)) +%% + <- cut-eqtp-m M Deqtp Dmeqtp Dlook Deqtpe Dmeqtpe. + +-trans : cut-eqtp-m (mpair M1 M2) + ([x] [d] + eqtp/trans + (Deq2 x d : eqtp (B' x) (B'' x) (K x)) + (Deq1 x d : eqtp (B x ) (B' x) (K x))) + ([x] [d] + meqtp/trans + (Dmeq2 x d : meqtp (Deq2 x d) M2) + (Dmeq1 x d : meqtp (Deq1 x d) M1)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtpe/trans (Deqe2 x) (Deqe1 x)) + ([x] meqtpe/trans (Dmeqe2 x) (Dmeqe1 x)) +%% + <- cut-eqtp-m M1 Deq1 Dmeq1 Dlook Deqe1 Dmeqe1 + <- cut-eqtp-m M2 Deq2 Dmeq2 Dlook Deqe2 Dmeqe2. + +-refl : cut-eqtp-m (msing M) + ([x] [d] + eqtp/refl (Dkof x d : ekof (B x) (K x))) + ([x] [d] + meqtp/refl (Dmkof x d : mekof (Dkof x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtpe/refl (Dkofe x)) + ([x] meqtpe/refl (Dmkofe x)) +%% + <- cut-ekof-m M Dkof Dmkof Dlook Dkofe Dmkofe. + +-kcon : cut-eqtp-m (mpair Am Km) + ([x] [d] eqtp/kcon + (Deqk x d : eqkind (K x) (K' x)) + (Deqtp x d : eqtp (B x) (B' x) (K x))) + ([x] [d] meqtp/kcon + (Dmeqk x d : meqkind (Deqk x d) Km) + (Dmeqtp x d : meqtp (Deqtp x d) Am)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtpe/kcon (Deqke x) (Deqtpe x)) + ([x] meqtpe/kcon (Dmeqke x) (Dmeqtpe x)) +%% + <- cut-eqtp-m Am Deqtp Dmeqtp Dlook Deqtpe Dmeqtpe + <- cut-eqkind-m Km Deqk Dmeqk Dlook Deqke Dmeqke. + + +%%%% + +-app : cut-eqtm-m _ + ([x] [d] + eqtm/app + (DeqN x d : eqtm (N x) (N' x) (A x)) + (DeqM x d : eqtm (M x) (M' x) (epi (A x) ([y] B x y)))) + ([x] [d] meqtm/app (DmeqN x d) (DmeqM x d)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/app (DeqeN x) (DeqeM x)) + ([x] meqtme/app (DmeqeN x) (DmeqeM x)) +%% + <- cut-eqtm-m _ DeqN DmeqN Dlook DeqeN DmeqeN + <- cut-eqtm-m _ DeqM DmeqM Dlook DeqeM DmeqeM. + +-lam : cut-eqtm-m (mpair Bm Am) + ([x] [d] + eqtm/lam + ([y] [e] DeqB x d y e : eqtm (B x y) (B' x y) (K x y)) + (DeqA x d : eqtp (A x) (A' x) ektype)) + ([x] [d] + meqtm/lam + ([y] [e] DmeqB x d y e : meqtm (DeqB x d y e) Bm) + (DmeqA x d : meqtp (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/lam ([y] DeqeB' x y) (DeqeA x)) + ([x] meqtme/lam ([y] DmeqeB' x y) (DmeqeA x)) +%% + <- cut-eqtp-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({x} {d} + cut-eqtm-m Bm ([y] [e] DeqB x d y e) ([y] [e] DmeqB x d y e) + ([y] elookup/hit) + ([y] DeqeB x d y + : eqtme (econs (G x) y (A x)) (B x y) (B' x y) (K x y)) + ([y] DmeqeB x d y + : meqtme (DeqeB x d y) Bm)) + <- ({y} + cut-eqtme-m Bm ([x] [d] DeqeB x d y) ([x] [d] DmeqeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqtme (econs (G x) y (A x)) (B x y) (B' x y) (K x y)) + ([x] DmeqeB' x y + : meqtme (DeqeB' x y) Bm)). + +-ext : cut-eqtm-m (mpair (mpair M1 M2) M3) + ([x] [d] + eqtm/ext + ([y] [e] Deqtm x d y e + : eqtm (eapp (B x) y) (eapp (B' x) y) (K x y)) + (DofB' x d : eof (B' x) (epi (A x) ([y] K'' x y))) + (DofB x d : eof (B x) (epi (A x) ([y] K' x y)))) + ([x] [d] + meqtm/ext + ([y] [e] Dmeqtm x d y e + : meqtm (Deqtm x d y e) M3) + (DmofB' x d : meof (DofB' x d) M2) + (DmofB x d : meof (DofB x d) M1)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/ext ([y] Deqtme' x y) (DofeB' x) (DofeB x)) + ([x] meqtme/ext ([y] Dmeqtme' x y) (DmofeB' x) (DmofeB x)) +%% + <- cut-eof-m M1 DofB DmofB Dlook + ([x] DofeB x : eofe (G x) (B x) (epi (A x) ([y] K' x y))) + ([x] DmofeB x : meofe (DofeB x) M1) + <- cut-eof-m M2 DofB' DmofB' Dlook + ([x] DofeB' x : eofe (G x) (B' x) (epi (A x) ([y] K'' x y))) + ([x] DmofeB' x : meofe (DofeB' x) M2) + <- ({x} {d} + cut-eqtm-m M3 ([y] [e] Deqtm x d y e) + ([y] [e] Dmeqtm x d y e) ([y] elookup/hit) + ([y] Deqtme x d y + : eqtme (econs (G x) y (A x)) + (eapp (B x) y) (eapp (B' x) y) (K x y)) + ([y] Dmeqtme x d y + : meqtme (Deqtme x d y) M3)) + <- ({y} + cut-eqtme-m M3 ([x] [d] Deqtme x d y) + ([x] [d] Dmeqtme x d y) ([x] elookup/miss (Dlook x)) + ([x] Deqtme' x y + : eqtme (econs (G x) y (A x)) + (eapp (B x) y) (eapp (B' x) y) (K x y)) + ([x] Dmeqtme' x y + : meqtme (Deqtme' x y) M3)). + +-extw : cut-eqtm-m (mpair M1 M2) + ([x] [d] + eqtm/extw + ([y] [e] Deqtp x d y e + : eqtm (eapp (B x) y) (eapp (B' x) y) (K x y)) + (DeqtpB x d : eqtm (B x) (B' x) (epi (A x) ([y] K' x y)))) + ([x] [d] + meqtm/extw + ([y] [e] Dmeqtp x d y e : meqtm (Deqtp x d y e) M2) + (DmeqtpB x d : meqtm (DeqtpB x d) M1)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/extw ([y] Deqtpe' x y) (DeqtpeB x)) + ([x] meqtme/extw ([y] Dmeqtpe' x y) (DmeqtpeB x)) +%% + <- cut-eqtm-m M1 DeqtpB DmeqtpB Dlook + ([x] DeqtpeB x + : eqtme (G x) (B x) (B' x) (epi (A x) ([y] K' x y))) + ([x] DmeqtpeB x : meqtme (DeqtpeB x) M1) + <- ({x} {d} + cut-eqtm-m M2 ([y] [e] Deqtp x d y e) + ([y] [e] Dmeqtp x d y e) ([y] elookup/hit) + ([y] Deqtpe x d y + : eqtme (econs (G x) y (A x)) + (eapp (B x) y) (eapp (B' x) y) (K x y)) + ([y] Dmeqtpe x d y + : meqtme (Deqtpe x d y) M2)) + <- ({y} + cut-eqtme-m M2 ([x] [d] Deqtpe x d y) + ([x] [d] Dmeqtpe x d y) ([x] elookup/miss (Dlook x)) + ([x] Deqtpe' x y + : eqtme (econs (G x) y (A x)) + (eapp (B x) y) (eapp (B' x) y) (K x y)) + ([x] Dmeqtpe' x y + : meqtme (Deqtpe' x y) M2)). + + +-beta : cut-eqtm-m (mpair Nm Bm) + ([x] [d] + eqtm/beta + (DofN x d: eof (N x) (A x)) + ([y] [e] DofB x d y e : eof (B x y) (K x y))) + ([x] [d] + meqtm/beta + (DmofN x d : meof (DofN x d) Nm) + ([y] [e] DmofB x d y e : meof (DofB x d y e) Bm)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/beta (DofeN x) ([y] DofeB' x y)) + ([x] meqtme/beta (DmofeN x) ([y] DmofeB' x y)) +%% + <- cut-eof-m Nm DofN DmofN Dlook + ([x] DofeN x : eofe (G x) (N x) (A x)) + ([x] DmofeN x : meofe (DofeN x) Nm) + <- ({x} {d} + cut-eof-m Bm ([y] [e] DofB x d y e) + ([y] [e] DmofB x d y e) ([y] elookup/hit) + ([y] DofeB x d y + : eofe (econs (G x) y (A x)) (B x y) (K x y)) + ([y] DmofeB x d y + : meofe (DofeB x d y) Bm)) + <- ({y} + cut-eofe-m Bm ([x] [d] DofeB x d y) ([x] [d] DmofeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofeB' x y + : eofe (econs (G x) y (A x)) (B x y) (K x y)) + ([x] DmofeB' x y + : meofe (DofeB' x y) Bm)). + +-sym : cut-eqtm-m (msing M) + ([x] [d] + eqtm/sym (Deqtm x d : eqtm (B x) (B' x) (K x))) + ([x] [d] + meqtm/sym (Dmeqtm x d : meqtm (Deqtm x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtme/sym (Deqtme x)) + ([x] meqtme/sym (Dmeqtme x)) +%% + <- cut-eqtm-m M Deqtm Dmeqtm Dlook Deqtme Dmeqtme. + +-trans : cut-eqtm-m (mpair M1 M2) + ([x] [d] + eqtm/trans + (Deq2 x d : eqtm (B' x) (B'' x) (K x)) + (Deq1 x d : eqtm (B x ) (B' x) (K x))) + ([x] [d] + meqtm/trans + (Dmeq2 x d : meqtm (Deq2 x d) M2) + (Dmeq1 x d : meqtm (Deq1 x d) M1)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtme/trans (Deqe2 x) (Deqe1 x)) + ([x] meqtme/trans (Dmeqe2 x) (Dmeqe1 x)) +%% + <- cut-eqtm-m M1 Deq1 Dmeq1 Dlook Deqe1 Dmeqe1 + <- cut-eqtm-m M2 Deq2 Dmeq2 Dlook Deqe2 Dmeqe2. + +-refl : cut-eqtm-m (msing M) + ([x] [d] + eqtm/refl (Dof x d : eof (B x) (K x))) + ([x] [d] + meqtm/refl (Dmof x d : meof (Dof x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtme/refl (Dofe x)) + ([x] meqtme/refl (Dmofe x)) +%% + <- cut-eof-m M Dof Dmof Dlook Dofe Dmofe. + +-tcon : cut-eqtm-m (mpair Am Km) + ([x] [d] eqtm/typecon + (Deqk x d : eqtp (K x) (K' x) _) + (Deqtm x d : eqtm (B x) (B' x) (K x))) + ([x] [d] meqtm/tcon + (Dmeqk x d : meqtp (Deqk x d) Km) + (Dmeqtm x d : meqtm (Deqtm x d) Am)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtme/tcon (Deqke x) (Deqtme x)) + ([x] meqtme/tcon (Dmeqke x) (Dmeqtme x)) +%% + <- cut-eqtm-m Am Deqtm Dmeqtm Dlook Deqtme Dmeqtme + <- cut-eqtp-m Km Deqk Dmeqk Dlook Deqke Dmeqke. + + +%%%% + +-tp : cut-eqkind-m munit ([x] [d] eqkind/tp) ([x] [d] meqkind/tp) _ + ([x] eqkinde/tp) ([x] meqkinde/tp). + +-pi : cut-eqkind-m (mpair Bm Am) + ([x] [d] + eqkind/pi + ([y] [e] DeqB x d y e : eqkind (B x y) (B' x y)) + (DeqA x d : eqtp (A x) (A' x) ektype)) + ([x] [d] + meqkind/pi + ([y] [e] DmeqB x d y e : meqkind (DeqB x d y e) Bm) + (DmeqA x d : meqtp (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqkinde/pi ([y] DeqeB' x y) (DeqeA x)) + ([x] meqkinde/pi ([y] DmeqeB' x y) (DmeqeA x)) +%% + <- cut-eqtp-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({x} {d} + cut-eqkind-m Bm + ([y] [e] DeqB x d y e) ([y] [e] DmeqB x d y e) + ([y] elookup/hit) + ([y] DeqeB x d y + : eqkinde (econs (G x) y (A x)) (B x y) (B' x y)) + ([y] DmeqeB x d y + : meqkinde (DeqeB x d y) Bm)) + <- ({y} + cut-eqkinde-m Bm ([x] [d] DeqeB x d y) ([x] [d] DmeqeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqkinde (econs (G x) y (A x)) (B x y) (B' x y)) + ([x] DmeqeB' x y + : meqkinde (DeqeB' x y) Bm)). + +-sym : cut-eqkind-m _ + ([x] [d] eqkind/sym (Deq x d)) + ([x] [d] meqkind/sym (Dmeq x d)) + ([x] Dlook x) + ([x] eqkinde/sym (Deqe x)) + ([x] meqkinde/sym (Dmeqe x)) + <- cut-eqkind-m _ Deq Dmeq Dlook Deqe Dmeqe. + +-trans : cut-eqkind-m _ + ([x] [d] eqkind/trans (Deq1 x d) (Deq2 x d)) + ([x] [d] meqkind/trn (Dmeq1 x d) (Dmeq2 x d)) + ([x] Dlook x) + ([x] eqkinde/trans (Deqe1 x) (Deqe2 x)) + ([x] meqkinde/trn (Dmeqe1 x) (Dmeqe2 x)) + <- cut-eqkind-m _ Deq1 Dmeq1 Dlook Deqe1 Dmeqe1 + <- cut-eqkind-m _ Deq2 Dmeq2 Dlook Deqe2 Dmeqe2. + +-refl : cut-eqkind-m _ + ([x] [d] eqkind/refl (Dwf x d)) + ([x] [d] meqkind/ref (Dmwf x d)) + ([x] Dlook x) + ([x] eqkinde/refl (Dwfe x)) + ([x] meqkinde/ref (Dmwfe x)) + <- cut-ewfkind-m _ Dwf Dmwf Dlook Dwfe Dmwfe. + + +%%%% + +%%%% + +-varioth : cut-eofe-m _ + ([x] [d] + eofe/vari + (Dkof x d : ekofe (G x) B ektype) + (Dvof : evof Y B)) + ([x] [d] + meofe/vari + (Dmkof x d : mekofe (Dkof x d) Mm)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/vari (Dkofe x) Dvof) + ([x] meofe/vari (Dmkofe x)) +%% + <- cut-ekofe-m Mm Dkof Dmkof Dlook + ([x] Dkofe x : ekofe (G x) B ektype) + ([x] Dmkofe x : mekofe (Dkofe x) Mm). + +-varisam : cut-eofe-m _ + ([x] [d:evof x A] + eofe/vari + (Dkof x d : ekofe (G x) A ektype) + d) + ([x] [d] meofe/vari (Dmkof x d)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/var (Dkof' x) (Dlook x)) + ([x] meofe/var (Dmkof' x)) +%% + <- cut-ekofe-m _ Dkof Dmkof Dlook + ([x] Dkof' x : ekofe (G x) A ektype) + ([x] Dmkof' x). + +-var : cut-eofe-m (msing Mm) + ([x] [d] + eofe/var + (Dkofe x d : ekofe (G x) (B x) ektype) + (DlookY x : elookup (G x) (Y x) (B x))) + ([x] [d] + meofe/var + (Dmkofe x d : mekofe (Dkofe x d) Mm)) + ([x] DlookX x : elookup (G x) x A) +%% + ([x] eofe/var (Dkofe' x) (DlookY x)) + ([x] meofe/var (Dmkofe' x)) +%% + <- cut-ekofe-m Mm Dkofe Dmkofe DlookX + ([x] Dkofe' x : ekofe (G x) (B x) ektype) + ([x] Dmkofe' x : mekofe (Dkofe' x) Mm). + +-const : cut-eofe-m _ + ([x] [d] + eofe/const + (DofB x d : ekofe (G x) (B x) ektype) + (DofC x : ecof C (B x))) + ([x] [d] + meofe/const + (DmofB x d : mekofe (DofB x d) Bm)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/const (DofeB x) (DofC x)) + ([x] meofe/const (DmofeB x)) +%% + <- cut-ekofe-m _ ([x] [d] DofB x d) ([x] [d] DmofB x d) + ([x] Dlook x) + ([x] DofeB x : ekofe (G x) (B x) ektype) + ([x] DmofeB x : mekofe (DofeB x) Bm). + +-app : cut-eofe-m _ + ([x] [d] + eofe/app + (DofN x d : eofe (G x) (N x) (B x)) + (DofM x d : eofe (G x) (M x) (epi (B x) ([y] C x y)))) + ([x] [d] + meofe/app + (DmofN x d : meofe (DofN x d) Nm) + (DmofM x d : meofe (DofM x d) Mm)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/app (DofeN x) (DofeM x)) + ([x] meofe/app (DmofeN x) (DmofeM x)) +%% + <- cut-eofe-m _ + DofN DmofN Dlook DofeN ([x] DmofeN x : meofe (DofeN x) Nm) + <- cut-eofe-m _ + DofM DmofM Dlook + ([x] DofeM x : eofe (G x) (M x) (epi (B x) ([y] C x y))) + ([x] DmofeM x : meofe (DofeM x) Mm). + +-lam : cut-eofe-m _ + ([x] [d] + eofe/lam + (DofA x d : ekofe (G x) (A x) ektype) + ([y] DofM x d y + : eofe (econs (G x) y (A x)) (M x y) (B x y))) + ([x] [d] + meofe/lam + (DmofA x d : mekofe (DofA x d) Am) + ([y] DmofM x d y : meofe (DofM x d y) Mm)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eofe/lam (DofA' x) ([y] DofM' x y)) + ([x] meofe/lam (DmofA' x) ([y] DmofM' x y)) +%% + <- cut-ekofe-m Am DofA DmofA Dlook + ([x] DofA' x : ekofe (G x) (A x) ektype) + ([x] DmofA' x : mekofe (DofA' x) Am) + <- ({y} + cut-eofe-m Mm ([x] [d] DofM x d y) ([x] [d] DmofM x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofM' x y : eofe (econs (G x) y (A x)) (M x y) (B x y)) + ([x] DmofM' x y : meofe (DofM' x y) Mm)). + +-eqtp : cut-eofe-m _ + ([x] [d] + eofe/eqtp + (Deqtp x d : eqtpe (G x) (B x) (C x) ektype) + (DofMB x d : eofe (G x) (M x) (B x))) + ([x] [d] + meofe/eqtp + (Dmeqtp x d : meqtpe (Deqtp x d) M2) + (DmofMB x d : meofe (DofMB x d) M1)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eofe/eqtp (Deqtpe x) (DofeMB x)) + ([x] meofe/eqtp (Dmeqtpe x) (DmeofeMB x)) +%% + <- cut-eofe-m _ DofMB DmofMB Dlook + ([x] DofeMB x : eofe (G x) (M x) (B x)) + ([x] DmeofeMB x : meofe (DofeMB x) M1) + <- cut-eqtpe-m _ Deqtp Dmeqtp Dlook + ([x] Deqtpe x : eqtpe (G x) (B x) (C x) ektype) + ([x] Dmeqtpe x : meqtpe (Deqtpe x) M2). + +-ext : cut-eofe-m _ + ([x] [d] + eofe/ext + ([y] DofApp x d y + : eofe (econs (G x) y (A x)) (eapp (M x) y) (B x y)) + (DofM x d : eofe (G x) (M x) (epi (A x) ([y] B' x y)))) + ([x] [d] + meofe/ext + ([y] DmofApp x d y) + (DmofM x d)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eofe/ext ([y] DofApp' x y) (DofM' x)) + ([x] meofe/ext ([y] DmofApp' x y) (DmofM' x)) +%% + <- cut-eofe-m _ DofM DmofM Dlook DofM' DmofM' + <- ({y} + cut-eofe-m _ ([x] [d] DofApp x d y) ([x] [d] DmofApp x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofApp' x y) ([x] DmofApp' x y)). + +%%%% + +-const : cut-ekofe-m (msing M) + ([x] [d] + ekofe/const + (Dwfkind x d : ewfkinde (G x) (K x)) + (Deckofe x : eckof B (K x))) + ([x] [d] + mekofe/const + (Dmwfkind x d : mewfkinde (Dwfkind x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] ekofe/const (Dwfkinde x) (Deckofe x)) + ([x] mekofe/const (Dmwfkinde x)) +%% + <- cut-ewfkinde-m M Dwfkind Dmwfkind Dlook Dwfkinde Dmwfkinde. + +-app : cut-ekofe-m (mpair Mof Mkof) + ([x] [d] + ekofe/app + (Dof x d : eofe (G x) (M x) (B x)) + (Dkof x d : ekofe (G x) (A x) (ekpi (B x) ([y] K x y)))) + ([x] [d] + mekofe/app + (Dmof x d : meofe (Dof x d) Mof) + (Dmkof x d : mekofe (Dkof x d) Mkof)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ekofe/app (Dofe x) (Dkofe x)) + ([x] mekofe/app (Dmofe x) (Dmkofe x)) +%% + <- cut-eofe-m Mof Dof Dmof Dlook + ([x] Dofe x : eofe (G x) (M x) (B x)) + ([x] Dmofe x : meofe (Dofe x) Mof) + <- cut-ekofe-m Mkof Dkof Dmkof Dlook + ([x] Dkofe x : ekofe (G x) (A x) (ekpi (B x) ([y] K x y))) + ([x] Dmkofe x : mekofe (Dkofe x) Mkof). + +-pi : cut-ekofe-m _ + ([x] [d] + ekofe/pi + (DofA x d : ekofe (G x) (A x) ektype) + ([y] DofB x d y + : ekofe (econs (G x) y (A x)) (B x y) ektype)) + ([x] [d] mekofe/pi (DmofA x d) ([y] DmofB x d y)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ekofe/pi (DofA' x) ([y] DofB' x y)) + ([x] mekofe/pi (DmofA' x) ([y] DmofB' x y)) +%% + <- cut-ekofe-m _ DofA DmofA Dlook DofA' DmofA' + <- ({y} + cut-ekofe-m _ ([x] [d] DofB x d y) ([x] [d] DmofB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofB' x y) + ([x] DmofB' x y)). + +-lam : cut-ekofe-m _ + ([x] [d] + ekofe/lam + (DofA x d : ekofe (G x) (A x) ektype) + ([y] DofB x d y + : ekofe (econs (G x) y (A x)) (B x y) (K x y))) + ([x] [d] mekofe/lam (DmofA x d) ([y] DmofB x d y)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ekofe/lam (DofA' x) ([y] DofB' x y)) + ([x] mekofe/lam (DmofA' x) ([y] DmofB' x y)) +%% + <- cut-ekofe-m _ DofA DmofA Dlook DofA' DmofA' + <- ({y} + cut-ekofe-m _ ([x] [d] DofB x d y) ([x] [d] DmofB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofB' x y) + ([x] DmofB' x y)). + +-eqkind : cut-ekofe-m (mpair Meq Mof) + ([x] [d] + ekofe/eqkind + (Deqkind x d : eqkinde (G x) (K x) (L x)) + (Dekof x d : ekofe (G x) (B x) (K x))) + ([x] [d] + mekofe/eqk + (Dmeqkind x d : meqkinde (Deqkind x d) Meq) + (Dmekof x d : mekofe (Dekof x d) Mof)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ekofe/eqkind (Deqkinde x) (Dekofe x)) + ([x] mekofe/eqk (Dmeqkinde x) (Dmekofe x)) +%% + <- cut-ekofe-m Mof Dekof Dmekof Dlook Dekofe Dmekofe + <- cut-eqkinde-m Meq Deqkind Dmeqkind Dlook Deqkinde Dmeqkinde. + +-ext : cut-ekofe-m _ + ([x] [d] + ekofe/ext + ([y] DofApp x d y + : ekofe (econs (G x) y (B x)) (eaapp (C x) y) (K x y)) + (DofC x d : ekofe (G x) (C x) (ekpi (B x) ([y] K' x y)))) + ([x] [d] mekofe/ext ([y] DmofApp x d y) (DmofC x d)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] ekofe/ext ([y] DofApp' x y) (DofC' x)) + ([x] mekofe/ext ([y] DmofApp' x y) (DmofC' x)) +%% + <- cut-ekofe-m _ DofC DmofC Dlook + ([x] DofC' x : ekofe (G x) (C x) (ekpi (B x) ([y] K' x y))) + ([x] DmofC' x) + <- ({y} + cut-ekofe-m _ ([x] [d] DofApp x d y) ([x] [d] DmofApp x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofApp' x y + : ekofe (econs (G x) y (B x)) (eaapp (C x) y) (K x y)) + ([x] DmofApp' x y)). + +%%%% + +-tp : cut-ewfkinde-m _ + ([x] [d] ewfkinde/tp) ([x] [d] mewfkinde/tp) _ + ([x] ewfkinde/tp) ([x] mewfkinde/tp). + +-pi : cut-ewfkinde-m _ + ([x] [d] + ewfkinde/pi + (DofA x d : ekofe (G x) (A x) ektype) + ([y] DofB x d y + : ewfkinde (econs (G x) y (A x)) (B x y))) + ([x] [d] mewfkinde/pi (DmofA x d) ([y] DmofB x d y)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] ewfkinde/pi (DofA' x) ([y] DofB' x y)) + ([x] mewfkinde/pi (DmofA' x) ([y] DmofB' x y)) +%% + <- cut-ekofe-m _ DofA DmofA Dlook DofA' DmofA' + <- ({y} + cut-ewfkinde-m _ ([x] [d] DofB x d y) ([x] [d] DmofB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofB' x y) + ([x] DmofB' x y)). + +%%%% + +-app : cut-eqtpe-m (mpair Mtm Mtp) + ([x] [d] + eqtpe/app + (Deqtm x d : eqtme (G x) (M x) (N x) (C x)) + (Deqtp x d + : eqtpe (G x) (A x) (B x) (ekpi (C x) ([y] K x y)))) + ([x] [d] + meqtpe/app + (Dmeqtm x d : meqtme (Deqtm x d) Mtm) + (Dmeqtp x d : meqtpe (Deqtp x d) Mtp)) + ([x] Dlook x : elookup (G x) x D) +%% + ([x] eqtpe/app (Deqtme x) (Deqtpe x)) + ([x] meqtpe/app (Dmeqtme x) (Dmeqtpe x)) +%% + <- cut-eqtme-m Mtm Deqtm Dmeqtm Dlook + ([x] Deqtme x : eqtme (G x) (M x) (N x) (C x)) + ([x] Dmeqtme x : meqtme (Deqtme x) Mtm) + <- cut-eqtpe-m Mtp Deqtp Dmeqtp Dlook + ([x] Deqtpe x + : eqtpe (G x) (A x) (B x) (ekpi (C x) ([y] K x y))) + ([x] Dmeqtpe x : meqtpe (Deqtpe x) Mtp). + +-pi : cut-eqtpe-m (mpair Bm Am) + ([x] [d] + eqtpe/pi + ([y] DeqB x d y : eqtpe _ (B x y) (B' x y) ektype) + (DeqA x d : eqtpe _ (A x) (A' x) ektype)) + ([x] [d] + meqtpe/pi + ([y] DmeqB x d y : meqtpe (DeqB x d y) Bm) + (DmeqA x d : meqtpe (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/pi ([y] DeqeB' x y) (DeqeA x)) + ([x] meqtpe/pi ([y] DmeqeB' x y) (DmeqeA x)) +%% + <- cut-eqtpe-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({y} + cut-eqtpe-m Bm ([x] [d] DeqB x d y) ([x] [d] DmeqB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqtpe (econs (G x) y (A x)) (B x y) (B' x y) ektype) + ([x] DmeqeB' x y + : meqtpe (DeqeB' x y) Bm)). + +-lam : cut-eqtpe-m (mpair Bm Am) + ([x] [d] + eqtpe/lam + ([y] DeqB x d y : eqtpe _ (B x y) (B' x y) (K x y)) + (DeqA x d : eqtpe _ (A x) (A' x) ektype)) + ([x] [d] + meqtpe/lam + ([y] DmeqB x d y : meqtpe (DeqB x d y) Bm) + (DmeqA x d : meqtpe (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/lam ([y] DeqeB' x y) (DeqeA x)) + ([x] meqtpe/lam ([y] DmeqeB' x y) (DmeqeA x)) +%% + <- cut-eqtpe-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({y} + cut-eqtpe-m Bm ([x] [d] DeqB x d y) ([x] [d] DmeqB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqtpe (econs (G x) y (A x)) (B x y) (B' x y) (K x y)) + ([x] DmeqeB' x y + : meqtpe (DeqeB' x y) Bm)). + +-ext : cut-eqtpe-m (mpair (mpair M1 M2) M3) + ([x] [d] + eqtpe/ext + ([y] Deqtp x d y + : eqtpe _ (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + (DofB' x d : ekofe _ (B' x) (ekpi (A x) ([y] K'' x y))) + (DofB x d : ekofe _ (B x) (ekpi (A x) ([y] K' x y)))) + ([x] [d] + meqtpe/ext + ([y] Dmeqtp x d y + : meqtpe (Deqtp x d y) M3) + (DmofB' x d : mekofe (DofB' x d) M2) + (DmofB x d : mekofe (DofB x d) M1)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/ext ([y] Deqtpe' x y) (DofeB' x) (DofeB x)) + ([x] meqtpe/ext ([y] Dmeqtpe' x y) (DmofeB' x) (DmofeB x)) +%% + <- cut-ekofe-m M1 DofB DmofB Dlook + ([x] DofeB x : ekofe (G x) (B x) (ekpi (A x) ([y] K' x y))) + ([x] DmofeB x : mekofe (DofeB x) M1) + <- cut-ekofe-m M2 DofB' DmofB' Dlook + ([x] DofeB' x : ekofe (G x) (B' x) (ekpi (A x) ([y] K'' x y))) + ([x] DmofeB' x : mekofe (DofeB' x) M2) + <- ({y} + cut-eqtpe-m M3 ([x] [d] Deqtp x d y) + ([x] [d] Dmeqtp x d y) ([x] elookup/miss (Dlook x)) + ([x] Deqtpe' x y + : eqtpe (econs (G x) y (A x)) + (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + ([x] Dmeqtpe' x y + : meqtpe (Deqtpe' x y) M3)). + +-extw : cut-eqtpe-m (mpair M1 M2) + ([x] [d] + eqtpe/extw + ([y] Deqtp x d y + : eqtpe _ (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + (DeqB x d + : eqtpe _ (B x) (B' x) (ekpi (A x) ([y] K' x y)))) + ([x] [d] + meqtpe/extw + ([y] Dmeqtp x d y : meqtpe (Deqtp x d y) M2) + (DmeqB x d : meqtpe (DeqB x d) M1)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/extw ([y] Deqtpe' x y) (DeqtpeB x)) + ([x] meqtpe/extw ([y] Dmeqtpe' x y) (DmeqtpeB x)) +%% + <- cut-eqtpe-m M1 DeqB DmeqB Dlook + ([x] DeqtpeB x : eqtpe (G x) (B x) (B' x) (ekpi (A x) ([y] K' x y))) + ([x] DmeqtpeB x : meqtpe (DeqtpeB x) M1) + <- ({y} + cut-eqtpe-m M2 ([x] [d] Deqtp x d y) + ([x] [d] Dmeqtp x d y) ([x] elookup/miss (Dlook x)) + ([x] Deqtpe' x y + : eqtpe (econs (G x) y (A x)) + (eaapp (B x) y) (eaapp (B' x) y) (K x y)) + ([x] Dmeqtpe' x y + : meqtpe (Deqtpe' x y) M2)). + +-beta : cut-eqtpe-m (mpair Nm Bm) + ([x] [d] + eqtpe/beta + (DofN x d : eofe (G x) (N x) (A x)) + ([y] DofB x d y + : ekofe (econs (G x) y (A x)) (B x y) (K x y))) + ([x] [d] + meqtpe/beta + (DmofN x d : meofe (DofN x d) Nm) + ([y] DmofB x d y : mekofe (DofB x d y) Bm)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtpe/beta (DofeN x) ([y] DofeB' x y)) + ([x] meqtpe/beta (DmofeN x) ([y] DmofeB' x y)) +%% + <- cut-eofe-m Nm DofN DmofN Dlook + ([x] DofeN x : eofe (G x) (N x) (A x)) + ([x] DmofeN x : meofe (DofeN x) Nm) + <- ({y} + cut-ekofe-m Bm ([x] [d] DofB x d y) ([x] [d] DmofB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofeB' x y + : ekofe (econs (G x) y (A x)) (B x y) (K x y)) + ([x] DmofeB' x y + : mekofe (DofeB' x y) Bm)). + +-sym : cut-eqtpe-m (msing M) + ([x] [d] + eqtpe/sym (Deqtp x d : eqtpe (G x) (B x) (B' x) (K x))) + ([x] [d] + meqtpe/sym (Dmeqtp x d : meqtpe (Deqtp x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtpe/sym (Deqtpe x)) + ([x] meqtpe/sym (Dmeqtpe x)) +%% + <- cut-eqtpe-m M Deqtp Dmeqtp Dlook Deqtpe Dmeqtpe. + +-trans : cut-eqtpe-m (mpair M1 M2) + ([x] [d] + eqtpe/trans + (Deq2 x d : eqtpe (G x) (B' x) (B'' x) (K x)) + (Deq1 x d : eqtpe (G x) (B x) (B' x) (K x))) + ([x] [d] + meqtpe/trans + (Dmeq2 x d : meqtpe (Deq2 x d) M2) + (Dmeq1 x d : meqtpe (Deq1 x d) M1)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtpe/trans (Deqe2 x) (Deqe1 x)) + ([x] meqtpe/trans (Dmeqe2 x) (Dmeqe1 x)) +%% + <- cut-eqtpe-m M1 Deq1 Dmeq1 Dlook Deqe1 Dmeqe1 + <- cut-eqtpe-m M2 Deq2 Dmeq2 Dlook Deqe2 Dmeqe2. + +-refl : cut-eqtpe-m (msing M) + ([x] [d] + eqtpe/refl (Dkof x d : ekofe (G x) (B x) (K x))) + ([x] [d] + meqtpe/refl (Dmkof x d : mekofe (Dkof x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtpe/refl (Dkofe x)) + ([x] meqtpe/refl (Dmkofe x)) +%% + <- cut-ekofe-m M Dkof Dmkof Dlook Dkofe Dmkofe. + +-kcon : cut-eqtpe-m (mpair Am Km) + ([x] [d] eqtpe/kcon + (Deqk x d : eqkinde _ (K x) (K' x)) + (Deqtp x d : eqtpe _ (B x) (B' x) (K x))) + ([x] [d] meqtpe/kcon + (Dmeqk x d : meqkinde (Deqk x d) Km) + (Dmeqtp x d : meqtpe (Deqtp x d) Am)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtpe/kcon (Deqke x) (Deqtpe x)) + ([x] meqtpe/kcon (Dmeqke x) (Dmeqtpe x)) +%% + <- cut-eqtpe-m Am Deqtp Dmeqtp Dlook Deqtpe Dmeqtpe + <- cut-eqkinde-m Km Deqk Dmeqk Dlook Deqke Dmeqke. + +%%%% + +-app : cut-eqtme-m (mpair Mtm Mtp) + ([x] [d] + eqtme/app + (Deqtm x d : eqtme (G x) (M x) (N x) (C x)) + (Deqtp x d + : eqtme (G x) (A x) (B x) (epi (C x) ([y] K x y)))) + ([x] [d] + meqtme/app + (Dmeqtm x d : meqtme (Deqtm x d) Mtm) + (Dmeqtp x d : meqtme (Deqtp x d) Mtp)) + ([x] Dlook x : elookup (G x) x D) +%% + ([x] eqtme/app (Deqtme x) (Deqtpe x)) + ([x] meqtme/app (Dmeqtme x) (Dmeqtpe x)) +%% + <- cut-eqtme-m Mtm Deqtm Dmeqtm Dlook + ([x] Deqtme x : eqtme (G x) (M x) (N x) (C x)) + ([x] Dmeqtme x : meqtme (Deqtme x) Mtm) + <- cut-eqtme-m Mtp Deqtp Dmeqtp Dlook + ([x] Deqtpe x + : eqtme (G x) (A x) (B x) (epi (C x) ([y] K x y))) + ([x] Dmeqtpe x : meqtme (Deqtpe x) Mtp). + +-lam : cut-eqtme-m (mpair Bm Am) + ([x] [d] + eqtme/lam + ([y] DeqB x d y : eqtme _ (B x y) (B' x y) (K x y)) + (DeqA x d : eqtpe _ (A x) (A' x) ektype)) + ([x] [d] + meqtme/lam + ([y] DmeqB x d y : meqtme (DeqB x d y) Bm) + (DmeqA x d : meqtpe (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/lam ([y] DeqeB' x y) (DeqeA x)) + ([x] meqtme/lam ([y] DmeqeB' x y) (DmeqeA x)) +%% + <- cut-eqtpe-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({y} + cut-eqtme-m Bm ([x] [d] DeqB x d y) ([x] [d] DmeqB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqtme (econs (G x) y (A x)) (B x y) (B' x y) (K x y)) + ([x] DmeqeB' x y + : meqtme (DeqeB' x y) Bm)). + +-ext : cut-eqtme-m (mpair (mpair M1 M2) M3) + ([x] [d] + eqtme/ext + ([y] Deqtp x d y + : eqtme _ (eapp (B x) y) (eapp (B' x) y) (K x y)) + (DofB' x d : eofe _ (B' x) (epi (A x) ([y] K'' x y))) + (DofB x d : eofe _ (B x) (epi (A x) ([y] K' x y)))) + ([x] [d] + meqtme/ext + ([y] Dmeqtp x d y + : meqtme (Deqtp x d y) M3) + (DmofB' x d : meofe (DofB' x d) M2) + (DmofB x d : meofe (DofB x d) M1)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/ext ([y] Deqtpe' x y) (DofeB' x) (DofeB x)) + ([x] meqtme/ext ([y] Dmeqtpe' x y) (DmofeB' x) (DmofeB x)) +%% + <- cut-eofe-m M1 DofB DmofB Dlook + ([x] DofeB x : eofe (G x) (B x) (epi (A x) ([y] K' x y))) + ([x] DmofeB x : meofe (DofeB x) M1) + <- cut-eofe-m M2 DofB' DmofB' Dlook + ([x] DofeB' x : eofe (G x) (B' x) (epi (A x) ([y] K'' x y))) + ([x] DmofeB' x : meofe (DofeB' x) M2) + <- ({y} + cut-eqtme-m M3 ([x] [d] Deqtp x d y) + ([x] [d] Dmeqtp x d y) ([x] elookup/miss (Dlook x)) + ([x] Deqtpe' x y + : eqtme (econs (G x) y (A x)) + (eapp (B x) y) (eapp (B' x) y) (K x y)) + ([x] Dmeqtpe' x y + : meqtme (Deqtpe' x y) M3)). + +-extw : cut-eqtme-m (mpair M1 M2) + ([x] [d] + eqtme/extw + ([y] Deqtm x d y + : eqtme _ (eapp (B x) y) (eapp (B' x) y) (K x y)) + (DeqB x d + : eqtme _ (B x) (B' x) (epi (A x) ([y] K' x y)))) + ([x] [d] + meqtme/extw + ([y] Dmeqtm x d y : meqtme (Deqtm x d y) M2) + (DmeqB x d : meqtme (DeqB x d) M1)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/extw ([y] Deqtme' x y) (DeqtmeB x)) + ([x] meqtme/extw ([y] Dmeqtme' x y) (DmeqtmeB x)) +%% + <- cut-eqtme-m M1 DeqB DmeqB Dlook + ([x] DeqtmeB x : eqtme (G x) (B x) (B' x) (epi (A x) ([y] K' x y))) + ([x] DmeqtmeB x : meqtme (DeqtmeB x) M1) + <- ({y} + cut-eqtme-m M2 ([x] [d] Deqtm x d y) + ([x] [d] Dmeqtm x d y) ([x] elookup/miss (Dlook x)) + ([x] Deqtme' x y + : eqtme (econs (G x) y (A x)) + (eapp (B x) y) (eapp (B' x) y) (K x y)) + ([x] Dmeqtme' x y + : meqtme (Deqtme' x y) M2)). + +-beta : cut-eqtme-m _ + ([x] [d] + eqtme/beta + (DofN x d : eofe (G x) (N x) (A x)) + ([y] DofB x d y + : eofe (econs (G x) y (A x)) (B x y) (K x y))) + ([x] [d] + meqtme/beta + (DmofN x d : meofe (DofN x d) _) + ([y] DmofB x d y : meofe (DofB x d y) _)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqtme/beta (DofeN x) ([y] DofeB' x y)) + ([x] meqtme/beta (DmofeN x) ([y] DmofeB' x y)) +%% + <- cut-eofe-m _ DofN DmofN Dlook + ([x] DofeN x : eofe (G x) (N x) (A x)) + ([x] DmofeN x : meofe (DofeN x) Nm) + <- ({y} + cut-eofe-m _ ([x] [d] DofB x d y) ([x] [d] DmofB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofeB' x y + : eofe (econs (G x) y (A x)) (B x y) (K x y)) + ([x] DmofeB' x y + : meofe (DofeB' x y) Bm)). + +-sym : cut-eqtme-m (msing M) + ([x] [d] + eqtme/sym (Deqtp x d : eqtme (G x) (B x) (B' x) (K x))) + ([x] [d] + meqtme/sym (Dmeqtp x d : meqtme (Deqtp x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtme/sym (Deqtpe x)) + ([x] meqtme/sym (Dmeqtpe x)) +%% + <- cut-eqtme-m M Deqtp Dmeqtp Dlook Deqtpe Dmeqtpe. + +-trans : cut-eqtme-m (mpair M1 M2) + ([x] [d] + eqtme/trans + (Deq2 x d : eqtme (G x) (B' x) (B'' x) (K x)) + (Deq1 x d : eqtme (G x) (B x) (B' x) (K x))) + ([x] [d] + meqtme/trans + (Dmeq2 x d : meqtme (Deq2 x d) M2) + (Dmeq1 x d : meqtme (Deq1 x d) M1)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtme/trans (Deqe2 x) (Deqe1 x)) + ([x] meqtme/trans (Dmeqe2 x) (Dmeqe1 x)) +%% + <- cut-eqtme-m M1 Deq1 Dmeq1 Dlook Deqe1 Dmeqe1 + <- cut-eqtme-m M2 Deq2 Dmeq2 Dlook Deqe2 Dmeqe2. + +-refl : cut-eqtme-m (msing M) + ([x] [d] + eqtme/refl (Dof x d : eofe (G x) (B x) (K x))) + ([x] [d] + meqtme/refl (Dmof x d : meofe (Dof x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtme/refl (Dofe x)) + ([x] meqtme/refl (Dmofe x)) +%% + <- cut-eofe-m M Dof Dmof Dlook Dofe Dmofe. + +-tcon : cut-eqtme-m (mpair Am Km) + ([x] [d] eqtme/tcon + (Deqk x d : eqtpe _ (K x) (K' x) _) + (Deqtm x d : eqtme _ (B x) (B' x) (K x))) + ([x] [d] meqtme/tcon + (Dmeqk x d : meqtpe (Deqk x d) Km) + (Dmeqtm x d : meqtme (Deqtm x d) Am)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqtme/tcon (Deqke x) (Deqtme x)) + ([x] meqtme/tcon (Dmeqke x) (Dmeqtme x)) +%% + <- cut-eqtme-m Am Deqtm Dmeqtm Dlook Deqtme Dmeqtme + <- cut-eqtpe-m Km Deqk Dmeqk Dlook Deqke Dmeqke. + +%%%% + +-tp : cut-eqkinde-m _ ([_][_] eqkinde/tp) ([_][_] meqkinde/tp) _ + ([_] eqkinde/tp) ([_] meqkinde/tp). + +-pi : cut-eqkinde-m (mpair Bm Am) + ([x] [d] + eqkinde/pi + ([y] DeqB x d y : eqkinde _ (B x y) (B' x y)) + (DeqA x d : eqtpe _ (A x) (A' x) ektype)) + ([x] [d] + meqkinde/pi + ([y] DmeqB x d y : meqkinde (DeqB x d y) Bm) + (DmeqA x d : meqtpe (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] eqkinde/pi ([y] DeqeB' x y) (DeqeA x)) + ([x] meqkinde/pi ([y] DmeqeB' x y) (DmeqeA x)) +%% + <- cut-eqtpe-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({y} + cut-eqkinde-m Bm ([x] [d] DeqB x d y) ([x] [d] DmeqB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqkinde (econs (G x) y (A x)) (B x y) (B' x y)) + ([x] DmeqeB' x y + : meqkinde (DeqeB' x y) Bm)). + +-sym : cut-eqkinde-m (msing M) + ([x] [d] + eqkinde/sym (Deqkind x d : eqkinde (G x) (B x) (B' x))) + ([x] [d] + meqkinde/sym (Dmeqkind x d : meqkinde (Deqkind x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqkinde/sym (Deqkinde x)) + ([x] meqkinde/sym (Dmeqkinde x)) +%% + <- cut-eqkinde-m M Deqkind Dmeqkind Dlook Deqkinde Dmeqkinde. + +-trans : cut-eqkinde-m _ + ([x] [d] + eqkinde/trans + (Deq2 x d : eqkinde (G x) (B' x) (B'' x)) + (Deq1 x d : eqkinde (G x) (B x) (B' x))) + ([x] [d] + meqkinde/trn + (Dmeq2 x d : meqkinde (Deq2 x d) M2) + (Dmeq1 x d : meqkinde (Deq1 x d) M1)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqkinde/trans (Deqe2 x) (Deqe1 x)) + ([x] meqkinde/trn (Dmeqe2 x) (Dmeqe1 x)) +%% + <- cut-eqkinde-m M1 Deq1 Dmeq1 Dlook Deqe1 Dmeqe1 + <- cut-eqkinde-m M2 Deq2 Dmeq2 Dlook Deqe2 Dmeqe2. + +-refl : cut-eqkinde-m (msing M) + ([x] [d] + eqkinde/refl (Dwfkind x d : ewfkinde (G x) (K x))) + ([x] [d] + meqkinde/ref (Dmwfkind x d : mewfkinde (Dwfkind x d) M)) + ([x] Dlook x : elookup (G x) x A) +%% + ([x] eqkinde/refl (Dwfkinde x)) + ([x] meqkinde/ref (Dmwfkinde x)) +%% + <- cut-ewfkinde-m M Dwfkind Dmwfkind Dlook Dwfkinde Dmwfkinde. + +%worlds (ecsig | easig | evar | eovar | ebind) + (cut-eof-m _ _ _ _ _ _) + (cut-ekof-m _ _ _ _ _ _) + (cut-ewfkind-m _ _ _ _ _ _) + (cut-eqtp-m _ _ _ _ _ _) + (cut-eqtm-m _ _ _ _ _ _) + (cut-eqkind-m _ _ _ _ _ _) + (cut-eofe-m _ _ _ _ _ _) + (cut-ekofe-m _ _ _ _ _ _ ) + (cut-ewfkinde-m _ _ _ _ _ _) + (cut-eqtme-m _ _ _ _ _ _) + (cut-eqtpe-m _ _ _ _ _ _) + (cut-eqkinde-m _ _ _ _ _ _). +%total {(M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12)} + (cut-eof-m M1 _ _ _ _ _) + (cut-ekof-m M2 _ _ _ _ _) + (cut-ewfkind-m M3 _ _ _ _ _) + (cut-eqtp-m M4 _ _ _ _ _) + (cut-eqtm-m M5 _ _ _ _ _) + (cut-eqkind-m M6 _ _ _ _ _) + (cut-eofe-m M7 _ _ _ _ _) + (cut-ekofe-m M8 _ _ _ _ _) + (cut-ewfkinde-m M9 _ _ _ _ _) + (cut-eqtpe-m M10 _ _ _ _ _) + (cut-eqtme-m M11 _ _ _ _ _) + (cut-eqkinde-m M12 _ _ _ _ _). + +%% without a metric + +cut-eof : ({x} evof x A -> eof (M x) (B x)) + -> ({x} elookup (G x) x A) +%% + -> ({x} eofe (G x) (M x) (B x)) -> type. +%mode cut-eof +X1 +X2 -X3. + +- : cut-eof ([x] [d] Deof x d : eof (M x) (B x)) ([x] Dlook x) + ([x] Deofe x) + <- ({x} {d} + can-meof (Deof x d) + (Dmeof x d : meof (Deof x d) Mm)) + <- cut-eof-m Mm Deof Dmeof Dlook + ([x] Deofe x : eofe (G x) (M x) (B x)) + _. + +%worlds (ecsig | easig | evar | eovar | ebind) (cut-eof _ _ _). +%total {} (cut-eof _ _ _). + +cut-ekof : ({x} evof x A -> ekof (B x) (K x)) + -> ({x} elookup (G x) x A) +%% + -> ({x} ekofe (G x) (B x) (K x)) -> type. +%mode cut-ekof +X1 +X2 -X3. + +- : cut-ekof ([x] [d] Dkof x d : ekof (A x) (K x)) ([x] Dlook x) + ([x] Dkofe x) + <- ({x} {d} + can-mekof (Dkof x d) + (Dmkof x d : mekof (Dkof x d) Mm)) + <- cut-ekof-m Mm Dkof Dmkof Dlook + ([x] Dkofe x : ekofe (G x) (A x) (K x)) + _. + +%worlds (ecsig | easig | evar | eovar | ebind) (cut-ekof _ _ _). +%total {} (cut-ekof _ _ _). + +cut-ewfkind : ({x} evof x A -> ewfkind (K x)) + -> ({x} elookup (G x) x A) +%% + -> ({x} ewfkinde (G x) (K x)) -> type. +%mode cut-ewfkind +X1 +X2 -X3. + +- : cut-ewfkind ([x] [d] Dwfkind x d : ewfkind (K x)) ([x] Dlook x) + ([x] Dwfkinde x) + <- ({x} {d} + can-mewfkind (Dwfkind x d) + (Dmwfkind x d : mewfkind (Dwfkind x d) Mm)) + <- cut-ewfkind-m Mm Dwfkind Dmwfkind Dlook + ([x] Dwfkinde x : ewfkinde (G x) (K x)) + _. + +%worlds (ecsig | easig | evar | eovar | ebind) (cut-ewfkind _ _ _). +%total {} (cut-ewfkind _ _ _). + + +cut-eqtm : ({x} evof x A -> eqtm (B x) (C x) (K x)) + -> ({x} elookup (G x) x A) +%% + -> ({x} eqtme (G x) (B x) (C x) (K x)) -> type. +%mode cut-eqtm +X1 +X2 -X3. + +- : cut-eqtm ([x] [d] Deqtm x d : eqtm (A x) (A' x) (K x)) ([x] Dlook x) + ([x] Deqtme x) + <- ({x} {d} + can-meqtm (Deqtm x d) + (Dmeqtm x d : meqtm (Deqtm x d) Mm)) + <- cut-eqtm-m Mm Deqtm Dmeqtm Dlook + ([x] Deqtme x : eqtme (G x) (A x) (A' x) (K x)) + _. + +%worlds (ecsig | easig | evar | eovar | ebind) (cut-eqtm _ _ _). +%total {} (cut-eqtm _ _ _). + + +cut-eqtp : ({x} evof x A -> eqtp (B x) (C x) (K x)) + -> ({x} elookup (G x) x A) +%% + -> ({x} eqtpe (G x) (B x) (C x) (K x)) -> type. +%mode cut-eqtp +X1 +X2 -X3. + +- : cut-eqtp ([x] [d] Deqtp x d : eqtp (A x) (A' x) (K x)) ([x] Dlook x) + ([x] Deqtpe x) + <- ({x} {d} + can-meqtp (Deqtp x d) + (Dmeqtp x d : meqtp (Deqtp x d) Mm)) + <- cut-eqtp-m Mm Deqtp Dmeqtp Dlook + ([x] Deqtpe x : eqtpe (G x) (A x) (A' x) (K x)) + _. + +%worlds (ecsig | easig | evar | eovar | ebind) (cut-eqtp _ _ _). +%total {} (cut-eqtp _ _ _). + +cut-eqkind : ({x} evof x A -> eqkind (B x) (C x)) + -> ({x} elookup (G x) x A) +%% + -> ({x} eqkinde (G x) (B x) (C x)) -> type. +%mode cut-eqkind +X1 +X2 -X3. + +- : cut-eqkind ([x] [d] Deqkind x d : eqkind (A x) (A' x)) ([x] Dlook x) + ([x] Deqkinde x) + <- ({x} {d} + can-meqkind (Deqkind x d) + (Dmeqkind x d : meqkind (Deqkind x d) Mm)) + <- cut-eqkind-m Mm Deqkind Dmeqkind Dlook + ([x] Deqkinde x : eqkinde (G x) (A x) (A' x)) + _. + +%worlds (ecsig | easig | evar | eovar | ebind) (cut-eqkind _ _ _). +%total {} (cut-eqkind _ _ _). + + +eappend-bounded-contra : eappend (econs G1 X A) G2 G -> ebounded G X + -> false -> type. +%mode eappend-bounded-contra +X1 +X2 -X3. + +- : eappend-bounded-contra eappend/nil (ebounded/cons _ Dprecedes) Dfalse + <- eprecedes-antisymm Dprecedes Dfalse. +- : eappend-bounded-contra + (eappend/cons Dapp) (ebounded/cons Debounded Dprecedes) + Dfalse + <- ebounded-increase-bound Debounded Dprecedes Debounded' + <- eappend-bounded-contra Dapp Debounded' Dfalse. + +%worlds (ecsig | easig | ebind | eovar | evar) (eappend-bounded-contra _ _ _). +%total D (eappend-bounded-contra D _ _). + + +strengthen-ebounded : ({x} eisvar x I -> ebounded G Y) -> ebounded G Y -> type. +%mode strengthen-ebounded +X1 -X2. + +- : strengthen-ebounded ([x] [d] ebounded/nil D) (ebounded/nil D). + +- : strengthen-ebounded + ([x] [d] ebounded/cons (Dbound x d) Dprec) + (ebounded/cons Dbound' Dprec) + <- strengthen-ebounded Dbound Dbound'. + +%worlds (ecsig | easig | evar | ebind | eovar) (strengthen-ebounded _ _). +%total D (strengthen-ebounded D _). + + +ecsub-ebounded : ({x} eisvar x I -> ebounded (G x) Y) -> ecsub ([x] G x) M G' + -> ebounded G' Y -> type. +%mode ecsub-ebounded +X1 +X2 -X3. + +- : ecsub-ebounded ([x] [d] ebounded/cons (Dbound x d) (Dprec x d)) ecsub/base + Dbound'' + <- ({x} {d} + ebounded-increase-bound (Dbound x d) (Dprec x d) (Dbound' x d)) + <- strengthen-ebounded Dbound' Dbound''. + +- : ecsub-ebounded + ([x] [d] ebounded/cons (Dbound x d) Dprec) + (ecsub/cons Decsub) + (ebounded/cons Dbound' Dprec) + <- ecsub-ebounded Dbound Decsub Dbound'. + +- : ecsub-ebounded + ([x] [d] Dbound x d : ebounded enil Y) + ecsub/nil + Dbound' + <- strengthen-ebounded Dbound Dbound'. + +%worlds (ecsig | easig | ebind | evar | eovar) (ecsub-ebounded _ _ _). +%total D (ecsub-ebounded D _ _). + + +ecsub-ordered : ({x} eisvar x I -> eordered (G x)) -> ecsub ([x] G x) M G' + -> eordered G' -> type. +%mode ecsub-ordered +X1 +X2 -X3. + +- : ecsub-ordered ([x] [d] eordered/cons (Dbound x d)) ecsub/base Dord + <- ebounded-is-eordered-strengthen Dbound Dord. + +- : ecsub-ordered ([x] [d] eordered/cons (Dbound x d)) (ecsub/cons Decsub) + (eordered/cons Dbound') + <- ecsub-ebounded Dbound Decsub Dbound'. + +- : ecsub-ordered ([x] [d] eordered/nil) ecsub/nil eordered/nil. + +%worlds (ecsig | easig | ebind | evar | eovar) (ecsub-ordered _ _ _). +%total {} (ecsub-ordered _ _ _). + +ecsub-lookup : ecsub ([x] G x) N Gx -> ({x} elookup (G x) Y (B x)) + -> elookup Gx Y (B N) -> type. +%mode ecsub-lookup +X1 +X2 -X3. + +- : ecsub-lookup + (ecsub/cons (Dcsub : ecsub ([x] G x) N Gx)) + ([_] elookup/hit) + elookup/hit. + +- : ecsub-lookup + (ecsub/cons (Dcsub : ecsub ([x] G x) N Gx)) + ([x] elookup/miss (Dlook x : elookup (G x) Y (B x))) + (elookup/miss Dlook') + <- ecsub-lookup Dcsub Dlook + (Dlook' : elookup Gx Y (B N)). + +- : ecsub-lookup + ecsub/base + ([x] elookup/miss (Dlook x : elookup G Y (B x))) + Dlook'' + <- strengthen-elookup Dlook + (Dlook' : elookup G Y B') + ([x] DeqB x : etp-eq (B x) B') + <- ({x} etp-eq-sym (DeqB x) (DeqB' x : etp-eq B' (B x))) + <- elookup-resp Dlook' ectx-eq/i etm-eq/i (DeqB' _) + Dlook''. + +%worlds (ecsig | easig | evar | ebind | eovar) (ecsub-lookup _ _ _). +%total D (ecsub-lookup _ D _). + +eappend-strengthen : ({x:etm} eappend (G1 x) (G2 x) G) + -> ({x} ectx-eq (G1 x) G1') + -> ({x} ectx-eq (G2 x) G2') -> type. +%mode eappend-strengthen +X1 -X2 -X3. + +- : eappend-strengthen ([x] eappend/nil) ([x] ectx-eq/i) ([x] ectx-eq/i). + +- : eappend-strengthen + ([x] eappend/cons (Dapp x : eappend (G1 x) (G2 x) G)) + Deq1 + DeqCons + <- eappend-strengthen Dapp Deq1 Deq2 + <- ({x} + econs-compat (Deq2 x) etm-eq/i etp-eq/i + (DeqCons x : ectx-eq (econs (G2 x) Y B) (econs G2' Y B))). + +%worlds (ecsig | easig | evar | ebind | eovar) (eappend-strengthen _ _ _). +%total D (eappend-strengthen D _ _). + +ecsub-closed : {G:ectx} {M:etm} ecsub ([_] G) M G -> type. +%mode ecsub-closed +G +M -D. + +-nil : ecsub-closed _ _ ecsub/nil. + +-cons : ecsub-closed (econs G _ _) M (ecsub/cons Dcsub) + <- ecsub-closed G M (Dcsub : ecsub ([_] G) M G). + +%worlds (ecsig | easig | evar | ebind | eovar) (ecsub-closed _ _ _). +%total G (ecsub-closed G _ _). + +ecsub-append : ({x} eappend (G1 x) (G2 x) (G x)) + -> ecsub G M Gx +%% + -> ecsub G1 M G1x + -> ecsub G2 M G2x + -> eappend G1x G2x Gx -> type. +%mode ecsub-append +X1 +X2 -X3 -X4 -X5. + +-nil : ecsub-append + ([x] eappend/nil : eappend (G x) enil (G x)) + (DsubG : ecsub G M Gx) + DsubG ecsub/nil eappend/nil. + +-base : ecsub-append + ([x] eappend/cons (Dapp x : eappend (G1 x) (G2 x) G)) + ecsub/base + DcsubG1 + DcsubG2 + (Dapp' ace) + <- eappend-strengthen Dapp + ([x] DeqG1 x : ectx-eq (G1 x) G1') + ([x] DeqG2 x : ectx-eq (G2 x) G2') + %% + <- ecsub-closed _ _ + (DcsubG1' : ecsub ([x] G1') _ G1') + <- ({x} ectx-eq-sym (DeqG1 x) (DeqG1' x : ectx-eq G1' (G1 x))) + <- ecsub-resp DcsubG1' DeqG1' etm-eq/i ectx-eq/i + (DcsubG1 : ecsub G1 _ G1') + %% + <- ecsub-closed _ M + (DcsubG2' : ecsub ([x] G2') M G2') + <- ({x} ectx-eq-sym (DeqG2 x) (DeqG2' x : ectx-eq G2' (G2 x))) + <- ({x} + econs-compat (DeqG2' x) etm-eq/i etp-eq/i + (DeqConsG2 x : ectx-eq (econs G2' x A) (econs (G2 x) x A))) + <- ecsub-resp ecsub/base (DeqConsG2) etm-eq/i ectx-eq/i + (DcsubG2 : ecsub ([x] econs (G2 x) x A) M G2') + %% + <- ({x} + eappend-resp (DeqG1 x) (DeqG2 x) ectx-eq/i (Dapp x) + (Dapp' x : eappend G1' G2' G)). + +-cons : ecsub-append + ([x] eappend/cons (Dapp x : eappend (G1 x) (G2 x) (G x))) + (ecsub/cons (Dsub : ecsub G M Gx)) + DsubG1 + (ecsub/cons DsubG2) + (eappend/cons Dapp') + <- ecsub-append Dapp Dsub + (DsubG1 : ecsub G1 M G1x) + (DsubG2 : ecsub G2 M G2x) + (Dapp' : eappend G1x G2x Gx). + +%worlds (ecsig | easig | evar | ebind | eovar) (ecsub-append _ _ _ _ _). +%total D (ecsub-append D _ _ _ _). + +can-eappend : {G1} {G2} eappend G1 G2 G -> type. +%mode can-eappend +X1 +X2 -X3. + +-nil : can-eappend G1 enil eappend/nil. + +-cons : can-eappend G1 (econs G2 X A) (eappend/cons D) + <- can-eappend G1 G2 (D : eappend G1 G2 G). + +%worlds (ecsig | easig | evar | ebind | eovar) (can-eappend _ _ _). +%total G (can-eappend _ G _). + + +weaken-eofe-csub : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) + -> ecsub G M Gx + -> eofe G1 N A +%% + -> eofe Gx N A -> type. +%mode weaken-eofe-csub +X1 +X2 +X3 +X4 -X5. + +-nil : weaken-eofe-csub _ ([_] eappend/nil) _ D D. + +-cons : weaken-eofe-csub + ([x] [d] eordered/cons (Dbound x d)) + ([x] eappend/cons (Dapp x)) + (ecsub/cons Dsub) + Dof +%% + Dof'' +%% + <- ({x} {d} + ebounded-is-ordered (Dbound x d) (Dord x d)) + <- weaken-eofe-csub Dord Dapp Dsub Dof Dof' + <- ecsub-ordered Dord Dsub Dord' + <- weaken-eofe Dof' _ _ Dof''. + +-bad : weaken-eofe-csub + ([x] [d] eordered/cons (Dbound x d)) + ([x] eappend/cons (Dapp x)) + ecsub/base + _ +%% + D +%% + <- ({x} {d} + eappend-bounded-contra (Dapp x) (Dbound x d) Dfalse) + <- false-implies-eofe Dfalse D. + +%worlds (ecsig | easig | ebind | evar | eovar) (weaken-eofe-csub _ _ _ _ _). +%total D (weaken-eofe-csub _ D _ _ _). + +%%% Substitution %%%% + +eofe-sub : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) +%% + -> ({x} eofe (G x) (M x) (B x)) + -> eofe G1 N A + -> ecsub ([x] G x) N Gx +%% + -> eofe Gx (M N) (B N) -> type. +%mode eofe-sub +X1 +X2 +X3 +X4 +X5 -X6. + +ekofe-sub : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) +%% + -> ({x} ekofe (G x) (M x) (B x)) + -> eofe G1 N A + -> ecsub ([x] G x) N Gx +%% + -> ekofe Gx (M N) (B N) -> type. +%mode ekofe-sub +X1 +X2 +X3 +X4 +X5 -X6. + +ewfkinde-sub : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) +%% + -> ({x} ewfkinde (G x) (K x)) + -> eofe G1 N A + -> ecsub ([x] G x) N Gx +%% + -> ewfkinde Gx (K N) -> type. +%mode ewfkinde-sub +X1 +X2 +X3 +X4 +X5 -X6. + +eqtme-sub : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) +%% + -> ({x} eqtme (G x) (M x) (M' x) (B x)) + -> eofe G1 N A + -> ecsub ([x] G x) N Gx +%% + -> eqtme Gx (M N) (M' N) (B N) -> type. +%mode eqtme-sub +X1 +X2 +X3 +X4 +X5 -X6. + +eqtpe-sub : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) +%% + -> ({x} eqtpe (G x) (M x) (M' x) (B x)) + -> eofe G1 N A + -> ecsub ([x] G x) N Gx +%% + -> eqtpe Gx (M N) (M' N) (B N) -> type. +%mode eqtpe-sub +X1 +X2 +X3 +X4 +X5 -X6. + +eqkinde-sub : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) +%% + -> ({x} eqkinde (G x) (K x) (K' x)) + -> eofe G1 N A + -> ecsub ([x] G x) N Gx +%% + -> eqkinde Gx (K N) (K' N) -> type. +%mode eqkinde-sub +X1 +X2 +X3 +X4 +X5 -X5. + +-vari : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/vari + (DofB x : ekofe (G x) B ektype) + (Dvof : evof Y B)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eofe/vari DofB' Dvof) +%% + <- ekofe-sub Dord Dappend DofB DofN Dcsub + (DofB' : ekofe Gx B ektype). + +-const : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/const + (DofB x : ekofe (G x) B ektype) + (Dcof : ecof C B)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eofe/const DofBx Dcof) +%% + <- ekofe-sub Dord Dappend DofB DofN Dcsub + (DofBx : ekofe Gx B ektype). + +-varsam : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/var + (DofA' x : ekofe (G x) (A' x) ektype) + (Dlook x : elookup (G x) x (A' x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + DofN' +%% + <- ({x} + eappend-lookup (Dappend x) + (Dlook' x : elookup (G x) x A)) + <- ({x} {d} + elookup-fun (Dord x d) (Dlook x) (Dlook' x) + (DeqA' x : etp-eq (A' x) A)) + <- weaken-eofe-csub Dord Dappend Dcsub DofN + (DofNGx : eofe Gx N A) + <- ({x} etp-eq-sym (DeqA' x) (DeqA x : etp-eq A (A' x))) + <- eofe-resp ectx-eq/i etm-eq/i (DeqA N) DofNGx + (DofN' : eofe Gx N (A' N)). + +-varoth : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/var + (DofB x : ekofe (G x) (B x) ektype) + (Dlook x : elookup (G x) Y (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eofe/var DofBx Dlook') +%% + <- ekofe-sub Dord Dappend DofB DofN Dcsub + (DofBx : ekofe Gx (B N) ektype) + <- ecsub-lookup Dcsub Dlook + (Dlook' : elookup Gx Y (B N)). + +-app : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] + eofe/app + (DofM x : eofe (G x) (M x) (B x)) + (DofO x : eofe (G x) (O x) (epi (B x) ([y] C x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eofe/app DofMx DofOx) +%% + <- eofe-sub Dord Dappend DofM DofN Dcsub + (DofMx : eofe Gx (M N) (B N)) + <- eofe-sub Dord Dappend DofO DofN Dcsub + (DofOx : eofe Gx (O N) (epi (B N) ([y] C N y))). + +% convince twelf app can't go in the context +-appbad : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/var + _ + (Dlook x : elookup (G x) (eapp _ _) _)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + Dofe +%% + <- ({x} {d} + elookup-isvar (Dord x d) (Dlook x) + (Disvar x : eisvar (eapp _ _) I)) + <- ({x} + eisvar-app-contra (Disvar x) Dfalse) + <- false-implies-eofe Dfalse Dofe. + +-lam : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/lam + (DofB x : ekofe (G x) (B x) ektype) + ([y] DofM x y + : eofe (econs (G x) y (B x)) (M x y) (C x y))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eofe/lam DofBx DofMx) +%% + <- ekofe-sub Dord Dappend DofB DofN Dcsub + (DofBx : ekofe Gx (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eofe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DofM x y) + DofN + (ecsub/cons Dcsub) + (DofMx y : eofe (econs Gx y (B N)) (M N y) (C N y))). + +% convince twelf lam can't go in the context +-lambad : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/var + _ + (Dlook x : elookup _ (elam _ _) _)) + _ + _ +%% + Dof +%% + <- ({x} {d} + elookup-isvar (Dord x d) (Dlook x) + (Disvar x : eisvar (elam _ _) I)) + <- ({x} + eisvar-lam-contra (Disvar x) Dfalse) + <- false-implies-eofe Dfalse Dof. + +-eqtp : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/eqtp + (Deqtp x : eqtpe (G x) (B x) (C x) ektype) + (DofM x : eofe (G x) (M x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eofe/eqtp Deqtpx DofMx) +%% + <- eofe-sub Dord Dappend DofM DofN Dcsub + (DofMx : eofe Gx (M N) (B N)) + <- eqtpe-sub Dord Dappend Deqtp DofN Dcsub + (Deqtpx : eqtpe Gx (B N) (C N) ektype). + +-ext : eofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eofe/ext + ([y] DofApp x y + : eofe (econs (G x) y (B x)) (eapp (M x) y) (C x y)) + (DofM x + : eofe (G x) (M x) (epi (B x) ([y] C' x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eofe/ext DofAppx DofMx) +%% + <- eofe-sub Dord Dappend DofM DofN Dcsub DofMx + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eofe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DofApp x y) + DofN + (ecsub/cons Dcsub) + (DofAppx y)). + +%%%% + +-const : ekofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] ekofe/const + (DofB x : ewfkinde (G x) B) + (Dcof : eckof C B)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (ekofe/const DofBx Dcof) +%% + <- ewfkinde-sub Dord Dappend DofB DofN Dcsub + (DofBx : ewfkinde Gx B). + +-pi : ekofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] ekofe/pi + (DofB x : ekofe (G x) (B x) ektype) + ([y] DofM x y + : ekofe (econs (G x) y (B x)) (M x y) ektype)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (ekofe/pi DofBx DofMx) +%% + <- ekofe-sub Dord Dappend DofB DofN Dcsub + (DofBx : ekofe Gx (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + ekofe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DofM x y) + DofN + (ecsub/cons Dcsub) + (DofMx y : ekofe (econs Gx y (B N)) (M N y) ektype)). + +-app : ekofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] + ekofe/app + (DofM x : eofe (G x) (M x) (B x)) + (DofO x : ekofe (G x) (O x) (ekpi (B x) ([y] C x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (ekofe/app DofMx DofOx) +%% + <- eofe-sub Dord Dappend DofM DofN Dcsub + (DofMx : eofe Gx (M N) (B N)) + <- ekofe-sub Dord Dappend DofO DofN Dcsub + (DofOx : ekofe Gx (O N) (ekpi (B N) ([y] C N y))). + +-lam : ekofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] ekofe/lam + (DofB x : ekofe (G x) (B x) ektype) + ([y] DofM x y + : ekofe (econs (G x) y (B x)) (M x y) (C x y))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (ekofe/lam DofBx DofMx) +%% + <- ekofe-sub Dord Dappend DofB DofN Dcsub + (DofBx : ekofe Gx (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + ekofe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DofM x y) + DofN + (ecsub/cons Dcsub) + (DofMx y : ekofe (econs Gx y (B N)) (M N y) (C N y))). + +-eqkind : ekofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] ekofe/eqkind + (Deqtp x : eqkinde (G x) (B x) (C x)) + (DofM x : ekofe (G x) (M x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (ekofe/eqkind Deqtpx DofMx) +%% + <- ekofe-sub Dord Dappend DofM DofN Dcsub + (DofMx : ekofe Gx (M N) (B N)) + <- eqkinde-sub Dord Dappend Deqtp DofN Dcsub + (Deqtpx : eqkinde Gx (B N) (C N)). + +-ext : ekofe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] ekofe/ext + ([y] DofApp x y + : ekofe (econs (G x) y (B x)) (eaapp (M x) y) (C x y)) + (DofM x + : ekofe (G x) (M x) (ekpi (B x) ([y] C' x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (ekofe/ext DofAppx DofMx) +%% + <- ekofe-sub Dord Dappend DofM DofN Dcsub DofMx + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + ekofe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DofApp x y) + DofN + (ecsub/cons Dcsub) + (DofAppx y)). + +%%%% + +-type : ewfkinde-sub _ _ ([x] ewfkinde/tp) _ _ ewfkinde/tp. + +-pi : ewfkinde-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] ewfkinde/pi + (DofB x : ekofe (G x) (B x) ektype) + ([y] DofM x y + : ewfkinde (econs (G x) y (B x)) (M x y))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (ewfkinde/pi DofBx DofMx) +%% + <- ekofe-sub Dord Dappend DofB DofN Dcsub + (DofBx : ekofe Gx (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + ewfkinde-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DofM x y) + DofN + (ecsub/cons Dcsub) + (DofMx y : ewfkinde (econs Gx y (B N)) (M N y))). + +%%%% + +-app : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/app + (DeqtmO x : eqtme (G x) (O x) (O' x) (B x)) + (DeqtmM x + : eqtme (G x) (M x) (M' x) (epi (B x) ([y] C x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/app DeqtmOx DeqtmMx) +%% + <- eqtme-sub Dord Dappend DeqtmO DofN Dcsub + DeqtmOx + <- eqtme-sub Dord Dappend DeqtmM DofN Dcsub + DeqtmMx. + +-lam : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/lam + ([y] DeqtmM x y + : eqtme (econs (G x) y (B x)) (M x y) (M' x y) (C x y)) + (DeqtpB x : eqtpe (G x) (B x) (B' x) ektype)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/lam DeqtmMx DeqtpBx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtme-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqtmM x y) + DofN (ecsub/cons Dcsub) + (DeqtmMx y + : eqtme (econs Gx y (B N)) (M N y) (M' N y) (C N y))) + <- eqtpe-sub Dord Dappend DeqtpB DofN Dcsub DeqtpBx. + +-ext : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/ext + ([y] DeqtmApp x y + : eqtme (econs (G x) y (B x)) + (eapp (M x) y) (eapp (M' x) y) (C* x y)) + (DofM' x : eofe (G x) (M' x) (epi (B x) ([y] C' x y))) + (DofM x : eofe (G x) (M x) (epi (B x) ([y] C x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/ext DeqtmAppx DofM'x DofMx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtme-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqtmApp x y) + DofN (ecsub/cons Dcsub) + (DeqtmAppx y + : eqtme (econs Gx y (B N)) + (eapp (M N) y) (eapp (M' N) y) (C* N y))) + <- eofe-sub Dord Dappend DofM' DofN Dcsub DofM'x + <- eofe-sub Dord Dappend DofM DofN Dcsub DofMx. + +-extw : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/extw + ([y] DeqtmApp x y + : eqtme (econs (G x) y (B x)) + (eapp (M x) y) (eapp (M' x) y) (C* x y)) + (DeqtmM x + : eqtme (G x) (M x) (M' x) (epi (B x) ([y] C x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/extw DeqtmAppx DeqtmMx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtme-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqtmApp x y) + DofN (ecsub/cons Dcsub) + (DeqtmAppx y + : eqtme (econs Gx y (B N)) + (eapp (M N) y) (eapp (M' N) y) (C* N y))) + <- eqtme-sub Dord Dappend DeqtmM DofN Dcsub DeqtmMx. + +-beta : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/beta + (DofO x : eofe (G x) (O x) (B x)) + ([y] DofM x y + : eofe (econs (G x) y (B x)) (M x y) (C x y))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/beta DofOx DofMx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eofe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DofM x y) + DofN (ecsub/cons Dcsub) + (DofMx y : eofe (econs Gx y (B N)) (M N y) (C N y))) + <- eofe-sub Dord Dappend DofO DofN Dcsub DofOx. + +-sym : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/sym + (Deqtm x : eqtme (G x) (M x) (M' x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/sym Deqtmx) +%% + <- eqtme-sub Dord Dappend Deqtm DofN Dcsub Deqtmx. + + +-trans : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/trans + (Deqtm2 x : eqtme (G x) (O x) (P x) (B x)) + (Deqtm1 x : eqtme (G x) (M x) (O x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/trans Deqtm2x Deqtm1x) +%% + <- eqtme-sub Dord Dappend Deqtm1 DofN Dcsub Deqtm1x + <- eqtme-sub Dord Dappend Deqtm2 DofN Dcsub Deqtm2x. + + + +-refl : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/refl (Dof x : eofe (G x) (M x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/refl Dofx) +%% + <- eofe-sub Dord Dappend Dof DofN Dcsub Dofx. + +-tcon : eqtme-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtme/tcon + (Deqtp x : eqtpe (G x) (B x) (C x) ektype) + (Deqtm x : eqtme (G x) (M x) (M' x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtme/tcon Deqtpx Deqtmx) +%% + <- eqtpe-sub Dord Dappend Deqtp DofN Dcsub Deqtpx + <- eqtme-sub Dord Dappend Deqtm DofN Dcsub Deqtmx. + +%%%% + +-app : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/app + (DeqtmO x : eqtme (G x) (O x) (O' x) (B x)) + (DeqtmM x + : eqtpe (G x) (M x) (M' x) (ekpi (B x) ([y] C x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/app DeqtmOx DeqtmMx) +%% + <- eqtme-sub Dord Dappend DeqtmO DofN Dcsub DeqtmOx + <- eqtpe-sub Dord Dappend DeqtmM DofN Dcsub DeqtmMx. + + +-pi : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/pi + ([y] DeqtmM x y + : eqtpe (econs (G x) y (B x)) (M x y) (M' x y) ektype) + (DeqtpB x : eqtpe (G x) (B x) (B' x) ektype)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/pi DeqtmMx DeqtpBx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtpe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqtmM x y) + DofN (ecsub/cons Dcsub) + (DeqtmMx y + : eqtpe (econs Gx y (B N)) (M N y) (M' N y) ektype)) + <- eqtpe-sub Dord Dappend DeqtpB DofN Dcsub DeqtpBx. + +-lam : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/lam + ([y] DeqtmM x y + : eqtpe (econs (G x) y (B x)) (M x y) (M' x y) (C x y)) + (DeqtpB x : eqtpe (G x) (B x) (B' x) ektype)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/lam DeqtmMx DeqtpBx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtpe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqtmM x y) + DofN (ecsub/cons Dcsub) + (DeqtmMx y + : eqtpe (econs Gx y (B N)) (M N y) (M' N y) (C N y))) + <- eqtpe-sub Dord Dappend DeqtpB DofN Dcsub DeqtpBx. + +-ext : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/ext + ([y] DeqtmApp x y + : eqtpe (econs (G x) y (B x)) + (eaapp (M x) y) (eaapp (M' x) y) (C* x y)) + (DofM' x : ekofe (G x) (M' x) (ekpi (B x) ([y] C' x y))) + (DofM x : ekofe (G x) (M x) (ekpi (B x) ([y] C x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/ext DeqtmAppx DofM'x DofMx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtpe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqtmApp x y) + DofN (ecsub/cons Dcsub) + (DeqtmAppx y + : eqtpe (econs Gx y (B N)) + (eaapp (M N) y) (eaapp (M' N) y) (C* N y))) + <- ekofe-sub Dord Dappend DofM' DofN Dcsub DofM'x + <- ekofe-sub Dord Dappend DofM DofN Dcsub DofMx. + +-extw : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/extw + ([y] DeqtmApp x y + : eqtpe (econs (G x) y (B x)) + (eaapp (M x) y) (eaapp (M' x) y) (C* x y)) + (DeqtmM x + : eqtpe (G x) (M x) (M' x) (ekpi (B x) ([y] C x y)))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/extw DeqtmAppx DeqtmMx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtpe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqtmApp x y) + DofN (ecsub/cons Dcsub) + (DeqtmAppx y + : eqtpe (econs Gx y (B N)) + (eaapp (M N) y) (eaapp (M' N) y) (C* N y))) + <- eqtpe-sub Dord Dappend DeqtmM DofN Dcsub DeqtmMx. + + +-beta : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/beta + (DofO x : eofe (G x) (O x) (B x)) + ([y] DofM x y + : ekofe (econs (G x) y (B x)) (M x y) (C x y))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/beta DofOx DofMx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + ekofe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DofM x y) + DofN (ecsub/cons Dcsub) + (DofMx y : ekofe (econs Gx y (B N)) (M N y) (C N y))) + <- eofe-sub Dord Dappend DofO DofN Dcsub DofOx. + +-sym : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/sym + (Deqtp x : eqtpe (G x) (M x) (M' x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/sym Deqtpx) +%% + <- eqtpe-sub Dord Dappend Deqtp DofN Dcsub Deqtpx. + +-trans : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/trans + (Deqtp2 x : eqtpe (G x) (O x) (P x) (B x)) + (Deqtp1 x : eqtpe (G x) (M x) (O x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/trans Deqtp2x Deqtp1x) +%% + <- eqtpe-sub Dord Dappend Deqtp1 DofN Dcsub Deqtp1x + <- eqtpe-sub Dord Dappend Deqtp2 DofN Dcsub Deqtp2x. + +-refl : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/refl (Dof x : ekofe (G x) (M x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/refl Dofx) +%% + <- ekofe-sub Dord Dappend Dof DofN Dcsub Dofx. + + +-kcon : eqtpe-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqtpe/kcon + (Deqtp x : eqkinde (G x) (B x) (C x)) + (Deqtm x : eqtpe (G x) (M x) (M' x) (B x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqtpe/kcon Deqtpx Deqtmx) +%% + <- eqkinde-sub Dord Dappend Deqtp DofN Dcsub Deqtpx + <- eqtpe-sub Dord Dappend Deqtm DofN Dcsub Deqtmx. + +%%%% + +-type : eqkinde-sub _ _ ([x] eqkinde/tp) _ _ eqkinde/tp. + +-pi : eqkinde-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) +%% + ([x] eqkinde/pi + ([y] DeqtmM x y + : eqkinde (econs (G x) y (B x)) (K x y) (K' x y)) + (DeqtpB x : eqtpe (G x) (B x) (B' x) ektype)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqkinde/pi DeqtmMx DeqtpBx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqkinde-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqtmM x y) + DofN (ecsub/cons Dcsub) + (DeqtmMx y : eqkinde (econs Gx y (B N)) (K N y) (K' N y))) + <- eqtpe-sub Dord Dappend DeqtpB DofN Dcsub DeqtpBx. + +-sym : eqkinde-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + ([x] eqkinde/sym (Deqtp x : eqkinde (G x) (K x) (K' x))) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) + (eqkinde/sym Deqtpx) + <- eqkinde-sub Dord Dappend Deqtp DofN Dcsub Deqtpx. + +-trans : eqkinde-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + ([x] eqkinde/trans (Deqtp2 x) (Deqtp1 x)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) +%% + (eqkinde/trans Deqtp2x Deqtp1x) +%% + <- eqkinde-sub Dord Dappend Deqtp1 DofN Dcsub Deqtp1x + <- eqkinde-sub Dord Dappend Deqtp2 DofN Dcsub Deqtp2x. + +-refl : eqkinde-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + ([x] eqkinde/refl (Dof x)) + (DofN : eofe G1 N A) + (Dcsub : ecsub ([x] G x) N Gx) + (eqkinde/refl Dofx) + <- ewfkinde-sub Dord Dappend Dof DofN Dcsub Dofx. + +%worlds (ecsig | easig | evar | eovar | ebind) + (eofe-sub _ _ _ _ _ _) + (ekofe-sub _ _ _ _ _ _) + (ewfkinde-sub _ _ _ _ _ _) + (eqtme-sub _ _ _ _ _ _) + (eqtpe-sub _ _ _ _ _ _) + (eqkinde-sub _ _ _ _ _ _). +%total (D1 D2 D3 D4 D5 D6) + (eofe-sub _ _ D1 _ _ _) + (ekofe-sub _ _ D2 _ _ _) + (ewfkinde-sub _ _ D3 _ _ _) + (eqtme-sub _ _ D4 _ _ _) + (eqtpe-sub _ _ D5 _ _ _) + (eqkinde-sub _ _ D6 _ _ _). + + +%%% Translation from implicit to explicit %%% + +eof1-to-eofe : ({x} evof x A -> eof (M x) (B x)) + -> ({x} eofe (econs enil x A) (M x) (B x)) -> type. +%mode eof1-to-eofe +X1 -X2. + +- : eof1-to-eofe + ([x] [d:evof x A] Dof x d : eof (M x) (B x)) + ([x] Dofe x) + <- cut-eof Dof ([_] elookup/hit) + ([x] Dofe x : eofe (econs enil x A) (M x) (B x)). + +%worlds (ecsig | easig | evar | eovar | ebind) (eof1-to-eofe _ _). +%total {} (eof1-to-eofe _ _). + +ekof1-to-ekofe : ({x} evof x A -> ekof (M x) (B x)) + -> ({x} ekofe (econs enil x A) (M x) (B x)) -> type. +%mode ekof1-to-ekofe +X1 -X2. + +- : ekof1-to-ekofe + ([x] [d:evof x A] Dkof x d : ekof (M x) (B x)) + ([x] Dkofe x) + <- cut-ekof Dkof ([_] elookup/hit) + ([x] Dkofe x : ekofe (econs enil x A) (M x) (B x)). + +%worlds (ecsig | easig | evar | eovar | ebind) (ekof1-to-ekofe _ _). +%total {} (ekof1-to-ekofe _ _). + +ewfkind1-to-ewfkinde : ({x} evof x A -> ewfkind (M x)) + -> ({x} ewfkinde (econs enil x A) (M x)) -> type. +%mode ewfkind1-to-ewfkinde +X1 -X2. + +- : ewfkind1-to-ewfkinde + ([x] [d:evof x A] Dwfkind x d : ewfkind (M x)) + ([x] Dwfkinde x) + <- cut-ewfkind Dwfkind ([_] elookup/hit) + ([x] Dwfkinde x : ewfkinde (econs enil x A) (M x)). + +%worlds (ecsig | easig | evar | eovar | ebind) (ewfkind1-to-ewfkinde _ _). +%total {} (ewfkind1-to-ewfkinde _ _). + + +eqtm1-to-eqtme : ({x} evof x A -> eqtm (M x) (M' x) (B x)) + -> ({x} eqtme (econs enil x A) (M x) (M' x) (B x)) -> type. +%mode eqtm1-to-eqtme +X1 -X2. + +- : eqtm1-to-eqtme + ([x] [d:evof x A] Deqtm x d : eqtm (M x) (M' x) (B x)) + ([x] Deqtme x) + <- cut-eqtm Deqtm ([_] elookup/hit) + ([x] Deqtme x : eqtme (econs enil x A) (M x) (M' x) (B x)). + +%worlds (ecsig | easig | evar | eovar | ebind) (eqtm1-to-eqtme _ _). +%total {} (eqtm1-to-eqtme _ _). + + +eqtp1-to-eqtpe : ({x} evof x A -> eqtp (M x) (M' x) (B x)) + -> ({x} eqtpe (econs enil x A) (M x) (M' x) (B x)) -> type. +%mode eqtp1-to-eqtpe +X1 -X2. + +- : eqtp1-to-eqtpe + ([x] [d:evof x A] Deqtp x d : eqtp (M x) (M' x) (B x)) + ([x] Deqtpe x) + <- cut-eqtp Deqtp ([_] elookup/hit) + ([x] Deqtpe x : eqtpe (econs enil x A) (M x) (M' x) (B x)). + +%worlds (ecsig | easig | evar | eovar | ebind) (eqtp1-to-eqtpe _ _). +%total {} (eqtp1-to-eqtpe _ _). + +eqkind1-to-eqkinde : ({x} evof x A -> eqkind (M x) (M' x)) + -> ({x} eqkinde (econs enil x A) (M x) (M' x)) -> type. +%mode eqkind1-to-eqkinde +X1 -X2. + +- : eqkind1-to-eqkinde + ([x] [d:evof x A] Deqkind x d : eqkind (M x) (M' x)) + ([x] Deqkinde x) + <- cut-eqkind Deqkind ([_] elookup/hit) + ([x] Deqkinde x : eqkinde (econs enil x A) (M x) (M' x)). + +%worlds (ecsig | easig | evar | eovar | ebind) (eqkind1-to-eqkinde _ _). +%total {} (eqkind1-to-eqkinde _ _). + + +eof-to-eofe : eof EN EA -> eofe enil EN EA -> type. +%mode eof-to-eofe +X1 -X2. + +%% XXX have to add w/o ekofe/closed +ekof-to-ekofe : ekof EA EK -> ekofe enil EA EK -> type. +%mode ekof-to-ekofe +X1 -X2. + +ewfkind-to-ewfkinde : ewfkind K -> ewfkinde enil K -> type. +%mode ewfkind-to-ewfkinde +X1 -X2. + +eqtm-to-eqtme : eqtm EM EN EA -> eqtme enil EM EN EA -> type. +%mode eqtm-to-eqtme +X1 -X2. + +eqtp-to-eqtpe : eqtp EA EB EK -> eqtpe enil EA EB EK -> type. +%mode eqtp-to-eqtpe +X1 -X2. + +eqkind-to-eqkinde : eqkind K J -> eqkinde enil K J -> type. +%mode eqkind-to-eqkinde +X1 -X2. + +-var : eof-to-eofe + (eof/var + (Dkof : ekof A ektype) + (Dvof : evof X A)) + (eofe/vari Dkofe Dvof) + <- ekof-to-ekofe Dkof Dkofe. + +-const : eof-to-eofe + (eof/const + (Dkof : ekof A ektype) + (Dcof : ecof C A)) + (eofe/const Dkofe Dcof) + <- ekof-to-ekofe Dkof Dkofe. + +-app : eof-to-eofe + (eof/app + (DofN : eof N A) + (DofM : eof M (epi A ([x] B x)))) + (eofe/app DofeN DofeM) + <- eof-to-eofe DofN DofeN + <- eof-to-eofe DofM DofeM. + +-lam : eof-to-eofe + (eof/lam + (DofA : ekof A ektype) + ([x] [d:evof x A] DofM x d : eof (M x) (B x))) + (eofe/lam DofeA DofeM) + <- ekof-to-ekofe DofA DofeA + <- eof1-to-eofe DofM DofeM. + +-eqtp : eof-to-eofe + (eof/eqtp + (Deqtp : eqtp A B ektype) + (Dof : eof M A)) + (eofe/eqtp Deqtpe Dofe) + <- eof-to-eofe Dof Dofe + <- eqtp-to-eqtpe Deqtp Deqtpe. + +-ext : eof-to-eofe + (eof/ext + ([x] [d:evof x A] DofApp x d + : eof (eapp M x) (B x)) + (DofM : eof M (epi A ([x] B' x)))) + (eofe/ext DofeApp DofeM) + <- eof1-to-eofe DofApp DofeApp + <- eof-to-eofe DofM DofeM. + +%% + +-const : ekof-to-ekofe + (ekof/const Dwf Dcof) + (ekofe/const Dwfe Dcof) + <- ewfkind-to-ewfkinde Dwf Dwfe. + +-pi : ekof-to-ekofe + (ekof/pi ([x] [d] Dkof' x d) Dkof) + (ekofe/pi Dkofe ([x] Dkofe' x)) + <- ekof-to-ekofe Dkof Dkofe + <- ekof1-to-ekofe Dkof' Dkofe'. + +-app : ekof-to-ekofe + (ekof/app Dof Dkof) + (ekofe/app Dofe Dkofe) + <- eof-to-eofe Dof Dofe + <- ekof-to-ekofe Dkof Dkofe. + +-lam : ekof-to-ekofe + (ekof/lam Dkof ([x] [d] Dkof' x d)) + (ekofe/lam Dkofe ([x] Dkofe' x)) + <- ekof-to-ekofe Dkof Dkofe + <- ekof1-to-ekofe Dkof' Dkofe'. + +-eqkind : ekof-to-ekofe + (ekof/eqkind Deqkind Dkof) + (ekofe/eqkind Deqkinde Dkofe) + <- ekof-to-ekofe Dkof Dkofe + <- eqkind-to-eqkinde Deqkind Deqkinde. + +-ext : ekof-to-ekofe + (ekof/ext ([x] [d] DofApp x d) Dof) + (ekofe/ext DofeApp Dofe) + <- ekof1-to-ekofe DofApp DofeApp + <- ekof-to-ekofe Dof Dofe. + +%% + +-tp : ewfkind-to-ewfkinde ewfkind/tp ewfkinde/tp. + +-pi : ewfkind-to-ewfkinde + (ewfkind/pi ([x] [d] Dwfkind x d) Dkof) + (ewfkinde/pi Dkofe ([x] Dwfkinde x)) + <- ekof-to-ekofe Dkof Dkofe + <- ewfkind1-to-ewfkinde Dwfkind Dwfkinde. + +%% + +-app : eqtm-to-eqtme + (eqtm/app Deqtm2 Deqtm1) + (eqtme/app Deqtme2 Deqtme1) + <- eqtm-to-eqtme Deqtm1 Deqtme1 + <- eqtm-to-eqtme Deqtm2 Deqtme2. + +-lam : eqtm-to-eqtme + (eqtm/lam + ([x] [d:evof x A] + Deqtm x d : eqtm (M x) (M' x) (B x)) + (Deqtp : eqtp A A' ektype)) + (eqtme/lam Deqtme Deqtpe) + <- eqtm1-to-eqtme Deqtm + ([x] Deqtme x : eqtme (econs enil x A) (M x) (M' x) (B x)) + <- eqtp-to-eqtpe Deqtp + (Deqtpe : eqtpe enil A A' ektype). + +-ext : eqtm-to-eqtme + (eqtm/ext ([x] [d:evof x A] Deqtm x d) DofN DofM) + (eqtme/ext ([x] Deqtme x) DofeN DofeM) + <- eqtm1-to-eqtme Deqtm Deqtme + <- eof-to-eofe DofN DofeN + <- eof-to-eofe DofM DofeM. + +-extw : eqtm-to-eqtme + (eqtm/extw ([x] [d:evof x A] Deqtm x d) Deqtm') + (eqtme/extw ([x] Deqtme x) Deqtme') + <- eqtm1-to-eqtme Deqtm Deqtme + <- eqtm-to-eqtme Deqtm' Deqtme'. + +-beta : eqtm-to-eqtme + (eqtm/beta Dof2 ([x] [d] Dof1 x d)) + (eqtme/beta Dofe2 ([x] Dofe1 x)) + <- eof1-to-eofe Dof1 Dofe1 + <- eof-to-eofe Dof2 Dofe2. + +-sym : eqtm-to-eqtme + (eqtm/sym Deqtm) + (eqtme/sym Deqtme) + <- eqtm-to-eqtme Deqtm Deqtme. + +-trans : eqtm-to-eqtme + (eqtm/trans Deqtm2 Deqtm1) + (eqtme/trans Deqtme2 Deqtme1) + <- eqtm-to-eqtme Deqtm1 Deqtme1 + <- eqtm-to-eqtme Deqtm2 Deqtme2. + +-refl : eqtm-to-eqtme + (eqtm/refl (Dof : eof M A)) + (eqtme/refl Dofe) + <- eof-to-eofe Dof Dofe. + +-tcon : eqtm-to-eqtme + (eqtm/typecon Deqtp Deqtm) + (eqtme/tcon Deqtpe Deqtme) + <- eqtp-to-eqtpe Deqtp Deqtpe + <- eqtm-to-eqtme Deqtm Deqtme. + +%% + +-app : eqtp-to-eqtpe + (eqtp/app Deqtm Deqtp) + (eqtpe/app Deqtme Deqtpe) + <- eqtp-to-eqtpe Deqtp Deqtpe + <- eqtm-to-eqtme Deqtm Deqtme. + +-pi : eqtp-to-eqtpe + (eqtp/pi ([x] [d] Deqtp2 x d) Deqtp1) + (eqtpe/pi ([x] Deqtpe2 x) Deqtpe1) + <- eqtp-to-eqtpe Deqtp1 Deqtpe1 + <- eqtp1-to-eqtpe Deqtp2 Deqtpe2. + +-lam : eqtp-to-eqtpe + (eqtp/lam + ([x] [d:evof x A] + Deqtm x d : eqtp (M x) (M' x) (B x)) + (Deqtp : eqtp A A' ektype)) + (eqtpe/lam Deqtme Deqtpe) + <- eqtp1-to-eqtpe Deqtm + ([x] Deqtme x : eqtpe (econs enil x A) (M x) (M' x) (B x)) + <- eqtp-to-eqtpe Deqtp + (Deqtpe : eqtpe enil A A' ektype). + +-ext : eqtp-to-eqtpe + (eqtp/ext ([x] [d:evof x A] Deqtp x d) DofN DofM) + (eqtpe/ext ([x] Deqtpe x) DofeN DofeM) + <- eqtp1-to-eqtpe Deqtp Deqtpe + <- ekof-to-ekofe DofN DofeN + <- ekof-to-ekofe DofM DofeM. + +-extw : eqtp-to-eqtpe + (eqtp/extw ([x] [d:evof x A] Deqtp x d) DeqM) + (eqtpe/extw ([x] Deqtpe x) DeqeM) + <- eqtp1-to-eqtpe Deqtp Deqtpe + <- eqtp-to-eqtpe DeqM DeqeM. + +-beta : eqtp-to-eqtpe + (eqtp/beta + (Dof : eof N A) + ([x] [d] Dkof x d : ekof (B x) (K x))) + (eqtpe/beta Dofe Dkofe) + <- ekof1-to-ekofe Dkof Dkofe + <- eof-to-eofe Dof Dofe. + +-sym : eqtp-to-eqtpe + (eqtp/sym Deqtp) + (eqtpe/sym Deqtpe) + <- eqtp-to-eqtpe Deqtp Deqtpe. + +-trans : eqtp-to-eqtpe + (eqtp/trans Deqtp2 Deqtp1) + (eqtpe/trans Deqtpe2 Deqtpe1) + <- eqtp-to-eqtpe Deqtp1 Deqtpe1 + <- eqtp-to-eqtpe Deqtp2 Deqtpe2. + + +-refl : eqtp-to-eqtpe + (eqtp/refl (Dof : ekof A K)) + (eqtpe/refl Dofe) + <- ekof-to-ekofe Dof Dofe. + +-kcon : eqtp-to-eqtpe + (eqtp/kcon Deqk Deqtp) + (eqtpe/kcon Deqke Deqtpe) + <- eqkind-to-eqkinde Deqk Deqke + <- eqtp-to-eqtpe Deqtp Deqtpe. + +%% + +-tp : eqkind-to-eqkinde eqkind/tp eqkinde/tp. + +-pi : eqkind-to-eqkinde + (eqkind/pi ([x] [d] Deqkind x d) Deqtp) + (eqkinde/pi ([x] Deqkinde x) Deqtpe) + <- eqtp-to-eqtpe Deqtp Deqtpe + <- eqkind1-to-eqkinde Deqkind Deqkinde. + +-sym : eqkind-to-eqkinde + (eqkind/sym Deqkind) + (eqkinde/sym Deqkinde) + <- eqkind-to-eqkinde Deqkind Deqkinde. + +-trans : eqkind-to-eqkinde + (eqkind/trans Deqkind2 Deqkind1) + (eqkinde/trans Deqkinde2 Deqkinde1) + <- eqkind-to-eqkinde Deqkind1 Deqkinde1 + <- eqkind-to-eqkinde Deqkind2 Deqkinde2. + + +-refl : eqkind-to-eqkinde + (eqkind/refl (Dof : ewfkind K)) + (eqkinde/refl Dofe) + <- ewfkind-to-ewfkinde Dof Dofe. + + +%worlds (ecsig | easig | evar | eovar | ebind) + (eof-to-eofe _ _) + (ekof-to-ekofe _ _) + (ewfkind-to-ewfkinde _ _) + (eqtm-to-eqtme _ _) + (eqtp-to-eqtpe _ _) + (eqkind-to-eqkinde _ _). +%total (D1 D2 D3 D4 D5 D6) + (eof-to-eofe D1 _) + (ekof-to-ekofe D2 _) + (ewfkind-to-ewfkinde D3 _) + (eqtm-to-eqtme D4 _) + (eqtp-to-eqtpe D5 _) + (eqkind-to-eqkinde D6 _). + +%%% Translation from explicit to implicit %%% + +eofi : ectx -> etm -> etp -> type. +ekofi : ectx -> etp -> ekind -> type. +ewfkindi : ectx -> ekind -> type. +eqtmi : ectx -> etm -> etm -> etp -> type. +eqtpi : ectx -> etp -> etp -> ekind -> type. +eqkindi : ectx -> ekind -> ekind -> type. + +eofi/nil : eofi enil M A + <- eof M A. + +eofi/cons : eofi (econs G X A) M B + <- (evof X A -> eofi G M B). + +ekofi/nil : ekofi enil M A + <- ekof M A. + +ekofi/cons : ekofi (econs G X A) M B + <- (evof X A -> ekofi G M B). + +ewfkindi/nil : ewfkindi enil K + <- ewfkind K. + +ewfkindi/cons : ewfkindi (econs G X A) K + <- (evof X A -> ewfkindi G K). + +eqtpi/nil : eqtpi enil A B K + <- eqtp A B K. + +eqtpi/cons : eqtpi (econs G X C) A B K + <- (evof X C -> eqtpi G A B K). + +eqtmi/nil : eqtmi enil A B K + <- eqtm A B K. + +eqtmi/cons : eqtmi (econs G X C) A B K + <- (evof X C -> eqtmi G A B K). + +eqkindi/nil : eqkindi enil A B + <- eqkind A B. + +eqkindi/cons : eqkindi (econs G X C) A B + <- (evof X C -> eqkindi G A B). + + +eofi-vari : evof X A -> ekofi G A ektype + -> eofi G X A -> type. +%mode eofi-vari +X1 +X2 -X3. + +- : eofi-vari Dvof (ekofi/nil DofA) (eofi/nil (eof/var DofA Dvof)). + +- : eofi-vari Dvof (ekofi/cons ([d:evof Y B] DofA d : ekofi G A ektype)) + (eofi/cons DofX) + <- ({d:evof Y B} + eofi-vari Dvof (DofA d) + (DofX d : eofi G X A)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eofi-vari _ _ _). +%total D (eofi-vari _ D _). + +eofi-const : ecof C A -> ekofi G A ektype + -> eofi G (econst C) A -> type. +%mode eofi-const +X1 +X2 -X3. + +- : eofi-const Dcof (ekofi/nil DofA) (eofi/nil (eof/const DofA Dcof)). + +- : eofi-const Dcof (ekofi/cons ([d:evof Y B] DofA d : ekofi G A ektype)) + (eofi/cons DofC) + <- ({d:evof Y B} + eofi-const Dcof (DofA d) + (DofC d : eofi G (econst C) A)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eofi-const _ _ _). +%total D (eofi-const _ D _). + +eofi-lookup : elookup G X A -> ekofi G A ektype + -> eofi G X A -> type. +%mode eofi-lookup +X1 +X2 -X3. + +- : eofi-lookup elookup/hit + (ekofi/cons ([d:evof X A] Dkof d : ekofi G A ektype)) + (eofi/cons Deofi) + <- ({d:evof X A} + eofi-vari d (Dkof d) + (Deofi d : eofi G X A)). + +- : eofi-lookup + (elookup/miss (Dlook : elookup G X A)) + (ekofi/cons ([d:evof Y B] Dkofi d : ekofi G A ektype)) + (eofi/cons Deofi) + <- ({d:evof Y B} + eofi-lookup Dlook (Dkofi d) + (Deofi d : eofi G X A)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eofi-lookup _ _ _). +%total D (eofi-lookup D _ _). + +eofi-app : eofi G M (epi A B) -> eofi G N A + -> eofi G (eapp M N) (B N) -> type. +%mode eofi-app +X1 +X2 -X3. + +- : eofi-app + (eofi/nil (DofM : eof M (epi A B))) (eofi/nil (DofN : eof N A)) + (eofi/nil (eof/app DofN DofM)). + +- : eofi-app + (eofi/cons + ([d:evof X C] DofM d : eofi G M (epi A B))) + (eofi/cons + ([d:evof X C] DofN d : eofi G N A)) + (eofi/cons DofApp) + <- ({d:evof X C} + eofi-app (DofM d) (DofN d) + (DofApp d : eofi G (eapp M N) (B N))). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eofi-app _ _ _). +%total D (eofi-app D _ _). + +eofi-lam : ekofi G A ektype -> ({x} eofi (econs G x A) (M x) (B x)) + -> eofi G (elam A M) (epi A B) -> type. +%mode eofi-lam +X1 +X2 -X3. + +- : eofi-lam (ekofi/nil (Dkof : ekof A ektype)) + ([x] eofi/cons ([d:evof x A] eofi/nil (DofM x d : eof (M x) (B x)))) + (eofi/nil (eof/lam Dkof DofM)). + +- : eofi-lam (ekofi/cons ([e:evof Y C] Dkof e : ekofi G A ektype)) + ([x] eofi/cons + ([d:evof x A] eofi/cons + ([e:evof Y C] DofM x d e : eofi G (M x) (B x)))) + (eofi/cons DofLam) + <- ({e:evof Y C} + eofi-lam (Dkof e) ([x] eofi/cons ([d] DofM x d e)) + (DofLam e : eofi G (elam A M) (epi A B))). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eofi-lam _ _ _). +%total D (eofi-lam D _ _). + +eofi-eqtp : eofi G M A -> eqtpi G A B ektype + -> eofi G M B -> type. +%mode eofi-eqtp +X1 +X2 -X3. + +- : eofi-eqtp (eofi/nil Dof) (eqtpi/nil Deqtp) + (eofi/nil (eof/eqtp Deqtp Dof)). + +- : eofi-eqtp (eofi/cons ([d] Dofi d)) (eqtpi/cons ([d] Deqtpi d)) + (eofi/cons D) + <- ({d} + eofi-eqtp (Dofi d) (Deqtpi d) + (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eofi-eqtp _ _ _). +%total D (eofi-eqtp D _ _). + +eofi-ext : ({x} eofi (econs G x A) (eapp M x) (B x)) + -> eofi G M (epi A B') + -> eofi G M (epi A B) -> type. +%mode eofi-ext +X1 +X2 -X3. + +- : eofi-ext + ([x] eofi/cons + ([d:evof x A] eofi/nil (DofApp x d : eof (eapp M x) (B x)))) + (eofi/nil (DofM : eof M (epi A B'))) + (eofi/nil (eof/ext DofApp DofM)). + +- : eofi-ext + ([x] eofi/cons ([d] eofi/cons ([e] DofApp x d e))) + (eofi/cons ([e] DofM e)) + (eofi/cons D) + <- ({e} eofi-ext ([x] eofi/cons ([d] DofApp x d e)) (DofM e) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eofi-ext _ _ _). +%total D (eofi-ext _ D _). + +ekofi-const : eckof C A -> ewfkindi G A + -> ekofi G (eaconst C) A -> type. +%mode ekofi-const +X1 +X2 -X3. + +- : ekofi-const Dcof (ewfkindi/nil DofA) (ekofi/nil (ekof/const DofA Dcof)). + +- : ekofi-const Dcof (ewfkindi/cons ([d:evof Y B] DofA d : ewfkindi G A)) + (ekofi/cons DofC) + <- ({d:evof Y B} + ekofi-const Dcof (DofA d) + (DofC d : ekofi G (eaconst C) A)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (ekofi-const _ _ _). +%total D (ekofi-const _ D _). + +ekofi-app : ekofi G M (ekpi A B) -> eofi G N A + -> ekofi G (eaapp M N) (B N) -> type. +%mode ekofi-app +X1 +X2 -X3. + +- : ekofi-app + (ekofi/nil (DofM : ekof M (ekpi A B))) (eofi/nil (DofN : eof N A)) + (ekofi/nil (ekof/app DofN DofM)). + +- : ekofi-app + (ekofi/cons + ([d:evof X C] DofM d : ekofi G M (ekpi A B))) + (eofi/cons + ([d:evof X C] DofN d : eofi G N A)) + (ekofi/cons DofApp) + <- ({d:evof X C} + ekofi-app (DofM d) (DofN d) + (DofApp d : ekofi G (eaapp M N) (B N))). + +%worlds (ecsig | easig | ebind | evar | eofblock) (ekofi-app _ _ _). +%total D (ekofi-app D _ _). + +ekofi-lam : ekofi G A ektype -> ({x} ekofi (econs G x A) (M x) (B x)) + -> ekofi G (ealam A M) (ekpi A B) -> type. +%mode ekofi-lam +X1 +X2 -X3. + +- : ekofi-lam + (ekofi/nil (Dkof : ekof A ektype)) + ([x] ekofi/cons + ([d:evof x A] ekofi/nil (DofM x d : ekof (M x) (B x)))) + (ekofi/nil (ekof/lam Dkof DofM)). + +- : ekofi-lam + (ekofi/cons ([e:evof Y C] Dkof e : ekofi G A ektype)) + ([x] ekofi/cons + ([d:evof x A] ekofi/cons + ([e:evof Y C] DofM x d e : ekofi G (M x) (B x)))) + (ekofi/cons DofLam) + <- ({e:evof Y C} + ekofi-lam (Dkof e) ([x] ekofi/cons ([d] DofM x d e)) + (DofLam e : ekofi G (ealam A M) (ekpi A B))). + +%worlds (ecsig | easig | ebind | evar | eofblock) (ekofi-lam _ _ _). +%total D (ekofi-lam D _ _). + +ekofi-pi : ekofi G A ektype -> ({x} ekofi (econs G x A) (M x) ektype) + -> ekofi G (epi A M) ektype -> type. +%mode ekofi-pi +X1 +X2 -X3. + +- : ekofi-pi + (ekofi/nil (Dkof : ekof A ektype)) + ([x] ekofi/cons + ([d:evof x A] ekofi/nil (DofM x d : ekof (M x) ektype))) + (ekofi/nil (ekof/pi DofM Dkof)). + +- : ekofi-pi + (ekofi/cons ([e:evof Y C] Dkof e : ekofi G A ektype)) + ([x] ekofi/cons + ([d:evof x A] ekofi/cons + ([e:evof Y C] DofM x d e : ekofi G (M x) ektype))) + (ekofi/cons DofLam) + <- ({e:evof Y C} + ekofi-pi (Dkof e) ([x] ekofi/cons ([d] DofM x d e)) + (DofLam e : ekofi G (epi A M) ektype)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (ekofi-pi _ _ _). +%total D (ekofi-pi D _ _). + +ekofi-eqkind : ekofi G M A -> eqkindi G A B + -> ekofi G M B -> type. +%mode ekofi-eqkind +X1 +X2 -X3. + +- : ekofi-eqkind (ekofi/nil Dof) (eqkindi/nil Deqkind) + (ekofi/nil (ekof/eqkind Deqkind Dof)). + +- : ekofi-eqkind (ekofi/cons ([d] Dofi d)) (eqkindi/cons ([d] Deqkindi d)) + (ekofi/cons D) + <- ({d} + ekofi-eqkind (Dofi d) (Deqkindi d) + (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (ekofi-eqkind _ _ _). +%total D (ekofi-eqkind D _ _). + +ekofi-ext : ({x} ekofi (econs G x A) (eaapp M x) (B x)) + -> ekofi G M (ekpi A B') + -> ekofi G M (ekpi A B) -> type. +%mode ekofi-ext +X1 +X2 -X3. + +- : ekofi-ext + ([x] ekofi/cons + ([d:evof x A] ekofi/nil (DofApp x d : ekof (eaapp M x) (B x)))) + (ekofi/nil (DofM : ekof M (ekpi A B'))) + (ekofi/nil (ekof/ext DofApp DofM)). + +- : ekofi-ext + ([x] ekofi/cons ([d] ekofi/cons ([e] DofApp x d e))) + (ekofi/cons ([e] DofM e)) + (ekofi/cons D) + <- ({e} ekofi-ext ([x] ekofi/cons ([d] DofApp x d e)) (DofM e) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (ekofi-ext _ _ _). +%total D (ekofi-ext _ D _). + + +ewfkindi-type : {G} ewfkindi G ektype -> type. +%mode ewfkindi-type +G -X. + +- : ewfkindi-type enil (ewfkindi/nil ewfkind/tp). + +- : ewfkindi-type (econs G X A) + (ewfkindi/cons ([_] Dwfi)) + <- ewfkindi-type G Dwfi. + +%worlds (ecsig | easig | ebind | evar | eofblock) (ewfkindi-type _ _). +%total D (ewfkindi-type D _). + +ewfkindi-pi : ekofi G A ektype -> ({x} ewfkindi (econs G x A) (K x)) + -> ewfkindi G (ekpi A K) -> type. +%mode ewfkindi-pi +X1 +X2 -X3. + +- : ewfkindi-pi + (ekofi/nil (Dkof : ekof A ektype)) + ([x] ewfkindi/cons + ([d:evof x A] ewfkindi/nil (DofM x d : ewfkind (K x)))) + (ewfkindi/nil (ewfkind/pi DofM Dkof)). + +- : ewfkindi-pi + (ekofi/cons ([e:evof Y C] Dkof e : ekofi G A ektype)) + ([x] ewfkindi/cons + ([d:evof x A] ewfkindi/cons + ([e:evof Y C] DofM x d e : ewfkindi G (K x)))) + (ewfkindi/cons DofLam) + <- ({e:evof Y C} + ewfkindi-pi (Dkof e) ([x] ewfkindi/cons ([d] DofM x d e)) + (DofLam e : ewfkindi G (ekpi A K))). + +%worlds (ecsig | easig | ebind | evar | eofblock) (ewfkindi-pi _ _ _). +%total D (ewfkindi-pi D _ _). + + +eqtmi-app : eqtmi G M M' (epi A B) -> eqtmi G N N' A + -> eqtmi G (eapp M N) (eapp M' N') (B N) -> type. +%mode eqtmi-app +X1 +X2 -X3. + +- : eqtmi-app (eqtmi/nil DeqtmM) (eqtmi/nil DeqtmN) + (eqtmi/nil (eqtm/app DeqtmN DeqtmM)). + +- : eqtmi-app (eqtmi/cons ([d] DeqtmiM d)) (eqtmi/cons ([d] DeqtmiN d)) + (eqtmi/cons Deqtmi) + <- ({d} eqtmi-app (DeqtmiM d) (DeqtmiN d) (Deqtmi d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-app _ _ _). +%total D (eqtmi-app D _ _). + +eqtmi-lam : eqtpi G A A' ektype + -> ({x} eqtmi (econs G x A) (M x) (M' x) (B x)) + -> eqtmi G (elam A M) (elam A' M') (epi A B) -> type. +%mode eqtmi-lam +X1 +X2 -X3. + +- : eqtmi-lam + (eqtpi/nil Deqtp) + ([x] eqtmi/cons ([d] eqtmi/nil (Deqtm x d))) + (eqtmi/nil (eqtm/lam ([x] [d] Deqtm x d) Deqtp)). + +- : eqtmi-lam + (eqtpi/cons ([e] Deqtpi e)) + ([x] eqtmi/cons ([d] eqtmi/cons ([e] Deqtmi x d e))) + (eqtmi/cons ([e] D e)) + <- ({e} + eqtmi-lam (Deqtpi e) ([x] eqtmi/cons ([d] Deqtmi x d e)) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-lam _ _ _). +%total D (eqtmi-lam D _ _). + +eqtmi-ext : ({x} eqtmi (econs G x A) (eapp M x) (eapp M' x) (B x)) + -> eofi G M (epi A B') + -> eofi G M' (epi A B'') + -> eqtmi G M M' (epi A B) -> type. +%mode eqtmi-ext +X1 +X2 +X3 -X4. + +- : eqtmi-ext + ([x] eqtmi/cons ([d] eqtmi/nil (Deqtm x d))) + (eofi/nil DofM) (eofi/nil DofM') + (eqtmi/nil (eqtm/ext ([x] [d] Deqtm x d) DofM' DofM)). + +- : eqtmi-ext + ([x] eqtmi/cons ([d] eqtmi/cons ([e] Deqtmi x d e))) + (eofi/cons ([e] DofM e)) + (eofi/cons ([e] DofM' e)) + (eqtmi/cons ([e] D e)) + <- ({e} + eqtmi-ext + ([x] eqtmi/cons ([d] Deqtmi x d e)) + (DofM e) (DofM' e) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-ext _ _ _ _). +%total D (eqtmi-ext _ D _ _). + +eqtmi-extw : ({x} eqtmi (econs G x A) (eapp M x) (eapp M' x) (B x)) + -> eqtmi G M M' (epi A B') + -> eqtmi G M M' (epi A B) -> type. +%mode eqtmi-extw +X2 +X3 -X4. + +- : eqtmi-extw + ([x] eqtmi/cons ([d] eqtmi/nil (Deqtm x d))) + (eqtmi/nil DeqM) + (eqtmi/nil (eqtm/extw ([x] [d] Deqtm x d) DeqM)). + +- : eqtmi-extw + ([x] eqtmi/cons ([d] eqtmi/cons ([e] Deqtmi x d e))) + (eqtmi/cons ([e] DeqM e)) + (eqtmi/cons ([e] D e)) + <- ({e} + eqtmi-extw + ([x] eqtmi/cons ([d] Deqtmi x d e)) + (DeqM e) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-extw _ _ _). +%total D (eqtmi-extw _ D _). + +eqtmi-beta : eofi G N A -> ({x} eofi (econs G x A) (M x) (B x)) + -> eqtmi G (eapp (elam A M) N) (M N) (B N) -> type. +%mode eqtmi-beta +X1 +X2 -X3. + +- : eqtmi-beta (eofi/nil DofN) ([x] eofi/cons ([d] eofi/nil (DofM x d))) + (eqtmi/nil (eqtm/beta DofN DofM)). + +- : eqtmi-beta + (eofi/cons ([e] DofiN e)) + ([x] eofi/cons ([d] eofi/cons ([e] DofiM x d e))) + (eqtmi/cons ([e] Dofi e)) + <- ({e} + eqtmi-beta (DofiN e) ([x] eofi/cons ([d] DofiM x d e)) + (Dofi e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-beta _ _ _). +%total D (eqtmi-beta D _ _). + +eqtmi-sym : eqtmi G M N A -> eqtmi G N M A -> type. +%mode eqtmi-sym +X1 -X2. + +- : eqtmi-sym (eqtmi/nil Deqtm) (eqtmi/nil (eqtm/sym Deqtm)). + +- : eqtmi-sym (eqtmi/cons ([d] Deqtmi d)) + (eqtmi/cons ([d] D d)) + <- ({d} eqtmi-sym (Deqtmi d) (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-sym _ _). +%total D (eqtmi-sym D _). + +eqtmi-trans : eqtmi G M N A -> eqtmi G N O A -> eqtmi G M O A -> type. +%mode eqtmi-trans +X1 +X2 -X3. + +- : eqtmi-trans (eqtmi/nil D1) (eqtmi/nil D2) + (eqtmi/nil (eqtm/trans D2 D1)). + +- : eqtmi-trans (eqtmi/cons ([d] D1 d)) (eqtmi/cons ([d] D2 d)) + (eqtmi/cons ([d] D d)) + <- ({d} eqtmi-trans (D1 d) (D2 d) (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-trans _ _ _). +%total D (eqtmi-trans D _ _). + +eqtmi-refl : eofi G M A -> eqtmi G M M A -> type. +%mode eqtmi-refl +X1 -X2. + +- : eqtmi-refl (eofi/nil D) (eqtmi/nil (eqtm/refl D)). + +- : eqtmi-refl (eofi/cons ([d] D d)) (eqtmi/cons ([d] D' d)) + <- ({d} eqtmi-refl (D d) (D' d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-refl _ _). +%total D (eqtmi-refl D _). + +eqtmi-tcon : eqtmi G M N A -> eqtpi G A B ektype + -> eqtmi G M N B -> type. +%mode eqtmi-tcon +X1 +X2 -X3. + +- : eqtmi-tcon (eqtmi/nil Dtm) (eqtpi/nil Dtp) + (eqtmi/nil (eqtm/typecon Dtp Dtm)). + +- : eqtmi-tcon (eqtmi/cons ([d] Dtm d)) (eqtpi/cons ([d] Dtp d)) + (eqtmi/cons ([d] D d)) + <- ({d} eqtmi-tcon (Dtm d) (Dtp d) (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtmi-tcon _ _ _). +%total D (eqtmi-tcon D _ _). + + +eqtpi-pi : eqtpi G A A' ektype + -> ({x} eqtpi (econs G x A) (M x) (M' x) ektype) + -> eqtpi G (epi A M) (epi A' M') ektype -> type. +%mode eqtpi-pi +X1 +X2 -X3. + +- : eqtpi-pi + (eqtpi/nil Deqtp) + ([x] eqtpi/cons ([d] eqtpi/nil (Deqtm x d))) + (eqtpi/nil (eqtp/pi ([x] [d] Deqtm x d) Deqtp)). + +- : eqtpi-pi + (eqtpi/cons ([e] Deqtpi e)) + ([x] eqtpi/cons ([d] eqtpi/cons ([e] Deqtmi x d e))) + (eqtpi/cons ([e] D e)) + <- ({e} + eqtpi-pi (Deqtpi e) ([x] eqtpi/cons ([d] Deqtmi x d e)) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-pi _ _ _). +%total D (eqtpi-pi D _ _). + +eqtpi-app : eqtpi G M M' (ekpi A B) -> eqtmi G N N' A + -> eqtpi G (eaapp M N) (eaapp M' N') (B N) -> type. +%mode eqtpi-app +X1 +X2 -X3. + +- : eqtpi-app (eqtpi/nil DeqtmM) (eqtmi/nil DeqtmN) + (eqtpi/nil (eqtp/app DeqtmN DeqtmM)). + +- : eqtpi-app (eqtpi/cons ([d] DeqtmiM d)) (eqtmi/cons ([d] DeqtmiN d)) + (eqtpi/cons Deqtmi) + <- ({d} eqtpi-app (DeqtmiM d) (DeqtmiN d) (Deqtmi d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-app _ _ _). +%total D (eqtpi-app D _ _). + +eqtpi-lam : eqtpi G A A' ektype + -> ({x} eqtpi (econs G x A) (M x) (M' x) (B x)) + -> eqtpi G (ealam A M) (ealam A' M') (ekpi A B) -> type. +%mode eqtpi-lam +X1 +X2 -X3. + +- : eqtpi-lam + (eqtpi/nil Deqtp) + ([x] eqtpi/cons ([d] eqtpi/nil (Deqtm x d))) + (eqtpi/nil (eqtp/lam ([x] [d] Deqtm x d) Deqtp)). + +- : eqtpi-lam + (eqtpi/cons ([e] Deqtpi e)) + ([x] eqtpi/cons ([d] eqtpi/cons ([e] Deqtmi x d e))) + (eqtpi/cons ([e] D e)) + <- ({e} + eqtpi-lam (Deqtpi e) ([x] eqtpi/cons ([d] Deqtmi x d e)) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-lam _ _ _). +%total D (eqtpi-lam D _ _). + +eqtpi-ext : ({x} eqtpi (econs G x A) (eaapp M x) (eaapp M' x) (B x)) + -> ekofi G M (ekpi A B') + -> ekofi G M' (ekpi A B'') + -> eqtpi G M M' (ekpi A B) -> type. +%mode eqtpi-ext +X1 +X2 +X3 -X4. + +- : eqtpi-ext + ([x] eqtpi/cons ([d] eqtpi/nil (Deqtm x d))) + (ekofi/nil DkofM) (ekofi/nil DkofM') + (eqtpi/nil (eqtp/ext ([x] [d] Deqtm x d) DkofM' DkofM)). + +- : eqtpi-ext + ([x] eqtpi/cons ([d] eqtpi/cons ([e] Deqtmi x d e))) + (ekofi/cons ([e] DkofM e)) + (ekofi/cons ([e] DkofM' e)) + (eqtpi/cons ([e] D e)) + <- ({e} + eqtpi-ext + ([x] eqtpi/cons ([d] Deqtmi x d e)) + (DkofM e) (DkofM' e) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-ext _ _ _ _). +%total D (eqtpi-ext _ D _ _). + +eqtpi-extw : ({x} eqtpi (econs G x A) (eaapp M x) (eaapp M' x) (B x)) + -> eqtpi G M M' (ekpi A B') + -> eqtpi G M M' (ekpi A B) -> type. +%mode eqtpi-extw +X2 +X3 -X4. + +- : eqtpi-extw + ([x] eqtpi/cons ([d] eqtpi/nil (Deqtm x d))) + (eqtpi/nil DeqM) + (eqtpi/nil (eqtp/extw ([x] [d] Deqtm x d) DeqM)). + +- : eqtpi-extw + ([x] eqtpi/cons ([d] eqtpi/cons ([e] Deqtmi x d e))) + (eqtpi/cons ([e] DeqM e)) + (eqtpi/cons ([e] D e)) + <- ({e} + eqtpi-extw + ([x] eqtpi/cons ([d] Deqtmi x d e)) + (DeqM e) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-extw _ _ _). +%total D (eqtpi-extw _ D _). + +eqtpi-beta : eofi G N A -> ({x} ekofi (econs G x A) (M x) (B x)) + -> eqtpi G (eaapp (ealam A M) N) (M N) (B N) -> type. +%mode eqtpi-beta +X1 +X2 -X3. + +- : eqtpi-beta (eofi/nil DofN) ([x] ekofi/cons ([d] ekofi/nil (DofM x d))) + (eqtpi/nil (eqtp/beta DofN DofM)). + +- : eqtpi-beta + (eofi/cons ([e] DofiN e)) + ([x] ekofi/cons ([d] ekofi/cons ([e] DofiM x d e))) + (eqtpi/cons ([e] Dofi e)) + <- ({e} + eqtpi-beta (DofiN e) ([x] ekofi/cons ([d] DofiM x d e)) + (Dofi e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-beta _ _ _). +%total D (eqtpi-beta D _ _). + +eqtpi-sym : eqtpi G M N A -> eqtpi G N M A -> type. +%mode eqtpi-sym +X1 -X2. + +- : eqtpi-sym (eqtpi/nil Deqtm) (eqtpi/nil (eqtp/sym Deqtm)). + +- : eqtpi-sym (eqtpi/cons ([d] Deqtpi d)) + (eqtpi/cons ([d] D d)) + <- ({d} eqtpi-sym (Deqtpi d) (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-sym _ _). +%total D (eqtpi-sym D _). + +eqtpi-trans : eqtpi G M N A -> eqtpi G N O A -> eqtpi G M O A -> type. +%mode eqtpi-trans +X1 +X2 -X3. + +- : eqtpi-trans (eqtpi/nil D1) (eqtpi/nil D2) + (eqtpi/nil (eqtp/trans D2 D1)). + +- : eqtpi-trans (eqtpi/cons ([d] D1 d)) (eqtpi/cons ([d] D2 d)) + (eqtpi/cons ([d] D d)) + <- ({d} eqtpi-trans (D1 d) (D2 d) (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-trans _ _ _). +%total D (eqtpi-trans D _ _). + +eqtpi-refl : ekofi G M A -> eqtpi G M M A -> type. +%mode eqtpi-refl +X1 -X2. + +- : eqtpi-refl (ekofi/nil D) (eqtpi/nil (eqtp/refl D)). + +- : eqtpi-refl (ekofi/cons ([d] D d)) (eqtpi/cons ([d] D' d)) + <- ({d} eqtpi-refl (D d) (D' d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-refl _ _). +%total D (eqtpi-refl D _). + +eqtpi-kcon : eqtpi G M N A -> eqkindi G A B + -> eqtpi G M N B -> type. +%mode eqtpi-kcon +X1 +X2 -X3. + +- : eqtpi-kcon (eqtpi/nil Dtm) (eqkindi/nil Dtp) + (eqtpi/nil (eqtp/kcon Dtp Dtm)). + +- : eqtpi-kcon (eqtpi/cons ([d] Dtm d)) (eqkindi/cons ([d] Dtp d)) + (eqtpi/cons ([d] D d)) + <- ({d} eqtpi-kcon (Dtm d) (Dtp d) (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqtpi-kcon _ _ _). +%total D (eqtpi-kcon D _ _). + + +eqkindi-type : {G} eqkindi G ektype ektype -> type. +%mode eqkindi-type +G -X. + +- : eqkindi-type enil (eqkindi/nil eqkind/tp). + +- : eqkindi-type (econs G _ _) + (eqkindi/cons ([_] D)) + <- eqkindi-type G D. + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqkindi-type _ _). +%total G (eqkindi-type G _). + +eqkindi-pi : eqtpi G A A' ektype + -> ({x} eqkindi (econs G x A) (M x) (M' x)) + -> eqkindi G (ekpi A M) (ekpi A' M') -> type. +%mode eqkindi-pi +X1 +X2 -X3. + +- : eqkindi-pi + (eqtpi/nil Deqtp) + ([x] eqkindi/cons ([d] eqkindi/nil (Deqtm x d))) + (eqkindi/nil (eqkind/pi ([x] [d] Deqtm x d) Deqtp)). + +- : eqkindi-pi + (eqtpi/cons ([e] Deqtpi e)) + ([x] eqkindi/cons ([d] eqkindi/cons ([e] Deqtmi x d e))) + (eqkindi/cons ([e] D e)) + <- ({e} + eqkindi-pi (Deqtpi e) ([x] eqkindi/cons ([d] Deqtmi x d e)) + (D e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqkindi-pi _ _ _). +%total D (eqkindi-pi D _ _). + +eqkindi-sym : eqkindi G M N -> eqkindi G N M -> type. +%mode eqkindi-sym +X1 -X2. + +- : eqkindi-sym (eqkindi/nil Deqtm) (eqkindi/nil (eqkind/sym Deqtm)). + +- : eqkindi-sym (eqkindi/cons ([d] Deqkindi d)) + (eqkindi/cons ([d] D d)) + <- ({d} eqkindi-sym (Deqkindi d) (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqkindi-sym _ _). +%total D (eqkindi-sym D _). + +eqkindi-trans : eqkindi G M N -> eqkindi G N O -> eqkindi G M O -> type. +%mode eqkindi-trans +X1 +X2 -X3. + +- : eqkindi-trans (eqkindi/nil D1) (eqkindi/nil D2) + (eqkindi/nil (eqkind/trans D2 D1)). + +- : eqkindi-trans (eqkindi/cons ([d] D1 d)) (eqkindi/cons ([d] D2 d)) + (eqkindi/cons ([d] D d)) + <- ({d} eqkindi-trans (D1 d) (D2 d) (D d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqkindi-trans _ _ _). +%total D (eqkindi-trans D _ _). + +eqkindi-refl : ewfkindi G M -> eqkindi G M M -> type. +%mode eqkindi-refl +X1 -X2. + +- : eqkindi-refl (ewfkindi/nil D) (eqkindi/nil (eqkind/refl D)). + +- : eqkindi-refl (ewfkindi/cons ([d] D d)) (eqkindi/cons ([d] D' d)) + <- ({d} eqkindi-refl (D d) (D' d)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (eqkindi-refl _ _). +%total D (eqkindi-refl D _). + + +eofe-to-eofi : eofe G M A -> eofi G M A -> type. +%mode eofe-to-eofi +X1 -X2. + +ekofe-to-ekofi : ekofe G A K -> ekofi G A K -> type. +%mode ekofe-to-ekofi +X1 -X2. + +ewfkinde-to-ewfkindi : ewfkinde G K -> ewfkindi G K -> type. +%mode ewfkinde-to-ewfkindi +X1 -X2. + +eqtme-to-eqtmi : eqtme G M N A -> eqtmi G M N A -> type. +%mode eqtme-to-eqtmi +X1 -X2. + +eqtpe-to-eqtpi : eqtpe G A B K -> eqtpi G A B K -> type. +%mode eqtpe-to-eqtpi +X1 -X2. + +eqkinde-to-eqkindi : eqkinde G K L -> eqkindi G K L -> type. +%mode eqkinde-to-eqkindi +X1 -X2. + +-vari : eofe-to-eofi + (eofe/vari + (Dkof : ekofe G A ektype) + (Dvof : evof X A)) + DofX + <- ekofe-to-ekofi Dkof Dkofi + <- eofi-vari Dvof Dkofi + (DofX : eofi G X A). + +-const : eofe-to-eofi + (eofe/const + (Dkof : ekofe G A ektype) + (Dcof : ecof C A)) + DofC + <- ekofe-to-ekofi Dkof Dkofi + <- eofi-const Dcof Dkofi + (DofC : eofi G (econst C) A). + +-var : eofe-to-eofi + (eofe/var + (Dkof : ekofe G A ektype) + (Dlook : elookup G X A)) + Dofi + <- ekofe-to-ekofi Dkof Dkofi + <- eofi-lookup Dlook Dkofi + (Dofi : eofi G X A). + +-app : eofe-to-eofi + (eofe/app + (DofN : eofe G N B) + (DofM : eofe G M (epi B ([x] A x)))) + DofiApp + <- eofe-to-eofi DofN DofiN + <- eofe-to-eofi DofM DofiM + <- eofi-app DofiM DofiN DofiApp. + +-lam : eofe-to-eofi + (eofe/lam + DofA + ([x] DofM x : eofe (econs G x A) (M x) (B x))) + D + <- ekofe-to-ekofi DofA DofiA + <- ({x} + eofe-to-eofi (DofM x) + (DofiM x : eofi (econs G x A) (M x) (B x))) + <- eofi-lam DofiA DofiM + D. + +-eqtp : eofe-to-eofi + (eofe/eqtp + (Deqtp : eqtpe G A B ektype) + (DofM : eofe G M A)) + D + <- eqtpe-to-eqtpi Deqtp Deqtpi + <- eofe-to-eofi DofM DofiM + <- eofi-eqtp DofiM Deqtpi + D. + +-ext : eofe-to-eofi + (eofe/ext + ([x] DofApp x + : eofe (econs G x A) (eapp M x) (B x)) + (DofM : eofe G M (epi A ([x] B' x)))) + D + <- ({x} + eofe-to-eofi (DofApp x) + (DofiApp x : eofi (econs G x A) (eapp M x) (B x))) + <- eofe-to-eofi DofM DofiM + <- eofi-ext DofiApp DofiM D. + +%% + +-const : ekofe-to-ekofi + (ekofe/const + (Dkof : ewfkinde G A) + (Dcof : eckof C A)) + DofC + <- ewfkinde-to-ewfkindi Dkof Dkofi + <- ekofi-const Dcof Dkofi + (DofC : ekofi G (eaconst C) A). + +-app : ekofe-to-ekofi + (ekofe/app Dofe Dkofe) + D + <- ekofe-to-ekofi Dkofe Dkofi + <- eofe-to-eofi Dofe Dofi + <- ekofi-app Dkofi Dofi D. + +-lam : ekofe-to-ekofi + (ekofe/lam D1 D2) + D + <- ({x} ekofe-to-ekofi (D2 x) (D2i x)) + <- ekofe-to-ekofi D1 D1i + <- ekofi-lam D1i D2i D. + +-pi : ekofe-to-ekofi + (ekofe/pi D1 D2) + D + <- ({x} ekofe-to-ekofi (D2 x) (D2i x)) + <- ekofe-to-ekofi D1 D1i + <- ekofi-pi D1i D2i D. + +-eqkind : ekofe-to-ekofi + (ekofe/eqkind Deqkinde Dekofe) + D + <- ekofe-to-ekofi Dekofe Dekofi + <- eqkinde-to-eqkindi Deqkinde Deqkindi + <- ekofi-eqkind Dekofi Deqkindi D. + +-ext : ekofe-to-ekofi + (ekofe/ext ([x] DofApp x) DofM) + D + <- ({x} ekofe-to-ekofi (DofApp x) (DofiApp x)) + <- ekofe-to-ekofi DofM DofiM + <- ekofi-ext DofiApp DofiM D. + +%% + +-type : ewfkinde-to-ewfkindi ewfkinde/tp Dwfi + <- ewfkindi-type _ Dwfi. + +-pi : ewfkinde-to-ewfkindi (ewfkinde/pi D1 D2) D + <- ({x} ewfkinde-to-ewfkindi (D2 x) (D2i x)) + <- ekofe-to-ekofi D1 D1i + <- ewfkindi-pi D1i D2i D. + +%% + +-app : eqtme-to-eqtmi (eqtme/app DeqtmN DeqtmM) + D + <- eqtme-to-eqtmi DeqtmN DeqtmiN + <- eqtme-to-eqtmi DeqtmM DeqtmiM + <- eqtmi-app DeqtmiM DeqtmiN D. + +-lam : eqtme-to-eqtmi (eqtme/lam ([x] Deqtm x) Deqtp) + D + <- eqtpe-to-eqtpi Deqtp Deqtpi + <- ({x} eqtme-to-eqtmi (Deqtm x) (Deqtmi x)) + <- eqtmi-lam Deqtpi Deqtmi D. + +-ext : eqtme-to-eqtmi (eqtme/ext ([x] Deqtm x) DofM' DofM) + D + <- eofe-to-eofi DofM DofiM + <- eofe-to-eofi DofM' DofiM' + <- ({x} eqtme-to-eqtmi (Deqtm x) (Deqtmi x)) + <- eqtmi-ext Deqtmi DofiM DofiM' D. + +-extw : eqtme-to-eqtmi (eqtme/extw ([x] Deqtm x) Deqtm') + D + <- eqtme-to-eqtmi Deqtm' Deqtmi' + <- ({x} eqtme-to-eqtmi (Deqtm x) (Deqtmi x)) + <- eqtmi-extw Deqtmi Deqtmi' + D. + +-beta : eqtme-to-eqtmi (eqtme/beta DofN ([x] DofM x)) + D + <- eofe-to-eofi DofN DofiN + <- ({x} eofe-to-eofi (DofM x) (DofiM x)) + <- eqtmi-beta DofiN DofiM D. + +-sym : eqtme-to-eqtmi (eqtme/sym Deqtm) + D + <- eqtme-to-eqtmi Deqtm Deqtmi + <- eqtmi-sym Deqtmi D. + +-trans : eqtme-to-eqtmi (eqtme/trans D2 D1) + D + <- eqtme-to-eqtmi D1 D1i + <- eqtme-to-eqtmi D2 D2i + <- eqtmi-trans D1i D2i D. + +-refl : eqtme-to-eqtmi (eqtme/refl Dof) + D + <- eofe-to-eofi Dof Dofi + <- eqtmi-refl Dofi D. + +-tcon : eqtme-to-eqtmi (eqtme/tcon Deqtp Deqtm) + D + <- eqtme-to-eqtmi Deqtm Deqtmi + <- eqtpe-to-eqtpi Deqtp Deqtpi + <- eqtmi-tcon Deqtmi Deqtpi D. + +%% + +-pi : eqtpe-to-eqtpi (eqtpe/pi ([x] D2 x) D1) + D + <- eqtpe-to-eqtpi D1 D1i + <- ({x} eqtpe-to-eqtpi (D2 x) (D2i x)) + <- eqtpi-pi D1i D2i D. + +-app : eqtpe-to-eqtpi (eqtpe/app DeqtmN DeqtmM) + D + <- eqtme-to-eqtmi DeqtmN DeqtmiN + <- eqtpe-to-eqtpi DeqtmM DeqtmiM + <- eqtpi-app DeqtmiM DeqtmiN D. + +-lam : eqtpe-to-eqtpi (eqtpe/lam ([x] Deqtm x) Deqtp) + D + <- eqtpe-to-eqtpi Deqtp Deqtpi + <- ({x} eqtpe-to-eqtpi (Deqtm x) (Deqtmi x)) + <- eqtpi-lam Deqtpi Deqtmi D. + +-ext : eqtpe-to-eqtpi (eqtpe/ext ([x] Deqtm x) DofM' DofM) + D + <- ekofe-to-ekofi DofM DofiM + <- ekofe-to-ekofi DofM' DofiM' + <- ({x} eqtpe-to-eqtpi (Deqtm x) (Deqtmi x)) + <- eqtpi-ext Deqtmi DofiM DofiM' D. + +-extw : eqtpe-to-eqtpi (eqtpe/extw ([x] Deqtm x) Deqtm') + D + <- eqtpe-to-eqtpi Deqtm' Deqtmi' + <- ({x} eqtpe-to-eqtpi (Deqtm x) (Deqtmi x)) + <- eqtpi-extw Deqtmi Deqtmi' + D. + +-beta : eqtpe-to-eqtpi (eqtpe/beta DofN ([x] DofM x)) + D + <- eofe-to-eofi DofN DofiN + <- ({x} ekofe-to-ekofi (DofM x) (DofiM x)) + <- eqtpi-beta DofiN DofiM D. + +-sym : eqtpe-to-eqtpi (eqtpe/sym Deqtp) + D + <- eqtpe-to-eqtpi Deqtp Deqtpi + <- eqtpi-sym Deqtpi D. + +-trans : eqtpe-to-eqtpi (eqtpe/trans D2 D1) + D + <- eqtpe-to-eqtpi D1 D1i + <- eqtpe-to-eqtpi D2 D2i + <- eqtpi-trans D1i D2i D. + +-refl : eqtpe-to-eqtpi (eqtpe/refl Dof) + D + <- ekofe-to-ekofi Dof Dofi + <- eqtpi-refl Dofi D. + +-kcon : eqtpe-to-eqtpi (eqtpe/kcon Deqtp Deqtm) + D + <- eqtpe-to-eqtpi Deqtm Deqtmi + <- eqkinde-to-eqkindi Deqtp Deqtpi + <- eqtpi-kcon Deqtmi Deqtpi D. + +%% + +-type : eqkinde-to-eqkindi eqkinde/tp D + <- eqkindi-type _ D. + +-pi : eqkinde-to-eqkindi (eqkinde/pi ([x] D2 x) D1) + D + <- eqtpe-to-eqtpi D1 D1i + <- ({x} eqkinde-to-eqkindi (D2 x) (D2i x)) + <- eqkindi-pi D1i D2i D. + +-sym : eqkinde-to-eqkindi (eqkinde/sym Deqtp) + D + <- eqkinde-to-eqkindi Deqtp Deqtpi + <- eqkindi-sym Deqtpi D. + +-trans : eqkinde-to-eqkindi (eqkinde/trans D2 D1) + D + <- eqkinde-to-eqkindi D1 D1i + <- eqkinde-to-eqkindi D2 D2i + <- eqkindi-trans D1i D2i D. + +-refl : eqkinde-to-eqkindi (eqkinde/refl Dof) + D + <- ewfkinde-to-ewfkindi Dof Dofi + <- eqkindi-refl Dofi D. + + +%worlds (ecsig | easig | evar | ebind) + (eofe-to-eofi _ _) + (ekofe-to-ekofi _ _) + (ewfkinde-to-ewfkindi _ _) + (eqtme-to-eqtmi _ _) + (eqtpe-to-eqtpi _ _) + (eqkinde-to-eqkindi _ _). +%total (D1 D2 D3 D4 D5 D6) + (eofe-to-eofi D1 _) + (ekofe-to-ekofi D2 _) + (ewfkinde-to-ewfkindi D3 _) + (eqtme-to-eqtmi D4 _) + (eqtpe-to-eqtpi D5 _) + (eqkinde-to-eqkindi D6 _). + +eofe-to-eof : eofe enil M A -> eof M A -> type. +%mode eofe-to-eof +X1 -X2. + +- : eofe-to-eof D D' + <- eofe-to-eofi D (eofi/nil D'). + +%worlds (ecsig | easig | evar | ebind) (eofe-to-eof _ _). +%total {} (eofe-to-eof _ _). + +ekofe-to-ekof : ekofe enil M A -> ekof M A -> type. +%mode ekofe-to-ekof +X1 -X2. + +- : ekofe-to-ekof D D' + <- ekofe-to-ekofi D (ekofi/nil D'). + +%worlds (ecsig | easig | evar | ebind) (ekofe-to-ekof _ _). +%total {} (ekofe-to-ekof _ _). + +eqtme-to-eqtm : eqtme enil M N A -> eqtm M N A -> type. +%mode eqtme-to-eqtm +X1 -X2. + +- : eqtme-to-eqtm D D' + <- eqtme-to-eqtmi D (eqtmi/nil D'). + +%worlds (ecsig | easig | evar | ebind) (eqtme-to-eqtm _ _). +%total {} (eqtme-to-eqtm _ _). + +eqtpe-to-eqtp : eqtpe enil M N A -> eqtp M N A -> type. +%mode eqtpe-to-eqtp +X1 -X2. + +- : eqtpe-to-eqtp D D' + <- eqtpe-to-eqtpi D (eqtpi/nil D'). + +%worlds (ecsig | easig | evar | ebind) (eqtpe-to-eqtp _ _). +%total {} (eqtpe-to-eqtp _ _). + +eqkinde-to-eqkind : eqkinde enil M N -> eqkind M N -> type. +%mode eqkinde-to-eqkind +X1 -X2. + +- : eqkinde-to-eqkind D D' + <- eqkinde-to-eqkindi D (eqkindi/nil D'). + +%worlds (ecsig | easig | evar | ebind) (eqkinde-to-eqkind _ _). +%total {} (eqkinde-to-eqkind _ _). diff --git a/src/explicit-lemmas.thm b/src/explicit-lemmas.thm new file mode 100644 index 0000000..7c1e319 --- /dev/null +++ b/src/explicit-lemmas.thm @@ -0,0 +1,3760 @@ +%% append %% + + +append-nil : {G} append nil G G -> type. +%mode append-nil +X1 -X2. + +- : append-nil nil append/nil. + +- : append-nil (cons G X A) (append/cons D) + <- append-nil G D. + +%worlds (csig | asig | var) (append-nil _ _). +%total G (append-nil G _). + + + +sappend-nil : {G} sappend snil G G -> type. +%mode sappend-nil +X1 -X2. + +- : sappend-nil snil sappend/nil. + +- : sappend-nil (scons G X A) (sappend/cons D) + <- sappend-nil G D. + +%worlds (csig | asig | var | evar) (sappend-nil _ _). +%total G (sappend-nil G _). + +%% ordered variables %% + +isvar-fun : isvar X I -> isvar X J -> nat-eq I J -> type. +%mode isvar-fun +X1 +X2 -X3. + +- : isvar-fun D D nat-eq/i. + +%worlds (csig | asig | var | ovar) (isvar-fun _ _ _). +%total {} (isvar-fun _ _ _). + + +precedes-trans : precedes X Y -> precedes Y Z -> precedes X Z -> type. +%mode precedes-trans +X1 +X2 -X3. + +- : precedes-trans + (precedes/i DltIJ (DisvarY : isvar Y J) (DisvarX : isvar X I)) + (precedes/i DltJ'K (DisvarZ : isvar Z K) (DisvarY' : isvar Y J')) + (precedes/i DltIK DisvarZ DisvarX) + <- isvar-fun DisvarY DisvarY' (Deq : nat-eq J J') + <- lt-resp nat-eq/i Deq DltIJ DltIJ' + <- lt-trans DltIJ' DltJ'K DltIK. + +%worlds (csig | asig | var | ovar) (precedes-trans _ _ _). +%total {} (precedes-trans _ _ _). + + +precedes-antisymm : precedes X X -> false -> type. +%mode precedes-antisymm +X1 -X2. + +- : precedes-antisymm + (precedes/i (Dlt : lt I J) (Disvar' : isvar X J) (Disvar : isvar X I)) + Dfalse + <- isvar-fun Disvar Disvar' (Deq : nat-eq I J) + <- lt-resp Deq nat-eq/i Dlt (Dlt' : lt J J) + <- lt-antisymm Dlt' Dfalse. + +%worlds (csig | asig | var | ovar) (precedes-antisymm _ _). +%total {} (precedes-antisymm _ _). + + +bounded-increase-bound : bounded G X -> precedes X Y -> bounded G Y -> type. +%mode bounded-increase-bound +X1 +X2 -X3. + +- : bounded-increase-bound (bounded/nil _) (precedes/i _ D _) (bounded/nil D). + +- : bounded-increase-bound (bounded/cons Dbounded Dprecedes) Dprecedes' + (bounded/cons Dbounded Dprecedes'') + <- precedes-trans Dprecedes Dprecedes' Dprecedes''. + +%worlds (csig | asig | bind | var | ovar) (bounded-increase-bound _ _ _). +%total {} (bounded-increase-bound _ _ _). + + + +sbounded-increase-bound : sbounded G X -> precedes X Y -> sbounded G Y -> type. +%mode sbounded-increase-bound +X1 +X2 -X3. + +- : sbounded-increase-bound (sbounded/nil _) (precedes/i _ D _) (sbounded/nil D). + +- : sbounded-increase-bound (sbounded/cons Dbounded Dprecedes) Dprecedes' + (sbounded/cons Dbounded Dprecedes'') + <- precedes-trans Dprecedes Dprecedes' Dprecedes''. + +%worlds (csig | asig | bind | var | ovar | evar) (sbounded-increase-bound _ _ _). +%total {} (sbounded-increase-bound _ _ _). + + +%% inversion to get isvar %% + +bounded-isvar : bounded G X -> isvar X I -> type. +%mode bounded-isvar +X1 -X2. + +- : bounded-isvar (bounded/nil (Disvar : isvar X I) : bounded nil X) + Disvar. + +- : bounded-isvar (bounded/cons _ (precedes/i _ Disvar _)) + Disvar. + +%worlds (csig | asig | var | ovar) (bounded-isvar _ _). +%total D (bounded-isvar D _). + + +lookup-isvar : lookup G X T -> ordered G -> isvar X I -> type. +%mode lookup-isvar +X1 +X2 -X3. + +- : lookup-isvar + (lookup/hit : lookup (cons G X T) X T) + (ordered/cons (Dsbounded : bounded G X) : ordered (cons G X T)) + Disvar + <- bounded-isvar Dsbounded + (Disvar : isvar X I). + +- : lookup-isvar + (lookup/miss (Dslookup)) + (ordered/cons ((bounded/cons Dsbounded _))) + Disvar + <- lookup-isvar Dslookup (ordered/cons Dsbounded) + (Disvar : isvar X I). + +%worlds (csig | asig | var | ovar) (lookup-isvar _ _ _). +%total D (lookup-isvar D _ _). + + +sbounded-isvar : sbounded G X -> isvar X I -> type. +%mode sbounded-isvar +X1 -X2. + +- : sbounded-isvar (sbounded/nil (Disvar : isvar X I) : sbounded snil X) + Disvar. + +- : sbounded-isvar (sbounded/cons _ (precedes/i _ Disvar _)) + Disvar. + +%worlds (csig | asig | var | ovar | evar) (sbounded-isvar _ _). +%total D (sbounded-isvar D _). + + +slookup-isvar : slookup G X T -> sordered G -> isvar X I -> type. +%mode slookup-isvar +X1 +X2 -X3. + +- : slookup-isvar + (slookup/hit : slookup (scons G X T) X T) + (sordered/cons (Dsbounded : sbounded G X) : sordered (scons G X T)) + Disvar + <- sbounded-isvar Dsbounded + (Disvar : isvar X I). + +- : slookup-isvar + (slookup/miss (Dslookup)) + (sordered/cons ((sbounded/cons Dsbounded _))) + Disvar + <- slookup-isvar Dslookup (sordered/cons Dsbounded) + (Disvar : isvar X I). + +%worlds (csig | asig | var | ovar | evar) (slookup-isvar _ _ _). +%total D (slookup-isvar D _ _). + + +%% inversion to get ordered %% + + +ordered-cons : ordered (cons G X A) -> ordered G -> type. +%mode ordered-cons +X1 -X2. + +-nil : ordered-cons + (ordered/cons (bounded/nil Disvar : bounded nil X)) + ordered/nil. + +-cons : ordered-cons + (ordered/cons (bounded/cons Dbound _)) + (ordered/cons Dbound). + +%worlds (csig | asig | var | bind | ovar) (ordered-cons _ _). +%total D (ordered-cons D _). + + +sordered-scons : sordered (scons G X A) -> sordered G -> type. +%mode sordered-scons +X1 -X2. + +-nil : sordered-scons + (sordered/cons (sbounded/nil Disvar : sbounded snil X)) + sordered/nil. + +-cons : sordered-scons + (sordered/cons (sbounded/cons Dbound _)) + (sordered/cons Dbound). + +%worlds (csig | asig | var | bind | ovar | evar) (sordered-scons _ _). +%total D (sordered-scons D _). + +ordered-append : append G1 G2 G -> ordered G + -> ordered G1 -> type. +%mode ordered-append +X1 +X2 -X3. + +-nil : ordered-append + (append/nil : append G nil G) + (Dord : ordered G) + Dord. + +-cons : ordered-append + (append/cons + (Dappend : append G1 G2 G) + : append G1 (cons G2 X A) (cons G X A)) + (Dord : ordered (cons G X A)) + Dord1 + <- ordered-cons Dord (Dord' : ordered G) + <- ordered-append Dappend Dord' + (Dord1 : ordered G1). + +%worlds (csig | asig | var | bind | ovar) (ordered-append _ _ _). +%total D (ordered-append D _ _). + +append-lookup : append (cons G1 X T) G2 G + -> lookup G X T -> type. +%mode append-lookup +X1 -X2. + +- : append-lookup append/nil lookup/hit. + +- : append-lookup (append/cons Dappend) (lookup/miss Dlook) + <- append-lookup Dappend Dlook. + +%worlds (csig | asig | var | ovar) (append-lookup _ _). +%total D (append-lookup D _). + +strengthen-lookup : ({x:atm} lookup G Y (A x)) + -> lookup G Y A' -> ({x} tp-eq (A x) A') -> type. +%mode strengthen-lookup +X1 -X2 -X3. + +- : strengthen-lookup ([_] lookup/hit) lookup/hit ([_] tp-eq/i). + +- : strengthen-lookup ([x] lookup/miss (Dlook x)) + (lookup/miss Dlook') Deq + <- strengthen-lookup Dlook Dlook' Deq. + +%worlds (csig | asig | var | bind | ovar) (strengthen-lookup _ _ _). +%total D (strengthen-lookup D _ _). + + +strengthen-slookup : ({x:atm} slookup G Y T) -> slookup G Y T -> type. +%mode strengthen-slookup +X1 -X2. + +- : strengthen-slookup ([x] slookup/hit) + slookup/hit. + +- : strengthen-slookup ([x] slookup/miss (Dlook x)) + (slookup/miss Dlook') + <- strengthen-slookup Dlook Dlook'. + +%worlds (csig | asig | var | bind | ovar | evar) (strengthen-slookup _ _). +%total D (strengthen-slookup D _). + + + + +slookup-drop : ({x} sappend (scons G1 x S) G2 (G x)) + -> sappend G1 G2 G' + -> ({x} slookup (G x) Y T) +%% + -> slookup G' Y T -> type. +%mode slookup-drop +X1 +X2 +X3 -X4. + +- : slookup-drop + ([x] sappend/cons (Dappend x)) + (sappend/cons Dappend') + ([x] slookup/hit) + (slookup/hit). + +- : slookup-drop + ([_] sappend/nil) + sappend/nil + ([x] slookup/miss (Dlook x)) + Dlook' + <- strengthen-slookup Dlook Dlook'. + +- : slookup-drop + ([x] sappend/cons (Dappend x)) + (sappend/cons Dappend') + ([x] slookup/miss (Dlook x)) + (slookup/miss Dlook') + <- slookup-drop Dappend Dappend' Dlook Dlook'. + +%worlds (csig | asig | var | ovar | evar) (slookup-drop _ _ _ _). +%total D (slookup-drop D _ _ _). + +slookup-drop' : drop ([x] G x) G' -> ({x} slookup (G x) Y T) + -> slookup G' Y T -> type. +%mode slookup-drop' +X1 +X2 -X3. + +- : slookup-drop' + (drop/base (Ddrop : drop ([x] G x) G')) + ([x] slookup/miss (Dlook x : slookup (G x) Y T)) + Dlook' + <- slookup-drop' Ddrop Dlook + (Dlook' : slookup G' Y T). + +- : slookup-drop' + (drop/cons (Ddrop : drop ([x] G x) G')) + ([x] slookup/miss (Dlook x : slookup (G x) Y T)) + (slookup/miss Dlook') + <- slookup-drop' Ddrop Dlook + (Dlook' : slookup G' Y T). + +- : slookup-drop' + (drop/cons (Ddrop : drop ([x] G x) G')) + ([x] slookup/hit) + slookup/hit. + +- : slookup-drop' drop/closed D (D aca). + +%worlds (csig | asig | var | ovar | evar) (slookup-drop' _ _ _). +%total D (slookup-drop' D _ _). + +isvar-vof-contra : isvar X _ -> vof X _ -> false -> type. +%mode isvar-vof-contra +X1 +X2 -X3. +%worlds (csig | asig | bind | var | ovar) (isvar-vof-contra _ _ _). +%total {} (isvar-vof-contra _ _ _). + +isvar-app-contra : isvar (app R M) _ -> false -> type. +%mode isvar-app-contra +X1 -X2. +%worlds (csig | asig | bind | var | ovar) (isvar-app-contra _ _). +%total {} (isvar-app-contra _ _). + +isvar-const-contra : isvar (const C) _ -> false -> type. +%mode isvar-const-contra +X1 -X2. +%worlds (csig | asig | bind | var | ovar) (isvar-const-contra _ _). +%total {} (isvar-const-contra _ _). + +vof-isvar-contra : vof X A -> isvar X I -> false -> type. +%mode vof-isvar-contra +X1 +X2 -X3. +%worlds (csig | asig | bind | var | ovar) (vof-isvar-contra _ _ _). +%total {} (vof-isvar-contra _ _ _). + + +vof-fun : vof X A -> vof X A' -> tp-eq A A' -> type. +%mode vof-fun +X1 +X2 -X3. + +- : vof-fun D D' tp-eq/i. + +%worlds (csig | asig | var | bind | ovar) (vof-fun _ _ _). +%total {} (vof-fun _ _ _). + + +lookup-bounded-contra : lookup G X A -> bounded G X -> false -> type. +%mode lookup-bounded-contra +X1 +X2 -X3. + +- : lookup-bounded-contra lookup/hit (bounded/cons _ Dprec) Dfalse + <- precedes-antisymm Dprec Dfalse. + +- : lookup-bounded-contra (lookup/miss Dlook) (bounded/cons Dbound Dprec) + Dfalse + <- bounded-increase-bound Dbound Dprec Dbound' + <- lookup-bounded-contra Dlook Dbound' Dfalse. + +%worlds (csig | asig | var | ovar) (lookup-bounded-contra _ _ _). +%total D (lookup-bounded-contra D _ _). + + + + +slookup-sbounded-contra : slookup G X T -> sbounded G X -> false -> type. +%mode slookup-sbounded-contra +X1 +X2 -X3. + +- : slookup-sbounded-contra slookup/hit (sbounded/cons _ Dprec) Dfalse + <- precedes-antisymm Dprec Dfalse. + +- : slookup-sbounded-contra (slookup/miss Dlook) (sbounded/cons Dbound Dprec) + Dfalse + <- sbounded-increase-bound Dbound Dprec Dbound' + <- slookup-sbounded-contra Dlook Dbound' Dfalse. + +%worlds (csig | asig | var | ovar | evar) (slookup-sbounded-contra _ _ _). +%total D (slookup-sbounded-contra D _ _). + + +lookup-fun : ordered G + -> lookup G X A + -> lookup G X A' +%% + -> tp-eq A A' -> type. +%mode lookup-fun +X0 +X1 +X2 -X3. + +- : lookup-fun _ _ _ tp-eq/i. + +- : lookup-fun + (Dord : ordered (cons G Y S)) + (lookup/miss (Dlook : lookup G X A) : lookup (cons G Y S) X A) + (lookup/miss (Dlook' : lookup G X A') : lookup (cons G Y S) X A') +%% + Deq +%% + <- ordered-cons Dord + (Dord' : ordered G) + <- lookup-fun Dord' Dlook Dlook' + (Deq : tp-eq A A'). + +- : lookup-fun + (ordered/cons (Dbound : bounded G Y) : ordered (cons G Y S)) + (lookup/miss (Dlook : lookup G Y A)) + lookup/hit +%% + Deq +%% + <- lookup-bounded-contra Dlook Dbound Dfalse + <- false-implies-tp-eq Dfalse Deq. + +- : lookup-fun + (ordered/cons (Dbound : bounded G Y) : ordered (cons G Y S)) + lookup/hit + (lookup/miss (Dlook : lookup G Y A)) +%% + Deq +%% + <- lookup-bounded-contra Dlook Dbound Dfalse + <- false-implies-tp-eq Dfalse Deq. + +%worlds (csig | asig | var | ovar) (lookup-fun _ _ _ _). +%total D (lookup-fun _ D _ _). + + +slookup-fun : sordered G + -> slookup G X T + -> slookup G X T' +%% + -> stp-eq T T' -> type. +%mode slookup-fun +X0 +X1 +X2 -X3. + +- : slookup-fun _ _ _ stp-eq/i. + +- : slookup-fun + (Dord : sordered (scons G Y S)) + (slookup/miss (Dlook : slookup G X T) : slookup (scons G Y S) X T) + (slookup/miss (Dlook' : slookup G X T') : slookup (scons G Y S) X T') +%% + Deq +%%% + <- sordered-scons Dord + (Dord' : sordered G) + <- slookup-fun Dord' Dlook Dlook' + (Deq : stp-eq T T'). + +- : slookup-fun + (sordered/cons (Dbound : sbounded G Y) : sordered (scons G Y S)) + (slookup/miss (Dlook : slookup G Y T)) + slookup/hit +%% + Deq +%%% + <- slookup-sbounded-contra Dlook Dbound Dfalse + <- false-implies-stp-eq Dfalse Deq. + +- : slookup-fun + (sordered/cons (Dbound : sbounded G Y) : sordered (scons G Y S)) + slookup/hit + (slookup/miss (Dlook : slookup G Y T)) +%% + Deq +%%% + <- slookup-sbounded-contra Dlook Dbound Dfalse + <- false-implies-stp-eq Dfalse Deq. + +%worlds (csig | asig | var | ovar | evar) (slookup-fun _ _ _ _). +%total D (slookup-fun _ D _ _). + + +%% preserving orderedness/boundedness %% + +extend-ordered : {A} + ordered G + -> {I} + ({x:atm} isvar x I -> ordered (cons G x A)) + -> type. +%mode extend-ordered +X1 +X2 -X3 -X4. + +- : extend-ordered _ ordered/nil + 0 ([x] [d] ordered/cons (bounded/nil d)). + +- : extend-ordered _ (ordered/cons (bounded/nil (DisvarY : isvar Y I))) + (s I) ([x] [d] ordered/cons + (bounded/cons (bounded/nil DisvarY) (precedes/i Dlt d DisvarY))) + <- lt-succ I Dlt. + +- : extend-ordered _ + (ordered/cons (bounded/cons D1 (precedes/i D2 (DisvarY:isvar Y I) D3))) + (s I) ([x] [d] ordered/cons + (bounded/cons (bounded/cons D1 (precedes/i D2 (DisvarY:isvar Y I) D3)) + (precedes/i Dlt d DisvarY))) + <- lt-succ I Dlt. + +%worlds (csig | asig | var | bind | ovar) (extend-ordered _ _ _ _). +%total {} (extend-ordered _ _ _ _). + + +extend-sordered : {A} + sordered G + -> {I} + ({x:atm} isvar x I -> sordered (scons G x A)) + -> type. +%mode extend-sordered +X1 +X2 -X3 -X4. + +- : extend-sordered _ sordered/nil + 0 ([x] [d] sordered/cons (sbounded/nil d)). + +- : extend-sordered _ (sordered/cons (sbounded/nil (DisvarY : isvar Y I))) + (s I) ([x] [d] sordered/cons + (sbounded/cons (sbounded/nil DisvarY) (precedes/i Dlt d DisvarY))) + <- lt-succ I Dlt. + +- : extend-sordered _ + (sordered/cons (sbounded/cons D1 (precedes/i D2 (DisvarY:isvar Y I) D3))) + (s I) ([x] [d] sordered/cons + (sbounded/cons (sbounded/cons D1 (precedes/i D2 (DisvarY:isvar Y I) D3)) + (precedes/i Dlt d DisvarY))) + <- lt-succ I Dlt. + +%worlds (csig | asig | var | bind | ovar | evar) (extend-sordered _ _ _ _). +%total {} (extend-sordered _ _ _ _). + + +%%% metrics on typing derivations %%% +% needed for cut-of and cut-ofe because we'd like to induct on the term itself, +% but sometimes we make an inductive call on its type, so we really need a +% common metric for of and ofe typing derivations. + +metric : type. %name metric Mm. + +munit : metric. +msing : metric -> metric. +mpair : metric -> metric -> metric. + +mof : of M A -> metric -> type. +matof : at-of R A -> metric -> type. +mkof : kof A K -> metric -> type. +matkof : at-kof P K -> metric -> type. +mwfkind : wfkind K -> metric -> type. + +mof/at : mof (of/at Datof) (msing Datof') + <- matof Datof Datof'. + +mof/lam : mof (of/lam Dkof ([x] [d] Dof x d)) (mpair Dof' Dkof') + <- mkof Dkof Dkof' + <- ({x} {d} mof (Dof x d) Dof'). + +matof/const : matof (at-of/const Dkof _) (msing Dkof') + <- mkof Dkof Dkof'. + +matof/var : matof (at-of/var Dkof _) (msing Dkof') + <- mkof Dkof Dkof'. + +matof/app : matof (at-of/app _ Dof Datof) (mpair Dof' Datof') + <- mof Dof Dof' + <- matof Datof Datof'. + +mkof/base : mkof (kof/base Datkof) (msing Datkof') + <- matkof Datkof Datkof'. + +mkof/pi : mkof (kof/pi ([x] [d] Dkof2 x d) Dkof1) (mpair Dkof2' Dkof1') + <- mkof Dkof1 Dkof1' + <- ({x} {d} mkof (Dkof2 x d) Dkof2'). + +mkof/lam : mkof (kof/lam ([x] [d] Dkof2 x d) Dkof1) + (mpair Dkof2' Dkof1') + <- mkof Dkof1 Dkof1' + <- ({x} {d} mkof (Dkof2 x d) Dkof2'). + +matkof/const : matkof (at-kof/const Dwfkind _) (msing Dwfkind') + <- mwfkind Dwfkind Dwfkind'. + +matkof/app : matkof (at-kof/app _ Dof Datkof) (mpair Dof' Datkof') + <- mof Dof Dof' + <- matkof Datkof Datkof'. + +mwfkind/tp : mwfkind wfkind/tp munit. + +mwfkind/pi : mwfkind (wfkind/pi ([x] [d] Dwfkind x d) Dkof) + (mpair Dwfkind' Dkof') + <- ({x} {d} mwfkind (Dwfkind x d) Dwfkind') + <- mkof Dkof Dkof'. + + +can-matof : {D:at-of R A} matof D Rm -> type. +%mode can-matof +X1 -X2. + +can-mof : {D:of M A} mof D Mm -> type. +%mode can-mof +X1 -X2. + +can-matkof : {D:at-kof P K} matkof D Pm -> type. +%mode can-matkof +X1 -X2. + +can-mkof : {D:kof A K} mkof D Am -> type. +%mode can-mkof +X1 -X2. + +can-mwfkind : {D:wfkind K} mwfkind D Km -> type. +%mode can-mwfkind +X1 -X2. + + +- : can-matof (at-of/const D _) (matof/const D') + <- can-mkof D D'. + +- : can-matof (at-of/var D _) (matof/var D') + <- can-mkof D D'. + +- : can-matof (at-of/app _ Dof Datof) (matof/app Datof' Dof') + <- can-matof Datof Datof' + <- can-mof Dof Dof'. + +- : can-mof (of/at D) (mof/at D') + <- can-matof D D'. + +- : can-mof (of/lam D1 D2) (mof/lam D2' D1') + <- can-mkof D1 D1' + <- ({x} {d} can-mof (D2 x d) (D2' x d)). + +- : can-matkof (at-kof/const D _) (matkof/const D') + <- can-mwfkind D D'. + +- : can-matkof (at-kof/app _ Dof Datkof) (matkof/app Datkof' Dof') + <- can-mof Dof Dof' + <- can-matkof Datkof Datkof'. + +- : can-mkof (kof/base Datkof) (mkof/base Datkof') + <- can-matkof Datkof Datkof'. + +- : can-mkof (kof/pi D2 D1) (mkof/pi D2' D1') + <- can-mkof D1 D1' + <- ({x} {d} can-mkof (D2 x d) (D2' x d)). + +- : can-mkof (kof/lam D2 D1) (mkof/lam D2' D1') + <- can-mkof D1 D1' + <- ({x} {d} can-mkof (D2 x d) (D2' x d)). + +- : can-mwfkind wfkind/tp mwfkind/tp. + +- : can-mwfkind (wfkind/pi D2 D1) (mwfkind/pi D1' D2') + <- can-mkof D1 D1' + <- ({x} {d} can-mwfkind (D2 x d) (D2' x d)). + + +%worlds (csig | asig | var | bind) + (can-matof _ _) + (can-mof _ _) + (can-matkof _ _) + (can-mkof _ _) + (can-mwfkind _ _). +%total (D1 D2 D3 D4 D5) + (can-matof D1 _) + (can-mof D2 _) + (can-matkof D3 _) + (can-mkof D4 _) + (can-mwfkind D5 _). + + +%% metrics for explicit contexts typing + +matofe : at-ofe G R A -> metric -> type. +mofe : ofe G M A -> metric -> type. +matkofe : at-kofe G P K -> metric -> type. +mkofe : kofe G A K -> metric -> type. +mwfkinde : wfkinde G K -> metric -> type. + +matofe/closed : matofe (at-ofe/closed Datof) Datof' + <- matof Datof Datof'. + +matofe/const : matofe (at-ofe/const Dkofe _) (msing Dkofe') + <- mkofe Dkofe Dkofe'. + +matofe/var : matofe (at-ofe/var Dkof _) (msing Dkof') + <- mkofe Dkof Dkof'. + +matofe/app : matofe (at-ofe/app _ Dofe Datofe) (mpair Dofe' Datofe') + <- mofe Dofe Dofe' + <- matofe Datofe Datofe'. + +mofe/at : mofe (ofe/at Datofe) (msing Datofe') + <- matofe Datofe Datofe'. + +mofe/lam : mofe (ofe/lam Dkofe ([x] Dofe x)) (mpair Dofe' Dkofe') + <- mkofe Dkofe Dkofe' + <- ({x} mofe (Dofe x) Dofe'). + +matkofe/const : matkofe (at-kofe/const Dwfkinde _) (msing Dwfkinde') + <- mwfkinde Dwfkinde Dwfkinde'. + +matkofe/closed : matkofe (at-kofe/closed Datkof) Datkof' + <- matkof Datkof Datkof'. + +matkofe/app : matkofe (at-kofe/app _ Dofe Datkofe) (mpair Dofe' Datkofe') + <- mofe Dofe Dofe' + <- matkofe Datkofe Datkofe'. + +mkofe/base : mkofe (kofe/base Datkofe) (msing Datkofe') + <- matkofe Datkofe Datkofe'. + +mkofe/pi : mkofe (kofe/pi ([x] DkofeB x) DkofeA) (mpair DkofeB' DkofeA') + <- ({x} mkofe (DkofeB x) DkofeB') + <- mkofe DkofeA DkofeA'. + +mkofe/lam : mkofe (kofe/lam ([x] D2 x) D1) (mpair D2' D1') + <- mkofe D1 D1' + <- ({x} mkofe (D2 x) D2'). + +mwfkinde/tp : mwfkinde wfkinde/tp munit. + +mwfkinde/pi : mwfkinde (wfkinde/pi ([x] Dwfkinde x) Dkofe) + (mpair Dwfkinde' Dkofe') + <- ({x} mwfkinde (Dwfkinde x) Dwfkinde') + <- mkofe Dkofe Dkofe'. + +%% can-mofe + +can-matofe : {D:at-ofe G R A} matofe D Rm -> type. +%mode can-matofe +X1 -X2. + +can-mofe : {D:ofe G M A} mofe D Mm -> type. +%mode can-mofe +X1 -X2. + +can-matkofe : {D:at-kofe G P K} matkofe D Pm -> type. +%mode can-matkofe +X1 -X2. + +can-mkofe : {D:kofe G A K} mkofe D Am -> type. +%mode can-mkofe +X1 -X2. + +can-mwfkinde : {D:wfkinde G K} mwfkinde D Km -> type. +%mode can-mwfkinde +X1 -X2. + + +- : can-matofe (at-ofe/const D _) (matofe/const D') + <- can-mkofe D D'. + +- : can-matofe (at-ofe/closed D) (matofe/closed Dmatof) + <- can-matof D Dmatof. + +- : can-matofe (at-ofe/var D _) (matofe/var D') + <- can-mkofe D D'. + +- : can-matofe (at-ofe/app _ Dof Datof) (matofe/app Datof' Dof') + <- can-matofe Datof Datof' + <- can-mofe Dof Dof'. + +- : can-mofe (ofe/at D) (mofe/at D') + <- can-matofe D D'. + +- : can-mofe (ofe/lam D1 D2) (mofe/lam D2' D1') + <- can-mkofe D1 D1' + <- ({x} can-mofe (D2 x) (D2' x)). + +- : can-matkofe (at-kofe/const D _) (matkofe/const D') + <- can-mwfkinde D D'. + +- : can-matkofe (at-kofe/closed D) (matkofe/closed D') + <- can-matkof D D'. + +- : can-matkofe (at-kofe/app _ Dof Datkof) (matkofe/app Datkof' Dof') + <- can-mofe Dof Dof' + <- can-matkofe Datkof Datkof'. + +- : can-mkofe (kofe/base Datkof) (mkofe/base Datkof') + <- can-matkofe Datkof Datkof'. + +- : can-mkofe (kofe/pi D2 D1) (mkofe/pi D1' D2') + <- can-mkofe D1 D1' + <- ({x} can-mkofe (D2 x) (D2' x)). + +- : can-mkofe (kofe/lam D2 D1) (mkofe/lam D2' D1') + <- can-mkofe D1 D1' + <- ({x} can-mkofe (D2 x) (D2' x)). + +- : can-mwfkinde wfkinde/tp mwfkinde/tp. + +- : can-mwfkinde (wfkinde/pi D2 D1) (mwfkinde/pi D1' D2') + <- can-mkofe D1 D1' + <- ({x} can-mwfkinde (D2 x) (D2' x)). + + +%worlds (csig | asig | var | bind) + (can-matofe _ _) + (can-mofe _ _) + (can-matkofe _ _) + (can-mkofe _ _) + (can-mwfkinde _ _). +%total (D1 D2 D3 D4 D5) + (can-matofe D1 _) + (can-mofe D2 _) + (can-matkofe D3 _) + (can-mkofe D4 _) + (can-mwfkinde D5 _). + + + + +%% respects lemmas %% + +matof-resp : atm-eq R R' + -> tp-eq A A' + -> {D:at-of R A} + matof D Rm +%% + -> {D':at-of R' A'} + matof D' Rm -> type. +%mode matof-resp +X1 +X2 +X3 +X4 -X5 -X6. + +- : matof-resp atm-eq/i tp-eq/i D Dm D Dm. + +%worlds (csig | asig | var | bind) (matof-resp _ _ _ _ _ _). +%total {} (matof-resp _ _ _ _ _ _). + + +matkof-resp : atp-eq P P' + -> kind-eq K K' + -> {D:at-kof P K} + matkof D Pm +%% + -> {D':at-kof P' K'} + matkof D' Pm -> type. +%mode matkof-resp +X1 +X2 +X3 +X4 -X5 -X6. + +- : matkof-resp atp-eq/i kind-eq/i D Dm D Dm. + +%worlds (csig | asig | var | bind) (matkof-resp _ _ _ _ _ _). +%total {} (matkof-resp _ _ _ _ _ _). + + +mof-resp : tm-eq M M' + -> tp-eq A A' + -> {D:of M A} + mof D Mm +%% + -> {D':of M A'} + mof D' Mm -> type. +%mode mof-resp +X1 +X2 +X3 +X4 -X5 -X6. + +- : mof-resp tm-eq/i tp-eq/i D Dm D Dm. + +%worlds (csig | asig | var | bind) (mof-resp _ _ _ _ _ _). +%total {} (mof-resp _ _ _ _ _ _). + + +mkof-resp : tp-eq A A' + -> kind-eq K K' + -> {D:kof A K} mkof D Am +%% + -> {D':kof A' K'} mkof D' Am -> type. +%mode mkof-resp +X0 +X1 +X2 +X3 -X4 -X5. + +- : mkof-resp tp-eq/i kind-eq/i D Dm D Dm. + +%worlds (csig | asig | var | bind) (mkof-resp _ _ _ _ _ _). +%total {} (mkof-resp _ _ _ _ _ _). + + +mwfkind-resp : kind-eq K K' -> {D:wfkind K} mwfkind D Km + -> {D':wfkind K'} mwfkind D' Km -> type. +%mode mwfkind-resp +X1 +X2 +X3 -X4 -X5. + +- : mwfkind-resp kind-eq/i D Dm D Dm. + +%worlds (csig | asig | var | bind) (mwfkind-resp _ _ _ _ _). +%total {} (mwfkind-resp _ _ _ _ _). + + + +%%% weakening %%% + + +weaken-lookup : lookup G Y A -> {X} {B} lookup (cons G X B) Y A -> type. +%mode weaken-lookup +X1 +X2 +X3 -X4. + +- : weaken-lookup Dlook _ _ (lookup/miss Dlook). + +%worlds (csig | asig | bind | ovar | var) (weaken-lookup _ _ _ _). +%total {} (weaken-lookup _ _ _ _). + + +weaken-lookup' : append G1 G2 G -> lookup G1 X A -> lookup G X A -> type. +%mode weaken-lookup' +X1 +X2 -X3. + +- : weaken-lookup' append/nil D D. + +- : weaken-lookup' + (append/cons (Dapp : append G1 G2' G')) + (Dlook : lookup G1 X A) +%% + Dlook'' + <- weaken-lookup' Dapp Dlook Dlook' + <- weaken-lookup Dlook' _ _ Dlook''. + +%worlds (csig | asig | bind | ovar | var) (weaken-lookup' _ _ _). +%total D (weaken-lookup' D _ _). + + +weakeng-lookup : append G1 G2 G -> append (cons G1 X B) G2 G' -> lookup G Y A +%% + -> lookup G' Y A -> type. +%mode weakeng-lookup +X1 +X2 +X3 -X4. + +-hit : weakeng-lookup + (append/cons _) + (append/cons _) + lookup/hit +%% + lookup/hit. + +-miss : weakeng-lookup + (append/cons Dapp1) + (append/cons Dapp2) + (lookup/miss Dlook) +%% + (lookup/miss Dlook') +%%% + <- weakeng-lookup Dapp1 Dapp2 Dlook Dlook'. + +-nil : weakeng-lookup append/nil append/nil Dlook +%% + (lookup/miss Dlook). + + +%worlds (csig | asig | var | bind) (weakeng-lookup _ _ _ _). +%total D (weakeng-lookup _ _ D _). + + +weakeng-atofe-m : {Rm} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:at-ofe G R A} + matofe D Rm +%% + -> {D':at-ofe G' R A} + matofe D' Rm -> type. +%mode weakeng-atofe-m +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +weakeng-ofe-m : {Mm} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:ofe G M A} + mofe D Mm +%% + -> {D':ofe G' M A} + mofe D' Mm -> type. +%mode weakeng-ofe-m +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +weakeng-atkofe-m : {Pm} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:at-kofe G P K} + matkofe D Pm +%% + -> {D':at-kofe G' P K} + matkofe D' Pm -> type. +%mode weakeng-atkofe-m +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +weakeng-kofe-m : {Am} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:kofe G A K} + mkofe D Am +%% + -> {D':kofe G' A K} + mkofe D' Am -> type. +%mode weakeng-kofe-m +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +weakeng-wfkinde-m : {Km} + append G1 G2 G + -> append (cons G1 X B) G2 G' + -> {D:wfkinde G A} + mwfkinde D Km +%% + -> {D':wfkinde G' A} + mwfkinde D' Km -> type. +%mode weakeng-wfkinde-m +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +-closed : weakeng-atofe-m Rm + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (at-ofe/closed (Datof : at-of R A)) + (matofe/closed (Dmatof : matof Datof Rm)) +%% + (at-ofe/closed Datof) + (matofe/closed Dmatof). + +-const : weakeng-atofe-m (msing Am) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (at-ofe/const (Dkofe : kofe G A ktype) (Dcof : cof C A)) + (matofe/const (Dmkofe : mkofe Dkofe Am)) +%% + (at-ofe/const Dkofe' Dcof) + (matofe/const Dmkofe') +%%% + <- weakeng-kofe-m Am Dappend Dappend' Dkofe Dmkofe + (Dkofe' : kofe G' A ktype) + (Dmkofe' : mkofe Dkofe' Am). + +-var : weakeng-atofe-m (msing Am) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (at-ofe/var (Dkofe : kofe G A ktype) (Dlookup : lookup G Y A)) + (matofe/var (Dmkofe : mkofe Dkofe Am)) +%% + (at-ofe/var Dkofe' Dlookup') + (matofe/var Dmkofe') +%%% + <- weakeng-lookup Dappend Dappend' Dlookup + (Dlookup' : lookup G' Y A) + <- weakeng-kofe-m Am Dappend Dappend' Dkofe Dmkofe + (Dkofe' : kofe G' A ktype) + (Dmkofe' : mkofe Dkofe' Am). + +-app : weakeng-atofe-m (mpair Mm Rm) %% G, x:B |- app (R:C) (M:A) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (at-ofe/app + (Dsub : tpsub ([x] C x) M C') + (Dofe : ofe G M A) + (Datofe : at-ofe G R (pi A ([x] C x)))) + (matofe/app + (Dmatofe : matofe Datofe Rm) + (Dmofe : mofe Dofe Mm)) +%% + (at-ofe/app Dsub Dofe' Datofe') + (matofe/app Dmatofe' Dmofe') +%%% + <- weakeng-atofe-m Rm Dappend Dappend' Datofe Dmatofe + (Datofe' : at-ofe G' R (pi A ([x] C x))) + (Dmatofe' : matofe Datofe' Rm) + <- weakeng-ofe-m Mm Dappend Dappend' Dofe Dmofe + (Dofe' : ofe G' M A) + (Dmofe' : mofe Dofe' Mm). + +-at : weakeng-ofe-m (msing Rm) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (ofe/at (Datofe : at-ofe G R (base P))) + (mofe/at (Dmatofe : matofe Datofe Rm)) +%% + (ofe/at Datofe') + (mofe/at Dmatofe') +%%% + <- weakeng-atofe-m Rm Dappend Dappend' Datofe Dmatofe + (Datofe' : at-ofe G' R (base P)) + (Dmatofe' : matofe Datofe' Rm). + +-lam : weakeng-ofe-m (mpair Mm Am) %% G, X:B |- \x.M : {X:A} C + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (ofe/lam + (Dkofe : kofe G A ktype) + ([x] Dofe x : ofe (cons G x A) (M x) (C x))) + (mofe/lam + ([x] Dmofe x : mofe (Dofe x) Mm) + (Dmkofe : mkofe Dkofe Am)) +%% + (ofe/lam Dkofe' ([x] Dofe' x)) + (mofe/lam ([x] Dmofe' x) Dmkofe') +%% + <- weakeng-kofe-m Am Dappend Dappend' Dkofe Dmkofe + (Dkofe' : kofe G' A ktype) + (Dmkofe' : mkofe Dkofe' Am) + <- ({x} + weakeng-ofe-m + Mm + (append/cons Dappend) + (append/cons Dappend') + (Dofe x) + (Dmofe x) + (Dofe' x : ofe (cons G' x A) (M x) (C x)) + (Dmofe' x : mofe (Dofe' x) Mm)). + +-aconst : weakeng-atkofe-m (msing Km) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (at-kofe/const + (Dwfkinde : wfkinde G K) + (Dckof : ckof P K)) + (matkofe/const + (Dmwfkinde : mwfkinde Dwfkinde Km)) +%% + (at-kofe/const Dwfkinde' Dckof) + (matkofe/const Dmwfkinde') +%%% + <- weakeng-wfkinde-m Km Dappend Dappend' Dwfkinde Dmwfkinde + (Dwfkinde' : wfkinde G' K) + (Dmwfkinde' : mwfkinde Dwfkinde' Km). + +-aclosed : weakeng-atkofe-m Pm + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (at-kofe/closed + (Datkof : at-kof P K)) + (matkofe/closed + (Dmatkof : matkof Datkof Pm)) +%% + (at-kofe/closed Datkof) + (matkofe/closed Dmatkof). + +-aapp : weakeng-atkofe-m (mpair Mm Pm) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (at-kofe/app + (Dksub : ksub ([x] K x) M K') + (Dofe : ofe G M A) + (Datkofe : at-kofe G P (kpi A [x] K x))) + (matkofe/app + (Dmatkofe : matkofe Datkofe Pm) + (Dmofe : mofe Dofe Mm)) +%% + (at-kofe/app Dksub Dofe' Datkofe') + (matkofe/app Dmatkofe' Dmkofe') +%%% + <- weakeng-atkofe-m Pm Dappend Dappend' Datkofe Dmatkofe + (Datkofe' : at-kofe G' P (kpi A [x] K x)) + (Dmatkofe' : matkofe Datkofe' Pm) + <- weakeng-ofe-m Mm Dappend Dappend' Dofe Dmofe + (Dofe' : ofe G' M A) + (Dmkofe' : mofe Dofe' Mm). + +-base : weakeng-kofe-m (msing Pm) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (kofe/base + (Datkofe : at-kofe G P ktype)) + (mkofe/base + (Dmatkofe : matkofe Datkofe Pm)) +%% + (kofe/base Datkofe') + (mkofe/base Dmatkofe') +%%% + <- weakeng-atkofe-m Pm Dappend Dappend' Datkofe Dmatkofe + (Datkofe' : at-kofe G' P ktype) + (Dmatkofe' : matkofe Datkofe' Pm). + +-pi : weakeng-kofe-m (mpair Cm Am) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (kofe/pi + ([x] DkofeC x : kofe (cons G x A) (C x) ktype) + (DkofeA : kofe G A ktype)) + (mkofe/pi + (DmkofeA : mkofe DkofeA Am) + ([x] DmkofeC x : mkofe (DkofeC x) Cm)) +%% + (kofe/pi ([x] DkofeC' x) DkofeA') + (mkofe/pi DmkofeA' ([x] DmkofeC' x)) +%%% + <- weakeng-kofe-m Am Dappend Dappend' DkofeA DmkofeA + (DkofeA' : kofe G' A ktype) + (DmkofeA' : mkofe DkofeA' Am) + <- ({x} + weakeng-kofe-m Cm (append/cons Dappend) (append/cons Dappend') + (DkofeC x) (DmkofeC x) + (DkofeC' x : kofe (cons G' x A) (C x) ktype) + (DmkofeC' x : mkofe (DkofeC' x) Cm)). + +-alam : weakeng-kofe-m (mpair Cm Am) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (kofe/lam + ([x] DkofeC x : kofe (cons G x A) (C x) (K x)) + (DkofeA : kofe G A ktype)) + (mkofe/lam + ([x] DmkofeC x : mkofe (DkofeC x) Cm) + (DmkofeA : mkofe DkofeA Am)) +%% + (kofe/lam ([x] DkofeC' x) DkofeA') + (mkofe/lam ([x] DmkofeC' x) DmkofeA') +%% + <- weakeng-kofe-m Am Dappend Dappend' DkofeA DmkofeA + (DkofeA' : kofe G' A ktype) + (DmkofeA' : mkofe DkofeA' Am) + <- ({x} + weakeng-kofe-m Cm + (append/cons Dappend) (append/cons Dappend') + (DkofeC x) + (DmkofeC x) + (DkofeC' x : kofe (cons G' x A) (C x) (K x)) + (DmkofeC' x : mkofe (DkofeC' x) Cm)). + +-ktype : weakeng-wfkinde-m munit Dappend Dappend' wfkinde/tp mwfkinde/tp + wfkinde/tp mwfkinde/tp. + +-kpi : weakeng-wfkinde-m (mpair Km Am) + (Dappend : append G1 G2 G) + (Dappend' : append (cons G1 X B) G2 G') + (wfkinde/pi + ([x] Dwfkinde x : wfkinde (cons G x A) (K x)) + (Dkofe : kofe G A ktype)) + (mwfkinde/pi + (Dmkofe : mkofe Dkofe Am) + ([x] Dmwfkinde x : mwfkinde (Dwfkinde x) Km)) +%% + (wfkinde/pi ([x] Dwfkinde' x) Dkofe') + (mwfkinde/pi Dmkofe' ([x] Dmwfkinde' x)) +%%% + <- weakeng-kofe-m Am Dappend Dappend' Dkofe Dmkofe + (Dkofe' : kofe G' A ktype) + (Dmkofe' : mkofe Dkofe' Am) + <- ({x} + weakeng-wfkinde-m Km (append/cons Dappend) (append/cons Dappend') + (Dwfkinde x) (Dmwfkinde x) + (Dwfkinde' x : wfkinde (cons G' x A) (K x)) + (Dmwfkinde' x : mwfkinde (Dwfkinde' x) Km)). + +%worlds (csig | asig | var | bind) + (weakeng-atofe-m _ _ _ _ _ _ _) + (weakeng-ofe-m _ _ _ _ _ _ _) + (weakeng-atkofe-m _ _ _ _ _ _ _) + (weakeng-kofe-m _ _ _ _ _ _ _) + (weakeng-wfkinde-m _ _ _ _ _ _ _). +%total (Rm Mm Pm Am Km) + (weakeng-atofe-m Rm _ _ _ _ _ _) + (weakeng-ofe-m Mm _ _ _ _ _ _) + (weakeng-atkofe-m Pm _ _ _ _ _ _) + (weakeng-kofe-m Am _ _ _ _ _ _) + (weakeng-wfkinde-m Km _ _ _ _ _ _). + + +weakeng-ofe : append G1 G2 G + -> append (cons G1 X B) G2 G' + -> ofe G M A +%% + -> ofe G' M A -> type. +%mode weakeng-ofe +X1 +X2 +X3 -X4. + +- : weakeng-ofe Dappend Dappend' Dof Dof' + <- can-mofe Dof Dmof + <- weakeng-ofe-m _ Dappend Dappend' Dof Dmof Dof' _. + +%worlds (csig | asig | var | ovar | bind) (weakeng-ofe _ _ _ _). +%total {} (weakeng-ofe _ _ _ _). + + +weakeng-atofe : append G1 G2 G + -> append (cons G1 X B) G2 G' + -> at-ofe G R A +%% + -> at-ofe G' R A -> type. +%mode weakeng-atofe +X1 +X2 +X3 -X4. + +- : weakeng-atofe Dappend Dappend' Dof Dof' + <- can-matofe Dof Dmof + <- weakeng-atofe-m _ Dappend Dappend' Dof Dmof Dof' _. + +%worlds (csig | asig | var | ovar | bind) (weakeng-atofe _ _ _ _). +%total {} (weakeng-atofe _ _ _ _). + + + +weakeng-kofe : append G1 G2 G + -> append (cons G1 X B) G2 G' + -> kofe G A K +%% + -> kofe G' A K -> type. +%mode weakeng-kofe +X1 +X2 +X3 -X4. + +- : weakeng-kofe Dappend Dappend' Dof Dof' + <- can-mkofe Dof Dmof + <- weakeng-kofe-m _ Dappend Dappend' Dof Dmof Dof' _. + +%worlds (csig | asig | var | ovar | bind) (weakeng-kofe _ _ _ _). +%total {} (weakeng-kofe _ _ _ _). + + +weakeng-atkofe : append G1 G2 G + -> append (cons G1 X B) G2 G' + -> at-kofe G R A +%% + -> at-kofe G' R A -> type. +%mode weakeng-atkofe +X1 +X2 +X3 -X4. + +- : weakeng-atkofe Dappend Dappend' Dof Dof' + <- can-matkofe Dof Dmof + <- weakeng-atkofe-m _ Dappend Dappend' Dof Dmof Dof' _. + +%worlds (csig | asig | var | ovar | bind) (weakeng-atkofe _ _ _ _). +%total {} (weakeng-atkofe _ _ _ _). + + +weakeng-wfkinde : append G1 G2 G + -> append (cons G1 X B) G2 G' + -> wfkinde G K +%% + -> wfkinde G' K -> type. +%mode weakeng-wfkinde +X1 +X2 +X3 -X4. + +- : weakeng-wfkinde Dappend Dappend' Dof Dof' + <- can-mwfkinde Dof Dmof + <- weakeng-wfkinde-m _ Dappend Dappend' Dof Dmof Dof' _. + +%worlds (csig | asig | var | ovar | bind) (weakeng-wfkinde _ _ _ _). +%total {} (weakeng-wfkinde _ _ _ _). + + + + +weaken-ofe : ofe G M A -> {B} {X} + ofe (cons G X B) M A -> type. +%mode weaken-ofe +X1 +X2 +X3 -X4. + +- : weaken-ofe (Dofe : ofe G M A) B X + Dofe' + <- weakeng-ofe + (append/nil : append G nil G) + (append/nil : append (cons G X B) nil (cons G X B)) + Dofe + (Dofe' : ofe (cons G X B) M A). + +%worlds (csig | asig | var | bind) (weaken-ofe _ _ _ _). +%total {} (weaken-ofe _ _ _ _). + + +weaken-atofe : at-ofe G R A -> {B} {X} +%% + at-ofe (cons G X B) R A -> type. +%mode weaken-atofe +X1 +X2 +X3 -X4. + +- : weaken-atofe + (Datofe : at-ofe G R A) B X +%% + Datofe' +%% + <- weakeng-atofe + (append/nil : append G nil G) + (append/nil : append (cons G X B) nil (cons G X B)) + Datofe + (Datofe' : at-ofe (cons G X B) R A). + +%worlds (csig | asig | var | bind) (weaken-atofe _ _ _ _). +%total {} (weaken-atofe _ _ _ _). + + +weaken-kofe : kofe G A K -> {B} {X} +%% + kofe (cons G X B) A K -> type. +%mode weaken-kofe +X1 +X2 +X3 -X4. + +- : weaken-kofe (Dkofe : kofe G A K) B X +%% + Dkofe' +%% + <- weakeng-kofe + (append/nil : append G nil G) + (append/nil : append (cons G X B) nil (cons G X B)) + Dkofe + (Dkofe' : kofe (cons G X B) A K). + +%worlds (csig | asig | var | bind) (weaken-kofe _ _ _ _). +%total {} (weaken-kofe _ _ _ _). + + +weaken-atkofe : at-kofe G R A -> {B} {X} +%% + at-kofe (cons G X B) R A -> type. +%mode weaken-atkofe +X1 +X2 +X3 -X4. + +- : weaken-atkofe + (Datkofe : at-kofe G R A) B X +%% + Datkofe' +%% + <- weakeng-atkofe + (append/nil : append G nil G) + (append/nil : append (cons G X B) nil (cons G X B)) + Datkofe + (Datkofe' : at-kofe (cons G X B) R A). + +%worlds (csig | asig | var | bind) (weaken-atkofe _ _ _ _). +%total {} (weaken-atkofe _ _ _ _). + + +weaken-wfkinde : wfkinde G K -> {B} {X} +%% + wfkinde (cons G X B) K -> type. +%mode weaken-wfkinde +X1 +X2 +X3 -X4. + +- : weaken-wfkinde (Dwfkinde : wfkinde G K) B X +%% + Dwfkinde' +%% + <- weakeng-wfkinde + (append/nil : append G nil G) + (append/nil : append (cons G X B) nil (cons G X B)) + Dwfkinde + (Dwfkinde' : wfkinde (cons G X B) K). + +%worlds (csig | asig | var | bind) (weaken-wfkinde _ _ _ _). +%total {} (weaken-wfkinde _ _ _ _). + + + +weaken-ofe' : append G1 G2 G -> ofe G1 M A -> ofe G M A -> type. +%mode weaken-ofe' +X1 +X2 -X3. + +-nil : weaken-ofe' append/nil D D. + +-cons : weaken-ofe' %% G = G1 @ (G2' :: X:B) + (append/cons (Dappend : append G1 G2' G')) + (Dofe : ofe G1 M A) +%% + Dofe'' + <- weaken-ofe' Dappend Dofe Dofe' + <- weaken-ofe Dofe' B X Dofe''. + + +%worlds (csig | asig | var | bind) (weaken-ofe' _ _ _). +%total D1 (weaken-ofe' D1 _ _). + + +weaken-kofe' : append G1 G2 G -> kofe G1 A K -> kofe G A K -> type. +%mode weaken-kofe' +X1 +X2 -X3. + +-nil : weaken-kofe' append/nil D D. + +-cons : weaken-kofe' + (append/cons (Dappend : append G1 G2' G')) + (Dkofe : kofe G1 A K) +%% + Dkofe'' +%% + <- weaken-kofe' Dappend Dkofe Dkofe' + <- weaken-kofe Dkofe' _ _ Dkofe''. + +%worlds (csig | asig | var | bind) (weaken-kofe' _ _ _). +%total D (weaken-kofe' D _ _). + + +weaken-wfkinde' : append G1 G2 G -> wfkinde G1 K -> wfkinde G K -> type. +%mode weaken-wfkinde' +X1 +X2 -X3. + +-nil : weaken-wfkinde' append/nil D D. + +-cons : weaken-wfkinde' + (append/cons (Dappend : append G1 G2' G')) + (Dwfkinde : wfkinde G1 K) +%% + Dwfkinde'' +%% + <- weaken-wfkinde' Dappend Dwfkinde Dwfkinde' + <- weaken-wfkinde Dwfkinde' _ _ Dwfkinde''. + + +%worlds (csig | asig | var | bind) (weaken-wfkinde' _ _ _). +%total D (weaken-wfkinde' D _ _). + + + +%%% weakening for simple types %%% + + +weakeng-slookup : sappend G1 G2 G + -> sappend (scons G1 X B) G2 G' + -> slookup G Y A +%% + -> slookup G' Y A -> type. +%mode weakeng-slookup +X1 +X2 +X3 -X4. + +-hit : weakeng-slookup (sappend/cons _) (sappend/cons _) slookup/hit + slookup/hit. + +-miss : weakeng-slookup + (sappend/cons Dapp1) + (sappend/cons Dapp2) + (slookup/miss Dlook) +%% + (slookup/miss Dlook') +%%% + <- weakeng-slookup Dapp1 Dapp2 Dlook Dlook'. + +-snil : weakeng-slookup sappend/nil sappend/nil Dlook + (slookup/miss Dlook). + +%worlds (csig | asig | var | bind | ovar | evar) (weakeng-slookup _ _ _ _). +%total D (weakeng-slookup _ _ D _). + +weakeng-wfkindes : sappend G1 G2 G + -> sappend (scons G1 X S) G2 G' + -> wfkindes G K +%% + -> wfkindes G' K -> type. +%mode weakeng-wfkindes +X2 +X3 +X4 -X5. + +weakeng-atkofes : sappend G1 G2 G + -> sappend (scons G1 X S) G2 G' + -> at-kofes G P K +%% + -> at-kofes G' P K -> type. +%mode weakeng-atkofes +X2 +X3 +X4 -X5. + +weakeng-kofes : sappend G1 G2 G + -> sappend (scons G1 X S) G2 G' + -> kofes G A K +%% + -> kofes G' A K -> type. +%mode weakeng-kofes +X2 +X3 +X4 -X5. + +weakeng-atofes : sappend G1 G2 G + -> sappend (scons G1 X S) G2 G' + -> at-ofes G R T +%% + -> at-ofes G' R T -> type. +%mode weakeng-atofes +X2 +X3 +X4 -X5. + +weakeng-ofes : sappend G1 G2 G + -> sappend (scons G1 X S) G2 G' + -> ofes G M T +%% + -> ofes G' M T -> type. +%mode weakeng-ofes +X2 +X3 +X4 -X5. + +-ktype : weakeng-wfkindes _ _ wfkindes/type wfkindes/type. + +-kpi : weakeng-wfkindes Dapp1 Dapp2 + (wfkindes/pi ([x] Dwfkindes x) Dsimp Dkofes) + (wfkindes/pi ([x] Dwfkindes' x) Dsimp Dkofes') + <- weakeng-kofes Dapp1 Dapp2 Dkofes Dkofes' + <- ({x} + weakeng-wfkindes + (sappend/cons Dapp1) + (sappend/cons Dapp2) + (Dwfkindes x) + (Dwfkindes' x)). + +-closed : weakeng-atkofes _ _ + (at-kofes/closed D1 D2 : at-kofes G P K) + (at-kofes/closed D1 D2 : at-kofes G' P K). + +-const : weakeng-atkofes Dapp1 Dapp2 + (at-kofes/const D1 D2 D3 : at-kofes G (aconst A) K) + (at-kofes/const D1 D2' D3) + <- weakeng-wfkindes Dapp1 Dapp2 D2 D2'. + +-app : weakeng-atkofes Dapp1 Dapp2 (at-kofes/app D2 D1) + (at-kofes/app D2' D1') + <- weakeng-atkofes Dapp1 Dapp2 D1 D1' + <- weakeng-ofes Dapp1 Dapp2 D2 D2'. + +-base : weakeng-kofes Dapp1 Dapp2 + (kofes/base Datkofes) + (kofes/base Datkofes') + <- weakeng-atkofes Dapp1 Dapp2 Datkofes + Datkofes'. + +-alam : weakeng-kofes Dapp1 Dapp2 + (kofes/lam Dof) + (kofes/lam Dof') + <- ({x} + weakeng-kofes + (sappend/cons Dapp1) + (sappend/cons Dapp2) + (Dof x) + (Dof' x)). + +-pi : weakeng-kofes Dapp1 Dapp2 + (kofes/pi ([x] DkofesB x) Dsimp DkofesA) + (kofes/pi ([x] DkofesB' x) Dsimp DkofesA') + <- weakeng-kofes Dapp1 Dapp2 DkofesA DkofesA' + <- ({x} weakeng-kofes + (sappend/cons Dapp1) + (sappend/cons Dapp2) + (DkofesB x) + (DkofesB' x)). + +-const : weakeng-atofes Dapp1 Dapp2 + (at-ofes/const D1 D2 D3 : at-ofes G (const C) T) + (at-ofes/const D1 D2' D3) + <- weakeng-kofes Dapp1 Dapp2 D2 D2'. + +-closed : weakeng-atofes _ _ + (at-ofes/closed D1 D2 : at-ofes G R T) + (at-ofes/closed D1 D2 : at-ofes G' R T). + +-var : weakeng-atofes Dappend Dappend' + (at-ofes/var Dlookup) + (at-ofes/var Dlookup') + <- weakeng-slookup Dappend Dappend' Dlookup Dlookup'. + +-app : weakeng-atofes Dappend Dappend' (at-ofes/app D2 D1) + (at-ofes/app D2' D1') + <- weakeng-atofes Dappend Dappend' D1 D1' + <- weakeng-ofes Dappend Dappend' D2 D2'. + +-at : weakeng-ofes Dappend Dappend' (ofes/at Datofes) + (ofes/at Datofes') + <- weakeng-atofes Dappend Dappend' Datofes Datofes'. + +-lam : weakeng-ofes Dappend Dappend' %% G |- \x.M : U -> V + (ofes/lam ([x] Dofes x : ofes (scons G x U) (M x) V)) +%% + (ofes/lam ([x] Dofes' x)) +%%% + <- ({x} + weakeng-ofes + (sappend/cons Dappend) + (sappend/cons Dappend') + (Dofes x) + (Dofes' x : ofes (scons G' x U) (M x) V)). + +%worlds (csig | asig | var | bind | ovar | evar) + (weakeng-wfkindes _ _ _ _) + (weakeng-atkofes _ _ _ _) + (weakeng-kofes _ _ _ _) + (weakeng-atofes _ _ _ _) + (weakeng-ofes _ _ _ _). +%total (D1 D2 D3 D4 D5) + (weakeng-wfkindes _ _ D1 _) + (weakeng-atkofes _ _ D2 _) + (weakeng-kofes _ _ D3 _) + (weakeng-atofes _ _ D4 _) + (weakeng-ofes _ _ D5 _). + + + +weaken-slookup : slookup G Y T -> {X} {S} slookup (scons G X S) Y T -> type. +%mode weaken-slookup +X1 +X2 +X3 -X4. + +- : weaken-slookup Dlook _ _ (slookup/miss Dlook). + +%worlds (csig | asig | bind | var | ovar | evar) (weaken-slookup _ _ _ _). +%total {} (weaken-slookup _ _ _ _). + + +weaken-ofes : ofes G M T -> {X} {S} ofes (scons G X S) M T -> type. +%mode weaken-ofes +X1 +X2 +X3 -X4. + +- : weaken-ofes Dof X S Dof' + <- weakeng-ofes sappend/nil sappend/nil Dof + (Dof' : ofes (scons G X S) M T). + +%worlds (csig | asig | bind | var | ovar | evar) (weaken-ofes _ _ _ _). +%total {} (weaken-ofes _ _ _ _). + + +weaken-atofes : at-ofes G M T -> {X} {S} at-ofes (scons G X S) M T -> type. +%mode weaken-atofes +X1 +X2 +X3 -X4. + +- : weaken-atofes Dof X S +%% + Dof' +%% + <- weakeng-atofes sappend/nil sappend/nil Dof + (Dof' : at-ofes (scons G X S) M T). + +%worlds (csig | asig | bind | var | ovar | evar) (weaken-atofes _ _ _ _). +%total {} (weaken-atofes _ _ _ _). + + +weaken-kofes : kofes G A K -> {X} {S} kofes (scons G X S) A K -> type. +%mode weaken-kofes +X1 +X2 +X3 -X4. + +- : weaken-kofes Dof X S Dof' + <- weakeng-kofes sappend/nil sappend/nil Dof + (Dof' : kofes (scons G X S) A K). + +%worlds (csig | asig | bind | var | ovar | evar) (weaken-kofes _ _ _ _). +%total {} (weaken-kofes _ _ _ _). + +weaken-atkofes : at-kofes G M T -> {X} {S} at-kofes (scons G X S) M T -> type. +%mode weaken-atkofes +X1 +X2 +X3 -X4. + +- : weaken-atkofes Dof X S +%% + Dof' +%% + <- weakeng-atkofes sappend/nil sappend/nil Dof + (Dof' : at-kofes (scons G X S) M T). + +%worlds (csig | asig | bind | var | ovar | evar) (weaken-atkofes _ _ _ _). +%total {} (weaken-atkofes _ _ _ _). + + +weaken-wfkindes : wfkindes G A -> {X} {S} wfkindes (scons G X S) A -> type. +%mode weaken-wfkindes +X1 +X2 +X3 -X4. + +- : weaken-wfkindes Dof X S Dof' + <- weakeng-wfkindes sappend/nil sappend/nil Dof + (Dof' : wfkindes (scons G X S) A). + +%worlds (csig | asig | bind | var | ovar | evar) (weaken-wfkindes _ _ _ _). +%total {} (weaken-wfkindes _ _ _ _). + + +weaken-ofes' : sappend G1 G2 G -> ofes G1 M A -> ofes G M A -> type. +%mode weaken-ofes' +X1 +X2 -X3. + +-nil : weaken-ofes' sappend/nil D D. + +-cons : weaken-ofes' + (sappend/cons (Dappend : sappend G1 G2' G)) + (Dofes : ofes G1 M A) +%% + Dofes'' + <- weaken-ofes' Dappend Dofes Dofes' + <- weaken-ofes Dofes' X B Dofes''. + +%worlds (csig | asig | var | bind | evar) (weaken-ofes' _ _ _). +%total D1 (weaken-ofes' D1 _ _). + + +weaken-atofes' : sappend G1 G2 G -> at-ofes G1 M A -> at-ofes G M A -> type. +%mode weaken-atofes' +X1 +X2 -X3. + +-nil : weaken-atofes' sappend/nil D D. + +-cons : weaken-atofes' + (sappend/cons (Dappend : sappend G1 G2' G)) + (Datofes : at-ofes G1 M A) +%% + Datofes'' + <- weaken-atofes' Dappend Datofes Datofes' + <- weaken-atofes Datofes' X B Datofes''. + +%worlds (csig | asig | var | bind | evar) (weaken-atofes' _ _ _). +%total D1 (weaken-atofes' D1 _ _). + + +weaken-kofes' : sappend G1 G2 G -> kofes G1 A K -> kofes G A K -> type. +%mode weaken-kofes' +X1 +X2 -X3. + +-nil : weaken-kofes' sappend/nil D D. + +-cons : weaken-kofes' + (sappend/cons (Dappend : sappend G1 G2' G)) + (Dkofes : kofes G1 A K) +%% + Dkofes'' + <- weaken-kofes' Dappend Dkofes Dkofes' + <- weaken-kofes Dkofes' X B Dkofes''. + +%worlds (csig | asig | var | bind | evar) (weaken-kofes' _ _ _). +%total D1 (weaken-kofes' D1 _ _). + +weaken-atkofes' : sappend G1 G2 G -> at-kofes G1 M A -> at-kofes G M A -> type. +%mode weaken-atkofes' +X1 +X2 -X3. + +-nil : weaken-atkofes' sappend/nil D D. + +-cons : weaken-atkofes' + (sappend/cons (Dappend : sappend G1 G2' G)) + (Datkofes : at-kofes G1 M A) +%% + Datkofes'' + <- weaken-atkofes' Dappend Datkofes Datkofes' + <- weaken-atkofes Datkofes' X B Datkofes''. + +%worlds (csig | asig | var | bind) (weaken-atkofes' _ _ _). +%total D1 (weaken-atkofes' D1 _ _). + + +weaken-wfkindes' : sappend G1 G2 G -> wfkindes G1 K -> wfkindes G K -> type. +%mode weaken-wfkindes' +X1 +X2 -X3. + +-nil : weaken-wfkindes' sappend/nil D D. + +-cons : weaken-wfkindes' (sappend/cons (Dappend : sappend G1 G2' G)) + (Dwfkindes : wfkindes G1 K) +%% + Dwfkindes'' + <- weaken-wfkindes' Dappend Dwfkindes Dwfkindes' + <- weaken-wfkindes Dwfkindes' X B Dwfkindes''. + +%worlds (csig | asig | var | bind) (weaken-wfkindes' _ _ _). +%total D (weaken-wfkindes' D _ _). + + + +%%% strengthening for cut %%% + +strengthen-for-cut-atof : {Rm} + {D:{x} vof x A -> at-of R (B x)} + ({x} {d} matof (D x d) Rm) +%% + -> ({x} tp-eq (B x) B') + -> {D':at-of R B'} + matof D' Rm -> type. +%mode strengthen-for-cut-atof +X1 +X2 +X3 -X4 -X5 -X6. + +strengthen-for-cut-of : {Mm} + {D:{x} vof x A -> of M B} + ({x} {d} mof (D x d) Mm) +%% + -> {D':of M B} + mof D' Mm -> type. +%mode strengthen-for-cut-of +X1 +X2 +X3 -X4 -X5. + +strengthen-for-cut-atkof : {Pm} + {D:{x} vof x A -> at-kof P (K x)} + ({x} {d} matkof (D x d) Pm) +%% + -> ({x} kind-eq (K x) K') + -> {D':at-kof P K'} + matkof D' Pm -> type. +%mode strengthen-for-cut-atkof +X1 +X2 +X3 -X4 -X5 -X6. + +strengthen-for-cut-kof : {Am} + {D:{x} vof x A -> kof B K} + ({x} {d} mkof (D x d) Am) +%% + -> {D':kof B K} + mkof D' Am -> type. +%mode strengthen-for-cut-kof +Am +D +X1 -D' -X3. + +strengthen-for-cut-wfkind : {Km} + {D:{x} vof x A -> wfkind K} + ({x} {d} mwfkind (D x d) Km) +%% + -> {D':wfkind K} + mwfkind D' Km -> type. +%mode strengthen-for-cut-wfkind +X1 +X2 +X3 -X4 -X5. + + +-const : strengthen-for-cut-atof (msing Bm) + ([x] [d:vof x A] + at-of/const + (Dkof x d : kof B ktype) + (Dcof : cof C B)) + ([x] [d] + matof/const (Dmkof x d : mkof (Dkof x d) Bm)) +%% + ([_] tp-eq/i) + (at-of/const Dkof' Dcof) + (matof/const Dmkof') +%% + <- strengthen-for-cut-kof _ Dkof Dmkof + (Dkof' : kof B ktype) + (Dmkof' : mkof Dkof' Bm). + +-var : strengthen-for-cut-atof (msing Bm) + ([x] [d:vof x A] + at-of/var + (Dkof x d : kof B ktype) + (Dvof : vof Y B)) + ([x] [d] + matof/var + (Dmkof x d : mkof (Dkof x d) Bm)) +%% + ([x] tp-eq/i) (at-of/var Dkof' Dvof) (matof/var Dmkof') +%%% + <- strengthen-for-cut-kof Bm Dkof Dmkof + (Dkof' : kof B ktype) + (Dmkof' : mkof Dkof' Bm). + +-app : strengthen-for-cut-atof (mpair Mm Rm) + ([x] [d:vof x A] + at-of/app + (Dsub x : tpsub ([y] B x y) M (By x)) + (Dof x d : of M (C x)) + (Datof x d : at-of R (pi (C x) [y] B x y))) + ([x] [d] + matof/app + (Dmatof x d : matof (Datof x d) Rm) + (Dmof x d : mof (Dof x d) Mm)) +%% + ([x] DeqRes x) + (at-of/app (Dsub'' aca) Dof'' Datof'') + (matof/app Dmatof'' Dmof'') +%%% + <- strengthen-for-cut-atof Rm Datof Dmatof + ([x] DeqPi x : tp-eq (pi (C x) [y] B x y) Api) + (Datof' : at-of R Api) + (Dmatof' : matof Datof' Rm) + <- tp-eq-pi-strengthen DeqPi + (DeqPi' : tp-eq Api (pi C' [y] B' y)) + <- ({x} + tp-eq-trans (DeqPi x) DeqPi' + (DeqPi'' x : tp-eq (pi (C x) [y] B x y) (pi C' [y] B' y))) + <- ({x} + pi-inj (DeqPi'' x) + (DeqDom x : tp-eq (C x) C') + ([y] DeqCod x y : tp-eq (B x y) (B' y))) + <- matof-resp atm-eq/i DeqPi' Datof' Dmatof' + (Datof'' : at-of R (pi C' [y] B' y)) + (Dmatof'' : matof Datof'' Rm) + <- ({x} {d} + mof-resp tm-eq/i (DeqDom x) (Dof x d) (Dmof x d) + (Dof' x d : of M C') + (Dmof' x d : mof (Dof' x d) Mm)) + <- strengthen-for-cut-of Mm Dof' Dmof' + (Dof'' : of M C') + (Dmof'' : mof Dof'' Mm) + <- ({x} + tpsub-compat ([y] DeqCod x y) tm-eq/i tp-eq/i (Dsub x) + (Dsub' x : tpsub ([y] B' y) M (By x))) + <- tpsub-closed Dsub' + ([x] DeqRes x : tp-eq (By x) By') + <- ({x} + tpsub-compat ([_] tp-eq/i) tm-eq/i (DeqRes x) (Dsub' x) + (Dsub'' x : tpsub ([y] B' y) M By')). + +-at : strengthen-for-cut-of (msing Rm) + ([x] [d:vof x A] + of/at + (Datof x d : at-of R (base P))) + ([x] [d] + mof/at + (Dmatof x d : matof (Datof x d) Rm)) +%% + (of/at (Datof'' aca)) + (mof/at (Dmatof'' aca)) +%% + <- strengthen-for-cut-atof Rm Datof Dmatof + ([x] Deq x : tp-eq (base P) B) + (Datof' : at-of R B) + (Dmatof' : matof Datof' Rm) + <- ({x} tp-eq-sym + (Deq x) + (Deq' x : tp-eq B (base P))) + <- ({x} matof-resp + atm-eq/i + (Deq' x) + Datof' + Dmatof' + (Datof'' x : at-of R (base P)) + (Dmatof'' x : matof (Datof'' x) Rm)). + + +-lam : strengthen-for-cut-of (mpair Mm Cm) + ([x] [d:vof x A] + of/lam + (Dkof x d : kof C ktype) + ([y] [e:vof y C] Dof y e x d : of (M y) (B y))) + ([x] [d] + mof/lam + ([y] [e] Dmof y e x d : mof (Dof y e x d) Mm) + (Dmkof x d : mkof (Dkof x d) Cm)) +%% + (of/lam Dkof' ([y] [e] Dof' y e)) + (mof/lam ([y] [e] Dmof' y e) Dmkof') +%% + <- strengthen-for-cut-kof Cm Dkof Dmkof + (Dkof' : kof C ktype) + (Dmkof' : mkof Dkof' Cm) + <- ({y} {e} + strengthen-for-cut-of Mm (Dof y e) (Dmof y e) + (Dof' y e : of (M y) (B y)) + (Dmof' y e : mof (Dof' y e) Mm)). + +-aconst : strengthen-for-cut-atkof (msing Km) + ([x] [d:vof x A] + at-kof/const + (Dwfkind x d : wfkind K) + (Dckof : ckof P K)) + ([x] [d] + matkof/const + (Dmwfkind x d : mwfkind (Dwfkind x d) Km)) +%% + ([_] kind-eq/i) + (at-kof/const Dwfkind' Dckof) + (matkof/const Dmwfkind') +%% + <- strengthen-for-cut-wfkind Km Dwfkind Dmwfkind + (Dwfkind' : wfkind K) + (Dmwfkind' : mwfkind Dwfkind' Km). + +-aapp : strengthen-for-cut-atkof (mpair Mm Pm) + ([x] [d : vof x A] + at-kof/app + (Dksub x : ksub ([y] K x y) M (Ksub x)) + (Dof x d : of M (B x)) + (Datkof x d : at-kof P (kpi (B x) [y] K x y))) + ([x] [d] + matkof/app + (Dmatkof x d : matkof (Datkof x d) Pm) + (Dmof x d : mof (Dof x d) Mm)) +%% + ([x] Deq x) + (at-kof/app (Dksub'' aca) Dof'' Datkof'') + (matkof/app Dmatkof'' Dmof'') +%% + <- strengthen-for-cut-atkof Pm Datkof Dmatkof + ([x] DeqKpi x : kind-eq (kpi (B x) [y] K x y) Kpi) + (Datkof' : at-kof P Kpi) + (Dmatkof' : matkof Datkof' Pm) + <- kind-eq-kpi-strengthen DeqKpi + (DeqKpi' : kind-eq Kpi (kpi B' [y] K' y)) + <- ({x} + kind-eq-trans (DeqKpi x) DeqKpi' + (DeqKpi'' x + : kind-eq (kpi (B x) [y] K x y) (kpi B' [y] K' y))) + <- ({x} + kpi-inj (DeqKpi'' x) + (DeqDom x : tp-eq (B x) B') + ([y] DeqCod x y : kind-eq (K x y) (K' y))) + <- matkof-resp atp-eq/i DeqKpi' Datkof' Dmatkof' + (Datkof'' : at-kof P (kpi B' [y] K' y)) + (Dmatkof'' : matkof Datkof'' Pm) + <- ({x} {d} + mof-resp tm-eq/i (DeqDom x) (Dof x d) (Dmof x d) + (Dof' x d : of M B') + (Dmof' x d : mof (Dof' x d) Mm)) + <- strengthen-for-cut-of Mm Dof' Dmof' + (Dof'' : of M B') + (Dmof'' : mof Dof'' Mm) + <- ({x} + ksub-compat ([y] DeqCod x y) tm-eq/i kind-eq/i (Dksub x) + (Dksub' x : ksub ([y] K' y) M (Ksub x))) + <- ksub-closed Dksub' + ([x] Deq x : kind-eq (Ksub x) Ksub') + <- ({x} + ksub-compat ([_] kind-eq/i) tm-eq/i (Deq x) (Dksub' x) + (Dksub'' x : ksub ([y] K' y) M Ksub')). + +-base : strengthen-for-cut-kof _ + ([x] [d] kof/base (Datkof x d : at-kof P ktype)) + ([x] [d] mkof/base (Dmatkof x d : matkof (Datkof x d) Pm)) +%% + (kof/base Datkof') + (mkof/base Dmatkof') +%%% + <- strengthen-for-cut-atkof _ Datkof Dmatkof + _ + (Datkof' : at-kof P ktype) + (Dmatkof' : matkof Datkof' Pm). + +-pi : strengthen-for-cut-kof (mpair Am2 Am1) + ([x] [d] + kof/pi + ([y] [e] Dkof2 x d y e : kof (A2 y) ktype) + (Dkof1 x d : kof A1 ktype)) + ([x] [d] + mkof/pi + ([y] [e] Dmkof2 x d y e : mkof (Dkof2 x d y e) Am2) + (Dmkof1 x d : mkof (Dkof1 x d) Am1)) +%% + (kof/pi Dkof2' Dkof1') + (mkof/pi ([y] [e] Dmkof2' y e) Dmkof1') +%% + <- strengthen-for-cut-kof Am1 Dkof1 Dmkof1 + (Dkof1' : kof A1 ktype) + (Dmkof1' : mkof Dkof1' Am1) + <- ({y} {e} + strengthen-for-cut-kof + Am2 + ([x] [d] Dkof2 x d y e) + ([x] [d] Dmkof2 x d y e) + (Dkof2' y e : kof (A2 y) ktype) + (Dmkof2' y e : mkof (Dkof2' y e) Am2)). + +-lam : strengthen-for-cut-kof (mpair Am2 Am1) + ([x] [d] + kof/lam + ([y] [e] Dkof2 x d y e : kof (B y) (K y)) + (Dkof1 x d : kof A ktype)) + ([x] [d] + mkof/lam + ([y] [e] Dmkof2 x d y e : mkof (Dkof2 x d y e) Am2) + (Dmkof1 x d : mkof (Dkof1 x d) Am1)) +%% + (kof/lam Dkof2' Dkof1') + (mkof/lam Dmkof2' Dmkof1') +%% + <- strengthen-for-cut-kof Am1 Dkof1 Dmkof1 + (Dkof1' : kof A ktype) + (Dmkof1' : mkof Dkof1' Am1) + <- ({y} {e} + strengthen-for-cut-kof Am2 + ([x] [d] Dkof2 x d y e) + ([x] [d] Dmkof2 x d y e) + (Dkof2' y e : kof (B y) (K y)) + (Dmkof2' y e : mkof (Dkof2' y e) Am2)). + +-ktype : strengthen-for-cut-wfkind munit + ([x] [d] + wfkind/tp : wfkind ktype) + ([x] [d] + mwfkind/tp : mwfkind wfkind/tp munit) +%% + wfkind/tp + mwfkind/tp. + +-kpi : strengthen-for-cut-wfkind (mpair Km Am) + ([x] [d] + wfkind/pi + ([y] [e] Dwfkind x d y e : wfkind (K y)) + (Dkof x d : kof A ktype)) + ([x] [d] + mwfkind/pi + (Dmkof x d : mkof (Dkof x d) Am) + ([y] [e] Dmwfkind x d y e : mwfkind (Dwfkind x d y e) Km)) +%% + (wfkind/pi Dwfkind' Dkof') + (mwfkind/pi Dmkof' ([y] [e] Dmwfkind' y e)) +%%% + <- strengthen-for-cut-kof Am Dkof Dmkof + (Dkof' : kof A ktype) + (Dmkof' : mkof Dkof' Am) + <- ({y} {e} + strengthen-for-cut-wfkind + Km + ([x] [d] Dwfkind x d y e) + ([x] [d] Dmwfkind x d y e) + (Dwfkind' y e : wfkind (K y)) + (Dmwfkind' y e : mwfkind (Dwfkind' y e) Km)). + + +%worlds (csig | asig | var | bind | ovar) + (strengthen-for-cut-atof _ _ _ _ _ _) + (strengthen-for-cut-of _ _ _ _ _) + (strengthen-for-cut-atkof _ _ _ _ _ _) + (strengthen-for-cut-kof _ _ _ _ _) + (strengthen-for-cut-wfkind _ _ _ _ _). +%total (M1 M2 M3 M4 M5) + (strengthen-for-cut-atof M1 _ _ _ _ _) + (strengthen-for-cut-of M2 _ _ _ _) + (strengthen-for-cut-atkof M3 _ _ _ _ _) + (strengthen-for-cut-kof M4 _ _ _ _) + (strengthen-for-cut-wfkind M5 _ _ _ _). + + + + +%%% cut %%% + +%% these say: if some derivation of well-typedness/formedness +%% has a metric M in the implicit system under some assumption +%% about its free variable, then +%% 1: there's an equivalent explicit context derivation for any +%% context holding the same variable assumption, and +%% 2: said derivation has the same metric. + +cut-at-of : {Rm} + {D:{x} vof x A -> at-of (R x) (B x)} + ({x} {d} matof (D x d) Rm) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} at-ofe (G x) (R x) (B x)} + ({x} matofe (D' x) Rm) + -> type. +%mode cut-at-of +X2 +X3 +X4 +X5 -X6 -X7. + +cut-of : {Mm} + {D:{x} vof x A -> of (M x) (B x)} + ({x} {d} mof (D x d) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} ofe (G x) (M x) (B x)} + ({x} mofe (D' x) Mm) + -> type. +%mode cut-of +X2 +X3 +X4 +X5 -X6 -X7. + +cut-at-kof : {Pm} + {D:{x} vof x A -> at-kof (P x) (K x)} + ({x} {d} matkof (D x d) Pm) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} at-kofe (G x) (P x) (K x)} + ({x} matkofe (D' x) Pm) + -> type. +%mode cut-at-kof +X2 +X3 +X4 +X5 -X6 -X7. + +cut-kof : {Bm} + {D:{x} vof x A -> kof (B x) (K x)} + ({x} {d} mkof (D x d) Bm) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} kofe (G x) (B x) (K x)} + ({x} mkofe (D' x) Bm) + -> type. +%mode cut-kof +X2 +X3 +X4 +X5 -X6 -X7. + +cut-wfkind : {Km} + {D:{x} vof x A -> wfkind (K x)} + ({x} {d} mwfkind (D x d) Km) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} wfkinde (G x) (K x)} + ({x} mwfkinde (D' x) Km) + -> type. +%mode cut-wfkind +X2 +X3 +X4 +X5 -X6 -X7. + +cut-at-ofe : {Rm} + {D:{x} vof x A -> at-ofe (G x) (R x) (B x)} + ({x} {d} matofe (D x d) Rm) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} at-ofe (G x) (R x) (B x)} + ({x} matofe (D' x) Rm) + -> type. +%mode cut-at-ofe +X2 +X3 +X4 +X5 -X6 -X7. + +cut-ofe : {Mm} + {D:{x} vof x A -> ofe (G x) (M x) (B x)} + ({x} {d} mofe (D x d) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} ofe (G x) (M x) (B x)} + ({x} mofe (D' x) Mm) + -> type. +%mode cut-ofe +X2 +X3 +X4 +X5 -X6 -X7. + +cut-at-kofe : {Pm} + {D:{x} vof x A -> at-kofe (G x) (P x) (K x)} + ({x} {d} matkofe (D x d) Pm) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} at-kofe (G x) (P x) (K x)} + ({x} matkofe (D' x) Pm) + -> type. +%mode cut-at-kofe +X2 +X3 +X4 +X5 -X6 -X7. + +cut-kofe : {Bm} + {D:{x} vof x A -> kofe (G x) (B x) (K x)} + ({x} {d} mkofe (D x d) Bm) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} kofe (G x) (B x) (K x)} + ({x} mkofe (D' x) Bm) + -> type. +%mode cut-kofe +X2 +X3 +X4 +X5 -X6 -X7. + +cut-wfkinde : {Km} + {D:{x} vof x A -> wfkinde (G x) (K x)} + ({x} {d} mwfkinde (D x d) Km) + -> ({x} lookup (G x) x A) +%% + -> {D':{x} wfkinde (G x) (K x)} + ({x} mwfkinde (D' x) Km) + -> type. +%mode cut-wfkinde +X2 +X3 +X4 +X5 -X6 -X7. + + +%% proof of cut lemmas %% + + +-const : cut-at-of (msing Bm) + ([x] [d:vof x A] + at-of/const + (Dkof x d : kof (B x) ktype) + (Dcof x : cof C (B x))) + ([x] [d] matof/const (Dmkof x d)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-ofe/const (Dkofe x) (Dcof x)) + ([x] matofe/const (Dmkofe x)) +%%% + <- cut-kof Bm Dkof Dmkof Dlookup + (Dkofe : {x} kofe (G x) (B x) ktype) + (Dmkofe : {x} mkofe (Dkofe x) Bm). + +-varsam : cut-at-of (msing Am) + ([x] [d:vof x A] + at-of/var + (Dkof x d : kof A ktype) + d) + ([x] [d] + matof/var + (Dmkof x d : mkof (Dkof x d) Am)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-ofe/var (Dkofe x) (Dlookup x)) + ([x] matofe/var (Dmkofe x)) +%%% + <- cut-kof Am Dkof Dmkof Dlookup + (Dkofe : {x} kofe (G x) A ktype) + (Dmkofe : {x} mkofe (Dkofe x) Am). + +-varoth : cut-at-of (msing Bm) + ([x] [d:vof x A] + at-of/var + (Dkof x d : kof B ktype) + (Dvof : vof Y B)) + ([x] [d] + matof/var + (Dmkof x d : mkof (Dkof x d) Bm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-ofe/closed (at-of/var Dkof' Dvof)) + ([x] matofe/closed (matof/var Dmkof')) +%%% + <- strengthen-for-cut-kof _ Dkof Dmkof + (Dkof' : kof B ktype) + (Dmkof' : mkof Dkof' Bm). + +-app : cut-at-of (mpair Mm Rm) + ([x] [d:vof x A] + at-of/app + (Dsub x : tpsub ([y] C x y) (M x) (C' x)) + (DofM x d : of (M x) (B x)) + (DatofR x d : at-of (R x) (pi (B x) ([y] C x y)))) + ([x] [d] + matof/app + (DmatofR x d : matof (DatofR x d) Rm) + (DmofM x d : mof (DofM x d) Mm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-ofe/app (Dsub x) (Dofe x) (Datofe x)) + ([x] matofe/app (Dmatofe x) (Dmofe x)) +%%% + <- cut-at-of Rm DatofR DmatofR Dlookup + (Datofe : {x} at-ofe (G x) (R x) (pi (B x) ([y] C x y))) + (Dmatofe : {x} matofe (Datofe x) Rm) + <- cut-of Mm DofM DmofM Dlookup + (Dofe : {x} ofe (G x) (M x) (B x)) + (Dmofe : {x} mofe (Dofe x) Mm). + +-at : cut-of (msing Rm) + ([x] [d:vof x A] + of/at + (Datof x d : at-of (R x) (base (P x)))) + ([x] [d] + mof/at + (Dmatof x d : matof (Datof x d) Rm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] ofe/at (Datofe x)) + ([x] mofe/at (Dmatofe x)) + <- cut-at-of Rm Datof Dmatof Dlookup + (Datofe : {x} at-ofe (G x) (R x) (base (P x))) + (Dmatofe : {x} matofe (Datofe x) Rm). + +-lam : cut-of + (mpair Mm Bm) + ([x] [d:vof x A] + of/lam + (Dkof x d : kof (B x) ktype) + (Dof x d : {y} vof y (B x) -> of (M x y) (C x y))) + ([x] [d] + mof/lam + (Dmof x d : {y} {e} mof (Dof x d y e) Mm) + (Dmkof x d : mkof (Dkof x d) Bm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] ofe/lam (Dkofe x) (Dofe' x)) + ([x] mofe/lam (Dmofe' x) (Dmkofe x)) +%%% + <- cut-kof Bm Dkof Dmkof Dlookup + (Dkofe : {x} kofe (G x) (B x) ktype) + (Dmkofe : {x} mkofe (Dkofe x) Bm) + <- ({x} {y} + weaken-lookup (Dlookup x) + y (B x) + (Dlookup' x y : lookup (cons (G x) y (B x)) x A)) + <- ({x} {d:vof x A} + cut-of + Mm + ([y] [e] Dof x d y e) + ([y] [e] Dmof x d y e) + ([y] lookup/hit) + (Dofe x d : {y} ofe (cons (G x) y (B x)) (M x y) (C x y)) + (Dmofe x d : {y} mofe (Dofe x d y) Mm)) + <- ({y} + cut-ofe + Mm + ([x] [d] Dofe x d y) + ([x] [d] Dmofe x d y) + ([x] Dlookup' x y) + ([x] Dofe' x y : ofe (cons (G x) y (B x)) (M x y) (C x y)) + ([x] Dmofe' x y : mofe (Dofe' x y) Mm)). + +-tconst : cut-at-kof (msing Km) + ([x] [d:vof x A] + at-kof/const + (Dwfkind x d : wfkind (K x)) + (Dckof x : ckof C (K x))) + ([x] [d] matkof/const (Dmwfkind x d)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-kofe/const (Dwfkinde x) (Dckof x)) + ([x] matkofe/const (Dmwfkinde x)) +%%% + <- cut-wfkind Km Dwfkind Dmwfkind Dlookup + (Dwfkinde : {x} wfkinde (G x) (K x)) + (Dmwfkinde : {x} mwfkinde (Dwfkinde x) Km). + +-tapp : cut-at-kof + (mpair Mm Pm) + ([x] [d:vof x A] + at-kof/app + (Dksub x : ksub ([y] K x y) (M x) (K' x)) + (Dof x d : of (M x) (B x)) + (Datkof x d : at-kof (P x) (kpi (B x) ([y] K x y)))) + ([x] [d] + matkof/app + (Dmatkof x d : matkof (Datkof x d) Pm) + (Dmof x d : mof (Dof x d) Mm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-kofe/app (Dksub x) (Dofe x) (Datkofe x)) + ([x] matkofe/app (Dmatkofe x) (Dmofe x)) +%%% + <- cut-at-kof Pm Datkof Dmatkof Dlookup + (Datkofe : {x} at-kofe (G x) (P x) (kpi (B x) ([y] K x y))) + (Dmatkofe : {x} matkofe (Datkofe x) Pm) + <- cut-of Mm Dof Dmof Dlookup + (Dofe : {x} ofe (G x) (M x) (B x)) + (Dmofe : {x} mofe (Dofe x) Mm). + +-base : cut-kof (msing Pm) + ([x] [d:vof x A] + kof/base + (Datkof x d : at-kof (P x) ktype)) + ([x] [d] + mkof/base + (Dmatkof x d : matkof (Datkof x d) Pm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] kofe/base (Datkofe x)) + ([x] mkofe/base (Dmatkofe x)) + <- cut-at-kof Pm Datkof Dmatkof Dlookup + (Datkofe : {x} at-kofe (G x) (P x) ktype) + (Dmatkofe : {x} matkofe (Datkofe x) Pm). + +-pi : cut-kof (mpair Cm Bm) + ([x] [d:vof x A] + kof/pi + (DkofC x d : {y} vof y (B x) -> kof (C x y) ktype) + (DkofB x d : kof (B x) ktype)) + ([x] [d] + mkof/pi + (DmkofC x d : {y} {e} mkof (DkofC x d y e) Cm) + (DmkofB x d : mkof (DkofB x d) Bm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] kofe/pi (DkofeC' x) (DkofeB x)) + ([x] mkofe/pi (DmkofeB x) (DmkofeC' x)) +%% + <- cut-kof Bm DkofB DmkofB Dlookup + (DkofeB : {x} kofe (G x) (B x) ktype) + (DmkofeB : {x} mkofe (DkofeB x) Bm) + <- ({x} {y} + weaken-lookup (Dlookup x) y (B x) + (Dlookup' x y : lookup (cons (G x) y (B x)) x A)) + <- ({x} {d:vof x A} + cut-kof + Cm + ([y] [e] DkofC x d y e) + ([y] [e] DmkofC x d y e) + ([y] lookup/hit) + (DkofeC x d : {y} kofe (cons (G x) y (B x)) (C x y) ktype) + (DmkofeC x d : {y} mkofe (DkofeC x d y) Cm)) + <- ({y} + cut-kofe + Cm + ([x] [d] DkofeC x d y) + ([x] [d] DmkofeC x d y) + ([x] Dlookup' x y) + ([x] DkofeC' x y : kofe (cons (G x) y (B x)) (C x y) ktype) + ([x] DmkofeC' x y : mkofe (DkofeC' x y) Cm)). + +-alam : cut-kof (mpair Cm Bm) + ([x] [d:vof x A] + kof/lam + ([y] [e] DofC x d y e : kof (C x y) (K x y)) + (DofB x d : kof (B x) ktype)) + ([x] [d] + mkof/lam + ([y] [e] DmofC x d y e : mkof (DofC x d y e) Cm) + (DmofB x d : mkof (DofB x d) Bm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] kofe/lam (DofeC' x) (DofeB x)) + ([x] mkofe/lam (DmofeC' x) (DmofeB x)) +%% + <- cut-kof Bm DofB DmofB Dlookup + ([x] DofeB x : kofe (G x) (B x) ktype) + ([x] DmofeB x : mkofe (DofeB x) Bm) + <- ({x} {y} + weaken-lookup (Dlookup x) y (B x) + (Dlookup' x y : lookup (cons (G x) y (B x)) x A)) + <- ({x} {d:vof x A} + cut-kof Cm ([y] [e] DofC x d y e) ([y] [e] DmofC x d y e) + ([y] lookup/hit) + ([y] DofeC x d y : kofe (cons (G x) y (B x)) (C x y) (K x y)) + ([y] DmofeC x d y : mkofe (DofeC x d y) Cm)) + <- ({y} + cut-kofe Cm ([x] [d] DofeC x d y) ([x] [d] DmofeC x d y) + ([x] Dlookup' x y) + ([x] DofeC' x y : kofe (cons (G x) y (B x)) (C x y) (K x y)) + ([x] DmofeC' x y : mkofe (DofeC' x y) Cm)). + +%% + +-ktype : cut-wfkind munit + ([x] [d:vof x A] wfkind/tp) + ([x] [d] mwfkind/tp) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] wfkinde/tp) + ([x] mwfkinde/tp). + +-kpi : cut-wfkind (mpair Km Bm) + ([x] [d:vof x A] + wfkind/pi + (Dwfkind x d : {y} vof y (B x) -> wfkind (K x y)) + (Dkof x d : kof (B x) ktype)) + ([x] [d] + mwfkind/pi + (Dmkof x d : mkof (Dkof x d) Bm) + (Dmwfkind x d : {y} {e} mwfkind (Dwfkind x d y e) Km)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] wfkinde/pi (Dwfkinde' x) (Dkofe x)) + ([x] mwfkinde/pi (Dmkofe x) (Dmwfkinde' x)) +%%% + <- cut-kof Bm Dkof Dmkof Dlookup + (Dkofe : {x} kofe (G x) (B x) ktype) + (Dmkofe : {x} mkofe (Dkofe x) Bm) + <- ({x} {y} + weaken-lookup (Dlookup x) y (B x) + (Dlookup' x y : lookup (cons (G x) y (B x)) x A)) + <- ({x} {d:vof x A} + cut-wfkind + Km + ([y] [e] Dwfkind x d y e) + ([y] [e] Dmwfkind x d y e) + ([y] lookup/hit) + (Dwfkinde x d : {y} wfkinde (cons (G x) y (B x)) (K x y)) + (Dmwfkinde x d : {y} mwfkinde (Dwfkinde x d y) Km)) + <- ({y} + cut-wfkinde + Km + ([x] [d] Dwfkinde x d y) + ([x] [d] Dmwfkinde x d y) + ([x] Dlookup' x y) + ([x] Dwfkinde' x y : wfkinde (cons (G x) y (B x)) (K x y)) + ([x] Dmwfkinde' x y : mwfkinde (Dwfkinde' x y) Km)). + + +-closed : cut-at-ofe + Rm + ([x] [d:vof x A] + at-ofe/closed + (Datof x d : at-of (R x) (B x))) + ([x] [d] + matofe/closed + (Dmatof x d : matof (Datof x d) Rm)) + ([x] Dlookup x : lookup (G x) x A) +%% + Datofe + Dmatofe +%%% + <- cut-at-of Rm Datof Dmatof Dlookup + (Datofe : {x} at-ofe (G x) (R x) (B x)) + (Dmatofe : {x} matofe (Datofe x) Rm). + +-const : cut-at-ofe + (msing Bm) + ([x] [d:vof x A] + at-ofe/const + (Dkofe x d : kofe (G x) (B x) ktype) + (Dcof x : cof C (B x))) + ([x] [d] matofe/const (Dmkofe x d)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-ofe/const (Dkofe' x) (Dcof x)) + ([x] matofe/const (Dmkofe' x)) +%%% + <- cut-kofe Bm Dkofe Dmkofe Dlookup + (Dkofe' : {x} kofe (G x) (B x) ktype) + (Dmkofe' : {x} mkofe (Dkofe' x) Bm). + +-var : cut-at-ofe (msing Bm) + ([x] [d:vof x A] + at-ofe/var + (DkofeB x d : kofe (G x) (B x) ktype) + (DlookupY x : lookup (G x) (Y x) (B x))) + ([x] [d] + matofe/var + (DmkofeB x d : mkofe (DkofeB x d) Bm)) + ([x] DlookupX x : lookup (G x) x A) +%% + ([x] at-ofe/var (DkofeB' x) (DlookupY x)) + ([x] matofe/var (DmkofeB' x)) +%%% + <- cut-kofe Bm DkofeB DmkofeB DlookupX + (DkofeB' : {x} kofe (G x) (B x) ktype) + (DmkofeB' : {x} mkofe (DkofeB' x) Bm). + +-app : cut-at-ofe + (mpair Mm Rm) + ([x] [d:vof x A] + at-ofe/app + (Dsub x : tpsub ([y] C x y) (M x) (C' x)) + (Dofe x d : ofe (G x) (M x) (B x)) + (Datofe x d : at-ofe (G x) (R x) (pi (B x) ([y] C x y)))) + ([x] [d] + matofe/app + (Dmatofe x d : matofe (Datofe x d) Rm) + (Dmofe x d : mofe (Dofe x d) Mm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-ofe/app (Dsub x) (Dofe' x) (Datofe' x)) + ([x] matofe/app (Dmatofe' x) (Dmofe' x)) +%%% + <- cut-at-ofe Rm Datofe Dmatofe Dlookup + (Datofe' : {x} at-ofe (G x) (R x) (pi (B x) ([y] C x y))) + (Dmatofe' : {x} matofe (Datofe' x) Rm) + <- cut-ofe Mm Dofe Dmofe Dlookup + (Dofe' : {x} ofe (G x) (M x) (B x)) + (Dmofe' : {x} mofe (Dofe' x) Mm). + + +-at : cut-ofe + (msing Rm) + ([x] [d:vof x A] + ofe/at + (Datofe x d : at-ofe (G x) (R x) (base (P x)))) + ([x] [d] + mofe/at + (Dmatofe x d : matofe (Datofe x d) Rm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] ofe/at (Datofe' x)) + ([x] mofe/at (Dmatofe' x)) + <- cut-at-ofe Rm Datofe Dmatofe Dlookup + (Datofe' : {x} at-ofe (G x) (R x) (base (P x))) + (Dmatofe' : {x} matofe (Datofe' x) Rm). + +-lam : cut-ofe + (mpair Mm Bm) + ([x] [d:vof x A] + ofe/lam + (Dkofe x d : kofe (G x) (B x) ktype) + (Dofe x d : {y} ofe (cons (G x) y (B x)) (M x y) (C x y))) + ([x] [d] + mofe/lam + (Dmofe x d : {y} mofe (Dofe x d y) Mm) + (Dmkofe x d : mkofe (Dkofe x d) Bm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] ofe/lam (Dkofe' x) (Dofe' x)) + ([x] mofe/lam (Dmofe' x) (Dmkofe' x)) +%% + <- cut-kofe Bm Dkofe Dmkofe Dlookup + (Dkofe' : {x} kofe (G x) (B x) ktype) + (Dmkofe' : {x} mkofe (Dkofe' x) Bm) + <- ({x} {y} + weaken-lookup (Dlookup x) y (B x) + (Dlookup' x y : lookup (cons (G x) y (B x)) x A)) + <- ({y} + cut-ofe + Mm + ([x] [d] Dofe x d y) + ([x] [d] Dmofe x d y) + ([x] Dlookup' x y) + ([x] Dofe' x y : ofe (cons (G x) y (B x)) (M x y) (C x y)) + ([x] Dmofe' x y : mofe (Dofe' x y) Mm)). + +-tconst : cut-at-kofe (msing Km) + ([x] [d:vof x A] + at-kofe/const + (Dwfkinde x d : wfkinde (G x) (K x)) + (Dckof x : ckof C (K x))) + ([x] [d] + matkofe/const + (Dmwfkinde x d : mwfkinde (Dwfkinde x d) Km)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-kofe/const (Dwfkinde' x) (Dckof x)) + ([x] matkofe/const (Dmwfkinde' x)) +%%% + <- cut-wfkinde Km Dwfkinde Dmwfkinde Dlookup + (Dwfkinde' : {x} wfkinde (G x) (K x)) + (Dmwfkinde' : {x} mwfkinde (Dwfkinde' x) Km). + +-tclosed : cut-at-kofe Pm + ([x] [d:vof x A] + at-kofe/closed + (Datkof x d : at-kof (P x) (K x))) + ([x] [d] + matkofe/closed + (Dmatkof x d : matkof (Datkof x d) Pm)) + ([x] Dlookup x : lookup (G x) x A) +%% + Datkofe + Dmatkofe +%%% + <- cut-at-kof Pm Datkof Dmatkof Dlookup + (Datkofe : {x} at-kofe (G x) (P x) (K x)) + (Dmatkofe : {x} matkofe (Datkofe x) Pm). + +-tapp : cut-at-kofe + (mpair Mm Pm) + ([x] [d:vof x A] + at-kofe/app + (Dksub x : ksub ([y] K x y) (M x) (K' x)) + (Dofe x d : ofe (G x) (M x) (B x)) + (Datkofe x d : at-kofe (G x) (P x) (kpi (B x) ([y] K x y)))) + ([x] [d] + matkofe/app + (Dmatkofe x d : matkofe (Datkofe x d) Pm) + (Dmofe x d : mofe (Dofe x d) Mm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] at-kofe/app (Dksub x) (Dofe' x) (Datkofe' x)) + ([x] matkofe/app (Dmatkofe' x) (Dmofe' x)) +%%% + <- cut-at-kofe Pm Datkofe Dmatkofe Dlookup + (Datkofe' : {x} at-kofe (G x) (P x) (kpi (B x) ([y] K x y))) + (Dmatkofe' : {x} matkofe (Datkofe' x) Pm) + <- cut-ofe Mm Dofe Dmofe Dlookup + (Dofe' : {x} ofe (G x) (M x) (B x)) + (Dmofe' : {x} mofe (Dofe' x) Mm). + +-base : cut-kofe + (msing Pm) + ([x] [d:vof x A] + kofe/base + (Datkofe x d : at-kofe (G x) (P x) ktype)) + ([x] [d] + mkofe/base + (Dmatkofe x d : matkofe (Datkofe x d) Pm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] kofe/base (Datkofe' x)) + ([x] mkofe/base (Dmatkofe' x)) + <- cut-at-kofe Pm Datkofe Dmatkofe Dlookup + (Datkofe' : {x} at-kofe (G x) (P x) ktype) + (Dmatkofe' : {x} matkofe (Datkofe' x) Pm). + +-pi : cut-kofe + (mpair Cm Bm) + ([x] [d:vof x A] + kofe/pi + (DkofeC x d : {y} kofe (cons (G x) y (B x)) (C x y) ktype) + (DkofeB x d : kofe (G x) (B x) ktype)) + ([x] [d] + mkofe/pi + (DmkofeB x d : mkofe (DkofeB x d) Bm) + (DmkofeC x d : {y} mkofe (DkofeC x d y) Cm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] kofe/pi (DkofeC' x) (DkofeB' x)) + ([x] mkofe/pi (DmkofeB' x) (DmkofeC' x)) +%% + <- cut-kofe Bm DkofeB DmkofeB Dlookup + (DkofeB' : {x} kofe (G x) (B x) ktype) + (DmkofeB' : {x} mkofe (DkofeB' x) Bm) + <- ({x} {y} + weaken-lookup (Dlookup x) y (B x) + (Dlookup' x y : lookup (cons (G x) y (B x)) x A)) + <- ({y} + cut-kofe + Cm + ([x] [d] DkofeC x d y) + ([x] [d] DmkofeC x d y) + ([x] Dlookup' x y) + ([x] DkofeC' x y : kofe (cons (G x) y (B x)) (C x y) ktype) + ([x] DmkofeC' x y : mkofe (DkofeC' x y) Cm)). + +-alam : cut-kofe (mpair Cm Bm) + ([x] [d:vof x A] + kofe/lam + ([y] DofeC x d y + : kofe (cons (G x) y (B x)) (C x y) (K x y)) + (DofeB x d : kofe (G x) (B x) ktype)) + ([x] [d] + mkofe/lam + ([y] DmofeC x d y : mkofe (DofeC x d y) Cm) + (DmofeB x d : mkofe (DofeB x d) Bm)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] kofe/lam (DofeC' x) (DofeB' x)) + ([x] mkofe/lam (DmofeC' x) (DmofeB' x)) +%% + <- cut-kofe Bm DofeB DmofeB Dlookup + ([x] DofeB' x : kofe (G x) (B x) ktype) + ([x] DmofeB' x : mkofe (DofeB' x) Bm) + <- ({x} {y} + weaken-lookup (Dlookup x) y (B x) + (Dlookup' x y : lookup (cons (G x) y (B x)) x A)) + <- ({y} + cut-kofe Cm ([x] [d] DofeC x d y) ([x] [d] DmofeC x d y) + ([x] Dlookup' x y) + ([x] DofeC' x y : kofe (cons (G x) y (B x)) (C x y) (K x y)) + ([x] DmofeC' x y : mkofe (DofeC' x y) Cm)). + +-ktype : cut-wfkinde + munit + ([x] [d:vof x A] wfkinde/tp) + ([x] [d] mwfkinde/tp) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] wfkinde/tp) + ([x] mwfkinde/tp). + +-kpi : cut-wfkinde + (mpair Km Bm) + ([x] [d:vof x A] + wfkinde/pi + (Dwfkinde x d : {y} wfkinde (cons (G x) y (B x)) (K x y)) + (Dkofe x d : kofe (G x) (B x) ktype)) + ([x] [d] + mwfkinde/pi + (Dmkofe x d : mkofe (Dkofe x d) Bm) + (Dmwfkinde x d : {y} mwfkinde (Dwfkinde x d y) Km)) + ([x] Dlookup x : lookup (G x) x A) +%% + ([x] wfkinde/pi (Dwfkinde' x) (Dkofe' x)) + ([x] mwfkinde/pi (Dmkofe' x) (Dmwfkinde' x)) +%%% + <- cut-kofe Bm Dkofe Dmkofe Dlookup + (Dkofe' : {x} kofe (G x) (B x) ktype) + (Dmkofe' : {x} mkofe (Dkofe' x) Bm) + <- ({x} {y} + weaken-lookup (Dlookup x) y (B x) + (Dlookup' x y : lookup (cons (G x) y (B x)) x A)) + <- ({y} + cut-wfkinde + Km + ([x] [d] Dwfkinde x d y) + ([x] [d] Dmwfkinde x d y) + ([x] Dlookup' x y) + ([x] Dwfkinde' x y : wfkinde (cons (G x) y (B x)) (K x y)) + ([x] Dmwfkinde' x y : mwfkinde (Dwfkinde' x y) Km)). + +%worlds (csig | asig | var | bind) + (cut-at-of _ _ _ _ _ _) + (cut-of _ _ _ _ _ _) + (cut-at-kof _ _ _ _ _ _) + (cut-kof _ _ _ _ _ _) + (cut-at-ofe _ _ _ _ _ _) + (cut-wfkind _ _ _ _ _ _) + (cut-ofe _ _ _ _ _ _) + (cut-at-kofe _ _ _ _ _ _) + (cut-kofe _ _ _ _ _ _) + (cut-wfkinde _ _ _ _ _ _). +%total (M1 M2 M3 M4 M5 M6 M7 M8 M9 M0) + (cut-at-of M1 _ _ _ _ _) + (cut-of M2 _ _ _ _ _) + (cut-at-kof M3 _ _ _ _ _) + (cut-kof M4 _ _ _ _ _) + (cut-at-ofe M5 _ _ _ _ _) + (cut-wfkind M6 _ _ _ _ _) + (cut-ofe M7 _ _ _ _ _) + (cut-at-kofe M8 _ _ _ _ _) + (cut-kofe M9 _ _ _ _ _) + (cut-wfkinde M0 _ _ _ _ _). + + +%%% translation to implicit form %%% + +wfkindi : ctx -> kind -> type. + +wfkindi/nil : wfkindi nil K + <- wfkind K. + +wfkindi/cons : wfkindi (cons G X A) K + <- (vof X A -> wfkindi G K). + + +at-kofi : ctx -> atp -> kind -> type. + +at-kofi/nil : at-kofi nil P K + <- at-kof P K. + +at-kofi/cons : at-kofi (cons G X A) P K + <- (vof X A -> at-kofi G P K). + + +kofi : ctx -> tp -> kind -> type. + +kofi/nil : kofi nil A K + <- kof A K. + +kofi/cons : kofi (cons G X A) B K + <- (vof X A -> kofi G B K). + + +at-ofi : ctx -> atm -> tp -> type. + +at-ofi/nil : at-ofi nil R A + <- at-of R A. + +at-ofi/cons : at-ofi (cons G X A) R B + <- (vof X A -> at-ofi G R B). + + +ofi : ctx -> tm -> tp -> type. + +ofi/nil : ofi nil M A + <- of M A. + +ofi/cons : ofi (cons G X A) M B + <- (vof X A -> ofi G M B). + + +atof-to-atofi : {G} at-of R A -> at-ofi G R A -> type. +%mode atof-to-atofi +X1 +X2 -X3. + +- : atof-to-atofi nil D (at-ofi/nil D). +- : atof-to-atofi (cons G X A) D (at-ofi/cons ([_] D')) + <- atof-to-atofi G D D'. + +%worlds (csig | asig | bind | var | ofblock) (atof-to-atofi _ _ _). +%total G (atof-to-atofi G _ _). + + +atkof-to-atkofi : {G} at-kof P K -> at-kofi G P K -> type. +%mode atkof-to-atkofi +X1 +X2 -X3. + +- : atkof-to-atkofi nil D (at-kofi/nil D). +- : atkof-to-atkofi (cons G X A) D (at-kofi/cons ([_] D')) + <- atkof-to-atkofi G D D'. + +%worlds (csig | asig | bind | var | ofblock) (atkof-to-atkofi _ _ _). +%total G (atkof-to-atkofi G _ _). + + +wfkindi-t : {G} wfkindi G ktype -> type. +%mode wfkindi-t +X1 -X2. + +- : wfkindi-t nil (wfkindi/nil wfkind/tp). +- : wfkindi-t (cons G X A) (wfkindi/cons D) + <- ({d} wfkindi-t G (D d)). + +%worlds (csig | asig | bind | var | ofblock) (wfkindi-t _ _). +%total G (wfkindi-t G _). + +wfkindi-pi : kofi G A ktype -> ({x} wfkindi (cons G x A) (K x)) + -> wfkindi G (kpi A K) -> type. +%mode wfkindi-pi +X1 +X2 -X3. + +- : wfkindi-pi (kofi/nil Dkof) ([x] wfkindi/cons ([d] wfkindi/nil (Dwfkind x d))) + (wfkindi/nil (wfkind/pi Dwfkind Dkof)). + +- : wfkindi-pi + (kofi/cons [e] Dkofi e) + ([x] wfkindi/cons ([d] wfkindi/cons ([e] Dwfkindi x d e))) + (wfkindi/cons [e] D e) + <- ({e} wfkindi-pi (Dkofi e) ([x] wfkindi/cons ([d] Dwfkindi x d e)) (D e)). + +%worlds (csig | asig | bind | var | ofblock) (wfkindi-pi _ _ _). +%total D (wfkindi-pi D _ _). + + +kofi-base : at-kofi G P ktype -> kofi G (base P) ktype -> type. +%mode kofi-base +X1 -X2. + +- : kofi-base (at-kofi/nil Datkof) (kofi/nil (kof/base Datkof)). + +- : kofi-base (at-kofi/cons ([d:vof X A] Datkofi d)) + (kofi/cons Dkofi) + <- ({d} kofi-base (Datkofi d) (Dkofi d)). + +%worlds (csig | asig | bind | var | ofblock) (kofi-base _ _). +%total D (kofi-base D _). + + +kofi-pi : ({x} kofi (cons G x A) (B x) ktype) -> kofi G A ktype + -> kofi G (pi A [x] B x) ktype -> type. +%mode kofi-pi +X1 +X2 -X3. + +- : kofi-pi + ([x] kofi/cons ([d] kofi/nil (DkofB x d : kof (B x) ktype))) + (kofi/nil (DkofA : kof A ktype)) + (kofi/nil (kof/pi DkofB DkofA)). + +- : kofi-pi + ([x] kofi/cons ([d] kofi/cons ([e] DkofB x d e))) + (kofi/cons ([e] DkofA e)) + (kofi/cons D) + <- ({e} kofi-pi ([x] kofi/cons ([d] DkofB x d e)) (DkofA e) (D e)). + +%worlds (csig | asig | bind | var | ofblock) (kofi-pi _ _ _). +%total D (kofi-pi _ D _). + + +atkofi-const : wfkindi G K -> ckof A K -> at-kofi G (aconst A) K -> type. +%mode atkofi-const +X1 +X2 -X3. + +- : atkofi-const (wfkindi/nil Dwfkind) Dckof + (at-kofi/nil (at-kof/const Dwfkind Dckof)). + +- : atkofi-const (wfkindi/cons ([d] Dwfkindi d)) Dckof + (at-kofi/cons [d] D d) + <- ({d} atkofi-const (Dwfkindi d) Dckof (D d)). + +%worlds (csig | asig | bind | var | ofblock) (atkofi-const _ _ _). +%total D (atkofi-const D _ _). + + +atkofi-app : ksub ([x] K x) M K' -> ofi G M B -> at-kofi G P (kpi B ([x] K x)) + -> at-kofi G (aapp P M) K' -> type. +%mode atkofi-app +X1 +X2 +X3 -X4. + +- : atkofi-app Dksub (ofi/nil Dof) (at-kofi/nil Datkof) + (at-kofi/nil (at-kof/app Dksub Dof Datkof)). + +- : atkofi-app Dksub (ofi/cons ([d] Dofi d)) (at-kofi/cons ([d] Datkofi d)) + (at-kofi/cons D) + <- ({d} atkofi-app Dksub (Dofi d) (Datkofi d) (D d)). + +%worlds (csig | asig | bind | var | ofblock) (atkofi-app _ _ _ _). +%total D (atkofi-app _ D _ _). + + +atofi-var : (kof A ktype -> at-of R A) -> kofi G A ktype + -> at-ofi G R A -> type. +%mode atofi-var +X1 +X2 -X3. + +- : atofi-var Datof (kofi/nil Dkof) (at-ofi/nil (Datof Dkof)). + +- : atofi-var (Datof : kof A ktype -> at-of R A) + (kofi/cons (Dkof : vof Y B -> kofi G A ktype)) +%% + (at-ofi/cons Datofi) +%% + <- ({d:vof Y B} + atofi-var Datof (Dkof d) + (Datofi d : at-ofi G R A)). + +%worlds (csig | asig | bind | var | ofblock) (atofi-var _ _ _). +%total D (atofi-var _ D _). + + +atofi-const : kofi G A ktype -> cof C A -> at-ofi G (const C) A -> type. +%mode atofi-const +X1 +X2 -X3. + +- : atofi-const (kofi/nil Dkof) Dcof + (at-ofi/nil (at-of/const Dkof Dcof)). + +- : atofi-const (kofi/cons ([d:vof X A] Dkof d : kofi G B ktype)) Dcof + (at-ofi/cons Datofi) + <- ({d:vof X A} + atofi-const (Dkof d) Dcof + (Datofi d : at-ofi G (const C) B)). + +%worlds (csig | asig | bind | var | ofblock) (atofi-const _ _ _). +%total D (atofi-const D _ _). + + +atofi-lookup : lookup G X A -> kofi G A ktype -> at-ofi G X A -> type. +%mode atofi-lookup +X1 +X2 -X3. + +- : atofi-lookup + (lookup/hit : lookup (cons G X A) X A) + (kofi/cons + (Dkof : vof X A -> kofi G A ktype) + : kofi (cons G X A) A ktype) +%% + (at-ofi/cons Datofi) +%% + <- ({d:vof X A} + atofi-var ([d_kof] at-of/var d_kof d) (Dkof d) + (Datofi d : at-ofi G X A)). + +- : atofi-lookup + (lookup/miss + (Dlook : lookup G X A) + : lookup (cons G Y B) X A) + (kofi/cons + (Dkof : vof Y B -> kofi G A ktype) + : kofi (cons G Y B) A ktype) +%% + (at-ofi/cons D) +%% + <- ({d:vof Y B} + atofi-lookup Dlook (Dkof d) + (D d : at-ofi G X A)). + +%worlds (csig | asig | bind | var | ofblock) (atofi-lookup _ _ _). +%total D (atofi-lookup D _ _). + + +atofi-app : at-ofi G R (pi A B) + -> ofi G M A + -> tpsub B M B' +%% + -> at-ofi G (app R M) B' -> type. +%mode atofi-app +X1 +X2 +X3 -X5. + +- : atofi-app (at-ofi/nil Datof) (ofi/nil Dof) Dtpsub + (at-ofi/nil (at-of/app Dtpsub Dof Datof)). + +- : atofi-app (at-ofi/cons Datofi) (ofi/cons Dofi) Dtpsub + (at-ofi/cons D) + <- ({d} atofi-app (Datofi d) (Dofi d) Dtpsub (D d)). + +%worlds (csig | asig | bind | var | ofblock) (atofi-app _ _ _ _). +%total D (atofi-app D _ _ _). + + +ofi-at : at-ofi G R (base P) -> ofi G (at R) (base P) -> type. +%mode ofi-at +X1 -X2. + +- : ofi-at (at-ofi/nil D) (ofi/nil (of/at D)). +- : ofi-at (at-ofi/cons D) (ofi/cons D') + <- ({d} ofi-at (D d) (D' d)). + +%worlds (bind | var | ofblock | csig | asig) (ofi-at _ _). +%total D (ofi-at D _). + + +ofi-lam : kofi G A ktype -> ({x} ofi (cons G x A) (M x) (B x)) + -> ofi G (lam M) (pi A B) -> type. +%mode ofi-lam +X1 +X2 -X3. + +- : ofi-lam (kofi/nil D1) ([x] ofi/cons ([d] ofi/nil (D2 x d))) + (ofi/nil (of/lam D1 D2)). + +- : ofi-lam (kofi/cons D1) ([x] ofi/cons ([d] ofi/cons ([e] D2 x d e))) + (ofi/cons D) + <- ({e} ofi-lam (D1 e) ([x] ofi/cons ([d] D2 x d e)) (D e)). + +%worlds (csig | asig | bind | var | ofblock) (ofi-lam _ _ _). +%total D (ofi-lam D _ _). + + +kofi-lam : kofi G A ktype -> ({x} kofi (cons G x A) (B x) (K x)) + -> kofi G (alam B) (kpi A K) -> type. +%mode kofi-lam +X1 +X2 -X3. + +- : kofi-lam (kofi/nil D1) ([x] kofi/cons ([d] kofi/nil (D2 x d))) + (kofi/nil (kof/lam D2 D1)). + +- : kofi-lam (kofi/cons D1) ([x] kofi/cons ([d] kofi/cons ([e] D2 x d e))) + (kofi/cons D) + <- ({e} kofi-lam (D1 e) ([x] kofi/cons ([d] D2 x d e)) (D e)). + +%worlds (csig | asig | bind | var | ofblock) (kofi-lam _ _ _). +%total D (kofi-lam D _ _). + + + + +atofe-to-atofi : at-ofe G R A -> at-ofi G R A -> type. +%mode atofe-to-atofi +X1 -X2. + +ofe-to-ofi : ofe G M A -> ofi G M A -> type. +%mode ofe-to-ofi +X1 -X2. + +kofe-to-kofi : kofe G A K -> kofi G A K -> type. +%mode kofe-to-kofi +X1 -X2. + +atkofe-to-atkofi : at-kofe G P K -> at-kofi G P K -> type. +%mode atkofe-to-atkofi +X1 -X2. + +wfkinde-to-wfkindi : wfkinde G K -> wfkindi G K -> type. +%mode wfkinde-to-wfkindi +X1 -X2. + +-at : ofe-to-ofi (ofe/at D) D'' + <- atofe-to-atofi D D' + <- ofi-at D' D''. + +-lam : ofe-to-ofi + (ofe/lam + (Dkofe : kofe G A ktype) + ([x] Dofe x : ofe (cons G x A) (M x) (B x))) + D + <- kofe-to-kofi Dkofe + (Dkofi : kofi G A ktype) + <- ({x} + ofe-to-ofi (Dofe x) + (Dofi x : ofi (cons G x A) (M x) (B x))) + <- ofi-lam Dkofi Dofi D. + +-closed : atofe-to-atofi (at-ofe/closed D) D' + <- atof-to-atofi _ D D'. + +-const : atofe-to-atofi (at-ofe/const Dkofe Dcof) D + <- kofe-to-kofi Dkofe + (Dkofi : kofi G A ktype) + <- atofi-const Dkofi Dcof D. + +-var : atofe-to-atofi (at-ofe/var Dkofe Dlook) Datofi + <- kofe-to-kofi Dkofe Dkofi + <- atofi-lookup Dlook Dkofi Datofi. + +-app : atofe-to-atofi (at-ofe/app Dsub Dofe Datofe) D + <- atofe-to-atofi Datofe Datofi + <- ofe-to-ofi Dofe Dofi + <- atofi-app Datofi Dofi Dsub D. + +-base : kofe-to-kofi (kofe/base Datkofe) D + <- atkofe-to-atkofi Datkofe Datkofi + <- kofi-base Datkofi D. + +-pi : kofe-to-kofi (kofe/pi ([x] DkofeB x) DkofeA) D + <- kofe-to-kofi DkofeA DkofiA + <- ({x} kofe-to-kofi (DkofeB x) (DkofiB x)) + <- kofi-pi DkofiB DkofiA D. + +-alam : kofe-to-kofi (kofe/lam ([x] DkofeB x) DkofeA) D + <- kofe-to-kofi DkofeA + (DkofiA : kofi G A ktype) + <- ({x} + kofe-to-kofi (DkofeB x) + (DkofiB x : kofi (cons G x A) (B x) (K x))) + <- kofi-lam DkofiA DkofiB D. + +-closed : atkofe-to-atkofi (at-kofe/closed Datkof) Datkofi + <- atkof-to-atkofi _ Datkof Datkofi. + +-const : atkofe-to-atkofi (at-kofe/const Dwfkinde Dckof) D + <- wfkinde-to-wfkindi Dwfkinde Dwfkindi + <- atkofi-const Dwfkindi Dckof D. + +-app : atkofe-to-atkofi (at-kofe/app Dksub Dofe Datkofe) D + <- ofe-to-ofi Dofe Dofi + <- atkofe-to-atkofi Datkofe Datkofi + <- atkofi-app Dksub Dofi Datkofi D. + +-tp : wfkinde-to-wfkindi wfkinde/tp D + <- wfkindi-t _ D. + +-pi : wfkinde-to-wfkindi (wfkinde/pi ([x] Dwfkinde x) Dkofe) D + <- kofe-to-kofi Dkofe Dkofi + <- ({x} wfkinde-to-wfkindi (Dwfkinde x) (Dwfkindi x)) + <- wfkindi-pi Dkofi Dwfkindi D. + +%worlds (var | bind | csig | asig) + (ofe-to-ofi _ _) + (atofe-to-atofi _ _) + (kofe-to-kofi _ _) + (atkofe-to-atkofi _ _) + (wfkinde-to-wfkindi _ _). +%total (D1 D2 D3 D4 D5) + (atofe-to-atofi D1 _) + (ofe-to-ofi D2 _) + (kofe-to-kofi D3 _) + (atkofe-to-atkofi D4 _) + (wfkinde-to-wfkindi D5 _). + +atofe-to-atof : at-ofe nil M A -> at-of M A -> type. +%mode atofe-to-atof +X1 -X2. + +- : atofe-to-atof D D' + <- atofe-to-atofi D (at-ofi/nil D'). + +%worlds (var | bind | csig | asig) (atofe-to-atof _ _). +%total {} (atofe-to-atof _ _). + + +ofe-to-of : ofe nil M A -> of M A -> type. +%mode ofe-to-of +X1 -X2. + +- : ofe-to-of D D' + <- ofe-to-ofi D (ofi/nil D'). + +%worlds (csig | asig | var | bind) (ofe-to-of _ _). +%total {} (ofe-to-of _ _). + +kofe-to-kof : kofe nil A K -> kof A K -> type. +%mode kofe-to-kof +X1 -X2. + +- : kofe-to-kof D D' + <- kofe-to-kofi D (kofi/nil D'). + +%worlds (csig | asig | var | bind) (kofe-to-kof _ _). +%total {} (kofe-to-kof _ _). + +atkofe-to-atkof : at-kofe nil M A -> at-kof M A -> type. +%mode atkofe-to-atkof +X1 -X2. + +- : atkofe-to-atkof D D' + <- atkofe-to-atkofi D (at-kofi/nil D'). + +%worlds (csig | asig | var | bind) (atkofe-to-atkof _ _). +%total {} (atkofe-to-atkof _ _). + + +wfkinde-to-wfkind : wfkinde nil K -> wfkind K -> type. +%mode wfkinde-to-wfkind +X1 -X2. + +- : wfkinde-to-wfkind D D' + <- wfkinde-to-wfkindi D (wfkindi/nil D'). + +%worlds (csig | asig | var | bind) (wfkinde-to-wfkind _ _). +%total {} (wfkinde-to-wfkind _ _). + + +%%% translation to explicit form %%% + +of1-to-ofe : ({x} vof x A -> of (M x) (B x)) +%% + -> ({x} ofe (cons nil x A) (M x) (B x)) -> type. +%mode of1-to-ofe +X2 -X3. + +- : of1-to-ofe + ([x] [d:vof x A] Dof x d : of (M x) (B x)) + ([x] Dofe x) + <- ({x} {d:vof x A} + can-mof (Dof x d) (Dmof x d : mof (Dof x d) Mm)) + <- cut-of Mm Dof Dmof ([_] lookup/hit) + (Dofe : {x} ofe (cons nil x A) (M x) (B x)) + _. + +%worlds (csig | asig | var | ovar | bind) (of1-to-ofe _ _). +%total {} (of1-to-ofe _ _). + + +atof1-to-atofe : ({x} vof x A -> at-of (R x) (B x)) +%% + -> ({x} at-ofe (cons nil x A) (R x) (B x)) -> type. +%mode atof1-to-atofe +X1 -X2. + +- : atof1-to-atofe + (Datof : {x} vof x A -> at-of (R x) (B x)) + ([x] Datofe x) +%%% + <- ({x} {d:vof x A} + can-matof (Datof x d) (Dmatof x d : matof (Datof x d) Mm)) + <- cut-at-of Mm Datof Dmatof ([_] lookup/hit) + ([x] Datofe x : at-ofe (cons nil x A) (R x) (B x)) + _. + +%worlds (csig | asig | var | bind) (atof1-to-atofe _ _). +%total {} (atof1-to-atofe _ _). + + +kof1-to-kofe : ({x} vof x A -> kof (B x) (K x)) +%% + -> ({x} kofe (cons nil x A) (B x) (K x)) -> type. +%mode kof1-to-kofe +X1 -X2. + +- : kof1-to-kofe + (Dkof : {x} vof x A -> kof (B x) (K x)) + ([x] Dkofe x) +%%% + <- ({x} {d:vof x A} + can-mkof (Dkof x d) (Dmkof x d : mkof (Dkof x d) Bm)) + <- cut-kof Bm Dkof Dmkof ([_] lookup/hit) + ([x] Dkofe x : kofe (cons nil x A) (B x) (K x)) + _. + +%worlds (csig | asig | var | bind) (kof1-to-kofe _ _). +%total {} (kof1-to-kofe _ _). + + +atkof1-to-atkofe : ({x} vof x A -> at-kof (P x) (K x)) +%% + -> ({x} at-kofe (cons nil x A) (P x) (K x)) -> type. +%mode atkof1-to-atkofe +X1 -X2. + +- : atkof1-to-atkofe + (Datkof : {x} vof x A -> at-kof (P x) (K x)) + ([x] Datkofe x) +%%% + <- ({x} {d:vof x A} + can-matkof (Datkof x d) (Dmatkof x d : matkof (Datkof x d) Pm)) + <- cut-at-kof Pm Datkof Dmatkof ([_] lookup/hit) + ([x] Datkofe x : at-kofe (cons nil x A) (P x) (K x)) + _. + +%worlds (csig | asig | var | bind) (atkof1-to-atkofe _ _). +%total {} (atkof1-to-atkofe _ _). + + +wfkind1-to-wfkinde : ({x} vof x A -> wfkind (K x)) +%% + -> ({x} wfkinde (cons nil x A) (K x)) -> type. +%mode wfkind1-to-wfkinde +X1 -X2. + +- : wfkind1-to-wfkinde + (Dwfkind : {x} vof x A -> wfkind (K x)) + ([x] Dwfkinde x) +%%% + <- ({x} {d:vof x A} + can-mwfkind (Dwfkind x d) (Dmwfkind x d : mwfkind (Dwfkind x d) Km)) + <- cut-wfkind Km Dwfkind Dmwfkind ([_] lookup/hit) + ([x] Dwfkinde x : wfkinde (cons nil x A) (K x)) + _. + +%worlds (csig | asig | var | bind) (wfkind1-to-wfkinde _ _). +%total {} (wfkind1-to-wfkinde _ _). + + + +atof-to-atofe : at-of R A -> at-ofe nil R A -> type. +%mode atof-to-atofe +X1 -X2. + +- : atof-to-atofe Datof (at-ofe/closed Datof). + +%worlds (csig | asig | var | bind | ovar) (atof-to-atofe _ _). +%total {} (atof-to-atofe _ _). + + +atkof-to-atkofe : at-kof P K +%% + -> at-kofe nil P K -> type. +%mode atkof-to-atkofe +X1 -X2. + +- : atkof-to-atkofe Datkof (at-kofe/closed Datkof). + +%worlds (csig | asig | var | bind) (atkof-to-atkofe _ _). +%total {} (atkof-to-atkofe _ _). + + +kof-to-kofe : kof A K +%% + -> kofe nil A K -> type. +%mode kof-to-kofe +X1 -X2. + +-base : kof-to-kofe (kof/base Datkof) (kofe/base Datkofe) + <- atkof-to-atkofe Datkof Datkofe. + +-pi : kof-to-kofe (kof/pi ([x] [d] D2 x d) D1) (kofe/pi D2' D1') + <- kof-to-kofe D1 D1' + <- kof1-to-kofe D2 D2'. + +-alam : kof-to-kofe (kof/lam ([x] [d] D2 x d) D1) (kofe/lam D2' D1') + <- kof-to-kofe D1 D1' + <- kof1-to-kofe D2 D2'. + +%worlds (csig | asig | var | bind) (kof-to-kofe _ _). +%total D (kof-to-kofe D _). + + +wfkind-to-wfkinde : wfkind K -> wfkinde nil K -> type. +%mode wfkind-to-wfkinde +X1 -X2. + +-type : wfkind-to-wfkinde wfkind/tp wfkinde/tp. + +-kpi : wfkind-to-wfkinde (wfkind/pi ([x] [d] Dwfkind x d) Dkof) + (wfkinde/pi Dwfkinde Dkofe) + <- kof-to-kofe Dkof Dkofe + <- wfkind1-to-wfkinde Dwfkind Dwfkinde. + +%worlds (csig | asig | var | bind) (wfkind-to-wfkinde _ _). +%total D (wfkind-to-wfkinde D _). + + +of-to-ofe : of M A -> ofe nil M A -> type. +%mode of-to-ofe +X1 -X2. + +- : of-to-ofe (of/at DofR) (ofe/at (at-ofe/closed DofR)). + +- : of-to-ofe (of/lam Dkof Dof) (ofe/lam Dkofe Dofe) + <- of1-to-ofe Dof Dofe + <- kof-to-kofe Dkof Dkofe. + +%worlds (csig | asig | var | bind | ovar) (of-to-ofe _ _). +%total D (of-to-ofe D _). + +of2-to-ofe : ({x} vof x A -> {y} vof y (B x) -> of (M x y) (C x y)) +%% + -> ({x} {y} ofe (cons (cons nil x A) y (B x)) (M x y) (C x y)) + -> type. +%mode of2-to-ofe +X1 -X2. + +- : of2-to-ofe + (Dof : {x} vof x A -> {y} vof y (B x) -> of (M x y) (C x y)) +%% + Dofe' +%% + <- ({x} {d:vof x A} {y} {e:vof y (B x)} + can-mof (Dof x d y e) (Dmof x d y e : mof (Dof x d y e) Mm)) + <- ({x} {d:vof x A} + cut-of Mm ([y] [e] Dof x d y e) ([y] [e] Dmof x d y e) + ([y] lookup/hit) + ([y] Dofe x d y : ofe (cons (cons nil x A) y (B x)) (M x y) (C x y)) + ([y] Dmofe x d y : mofe (Dofe x d y) Mm)) + <- ({y} + cut-ofe Mm ([x] [d] Dofe x d y) ([x] [d] Dmofe x d y) + ([x] lookup/miss lookup/hit) + ([x] Dofe' x y : ofe (cons (cons nil x A) y (B x)) (M x y) (C x y)) + _). + +%worlds (csig | asig | var | bind) (of2-to-ofe _ _). +%total {} (of2-to-ofe _ _). + +kof2-to-kofe : ({x} vof x A -> {y} vof y (B x) -> kof (M x y) (C x y)) +%% + -> ({x} {y} kofe (cons (cons nil x A) y (B x)) (M x y) (C x y)) + -> type. +%mode kof2-to-kofe +X1 -X2. + +- : kof2-to-kofe + (Dof : {x} vof x A -> {y} vof y (B x) -> kof (M x y) (C x y)) +%% + Dofe' +%% + <- ({x} {d:vof x A} {y} {e:vof y (B x)} + can-mkof (Dof x d y e) (Dmof x d y e : mkof (Dof x d y e) Mm)) + <- ({x} {d:vof x A} + cut-kof Mm ([y] [e] Dof x d y e) ([y] [e] Dmof x d y e) + ([y] lookup/hit) + ([y] Dofe x d y : kofe (cons (cons nil x A) y (B x)) (M x y) (C x y)) + ([y] Dmofe x d y : mkofe (Dofe x d y) Mm)) + <- ({y} + cut-kofe Mm ([x] [d] Dofe x d y) ([x] [d] Dmofe x d y) + ([x] lookup/miss lookup/hit) + ([x] Dofe' x y : kofe (cons (cons nil x A) y (B x)) (M x y) (C x y)) + _). + +%worlds (csig | asig | var | bind) (kof2-to-kofe _ _). +%total {} (kof2-to-kofe _ _). + + + +append-bounded-contra : append (cons G1 X A) G2 G -> bounded G X -> false -> type. +%mode append-bounded-contra +X1 +X2 -X3. + +- : append-bounded-contra append/nil (bounded/cons _ Dprecedes) Dfalse + <- precedes-antisymm Dprecedes Dfalse. +- : append-bounded-contra (append/cons Dapp) (bounded/cons Dbounded Dprecedes) + Dfalse + <- bounded-increase-bound Dbounded Dprecedes Dbounded' + <- append-bounded-contra Dapp Dbounded' Dfalse. + +%worlds (csig | asig | bind | ovar | var) (append-bounded-contra _ _ _). +%total D (append-bounded-contra D _ _). + + + +strengthen-bounded : ({x} isvar x I -> bounded G Y) -> bounded G Y -> type. +%mode strengthen-bounded +X1 -X2. + +- : strengthen-bounded ([x] [d] bounded/nil D) (bounded/nil D). + +- : strengthen-bounded + ([x] [d] bounded/cons (Dbound x d) Dprec) + (bounded/cons Dbound' Dprec) + <- strengthen-bounded Dbound Dbound'. + +%worlds (csig | asig | var | bind | ovar) (strengthen-bounded _ _). +%total D (strengthen-bounded D _). + +strengthen-ordered : ({x} isvar x I -> ordered G) -> ordered G -> type. +%mode strengthen-ordered +X1 -X2. + +- : strengthen-ordered ([x] [d] ordered/nil) ordered/nil. +- : strengthen-ordered ([x] [d] ordered/cons (Dbound x d)) + (ordered/cons Dbound') + <- strengthen-bounded Dbound Dbound'. + +%worlds (csig | asig | var | bind | ovar) (strengthen-ordered _ _). +%total {} (strengthen-ordered _ _). + + +bounded-increase-bound : bounded G X -> precedes X Y -> bounded G Y -> type. +%mode bounded-increase-bound +X1 +X2 -X3. + +- : bounded-increase-bound (bounded/nil _) (precedes/i _ D _) (bounded/nil D). +- : bounded-increase-bound (bounded/cons Dbounded Dprecedes) Dprecedes' + (bounded/cons Dbounded Dprecedes'') + <- precedes-trans Dprecedes Dprecedes' Dprecedes''. + +%worlds (csig | asig | bind | var | ovar) (bounded-increase-bound _ _ _). +%total {} (bounded-increase-bound _ _ _). + +bounded-is-ordered : bounded G X -> ordered G -> type. +%mode bounded-is-ordered +X1 -X2. + +- : bounded-is-ordered (bounded/nil _) ordered/nil. +- : bounded-is-ordered (bounded/cons D _) (ordered/cons D). + +%worlds (csig | asig | var | bind | ovar) (bounded-is-ordered _ _). +%total {} (bounded-is-ordered _ _). + +bounded-is-ordered-strengthen : ({x} isvar x I -> bounded G x) + -> ordered G -> type. +%mode bounded-is-ordered-strengthen +X1 -X2. + +- : bounded-is-ordered-strengthen ([x] [d] bounded/nil d) ordered/nil. +- : bounded-is-ordered-strengthen + ([x] [d] bounded/cons (D x d) (precedes/i Dlt d Disvar)) + (ordered/cons D') + <- strengthen-bounded D D'. + +%worlds (csig | asig | var | bind | ovar) (bounded-is-ordered-strengthen _ _). +%total {} (bounded-is-ordered-strengthen _ _). + +csub-closed : {G} {M} csub ([x] G) M G -> type. +%mode csub-closed +G +M -X1. + +-nil : csub-closed nil _ csub/nil. + +-cons : csub-closed (cons G X A) M + (csub/cons DsubA DsubG) + <- tpsub-absent _ _ + (DsubA : tpsub ([x] A) M A) + <- csub-closed G M + (DsubG : csub ([x] G) M G). + +%worlds (csig | asig | var) (csub-closed _ _ _). +%total G (csub-closed G _ _). + +csub-bounded : ({x} isvar x I -> bounded (G x) Y) -> csub ([x] G x) M G' + -> bounded G' Y -> type. +%mode csub-bounded +X1 +X2 -X3. + +- : csub-bounded ([x] [d] bounded/cons (Dbound x d) (Dprec x d)) csub/base + Dbound'' + <- ({x} {d} + bounded-increase-bound (Dbound x d) (Dprec x d) (Dbound' x d)) + <- strengthen-bounded Dbound' Dbound''. + +- : csub-bounded + ([x] [d] bounded/cons (Dbound x d) Dprec) + (csub/cons Dsub Dcsub) + (bounded/cons Dbound' Dprec) + <- csub-bounded Dbound Dcsub Dbound'. + +- : csub-bounded + ([x] [d] Dbound x d : bounded nil Y) + csub/nil + Dbound' + <- strengthen-bounded Dbound Dbound'. + +%worlds (csig | asig | bind | var | ovar) (csub-bounded _ _ _). +%total D (csub-bounded D _ _). + + +csub-ordered : ({x} isvar x I -> ordered (G x)) -> csub ([x] G x) M G' + -> ordered G' -> type. +%mode csub-ordered +X1 +X2 -X3. + +- : csub-ordered ([x] [d] ordered/cons (Dbound x d)) csub/base Dord + <- bounded-is-ordered-strengthen Dbound Dord. + +- : csub-ordered ([x] [d] ordered/cons (Dbound x d)) (csub/cons Dtsub Dcsub) + (ordered/cons Dbound') + <- csub-bounded Dbound Dcsub Dbound'. + +- : csub-ordered ([x] [d] ordered/nil) csub/nil ordered/nil. + +%worlds (csig | asig | bind | var | ovar) (csub-ordered _ _ _). +%total {} (csub-ordered _ _ _). + + +csub-lookup : csub G M G' -> ({x} lookup (G x) Y (A x)) + -> tpsub A M A' + -> lookup G' Y A' -> type. +%mode csub-lookup +X1 +X2 -X3 -X4. + +- : csub-lookup (csub/cons Dtsub Dcsub) ([_] lookup/hit) Dtsub lookup/hit. + +- : csub-lookup (csub/cons _ Dcsub) ([x] lookup/miss (Dlookup x)) + Dtsub + (lookup/miss Dlookup') + <- csub-lookup Dcsub ([x] Dlookup x) Dtsub Dlookup'. + +- : csub-lookup csub/base ([x] lookup/miss (Dlookup x : lookup G Y (A x))) + Dtsub' + Dlookup' + <- strengthen-lookup ([x] Dlookup x) + (Dlookup' : lookup G Y A') + ([x] Deq x : tp-eq (A x) A') + <- ({x} tp-eq-sym (Deq x) (Deq' x : tp-eq A' (A x))) + <- tpsub-absent _ _ + (Dtsub : tpsub ([_] A') M A') + <- tpsub-compat Deq' tm-eq/i tp-eq/i Dtsub + (Dtsub' : tpsub ([x] A x) M A'). + +%worlds (csig | asig | var | bind | ovar) (csub-lookup _ _ _ _). +%total D (csub-lookup _ D _ _). + +csub-append! : append (cons G1 X A) G2 G -> append G1 G' G -> type. +%mode csub-append! +X1 -X2. + +- : csub-append! append/nil (append/cons append/nil). + +- : csub-append! (append/cons D) (append/cons D') + <- csub-append! D D'. + +%worlds (csig | asig | var | ovar) (csub-append! _ _). +%total D (csub-append! D _). + +strengthen-append : ({x:atm} append (G1 x) (G2 x) G) + -> ({x} ctx-eq (G1 x) G1') + -> ({x} ctx-eq (G2 x) G2') -> type. +%mode strengthen-append +X1 -X2 -X3. + +-nil : strengthen-append ([x] append/nil) ([_] ctx-eq/i) ([_] ctx-eq/i). + +-cons : strengthen-append + ([x] append/cons + (Dappend x : append (G1 x) (G2 x) G)) + Deq1 + Deq2' + <- strengthen-append Dappend + ([x] Deq1 x : ctx-eq (G1 x) G1') + ([x] Deq2 x : ctx-eq (G2 x) G2') + <- ({x} + cons-compat (Deq2 x) atm-eq/i tp-eq/i + (Deq2' x : ctx-eq (cons (G2 x) Y A) (cons G2' Y A))). + +%worlds (csig | asig | var | ovar) (strengthen-append _ _ _). +%total D (strengthen-append D _ _). + +cons-closed-contra : ({x} ctx-eq (cons G x A) G') -> false -> type. +%mode cons-closed-contra +X1 -X2. + +%worlds (csig | asig | var | ovar) (cons-closed-contra _ _). +%total {} (cons-closed-contra _ _). + +csub-append : csub G M G' -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> append G1 G2' G' -> type. +%mode csub-append +X1 +X2 -X3. + +- : csub-append csub/base ([x] append/nil) append/nil. + +- : csub-append (csub/cons _ Dsub) ([x] append/cons (Dappend x)) + (append/cons Dappend') + <- csub-append Dsub Dappend Dappend'. + +- : csub-append csub/base ([x] append/cons (Dappend x)) D + <- csub-append! (Dappend aca) D. + +%worlds (csig | asig | var | ovar) (csub-append _ _ _). +%total D (csub-append D _ _). + + +weaken-ofe-csub : ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A +%% + -> ofe G' M A -> type. +%mode weaken-ofe-csub +X1 +X2 +X3 +X4 -X5. + +-nil : weaken-ofe-csub _ ([x] append/nil) _ D D. + +-cons : weaken-ofe-csub + ([x] [d] ordered/cons (Dbound x d)) + ([x] append/cons (Dapp x)) + (csub/cons _ Dsub) + Dof +%% + Dof'' +%% + <- ({x} {d:isvar x I} + bounded-is-ordered (Dbound x d) (Dord x d)) + <- weaken-ofe-csub Dord Dapp Dsub Dof Dof' + <- csub-ordered Dord Dsub Dord' + <- weaken-ofe Dof' _ _ Dof''. + +-bad : weaken-ofe-csub + ([x] [d] ordered/cons (Dbound x d)) + ([x] append/cons (Dapp x)) + csub/base + _ +%% + D +%% + <- ({x} {d} + append-bounded-contra (Dapp x) (Dbound x d) Dfalse) + <- false-implies-ofe Dfalse D. + +%worlds (csig | asig | bind | var | ovar) (weaken-ofe-csub _ _ _ _ _). +%total D (weaken-ofe-csub _ D _ _ _). + + +%%% for expand.thm %%% + +weaken-kofe-insert1 : ordered G + -> ({y} kofe (cons G y B) (C y) (K y)) + -> {A} +%% + ({x} {y} kofe (cons (cons G x A) y B) (C y) (K y)) -> type. +%mode weaken-kofe-insert1 +X1 +X2 +X3 -X4. + +- : weaken-kofe-insert1 + (Dord : ordered G) + ([y] DofC y : kofe (cons G y B) (C y) (K y)) + A +%% + DofC'' +%% + <- ({x} {y} + weakeng-kofe (append/cons append/nil) (append/cons append/nil) + (DofC y) + (DofC'' x y : kofe (cons (cons G x A) y B) (C y) (K y))). + +%worlds (csig | asig | var | bind | ovar) (weaken-kofe-insert1 _ _ _ _). +%total {} (weaken-kofe-insert1 _ _ _ _). diff --git a/src/false.thm b/src/false.thm new file mode 100644 index 0000000..2cd7e2c --- /dev/null +++ b/src/false.thm @@ -0,0 +1,269 @@ +false : type. + +%%%% explosion %%%% + +false-implies-tm-eq : false -> tm-eq M N -> type. +%mode +{M:tm} +{N:tm} +{X1:false} -{X2:tm-eq M N} + (false-implies-tm-eq X1 X2). +%worlds (ecsig | easig | csig | asig | var) (false-implies-tm-eq _ _). +%total {} (false-implies-tm-eq _ _). + +false-implies-sub : false -> sub ([x] M x) N M' -> type. +%mode +{M:atm -> tm} +{N:tm} -{M':tm} +{X1:false} -{X2:sub ([r:atm] M r) N M'} + (false-implies-sub X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind) (false-implies-sub _ _). +%total {} (false-implies-sub _ _). + +false-implies-sub' : false -> sub ([x] M x) N M' -> type. +%mode +{M:atm -> tm} +{N:tm} +{M':tm} +{X1:false} -{X2:sub ([r:atm] M r) N M'} + (false-implies-sub' X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind) (false-implies-sub' _ _). +%total {} (false-implies-sub' _ _). + +false-implies-rmsub : false -> rmsub ([x] R x) M N -> type. +%mode +{R:atm -> atm} +{M:tm} +{N:tm} +{X1:false} -{X2:rmsub ([r:atm] R r) M N} + (false-implies-rmsub X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind) (false-implies-rmsub _ _). +%total {} (false-implies-rmsub _ _). + +false-implies-rrsub : false -> rrsub ([x] R x) M Rx -> type. +%mode +{R:atm -> atm} +{M:tm} +{Rx:atm} +{X1:false} -{X2:rrsub ([r:atm] R r) M Rx} + (false-implies-rrsub X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind) (false-implies-rrsub _ _). +%total {} (false-implies-rrsub _ _). + +false-implies-tpsub : false -> tpsub ([x] M x) N M' -> type. +%mode +{M:atm -> tp} +{N:tm} -{M':tp} +{X1:false} -{X2:tpsub ([r:atm] M r) N M'} + (false-implies-tpsub X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind) (false-implies-tpsub _ _). +%total {} (false-implies-tpsub _ _). + +false-implies-stp-leq : false -> stp-leq S T -> type. +%mode +{S:stp} +{T:stp} +{X1:false} -{X2:stp-leq S T} + (false-implies-stp-leq X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | evar) (false-implies-stp-leq _ _). +%total {} (false-implies-stp-leq _ _). + +false-implies-tp-eq : false -> tp-eq S T -> type. +%mode +{S:tp} +{T:tp} +{X1:false} -{X2:tp-eq S T} + (false-implies-tp-eq X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind) (false-implies-tp-eq _ _). +%total {} (false-implies-tp-eq _ _). + +false-implies-stp-eq : false -> stp-eq S T -> type. +%mode +{S:stp} +{T:stp} +{X1:false} -{X2:stp-eq S T} + (false-implies-stp-eq X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | evar | tvar) (false-implies-stp-eq _ _). +%total {} (false-implies-stp-eq _ _). + +false-implies-stp-eq' : false -> stp-eq S T -> type. +%mode +{S:stp} -{T:stp} +{X1:false} -{X2:stp-eq S T} + (false-implies-stp-eq' X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | evar) (false-implies-stp-eq' _ _). +%total {} (false-implies-stp-eq' _ _). + + + +false-implies-ofe : false -> ofe G R T -> type. +%mode +{G:ctx} +{R:tm} +{T:tp} +{X1:false} -{X2:ofe G R T} + (false-implies-ofe X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | ovar) (false-implies-ofe _ _). +%total {} (false-implies-ofe _ _). + +false-implies-atofe : false -> at-ofe G R T -> type. +%mode +{G:ctx} +{R:atm} +{T:tp} +{X1:false} -{X2:at-ofe G R T} + (false-implies-atofe X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | ovar) (false-implies-atofe _ _). +%total {} (false-implies-atofe _ _). + +false-implies-atofes : false -> at-ofes G R T -> type. +%mode +{G:sctx} +{R:atm} +{T:stp} +{X1:false} -{X2:at-ofes G R T} + (false-implies-atofes X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | ovar | evar) (false-implies-atofes _ _). +%total {} (false-implies-atofes _ _). + +false-implies-ofes : false -> ofes G M T -> type. +%mode +{G:sctx} +{M:tm} +{T:stp} +{X1:false} -{X2:ofes G M T} + (false-implies-ofes X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | ovar | evar) (false-implies-ofes _ _). +%total {} (false-implies-ofes _ _). + +false-implies-expand : false -> expand R T M -> type. +%mode +{R:atm} +{T:stp} +{M:tm} +{X1:false} -{X2:expand R T M} + (false-implies-expand X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | ovar | evar) (false-implies-expand _ _). +%total {} (false-implies-expand _ _). + +false-implies-tptrans : false -> tptrans EA A K -> type. +%mode +{EA:etp} -{A:tp} -{K:kind} +{X1:false} -{X2:tptrans EA A K} + (false-implies-tptrans X1 X2). +%worlds (ecsig | easig | csig | asig | bind) (false-implies-tptrans _ _). +%total {} (false-implies-tptrans _ _). + +false-implies-kof : false -> kof A K -> type. +%mode +{A:tp} +{K:kind} +{X1:false} -{X2:kof A K} + (false-implies-kof X1 X2). +%worlds (ecsig | easig | csig | asig | bind) (false-implies-kof _ _). +%total {} (false-implies-kof _ _). + +false-implies-etp-eq : false -> etp-eq A B -> type. +%mode +{A:etp} +{B:etp} +{X1:false} -{X2:etp-eq A B} + (false-implies-etp-eq X1 X2). +%worlds (ecsig | easig | csig | asig | evar | eovar) (false-implies-etp-eq _ _). +%total {} (false-implies-etp-eq _ _). + +false-implies-cof : false -> cof C A -> type. +%mode +{C:ctm} -{A:tp} +{X1:false} -{X2:cof C A} + (false-implies-cof X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | ovar) (false-implies-cof _ _). +%total {} (false-implies-cof _ _). + + + +false-implies-ecof : false -> ecof C A -> type. +%mode +{C:ctm} +{A:etp} +{X1:false} -{X2:ecof C A} + (false-implies-ecof X1 X2). +%worlds (ecsig | easig | csig | asig | evar) (false-implies-ecof _ _). +%total {} (false-implies-ecof _ _). + +false-implies-ecof' : false -> ecof C A -> type. +%mode +{C:ctm} -{A:etp} +{X1:false} -{X2:ecof C A} + (false-implies-ecof' X1 X2). +%worlds (ecsig | easig | csig | asig | evar) (false-implies-ecof' _ _). +%total {} (false-implies-ecof' _ _). + + +false-implies-kofes : false -> kofes G A K -> type. +%mode +{G} +{A} +{K} +{X1:false} -{X2:kofes G A K} + (false-implies-kofes X1 X2). +%worlds (ecsig | easig | csig | asig | bind | var | ovar) (false-implies-kofes _ _). +%total {} (false-implies-kofes _ _). + + + +%{ +false-implies-ekofes : false -> ekofes G A K -> type. +%mode +{G} +{A} +{K} +{X1:false} -{X2:ekofes G A K} + (false-implies-ekofes X1 X2). +%worlds (ecsig | easig | csig | asig | evar | ebind) (false-implies-ekofes _ _). +%total {} (false-implies-ekofes _ _). + +false-implies-eofes : false -> eofes G M A -> type. +%mode +{G} +{M} +{A} +{X1:false} -{X2:eofes G M A} + (false-implies-eofes X1 X2). +%worlds (ecsig | easig | csig | asig | evar | ebind) (false-implies-eofes _ _). +%total {} (false-implies-eofes _ _). + +false-implies-eofes' : false -> eofes G M A -> type. +%mode +{G} +{M} -{A} +{X1:false} -{X2:eofes G M A} + (false-implies-eofes' X1 X2). +%worlds (ecsig | easig | csig | asig | evar | ebind) (false-implies-eofes' _ _). +%total {} (false-implies-eofes' _ _). +}% + +false-implies-simp : false -> simp A T -> type. +%mode +{A} +{T} +{X1:false} -{X2:simp A T} + (false-implies-simp X1 X2). +%worlds (ecsig | easig | csig | asig | var) (false-implies-simp _ _). +%total {} (false-implies-simp _ _). + + +%{ +false-implies-esimp : false -> esimp A T -> type. +%mode +{A} +{T} +{X1:false} -{X2:esimp A T} + (false-implies-esimp X1 X2). +%worlds (ecsig | easig | csig | asig | evar) (false-implies-esimp _ _). +%total {} (false-implies-esimp _ _). + +false-implies-esimp' : false -> esimp A T -> type. +%mode +{A} -{T} +{X1:false} -{X2:esimp A T} + (false-implies-esimp' X1 X2). +%worlds (ecsig | easig | csig | asig | evar) (false-implies-esimp' _ _). +%total {} (false-implies-esimp' _ _). +}% + +false-implies-eofe : false -> eofe G M A -> type. +%mode false-implies-eofe +X1 -X2. +%mode +{G:ectx} +{M:etm} +{A:etp} +{X1:false} -{X2:eofe G M A} + (false-implies-eofe X1 X2). +%worlds (ecsig | easig | csig | asig | evar | ebind | eovar) (false-implies-eofe _ _). +%total D (false-implies-eofe D _). + +false-implies-eqtme : false -> eqtme G M N A -> type. +%mode +{G:ectx} +{M:etm} +{N:etm} +{A:etp} +{X1:false} -{X2:eqtme G M N A} + (false-implies-eqtme X1 X2). +%worlds (ecsig | easig | csig | asig | evar | ebind | eovar) (false-implies-eqtme _ _). +%total {} (false-implies-eqtme _ _). + +false-implies-drop : false -> drop ([x] G x) G' -> type. +%mode +{G:atm -> sctx} -{G':sctx} +{X1:false} -{X2:drop ([x] G x) G'} + (false-implies-drop X1 X2). +%worlds (ecsig | easig | csig | asig | ovar | var) (false-implies-drop _ _). +%total {} (false-implies-drop _ _). + +false-implies-append : false -> append G1 G2 G -> type. +%mode +{G1:ctx} -{G2:ctx} +{G:ctx} +{X1:false} -{X2:append G1 G2 G} + (false-implies-append X1 X2). +%worlds (ecsig | easig | csig | asig | var | ovar) (false-implies-append _ _). +%total {} (false-implies-append _ _). + +false-implies-transe : false -> transe G EM M A -> type. +%mode +{G:ctx} +{EM:etm} +{M:tm} +{A:tp} +{X1:false} -{X2:transe G EM M A} + (false-implies-transe X1 X2). +%worlds (ecsig | easig | csig | asig | bind | tvar | tbind) (false-implies-transe _ _). +%total {} (false-implies-transe _ _). + +%{ +false-implies-transes : false -> transes G EM M -> type. +%mode +{G:sctx} +{EM:etm} +{M:tm} +{X1:false} -{X2:transes G EM M} + (false-implies-transes X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | tevar | tbind) (false-implies-transes _ _). +%total {} (false-implies-transes _ _). + +false-implies-transes' : false -> transes G EM M -> type. +%mode +{G:sctx} +{EM:etm} -{M:tm} +{X1:false} -{X2:transes G EM M} + (false-implies-transes' X1 X2). +%worlds (ecsig | easig | csig | asig | var | bind | tevar | tbind) (false-implies-transes' _ _). +%total {} (false-implies-transes' _ _). +}% + +false-implies-ekind-eq : false -> ekind-eq K L -> type. +%mode false-implies-ekind-eq +X1 -X2. +%mode +{K:ekind} +{L:ekind} +{X1:false} -{X2:ekind-eq K L} + (false-implies-ekind-eq X1 X2). +%worlds (ecsig | easig | csig | asig | ebind) (false-implies-ekind-eq _ _). +%total {} (false-implies-ekind-eq _ _). + +false-implies-etp-eq : false -> etp-eq K L -> type. +%mode false-implies-etp-eq +X1 -X2. +%mode +{K:etp} +{L:etp} +{X1:false} -{X2:etp-eq K L} + (false-implies-etp-eq X1 X2). +%worlds (ecsig | easig | csig | asig | ebind | evar | eovar) (false-implies-etp-eq _ _). +%total {} (false-implies-etp-eq _ _). + +false-implies-etm-eq : false -> etm-eq K L -> type. +%mode false-implies-etm-eq +X1 -X2. +%mode +{K:etm} +{L:etm} +{X1:false} -{X2:etm-eq K L} + (false-implies-etm-eq X1 X2). +%worlds (ecsig | easig | csig | asig | ebind | evar | eovar) (false-implies-etm-eq _ _). +%total {} (false-implies-etm-eq _ _). + +false-implies-vtrans : false -> vtrans EX X -> type. +%mode -{EX:etm} +{X:atm} +{X1:false} -{X2:vtrans EX X} + (false-implies-vtrans X1 X2). +%worlds (ecsig | easig | csig | asig | tvar | tbind) (false-implies-vtrans _ _). +%total {} (false-implies-vtrans _ _). + +false-implies-tpconvert : false -> tpconvert A K EA -> type. +%mode +{A:tp} +{K:kind} -{EA:etp} +{X1:false} -{X2:tpconvert A K EA} + (false-implies-tpconvert X1 X2). +%worlds (ecsig | easig | csig | asig | tvar | tbind | eofblock) (false-implies-tpconvert _ _). +%total {} (false-implies-tpconvert _ _). + +false-implies-evof : false -> evof EX EA -> type. +%mode +{EX:etm} +{EA:etp} +{X1:false} -{X2:evof EX EA} + (false-implies-evof X1 X2). +%worlds (ecsig | easig | csig | asig | tvar | tbind | eofblock) (false-implies-evof _ _). +%total {} (false-implies-evof _ _). + + diff --git a/src/invert.thm b/src/invert.thm new file mode 100644 index 0000000..44c1ced --- /dev/null +++ b/src/invert.thm @@ -0,0 +1,188 @@ + +app-rrsub-invert : rrsub ([x] app (Q x) (M x)) N (app Q' M') + -> rrsub ([x] Q x) N Q' + -> sub ([x] M x) N M' -> type. +%mode app-rrsub-invert +X1 -X2 -X3. + +-closed : app-rrsub-invert + (rrsub/closed : rrsub ([_] app Q M) N (app Q M)) + rrsub/closed + Dmclosed + <- sub-absent M N + (Dmclosed : sub ([_] M) N M). + +-app : app-rrsub-invert (rrsub/app D2 D1) D1 D2. + +%worlds (csig | asig | bind | var | ovar) (app-rrsub-invert _ _ _). +%total D (app-rrsub-invert D _ _). + +app-of-invert : at-of (app Q M) Ax + -> at-of Q (pi A2 [x] A x) + -> of M A2 + -> tpsub ([x] A x) M Ax -> type. +%mode app-of-invert +X1 -X2 -X3 -X4. + +-app : app-of-invert + (at-of/app + (Dsub : tpsub ([x] A x) M Ax) + (DofM : of M A2) + (DofR : at-of R (pi A2 [x] A x))) +%% + DofR + DofM + Dsub. + +%worlds (csig | asig | bind | var | ovar) (app-of-invert _ _ _ _). +%total D (app-of-invert D _ _ _). + + +app-ofes-invert : sordered G -> at-ofes G (app Q M) S + -> at-ofes G Q (arrow S2 S) -> ofes G M S2 -> type. +%mode app-ofes-invert +X0 +X1 -X2 -X3. + +-app : app-ofes-invert _ (at-ofes/app DofM DofR) DofR DofM. + +-var : app-ofes-invert Dord (at-ofes/var (Dlook : slookup G (app Q M) S)) + DofR DofM + <- slookup-isvar Dlook Dord + (Disvar : isvar (app Q M) _) + <- isvar-app-contra Disvar Dfalse + <- false-implies-atofes Dfalse + (DofR : at-ofes G Q (arrow o S)) + <- false-implies-ofes Dfalse + (DofM : ofes G M o). + +-closed : app-ofes-invert _ + (at-ofes/closed + (Dsimp : simp A S) + (Datof : at-of (app Q M) A) + : at-ofes G (app Q M) S) +%% + DofesQ' + DofesM' +%% + <- app-of-invert Datof + (DofQ : at-of Q (pi A2 [x] A' x)) + (DofM : of M A2) + (Dsub : tpsub ([x] A' x) M A) + <- ({x} can-simp (A' x) + (DsimpA' x : simp (A' x) S')) + <- tpsub-preserves-simp Dsub DsimpA' + (DsimpA : simp A S') + <- simp-fun DsimpA Dsimp + (DeqS'S : stp-eq S' S) + <- ({x} + simp-compat tp-eq/i DeqS'S (DsimpA' x) + (DsimpA'S x : simp (A' x) S)) + <- of-to-ofe DofM + (DofeM : ofe nil M A2) + <- atof-to-atofe DofQ + (DofeQ : at-ofe nil Q (pi A2 [x] A' x)) + <- can-simp A2 + (DsimpA2 : simp A2 S2) + <- ofe-simp simpctx/nil DsimpA2 DofeM + (DofesM : ofes snil M S2) + <- at-ofe-simp simpctx/nil (simp/pi ([x] DsimpA'S x) DsimpA2) DofeQ + (DofesQ : at-ofes snil Q (arrow S2 S)) + <- sappend-nil G + (Dappend : sappend snil G G) + <- weaken-ofes' Dappend DofesM + (DofesM' : ofes G M S2) + <- weaken-atofes' Dappend DofesQ + (DofesQ' : at-ofes G Q (arrow S2 S)). + +%worlds (csig | asig | bind | var | ovar | evar) (app-ofes-invert _ _ _ _). +%total D (app-ofes-invert _ D _ _). + + +aapp-kofes-invert : sordered G -> at-kofes G (aapp P M) H + -> at-kofes G P (karrow S2 H') -> ofes G M S2 -> type. +%mode aapp-kofes-invert +X0 +X1 -X2 -X3. + +-aapp : aapp-kofes-invert _ (at-kofes/app DofM DofP) DofP DofM. + +-closed : aapp-kofes-invert _ + (at-kofes/closed + (Dksimp : ksimp K' H') + (at-kof/app + (Dksub : ksub ([x] K x) M K') + (DofM : of M A) + (DofP : at-kof P (kpi A [x] K x)) + : at-kof (aapp P M) K') + : at-kofes G (aapp P M) H') +%% + DofesP' + DofesM' +%% + %% get derivation for M + <- of-to-ofe DofM + (DofeM : ofe nil M A) + <- can-simp A + (DsimpA : simp A S) + <- ofe-simp simpctx/nil DsimpA DofeM + (DofesM : ofes snil M S) + <- sappend-nil G + (Dappend : sappend snil G G) + <- weaken-ofes' Dappend DofesM + (DofesM' : ofes G M S) + %% get derivation for P + <- atkof-to-atkofe DofP + (DofeP : at-kofe nil P (kpi A [x] K x)) + <- ({x} + can-ksimp (K x) + (DsimpK x : ksimp (K x) H)) + <- atkofe-simp simpctx/nil (ksimp/pi DsimpK DsimpA) DofeP + (DofesP : at-kofes snil P (karrow S H)) + <- weaken-atkofes' Dappend DofesP + (DofesP' : at-kofes G P (karrow S H)). + +%worlds (csig | asig | bind | var | ovar) (aapp-kofes-invert _ _ _ _). +%total D (aapp-kofes-invert _ D _ _). + +of-const-invert : at-of (const C) A + -> cof C A + -> kof A ktype -> type. +%mode of-const-invert +X1 -X2 -X3. + +-const : of-const-invert (at-of/const D2 D1) D1 D2. + +%worlds (csig | asig | var | bind | ovar) (of-const-invert _ _ _). +%total {} (of-const-invert _ _ _). + +ofes-const-invert : sordered G -> at-ofes G (const C) T + -> cof C A + -> kofes G A sktype + -> simp A T -> type. +%mode ofes-const-invert +X0 +X1 -X2 -X3 -X4. + +-const : ofes-const-invert _ (at-ofes/const D3 D2 D1) + D1 D2 D3. + +-var : ofes-const-invert Dord + (at-ofes/var Dlook) + Dcof Dkofes Dsimp + <- slookup-isvar Dlook Dord Disvar + <- isvar-const-contra Disvar Dfalse + <- false-implies-cof Dfalse Dcof + <- false-implies-kofes Dfalse Dkofes + <- false-implies-simp Dfalse Dsimp. + +-closed : ofes-const-invert (Dord : sordered G) + (at-ofes/closed + (Dsimp : simp A T) + (DofR : at-of (const C) A)) + Dcof Dkofes Dsimp + <- of-const-invert DofR + (Dcof : cof C A) + (Dkof : kof A ktype) + <- kof-to-kofe Dkof + (Dkofenil : kofe nil A ktype) + <- kofe-simp simpctx/nil ksimp/type Dkofenil + (Dkofesnil : kofes snil A sktype) + <- sappend-nil G Dapp + <- weaken-kofes' Dapp Dkofesnil + (Dkofes : kofes G A sktype). + +%worlds (csig | asig | bind | var | ovar) (ofes-const-invert _ _ _ _ _). +%total D (ofes-const-invert _ D _ _ _). + diff --git a/src/nat.elf b/src/nat.elf new file mode 100644 index 0000000..64cb7c7 --- /dev/null +++ b/src/nat.elf @@ -0,0 +1,14 @@ +nat : type. %name nat N. + +0 : nat. +s : nat -> nat. + +lt : nat -> nat -> type. + +lt/z : lt 0 (s _). +lt/s : lt (s N1) (s N2) + <- lt N1 N2. + +nat-eq : nat -> nat -> type. + +nat-eq/i : nat-eq N N. diff --git a/src/nat.thm b/src/nat.thm new file mode 100644 index 0000000..c48b344 --- /dev/null +++ b/src/nat.thm @@ -0,0 +1,48 @@ +%%%% equality %%%% + +lt-resp : nat-eq N1 N1' -> nat-eq N2 N2' -> lt N1 N2 -> lt N1' N2' -> type. +%mode lt-resp +D1 +D2 +D3 -D. + +- : lt-resp nat-eq/i nat-eq/i D D. + +%worlds () (lt-resp _ _ _ _). +%total {} (lt-resp _ _ _ _). + + +lt-succ : {N} lt N (s N) -> type. +%mode lt-succ +X1 -X2. + +- : lt-succ 0 lt/z. + +- : lt-succ (s N) (lt/s D) + <- lt-succ N D. + +%worlds () (lt-succ _ _). +%total N (lt-succ N _). + + +%%%% lt %%%% + + +lt-trans : lt N1 N2 -> lt N2 N3 -> lt N1 N3 -> type. +%mode lt-trans +D1 +D2 -D3. + +- : lt-trans lt/z (lt/s _) lt/z. +- : lt-trans (lt/s D1) (lt/s D2) (lt/s D3) + <- lt-trans D1 D2 D3. + +%worlds () (lt-trans _ _ _). +%total D (lt-trans D _ _). + + +lt-antisymm : lt N N -> false -> type. +%mode lt-antisymm +X1 -X2. + +- : lt-antisymm (lt/s D) D' + <- lt-antisymm D D'. + +%worlds () (lt-antisymm _ _). +%total D (lt-antisymm D _). + + + diff --git a/src/noncan-explicit.elf b/src/noncan-explicit.elf new file mode 100644 index 0000000..5b7faa1 --- /dev/null +++ b/src/noncan-explicit.elf @@ -0,0 +1,239 @@ +%%% ordered variables %%% + +eisvar : etm -> nat -> type. + +- : (eisvar _ _ -> eisvar _ _) -> type. + + +eprecedes : etm -> etm -> type. + +eprecedes/i : eprecedes X Y + <- eisvar X I + <- eisvar Y J + <- lt I J. + + +%%% contexts %%% + +ectx : type. %name ectx G. + +enil : ectx. +econs : ectx -> etm -> etp -> ectx. + +ebounded : ectx -> etm -> type. + +ebounded/nil : ebounded enil X + <- eisvar X _. +ebounded/cons : ebounded (econs G Y _) X + <- eprecedes Y X + <- ebounded G Y. + + +eordered : ectx -> type. + +eordered/nil : eordered enil. +eordered/cons : eordered (econs G X _) + <- ebounded G X. + + +elookup : ectx -> etm -> etp -> type. + +elookup/hit : elookup (econs G X A) X A. + +elookup/miss : elookup (econs G Y _) X A + <- elookup G X A. + + +ecsub : (etm -> ectx) -> etm -> ectx -> type. + +ecsub/nil : ecsub ([_] enil) _ enil. +ecsub/base : ecsub ([x] econs G x A) M G. +ecsub/cons : ecsub ([x] econs (G x) Y (A x)) M (econs G' Y (A M)) + <- ecsub ([x] G x) M G'. + + +eappend : ectx -> ectx -> ectx -> type. + +eappend/nil : eappend G enil G. +eappend/cons : eappend G1 (econs G2 X A) (econs G X A) + <- eappend G1 G2 G. + +%% typing %% + +eofe : ectx -> etm -> etp -> type. +ekofe : ectx -> etp -> ekind -> type. +ewfkinde : ectx -> ekind -> type. + +eqtme : ectx -> etm -> etm -> etp -> type. +eqtpe : ectx -> etp -> etp -> ekind -> type. +eqkinde : ectx -> ekind -> ekind -> type. + +eofe/vari : eofe G X A + <- evof X A + <- ekofe G A ektype. + +eofe/const : eofe G (econst C) A + <- ecof C A + <- ekofe G A ektype. + +eofe/var : eofe G X A + <- elookup G X A + <- ekofe G A ektype. + +eofe/app : eofe G (eapp M N) (A N) + <- eofe G M (epi B ([x] A x)) + <- eofe G N B. + +eofe/lam : eofe G (elam A ([x] M x)) (epi A ([x] B x)) + <- ({x} eofe (econs G x A) (M x) (B x)) + <- ekofe G A ektype. + +eofe/eqtp : eofe G M B + <- eofe G M A + <- eqtpe G A B ektype. + +eofe/ext : eofe G M (epi A ([x] B x)) + <- eofe G M (epi A B') + <- ({x} eofe (econs G x A) (eapp M x) (B x)). + +%% + +%{ XXX needed? +ekofe/closed : ekofe G A K + <- ekof A K. +}% + +ekofe/const : ekofe G (eaconst A) K + <- eckof A K + <- ewfkinde G K. + +ekofe/app : ekofe G (eaapp A M) (K M) + <- ekofe G A (ekpi B ([x] K x)) + <- eofe G M B. + +ekofe/pi : ekofe G (epi A ([x] B x)) ektype + <- ({x} ekofe (econs G x A) (B x) ektype) + <- ekofe G A ektype. + +ekofe/lam : ekofe G (ealam A ([x] B x)) (ekpi A ([x] K x)) + <- ({x} ekofe (econs G x A) (B x) (K x)) + <- ekofe G A ektype. + +ekofe/eqkind : ekofe G A K' + <- ekofe G A K + <- eqkinde G K K'. + +ekofe/ext : ekofe G B (ekpi A ([x] K x)) + <- ekofe G B (ekpi A ([x] K' x)) + <- ({x} ekofe (econs G x A) (eaapp B x) (K x)). + +%% + +ewfkinde/tp : ewfkinde G ektype. + +ewfkinde/pi : ewfkinde G (ekpi A ([x] K x)) + <- ({x} ewfkinde (econs G x A) (K x)) + <- ekofe G A ektype. + +%% equivalence %% + +eqtme/app : eqtme G (eapp M N) (eapp M' N') (B N) + <- eqtme G M M' (epi A ([x] B x)) + <- eqtme G N N' A. + +eqtme/lam : eqtme G (elam A ([x] M x)) (elam A' ([x] M' x)) + (epi A ([x] B x)) + <- eqtpe G A A' ektype + <- ({x} eqtme (econs G x A) (M x) (M' x) (B x)). + +eqtme/ext : eqtme G M N (epi A ([x] B x)) + <- eofe G M (epi A ([x] B' x)) + <- eofe G N (epi A ([x] B'' x)) + <- ({x} eqtme (econs G x A) (eapp M x) (eapp N x) (B x)). + +eqtme/extw : eqtme G M N (epi A ([x] B x)) + <- eqtme G M N (epi A ([x] B' x)) + <- ({x} eqtme (econs G x A) (eapp M x) (eapp N x) (B x)). + +eqtme/beta : eqtme G (eapp (elam A [x] M x) N) (M N) (B N) + <- ({x} eofe (econs G x A) (M x) (B x)) + <- eofe G N A. + +eqtme/sym : eqtme G N M A + <- eqtme G M N A. + +eqtme/trans : eqtme G M O A + <- eqtme G M N A + <- eqtme G N O A. + +eqtme/refl : eqtme G M M A + <- eofe G M A. + +eqtme/tcon : eqtme G M N B + <- eqtme G M N A + <- eqtpe G A B ektype. + +%% + +eqtpe/app : eqtpe G (eaapp A M) (eaapp B N) (K M) + <- eqtpe G A B (ekpi C [x] K x) + <- eqtme G M N C. + +eqtpe/pi : eqtpe G (epi A ([x] B x)) (epi A' ([x] B' x)) ektype + <- eqtpe G A A' ektype + <- ({x} eqtpe (econs G x A) (B x) (B' x) ektype). + +eqtpe/lam : eqtpe G (ealam A ([x] B x)) (ealam A' ([x] B' x)) + (ekpi A ([x] K x)) + <- eqtpe G A A' ektype + <- ({x} eqtpe (econs G x A) (B x) (B' x) (K x)). + +eqtpe/ext : eqtpe G B C (ekpi A ([x] K x)) + <- ekofe G B (ekpi A ([x] K' x)) + <- ekofe G C (ekpi A ([x] K'' x)) + <- ({x} eqtpe (econs G x A) (eaapp B x) (eaapp C x) (K x)). + +eqtpe/extw : eqtpe G B C (ekpi A ([x] K x)) + <- eqtpe G B C (ekpi A ([x] K' x)) + <- ({x} eqtpe (econs G x A) (eaapp B x) (eaapp C x) (K x)). + +eqtpe/beta : eqtpe G (eaapp (ealam A ([x] B x)) N) (B N) (K N) + <- ({x} ekofe (econs G x A) (B x) (K x)) + <- eofe G N A. + +eqtpe/sym : eqtpe G B A K + <- eqtpe G A B K. + +eqtpe/trans : eqtpe G A C K + <- eqtpe G A B K + <- eqtpe G B C K. + +eqtpe/refl : eqtpe G A A K + <- ekofe G A K. + +eqtpe/kcon : eqtpe G A B K' + <- eqtpe G A B K + <- eqkinde G K K'. + +%% + +eqkinde/tp : eqkinde G ektype ektype. + +eqkinde/pi : eqkinde G (ekpi A [x] K x) (ekpi A' [x] K' x) + <- eqtpe G A A' ektype + <- ({x} eqkinde (econs G x A) (K x) (K' x)). + +eqkinde/sym : eqkinde G L K + <- eqkinde G K L. + +eqkinde/trans : eqkinde G K K'' + <- eqkinde G K K' + <- eqkinde G K' K''. + +eqkinde/refl : eqkinde G K K + <- ewfkinde G K. + +%% worlds %% + +%block eovar : some {n:nat} block {ex:etm} {d:eisvar ex n}. + diff --git a/src/noncan.elf b/src/noncan.elf new file mode 100644 index 0000000..7aca93e --- /dev/null +++ b/src/noncan.elf @@ -0,0 +1,256 @@ +%%% syntax %%% + +ekind : type. %name ekind EK. +etp : type. %name etp EA. +etm : type. %name etm EM. + +%% kinds %% +ektype : ekind. +ekpi : etp -> (etm -> ekind) -> ekind. + +%% families %% +eaconst : ctp -> etp. +epi : etp -> (etm -> etp) -> etp. +eaapp : etp -> etm -> etp. +% added 05/13/09 +ealam : etp -> (etm -> etp) -> etp. + +%% objects %% +econst : ctm -> etm. +elam : etp -> (etm -> etm) -> etm. +eapp : etm -> etm -> etm. + + +%%% judgments %%% + +% M : A +eof : etm -> etp -> type. +ecof : ctm -> etp -> type. +evof : etm -> etp -> type. + +% A : K +ekof : etp -> ekind -> type. +eckof : ctp -> ekind -> type. + +% K : kind +ewfkind : ekind -> type. + +% M = N at A +eqtm : etm -> etm -> etp -> type. + +% A = B at K +eqtp : etp -> etp -> ekind -> type. + +% K = L +eqkind : ekind -> ekind -> type. + +%% constants %% + +%{ +etclosed : etp -> type. +ekclosed : ekind -> type. +%% XXX fill in +}% + +%block ecsig : some {A:etp} + block {c:ctm} {d:ecof c A}. +%block easig : some {K:ekind} + block {a:ctp} {d:eckof a K}. + + +%%% typing %%% + +% objects + +eof/var : eof X A + <- evof X A + <- ekof A ektype. + +eof/const : eof (econst C) A + <- ecof C A + <- ekof A ektype. + +eof/app : eof (eapp M N) (B N) + <- eof M (epi A ([x] B x)) + <- eof N A. + +eof/lam : eof (elam A ([x] M x)) (epi A ([x] B x)) + <- ({x} evof x A -> eof (M x) (B x)) + <- ekof A ektype. + +eof/eqtp : eof M B + <- eof M A + <- eqtp A B ektype. + +%% added 3/8/09: +eof/ext : eof M (epi A ([x] B x)) + <- eof M (epi A B') + <- ({x} evof x A -> eof (eapp M x) (B x)). + +% families + +ekof/const : ekof (eaconst A) K + <- eckof A K + <- ewfkind K. + +ekof/app : ekof (eaapp A M) (K M) + <- ekof A (ekpi B ([x] K x)) + <- eof M B. + +% XXX switch order of premises +ekof/pi : ekof (epi A1 ([x] A2 x)) ektype + <- ekof A1 ektype + <- ({x} evof x A1 -> ekof (A2 x) ektype). + +% added 05/13/09 +ekof/lam : ekof (ealam A1 ([x] A2 x)) (ekpi A1 ([x] K2 x)) + <- ({x} evof x A1 -> ekof (A2 x) (K2 x)) + <- ekof A1 ektype. + +% added 05/13/09 +ekof/ext : ekof C (ekpi A [x] K x) + <- ekof C (ekpi A [x] K' x) + <- ({x} evof x A -> ekof (eaapp C x) (K x)). + +ekof/eqkind : ekof A L + <- ekof A K + <- eqkind K L. + +% kinds + +ewfkind/tp : ewfkind ektype. + +ewfkind/pi : ewfkind (ekpi A ([x] K x)) + <- ekof A ektype + <- ({x} evof x A -> ewfkind (K x)). + + +%%% equivalence and congruence %%% + +%% eqtm + +eqtm/app : eqtm (eapp M1 M2) (eapp N1 N2) (A1 M2) + <- eqtm M1 N1 (epi A2 ([x] A1 x)) + <- eqtm M2 N2 A2. + +eqtm/lam : eqtm (elam A ([x] M x)) (elam A' ([x] M' x)) (epi A ([x] B x)) + <- eqtp A A' ektype + <- ({x} evof x A -> eqtm (M x) (M' x) (B x)). + +eqtm/ext : eqtm M N (epi A ([x] B x)) + <- eof M (epi A ([x] B' x)) + <- eof N (epi A ([x] B'' x)) + <- ({x} evof x A -> eqtm (eapp M x) (eapp N x) (B x)). + +%% weak extensionality -- added 01/14/10 for efunctionality +eqtm/extw : eqtm M N (epi A ([x] B x)) + <- eqtm M N (epi A ([x] B' x)) + <- ({x} evof x A -> eqtm (eapp M x) (eapp N x) (B x)). + +% eqtm/parcon : eqtm (eapp (elam A1 [x] M2 x) M1) (N2 N1) (A2 M1) +% <- ({x} evof x A1 -> eqtm (M2 x) (N2 x) (A2 x)) +% <- eqtm M1 N1 A1. + +eqtm/beta : eqtm (eapp (elam A [x] M x) N) (M N) (B N) + <- ({x} evof x A -> eof (M x) (B x)) + <- eof N A. %% added this premise 3/8/09. + +eqtm/sym : eqtm N M A + <- eqtm M N A. + +eqtm/trans : eqtm M O A + <- eqtm M N A + <- eqtm N O A. + +eqtm/refl : eqtm M M A + <- eof M A. + +eqtm/typecon : eqtm M N B + <- eqtm M N A + <- eqtp A B ektype. + +%% eqtp + +eqtp/app : eqtp (eaapp A M) (eaapp B N) (K M) + <- eqtp A B (ekpi C [x] K x) + <- eqtm M N C. + +eqtp/pi : eqtp (epi A [y] B y) (epi A' [y] B' y) ektype + <- eqtp A A' ektype + <- ({x} evof x A -> eqtp (B x) (B' x) ektype). + +% added 05/13/09 +eqtp/lam : eqtp (ealam A ([x] B x)) (ealam A' ([x] B' x)) (ekpi A ([x] K x)) + <- eqtp A A' ektype + <- ({x} evof x A -> eqtp (B x) (B' x) (K x)). + +% added 05/13/09 +eqtp/ext : eqtp B C (ekpi A ([x] K x)) + <- ekof B (ekpi A ([x] K' x)) + <- ekof C (ekpi A ([x] K'' x)) + <- ({x} evof x A -> eqtp (eaapp B x) (eaapp C x) (K x)). + +%% weak extensionality -- added 01/14/10 for efunctionality +eqtp/extw : eqtp M N (ekpi A ([x] B x)) + <- eqtp M N (ekpi A ([x] B' x)) + <- ({x} evof x A -> eqtp (eaapp M x) (eaapp N x) (B x)). + + +% added 05/13/09 +eqtp/beta : eqtp (eaapp (ealam A [x] B x) N) (B N) (K N) + <- ({x} evof x A -> ekof (B x) (K x)) + <- eof N A. + +eqtp/sym : eqtp B A K + <- eqtp A B K. + +eqtp/trans : eqtp A C K + <- eqtp A B K + <- eqtp B C K. + +eqtp/refl : eqtp A A K + <- ekof A K. + +eqtp/kcon : eqtp A B L + <- eqtp A B K + <- eqkind K L. + +%% eqkind + +eqkind/tp : eqkind ektype ektype. + +eqkind/pi : eqkind (ekpi A [y] K y) (ekpi B [z] L z) + <- eqtp A B ektype + <- ({x} evof x A -> eqkind (K x) (L x)). + +eqkind/sym : eqkind L K + <- eqkind K L. + +eqkind/trans : eqkind K L' + <- eqkind K L + <- eqkind L L'. + +eqkind/refl : eqkind K K + <- ewfkind K. % added 3/8/09. + +%% worlds %% + +%block evar : block {ex:etm}. +%block ebind : some {ea:etp} + block {ex:etm} {ed:evof ex ea}. +%block eofblock : some {ex:etm} {ea:etp} + block {ed:evof ex ea}. + +%% a closed etm %% + +ace : etm = econst unit. + +%% Sample signature. A test and a thing to make stuff split. +anat : ctp. +dkof_nat : ckof anat ktype. +dekof_nat : eckof anat ektype. + +czero : ctm. +dof_zero : cof czero (base (aconst anat)). +deof_zero : ecof czero (eaconst anat). + diff --git a/src/pi-inj.thm b/src/pi-inj.thm new file mode 100644 index 0000000..bed66e9 --- /dev/null +++ b/src/pi-inj.thm @@ -0,0 +1,2251 @@ +%% First: direct proof of alam-invert %% + +eqkind-pi-invert : eqkind K* (ekpi A K) + -> ekind-eq K* (ekpi A' K') + -> eqtp A A' ektype + -> ({x} evof x A -> eqkind (K x) (K' x)) -> type. +%mode eqkind-pi-invert +X1 -X2 -X3 -X4. + +eqkind-pi-invert' : eqkind (ekpi A K) K* + -> ekind-eq K* (ekpi A' K') + -> eqtp A A' ektype + -> ({x} evof x A -> eqkind (K x) (K' x)) -> type. +%mode eqkind-pi-invert' +X1 -X2 -X3 -X4. + +- : eqkind-pi-invert + (eqkind/pi + ([x] [d:evof x A] DeqK x d : eqkind (K x) (K' x)) + (DeqA : eqtp A A' ektype)) + ekind-eq/i + (eqtp/sym DeqA) + DeqK' + <- eqtp-reg DeqA _ DofA' _ + <- ({x} {d:evof x A'} + esubst-eqkind + ([x] [d:evof x A] eqkind/sym (DeqK x d)) + (eof/eqtp (eqtp/sym DeqA) (eof/var DofA' d)) + (DeqK' x d : eqkind (K' x) (K x))). + +- : eqkind-pi-invert (eqkind/sym DeqK') + Deq + DeqAA' + DeqKK' + <- eqkind-pi-invert' DeqK' + (Deq : ekind-eq K* (ekpi A' K')) + (DeqAA' : eqtp A A' ektype) + ([x] [d:evof x A] DeqKK' x d : eqkind (K x) (K' x)). + +- : eqkind-pi-invert + (eqkind/refl (ewfkind/pi ([x] [d:evof x A] DofK x d) DofA)) + ekind-eq/i + (eqtp/refl DofA) + ([x] [d] eqkind/refl (DofK x d)). + +- : eqkind-pi-invert + (eqkind/trans + (DequivK** : eqkind K** (ekpi A K)) + (DequivK* : eqkind K* K**)) + DeqK* + (eqtp/trans DequivA' DequivA) + ([x] [d] eqkind/trans (DequivK'_ x d) (DequivK x d)) + <- eqkind-pi-invert DequivK** + (DeqK** : ekind-eq K** (ekpi A' K')) + (DequivA : eqtp A A' ektype) + ([x] [d:evof x A] DequivK x d : eqkind (K x) (K' x)) + <- eqkind-resp DequivK* ekind-eq/i DeqK** + (DequivK*Pi : eqkind K* (ekpi A' K')) + <- eqkind-pi-invert DequivK*Pi + (DeqK* : ekind-eq K* (ekpi A'' K'')) + (DequivA' : eqtp A' A'' ektype) + ([x] [d:evof x A'] DequivK' x d : eqkind (K' x) (K'' x)) + %% get DequivK' under the right binder + <- eqtp-reg DequivA + DofA _ _ + <- ({x} {d:evof x A} + esubst-eqkind ([x] [d:evof x A'] DequivK' x d) + (eof/eqtp DequivA (eof/var DofA d)) + (DequivK'_ x d : eqkind (K' x) (K'' x))). + +%% + +- : eqkind-pi-invert' (eqkind/pi DeqK DeqA) ekind-eq/i DeqA DeqK. + +- : eqkind-pi-invert' (eqkind/sym (DequivK* : eqkind K* (ekpi A K))) + DeqK* + DeqA + DeqK + <- eqkind-pi-invert DequivK* + (DeqK* : ekind-eq K* (ekpi A' K')) + DeqA + DeqK. + +- : eqkind-pi-invert' + (eqkind/refl (ewfkind/pi ([x] [d:evof x A] DofK x d) DofA)) + ekind-eq/i + (eqtp/refl DofA) + ([x] [d] eqkind/refl (DofK x d)). + +- : eqkind-pi-invert' + (eqkind/trans + (DequivK* : eqkind K* K**) + (DequivPiK* : eqkind (ekpi A K) K*)) + DeqK** + (eqtp/trans DequivA' DequivA) + ([x] [d] eqkind/trans (DequivK'_ x d) (DequivK x d)) + <- eqkind-pi-invert' DequivPiK* + (DeqK* : ekind-eq K* (ekpi A' K')) + (DequivA : eqtp A A' ektype) + ([x] [d:evof x A] DequivK x d : eqkind (K x) (K' x)) + <- eqkind-resp DequivK* DeqK* ekind-eq/i + (DequivPiK** : eqkind (ekpi A' K') K**) + <- eqkind-pi-invert' DequivPiK** + (DeqK** : ekind-eq K** (ekpi A'' K'')) + (DequivA' : eqtp A' A'' ektype) + ([x] [d:evof x A'] DequivK' x d : eqkind (K' x) (K'' x)) + %% get DequivK' under the right binder + <- eqtp-reg DequivA + DofA _ _ + <- ({x} {d:evof x A} + esubst-eqkind ([x] [d:evof x A'] DequivK' x d) + (eof/eqtp DequivA (eof/var DofA d)) + (DequivK'_ x d : eqkind (K' x) (K'' x))). + +%worlds (ecsig | easig | ebind | evar) + (eqkind-pi-invert _ _ _ _) + (eqkind-pi-invert' _ _ _ _). +%total (D1 D2) + (eqkind-pi-invert D1 _ _ _) + (eqkind-pi-invert' D2 _ _ _). + +%% more useful lemma related to the above %% + +eqkind-pi-pi-invert : eqkind (ekpi A K) (ekpi A' K') + -> eqtp A A' ektype + -> ({x} {d:evof x A} eqkind (K x) (K' x)) -> type. +%mode eqkind-pi-pi-invert +X1 -X2 -X3. + +- : eqkind-pi-pi-invert + (Deq : eqkind (ekpi A K) (ekpi A' K')) + DequivAA' + DequivKK' + <- eqkind-pi-invert' Deq + (DeqA'K' : ekind-eq (ekpi A' K') (ekpi A'* K'*)) + (DequivA : eqtp A A'* ektype) + ([x] [d:evof x A] DequivK x d : eqkind (K x) (K'* x)) + %% + <- ekpi-inj DeqA'K' + (DeqA'A'* : etp-eq A' A'*) + ([x] DeqK'K'* x : ekind-eq (K' x) (K'* x)) + <- etp-eq-sym DeqA'A'* DeqA'*A' + <- eqtp-resp DequivA etp-eq/i DeqA'*A' ekind-eq/i + (DequivAA' : eqtp A A' ektype) + %% + <- ({x} ekind-eq-sym (DeqK'K'* x) (DeqK'*K' x)) + <- ({x} {d:evof x A} + eqkind-resp (DequivK x d) ekind-eq/i (DeqK'*K' x) + (DequivKK' x d : eqkind (K x) (K' x))). + +%worlds (ecsig | easig | ebind) (eqkind-pi-pi-invert _ _ _). +%total D (eqkind-pi-pi-invert D _ _). + +%% Explicit contexts version + +eqkinde-pi-invert : eordered G + -> eqkinde G K* (ekpi A K) + -> ekind-eq K* (ekpi A' K') + -> eqtpe G A A' ektype + -> ({x} eqkinde (econs G x A) (K x) (K' x)) -> type. +%mode eqkinde-pi-invert +X0 +X1 -X2 -X3 -X4. + +eqkinde-pi-invert' : eordered G + -> eqkinde G (ekpi A K) K* + -> ekind-eq K* (ekpi A' K') + -> eqtpe G A A' ektype + -> ({x} eqkinde (econs G x A) (K x) (K' x)) -> type. +%mode eqkinde-pi-invert' +X0 +X1 -X2 -X3 -X4. + +- : eqkinde-pi-invert + (Dord : eordered G) + (eqkinde/pi + ([x] DeqK x : eqkinde (econs G x A) (K x) (K' x)) + (DeqA : eqtpe G A A' ektype)) + ekind-eq/i + (eqtpe/sym DeqA) + ([x] eqkinde/sym (DeqK' x)) + <- extend-eordered _ Dord _ + ([x] [d] Dord' x d : eordered (econs G x A)) + <- eqkinde-tcon-bind Dord' DeqA DeqK + ([x] DeqK' x : eqkinde (econs G x A') (K x) (K' x)). + +- : eqkinde-pi-invert Dord (eqkinde/sym DeqK') + Deq + DeqAA' + DeqKK' + <- eqkinde-pi-invert' Dord DeqK' Deq DeqAA' DeqKK'. + +- : eqkinde-pi-invert Dord (eqkinde/refl (ewfkinde/pi DofB DofK)) + ekind-eq/i + (eqtpe/refl DofB) + ([x] eqkinde/refl (DofK x)). + +- : eqkinde-pi-invert Dord + (eqkinde/trans + (DequivK** : eqkinde G K** (ekpi A K)) + (DequivK* : eqkinde G K* K**)) + DeqK* + (eqtpe/trans DequivA' DequivA) + ([x] eqkinde/trans (DequivK'' x) (DequivK x)) + <- eqkinde-pi-invert Dord DequivK** + (DeqK** : ekind-eq K** (ekpi A' K')) + (DequivA : eqtpe G A A' ektype) + ([x] DequivK x : eqkinde (econs G x A) (K x) (K' x)) + <- eqkinde-resp ectx-eq/i ekind-eq/i DeqK** DequivK* + (DequivK*Pi : eqkinde G K* (ekpi A' K')) + <- eqkinde-pi-invert Dord DequivK*Pi + (DeqK* : ekind-eq K* (ekpi A'' K'')) + (DequivA' : eqtpe G A' A'' ektype) + ([x] DequivK' x : eqkinde (econs G x A') (K' x) (K'' x)) + %% Get K' = K'' under A instead of A' + <- extend-eordered _ Dord _ Dord' + <- eqkinde-tcon-bind Dord' (eqtpe/sym DequivA) DequivK' + ([x] DequivK'' x : eqkinde (econs G x A) (K' x) (K'' x)). + +%% + +- : eqkinde-pi-invert' _ (eqkinde/pi DeqK DeqA) ekind-eq/i DeqA DeqK. + +- : eqkinde-pi-invert' Dord (eqkinde/sym DequivK) + DeqK + DequivA + DequivK' + <- eqkinde-pi-invert Dord DequivK + DeqK + DequivA + DequivK'. + +- : eqkinde-pi-invert' Dord + (eqkinde/refl (ewfkinde/pi DofA DofK)) + ekind-eq/i + (eqtpe/refl DofA) + ([x] eqkinde/refl (DofK x)). + +- : eqkinde-pi-invert' Dord + (eqkinde/trans + (DequivK* : eqkinde G K* K**) + (DequivPiK* : eqkinde G (ekpi A K) K*)) + DeqK** + (eqtpe/trans DequivA' DequivA) + ([x] eqkinde/trans (DequivK'' x) (DequivK x)) + <- eqkinde-pi-invert' Dord DequivPiK* + (DeqK* : ekind-eq K* (ekpi A' K')) + (DequivA : eqtpe G A A' ektype) + ([x] DequivK x : eqkinde (econs G x A) (K x) (K' x)) + <- eqkinde-resp ectx-eq/i DeqK* ekind-eq/i DequivK* + (DequivPiK** : eqkinde G (ekpi A' K') K**) + <- eqkinde-pi-invert' Dord DequivPiK** + (DeqK** : ekind-eq K** (ekpi A'' K'')) + (DequivA' : eqtpe G A' A'' ektype) + ([x] DequivK' x : eqkinde (econs G x A') (K' x) (K'' x)) + %% Get K' = K'' under A instead of A' + <- extend-eordered _ Dord _ Dord' + <- eqkinde-tcon-bind Dord' (eqtpe/sym DequivA) DequivK' + ([x] DequivK'' x : eqkinde (econs G x A) (K' x) (K'' x)). + +%worlds (ecsig | easig | eovar | ebind | evar) + (eqkinde-pi-invert _ _ _ _ _) + (eqkinde-pi-invert' _ _ _ _ _). +%total (D1 D2) + (eqkinde-pi-invert _ D1 _ _ _) + (eqkinde-pi-invert' _ D2 _ _ _). + +eqkinde-pi-pi-invert : eordered G -> eqkinde G (ekpi A K) (ekpi A' K') + -> eqtpe G A A' ektype + -> ({x} eqkinde (econs G x A) (K x) (K' x)) -> type. +%mode eqkinde-pi-pi-invert +X0 +X1 -X2 -X3. + +- : eqkinde-pi-pi-invert Dord + (Deq : eqkinde G (ekpi A K) (ekpi A' K')) + DequivAA' + DequivKK' + <- eqkinde-pi-invert' Dord Deq + (DeqA'K' : ekind-eq (ekpi A' K') (ekpi A'* K'*)) + (DequivA : eqtpe G A A'* ektype) + ([x] DequivK x : eqkinde (econs G x A) (K x) (K'* x)) + %% + <- ekpi-inj DeqA'K' + (DeqA'A'* : etp-eq A' A'*) + ([x] DeqK'K'* x : ekind-eq (K' x) (K'* x)) + <- etp-eq-sym DeqA'A'* DeqA'*A' + <- eqtpe-resp ectx-eq/i etp-eq/i DeqA'*A' ekind-eq/i DequivA + (DequivAA' : eqtpe G A A' ektype) + %% + <- ({x} ekind-eq-sym (DeqK'K'* x) (DeqK'*K' x)) + <- ({x} + eqkinde-resp ectx-eq/i ekind-eq/i (DeqK'*K' x) (DequivK x) + (DequivKK' x : eqkinde (econs G x A) (K x) (K' x))). + +%worlds (ecsig | easig | evar | eovar | ebind) (eqkinde-pi-pi-invert _ _ _ _). +%total {} (eqkinde-pi-pi-invert _ _ _ _). + + +%% Type family normalization and similarity %% +%% This normalizes away the family-level redexes. + +norm : etp -> etp -> type. + +norm/pi : norm (epi A B) (epi A B). + +norm/lam : norm (ealam A B) (ealam A B') + <- ({x} norm (B x) (B' x)). + +norm/app : norm (eaapp B M) (B' M) + <- norm B (ealam A B'). + +sim : etp -> etp -> ekind -> type. + +sim/pi : sim (epi A B) (epi C D) ektype + <- eqtp A C ektype + <- ({x} evof x A -> eqtp (B x) (D x) ektype). + +sim/lam : sim (ealam A B) (ealam C D) (ekpi E K) + % A sim C sim E : type isn't necessary. + <- ({x} evof x E -> sim (B x) (D x) (K x)). + +%% Sim lemmas %% + +sim-resp : sim A B K -> etp-eq A A' -> etp-eq B B' -> ekind-eq K K' + -> sim A' B' K' -> type. +%mode sim-resp +X0 +X1 +X2 +X4 -X5. + +- : sim-resp D etp-eq/i etp-eq/i ekind-eq/i D. + +%worlds (ecsig | easig | evar | ebind) (sim-resp _ _ _ _ _). +%total {} (sim-resp _ _ _ _ _). + +sim-sub-gen : (evof M A -> sim B C K) + -> (eof M A -> sim B C K) -> type. +%mode sim-sub-gen +X1 -X2. + +-pi : sim-sub-gen + ([d:evof M A] + sim/pi + ([y] [e:evof y B] DeqC d y e : eqtp (C y) (C' y) ektype) + (DeqB d : eqtp B B' ektype)) + ([d:eof M A] + sim/pi + ([y] [e] DeqC' y e d) + (DeqB' d)) + <- esubst-eqtp-gen DeqB + (DeqB' : eof M A -> eqtp B B' ektype) + <- ({y} {e:evof y B} + esubst-eqtp-gen ([d] DeqC d y e) + (DeqC' y e : eof M A -> eqtp (C y) (C' y) ektype)). + +-lam : sim-sub-gen + ([d:evof M A] + sim/lam + ([y] [e:evof y B] DsimC d y e : sim (C y) (C' y) (K y))) + ([d:eof M A] + sim/lam + ([y] [e] DsimC' y e d)) + <- ({y} {e:evof y B} + sim-sub-gen ([d] DsimC d y e) + (DsimC' y e : eof M A -> sim (C y) (C' y) (K y))). + +%worlds (ecsig | easig | evar | ebind) (sim-sub-gen _ _). +%total D (sim-sub-gen D _). + +sim-sub : ({x} {d:evof x A} sim (B x) (C x) (K x)) + -> eof N A + -> sim (B N) (C N) (K N) -> type. +%mode sim-sub +X1 +X2 -X3. + +- : sim-sub ([x] [d:evof x A] Dsim x d) Dof + (Dsim' Dof) + <- sim-sub-gen (Dsim _) Dsim'. + +%worlds (ecsig | easig | evar | ebind) (sim-sub _ _ _). +%total {} (sim-sub _ _ _). + + +sim-vof-con : ({x} evof x A -> sim (B x) (C x) (K x)) + -> eqtp A A' ektype + -> ({x} evof x A' -> sim (B x) (C x) (K x)) -> type. +%mode sim-vof-con +X1 +X2 -X3. + +- : sim-vof-con + ([x] [d:evof x A] Dsim x d : sim (B x) (C x) (K x)) + (Deqtp : eqtp A A' ektype) + Dsim' + <- eqtp-reg Deqtp + (DofA : ekof A ektype) + (DofA' : ekof A' ektype) + _ + <- ({x} {d:evof x A'} + sim-sub + ([x] [d:evof x A] Dsim x d) + (eof/eqtp (eqtp/sym Deqtp) (eof/var DofA' d)) + (Dsim' x d : sim (B x) (C x) (K x))). + +%worlds (ecsig | easig | evar | ebind) (sim-vof-con _ _ _). +%total {} (sim-vof-con _ _ _). + +sim-kcon : sim A B K -> eqkind K L -> sim A B L -> type. +%mode sim-kcon +X1 +X2 -X3. +%% for symmetry +sim-kcon' : sim A B K -> eqkind L K -> sim A B L -> type. +%mode sim-kcon' +X1 +X2 -X3. + +- : sim-kcon Dsim eqkind/tp Dsim. + +- : sim-kcon Dsim (eqkind/refl _) Dsim. + +- : sim-kcon + (Dsim : sim A B K) + (eqkind/sym (Deqk : eqkind L K)) + Dsim' + <- sim-kcon' Dsim Deqk Dsim'. + +- : sim-kcon + (Dsim : sim A B K) + (eqkind/trans (Deqk' : eqkind K' L) (Deqk : eqkind K K')) + Dsim'' + <- sim-kcon Dsim Deqk + (Dsim' : sim A B K') + <- sim-kcon Dsim' Deqk' + (Dsim'' : sim A B L). + +- : sim-kcon + (sim/lam ([x] [d:evof x A] DsimB x d : sim (B x) (D x) (K x)) + : sim (ealam E B) (ealam E' D) (ekpi A K)) + (eqkind/pi + ([x] [d:evof x A] DeqK x d : eqkind (K x) (L x)) + (DeqA : eqtp A A' ektype)) + (sim/lam DsimB'') + <- ({x} {d:evof x A} + sim-kcon (DsimB x d) (DeqK x d) + (DsimB' x d : sim (B x) (D x) (L x))) + <- sim-vof-con DsimB' DeqA + ([x] [d:evof x A'] DsimB'' x d : sim (B x) (D x) (L x)). + +%% symmetric cases + +- : sim-kcon' Dsim eqkind/tp Dsim. + +- : sim-kcon' Dsim (eqkind/refl _) Dsim. + +- : sim-kcon' + (Dsim : sim A B K) + (eqkind/sym (Deqk : eqkind K L)) + Dsim' + <- sim-kcon Dsim Deqk Dsim'. + +- : sim-kcon' + (Dsim : sim A B L) + (eqkind/trans (Deqk' : eqkind K' L) (Deqk : eqkind K K')) + Dsim'' + <- sim-kcon' Dsim Deqk' + (Dsim' : sim A B K') + <- sim-kcon' Dsim' Deqk + (Dsim'' : sim A B K). + +- : sim-kcon' + (sim/lam ([x] [d:evof x A] DsimB x d : sim (B x) (D x) (K x)) + : sim (ealam E B) (ealam E' D) (ekpi A K)) + (eqkind/pi + ([x] [d:evof x A'] DeqL x d : eqkind (L x) (K x)) + (DeqA : eqtp A' A ektype)) + (sim/lam DsimB'') + <- sim-vof-con DsimB (eqtp/sym DeqA) + ([x] [d:evof x A'] DsimB' x d : sim (B x) (D x) (K x)) + <- ({x} {d:evof x A'} + sim-kcon' (DsimB' x d) (DeqL x d) + (DsimB'' x d : sim (B x) (D x) (L x))). + +%worlds (ecsig | easig | evar | ebind) (sim-kcon _ _ _) (sim-kcon' _ _ _). +%total (D1 D2) (sim-kcon _ D1 _) (sim-kcon' _ D2 _). + +%% Need an explicit contexts sim in order to do functionality. + +sime : ectx -> etp -> etp -> ekind -> type. + +sime/pi : sime G (epi A B) (epi C D) ektype + <- eqtpe G A C ektype + <- ({x} eqtpe (econs G x A) (B x) (D x) ektype). + +sime/lam : sime G (ealam A B) (ealam C D) (ekpi E K) + <- ({x} sime (econs G x E) (B x) (D x) (K x)). + +weakeng-sime : eappend G1 G2 G + -> eappend (econs G1 X C) G2 G' + -> sime G A B K +%% + -> sime G' A B K -> type. +%mode weakeng-sime +X1 +X2 +X3 -X4. + +-pi : weakeng-sime Dappend Dappend' + (sime/pi + ([x] DeqB x : eqtpe (econs G x A) (B x) (B' x) ektype) + (DeqA : eqtpe G A A' ektype)) + (sime/pi DeqB' DeqA') + <- weakeng-eqtpe Dappend Dappend' DeqA DeqA' + <- ({x} + weakeng-eqtpe (eappend/cons Dappend) (eappend/cons Dappend') + (DeqB x) + (DeqB' x)). + +-lam : weakeng-sime Dapp Dapp' + (sime/lam + ([x] DeqB x : sime (econs G x A) (B x) (B' x) (K x))) + (sime/lam DeqB') + <- ({x} + weakeng-sime (eappend/cons Dapp) (eappend/cons Dapp') + (DeqB x) + (DeqB' x)). + +%worlds (ecsig | easig | evar | ebind) (weakeng-sime _ _ _ _). +%total D (weakeng-sime _ _ D _). + +sime-sub : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) + -> ({x} sime (G x) (B1 x) (B2 x) (K x)) + -> eofe G1 N A + -> ecsub ([x] G x) N Gx +%% + -> sime Gx (B1 N) (B2 N) (K N) -> type. +%mode sime-sub +X1 +X2 +X3 +X4 +X5 -X6. + +-pi : sime-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + ([x] + sime/pi + ([y] DeqC x y + : eqtpe (econs (G x) y (B x)) (C x y) (C' x y) ektype) + (DeqB x + : eqtpe (G x) (B x) (B' x) ektype)) + (DofN : eofe G1 N A) + (Dcsub : ecsub G N Gx) +%% + (sime/pi DeqCx DeqBx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtpe-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DeqC x y) DofN (ecsub/cons Dcsub) + (DeqCx y + : eqtpe (econs Gx y (B N)) (C N y) (C' N y) ektype)) + <- eqtpe-sub Dord Dappend DeqB DofN Dcsub DeqBx. + +-lam : sime-sub + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + ([x] + sime/lam + ([y] DsimC x y + : sime (econs (G x) y (B x)) (C x y) (C' x y) (K x y))) + (DofN : eofe G1 N A) + (Dcsub : ecsub G N Gx) +%% + (sime/lam DsimCx) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : eordered (econs (G x) y (B x)))) + <- ({y} {e} + sime-sub + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + ([x] DsimC x y) DofN (ecsub/cons Dcsub) + (DsimCx y + : sime (econs Gx y (B N)) (C N y) (C' N y) (K N y))). + +%worlds (ecsig | easig | evar | eovar | ebind) (sime-sub _ _ _ _ _ _). +%total D (sime-sub _ _ D _ _ _). + + +sime-kcon : eordered G -> sime G A B K -> eqkinde G K L + -> sime G A B L -> type. +%mode sime-kcon +X0 +X1 +X2 -X3. +%% for symmetry +sime-kcon' : eordered G -> sime G A B K -> eqkinde G L K + -> sime G A B L -> type. +%mode sime-kcon' +X0 +X1 +X2 -X3. + +- : sime-kcon _ Dsime eqkinde/tp Dsime. + +- : sime-kcon _ Dsime (eqkinde/refl _) Dsime. + +- : sime-kcon Dord Dsime (eqkinde/sym Deqk) Dsime' + <- sime-kcon' Dord Dsime Deqk Dsime'. + +- : sime-kcon Dord Dsime (eqkinde/trans Deqk' Deqk) + Dsime'' + <- sime-kcon Dord Dsime Deqk Dsime' + <- sime-kcon Dord Dsime' Deqk' Dsime''. + +- : sime-kcon Dord + (sime/lam DsimeB) + (eqkinde/pi DeqK DeqA) + (sime/lam DsimeB''') + <- extend-eordered _ Dord _ Dord' + <- ({x} {d} + sime-kcon (Dord' x d) (DsimeB x) (DeqK x) + (DsimeB' x : sime (econs G x A) (B x) (B' x) (K x))) + %% finagle the bound var from A to A': + %% (XXX make this a lemma?) + %% first, weaken x' : A' before x : A + <- ({x} {x'} + weakeng-sime + (eappend/cons eappend/nil) + (eappend/cons eappend/nil) + (DsimeB' x) + (DsimeB'' x x' + : sime (econs (econs G x' A') x A) (B x) (B' x) (K x))) + %% need to weaken A = A', and get wfness of A' + <- ({x'} + weaken-eqtpe DeqA _ _ + (DeqA' x' : eqtpe (econs G x' A') A A' ektype)) + <- extend-eordered _ Dord _ Dord'' + <- ({x'} {d'} + eqtpe-reg (Dord'' x' d') (DeqA' x') (_1 x') (DofA' x') (_2 x')) + %% then subst x' for x + <- ({x'} {d'} + extend-eordered _ (Dord'' x' d') _nat + ([x] [d] Dord''' x d x' d')) + <- ({x'} {d'} + sime-sub ([x] [d] Dord''' x d x' d') ([_] eappend/nil) + ([x] DsimeB'' x x') + (eofe/eqtp + (eqtpe/sym (DeqA' x')) + (eofe/var (DofA' x') elookup/hit)) ecsub/base + (DsimeB''' x' + : sime (econs G x' A') (B x') (B' x') (K x'))). + +%% symmetric cases + +- : sime-kcon' _ Dsime eqkinde/tp Dsime. + +- : sime-kcon' _ Dsime (eqkinde/refl _) Dsime. + +- : sime-kcon' Dord Dsime (eqkinde/sym Deqk) + Dsime' + <- sime-kcon Dord Dsime Deqk Dsime'. + +- : sime-kcon' Dord Dsime (eqkinde/trans Deqk' Deqk) + Dsime'' + <- sime-kcon' Dord Dsime Deqk' + (Dsime' : sime G A B K') + <- sime-kcon' Dord Dsime' Deqk + (Dsime'' : sime G A B K). + +- : sime-kcon' Dord + (sime/lam + ([x] DsimeB x : sime (econs G x A) (B x) (D x) (K x)) + : sime G (ealam E B) (ealam E' D) (ekpi A K)) + (eqkinde/pi + ([x] DeqL x : eqkinde (econs G x A') (L x) (K x)) + (DeqA : eqtpe G A' A ektype)) + (sime/lam DsimeB''') + %% finagle the bound var in DsimeB from A to A': + %% first, weaken x' : A' before x : A + <- ({x} {x'} + weakeng-sime + (eappend/cons eappend/nil) + (eappend/cons eappend/nil) + (DsimeB x) + (DsimeB' x x' + : sime (econs (econs G x' A') x A) (B x) (D x) (K x))) + %% weaken A = A' and get wfness of A' + <- ({x'} + weaken-eqtpe DeqA _ _ + (DeqA' x' : eqtpe (econs G x' A') A' A ektype)) + <- extend-eordered _ Dord _ Dord' + <- ({x'} {d'} + eqtpe-reg (Dord' x' d') (DeqA' x') + (DofA x') (DofA' x') (_1 x')) + %% subst x' for x + <- ({x'} {d'} + extend-eordered _ (Dord' x' d') _nat + ([x] [d] Dord'' x d x' d')) + <- ({x'} {d'} + sime-sub ([x] [d] Dord'' x d x' d') ([_] eappend/nil) + ([x] DsimeB' x x') + (eofe/eqtp + (DeqA' x') + (eofe/var (DofA x') elookup/hit)) + ecsub/base + (DsimeB'' x' + : sime (econs G x' A') (B x') (D x') (K x'))) + %% + <- extend-eordered _ Dord _ Dord* + <- ({x} {d} + sime-kcon' (Dord* x d) (DsimeB'' x) (DeqL x) + (DsimeB''' x : sime (econs G x A') (B x) (D x) (L x))). + +%worlds (ecsig | easig | eovar) (sime-kcon _ _ _ _) (sime-kcon' _ _ _ _). +%total (D1 D2) (sime-kcon _ _ D1 _) (sime-kcon' _ _ D2 _). + +%%%% + +%% [ispi A K] means A is a pi underneath kind K. +ispi : etp -> ekind -> type. + +ispi/pi : ispi (epi A B) ektype + <- ekof A ektype + <- ({x} evof x A -> ekof (B x) ektype). + +ispi/lam : ispi (ealam A' B) (ekpi A K) + <- ekof A ektype %% added 2/23/2011 for regularity + <- ({x} evof x A -> ispi (B x) (K x)). + +%% explicit contexts version +ispie : ectx -> etp -> ekind -> type. + +ispie/pi : ispie G (epi A B) ektype + <- ekofe G A ektype + <- ({x} ekofe (econs G x A) (B x) ektype). + +ispie/lam : ispie G (ealam A' B) (ekpi A K) + <- ekofe G A ektype + <- ({x} ispie (econs G x A) (B x) (K x)). + +sim-fun-e : ({x} eisvar x I -> eordered (G x)) + -> ({x} eappend (econs G1 x A) (G2 x) (G x)) + -> eqtme G1 M N A + -> ({x} ispie (G x) (B x) (K x)) + -> ecsub G M Gx +%% + -> sime Gx (B M) (B N) (K M) -> type. +%mode sim-fun-e +X1 +X2 +X2 +X4 +X5 -X6. + +-pi : sim-fun-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtm : eqtme G1 M N A) + ([x] + ispie/pi + ([y] DofC x y : ekofe (econs (G x) y (B x)) (C x y) ektype) + (DofB x : ekofe (G x) (B x) ektype)) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (sime/pi DeqC DeqB) +%% + <- ({x} {d} + eordered-append (Dappend x) (Dord x d) + (DordG1xA x d : eordered (econs G1 x A))) + <- ({x} {d} + eordered-cons (DordG1xA x d) + (DordG1' x d : eordered G1)) + <- strengthen-eordered DordG1' DordG1 + <- eqtme-reg DordG1 Deqtm DofM DofN DofA + <- eqtm-tpsub-e Dord Dappend Deqtm DofM DofN DofB Dcsub + (DeqB : eqtpe Gx (B M) (B N) ektype) + <- ({x} {d} + extend-eordered _ (Dord x d) _dontcare + ([y] [e] Dord' x d y e : eordered (econs (G x) y (B x)))) + <- ({y} {e} + eqtm-tpsub-e + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + Deqtm DofM DofN ([x] DofC x y) (ecsub/cons Dcsub) + (DeqC y : eqtpe (econs Gx y (B M)) (C M y) (C N y) ektype)). + +-lam : sim-fun-e + ([x] [d] Dord x d : eordered (G x)) + ([x] Dappend x : eappend (econs G1 x A) (G2 x) (G x)) + (Deqtm : eqtme G1 M N A) + ([x] + ispie/lam + ([y] DispiC x y + : ispie (econs (G x) y (B x)) (C x y) (K x y)) + _) + (Dcsub : ecsub ([x] G x) M Gx) +%% + (sime/lam DsimC) +%% + <- ({x} {d} + extend-eordered _ (Dord x d) _dontcare + ([y] [e] Dord' x d y e : eordered (econs (G x) y (B x)))) + <- ({y} {e} + sim-fun-e + ([x] [d] Dord' x d y e) + ([x] eappend/cons (Dappend x)) + Deqtm ([x] DispiC x y) (ecsub/cons Dcsub) + (DsimC y : sime (econs Gx y (B M)) (C M y) (C N y) (K M y))). + +%worlds (ecsig | easig | evar | ebind | eovar) (sim-fun-e _ _ _ _ _ _). +%total D (sim-fun-e _ _ _ D _ _). + +%%%% Explicit/implicit contexts sim conversion %%%% + +%% cut %% + +msim : sim A B K -> metric -> type. +msime : sime G A B K -> metric -> type. + +msim/pi : msim (sim/pi ([x] [d] DeqB x d) DeqA) (mpair M1 M2) + <- meqtp DeqA M1 + <- ({x} {d} meqtp (DeqB x d) M2). + +msim/lam : msim (sim/lam ([x] [d] Dsim x d)) (msing M) + <- ({x} {d} msim (Dsim x d) M). + +msime/pi : msime (sime/pi ([x] DeqB x) DeqA) (mpair M1 M2) + <- meqtpe DeqA M1 + <- ({x} meqtpe (DeqB x) M2). + +msime/lam : msime (sime/lam ([x] DsimB x)) (msing M) + <- ({x} msime (DsimB x) M). + +can-msim : {D:sim A B K} msim D M -> type. +%mode can-msim +X1 -X2. + +- : can-msim (sim/pi D2 D1) (msim/pi D2' D1') + <- can-meqtp D1 D1' + <- ({x} {d} can-meqtp (D2 x d) (D2' x d)). + +- : can-msim (sim/lam D) (msim/lam D') + <- ({x} {d} can-msim (D x d) (D' x d)). + +%worlds (ecsig | easig | evar | eovar | ebind) (can-msim _ _). +%total D (can-msim D _). + +cut-sim-m : {M} + {D : {x} {d:evof x A} sim (B x) (B' x) (K x)} + ({x} {d} msim (D x d) M) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} sime (G x) (B x) (B' x) (K x)} + ({x} msime (D' x) M) -> type. +%mode cut-sim-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-sime-m : {M} + {D : {x} {d:evof x A} sime (G x) (B x) (B' x) (K x)} + ({x} {d} msime (D x d) M) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} sime (G x) (B x) (B' x) (K x)} + ({x} msime (D' x) M) -> type. +%mode cut-sime-m +X1 +X2 +X3 +X4 -X5 -X6. + +-pi : cut-sim-m (mpair Am Bm) + ([x] [d] + sim/pi + ([y] [e] DeqB x d y e : eqtp (B x y) (B' x y) ektype) + (DeqA x d : eqtp (A x) (A' x) ektype)) + ([x] [d] + msim/pi + ([y] [e] DmeqB x d y e : meqtp (DeqB x d y e) Bm) + (DmeqA x d : meqtp (DeqA x d) Am)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] sime/pi (DeqeB' x) (DeqeA x)) + ([x] msime/pi (DmeqeB' x) (DmeqeA x)) +%% + <- cut-eqtp-m Am DeqA DmeqA Dlook + DeqeA DmeqeA + <- ({x} {d} + cut-eqtp-m Bm ([y] [e] DeqB x d y e) ([y] [e] DmeqB x d y e) + ([y] elookup/hit) + ([y] DeqeB x d y) + ([y] DmeqeB x d y)) + <- ({y} + cut-eqtpe-m Bm ([x] [d] DeqeB x d y) ([x] [d] DmeqeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y) + ([x] DmeqeB' x y)). + +-lam : cut-sim-m (msing M) + ([x] [d] + sim/lam + ([y] [e] DsimB x d y e : sim (B x y) (B' x y) (K x y))) + ([x] [d] + msim/lam + ([y] [e] DmsimB x d y e : msim (DsimB x d y e) M)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] sime/lam (DsimeB' x)) + ([x] msime/lam (DmsimeB' x)) +%% + <- ({x} {d} + cut-sim-m M ([y] [e] DsimB x d y e) ([y] [e] DmsimB x d y e) + ([y] elookup/hit) + ([y] DsimeB x d y) + ([y] DmsimeB x d y)) + <- ({y} + cut-sime-m M ([x] [d] DsimeB x d y) ([x] [d] DmsimeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DsimeB' x y) + ([x] DmsimeB' x y)). + +%% + +-pi : cut-sime-m (mpair Am Bm) + ([x] [d] sime/pi (DeqB x d) (DeqA x d)) + ([x] [d] msime/pi (DmeqB x d) (DmeqA x d)) + ([x] Dlook x : elookup (G x) x C) +%% + ([x] sime/pi (DeqeB' x) (DeqeA x)) + ([x] msime/pi (DmeqeB' x) (DmeqeA x)) +%% + <- cut-eqtpe-m Am DeqA DmeqA Dlook + ([x] DeqeA x : eqtpe (G x) (A x) (A' x) ektype) + ([x] DmeqeA x : meqtpe (DeqeA x) Am) + <- ({y} + cut-eqtpe-m Bm ([x] [d] DeqB x d y) ([x] [d] DmeqB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DeqeB' x y + : eqtpe (econs (G x) y (A x)) (B x y) (B' x y) ektype) + ([x] DmeqeB' x y + : meqtpe (DeqeB' x y) Bm)). + +-lam : cut-sime-m (msing M) + ([x] [d] sime/lam (DsimB x d)) + ([x] [d] msime/lam (DmsimB x d)) + ([x] Dlook x) +%% + ([x] sime/lam ([y] DsimB' x y)) + ([x] msime/lam ([y] DmsimB' x y)) +%% + <- ({y} + cut-sime-m M ([x] [d] DsimB x d y) ([x] [d] DmsimB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DsimB' x y) + ([x] DmsimB' x y)). + +%worlds (ecsig | easig | evar | eovar | ebind) + (cut-sim-m _ _ _ _ _ _) + (cut-sime-m _ _ _ _ _ _). +%total {(M1 M2)} + (cut-sim-m M1 _ _ _ _ _) + (cut-sime-m M2 _ _ _ _ _). + +cut-sim : ({x} evof x A -> sim (B x) (B' x) (K x)) + -> ({x} elookup (G x) x A) +%% + -> ({x} sime (G x) (B x) (B' x) (K x)) -> type. +%mode cut-sim +X1 +X2 -X3. + +- : cut-sim ([x] [d] Dsim x d) Dlook + Dsim' + <- ({x} {d} + can-msim (Dsim x d) (Dmsim x d)) + <- cut-sim-m _ Dsim Dmsim Dlook Dsim' _. + +%worlds (ecsig | easig | evar | eovar | ebind) (cut-sim _ _ _). +%total {} (cut-sim _ _ _). + +%% same thing for ispi + +mispi : ispi A K -> metric -> type. +mispie : ispie G A K -> metric -> type. + +mispi/pi : mispi (ispi/pi DofB DofA) (mpair M1 M2) + <- mekof DofA M1 + <- ({x} {d} mekof (DofB x d) M2). + +mispi/lam : mispi (ispi/lam DisB DofA) (mpair M1 M2) + <- mekof DofA M1 + <- ({x} {d} mispi (DisB x d) M2). + + +mispie/pi : mispie (ispie/pi DofB DofA) (mpair M1 M2) + <- mekofe DofA M1 + <- ({x} mekofe (DofB x) M2). + +mispie/lam : mispie (ispie/lam DisB DofA) (mpair M1 M2) + <- mekofe DofA M1 + <- ({x} mispie (DisB x) M2). + +can-mispi : {D:ispi A K} mispi D M -> type. +%mode can-mispi +D -X. + +- : can-mispi (ispi/pi D2 D1) (mispi/pi D2' D1') + <- can-mekof D1 D1' + <- ({x} {d} can-mekof (D2 x d) (D2' x d)). + +- : can-mispi (ispi/lam D2 D1) (mispi/lam D2' D1') + <- can-mekof D1 D1' + <- ({x} {d} can-mispi (D2 x d) (D2' x d)). + +%worlds (ecsig | easig | evar | eovar | ebind) (can-mispi _ _). +%total D (can-mispi D _). + +cut-ispi-m : {M} + {D : {x} {d:evof x A} ispi (B x) (K x)} + ({x} {d} mispi (D x d) M) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} ispie (G x) (B x) (K x)} + ({x} mispie (D' x) M) -> type. +%mode cut-ispi-m +X1 +X2 +X3 +X4 -X5 -X6. + +cut-ispie-m : {M} + {D : {x} {d:evof x A} ispie (G x) (B x) (K x)} + ({x} {d} mispie (D x d) M) + -> ({x} elookup (G x) x A) +%% + -> {D' : {x} ispie (G x) (B x) (K x)} + ({x} mispie (D' x) M) -> type. +%mode cut-ispie-m +X1 +X2 +X3 +X4 -X5 -X6. + +-pi : cut-ispi-m (mpair Am Bm) + ([x] [d] + ispi/pi + ([y] [e] DofB x d y e) + (DofA x d)) + ([x] [d] + mispi/pi + ([y] [e] DmofB x d y e) + (DmofA x d)) + ([x] Dlook x: elookup (G x) x C) +%% + ([x] ispie/pi ([y] DofeB' x y) (DofeA x)) + ([x] mispie/pi ([y] DmofeB' x y) (DmofeA x)) +%% + <- cut-ekof-m Am DofA DmofA Dlook + DofeA DmofeA + <- ({x} {d} + cut-ekof-m Bm ([y] [e] DofB x d y e) ([y] [e] DmofB x d y e) + ([y] elookup/hit) + ([y] DofeB x d y) + ([y] DmofeB x d y)) + <- ({y} + cut-ekofe-m Bm ([x] [d] DofeB x d y) ([x] [d] DmofeB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofeB' x y) + ([x] DmofeB' x y)). + +-lam : cut-ispi-m (mpair Am Bm) + ([x] [d] + ispi/lam + ([y] [e] DisB x d y e) + (DofA x d)) + ([x] [d] + mispi/lam + ([y] [e] DmisB x d y e) + (DmofA x d)) + ([x] Dlook x: elookup (G x) x C) +%% + ([x] ispie/lam ([y] DiseB' x y) (DofeA x)) + ([x] mispie/lam ([y] DmiseB' x y) (DmofeA x)) +%% + <- cut-ekof-m Am DofA DmofA Dlook + DofeA DmofeA + <- ({x} {d} + cut-ispi-m Bm ([y] [e] DisB x d y e) ([y] [e] DmisB x d y e) + ([y] elookup/hit) + ([y] DiseB x d y) + ([y] DmiseB x d y)) + <- ({y} + cut-ispie-m Bm ([x] [d] DiseB x d y) ([x] [d] DmiseB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DiseB' x y) + ([x] DmiseB' x y)). + +%% + +-pi : cut-ispie-m (mpair Am Bm) + ([x] [d] ispie/pi (DofB x d) (DofA x d)) + ([x] [d] mispie/pi (DmofB x d) (DmofA x d)) + ([x] Dlook x) +%% + ([x] ispie/pi (DofB' x) (DofA' x)) + ([x] mispie/pi (DmofB' x) (DmofA' x)) +%% + <- cut-ekofe-m Am DofA DmofA Dlook + DofA' DmofA' + <- ({y} + cut-ekofe-m Bm ([x] [d] DofB x d y) ([x] [d] DmofB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DofB' x y) + ([x] DmofB' x y)). + +-lam : cut-ispie-m (mpair Am Bm) + ([x] [d] ispie/lam (DisB x d) (DofA x d)) + ([x] [d] mispie/lam (DmisB x d) (DmofA x d)) + ([x] Dlook x) +%% + ([x] ispie/lam (DisB' x) (DofA' x)) + ([x] mispie/lam (DmisB' x) (DmofA' x)) +%% + <- cut-ekofe-m Am DofA DmofA Dlook + DofA' DmofA' + <- ({y} + cut-ispie-m Bm ([x] [d] DisB x d y) ([x] [d] DmisB x d y) + ([x] elookup/miss (Dlook x)) + ([x] DisB' x y) + ([x] DmisB' x y)). + +%worlds (ecsig | easig | evar | eovar | ebind) + (cut-ispi-m _ _ _ _ _ _) + (cut-ispie-m _ _ _ _ _ _). +%total {(M1 M2)} + (cut-ispi-m M1 _ _ _ _ _) + (cut-ispie-m M2 _ _ _ _ _). + +cut-ispi : ({x} evof x A -> ispi (B x) (K x)) + -> ({x} elookup (G x) x A) +%% + -> ({x} ispie (G x) (B x) (K x)) -> type. +%mode cut-ispi +X1 +X2 -X3. + +- : cut-ispi Dis Dlook Dise + <- ({x} {d} + can-mispi (Dis x d) (Dmis x d)) + <- cut-ispi-m _ Dis Dmis Dlook Dise _. + +%worlds (ecsig | easig | evar | eovar | ebind) (cut-ispi _ _ _). +%total {} (cut-ispi _ _ _). + +sim1-to-sime : ({x} evof x A -> sim (B x) (B' x) (K x)) + -> ({x} sime (econs enil x A) (B x) (B' x) (K x)) -> type. +%mode sim1-to-sime +X1 -X2. + +- : sim1-to-sime + ([x] [d:evof x A] Dsim x d : sim (B x) (B' x) (K x)) + Dsime + <- cut-sim Dsim ([_] elookup/hit) + ([x] Dsime x : sime (econs enil x A) (B x) (B' x) (K x)). + +%worlds (ecsig | easig | evar | eovar | ebind) (sim1-to-sime _ _). +%total {} (sim1-to-sime _ _). + +ispi1-to-ispie : ({x} evof x A -> ispi (B x) (K x)) + -> ({x} ispie (econs enil x A) (B x) (K x)) -> type. +%mode ispi1-to-ispie +X1 -X2. + +- : ispi1-to-ispie Dispi Dispie + <- cut-ispi Dispi ([_] elookup/hit) Dispie. + +%worlds (ecsig | easig | evar | eovar | ebind) (ispi1-to-ispie _ _). +%total {} (ispi1-to-ispie _ _). + +sim-to-sime : sim A B K -> sime enil A B K -> type. +%mode sim-to-sime +X1 -X2. + +-pi : sim-to-sime + (sim/pi + ([x] [d:evof x A] DeqB x d : eqtp (B x) (B' x) ektype) + (DeqA : eqtp A A' ektype)) + (sime/pi DeqtpeB DeqtpeA) + <- eqtp1-to-eqtpe DeqB DeqtpeB + <- eqtp-to-eqtpe DeqA DeqtpeA. + +-lam : sim-to-sime + (sim/lam + ([x] [d:evof x A] DsimB x d : sim (B x) (B' x) (K x))) + (sime/lam DsimeB) + <- sim1-to-sime DsimB DsimeB. + +%worlds (ecsig | easig | evar | eovar | ebind) (sim-to-sime _ _). +%total D (sim-to-sime D _). + +simi : ectx -> etp -> etp -> ekind -> type. +simi/nil : simi enil A B K + <- sim A B K. +simi/cons : simi (econs G X A) B C K + <- (evof X A -> simi G B C K). + +simi-pi : ({x} eqtpi (econs G x A) (B x) (B' x) ektype) + -> eqtpi G A A' ektype +%% + -> simi G (epi A B) (epi A' B') ektype -> type. +%mode simi-pi +X1 +X2 -X3. + +-nil : simi-pi + ([x] eqtpi/cons ([d:evof x A] eqtpi/nil (DeqB x d))) + (eqtpi/nil (Deqtp : eqtp A A' ektype) : eqtpi enil A A' ektype) + (simi/nil (sim/pi DeqB Deqtp)). + +-cons : simi-pi + ([x] eqtpi/cons + ([d:evof x A] eqtpi/cons + ([e:evof Y C] DeqB x d e : eqtpi G (B x) (B' x) ektype))) + (eqtpi/cons ([e:evof Y C] DeqA e : eqtpi G A A' ektype)) + %% + (simi/cons DsimLam) + %% + <- ({e:evof Y C} + simi-pi ([x] eqtpi/cons ([d] DeqB x d e)) (DeqA e) + (DsimLam e)). + +%worlds (ecsig | easig | ebind | evar | eofblock) (simi-pi _ _ _). +%total D (simi-pi _ D _). + +simi-lam : {G} ({x} simi (econs G x A) (B x) (B' x) (K x)) + -> {A1} {A2} simi G (ealam A1 B) (ealam A2 B') (ekpi A K) -> type. +%mode simi-lam +G +X1 +A1 +A2 -X2. + +-nil : simi-lam _ + ([x] simi/cons ([d:evof x A] simi/nil (DsimB x d))) _ _ + (simi/nil (sim/lam DsimB)). + +-cons : simi-lam _ + ([x] simi/cons + ([d:evof x A] + simi/cons + ([e:evof Y B] DsimC x d e + : simi G (C x) (C' x) (K x)))) + A1 A2 + (simi/cons Dsimi') + <- ({e:evof Y B} + simi-lam _ ([x] simi/cons ([d] DsimC x d e)) + A1 A2 + (Dsimi' e : simi G (ealam A1 C) (ealam A2 C') (ekpi A K))). + +%worlds (ecsig | easig | ebind | evar | eofblock) (simi-lam _ _ _ _ _). +%total G (simi-lam G _ _ _ _). + +sime-to-simi : sime G A B K -> simi G A B K -> type. +%mode sime-to-simi +X1 -X2. + +-pi : sime-to-simi + (sime/pi + ([x] DeqB x : eqtpe (econs G x A) (B x) (B' x) ektype) + (DeqA : eqtpe G A A' ektype)) + Dsimi + <- eqtpe-to-eqtpi DeqA DeqiA + <- ({x} eqtpe-to-eqtpi (DeqB x) (DeqiB x)) + <- simi-pi DeqiB DeqiA Dsimi. + +-lam : sime-to-simi + (sime/lam + ([x] DsimB x : sime (econs G x A) (B x) (B' x) (K x))) + Dsimi + <- ({x} sime-to-simi (DsimB x) (DsimiB x)) + <- simi-lam _ DsimiB _ _ Dsimi. + +%worlds (ecsig | easig | evar | ebind) (sime-to-simi _ _). +%total D (sime-to-simi D _). + +sime-to-sim : sime enil A B K -> sim A B K -> type. +%mode sime-to-sim +X1 -X2. + +- : sime-to-sim D D' <- sime-to-simi D (simi/nil D'). + +%worlds (ecsig | easig | evar | eovar | ebind) (sime-to-sim _ _). +%total {} (sime-to-sim _ _). + +%%%% + +sim-fun : eqtm M N A -> ({x} evof x A -> ispi (B x) (K x)) + -> sim (B M) (B N) (K M) -> type. +%mode sim-fun +X1 +X2 -X3. + +- : sim-fun + (Deqtm : eqtm M N A) + ([x] [d] Dispi x d : ispi (B x) (K x)) + Dsim + <- eqtm-to-eqtme Deqtm (Deqtme_nil : eqtme enil M N A) + <- extend-eordered _ eordered/nil _ Dord + <- ispi1-to-ispie Dispi Dispie + <- sim-fun-e Dord ([_] eappend/nil) Deqtme_nil Dispie ecsub/base + (Dsime : sime enil (B M) (B N) (K M)) + <- sime-to-sim Dsime + (Dsim : sim (B M) (B N) (K M)). + +%worlds (ecsig | easig | evar | ebind) (sim-fun _ _ _). +%total {} (sim-fun _ _ _). + +sim-trans : sim A B K -> sim B C K + -> sim A C K -> type. +%mode sim-trans +X1 +X2 -X3. + +- : sim-trans + (sim/pi + ([x] [d:evof x A1] DeqB1 x d : eqtp (B1 x) (B2 x) ektype) + (DeqA1 : eqtp A1 A2 ektype)) + (sim/pi + ([x] [d:evof x A2] DeqB2 x d : eqtp (B2 x) (B3 x) ektype) + (DeqA2 : eqtp A2 A3 ektype)) + (sim/pi + ([x] [d:evof x A1] eqtp/trans (DeqB2' x d) (DeqB1 x d)) + (eqtp/trans DeqA2 DeqA1)) + <- eqtp-reg DeqA1 + (DofA1 : ekof A1 ektype) + (DofA2 : ekof A2 ektype) + _ + <- ({x} {d:evof x A1} + esubst-eqtp ([x] [d:evof x A2] DeqB2 x d) + (eof/eqtp DeqA1 (eof/var DofA1 d)) + (DeqB2' x d : eqtp (B2 x) (B3 x) ektype)). + +- : sim-trans + (sim/lam + ([x] [d:evof x C] DsimB1 x d : sim (B1 x) (B2 x) (K x))) + (sim/lam + ([x] [d:evof x C] DsimB2 x d : sim (B2 x) (B3 x) (K x))) + (sim/lam DsimB3) + <- ({x} {d:evof x C} + sim-trans (DsimB1 x d) (DsimB2 x d) + (DsimB3 x d : sim (B1 x) (B3 x) (K x))). + +%worlds (ecsig | easig | evar | ebind) (sim-trans _ _ _). +%total D (sim-trans D _ _). + +ispi-reg : ispi B K + -> ewfkind K -> type. +%mode ispi-reg +X1 -X2. + +-pi : ispi-reg (ispi/pi DofB DofA) + ewfkind/tp. + +-lam : ispi-reg + (ispi/lam + ([x] [d:evof x A] DispiB x d : ispi (B x) (K x)) + (DofA : ekof A ektype)) + (ewfkind/pi DofK DofA) + <- ({x} {d:evof x A} + ispi-reg (DispiB x d) + (DofK x d : ewfkind (K x))). + +%worlds (ecsig | easig | evar | ebind) (ispi-reg _ _). +%total D (ispi-reg D _). + +%% Derived form +sim-fun' : ({x} evof x A -> sim (B x) (B' x) (K x)) + -> ({x} evof x A -> ispi (B x) (K x)) + -> eqtm M N A + -> sim (B M) (B' N) (K M) -> type. +%mode sim-fun' +X1 +X2 +X3 -X4. + +- : sim-fun' + ([x] [d] DsimB x d : sim (B x) (B' x) (K x)) + ([x] [d] DispiB x d : ispi (B x) (K x)) + (Deq : eqtm M N A) +%% + Dsim +%% + <- sim-fun Deq DispiB + (DsimBM_BN : sim (B M) (B N) (K M)) + <- eqtm-reg Deq DofM DofN DofA + <- sim-sub DsimB DofN + (DsimBN_B'N : sim (B N) (B' N) (K N)) + <- ({x} {d} ispi-reg (DispiB x d) (DofK x d : ewfkind (K x))) + <- eqtm-ksub DofK Deq DofM DofN + (DeqKM_KN : eqkind (K M) (K N)) + <- sim-kcon DsimBN_B'N (eqkind/sym DeqKM_KN) + (DsimBN_B'N* : sim (B N) (B' N) (K M)) + <- sim-trans DsimBM_BN DsimBN_B'N* + (Dsim : sim (B M) (B' N) (K M)). + +%worlds (ecsig | easig | evar | ebind) (sim-fun' _ _ _ _). +%total {} (sim-fun' _ _ _ _). + +%% ispi lemmas %% + +ispi-resp : ispi A K -> etp-eq A A' -> ekind-eq K K' + -> ispi A' K' -> type. +%mode ispi-resp +X1 +X2 +X3 -X4. + +- : ispi-resp D etp-eq/i ekind-eq/i D. + +%worlds (ecsig | easig | ebind) (ispi-resp _ _ _ _). +%total {} (ispi-resp _ _ _ _). + +ispi-kpi-lam : ispi B (ekpi A K) + -> etp-eq B (ealam A' B') -> type. +%mode ispi-kpi-lam +X1 -X2. + +- : ispi-kpi-lam (ispi/lam _ _) etp-eq/i. + +%worlds (ecsig | easig | evar | ebind) (ispi-kpi-lam _ _). +%total {} (ispi-kpi-lam _ _). + +ispi-sim-refl : ispi A K -> sim A A K -> type. +%mode ispi-sim-refl +X1 -X2. + +- : ispi-sim-refl (ispi/pi ([x] [d] DofB x d) DofA) + (sim/pi ([x] [d] eqtp/refl (DofB x d)) (eqtp/refl DofA)). + +- : ispi-sim-refl (ispi/lam ([x] [d] DispiB x d) DofA) + (sim/lam DsimB) + <- ({x} {d} + ispi-sim-refl (DispiB x d) + (DsimB x d : sim (B x) (B x) (K x))). + +%worlds (ecsig | easig | ebind) (ispi-sim-refl _ _). +%total D (ispi-sim-refl D _). + +ispi-subst-gen : (evof M A -> ispi B K) + -> (eof M A -> ispi B K) -> type. +%mode ispi-subst-gen +X1 -X2. + +-pi : ispi-subst-gen + ([d:evof M A] + ispi/pi + ([y] [e:evof y B] DofC d y e : ekof (C y) ektype) + (DofB d : ekof B ektype)) + ([d:eof M A] + ispi/pi + ([y] [e] DofC' y e d) + (DofB' d)) + <- esubst-kof-gen DofB DofB' + <- ({y} {e:evof y B} + esubst-kof-gen ([d:evof M A] DofC d y e) + (DofC' y e : eof M A -> ekof (C y) ektype)). + +-lam : ispi-subst-gen + ([d:evof M A] + ispi/lam + ([y] [e:evof y B] DispiC d y e : ispi (C y) (K y)) + (DofB d)) + ([d:eof M A] + ispi/lam + ([y] [e:evof y B] DispiC' y e d) + (DofB' d)) + <- ({y} {e:evof y B} + ispi-subst-gen ([d:evof M A] DispiC d y e) + ([d:eof M A] DispiC' y e d : ispi (C y) (K y))) + <- esubst-kof-gen DofB DofB'. + +%worlds (ecsig | easig | ebind) (ispi-subst-gen _ _). +%total D (ispi-subst-gen D _). + +ispi-subst : ({x} evof x A -> ispi (B x) (K x)) + -> eof M A + -> ispi (B M) (K M) -> type. +%mode ispi-subst +X1 +X2 -X3. + +- : ispi-subst D1 D2 (D1' D2) + <- ispi-subst-gen (D1 _) D1'. + +%worlds (ecsig | easig | ebind) (ispi-subst _ _ _). +%total D (ispi-subst D _ _). + +ispi-eqkind : ispi A K -> eqkind K K' -> ispi A K' -> type. +%mode ispi-eqkind +X1 +X2 -X3. + +ispi-eqkind' : ispi A K -> eqkind K' K -> ispi A K' -> type. +%mode ispi-eqkind' +X1 +X2 -X3. + +-tp : ispi-eqkind D eqkind/tp D. + +-refl : ispi-eqkind D (eqkind/refl _) D. + +-pi : ispi-eqkind + (ispi/lam + ([x] [d:evof x A] Dispi x d : ispi (B x) (K x)) + (DofA : ekof A ektype)) + (eqkind/pi + ([x] [d:evof x A] DeqK x d : eqkind (K x) (K' x)) + (DeqA : eqtp A A' ektype)) + (ispi/lam Dispi'' DofA') + <- ({x} {d:evof x A} + ispi-eqkind (Dispi x d) (DeqK x d) + (Dispi' x d : ispi (B x) (K' x))) + <- eqtp-reg DeqA _ DofA' _ + <- ({x} {d:evof x A'} + ispi-subst Dispi' + (eof/eqtp (eqtp/sym DeqA) (eof/var DofA' d)) + (Dispi'' x d : ispi (B x) (K' x))). + +-sym : ispi-eqkind (Dispi : ispi A K) (eqkind/sym Deq') + Dispi' + <- ispi-eqkind' Dispi Deq' Dispi'. + +-trans : ispi-eqkind + (Dispi : ispi A K) + (eqkind/trans + (Deq2 : eqkind K' K'') + (Deq1 : eqkind K K')) + Dispi2 + <- ispi-eqkind Dispi Deq1 Dispi1 + <- ispi-eqkind Dispi1 Deq2 Dispi2. + +%% + +-tp : ispi-eqkind' D eqkind/tp D. + +-refl : ispi-eqkind' D (eqkind/refl _) D. + +-pi : ispi-eqkind' + (ispi/lam + ([x] [d:evof x A] Dispi x d : ispi (B x) (K x)) + DofA) + (eqkind/pi + ([x] [d:evof x A'] DeqK' x d : eqkind (K' x) (K x)) + (DeqA' : eqtp A' A ektype)) + (ispi/lam Dispi'' DofA') + <- eqtp-reg DeqA' DofA' _ _ + <- ({x} {d:evof x A'} + ispi-subst Dispi (eof/eqtp DeqA' (eof/var DofA' d)) + (Dispi' x d : ispi (B x) (K x))) + <- ({x} {d:evof x A'} + ispi-eqkind' (Dispi' x d) (DeqK' x d) + (Dispi'' x d : ispi (B x) (K' x))). + +-sym : ispi-eqkind' Dispi (eqkind/sym Deq) Dispi' + <- ispi-eqkind Dispi Deq Dispi'. + +-trans : ispi-eqkind' + (Dispi : ispi A K) + (eqkind/trans + (Deq2 : eqkind K' K) + (Deq1 : eqkind K'' K')) + Dispi1 + <- ispi-eqkind' Dispi Deq2 Dispi2 + <- ispi-eqkind' Dispi2 Deq1 Dispi1. + +%worlds (ecsig | easig | ebind) + (ispi-eqkind _ _ _) + (ispi-eqkind' _ _ _). +%total (D1 D2) + (ispi-eqkind _ D1 _) + (ispi-eqkind' _ D2 _). + +%% norm lemmas %% + +norm-resp : norm A B -> etp-eq A A' -> etp-eq B B' + -> norm A' B' -> type. +%mode norm-resp +X1 +X2 +X3 -X4. + +- : norm-resp Dnorm etp-eq/i etp-eq/i Dnorm. + +%worlds (ecsig | easig | evar | ebind) (norm-resp _ _ _ _). +%total {} (norm-resp _ _ _ _). + +norm-fun : norm A B -> norm A B' -> etp-eq B B' -> type. +%mode norm-fun +X1 +X2 -X3. + +-pi : norm-fun norm/pi norm/pi etp-eq/i. + +-lam : norm-fun + (norm/lam ([x] DnormB1 x : norm (B x) (B1 x))) + (norm/lam ([x] DnormB2 x : norm (B x) (B2 x))) + DeqLam + <- ({x} + norm-fun (DnormB1 x) (DnormB2 x) + (DeqB1B2 x : etp-eq (B1 x) (B2 x))) + <- ealam-compat etp-eq/i DeqB1B2 + (DeqLam : etp-eq (ealam A B1) (ealam A B2)). + +-app : norm-fun + (norm/app (DnormB1 : norm B (ealam A1 B1))) + (norm/app (DnormB2 : norm B (ealam A2 B2))) + (DeqB1B2 M) + <- norm-fun DnormB1 DnormB2 + (DeqLam : etp-eq (ealam A1 B1) (ealam A2 B2)) + <- ealam-inj DeqLam _ ([x] DeqB1B2 x : etp-eq (B1 x) (B2 x)). + +%worlds (ecsig | easig | evar) (norm-fun _ _ _). +%total D (norm-fun D _ _). + + +ektype-unique : eqkind ektype K -> ekind-eq K ektype -> type. +ektype-unique' : eqkind K ektype -> ekind-eq K ektype -> type. +%mode ektype-unique +X1 -X2. +%mode ektype-unique' +X1 -X2. + +- : ektype-unique eqkind/tp ekind-eq/i. + +- : ektype-unique (eqkind/refl _) ekind-eq/i. + +- : ektype-unique (eqkind/sym Deqk) Deq + <- ektype-unique' Deqk Deq. + +- : ektype-unique + (eqkind/trans + (Deqk2 : eqkind K K') + (Deqk1 : eqkind ektype K)) + DeqK' + <- ektype-unique Deqk1 + (DeqK : ekind-eq K ektype) + <- eqkind-resp Deqk2 DeqK ekind-eq/i + (Deqk2' : eqkind ektype K') + <- ektype-unique Deqk2' + (DeqK' : ekind-eq K' ektype). + +%% + +- : ektype-unique' eqkind/tp ekind-eq/i. + +- : ektype-unique' (eqkind/refl _) ekind-eq/i. + +- : ektype-unique' (eqkind/sym Deqk) Deq + <- ektype-unique Deqk Deq. + +- : ektype-unique' + (eqkind/trans + (Deqk2 : eqkind K' ektype) + (Deqk1 : eqkind K K')) + Deq + <- ektype-unique' Deqk2 + (DeqK' : ekind-eq K' ektype) + <- eqkind-resp Deqk1 ekind-eq/i DeqK' + (DeqK : eqkind K ektype) + <- ektype-unique' DeqK + (Deq : ekind-eq K ektype). + +%worlds (ecsig | easig | ebind) (ektype-unique _ _) (ektype-unique' _ _). +%total (D1 D2) (ektype-unique D1 _) (ektype-unique' D2 _). + +%{ +ekof-pi-pi-contra : ekof (epi A B) (ekpi C K) -> false -> type. +%mode ekof-pi-pi-contra +X1 -X2. + +-ext : ekof-pi-pi-contra + (ekof/ext + ([x] [d:evof x A] DofApp x d + : ekof (eaapp (epi B C) x) (K x)) + (DofPi : ekof (epi B C) (ekpi A K'))) + Dfalse + <- ekof-pi-pi-contra DofPi Dfalse. + +-eqk : ekof-pi-pi-contra + (ekof/eqkind + (Deqk : eqkind K (ekpi C K')) + (Dof : ekof (epi A B) K)) + _ + . + +%worlds (ecsig | easig | ebind) (ekof-pi-pi-contra _ _). +%total D (ekof-pi-pi-contra D _). +}% + +type-pi-contra : ekind-eq (ekpi A K) ektype -> false -> type. +%mode type-pi-contra +X1 -X2. +%worlds (ecsig | easig | ebind) (type-pi-contra _ _). +%total {} (type-pi-contra _ _). + +ekof-pi-type : ekof (epi A B) K -> ekind-eq K ektype -> type. +%mode ekof-pi-type +X1 -X2. + +-pi : ekof-pi-type (ekof/pi _ _) ekind-eq/i. + +-ekq : ekof-pi-type + (ekof/eqkind + (Deqk : eqkind K L) + (Dof : ekof (epi A B) K)) + DeqL + <- ekof-pi-type Dof + (DeqK : ekind-eq K ektype) + <- eqkind-resp Deqk DeqK ekind-eq/i + (Deqk' : eqkind ektype L) + <- ektype-unique Deqk' + (DeqL : ekind-eq L ektype). + +-ext : ekof-pi-type + (ekof/ext + ([x] [d:evof x A] DofApp x d + : ekof (eaapp (epi B C) x) (K x)) + (DofPi : ekof (epi B C) (ekpi A K'))) + Deq + <- ekof-pi-type DofPi + (DeqPiType : ekind-eq (ekpi A K') ektype) + <- type-pi-contra DeqPiType + Dfalse + <- false-implies-ekind-eq Dfalse Deq. + +%worlds (ecsig | easig | ebind) (ekof-pi-type _ _). +%total D (ekof-pi-type D _). + +norm-ispi : ekof A K -> norm A A' -> ispi A' K -> type. +%mode norm-ispi +X1 +X2 -X3. + +-pi : norm-ispi + (DofPi : ekof (epi A B) K) + norm/pi + Dispi + <- ekof-pi-invert DofPi + (DofA : ekof A ektype) + ([x] [d:evof x A] DofB x d : ekof (B x) ektype) + <- ekof-pi-type DofPi + (DeqK : ekind-eq K ektype) + <- ekind-eq-sym DeqK + (DeqK' : ekind-eq ektype K) + <- ispi-resp (ispi/pi DofB DofA) etp-eq/i DeqK' + (Dispi : ispi (epi A B) K). + +-lam : norm-ispi + (ekof/lam + (DofA : ekof A ektype) + ([x] [d:evof x A] DofB x d : ekof (B x) (K x))) + (norm/lam + ([x] DnormB x : norm (B x) (B' x))) + (ispi/lam DispiB DofA) + <- ({x} {d:evof x A} + norm-ispi (DofB x d) (DnormB x) + (DispiB x d : ispi (B' x) (K x))). + +%{ Need to do it this way if induction is over the reduction argument. +-lam : norm-ispi + (DofLam : ekof (ealam A B) K) + (norm/lam ([x] DnormB x : norm (B x) (B' x))) + Dispi + <- ekof-lam-invert DofLam + (DofA : ekof A ektype) + ([x] [d:evof x A] DofB x d : ekof (B x) (K' x)) + (DequivK : eqkind K (ekpi A K')) + <- eqkind-pi-invert DequivK + (DeqK : ekind-eq K (ekpi A* K*)) + (DequivA : eqtp A A* ektype) + ([x] [d:evof x A] DequivK' x d : eqkind (K' x) (K* x)) + <- ekind-eq-sym DeqK (DeqPiK : ekind-eq (ekpi A* K*) K) + <- eqtp-reg DequivA _ DofA* _ + <- ({x} {d:evof x A*} + esubst-eqkind DequivK' + (eof/eqtp (eqtp/sym DequivA) (eof/var DofA* d)) + (DequivK'' x d : eqkind (K' x) (K* x))) + <- ({x} {d:evof x A*} + esubst-kof DofB + (eof/eqtp (eqtp/sym DequivA) (eof/var DofA* d)) + (DofB'' x d : ekof (B x) (K' x))) + <- ({x} {d:evof x A*} + norm-ispi + (ekof/eqkind (DequivK'' x d) (DofB'' x d)) + (DnormB x) + (DispiB' x d : ispi (B' x) (K* x))) + <- ispi-resp (ispi/lam DispiB') etp-eq/i DeqPiK + (Dispi : ispi (ealam A B') K). +}% + +-app : norm-ispi + (ekof/app + (DofM : eof M A) + (DofB : ekof B (ekpi A K)) + : ekof (eaapp B M) (K M)) + (norm/app + (DnormB : norm B (ealam A' B')) + : norm (eaapp B M) (B' M)) + Dispi + <- norm-ispi DofB DnormB + (ispi/lam + ([x] [d:evof x A] DispiB' x d : ispi (B' x) (K x)) + _) + <- ispi-subst DispiB' DofM + (Dispi : ispi (B' M) (K M)). + +-eqk : norm-ispi + (ekof/eqkind + (Deqkind : eqkind K K') + (DofA : ekof A K)) + (Dnorm : norm A A') + Dispi' + <- norm-ispi DofA Dnorm + (Dispi : ispi A' K) + <- ispi-eqkind Dispi Deqkind Dispi'. + +-ext : norm-ispi + (ekof/ext + ([x] [d:evof x A] DofApp x d : ekof (eaapp B x) (K x)) + (DofB : ekof B (ekpi A K'))) + (Dnorm : norm B B') + Dispi + <- norm-ispi DofB Dnorm + (DispiB' : ispi B' (ekpi A K')) + <- ispi-kpi-lam DispiB' + (DeqB' : etp-eq B' (ealam A' C)) + <- norm-resp Dnorm etp-eq/i DeqB' + (DnormB : norm B (ealam A' C)) + %% x, d:evof x A |- (norm/app DnormB) : norm (eaapp B x) (C x) + <- ({x} {d:evof x A} + norm-ispi (DofApp x d) (norm/app DnormB) + (DispiC x d : ispi (C x) (K x))) + %% + <- etp-eq-sym DeqB' (DeqLam : etp-eq (ealam A' C) B') + <- ekof-reg DofB + (ewfkind/pi _ DofA) + <- ispi-resp (ispi/lam DispiC DofA) DeqLam ekind-eq/i + (Dispi : ispi B' (ekpi A K)). + +%worlds (ecsig | easig | ebind) (norm-ispi _ _ _). +%total D (norm-ispi D _ _). + +% XXX maybe not the best name +norm-str : ({x:etm} norm A (B x)) -> ({x} etp-eq (B x) B') -> type. +%mode norm-str +X1 -X2. + +- : norm-str ([x] norm/pi) ([x] etp-eq/i). + +- : norm-str ([x] norm/lam ([y] DnormB x y : norm (B y) (B' x y))) + DeqLam + <- ({y} + norm-str ([x] DnormB x y) + ([x] DeqB x y : etp-eq (B' x y) (B'' y))) + <- ({x} + ealam-compat etp-eq/i ([y] DeqB x y) + (DeqLam x : etp-eq (ealam A (B' x)) _)). + +- : norm-str ([x] norm/app (DnormB x : norm B (ealam (A x) (B' x)))) + ([x] DeqB' x _) + <- norm-str DnormB + ([x] DeqLam x : etp-eq (ealam (A x) (B' x)) (ealam A* B'*)) + <- ({x} + ealam-inj (DeqLam x) + _ + ([y] DeqB' x y : etp-eq (B' x y) (B'* y))). + +%worlds (ecsig | easig | evar) (norm-str _ _). +%total D (norm-str D _). + +inst-lam : etp-eq (A M) (ealam C D) + -> ({x:etm} etp-eq (A x) (ealam (C' x) (D' x))) -> type. +%mode inst-lam +X1 -X2. + +- : inst-lam etp-eq/i ([x] etp-eq/i). + +%worlds (ecsig | easig | evar) (inst-lam _ _). +%total {} (inst-lam _ _). + + +norm-unsub : {A:etm -> etp} norm (A M) B -> ({x:etm} norm (A x) (A' x)) -> type. +%mode norm-unsub +X1 +X2 -X3. + +-pi : norm-unsub _ norm/pi ([x] norm/pi). + +-app : norm-unsub + ([x] eaapp (A x) (N x)) + (norm/app + (DnormA : norm (A M) (ealam C D)) + : norm (eaapp (A M) (N M)) _) + ([x] norm/app (DnormA*' x)) + <- norm-unsub A DnormA + ([x] DnormA* x : norm (A x) (A' x)) + <- norm-fun (DnormA* M) DnormA + (DeqA' : etp-eq (A' M) (ealam C D)) + <- inst-lam DeqA' + ([x] DeqA'' x : etp-eq (A' x) (ealam (C' x) (D' x))) + <- ({x} + norm-resp (DnormA* x) etp-eq/i (DeqA'' x) + (DnormA*' x : norm (A x) (ealam (C' x) (D' x)))). + +-lam : norm-unsub ([x] ealam (A x) ([y] B x y)) + (norm/lam + ([y] DnormB y : norm (B M y) (B' y))) + ([x] norm/lam (DnormB* x)) + <- ({y} + norm-unsub ([x] B x y) (DnormB y) + ([x] DnormB* x y : norm (B x y) (B* x y))). + +%worlds (ecsig | easig | evar) (norm-unsub _ _ _). +%total D (norm-unsub _ D _). + +%% Generalization of pi injectivity %% + +norm-sim : eqtp A B K -> norm A A' + -> norm B B' -> sim A' B' K -> type. +%mode norm-sim +X1 +X2 -X3 -X4. + +%% second version for symmetry +norm-sim' : norm A A' -> eqtp B A K + -> norm B B' -> sim A' B' K -> type. +%mode norm-sim' +X1 +X2 -X3 -X4. + +-app : norm-sim + (eqtp/app + (Deqtm : eqtm M N D) + (Deqtp : eqtp B B' (ekpi D K))) + (norm/app (DnormB : norm B (ealam A C))) +%% + (norm/app DnormB') + DsimCM +%% + <- norm-sim Deqtp DnormB + (DnormB' : norm B' (ealam A' C')) + (sim/lam ([x] [d:evof x D] DsimC x d : sim (C x) (C' x) (K x))) + %% + <- eqtp-reg Deqtp + (DofB : ekof B (ekpi D K)) + (DofB' : ekof B' (ekpi D K)) + _dontcare + <- norm-ispi DofB DnormB + (ispi/lam + ([x] [d:evof x D] DispiC x d : ispi (C x) (K x)) + _) + <- sim-fun' DsimC DispiC Deqtm + (DsimCM : sim (C M) (C' N) (K M)). + +-pi : norm-sim + (eqtp/pi + ([x] [d:evof x A] DeqB x d : eqtp (B x) (B' x) ektype) + (DeqA : eqtp A A' ektype)) + norm/pi + norm/pi + (sim/pi DeqB DeqA). + +-lam : norm-sim + (eqtp/lam + ([x] [d:evof x A] DeqB x d : eqtp (B x) (B' x) (K x)) + (DeqA : eqtp A A' ektype)) + (norm/lam ([x] DnormB x : norm (B x) (B1 x))) + (norm/lam DnormB') + (sim/lam DsimB1B2) + <- ({x} {d:evof x A} + norm-sim (DeqB x d) (DnormB x) + (DnormB' x : norm (B' x) (B2 x)) + (DsimB1B2 x d : sim (B1 x) (B2 x) (K x))). + +-ext : norm-sim + (eqtp/ext + ([x] [d:evof x A] DeqApp x d + : eqtp (eaapp B x) (eaapp C x) (K x)) + (DofC : ekof C (ekpi A K'')) + (DofB : ekof B (ekpi A K'))) + (DnormB : norm B B') + (DnormC ace) + DsimB' + <- norm-ispi DofB DnormB + (Dispi : ispi B' (ekpi A K')) + <- ispi-kpi-lam Dispi + (DeqB' : etp-eq B' (ealam A' B'')) + <- norm-resp DnormB etp-eq/i DeqB' + (DnormBLam : norm B (ealam A' B'')) + %% + <- ({x} {d} + norm-sim (DeqApp x d) (norm/app DnormBLam) + (norm/app + (DnormC x : norm C (ealam (D x) ([y] E x y)))) + (DsimB'' x d : sim (B'' x) (E x x) (K x))) + <- etp-eq-sym DeqB' (DeqLam : etp-eq (ealam A' B'') B') + <- norm-str DnormC + ([x] DeqLamDE x : etp-eq (ealam (D x) (E x)) Lam') + <- ealam-inj-str DeqLamDE + ([x] DeqD x : etp-eq (D x) D') + ([x] [y] DeqE x y : etp-eq (E x y) (E' y)) + <- ({x} + ealam-compat (DeqD x) (DeqE x) + (DeqLamDE' x : etp-eq (ealam (D x) (E x)) (ealam D' E'))) + <- ({x} + etp-eq-sym (DeqLamDE' x) + (DeqLamDE'' x : etp-eq (ealam D' E') (ealam (D x) (E x)))) + <- ({x} {d} + sim-resp (DsimB'' x d) etp-eq/i (DeqE x x) ekind-eq/i + (DsimB''* x d : sim (B'' x) (E' x) (K x))) + <- sim-resp (sim/lam DsimB''*) DeqLam (DeqLamDE'' ace) ekind-eq/i + (DsimB' : sim B' (ealam (D ace) (E ace)) (ekpi A K)). + +-extw : norm-sim + (eqtp/extw + ([x] [d:evof x A] + DeqApp x d : eqtp (eaapp B x) (eaapp C x) (K x)) + (DeqBC : eqtp B C (ekpi A K'))) + (DnormB : norm B B') + (DnormC ace) + DsimB' + <- eqtp-reg DeqBC + (DofB : ekof B (ekpi A K')) + (DofC : ekof C (ekpi A K')) + _ + <- norm-ispi DofB DnormB + (Dispi : ispi B' (ekpi A K')) + <- ispi-kpi-lam Dispi + (DeqB' : etp-eq B' (ealam A' B'')) + <- norm-resp DnormB etp-eq/i DeqB' + (DnormBLam : norm B (ealam A' B'')) + %% + <- ({x} {d} + norm-sim (DeqApp x d) (norm/app DnormBLam) + (norm/app + (DnormC x : norm C (ealam (D x) ([y] E x y)))) + (DsimB'' x d : sim (B'' x) (E x x) (K x))) + <- etp-eq-sym DeqB' (DeqLam : etp-eq (ealam A' B'') B') + <- norm-str DnormC + ([x] DeqLamDE x : etp-eq (ealam (D x) (E x)) Lam') + <- ealam-inj-str DeqLamDE + ([x] DeqD x : etp-eq (D x) D') + ([x] [y] DeqE x y : etp-eq (E x y) (E' y)) + <- ({x} + ealam-compat (DeqD x) (DeqE x) + (DeqLamDE' x : etp-eq (ealam (D x) (E x)) (ealam D' E'))) + <- ({x} + etp-eq-sym (DeqLamDE' x) + (DeqLamDE'' x : etp-eq (ealam D' E') (ealam (D x) (E x)))) + <- ({x} {d} + sim-resp (DsimB'' x d) etp-eq/i (DeqE x x) ekind-eq/i + (DsimB''* x d : sim (B'' x) (E' x) (K x))) + <- sim-resp (sim/lam DsimB''*) DeqLam (DeqLamDE'' ace) ekind-eq/i + (DsimB' : sim B' (ealam (D ace) (E ace)) (ekpi A K)). + +-beta : norm-sim + (eqtp/beta + (DofN : eof N A) + ([x] [d:evof x A] DofB x d : ekof (B x) (K x))) + (norm/app (norm/lam ([x] DnormB x : norm (B x) (B' x)))) + (DnormB N) + Dsim + <- esubst-kof DofB DofN (DofBx : ekof (B N) (K N)) + <- norm-ispi DofBx (DnormB N) + (DispiB'N : ispi (B' N) (K N)) + <- ispi-sim-refl DispiB'N + (Dsim : sim (B' N) (B' N) (K N)). + +-sym : norm-sim + (eqtp/sym (Deqtp : eqtp B A K)) + (Dnorm : norm A A') + DnormB + Dsim + <- norm-sim' Dnorm Deqtp + (DnormB : norm B B') + (Dsim : sim A' B' K). + +-trans : norm-sim + (eqtp/trans + (DeqB : eqtp B C K) + (DeqA : eqtp A B K)) + (DnormA : norm A A') + DnormC + DsimA'C' + <- norm-sim DeqA DnormA + (DnormB : norm B B') + (DsimA'B' : sim A' B' K) + <- norm-sim DeqB DnormB + (DnormC : norm C C') + (DsimB'C' : sim B' C' K) + <- sim-trans DsimA'B' DsimB'C' + (DsimA'C' : sim A' C' K). + +-refl : norm-sim + (eqtp/refl (Dof : ekof A K)) + (Dnorm : norm A A') + Dnorm + Dsim + <- norm-ispi Dof Dnorm + (Dispi : ispi A' K) + <- ispi-sim-refl Dispi + (Dsim : sim A' A' K). + +-kcon : norm-sim + (eqtp/kcon (Deqk : eqkind K L) (Deqtp : eqtp A B K)) + (DnormA : norm A A') + DnormB + Dsim' + <- norm-sim Deqtp DnormA + (DnormB : norm B B') + (Dsim : sim A' B' K) + <- sim-kcon Dsim Deqk Dsim'. + +%% + +-app : norm-sim' + (norm/app (DnormC : norm C (ealam D E))) + (eqtp/app + (Deqtm : eqtm M N A) + (Deqtp : eqtp B C (ekpi A K))) + (norm/app DnormB) + Dsim' + <- norm-sim' DnormC Deqtp + (DnormB : norm B (ealam D' E')) + (sim/lam ([x] [d:evof x A] DsimE x d : sim (E x) (E' x) (K x))) + %% + <- eqtp-reg Deqtp DofB DofC _dofPi + <- norm-ispi DofC DnormC + (ispi/lam + ([x] [d:evof x A] DispiE x d : ispi (E x) (K x)) + _) + <- sim-fun' DsimE DispiE (eqtm/sym Deqtm) + (Dsim : sim (E N) (E' M) (K N)) + <- eqtp-reg Deqtp _ _ + (ewfkind/pi + ([x] [d:evof x A] DofK x d : ewfkind (K x)) + (DofA : ekof A ektype)) + <- eqtm-reg Deqtm DofM DofN _ + <- eqtm-ksub DofK (eqtm/sym Deqtm) DofN DofM + (Deqkind : eqkind (K N) (K M)) + <- sim-kcon Dsim Deqkind + (Dsim' : sim (E N) (E' M) (K M)). + +-pi : norm-sim' + norm/pi + (eqtp/pi + ([x] [d:evof x A'] DeqB x d : eqtp (B' x) (B x) ektype) + (DeqA : eqtp A' A ektype)) + norm/pi + (sim/pi DeqB' (eqtp/sym DeqA)) + <- eqtp-reg DeqA _ DofA _ + <- ({x} {d:evof x A} + esubst-eqtp ([x] [d:evof x A'] eqtp/sym (DeqB x d)) + (eof/eqtp (eqtp/sym DeqA) (eof/var DofA d)) + (DeqB' x d : eqtp (B x) (B' x) ektype)). + +-lam : norm-sim' + (norm/lam ([x] DnormB x : norm (B x) (B* x))) + (eqtp/lam + ([x] [d:evof x A'] DeqB x d : eqtp (B' x) (B x) (K x)) + (DeqA : eqtp A' A ektype)) + (norm/lam DnormB') + (sim/lam DsimB) + <- ({x} {d:evof x A'} + norm-sim' (DnormB x) (DeqB x d) + (DnormB' x : norm (B' x) (B'* x)) + (DsimB x d : sim (B* x) (B'* x) (K x))). + +-ext : norm-sim' + (DnormB : norm B B') + (eqtp/ext + ([x] [d:evof x A] DeqApp x d + : eqtp (eaapp C x) (eaapp B x) (K x)) + (DofB : ekof B (ekpi A K')) + (DofC : ekof C (ekpi A K''))) + (DnormC ace) + DsimB' + <- norm-ispi DofB DnormB + (Dispi : ispi B' (ekpi A K')) + <- ispi-kpi-lam Dispi + (DeqB' : etp-eq B' (ealam A' B'')) + <- norm-resp DnormB etp-eq/i DeqB' + (DnormBLam : norm B (ealam A' B'')) + %% + <- ({x} {d} + norm-sim' (norm/app DnormBLam) (DeqApp x d) + (norm/app + (DnormC x : norm C (ealam (D x) ([y] E x y)))) + (DsimB'' x d : sim (B'' x) (E x x) (K x))) + <- etp-eq-sym DeqB' (DeqLam : etp-eq (ealam A' B'') B') + <- norm-str DnormC + ([x] DeqLamDE x : etp-eq (ealam (D x) (E x)) Lam') + <- ealam-inj-str DeqLamDE + ([x] DeqD x : etp-eq (D x) D') + ([x] [y] DeqE x y : etp-eq (E x y) (E' y)) + <- ({x} + ealam-compat (DeqD x) (DeqE x) + (DeqLamDE' x : etp-eq (ealam (D x) (E x)) (ealam D' E'))) + <- ({x} + etp-eq-sym (DeqLamDE' x) + (DeqLamDE'' x : etp-eq (ealam D' E') (ealam (D x) (E x)))) + <- ({x} {d} + sim-resp (DsimB'' x d) etp-eq/i (DeqE x x) ekind-eq/i + (DsimB''* x d : sim (B'' x) (E' x) (K x))) + <- sim-resp (sim/lam DsimB''*) DeqLam (DeqLamDE'' ace) ekind-eq/i + (DsimB' : sim B' (ealam (D ace) (E ace)) (ekpi A K)). + +-extw : norm-sim' + (DnormB : norm B B') + (eqtp/extw + ([x] [d:evof x A] + DeqApp x d : eqtp (eaapp C x) (eaapp B x) (K x)) + (DeqBC : eqtp C B (ekpi A K'))) + (DnormC ace) + DsimB' + <- eqtp-reg DeqBC + (DofC : ekof C (ekpi A K')) + (DofB : ekof B (ekpi A K')) + _ + <- norm-ispi DofB DnormB + (Dispi : ispi B' (ekpi A K')) + <- ispi-kpi-lam Dispi + (DeqB' : etp-eq B' (ealam A' B'')) + <- norm-resp DnormB etp-eq/i DeqB' + (DnormBLam : norm B (ealam A' B'')) + %% + <- ({x} {d} + norm-sim' (norm/app DnormBLam) (DeqApp x d) + (norm/app + (DnormC x : norm C (ealam (D x) ([y] E x y)))) + (DsimB'' x d : sim (B'' x) (E x x) (K x))) + <- etp-eq-sym DeqB' (DeqLam : etp-eq (ealam A' B'') B') + <- norm-str DnormC + ([x] DeqLamDE x : etp-eq (ealam (D x) (E x)) Lam') + <- ealam-inj-str DeqLamDE + ([x] DeqD x : etp-eq (D x) D') + ([x] [y] DeqE x y : etp-eq (E x y) (E' y)) + <- ({x} + ealam-compat (DeqD x) (DeqE x) + (DeqLamDE' x : etp-eq (ealam (D x) (E x)) (ealam D' E'))) + <- ({x} + etp-eq-sym (DeqLamDE' x) + (DeqLamDE'' x : etp-eq (ealam D' E') (ealam (D x) (E x)))) + <- ({x} {d} + sim-resp (DsimB'' x d) etp-eq/i (DeqE x x) ekind-eq/i + (DsimB''* x d : sim (B'' x) (E' x) (K x))) + <- sim-resp (sim/lam DsimB''*) DeqLam (DeqLamDE'' ace) ekind-eq/i + (DsimB' : sim B' (ealam (D ace) (E ace)) (ekpi A K)). + +-beta : norm-sim' + (DnormBN : norm (B N) C) + (eqtp/beta + (DofN : eof N A) + ([x] [d:evof x A] DofB x d : ekof (B x) (K x))) + %% + Dnorm + Dsim + %% + <- norm-unsub _ DnormBN + ([x:etm] DnormB x : norm (B x) (B' x)) + <- norm-fun (DnormB N) DnormBN + (DeqB'N : etp-eq (B' N) C) + <- norm-resp (norm/app (norm/lam DnormB)) etp-eq/i DeqB'N + (Dnorm : norm (eaapp (ealam A B) N) C) + %% + <- esubst-kof DofB DofN + (DofBN : ekof (B N) (K N)) + <- norm-ispi DofBN DnormBN + (DispiC : ispi C (K N)) + <- ispi-sim-refl DispiC + (Dsim : sim C C (K N)). + +-sym : norm-sim' + (Dnorm : norm A A') + (eqtp/sym (Deqtp : eqtp A B K)) + DnormB + Dsim + <- norm-sim Deqtp Dnorm DnormB Dsim. + +-trans : norm-sim' + (DnormA : norm A A') + (eqtp/trans + (DeqB : eqtp B A K) + (DeqC : eqtp C B K)) + DnormC + DsimA'C' + <- norm-sim' DnormA DeqB + (DnormB : norm B B') + (DsimA'B' : sim A' B' K) + <- norm-sim' DnormB DeqC + (DnormC : norm C C') + (DsimB'C' : sim B' C' K) + %% + <- sim-trans DsimA'B' DsimB'C' + (DsimA'C' : sim A' C' K). + +-refl : norm-sim' + (Dnorm : norm A A') + (eqtp/refl (Dof : ekof A K)) + Dnorm + Dsim + <- norm-ispi Dof Dnorm Dispi + <- ispi-sim-refl Dispi Dsim. + +-kcon : norm-sim' + (DnormA : norm A A') + (eqtp/kcon (Deqk : eqkind K L) (Deqtp : eqtp B A K)) + DnormB + Dsim' + <- norm-sim' DnormA Deqtp + (DnormB : norm B B') + (Dsim : sim A' B' K) + <- sim-kcon Dsim Deqk Dsim'. + +%worlds (ecsig | easig | ebind) (norm-sim _ _ _ _) (norm-sim' _ _ _ _). +%total (D1 D2) (norm-sim D1 _ _ _) (norm-sim' _ D2 _ _). + + +eqtp-pi-invert : eqtp (epi A B) (epi A' B') ektype + -> eqtp A A' ektype + -> ({x} evof x A -> eqtp (B x) (B' x) ektype) -> type. +%mode eqtp-pi-invert +X1 -X2 -X3. + +- : eqtp-pi-invert + (Deqtp : eqtp (epi A B) (epi A' B') ektype) + DeqA + DeqB + <- norm-sim Deqtp norm/pi + (Dnorm : norm (epi A' B') C) + (Dsim : sim (epi A B) C ektype) + <- norm-fun Dnorm norm/pi + (DeqC : etp-eq C (epi A' B')) + <- sim-resp Dsim etp-eq/i DeqC ekind-eq/i + (sim/pi + ([x] [d:evof x A] DeqB x d : eqtp (B x) (B' x) ektype) + (DeqA : eqtp A A' ektype)). + +%worlds (ecsig | easig | ebind) (eqtp-pi-invert _ _ _). +%total {} (eqtp-pi-invert _ _ _). diff --git a/src/reduce-equiv.thm b/src/reduce-equiv.thm new file mode 100644 index 0000000..1c17b28 --- /dev/null +++ b/src/reduce-equiv.thm @@ -0,0 +1,301 @@ +%%%% + +eof-lam-invert : eof (elam A M) C + -> eqtp C (epi A B) ektype + -> ({x} evof x A -> eof (M x) (B x)) -> type. +%mode eof-lam-invert +X1 -X2 -X3. + +%% Reduction implies equivalence %% + +reduce-equiv : eof M A -> reduce M N -> eqtm M N A -> type. +%mode reduce-equiv +X1 +X2 -X3. + +tpreduce-equiv : ekof A K -> tpreduce A B -> eqtp A B K -> type. +%mode tpreduce-equiv +X1 +X2 -X3. + +%% cases of lam inversion + +-lam : eof-lam-invert (eof/lam DofA DofM) + (eqtp/refl DofPi) DofM + <- eof-reg (eof/lam DofA DofM) + (DofPi). + +-eqtp : eof-lam-invert + (eof/eqtp + (Deqtp : eqtp C C' ektype) + (DofLam : eof (elam A M) C)) + (eqtp/trans DeqCPi (eqtp/sym Deqtp)) + DofM + <- eof-lam-invert DofLam + (DeqCPi : eqtp C (epi A B) ektype) + ([x] [d:evof x A] DofM x d : eof (M x) (B x)). + +-ext : eof-lam-invert + (eof/ext + ([x] [d:evof x A] DofApp x d + : eof (eapp (elam A' M) x) (B x)) + (DofLam' : eof (elam A' M) (epi A B'))) + (eqtp/pi ([x] [d] eqtp/refl (DofB x d)) DeqAA') + DofM* + <- eof-lam-invert DofLam' + (DeqPi : eqtp (epi A B') (epi A' B'') ektype) + ([x] [d:evof x A'] DofM' x d : eof (M x) (B'' x)) + %% + <- eqtp-pi-invert DeqPi + (DeqAA' : eqtp A A' ektype) + ([x] [d:evof x A] DeqB'B'' x d : eqtp (B' x) (B'' x) ektype) + <- eqtp-reg DeqAA' DofA DofA' _ + %% + <- ({x} {d:evof x A} + reduce-equiv (DofApp x d) reduce/beta + (DeqApp x d : eqtm _ (M x) (B x))) + <- ({x} {d:evof x A} + eqtm-reg (DeqApp x d) + _ + (DofM x d : eof (M x) (B x)) + (DofB x d : ekof (B x) ektype)) + <- ({x} {d:evof x A'} + esubst DofM + (eof/eqtp (eqtp/sym DeqAA') (eof/var DofA' d)) + (DofM* x d : eof (M x) (B x))). + +%% cases of reduce-equiv + +-const : reduce-equiv Deof reduce/refl (eqtm/refl Deof). + +-ext : reduce-equiv + (eof/ext + ([x] [d:evof x A] + DofApp x d : eof (eapp M x) (C x)) + (DofM : eof M (epi A B))) + (DredM : reduce M M') + (eqtm/extw DeqApp Deqtm) + <- reduce-equiv DofM DredM + (Deqtm : eqtm M M' (epi A B)) + <- ({x} {d:evof x A} + reduce-equiv (DofApp x d) (reduce/app reduce/refl DredM) + (DeqApp x d : eqtm (eapp M x) (eapp M' x) (C x))). + +-eqtp : reduce-equiv + (eof/eqtp + (Deqtp : eqtp A B ektype) + (DofM : eof M A)) + (DredM : reduce M M') + (eqtm/typecon Deqtp Deqtm) + <- reduce-equiv DofM DredM + (Deqtm : eqtm M M' A). + +-lam : reduce-equiv + (eof/lam + (DofA : ekof A ektype) + ([x] [d:evof x A] DofM x d : eof (M x) (B x))) + (reduce/lam + ([x] [dv:variable x] DreduceM x dv : reduce (M x) (M' x)) + (DreduceA : tpreduce A A')) +%% + (eqtm/lam DeqM DeqA) +%% + <- tpreduce-equiv DofA DreduceA + (DeqA : eqtp A A' ektype) + <- ({x} {d:evof x A} {dv:variable x} + reduce-equiv (DofM x d) (DreduceM x dv) + (DeqM x d : eqtm (M x) (M' x) (B x))). + +-app : reduce-equiv + (eof/app + (DofN : eof N A) + (DofM : eof M (epi A ([x] B x)))) + (reduce/app + (DreduceN : reduce N N') + (DreduceM : reduce M M')) +%% + (eqtm/app DeqtmN DeqtmM) +%% + <- reduce-equiv DofN DreduceN DeqtmN + <- reduce-equiv DofM DreduceM DeqtmM. + +-beta : reduce-equiv + (eof/app + (DofN : eof N A) + (DofLam : eof (elam A' M) (epi A B)) + : eof (eapp (elam A' M) N) (B N)) + (reduce/beta : reduce (eapp (elam A' M) N) (M N)) + (eqtm/beta + (eof/eqtp DeqA DofN) + ([x] [d] eof/eqtp (eqtp/sym (DeqB* x d)) (DofM x d))) + <- eof-lam-invert DofLam + (DeqPi : eqtp (epi A B) (epi A' B') ektype) + ([x] [d:evof x A'] DofM x d : eof (M x) (B' x)) + <- eqtp-pi-invert DeqPi + (DeqA : eqtp A A' ektype) + ([x] [d:evof x A] DeqB x d : eqtp (B x) (B' x) ektype) + %% + <- eqtp-reg DeqA _ DofA' _ + <- ({x} {d:evof x A'} + esubst-eqtp DeqB + (eof/eqtp (eqtp/sym DeqA) (eof/var DofA' d)) + (DeqB* x d : eqtp (B x) (B' x) ektype)). + + +%%%% + +%% + +-const : tpreduce-equiv Dekof Dreduce (eqtp/refl Dekof). + +-pi : tpreduce-equiv + (ekof/pi + ([x] [d:evof x A] DofB x d : ekof (B x) ektype) + (DofA : ekof A ektype)) + (tpreduce/pi + ([x] [dv:variable x] DreduceB x dv : tpreduce (B x) (B' x)) + (DreduceA : tpreduce A A')) + (eqtp/pi DeqB DeqA) + <- tpreduce-equiv DofA DreduceA + (DeqA : eqtp A A' ektype) + <- ({x} {d:evof x A} {dv:variable x} + tpreduce-equiv (DofB x d) (DreduceB x dv) + (DeqB x d : eqtp (B x) (B' x) ektype)). + +-lam : tpreduce-equiv + (ekof/lam + (DofA : ekof A ektype) + ([x] [d:evof x A] DofB x d : ekof (B x) (K x))) + (tpreduce/lam + ([x] [dv:variable x] DreduceB x dv : tpreduce (B x) (B' x)) + (DreduceA : tpreduce A A')) +%% + (eqtp/lam DeqB DeqA) +%% + <- tpreduce-equiv DofA DreduceA + (DeqA : eqtp A A' ektype) + <- ({x} {d:evof x A} {dv:variable x} + tpreduce-equiv (DofB x d) (DreduceB x dv) + (DeqB x d : eqtp (B x) (B' x) (K x))). + +-app : tpreduce-equiv + (ekof/app + (DofN : eof N A) + (DofB : ekof B (ekpi A ([x] K x)))) + (tpreduce/app + (DreduceN : reduce N N') + (DreduceB : tpreduce B B')) +%% + (eqtp/app DeqN DeqB) +%% + <- reduce-equiv DofN DreduceN + (DeqN : eqtm N N' A) + <- tpreduce-equiv DofB DreduceB + (DeqB : eqtp B B' (ekpi A ([x] K x))). + +-eqkind : tpreduce-equiv + (ekof/eqkind + (Deqkind : eqkind K K') + (DofA : ekof A K)) + (Dreduce : tpreduce A A') +%% + (eqtp/kcon Deqkind DeqA) +%% + <- tpreduce-equiv DofA Dreduce + (DeqA : eqtp A A' K). + +-ext : tpreduce-equiv + (ekof/ext + ([x] [d:evof x A] + DofApp x d : ekof (eaapp B x) (K x)) + (DofB : ekof B (ekpi A K'))) + (Dreduce : tpreduce B B') + (eqtp/extw DeqApp Deqtp) + <- tpreduce-equiv DofB Dreduce + (Deqtp : eqtp B B' (ekpi A K')) + <- ({x} {d:evof x A} + tpreduce-equiv (DofApp x d) + (tpreduce/app reduce/refl Dreduce) + (DeqApp x d : eqtp (eaapp B x) (eaapp B' x) (K x))). + +%worlds (ecsig | easig | ebind | evbind) + (reduce-equiv _ _ _) + (tpreduce-equiv _ _ _) + (eof-lam-invert _ _ _). +%total (D1 D2 D3) + (reduce-equiv D1 _ _) + (tpreduce-equiv D2 _ _) + (eof-lam-invert D3 _ _). + +kreduce-equiv : ewfkind K -> kreduce K K' -> eqkind K K' -> type. +%mode kreduce-equiv +X1 +X2 -X3. + +-type : kreduce-equiv ewfkind/tp kreduce/type + (eqkind/refl ewfkind/tp). + +-pi : kreduce-equiv + (ewfkind/pi DofB DofA) + (kreduce/pi DreduceB DreduceA) +%% + (eqkind/pi DeqB DeqA) +%% + <- tpreduce-equiv DofA DreduceA + (DeqA : eqtp A A' ektype) + <- ({x} {d:evof x A} {dv:variable x} + kreduce-equiv (DofB x d) (DreduceB x dv) + (DeqB x d : eqkind (B x) (B' x))). + +%worlds (ecsig | easig | ebind | evbind) (kreduce-equiv _ _ _). +%total {D E} (kreduce-equiv E D _). + +reduce*-equiv : eof M A -> reduce* M N -> eqtm M N A -> type. +%mode reduce*-equiv +X1 +X2 -X3. + +-refl : reduce*-equiv Dof reduce*/refl (eqtm/refl Dof). + +-trans : reduce*-equiv DofM + (reduce*/trans + (Dred* : reduce* M' N) + (Dred : reduce M M')) + (eqtm/trans DeqM'N DeqM) + <- reduce-equiv DofM Dred + (DeqM : eqtm M M' A) + <- eqtm-reg DeqM _ DofM' _ + <- reduce*-equiv DofM' Dred* + (DeqM'N : eqtm M' N A). + +%worlds (ecsig | easig | ebind | evbind) (reduce*-equiv _ _ _). +%total D (reduce*-equiv _ D _). + +tpreduce*-equiv : ekof M A -> tpreduce* M N -> eqtp M N A -> type. +%mode tpreduce*-equiv +X1 +X2 -X3. + +-refl : tpreduce*-equiv Dof tpreduce*/refl (eqtp/refl Dof). + +-trans : tpreduce*-equiv DofM + (tpreduce*/trans + (Dred* : tpreduce* M' N) + (Dred : tpreduce M M')) + (eqtp/trans DeqM'N DeqM) + <- tpreduce-equiv DofM Dred + (DeqM : eqtp M M' A) + <- eqtp-reg DeqM _ DofM' _ + <- tpreduce*-equiv DofM' Dred* + (DeqM'N : eqtp M' N A). + +%worlds (ecsig | easig | ebind | evbind) (tpreduce*-equiv _ _ _). +%total D (tpreduce*-equiv _ D _). + +kreduce*-equiv : ewfkind M -> kreduce* M N -> eqkind M N -> type. +%mode kreduce*-equiv +X1 +X2 -X3. + +-refl : kreduce*-equiv Dof kreduce*/refl (eqkind/refl Dof). + +-trans : kreduce*-equiv DofM + (kreduce*/trans + (Dred* : kreduce* M' N) + (Dred : kreduce M M')) + (eqkind/trans DeqM'N DeqM) + <- kreduce-equiv DofM Dred + (DeqM : eqkind M M') + <- eqkind-reg DeqM _ DofM' + <- kreduce*-equiv DofM' Dred* + (DeqM'N : eqkind M' N). + +%worlds (ecsig | easig | ebind | evbind) (kreduce*-equiv _ _ _). +%total D (kreduce*-equiv _ D _). diff --git a/src/reduce-normal.elf b/src/reduce-normal.elf new file mode 100644 index 0000000..debbedf --- /dev/null +++ b/src/reduce-normal.elf @@ -0,0 +1,82 @@ + +variable : etm -> type. + +%block evvar : block {x:etm} {dv:variable x}. +%block evbind : some {A:etp} block {x:etm} {d:evof x A} {dv:variable x}. + +%%%% Beta Normalization %%%% + +oa : etm -> type. %% outermost atomic. + +oa/const : oa (econst C). + +oa/var : oa X + <- variable X. + +oa/app : oa (eapp M N). + + +tpoa : etp -> type. + +tpoa/const : tpoa (eaconst A). +tpoa/app : tpoa (eaapp A M). + +reduce : etm -> etm -> type. +tpreduce : etp -> etp -> type. +kreduce : ekind -> ekind -> type. + +reduce-app : etm -> etm -> etm -> type. +% tpreduce-app : etp -> etm -> etp -> type. + +reduce/const : reduce (econst C) (econst C). + +reduce/var : reduce X X + <- variable X. + +reduce/lam : reduce (elam A M) (elam A' M') + <- tpreduce A A' + <- ({x} variable x -> reduce (M x) (M' x)). + +reduce/app : reduce (eapp M N) O + <- reduce M M' + <- reduce N N' + <- reduce-app M' N' O. + +reduce-app/atm : reduce-app M N (eapp M N) + <- oa M. + +reduce-app/beta : reduce-app (elam A ([x] M x)) N O + <- reduce (M N) O. + +%% + +tpreduce/const : tpreduce (eaconst A) (eaconst A). + +tpreduce/pi : tpreduce (epi A B) (epi A' B') + <- tpreduce A A' + <- ({x} variable x -> tpreduce (B x) (B' x)). + +tpreduce/lam : tpreduce (ealam A B) (ealam A' B') + <- tpreduce A A' + <- ({x} variable x -> tpreduce (B x) (B' x)). + +tpreduce/app : tpreduce (eaapp A M) (eaapp A' M') + <- tpreduce A A' + <- reduce M M'. + +%{ Removed 12/16/09 based on advice from Karl that reduction should only + serve to transform the EL term in the way that hsub transforms the + IL term -- that is, reductions on types should only reduce the terms + inside them. +tpreduce-app/atm : tpreduce-app A M (eaapp A M) + <- tpoa A. + +tpreduce-app/beta : tpreduce-app (ealam A ([x] B x)) M C + <- tpreduce (B M) C. +}% + +kreduce/type : kreduce ektype ektype. + +kreduce/pi : kreduce (ekpi A K) (ekpi A' K') + <- tpreduce A A' + <- ({x} variable x -> kreduce (K x) (K' x)). diff --git a/src/reduce.elf b/src/reduce.elf new file mode 100644 index 0000000..c66f37a --- /dev/null +++ b/src/reduce.elf @@ -0,0 +1,65 @@ + +variable : etm -> type. + +%block evvar : block {x:etm} {dv:variable x}. +%block evbind : some {A:etp} block {x:etm} {d:evof x A} {dv:variable x}. + +%%%% Syntactic Reduction %%%% + +reduce : etm -> etm -> type. +tpreduce : etp -> etp -> type. +kreduce : ekind -> ekind -> type. + +reduce/refl : reduce M M. + +reduce/lam : reduce (elam A M) (elam A' M') + <- tpreduce A A' + <- ({x} variable x -> reduce (M x) (M' x)). + +reduce/beta : reduce (eapp (elam _ [x] M x) N) (M N). + +reduce/app : reduce (eapp M N) (eapp M' N') + <- reduce M M' + <- reduce N N'. + +%% + +tpreduce/const : tpreduce (eaconst A) (eaconst A). + +tpreduce/pi : tpreduce (epi A B) (epi A' B') + <- tpreduce A A' + <- ({x} variable x -> tpreduce (B x) (B' x)). + +tpreduce/lam : tpreduce (ealam A B) (ealam A' B') + <- tpreduce A A' + <- ({x} variable x -> tpreduce (B x) (B' x)). + +tpreduce/app : tpreduce (eaapp A M) (eaapp A' M') + <- tpreduce A A' + <- reduce M M'. + +kreduce/type : kreduce ektype ektype. + +kreduce/pi : kreduce (ekpi A K) (ekpi A' K') + <- tpreduce A A' + <- ({x} variable x -> kreduce (K x) (K' x)). + +%% Transitive closure %% + +reduce* : etm -> etm -> type. +reduce*/refl : reduce* M M. +reduce*/trans : reduce* M N + <- reduce M M' + <- reduce* M' N. + +tpreduce* : etp -> etp -> type. +tpreduce*/refl : tpreduce* A A. +tpreduce*/trans : tpreduce* A C + <- tpreduce A B + <- tpreduce* B C. + +kreduce* : ekind -> ekind -> type. +kreduce*/refl : kreduce* A A. +kreduce*/trans : kreduce* A C + <- kreduce A B + <- kreduce* B C. diff --git a/src/regularity.thm b/src/regularity.thm new file mode 100644 index 0000000..57418a8 --- /dev/null +++ b/src/regularity.thm @@ -0,0 +1,173 @@ +%%%% regularity (implicit context) %%%% + +atkof-reg : at-kof P K -> wfkind K -> type. +%mode atkof-reg +X1 -X2. + +-const : atkof-reg (at-kof/const D _) D. + +-app : atkof-reg + (at-kof/app + (DsubK : ksub ([x] K x) M Kx) + (DofM : of M B) + (DofP : at-kof P (kpi B ([x] K x)))) +%% + DwfKx +%% + <- atkof-reg DofP + (wfkind/pi + ([x] [d:vof x B] DwfK x d : wfkind (K x)) + _) + <- ksubst DsubK ([x] [d] DwfK x d) DofM + (DwfKx : wfkind Kx). + + +%worlds (csig | asig | bind | var | ovar) (atkof-reg _ _). +%total D (atkof-reg D _). + +atof-reg : at-of R A -> kof A ktype -> type. +%mode atof-reg +X1 -X2. + +-const : atof-reg (at-of/const Dkof _) Dkof. + +-var : atof-reg (at-of/var Dkof _) Dkof. + +-app : atof-reg + (at-of/app + (Dtpsub : tpsub ([x] B x) M Bx) + (DofM : of M A) + (DofR : at-of R (pi A [x] B x))) +%% + DkofBx +%% + <- atof-reg DofR + (kof/pi + ([x] [d:vof x A] DkofB x d : kof (B x) ktype) + (DkofA : kof A ktype)) + <- tpsubst Dtpsub ksub/type ([x] [d] DkofB x d) DofM + (DkofBx : kof Bx ktype). + +%worlds (csig | asig | bind | var | ovar) (atof-reg _ _). +%total D (atof-reg D _). + + +of-reg : of M A -> kof A ktype -> type. +%mode of-reg +X1 -X2. + +-at : of-reg (of/at Datof) Dkof + <- atof-reg Datof Dkof. + +-lam : of-reg (of/lam DofA ([x] [d:vof x A] DofM x d : of (M x) (B x))) + (kof/pi DofB DofA) + <- ({x} {d} + of-reg (DofM x d) + (DofB x d : kof (B x) ktype)). + +%worlds (csig | asig | bind | var) (of-reg _ _). +%total D (of-reg D _). + + +%%%% regularity (explicit context) %%%% + +atofe-reg : ordered G -> at-ofe G R A -> kofe G A ktype -> type. +%mode atofe-reg +X0 +X1 -X2. + +-closed : atofe-reg _ (at-ofe/closed Datof) Dkofe + <- atof-reg Datof Dkof + <- kof-to-kofe Dkof DkofeNil + <- append-nil _ Dappend + <- weaken-kofe' Dappend DkofeNil Dkofe. + +-const : atofe-reg _ (at-ofe/const Dkof _) Dkof. + +-var : atofe-reg _ (at-ofe/var Dkof _) Dkof. + +-app : atofe-reg + (Dord : ordered G) + (at-ofe/app + (Dtpsub : tpsub ([x] B x) M Bx) + (DofM : ofe G M A) + (DofR : at-ofe G R (pi A [x] B x))) +%% + DkofBx +%% + <- atofe-reg Dord DofR + (kofe/pi + ([x] DkofB x : kofe (cons G x A) (B x) ktype) + (DkofA : kofe G A ktype)) + <- extend-ordered _ Dord _ + ([x] [d:isvar x _] Dord' x d : ordered (cons G x A)) + <- tpsubst-e Dord' ([_] append/nil) csub/base DofM Dtpsub DkofB + ksub/type + DkofBx. + +%worlds (csig | asig | bind | var | ovar) (atofe-reg _ _ _). +%total D (atofe-reg _ D _). + +atkofe-reg : ordered G -> at-kofe G P K -> wfkinde G K -> type. +%mode atkofe-reg +X1 +X2 -X3. + +-closed : atkofe-reg _ (at-kofe/closed Datkof) Dwfkinde + <- atkof-reg Datkof Dwfkind + <- wfkind-to-wfkinde Dwfkind DwfkindeNil + <- append-nil _ Dappend + <- weaken-wfkinde' Dappend DwfkindeNil Dwfkinde. + +-const : atkofe-reg _ (at-kofe/const Dwfkinde _) Dwfkinde. + +-app : atkofe-reg + (Dord : ordered G) + (at-kofe/app + (Dsub : ksub ([x] K x) M Kx) + (DofM : ofe G M A) + (DofP : at-kofe G P (kpi A [x] K x))) +%% + DofKx +%% + <- atkofe-reg Dord DofP + (wfkinde/pi + ([x] DofK x : wfkinde (cons G x A) (K x)) + (DofA : kofe G A ktype)) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x A)) + <- ksubst-e Dord' ([_] append/nil) csub/base DofM Dsub DofK + DofKx. + +%worlds (csig | asig | bind | var | ovar) (atkofe-reg _ _ _). +%total D (atkofe-reg _ D _). + +ofe-reg : ordered G -> ofe G M A -> kofe G A ktype -> type. +%mode ofe-reg +X1 +X2 -X3. + +-at : ofe-reg Dord (ofe/at Datofe) Dkofe + <- atofe-reg Dord Datofe Dkofe. + +-lam : ofe-reg Dord (ofe/lam Dkofe Dofe) (kofe/pi Dkofe' Dkofe) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d) + <- ({x} {d} + ofe-reg (Dord' x d) (Dofe x) (Dkofe' x)). + +%worlds (csig | asig | bind | var | ovar) (ofe-reg _ _ _). +%total D (ofe-reg _ D _). + + +kofe-reg : ordered G -> kofe G M A -> wfkinde G A -> type. +%mode kofe-reg +X1 +X2 -X3. + +-base : kofe-reg Dord (kofe/base Datofe) Dkofe + <- atkofe-reg Dord Datofe Dkofe. + +-lam : kofe-reg Dord (kofe/lam Dofe Dkofe) (wfkinde/pi Dkofe' Dkofe) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d) + <- ({x} {d} + kofe-reg (Dord' x d) (Dofe x) (Dkofe' x)). + +-pi : kofe-reg Dord (kofe/pi Dofe Dkofe) wfkinde/tp. + +%worlds (csig | asig | bind | var | ovar) (kofe-reg _ _ _). +%total D (kofe-reg _ D _). + + + + diff --git a/src/simp-lemmas.thm b/src/simp-lemmas.thm new file mode 100644 index 0000000..b34be07 --- /dev/null +++ b/src/simp-lemmas.thm @@ -0,0 +1,674 @@ +%%% functionality %%% + +simp-fun : simp A T -> simp A T' -> stp-eq T T' -> type. +%mode simp-fun +X1 +X2 -X3. + +-base : simp-fun simp/base simp/base stp-eq/i. + +-pi : simp-fun (simp/pi Dsimp2 Dsimp1) (simp/pi Dsimp2' Dsimp1') Deq + <- simp-fun Dsimp1 Dsimp1' Deq1 + <- ({x} simp-fun (Dsimp2 x) (Dsimp2' x) Deq2) + <- stp-compat-stp ([t] arrow t T2) Deq1 Deq1' + <- stp-compat-stp ([t] arrow T1' t) Deq2 Deq2' + <- stp-eq-trans Deq1' Deq2' Deq. + +-lam : simp-fun (simp/lam ([x] Dsimp x)) (simp/lam ([x] Dsimp' x)) Deq + <- ({x} simp-fun (Dsimp x) (Dsimp' x) Deq). + +%worlds (csig | asig | var | evar) (simp-fun _ _ _). +%total D (simp-fun D _ _). + + +ksimp-fun : ksimp K H -> ksimp K H' -> skind-eq H H' -> type. +%mode ksimp-fun +X1 +X2 -X3. + +-ktype : ksimp-fun ksimp/type ksimp/type skind-eq/i. + +-kpi : ksimp-fun (ksimp/pi Dksimp Dsimp) (ksimp/pi Dksimp' Dsimp') Deq + <- simp-fun Dsimp Dsimp' Dtpeq + <- ({x} ksimp-fun (Dksimp x) (Dksimp' x) Dkindeq) + <- skind-compat-skind ([t] karrow t T2) Dtpeq Deq1 + <- skind-compat-skind' ([t] karrow T1' t) Dkindeq Deq2 + <- skind-eq-trans Deq1 Deq2 Deq. + +%worlds (csig | asig | var | evar) (ksimp-fun _ _ _). +%total D (ksimp-fun D _ _). + +simpctx-fun : simpctx G G' -> simpctx G G'' -> sctx-eq G' G'' -> type. +%mode simpctx-fun +X1 +X2 -X3. + +-nil : simpctx-fun simpctx/nil simpctx/nil sctx-eq/i. + +-cons : simpctx-fun (simpctx/cons DsimpA Dsimpctx) (simpctx/cons DsimpA' Dsimpctx') + Deq + <- simp-fun DsimpA DsimpA' DeqA + <- simpctx-fun Dsimpctx Dsimpctx' DeqG + <- sctx-compat-cons _ DeqG DeqA Deq. + +%worlds (csig | asig | var | evar) (simpctx-fun _ _ _). +%total D (simpctx-fun D _ _). + + +%%% random stuff %%% + +%% this lemma allows us to tell twelf that one type reduces to another +%% when they are stp-leq. + +employ-stp-leq : {S} {T} stp-leq S T -> type. +%mode employ-stp-leq +S +T +X1. + +- : employ-stp-leq _ _ stp-leq/eq. + +- : employ-stp-leq S (arrow T1 T2) (stp-leq/arr1 (Dleq : stp-leq S T1)) + <- employ-stp-leq S T1 Dleq. + +- : employ-stp-leq S (arrow T1 T2) (stp-leq/arr2 (Dleq : stp-leq S T2)) + <- employ-stp-leq S T2 Dleq. + +%worlds (csig | asig | evar) (employ-stp-leq _ _ _). +%total D (employ-stp-leq _ _ D). +%reduces S <= T (employ-stp-leq S T _). + + +stp-leq-trans : stp-leq T1 T2 -> stp-leq T2 T3 -> stp-leq T1 T3 -> type. +%mode stp-leq-trans +X1 +X2 -X3. + +- : stp-leq-trans D stp-leq/eq D. + +- : stp-leq-trans D (stp-leq/arr1 D') (stp-leq/arr1 D'') + <- stp-leq-trans D D' D''. + +- : stp-leq-trans D (stp-leq/arr2 D' ) (stp-leq/arr2 D'') + <- stp-leq-trans D D' D''. + +%worlds (csig | asig | evar) (stp-leq-trans _ _ _). +%total D (stp-leq-trans _ D _). + + +tpsub-preserves-simp : tpsub A _ B -> ({x} simp (A x) T) -> simp B T -> type. +%mode tpsub-preserves-simp +X1 +X2 -X3. + +- : tpsub-preserves-simp (tpsub/base _) ([_] simp/base) simp/base. + +- : tpsub-preserves-simp (tpsub/pi Dsub2 Dsub1) + ([x] simp/pi ([y] Dsimp2 x y) (Dsimp1 x)) +%% + (simp/pi Dsimp2' Dsimp1') +%% + <- tpsub-preserves-simp Dsub1 Dsimp1 Dsimp1' + <- ({y} tpsub-preserves-simp (Dsub2 y) ([x] Dsimp2 x y) (Dsimp2' y)). + +- : tpsub-preserves-simp (tpsub/lam ([x] Dsub x)) + ([x] simp/lam ([y] Dsimp x y)) +%% + (simp/lam ([y] Dsimp' y)) +%% + <- ({y} tpsub-preserves-simp (Dsub y) ([x] Dsimp x y) (Dsimp' y)). + +%worlds (csig | asig | var | evar) (tpsub-preserves-simp _ _ _). +%total D (tpsub-preserves-simp _ D _). + + + +ksub-preserves-ksimp : ksub K _ K' -> ({x} ksimp (K x) H) -> ksimp K' H -> type. +%mode ksub-preserves-ksimp +X1 +X2 -X3. + +- : ksub-preserves-ksimp ksub/type ([_] ksimp/type) ksimp/type. + +- : ksub-preserves-ksimp (ksub/pi ([y] Dksub y) Dtpsub) + ([x] ksimp/pi ([y] Dksimp x y) (Dsimp x)) +%% + (ksimp/pi Dksimp' Dsimp') +%% + <- tpsub-preserves-simp Dtpsub Dsimp Dsimp' + <- ({y} ksub-preserves-ksimp (Dksub y) ([x] Dksimp x y) (Dksimp' y)). + +%worlds (csig | asig | var | evar) (ksub-preserves-ksimp _ _ _). +%total D (ksub-preserves-ksimp _ D _). + + + +%%% effectiveness %%% + +can-simp : {A} simp A T -> type. +%mode can-simp +X1 -X2. + +-pi : can-simp (pi A [x] B x) (simp/pi ([x] DsimpB x) DsimpA) + <- can-simp A DsimpA + <- ({x} can-simp (B x) (DsimpB x)). + +-base : can-simp (base _) simp/base. + +-lam : can-simp (alam ([x] A x)) (simp/lam ([x] DsimpA x)) + <- ({x} can-simp (A x) (DsimpA x)). + +%worlds (csig | asig | var | evar) (can-simp _ _). +%total A (can-simp A _). + + +can-ksimp : {A} ksimp A T -> type. +%mode can-ksimp +X1 -X2. + +-pi : can-ksimp (kpi A [x] K x) (ksimp/pi ([x] DksimpK x) DsimpA) + <- can-simp A DsimpA + <- ({x} can-ksimp (K x) (DksimpK x)). + +-base : can-ksimp ktype ksimp/type. + +%worlds (csig | asig | var | evar) (can-ksimp _ _). +%total A (can-ksimp A _). + + +can-simpctx : {G} simpctx G G' -> type. +%mode can-simpctx +X1 -X2. + +- : can-simpctx nil simpctx/nil. + +- : can-simpctx (cons G X A) (simpctx/cons DsimpA DsimpG) + <- can-simpctx G DsimpG + <- can-simp A DsimpA. + +%worlds (csig | asig | var | evar) (can-simpctx _ _). +%total G (can-simpctx G _). + + +%%% simplification of context preserves context properties %%% + + +bounded-simpctx : simpctx G G' -> bounded G X -> sbounded G' X -> type. +%mode bounded-simpctx +X1 +X2 -X3. + +- : bounded-simpctx simpctx/nil (bounded/nil D) (sbounded/nil D). + +- : bounded-simpctx (simpctx/cons _ Dsimp) (bounded/cons Dbound Dprec) (sbounded/cons Dbound' Dprec) + <- bounded-simpctx Dsimp Dbound Dbound'. + +%worlds (csig | asig | var | ovar | evar) (bounded-simpctx _ _ _). +%total D (bounded-simpctx D _ _). + + +ordered-simpctx : simpctx G G' -> ordered G -> sordered G' -> type. +%mode ordered-simpctx +X1 +X2 -X3. + +- : ordered-simpctx simpctx/nil ordered/nil sordered/nil. + +- : ordered-simpctx (simpctx/cons _ Dsimp) (ordered/cons Dbound) (sordered/cons Dbound') + <- bounded-simpctx Dsimp Dbound Dbound'. + +%worlds (csig | asig | var | ovar | evar) (ordered-simpctx _ _ _). +%total {} (ordered-simpctx _ _ _). + +sappend-resp : sctx-eq G1 G1' -> sctx-eq G2 G2' -> sctx-eq G G' -> sappend G1 G2 G + -> sappend G1' G2' G' -> type. +%mode sappend-resp +X1 +X2 +X3 +X4 -X5. + +- : sappend-resp sctx-eq/i sctx-eq/i sctx-eq/i D D. + +%worlds (csig | asig | var | evar) (sappend-resp _ _ _ _ _). +%total {} (sappend-resp _ _ _ _ _). + +append-simpctx : append G1 G2 G + -> simpctx G1 G1' -> simpctx G2 G2' -> simpctx G G' + -> sappend G1' G2' G' -> type. +%mode append-simpctx +X1 +X2 -X3 -X4 -X5. + +% G1 = G; G2 = nil +- : append-simpctx (append/nil : append G nil G) + DsimpG + (simpctx/nil : simpctx nil snil) + DsimpG + (sappend/nil : sappend G' snil G') + . +%{ + <- can-simpctx G + (DsimpG : simpctx G G'). +}% + +% G1 = G1; G2 = (cons G2 X A) +- : append-simpctx (append/cons (Dappend : append G1 G2 G) + : append G1 (cons G2 X A) (cons G X A)) + DsimpG1 + (simpctx/cons DsimpA DsimpG2) + (simpctx/cons DsimpA DsimpG) + (sappend/cons Dsappend) + <- append-simpctx Dappend + (DsimpG1 : simpctx G1 G1') + (DsimpG2 : simpctx G2 G2') + (DsimpG : simpctx G G') + (Dsappend : sappend G1' G2' G') + <- can-simp A + (DsimpA : simp A T). + +%worlds (csig | asig | var | ovar) (append-simpctx _ _ _ _ _). +%total D (append-simpctx D _ _ _ _). + + +append-simpctx' : append G1 G2 G -> simpctx G1 G1' -> simpctx G2 G2' -> simpctx G G' + -> sappend G1' G2' G' -> type. +%mode append-simpctx' +X1 +X2 +X3 +X4 -X5. + +% G1 = G; G2 = nil +- : append-simpctx' + (append/nil : append G nil G) + (DsimpG : simpctx G G') + (simpctx/nil : simpctx nil snil) + (DsimpG' : simpctx G G'') +%% + Dappend +%% + <- simpctx-fun DsimpG DsimpG' + (DeqG'G'' : sctx-eq G' G'') + <- sappend-resp sctx-eq/i sctx-eq/i DeqG'G'' sappend/nil + (Dappend : sappend G' snil G''). + +% G1 = G1; G2 = (cons G2 X A); G = (cons G X A) +% append G1 (cons G2 X A) (cons G X A) +- : append-simpctx' + (append/cons (Dappend : append G1 G2 G) + : append G1 (cons G2 X A) (cons G X A)) + (DsimpG1 : simpctx G1 G1') + (simpctx/cons DsimpA DsimpG2 : simpctx (cons G2 X A) (scons G2' X T)) + (simpctx/cons DsimpA' DsimpG : simpctx (cons G X A) (scons G' X T')) +%% + Dsappend' +%% + <- append-simpctx' Dappend DsimpG1 DsimpG2 DsimpG + (Dsappend : sappend G1' G2' G') + <- simp-fun DsimpA DsimpA' + (DeqTT' : stp-eq T T') + <- sctx-compat-cons _ sctx-eq/i DeqTT' + (DeqCons : sctx-eq (scons G' X T) (scons G' X T')) + <- sappend-resp sctx-eq/i sctx-eq/i DeqCons (sappend/cons Dsappend) + (Dsappend' : sappend G1' (scons G2' X T) (scons G' X T')). + +%worlds (csig | asig | var | ovar) (append-simpctx' _ _ _ _ _). +%total D (append-simpctx' D _ _ _ _). + + +lookup-simp : simpctx G G' -> simp A T -> lookup G X A + -> slookup G' X T -> type. +%mode lookup-simp +X1 +X2 +X3 -X4. + +- : lookup-simp (simpctx/cons Dsimp Dsimpctx) Dsimp' lookup/hit D + <- simp-fun Dsimp Dsimp' Deq + <- slookup-compat sctx-eq/i atm-eq/i Deq slookup/hit D. + +- : lookup-simp (simpctx/cons _ Dsimpctx) Dsimp (lookup/miss Dlookup) + (slookup/miss Dlookup') + <- lookup-simp Dsimpctx Dsimp Dlookup Dlookup'. + +%worlds (csig | asig | var | evar) (lookup-simp _ _ _ _). +%total D (lookup-simp _ _ D _). + + +context-append-simp-lookup : ({x} append (cons G1 x A) (G2 x) (G x)) + -> simp A T +%% + -> ({x} simpctx (G x) (G' x)) + -> ({x} slookup (G' x) x T) -> type. +%mode context-append-simp-lookup +X1 +X2 -X3 -X4. + +- : context-append-simp-lookup + ([x] append/nil) + Dsimp +%% + ([x] simpctx/cons Dsimp Dsimpctx) + ([x] slookup/hit) +%% + <- can-simpctx G Dsimpctx. + +- : context-append-simp-lookup + ([x] append/cons (Dappend x)) + Dsimp +%% + ([x] simpctx/cons (Dsimp' x) (Dsimpctx x)) + ([x] slookup/miss (Dlookup x)) +%% + <- ({x} can-simp _ (Dsimp' x : simp _ T)) + <- context-append-simp-lookup Dappend Dsimp Dsimpctx Dlookup. + +%worlds (csig | asig | var | ovar | evar) (context-append-simp-lookup _ _ _ _). +%total D (context-append-simp-lookup D _ _ _). + + +context-append-simp-lookup' : ({x} append (cons G1 x A) (G2 x) (G x)) + -> ({x} isvar x I -> ordered (G x)) + -> simp A T +%% + -> ({x} simpctx (G x) (G' x)) + -> ({x} slookup (G' x) x T) -> type. +%mode context-append-simp-lookup' +X1 +X2 +X3 -X4 -X5. + +- : context-append-simp-lookup' + ([x] append/nil) + ([x] [d] ordered/cons (Dbounded x d)) + Dsimp +%% + ([x] simpctx/cons Dsimp Dsimpctx) + ([x] slookup/hit) +%%% + <- can-simpctx G Dsimpctx. + +- : context-append-simp-lookup' + ([x] append/cons (Dappend x)) + ([x] [d] ordered/cons (Dbounded x d)) + Dsimp +%% + ([x] simpctx/cons (Dsimp' x) (Dsimpctx x)) + ([x] slookup/miss (Dlookup x)) +%%% + <- ({x} can-simp _ (Dsimp' x : simp _ T)) + <- context-append-simp-lookup Dappend Dsimp Dsimpctx Dlookup. + +%worlds (csig | asig | var | ovar | evar) (context-append-simp-lookup' _ _ _ _ _). +%total {} (context-append-simp-lookup' _ _ _ _ _). + + +%%% weakening (XXX this should probably go in explicit-lemmas) %%% + + +append-lookup : append (cons G1 X T) G2 G + -> lookup G X T -> type. +%mode append-lookup +X1 -X2. + +-nil : append-lookup append/nil lookup/hit. + +-cons : append-lookup (append/cons Dappend) + (lookup/miss Dlook) + <- append-lookup Dappend Dlook. + +%worlds (csig | asig | var | ovar) (append-lookup _ _). +%total D (append-lookup D _). + + + +sappend-slookup : sappend (scons G1 X T) G2 G + -> slookup G X T -> type. +%mode sappend-slookup +X1 -X2. + +-nil : sappend-slookup sappend/nil slookup/hit. + +-cons : sappend-slookup (sappend/cons Dappend) + (slookup/miss Dlook) + <- sappend-slookup Dappend Dlook. + +%worlds (csig | asig | var | ovar) (sappend-slookup _ _). +%total D (sappend-slookup D _). + + + +%%% simplification preserves typing %%% + +at-ofe-simp : simpctx G G' -> simp A T -> at-ofe G R A + -> at-ofes G' R T -> type. +%mode at-ofe-simp +X1 +X2 +X3 -X4. + +ofe-simp : simpctx G G' -> simp A T -> ofe G M A + -> ofes G' M T -> type. +%mode ofe-simp +X1 +X2 +X3 -X4. + +atkofe-simp : simpctx G G' -> ksimp K H -> at-kofe G P K + -> at-kofes G' P H -> type. +%mode atkofe-simp +X1 +X2 +X3 -X4. + +kofe-simp : simpctx G G' -> ksimp K K' -> kofe G A K + -> kofes G' A K' -> type. +%mode kofe-simp +X0 +X1 +X2 -X3. + +wfkinde-simp : simpctx G G' -> wfkinde G K -> wfkindes G' K -> type. +%mode wfkinde-simp +X1 +X2 -X3. + +-closed : at-ofe-simp Dsimpctx Dsimp (at-ofe/closed Datof) + (at-ofes/closed Dsimp Datof). + +-const : at-ofe-simp Dsimpctx Dsimp (at-ofe/const Dkofe Dcof) + (at-ofes/const Dsimp Dkofes Dcof) + <- kofe-simp Dsimpctx ksimp/type Dkofe Dkofes. + +-var : at-ofe-simp Dsimpctx Dsimp (at-ofe/var _ Dlookup) + (at-ofes/var Dlookup') + <- lookup-simp Dsimpctx Dsimp Dlookup Dlookup'. + +-app : at-ofe-simp Dsimpctx Dsimp (at-ofe/app Dsub Dof Datof) D + <- can-simp _ DsimpA + <- ({x} can-simp _ (DsimpB x)) + <- at-ofe-simp Dsimpctx (simp/pi DsimpB DsimpA) Datof Datof' + <- ofe-simp Dsimpctx DsimpA Dof Dof' + <- tpsub-preserves-simp Dsub DsimpB Dsimp' + <- simp-fun Dsimp' Dsimp Deq + <- atofes-resp sctx-eq/i atm-eq/i Deq (at-ofes/app Dof' Datof') D. + +-at : ofe-simp Dsimpctx simp/base (ofe/at Datof) (ofes/at Datof') + <- at-ofe-simp Dsimpctx simp/base Datof Datof'. + +-lam : ofe-simp Dsimpctx (simp/pi DsimpB DsimpA) (ofe/lam _ Dof) + (ofes/lam Dof') + <- ({x} + ofe-simp + (simpctx/cons DsimpA Dsimpctx) + (DsimpB x) + (Dof x) + (Dof' x)). + +-base : kofe-simp Dsimpctx _ (kofe/base Datkofe) (kofes/base Datkofes) + <- atkofe-simp Dsimpctx ksimp/type Datkofe Datkofes. + +-pi : kofe-simp Dsimpctx _ (kofe/pi ([x] DkofeB x) DkofeA) + (kofes/pi ([x] DkofesB x) DsimpA DkofesA) + <- can-simp _ DsimpA + <- kofe-simp Dsimpctx ksimp/type DkofeA DkofesA + <- ({x} + kofe-simp (simpctx/cons DsimpA Dsimpctx) ksimp/type (DkofeB x) + (DkofesB x)). + +-alam : kofe-simp Dsimpctx (ksimp/pi DsimpK DsimpA) + (kofe/lam ([x] DofB x) DofA) + (kofes/lam DofB') + <- ({x} + kofe-simp + (simpctx/cons DsimpA Dsimpctx) (DsimpK x) (DofB x) + (DofB' x)). + +-closed : atkofe-simp Dsimpctx Dksimp (at-kofe/closed Datkof) + (at-kofes/closed Dksimp Datkof). + +-const : atkofe-simp Dsimpctx Dksimp (at-kofe/const Dwfkinde Dckof) + (at-kofes/const Dksimp Dwfkindes Dckof) + <- wfkinde-simp Dsimpctx Dwfkinde Dwfkindes. + +-app : atkofe-simp Dsimpctx Dksimp (at-kofe/app Dsub Dofe Datkofe) + D + <- can-simp _ Dsimp + <- ({x} can-ksimp _ (Dksimp' x)) + <- atkofe-simp Dsimpctx (ksimp/pi ([x] Dksimp' x) Dsimp) Datkofe + Datkofes + <- ofe-simp Dsimpctx Dsimp Dofe Dofes + <- ksub-preserves-ksimp Dsub Dksimp' DsimpKx + <- ksimp-fun DsimpKx Dksimp Deq + <- atkofes-resp sctx-eq/i atp-eq/i Deq + (at-kofes/app Dofes Datkofes) D. + +-ktype : wfkinde-simp _ wfkinde/tp wfkindes/type. + +-kpi : wfkinde-simp Dsimpctx (wfkinde/pi ([x] Dwfkinde x) Dkofe) + (wfkindes/pi ([x] Dwfkindes x) Dsimp Dkofes) + <- can-simp _ Dsimp + <- kofe-simp Dsimpctx ksimp/type Dkofe Dkofes + <- ({x} + wfkinde-simp (simpctx/cons Dsimp Dsimpctx) (Dwfkinde x) + (Dwfkindes x)). + +%worlds (csig | asig | bind | var | evar) + (at-ofe-simp _ _ _ _) + (ofe-simp _ _ _ _) + (atkofe-simp _ _ _ _) + (kofe-simp _ _ _ _) + (wfkinde-simp _ _ _). +%total (D1 D2 D3 D4 D5) + (at-ofe-simp _ _ D1 _) + (ofe-simp _ _ D2 _) + (atkofe-simp _ _ D3 _) + (kofe-simp _ _ D4 _) + (wfkinde-simp _ D5 _). + + +tpsub-simp : tpsub ([x] A x) M Ax -> ({x} simp (A x) T) + -> simp Ax T -> type. +%mode tpsub-simp +X1 +X2 -X3. + +- : tpsub-simp + (tpsub/pi ([y] DsubB y) DsubA) + ([x] simp/pi ([y] DsimpB x y) (DsimpA x)) +%% + (simp/pi ([y] DsimpBx y) DsimpAx) +%% + <- tpsub-simp DsubA DsimpA DsimpAx + <- ({y} + tpsub-simp (DsubB y) ([x] DsimpB x y) (DsimpBx y)). + +- : tpsub-simp (tpsub/base _) ([x] simp/base) simp/base. + +- : tpsub-simp + (tpsub/lam ([y] Dsub y)) + ([x] simp/lam ([y] Dsimp x y)) + (simp/lam ([y] Dsimp' y)) + <- ({y} + tpsub-simp (Dsub y) ([x] Dsimp x y) (Dsimp' y)). + +%worlds (csig | asig | var) (tpsub-simp _ _ _). +%total D (tpsub-simp _ D _). + + +%{ +strengthen-simpctx : ({x:atm} simpctx (G x) G') + -> ({x} ctx-eq (G x) Gx) -> type. +%mode strengthen-simpctx +X1 -X2. + +- : strengthen-simpctx ([x] simpctx/nil) ([_] ctx-eq/i). + +- : strengthen-simpctx + ([x] simpctx/cons + (DsimpA x : simp (A x) T) + (Dsimpctx x : simpctx (G x) G') + : simpctx (cons (G x) Y (A x)) (scons G' Y T)) + ([x] DeqGYA x) + <- strengthen-simpctx Dsimpctx + ([x] DeqG x : ctx-eq (G x) Gx) + <- ({x} + cons-compat (DeqG x) atm-eq/i (DeqAA' x) + (DeqGYA x : ctx-eq (cons (G x) Y (A x)) (cons Gx Y A'))) + . + +%worlds (csig | asig | var) (strengthen-simpctx _ _). +%total D (strengthen-simpctx D _). +XXX not provable! + +maybe something like + +- : ({x} simpctx (G x)) G' -> csub ([x] G x) _ Gx + -> simpctx Gx G' -> type. + +? }% + +strengthen-simpctx : ({x:atm} simpctx G (G' x)) + -> ({x} sctx-eq (G' x) G'') -> type. +%mode strengthen-simpctx +X1 -X2. + +-nil : strengthen-simpctx ([_] simpctx/nil) ([_] sctx-eq/i). + +-cons : strengthen-simpctx + ([x] simpctx/cons (Dsimpctx x) (Dsimp x)) + DeqGxS + <- strengthen-simpctx Dsimp + ([x] DeqG x : sctx-eq (G x) G') + <- ({x} + scons-compat (DeqG x) atm-eq/i stp-eq/i + (DeqGxS x : sctx-eq (scons (G x) Y T) (scons G' Y T))). + +%worlds (csig | asig | var) (strengthen-simpctx _ _). +%total D (strengthen-simpctx D _). + +csub-simp : {G} csub ([x] G x) M Gx + -> ({x} simpctx (G x) (G' x)) + -> drop ([x] G' x) G'' +%% + -> simpctx Gx G'' -> type. +%mode csub-simp +G +X1 +X2 +X3 -X4. + +-base : csub-simp _ + (csub/base : csub ([x] cons G x A) M G) + ([x] + simpctx/cons + (Dsimp x : simp A T) + (Dsimpctx x : simpctx G (G' x))) + (drop/base (Ddrop : drop ([x] G' x) G'')) + Dsimpctx' + <- csub-closed _ _ + (DsubG : csub ([x] G) M G) + <- csub-simp _ DsubG Dsimpctx Ddrop + (Dsimpctx' : simpctx G G''). + +-nil : csub-simp _ csub/nil ([_] simpctx/nil) _ + simpctx/nil . + +-cons : csub-simp + ([x] cons (G x) Y (A x)) + (csub/cons + (DsubA : tpsub ([x] A x) M Ax) + (DsubG : csub ([x] G x) M Gx)) + ([x] simpctx/cons + (DsimpA x : simp (A x) T) + (DsimpG x : simpctx (G x) G')) + drop/closed + (simpctx/cons DsimpAx DsimpGx) + <- csub-simp ([x] G x) DsubG DsimpG drop/closed + (DsimpGx : simpctx Gx G') + <- tpsub-simp DsubA DsimpA + (DsimpAx : simp Ax T) + . + +-cons : csub-simp ([x] cons (G x) Y (A x)) + (csub/cons + (DsubA : tpsub ([x] A x) M Ax) + (DsubG : csub ([x] G x) M Gx) + : csub ([x] cons (G x) Y (A x)) M (cons Gx Y Ax)) + ([x] simpctx/cons + (DsimpA x : simp (A x) T) + (DsimpG x : simpctx (G x) (G' x))) + (drop/cons + (Ddrop : drop ([x] G' x) G'') + : drop ([x] scons (G' x) Y T) (scons G'' _ _)) + (simpctx/cons + DsimpAx + DsimpGx) + <- tpsub-simp DsubA DsimpA + (DsimpAx : simp Ax T) + <- csub-simp ([x] G x) DsubG DsimpG Ddrop + (DsimpGx : simpctx Gx G''). + +%worlds (csig | asig | var) (csub-simp _ _ _ _ _). +%total G (csub-simp G _ _ _ _). + +lookup-simp-rev : slookup G' X T -> simpctx G G' + -> lookup G X A + -> simp A T -> type. +%mode lookup-simp-rev +X1 +X2 -X3 -X4. + +-hit : lookup-simp-rev + slookup/hit + (simpctx/cons (Dsimp : simp A T) (Dsimpctx : simpctx G G')) + lookup/hit + Dsimp. + +-miss : lookup-simp-rev + (slookup/miss (Dlook : slookup G' X T)) + (simpctx/cons (Dsimp : simp B S) (Dsimpctx : simpctx G G')) + (lookup/miss Dlook') + Dsimp' + <- lookup-simp-rev Dlook Dsimpctx + (Dlook' : lookup G X A) + (Dsimp' : simp A T). + +%worlds (csig | asig | var) (lookup-simp-rev _ _ _ _). +%total D (lookup-simp-rev D _ _ _). + diff --git a/src/simple-regularity.thm b/src/simple-regularity.thm new file mode 100644 index 0000000..d404d38 --- /dev/null +++ b/src/simple-regularity.thm @@ -0,0 +1,173 @@ + +%% implicit typing, simple regularity %% + +atof-reg-kofes : at-of R A -> kofes snil A sktype -> type. +%mode atof-reg-kofes +X1 -X2. + +-const : atof-reg-kofes (at-of/const Dkof Dcof) Dkofes + <- kof-to-kofe Dkof (Dkofe : kofe nil A ktype) + <- kofe-simp simpctx/nil ksimp/type Dkofe + (Dkofes : kofes snil A sktype). + +-var : atof-reg-kofes (at-of/var Dkof Dvof) Dkofes + <- kof-to-kofe Dkof (Dkofe : kofe nil A ktype) + <- kofe-simp simpctx/nil ksimp/type Dkofe + (Dkofes : kofes snil A sktype). + +-app : atof-reg-kofes (at-of/app Dtpsub Dof Datof) Dkofes' + <- atof-reg-kofes Datof + (kofes/pi ([x] DkofesB x) DsimpA DkofesA) + <- of-to-ofe Dof (Dofe : ofe nil M A) + <- ({x} + weaken-ofe Dofe _ _ + (Dofe' x : ofe (cons nil x A) M A)) + <- ({x} + ofe-simp (simpctx/cons DsimpA simpctx/nil) DsimpA (Dofe' x) + (Dofes x : ofes (scons snil x T) M T)) + <- ({x} + lookup-simp (simpctx/cons DsimpA simpctx/nil) DsimpA lookup/hit + (Dslook x : slookup (scons snil x T) x T)) + <- tpsubst-es + ([x] [d:isvar x 0] sordered/cons (sbounded/nil d)) + ([x] Dslook x) + ([x] Dofes x) + ([x] DkofesB x) + Dtpsub + ([x] Dkofes x : kofes (scons snil x T) B' sktype) + <- strengthen-kofes ([_] sappend/nil) sappend/nil ([x] Dkofes x) + Dkofes'. + +%worlds (csig | asig | bind | var | ovar) (atof-reg-kofes _ _). +%total D (atof-reg-kofes D _). + + +atkof-reg-wfkindes : at-kof P K -> wfkindes snil K -> type. +%mode atkof-reg-wfkindes +X1 -X2. + +-const : atkof-reg-wfkindes (at-kof/const Dwfkind _) Dwfkindes + <- wfkind-to-wfkinde Dwfkind (Dwfkinde : wfkinde nil K) + <- wfkinde-simp simpctx/nil Dwfkinde + (Dwfkindes : wfkindes snil K). + +-app : atkof-reg-wfkindes + (at-kof/app + (Dksub : ksub ([x] K x) M Kx) + (Dof : of M A) + (Datkof : at-kof P (kpi A [x] K x))) + Dwfkindes'' + <- atkof-reg-wfkindes Datkof + (wfkindes/pi ([x] Dwfkindes x) DsimpA DkofesA) + <- of-to-ofe Dof (Dofe : ofe nil M A) + <- ({x} + weaken-ofe Dofe _ _ + (Dofe' x : ofe (cons nil x A) M A)) + <- ({x} + ofe-simp (simpctx/cons DsimpA simpctx/nil) DsimpA (Dofe' x) + (Dofes x : ofes (scons snil x T) M T)) + <- ({x} + lookup-simp (simpctx/cons DsimpA simpctx/nil) DsimpA lookup/hit + (Dslook x : slookup (scons snil x T) x T)) + <- ksubst-es + ([x] [d:isvar x 0] sordered/cons (sbounded/nil d)) + ([x] Dslook x) + ([x] Dofes x) + ([x] Dwfkindes x) + Dksub + ([x] Dwfkindes' x : wfkindes (scons snil x T) Kx) + <- strengthen-wfkindes ([_] sappend/nil) sappend/nil ([x] Dwfkindes' x) + (Dwfkindes'' : wfkindes snil Kx). + +%worlds (csig | asig | bind | var | ovar) (atkof-reg-wfkindes _ _). +%total D (atkof-reg-wfkindes D _). + + +%% explicit typing, simple regularity %% + +atofe-reg-kofes : ordered G -> at-ofe G R A -> simpctx G G' + -> kofes G' A sktype -> type. +%mode atofe-reg-kofes +X0 +X1 +X2 -X3. + +-closed : atofe-reg-kofes _ (at-ofe/closed Datof) _ Dkofes' + <- atof-reg-kofes Datof Dkofes + <- sappend-nil _ Dappend + <- weaken-kofes' Dappend Dkofes Dkofes'. + +-const : atofe-reg-kofes _ (at-ofe/const Dkofe Dcof) Dsimpctx Dkofes + <- kofe-simp Dsimpctx ksimp/type Dkofe Dkofes. + +-var : atofe-reg-kofes _ (at-ofe/var Dkofe _) Dsimpctx Dkofes + <- kofe-simp Dsimpctx ksimp/type Dkofe Dkofes. + +-app : atofe-reg-kofes Dord (at-ofe/app Dsub Dofe Datofe) Dsimpctx + Dkofes' + <- atofe-reg-kofes Dord Datofe Dsimpctx + (kofes/pi ([x] DkofesB x) DsimpA DkofesA) + <- ({x} weaken-ofe Dofe _ _ + (Dofe' x : ofe (cons G x A) M A)) + <- ({x} ofe-simp + (simpctx/cons DsimpA Dsimpctx) + DsimpA + (Dofe' x) + (Dofes x : ofes (scons G' x T) M T)) + <- ({x} + lookup-simp (simpctx/cons DsimpA Dsimpctx) DsimpA lookup/hit + (Dslook x : slookup (scons G' x T) x T)) + <- ordered-simpctx Dsimpctx Dord Dsord + <- extend-sordered _ Dsord _ + ([x] [d] Dsord' x d : sordered (scons G' x T)) + <- tpsubst-es + ([x] [d] Dsord' x d) + ([x] Dslook x) + ([x] Dofes x) + ([x] DkofesB x) + Dsub + ([x] Dkofes x : kofes (scons G' x T) B' sktype) + <- strengthen-kofes ([_] sappend/nil) sappend/nil ([x] Dkofes x) + Dkofes'. + +%worlds (csig | asig | bind | var | ovar) (atofe-reg-kofes _ _ _ _). +%total D (atofe-reg-kofes _ D _ _). + + +atkofe-reg-wfkindes : ordered G -> at-kofe G P K -> simpctx G G' + -> wfkindes G' K -> type. +%mode atkofe-reg-wfkindes +X0 +X1 +X2 -X3. + +-closed : atkofe-reg-wfkindes _ (at-kofe/closed Datkof) _ Dwfkindes' + <- atkof-reg-wfkindes Datkof Dwfkindes + <- sappend-nil _ Dappend + <- weaken-wfkindes' Dappend Dwfkindes Dwfkindes'. + +-const : atkofe-reg-wfkindes _ (at-kofe/const Dwfkinde _) Dsimpctx Dwfkindes + <- wfkinde-simp Dsimpctx Dwfkinde Dwfkindes. + +-app : atkofe-reg-wfkindes Dord (at-kofe/app Dsub Dofe Datkofe) Dsimpctx + Dwfkindes' + <- atkofe-reg-wfkindes Dord Datkofe Dsimpctx + (wfkindes/pi ([x] DwfkindesK x) DsimpA DkofesA) + <- ({x} weaken-ofe Dofe _ _ + (Dofe' x : ofe (cons G x A) M A)) + <- ({x} ofe-simp + (simpctx/cons DsimpA Dsimpctx) + DsimpA + (Dofe' x) + (Dofes x : ofes (scons G' x T) M T)) + <- ({x} + lookup-simp (simpctx/cons DsimpA Dsimpctx) DsimpA lookup/hit + (Dslook x : slookup (scons G' x T) x T)) + <- ordered-simpctx Dsimpctx Dord Dsord + <- extend-sordered _ Dsord _ + ([x] [d] Dsord' x d : sordered (scons G' x T)) + <- ksubst-es + ([x] [d] Dsord' x d) + ([x] Dslook x) + ([x] Dofes x) + ([x] DwfkindesK x) + Dsub + ([x] Dwfkindes x : wfkindes (scons G' x T) K') + <- strengthen-wfkindes ([_] sappend/nil) sappend/nil ([x] Dwfkindes x) + Dwfkindes'. + +%worlds (csig | asig | bind | var | ovar) (atkofe-reg-wfkindes _ _ _ _). +%total D (atkofe-reg-wfkindes _ D _ _). + diff --git a/src/sound.thm b/src/sound.thm new file mode 100644 index 0000000..a6d58bf --- /dev/null +++ b/src/sound.thm @@ -0,0 +1,681 @@ +%%%% + +expand-convert : expand R T N + -> simp A T + -> aconvert R A EM + -> convert N A EN +%% + -> tpconvert A ktype EA + -> eqtm EM EN EA -> type. +%mode expand-convert +X1 +X2 +X3 +X4 -X5 -X6. + +-o : expand-convert expand/o simp/base + (DconvR : aconvert R (base P) EM) + (convert/at (DconvR' : aconvert R (base P) EM')) +%% + DconvP + Deqtm +%% + <- aconvert-reg-il DconvR + (DofR : at-of R (base P)) + <- atof-reg DofR + (DofP : kof (base P) ktype) + <- can-tpconvert DofP + (DconvP : tpconvert (base P) ktype EA) + %% + <- aconvert-fun DconvR DconvR' tp-eq/i + (Deq : etm-eq EM EM') + <- aconvert-reg DconvR DconvP + (Dof : eof EM EA) + <- eqtm-resp (eqtm/refl Dof) etm-eq/i Deq etp-eq/i + (Deqtm : eqtm EM EM' EA). + +-arr : expand-convert + (expand/arr + ([x] DexpApp x : expand (app R (X x)) T (M x)) + ([x] DexpX x : expand x S (X x)) + : expand R (arrow S T) (lam [x] M x)) + (simp/pi + ([x] DsimpB x : simp (B x) T) + (DsimpA : simp A S)) + (DconvR : aconvert R (pi A B) EO) + (convert/lam + ([x] [d:vof x A] + [ex] [dt:vtrans ex x] + DconvM x d ex dt : convert (M x) (B x) (EM ex)) + (DconvA : tpconvert A ktype EA)) +%% + (tpconvert/pi DconvB DconvA) + (eqtm/ext + ([ex] [ed:evof ex EA] + eqtm/trans + (eqtm/trans + (eqtm/sym + (eqtm/beta + (eof/var DofEA ed) + DofEM)) + (DeqApp ex ed)) + (eqtm/app + (DeqEX' ex ed) + (eqtm/refl DofEO))) + (eof/lam DofEA DofEM) + DofEO) +%% + <- tpconvert-reg DconvA kconvert/type + (DofEA : ekof EA ektype) + %% + <- aconvert-reg-il DconvR (DofR : at-of R (pi A B)) + <- atof-reg DofR + (kof/pi + ([x] [d] DofB x d : kof (B x) ktype) + (DofA : kof A ktype)) + <- ({x} {d:vof x A} + expand-reg (at-of/var DofA d) DsimpA (DexpX x) + (DofX x d : of (X x) A)) + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv + -> convert-vof d xt DconvA ed + -> can-convert (DofX x d) + (DconvN x d ex xt : convert (X x) A (EN ex))) + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv + -> convert-vof d xt DconvA ed + -> expand-convert (DexpX x) DsimpA (aconvert/var xt DconvA DofA d) + (DconvN x d ex xt) + %% + (DconvA' x d ex xt : tpconvert A ktype (EA' ex)) + (DeqEX ex ed : eqtm ex (EN ex) (EA' ex))) + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} + tpconvert-fun (DconvA' x d ex xt) DconvA + (DeqEA ex : etp-eq (EA' ex) EA)) + <- ({ex} {ed} + eqtm-resp (DeqEX ex ed) etm-eq/i etm-eq/i (DeqEA ex) + (DeqEX' ex ed : eqtm ex (EN ex) EA)) + %% + <- ({x} {d} + can-tpsub DofB (DofX x d) + (DsubB' x : tpsub B (X x) (B' x))) + <- ({x} + tpsub-expand _ (DexpX x) (DsubB' x) + (DeqB x : tp-eq (B' x) (B x))) + <- ({x} + tpsub-compat ([_] tp-eq/i) tm-eq/i (DeqB x) (DsubB' x) + (DsubB x : tpsub B (X x) (B x))) + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv + -> convert-vof d xt DconvA ed + -> expand-convert + (DexpApp x) (DsimpB x) + (aconvert/app + (DsubB x) (DconvN x d ex xt) DconvR + : aconvert (app R (X x)) (B x) (eapp EO (EN ex))) + (DconvM x d ex xt) + %% + (DconvB x d ex xt : tpconvert (B x) ktype (EB ex)) + (DeqApp ex ed : eqtm (eapp EO (EN ex)) (EM ex) (EB ex))) + %% + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv + -> convert-vof d xt DconvA ed + -> convert-reg (DconvM x d ex xt) (DconvB x d ex xt) + (DofEM ex ed : eof (EM ex) (EB ex))) + %% + <- aconvert-reg DconvR (tpconvert/pi DconvB DconvA) + (DofEO : eof EO (epi EA EB)). + +%worlds (scsig | sasig | sbind) (expand-convert _ _ _ _ _ _). +%total D (expand-convert D _ _ _ _ _). + +expand-tpconvert : tpexpand R T N + -> ksimp A T + -> atpconvert R A EM + -> tpconvert N A EN +%% + -> kconvert A EA + -> eqtp EM EN EA -> type. +%mode expand-tpconvert +X1 +X2 +X3 +X4 -X5 -X6. + +-t : expand-tpconvert tpexpand/type ksimp/type + (Dconv : atpconvert P ktype EA) + (tpconvert/base + (Dconv' : atpconvert P ktype EA')) +%% + kconvert/type + Dequiv +%% + <- atpconvert-fun Dconv Dconv' _ + (Deq : etp-eq EA EA') + <- atpconvert-reg Dconv kconvert/type + (Dof : ekof EA ektype) + <- eqtp-resp (eqtp/refl Dof) etp-eq/i Deq ekind-eq/i + (Dequiv : eqtp EA EA' ektype). + +-pi : expand-tpconvert + (tpexpand/arr + ([x] DexpApp x : tpexpand (aapp R (X x)) T (M x)) + ([x] DexpX x : expand x S (X x)) + : tpexpand R (karrow S T) (alam [x] M x)) + (ksimp/pi + ([x] DsimpB x : ksimp (B x) T) + (DsimpA : simp A S)) + (DconvR : atpconvert R (kpi A B) EO) + (tpconvert/lam + ([x] [d:vof x A] + [ex] [dt:vtrans ex x] + DconvM x d ex dt : tpconvert (M x) (B x) (EM ex)) + (DconvA : tpconvert A ktype EA)) +%% + (kconvert/pi DconvB DconvA) + (eqtp/ext + ([ex] [ed:evof ex EA] + eqtp/trans + (eqtp/trans + (eqtp/sym + (eqtp/beta + (eof/var DofEA ed) + DofEM)) + (DeqApp ex ed)) + (eqtp/app + (DeqEX' ex ed) + (eqtp/refl DofEO))) + (ekof/lam DofEA DofEM) + DofEO) +%% + <- tpconvert-reg DconvA kconvert/type + (DofEA : ekof EA ektype) + %% + <- atpconvert-reg-il DconvR (DofR : at-kof R (kpi A B)) + <- atkof-reg DofR + (wfkind/pi + ([x] [d] DofB x d : wfkind (B x)) + (DofA : kof A ktype)) + <- ({x} {d:vof x A} + expand-reg (at-of/var DofA d) DsimpA (DexpX x) + (DofX x d : of (X x) A)) + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv + -> convert-vof d xt DconvA ed + -> can-convert (DofX x d) + (DconvN x d ex xt : convert (X x) A (EN ex))) + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv + -> convert-vof d xt DconvA ed + -> expand-convert (DexpX x) DsimpA (aconvert/var xt DconvA DofA d) + (DconvN x d ex xt) + %% + (DconvA' x d ex xt : tpconvert A ktype (EA' ex)) + (DeqEX ex ed : eqtm ex (EN ex) (EA' ex))) + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} + tpconvert-fun (DconvA' x d ex xt) DconvA + (DeqEA ex : etp-eq (EA' ex) EA)) + <- ({ex} {ed} + eqtm-resp (DeqEX ex ed) etm-eq/i etm-eq/i (DeqEA ex) + (DeqEX' ex ed : eqtm ex (EN ex) EA)) + %% + <- ({x} {d} + can-ksub DofB (DofX x d) + (DsubB' x : ksub B (X x) (B' x))) + <- ({x} + ksub-expand _ (DexpX x) (DsubB' x) + (DeqB x : kind-eq (B' x) (B x))) + <- ({x} + ksub-compat ([_] kind-eq/i) tm-eq/i (DeqB x) (DsubB' x) + (DsubB x : ksub B (X x) (B x))) + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv + -> convert-vof d xt DconvA ed + -> expand-tpconvert + (DexpApp x) (DsimpB x) + (atpconvert/app + (DsubB x) (DconvN x d ex xt) DconvR + : atpconvert (aapp R (X x)) (B x) (eaapp EO (EN ex))) + (DconvM x d ex xt) + %% + (DconvB x d ex xt : kconvert (B x) (EB ex)) + (DeqApp ex ed : eqtp (eaapp EO (EN ex)) (EM ex) (EB ex))) + %% + <- ({x} {d:vof x A} + {ex} {xt:vtrans ex x} {ed:evof ex EA} {dv:variable ex} + vtrans-variable xt dv + -> convert-vof d xt DconvA ed + -> tpconvert-reg (DconvM x d ex xt) (DconvB x d ex xt) + (DofEM ex ed : ekof (EM ex) (EB ex))) + %% + <- atpconvert-reg DconvR (kconvert/pi DconvB DconvA) + (DofEO : ekof EO (ekpi EA EB)). + +%worlds (scsig | sasig | sbind) (expand-tpconvert _ _ _ _ _ _). +%total D (expand-tpconvert D _ _ _ _ _). + +%%%% + +sound-trans : trans EM M A + -> convert M A EM' + -> tpconvert A ktype EA + -> eqtm EM EM' EA -> type. +%mode sound-trans +X1 -X2 -X3 -X4. + +sound-tptrans : tptrans EA A K + -> tpconvert A K EA' + -> kconvert K EK + -> eqtp EA EA' EK -> type. +%mode sound-tptrans +X1 -X2 -X3 -X4. + +-const : sound-trans + (trans/const + (Dexpand : expand (const C) T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (Dcof : cof C A)) + DconvertM + DconvertA + Deqtm + <- trans-reg (trans/const Dexpand Dsimp Dkof Dcof) + (DofM : of M A) + <- can-convert DofM + (DconvertM : convert M A EM) + <- can-tpconvert Dkof + (DconvertA : tpconvert A ktype EA) + <- expand-convert Dexpand Dsimp + (aconvert/const DconvertA Dkof Dcof) DconvertM + (DconvertA' : tpconvert A ktype EA') + (Deqtm' : eqtm (econst C) EM EA') + <- tpconvert-fun DconvertA' DconvertA + (DeqEA' : etp-eq EA' EA) + <- eqtm-resp Deqtm' etm-eq/i etm-eq/i DeqEA' + (Deqtm : eqtm (econst C) EM EA). + +-var : sound-trans + (trans/var + (Dexpand : expand X T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (Dvof : vof X A) + (Dvtrans : vtrans EX X)) +%% + DconvertM + DconvertA + Deqtm +%% + <- trans-reg (trans/var Dexpand Dsimp Dkof Dvof Dvtrans) + (DofM : of M A) + <- can-convert DofM + (DconvertM : convert M A EM) + <- can-tpconvert Dkof + (DconvertA : tpconvert A ktype EA) + <- expand-convert Dexpand Dsimp + (aconvert/var Dvtrans DconvertA Dkof Dvof) DconvertM + (DconvertA' : tpconvert A ktype EA') + (Deqtm' : eqtm EX EM EA') + <- tpconvert-fun DconvertA' DconvertA + (DeqEA' : etp-eq EA' EA) + <- eqtm-resp Deqtm' etm-eq/i etm-eq/i DeqEA' + (Deqtm : eqtm EX EM EA). + + +-app : sound-trans + (trans/app + (DsubA : tpsub ([x] A x) N Ax) + (DsubL : sub ([x] L x) N Lx) + (DtransN : trans EN N B) + (DtransM : trans EM (lam [x] L x) (pi B [x] A x))) +%% + + DconvertLx + DconvertAx + (eqtm/typecon + (eqtp/trans DeqtpEAEN'_EAx DeqtpEAEN_EAEN') + (eqtm/trans + (eqtm/trans + (eqtm/trans + (eqtm/typecon + (eqtp/sym DeqtpEAEN_EAEN') + DeqtmELEN'_ELx) + DeqtmELEN_ELEN') + (eqtm/beta DofEN DofEL)) + (eqtm/app + (eqtm/refl DofEN) + DeqtmEM))) +%% + <- sound-trans DtransN + (DconvertN : convert N B EN') + (DconvertB : tpconvert B ktype EB) + (DeqtmENEN' : eqtm EN EN' EB) + <- sound-trans DtransM + (convert/lam + ([x] [d:vof x B] [ex] [xt] + DconvertL x d ex xt + : convert (L x) (A x) (EL ex)) + (DconvertB' : tpconvert B ktype EB')) + (tpconvert/pi + ([x] [d] [ex] [xt] + DconvertA x d ex xt + : tpconvert (A x) ktype (EA ex)) + (DconvertB'' : tpconvert B ktype EB'')) + (DeqtmEM' + : eqtm EM (elam EB' ([ex] EL ex)) (epi EB'' ([ex] EA ex))) + <- tpconvert-fun DconvertB'' DconvertB + (DeqEBEB'' : etp-eq EB'' EB) + <- tpconvert-fun DconvertB' DconvertB + (DeqEBEB' : etp-eq EB' EB) + <- elam-compat DeqEBEB' ([_] etm-eq/i) + (DeqLam : etm-eq (elam EB' EL) (elam EB EL)) + <- epi-compat DeqEBEB'' ([_] etp-eq/i) + (DeqPi : etp-eq (epi EB'' EA) (epi EB EA)) + <- eqtm-resp DeqtmEM' etm-eq/i DeqLam DeqPi + (DeqtmEM : eqtm EM (elam EB EL) (epi EB EA)) + %% + <- ({x} {d} {ex} {xt} {ed:evof ex EB} + {dv} vtrans-variable xt dv -> + convert-vof d xt DconvertB ed -> + convert-reg + (DconvertL x d ex xt) (DconvertA x d ex xt) + (DofEL ex ed : eof (EL ex) (EA ex))) + <- convert-reg DconvertN DconvertB + (DofEN' : eof EN' EB) + <- esubst ([ex] [ed] DofEL ex ed) DofEN' + (DofELEN' : eof (EL EN') (EA EN')) + <- convert-sub DconvertL DconvertN DsubL DsubA + (DconvertLx : convert Lx Ax ELx) + (DreduceLx : reduce* (EL EN') ELx) + <- reduce*-equiv DofELEN' DreduceLx + (DeqtmELEN'_ELx : eqtm (EL EN') ELx (EA EN')) + <- eqtm-reg DeqtmENEN' + (DofEN : eof EN EB) + (DofEN'_ : eof EN' EB) + _ + <- eqtm-sub DofEL DeqtmENEN' DofEN DofEN' + (DeqtmELEN_ELEN' : eqtm (EL EN) (EL EN') (EA EN)) + %% + <- ({x} {d} {ex} {xt} {ed:evof ex EB} + {dv} vtrans-variable xt dv -> + convert-vof d xt DconvertB ed -> + tpconvert-reg + (DconvertA x d ex xt) kconvert/type + (DofEA ex ed : ekof (EA ex) ektype)) + <- esubst-kof ([ex] [ed] DofEA ex ed) DofEN' + (DofEAEN' : ekof (EA EN') ektype) + <- convert-tpsub DconvertA DconvertN DsubA ksub/type + (DconvertAx : tpconvert Ax ktype EAx) + (DreduceAx : tpreduce* (EA EN') EAx) + <- tpreduce*-equiv DofEAEN' DreduceAx + (DeqtpEAEN'_EAx : eqtp (EA EN') EAx ektype) + <- eqtm-tpsub DofEA DeqtmENEN' DofEN DofEN' + (DeqtpEAEN_EAEN' : eqtp (EA EN) (EA EN') ektype). + +-lam : sound-trans + (trans/lam + ([x] [d:vof x A] [ex] [xt] + DtransM x d ex xt : trans (EM ex) (M x) (B x)) + (DtransA : tptrans EA A ktype)) +%% + (convert/lam DconvertM DconvertA) + (tpconvert/pi DconvertB DconvertA) + (eqtm/typecon + (eqtp/pi + ([ex] [ed] eqtp/refl (DofEB ex ed)) + DeqtpEA) + (eqtm/lam + ([ex] [ed] Deqtm ex ed) + DeqtpEA)) +%% + <- sound-tptrans DtransA + (DconvertA : tpconvert A ktype EA') + kconvert/type + (DeqtpEA : eqtp EA EA' ektype) + <- ({x} {d} {ex} {xt} {ed:evof ex EA'} + {dv} vtrans-variable xt dv -> + convert-vof d xt DconvertA ed + -> sound-trans (DtransM x d ex xt) + (DconvertM x d ex xt : convert (M x) (B x) (EM' ex)) + (DconvertB x d ex xt : tpconvert (B x) ktype (EB ex)) + (Deqtm' ex ed : eqtm (EM ex) (EM' ex) (EB ex))) + <- eqtp-reg DeqtpEA DofEA _ _ + <- ({ex} {ed:evof ex EA} + esubst-eqtm ([ex] [ed] Deqtm' ex ed) + (eof/eqtp DeqtpEA (eof/var DofEA ed)) + (Deqtm ex ed : eqtm (EM ex) (EM' ex) (EB ex))) + %% + <- ({x} {d} {ex} {xt} {ed:evof ex EA'} + {dv} vtrans-variable xt dv -> + convert-vof d xt DconvertA ed -> + tpconvert-reg (DconvertB x d ex xt) kconvert/type + (DofEB' ex ed : ekof (EB ex) ektype)) + <- ({ex} {ed:evof ex EA} + esubst-kof ([ex] [ed] DofEB' ex ed) + (eof/eqtp DeqtpEA (eof/var DofEA ed)) + (DofEB ex ed : ekof (EB ex) ektype)). + +%%%% + +-const : sound-tptrans + (tptrans/const Dexpand Dsimp Dkof Dcof) + DconvertM + DconvertA + Deqtm + <- tptrans-reg (tptrans/const Dexpand Dsimp Dkof Dcof) + DofM + <- can-tpconvert DofM DconvertM + <- can-kconvert Dkof DconvertA + <- expand-tpconvert Dexpand Dsimp + (atpconvert/const DconvertA Dkof Dcof) DconvertM + DconvertA' + Deqtm' + <- kconvert-fun DconvertA' DconvertA DeqEA' + <- eqtp-resp Deqtm' etp-eq/i etp-eq/i DeqEA' + Deqtm. + +-app : sound-tptrans + (tptrans/app + (DsubA : ksub ([x] A x) N Ax) + (DsubL : tpsub ([x] L x) N Lx) + (DtransN : trans EN N B) + (DtransM : tptrans EM (alam [x] L x) (kpi B [x] A x))) +%% + DconvertLx + DconvertAx + (eqtp/kcon + (eqkind/trans DeqtpEAEN'_EAx DeqtpEAEN_EAEN') + (eqtp/trans + (eqtp/trans + (eqtp/trans + (eqtp/kcon + (eqkind/sym DeqtpEAEN_EAEN') + DeqtmELEN'_ELx) + DeqtmELEN_ELEN') + (eqtp/beta DofEN DofEL)) + (eqtp/app + (eqtm/refl DofEN) + DeqtmEM))) +%% + <- sound-trans DtransN + (DconvertN : convert N B EN') + (DconvertB : tpconvert B ktype EB) + (DeqtmENEN' : eqtm EN EN' EB) + <- sound-tptrans DtransM + (tpconvert/lam DconvertL DconvertB') + (kconvert/pi DconvertA DconvertB'') + DeqtmEM' + <- tpconvert-fun DconvertB'' DconvertB + (DeqEBEB'' : etp-eq EB'' EB) + <- tpconvert-fun DconvertB' DconvertB + (DeqEBEB' : etp-eq EB' EB) + <- ealam-compat DeqEBEB' ([_] etp-eq/i) + (DeqLam : etp-eq (ealam EB' EL) (ealam EB EL)) + <- ekpi-compat DeqEBEB'' ([_] ekind-eq/i) + (DeqPi : ekind-eq (ekpi EB'' EA) (ekpi EB EA)) + <- eqtp-resp DeqtmEM' etp-eq/i DeqLam DeqPi + (DeqtmEM : eqtp EM (ealam EB EL) (ekpi EB EA)) + %% + <- ({x} {d} {ex} {xt} {ed:evof ex EB} + {dv} vtrans-variable xt dv + -> convert-vof d xt DconvertB ed + -> tpconvert-reg + (DconvertL x d ex xt) (DconvertA x d ex xt) + (DofEL ex ed : ekof (EL ex) (EA ex))) + <- convert-reg DconvertN DconvertB + (DofEN' : eof EN' EB) + <- esubst-kof ([ex] [ed] DofEL ex ed) DofEN' + (DofELEN' : ekof (EL EN') (EA EN')) + <- convert-tpsub DconvertL DconvertN DsubL DsubA + (DconvertLx : tpconvert Lx Ax ELx) + (DreduceLx : tpreduce* (EL EN') ELx) + <- tpreduce*-equiv DofELEN' DreduceLx + (DeqtmELEN'_ELx : eqtp (EL EN') ELx (EA EN')) + <- eqtm-reg DeqtmENEN' + (DofEN : eof EN EB) + (DofEN'_ : eof EN' EB) + _ + <- eqtm-tpsub DofEL DeqtmENEN' DofEN DofEN' + (DeqtmELEN_ELEN' : eqtp (EL EN) (EL EN') (EA EN)) + %% + <- ({x} {d} {ex} {xt} {ed:evof ex EB} + {dv} vtrans-variable xt dv + -> convert-vof d xt DconvertB ed + -> kconvert-reg + (DconvertA x d ex xt) + (DofEA ex ed : ewfkind (EA ex))) + <- esubst-wfkind ([ex] [ed] DofEA ex ed) DofEN' + (DofEAEN' : ewfkind (EA EN')) + <- convert-ksub DconvertA DconvertN DsubA + (DconvertAx : kconvert Ax EAx) + (DreduceAx : kreduce* (EA EN') EAx) + <- kreduce*-equiv DofEAEN' DreduceAx + (DeqtpEAEN'_EAx : eqkind (EA EN') EAx) + <- eqtm-ksub DofEA DeqtmENEN' DofEN DofEN' + (DeqtpEAEN_EAEN' : eqkind (EA EN) (EA EN')). + +-pi : sound-tptrans + (tptrans/pi + ([x] [d:vof x A] [ex] [xt] + DtransM x d ex xt : tptrans (EM ex) (M x) ktype) + (DtransA : tptrans EA A ktype)) +%% + (tpconvert/pi DconvertM DconvertA) + kconvert/type + (eqtp/pi Deqtm DeqtpEA) +%% + <- sound-tptrans DtransA + (DconvertA : tpconvert A ktype EA') + kconvert/type + (DeqtpEA : eqtp EA EA' ektype) + <- ({x} {d} {ex} {xt} {ed:evof ex EA'} + {dv} vtrans-variable xt dv + -> convert-vof d xt DconvertA ed + -> sound-tptrans (DtransM x d ex xt) + (DconvertM x d ex xt : tpconvert (M x) ktype (EM' ex)) + kconvert/type + (Deqtm' ex ed : eqtp (EM ex) (EM' ex) ektype)) + <- eqtp-reg DeqtpEA DofEA _ _ + <- ({ex} {ed:evof ex EA} + esubst-eqtp ([ex] [ed] Deqtm' ex ed) + (eof/eqtp DeqtpEA (eof/var DofEA ed)) + (Deqtm ex ed : eqtp (EM ex) (EM' ex) ektype)). + +-lam : sound-tptrans + (tptrans/lam + ([x] [d:vof x A] [ex] [xt] + DtransM x d ex xt : tptrans (EM ex) (M x) (B x)) + (DtransA : tptrans EA A ktype)) +%% + (tpconvert/lam DconvertM DconvertA) + (kconvert/pi DconvertB DconvertA) + (eqtp/kcon + (eqkind/pi + ([ex] [ed] eqkind/refl (DofEB ex ed)) + DeqtpEA) + (eqtp/lam + ([ex] [ed] Deqtm ex ed) + DeqtpEA)) +%% + <- sound-tptrans DtransA + (DconvertA : tpconvert A ktype EA') + kconvert/type + (DeqtpEA : eqtp EA EA' ektype) + <- ({x} {d} {ex} {xt} {ed:evof ex EA'} + {dv} vtrans-variable xt dv + -> convert-vof d xt DconvertA ed + -> sound-tptrans (DtransM x d ex xt) + (DconvertM x d ex xt : tpconvert (M x) (B x) (EM' ex)) + (DconvertB x d ex xt : kconvert (B x) (EB ex)) + (Deqtm' ex ed : eqtp (EM ex) (EM' ex) (EB ex))) + <- eqtp-reg DeqtpEA DofEA _ _ + <- ({ex} {ed:evof ex EA} + esubst-eqtp ([ex] [ed] Deqtm' ex ed) + (eof/eqtp DeqtpEA (eof/var DofEA ed)) + (Deqtm ex ed : eqtp (EM ex) (EM' ex) (EB ex))) + %% + <- ({x} {d} {ex} {xt} {ed:evof ex EA'} + {dv} vtrans-variable xt dv + -> convert-vof d xt DconvertA ed + -> kconvert-reg (DconvertB x d ex xt) + (DofEB' ex ed : ewfkind (EB ex))) + <- ({ex} {ed:evof ex EA} + esubst-wfkind ([ex] [ed] DofEB' ex ed) + (eof/eqtp DeqtpEA (eof/var DofEA ed)) + (DofEB ex ed : ewfkind (EB ex))). + +%worlds (scsig | sasig | sbind) (sound-trans _ _ _ _) (sound-tptrans _ _ _ _). +%total (D1 D2) (sound-trans D1 _ _ _) (sound-tptrans D2 _ _ _). + + +soundness : trans EM M A + -> trans EM' M A + -> tptrans EA A ktype +%% + -> eqtm EM EM' EA -> type. +%mode soundness +X1 +X2 +X3 -X4. + +- : soundness + (DtransM : trans EM M A) + (DtransN : trans EN M A) + (DtransA : tptrans EA A ktype) +%% + (eqtm/trans + (eqtm/sym + (eqtm/typecon + (eqtp/sym DeqtpEAEA'') + DeqtmENEM')) + (eqtm/typecon + (eqtp/sym DeqtpEAEA') + DeqtmEM)) +%% + <- sound-trans DtransM + (DconvertM : convert M A EM') + (DconvertA' : tpconvert A ktype EA') + (DeqtmEM : eqtm EM EM' EA') + <- sound-trans DtransN + (DconvertN : convert M A EN') + (DconvertA'' : tpconvert A ktype EA'') + (DeqtmEN : eqtm EN EN' EA'') + <- sound-tptrans DtransA + (DconvertA''' : tpconvert A ktype EA''') + kconvert/type + (DeqtpEA''' : eqtp EA EA''' ektype) + %% + <- tpconvert-fun DconvertA''' DconvertA' + (DeqEA'''EA' : etp-eq EA''' EA') + <- eqtp-resp DeqtpEA''' etp-eq/i DeqEA'''EA' ekind-eq/i + (DeqtpEAEA' : eqtp EA EA' ektype) + %% + <- convert-fun DconvertN DconvertM + (DeqEN'EM' : etm-eq EN' EM') + <- tpconvert-fun DconvertA''' DconvertA'' + (DeqEA'''EA'' : etp-eq EA''' EA'') + <- eqtp-resp DeqtpEA''' etp-eq/i DeqEA'''EA'' ekind-eq/i + (DeqtpEAEA'' : eqtp EA EA'' ektype) + <- eqtm-resp DeqtmEN etm-eq/i DeqEN'EM' etp-eq/i + (DeqtmENEM' : eqtm EN EM' EA''). + +%worlds (sbind | scsig | sasig) (soundness _ _ _ _). +%total {} (soundness _ _ _ _). + diff --git a/src/sources.cfg b/src/sources.cfg new file mode 100644 index 0000000..3dd01c9 --- /dev/null +++ b/src/sources.cfg @@ -0,0 +1,51 @@ +nat.elf +constant.elf +canonical.elf +canonical-explicit.elf +canonical-simple.elf +expand.elf +noncan.elf +noncan-explicit.elf +translate.elf +convert.elf +reduce.elf + +%% Canonical LF Metatheory: Substitution and Expansion %% +equality.thm +false.thm +subst-fun.thm +nat.thm +strengthen.thm +explicit-lemmas.thm +simp-lemmas.thm +subst-effect.thm +simple-regularity.thm +invert.thm +substitution.thm +regularity.thm +expand.thm + +%% Completeness %% +esubstitution.thm +trans-reg.thm +estrengthen.thm +trans-explicit.thm +trans-sub.thm +trans-fun.thm +complete.thm + +%% Soundness %% +explicit-lemmas-noncan.thm +efunctionality.thm +eregularity.thm +pi-inj.thm + +convert-fun.thm +convert-effect.thm +convert-normal.thm +convert-explicit.thm +convert-reg-il.thm +convert-sub.thm +reduce-equiv.thm +convert-reg.thm +sound.thm diff --git a/src/strengthen.thm b/src/strengthen.thm new file mode 100644 index 0000000..867d0d5 --- /dev/null +++ b/src/strengthen.thm @@ -0,0 +1,425 @@ + +%%%%% substitution for absent variables %%%%% + +rrsub-absent : {R} {M} rrsub ([_] R) M R -> type. +%mode rrsub-absent +X1 +X2 -X3. + +- : rrsub-absent R M rrsub/closed. + +%worlds (csig | asig | var) (rrsub-absent _ _ _). +%total {} (rrsub-absent _ _ _). + + +sub-absent : {N} {M} sub ([_] N) M N -> type. +%mode sub-absent +X1 +X2 -X3. + +-at : sub-absent (at R) M (sub/rr rrsub/closed). + +-lam : sub-absent (lam N) M (sub/lam D) + <- ({y} sub-absent (N y) M (D y)). + +%worlds (csig | asig | var) (sub-absent _ _ _). +%total N (sub-absent N _ _). + + +atpsub-absent : {P} {M} atpsub ([_] P) M P -> type. +%mode atpsub-absent +X1 +X2 -X3. + +- : atpsub-absent P M atpsub/closed. + +%worlds (csig | asig | var) (atpsub-absent _ _ _). +%total {} (atpsub-absent _ _ _). + + +tpsub-absent : {A} {M} tpsub ([_] A) M A -> type. +%mode tpsub-absent +X1 +X2 -X3. + +-base : tpsub-absent (base P) M (tpsub/base atpsub/closed). + +-pi : tpsub-absent (pi A1 A2) M (tpsub/pi D2 D1) + <- tpsub-absent A1 M D1 + <- ({y} + tpsub-absent (A2 y) M (D2 y)). + +-lam : tpsub-absent (alam ([x] A x)) M (tpsub/lam D) + <- ({x} tpsub-absent (A x) M (D x)). + +%worlds (csig | asig | var) (tpsub-absent _ _ _). +%total A (tpsub-absent A _ _). + + +ksub-absent : {K} {M} ksub ([_] K) M K -> type. +%mode ksub-absent +X1 +X2 -X3. + +-ktype : ksub-absent ktype M ksub/type. + +-kpi : ksub-absent (kpi A [x] K x) M (ksub/pi ([y] D2 y) D1) + <- tpsub-absent A M D1 + <- ({y} + ksub-absent (K y) M (D2 y)). + +%worlds (csig | asig | var) (ksub-absent _ _ _). +%total K (ksub-absent K _ _). + + +%%%% substitution strengthening %%%% + +rrsub-closed : ({x:atm} rrsub R M (Q x)) -> ({x} atm-eq (Q x) Q') -> type. +%mode rrsub-closed +X1 -X2. + +rmsub-closed : ({x:atm} rmsub R M (N x)) -> ({x} tm-eq (N x) N') -> type. +%mode rmsub-closed +X1 -X2. + +sub-closed : ({x:atm} sub N M (O x)) -> ({x:atm} tm-eq (O x) O') -> type. +%mode sub-closed +X1 -X2. + +atpsub-closed : ({x:atm} atpsub P M (O x)) -> ({x:atm} atp-eq (O x) O') -> type. +%mode atpsub-closed +X1 -X2. + +tpsub-closed : ({x:atm} tpsub ([y] A y) M (B x)) + -> ({x:atm} tp-eq (B x) B') -> type. +%mode tpsub-closed +X1 -X2. + +ksub-closed : ({x:atm} ksub ([y] K y) M (K' x)) + -> ({x:atm} kind-eq (K' x) K'') -> type. +%mode ksub-closed +X1 -X2. + +-closed : rrsub-closed ([_] rrsub/closed) ([_] atm-eq/i). + +-app : rrsub-closed ([x] rrsub/app (D2 x) (D1 x)) Deq + <- rrsub-closed D1 Deq1 + <- sub-closed D2 Deq2 + <- ({x} app-compat (Deq1 x) (Deq2 x) (Deq x)). + +-var : rmsub-closed ([_] rmsub/var) ([_] tm-eq/i). + +-app : rmsub-closed ([x] rmsub/app (D3 x) (D2 x) (D1 x)) Deq + <- rmsub-closed D1 Deq1 + <- ({x} lam-inj (Deq1 x) (Deq1' x)) + <- sub-closed D2 Deq2 + <- sub-compat1 Deq1' Deq2 ([_] tm-eq/i) D3 D3' + <- sub-closed D3' Deq. + +-rr : sub-closed ([x] sub/rr (D1 x)) Deq' + <- rrsub-closed D1 Deq + <- ({x} at-compat (Deq x) (Deq' x)). + +-rm : sub-closed ([x] sub/rm (D1 x)) Deq + <- rmsub-closed D1 Deq. + +-lam : sub-closed ([x] sub/lam (D1 x)) Deq' + <- ({y} sub-closed ([x] D1 x y) ([x] Deq x y)) + <- ({x} lam-compat (Deq x) (Deq' x)). + +-closed : atpsub-closed ([_] atpsub/closed) ([_] atp-eq/i). + +-aapp : atpsub-closed ([x] atpsub/app (Dsub x) (Datpsub x)) Deq + <- sub-closed Dsub Dtmeq + <- atpsub-closed Datpsub Datpeq + <- ({x} aapp-compat (Datpeq x) (Dtmeq x) (Deq x)). + +-base : tpsub-closed ([x] tpsub/base (Datpsub x)) Deq' + <- atpsub-closed Datpsub Deq + <- ({x} base-compat (Deq x) (Deq' x)). + +-pi : tpsub-closed ([x] tpsub/pi (D2 x) (D1 x)) Deq + <- tpsub-closed D1 Deq1 + <- ({y} tpsub-closed ([x] D2 x y) ([x] Deq2 x y)) + <- ({x} pi-compat (Deq1 x) (Deq2 x) (Deq x)). + +-lam : tpsub-closed ([x] tpsub/lam (D x)) Deq' + <- ({y} tpsub-closed ([x] D x y) ([x] Deq x y)) + <- ({x} alam-compat (Deq x) (Deq' x)). + +-closed : ksub-closed ([_] ksub/type) ([_] kind-eq/i). + +-kpi : ksub-closed ([x] ksub/pi (D2 x) (D1 x)) Deq + <- tpsub-closed D1 Deq1 + <- ({y} ksub-closed ([x] D2 x y) ([x] Deq2 x y)) + <- ({x} kpi-compat (Deq1 x) (Deq2 x) (Deq x)). + + +%worlds (csig | asig | var) + (rrsub-closed _ _) + (rmsub-closed _ _) + (sub-closed _ _) + (atpsub-closed _ _) + (tpsub-closed _ _) + (ksub-closed _ _). +%total (D1 D2 D3 D4 D5 D6) + (rrsub-closed D1 _) + (rmsub-closed D2 _) + (sub-closed D3 _) + (atpsub-closed D4 _) + (tpsub-closed D5 _) + (ksub-closed D6 _). + + +rrsub-closed' : ({x:atm} rrsub R M (Q x)) -> rrsub R M Q' -> type. +%mode rrsub-closed' +X1 -X2. + +- : rrsub-closed' Dsub (Dsub' aca) + <- rrsub-closed Dsub Deq + <- ({x} rrsub-compat ([_] atm-eq/i) tm-eq/i (Deq x) (Dsub x) (Dsub' x)). + +%worlds (csig | asig | var) (rrsub-closed' _ _). +%total {} (rrsub-closed' _ _). + +sub-closed' : ({x:atm} sub N M (O x)) -> sub N M O' -> type. +%mode sub-closed' +X1 -X2. + +- : sub-closed' Dsub (Dsub' aca) + <- sub-closed Dsub Deq + <- ({x} sub-compat ([_] tm-eq/i) tm-eq/i (Deq x) (Dsub x) (Dsub' x)). + +%worlds (csig | asig | var) (sub-closed' _ _). +%total {} (sub-closed' _ _). + + +%{ %% Not needed; deducible by pattern matching. +cof-strengthen : ({x:atm} cof C (A x)) -> ({x} tp-eq (A x) A') -> type. +%mode cof-strengthen +X1 -X2. + +- : cof-strengthen + ([x] cof/i (Dopen x : topen Ac (A x)) (Dccof : ccof C Ac)) + Deq + <- ({x} + topen-fun (Dopen x) (Dopen aca) + (Deq x : tp-eq (A x) (A aca))). + +%worlds (csig | asig | var) (cof-strengthen _ _). +%total {} (cof-strengthen _ _). + + +ckof-strengthen : ({x:atm} ckof P (K x)) -> ({x} kind-eq (K x) K') -> type. +%mode ckof-strengthen +X1 -X2. + +- : ckof-strengthen + ([x] ckof/i (Dkopen x : kopen Kc (K x)) (Dcckof : cckof P Kc)) + Deq +%%% + <- ({x} + kopen-fun (Dkopen x) (Dkopen aca) + (Deq x : kind-eq (K x) (K aca))). + +%worlds (csig | asig | var) (ckof-strengthen _ _). +%total {} (ckof-strengthen _ _). +}% + +%%% noassm %%% + +atof-noassm : ({x:atm} at-of (R x) (A x)) +%% + -> ({x} atm-eq (R x) R') + -> ({x} tp-eq (A x) A') -> type. +%mode atof-noassm +X1 -X2 -X3. + +of-noassm : ({x:atm} of (M x) (A x)) + -> ({x} tm-eq (M x) M') -> type. +%mode of-noassm +X1 -X2. + +atkof-noassm : ({x:atm} at-kof (P x) (K x)) +%% + -> ({x} atp-eq (P x) P') + -> ({x} kind-eq (K x) K') -> type. +%mode atkof-noassm +X1 -X2 -X3. + +kof-noassm : ({x:atm} kof (A x) (K x)) + -> ({x} tp-eq (A x) A') + -> ({x} kind-eq (K x) K') -> type. +%mode kof-noassm +X1 -X2 -X3. + +-const : atof-noassm + ([x] at-of/const _ (Dcof x : cof C A)) +%% + ([_] atm-eq/i) + ([_] tp-eq/i). + +-var : atof-noassm + ([x] at-of/var (Dkof x : kof A ktype) (Dvof : vof X A)) +%% + ([_] atm-eq/i) + ([_] tp-eq/i). + +-app : atof-noassm + ([x] at-of/app + (Dsub x : tpsub ([y] A x y) (M x) (Ax x)) + (Dof x : of (M x) (A2 x)) + (Datof x : at-of (R x) (pi (A2 x) ([y] A x y)))) +%% + Deqa + Deqt +%% + <- atof-noassm Datof + ([x] DeqR x : atm-eq (R x) R') + ([x] DeqPi x + : tp-eq (pi (A2 x) ([y] A x y)) (pi A2' ([y] A' y))) + <- of-noassm Dof + ([x] DeqM x : tm-eq (M x) M') + <- ({x} + pi-inj (DeqPi x) + (DeqA2 x : tp-eq (A2 x) A2') + ([y] DeqA x y : tp-eq (A x y) (A' y))) + <- ({x} + app-compat (DeqR x) (DeqM x) + (Deqa x : atm-eq (app (R x) (M x)) (app R' M'))) + <- ({x} + tpsub-compat (DeqA x) (DeqM x) tp-eq/i (Dsub x) + (Dsub' x : tpsub ([y] A' y) M' (Ax x))) + <- tpsub-closed ([x] Dsub' x) + ([x] Deqt x : tp-eq (Ax x) Ax'). + +-at : of-noassm ([x] of/at (Datof x : at-of (R x) (base (P x)))) + Deq' + <- atof-noassm ([x] Datof x) + ([x] Deq x : atm-eq (R x) R') + _ + <- ({x} + at-compat (Deq x) + (Deq' x : tm-eq (at (R x)) (at R'))). + +-lam : of-noassm ([x] of/lam + (Dkof x : kof (A x) ktype) + (Dof x : {y} vof y (A x) -> of (M x y) (B x y))) +%% + ([x] Deq' x) +%% + <- kof-noassm Dkof + ([x] DeqA x : tp-eq (A x) A') + ([x] DeqK x : kind-eq ktype K') + <- of-bind-resp1 DeqA Dof + ([x] Dof' x : {y} vof y A' -> of (M x y) (B x y)) + <- ({y} {e} + of-noassm ([x] Dof' x y e) + ([x] DeqM x y : tm-eq (M x y) (M' y))) + <- ({x} + lam-compat (DeqM x) + (Deq' x : tm-eq (lam [y] M x y) (lam [y] M' y))). + +-aconst : atkof-noassm + ([x] at-kof/const _ (Dckof x : ckof A K)) +%% + ([_] atp-eq/i) + ([_] kind-eq/i). + +-aapp : atkof-noassm + ([x] at-kof/app + (Dksub x : ksub ([y] K x y) (M x) (Ky x)) + (Dof x : of (M x) (A x)) + (Datkof x : at-kof (P x) (kpi (A x) ([y] K x y)))) +%% + DeqAtp + DeqKind +%% + <- atkof-noassm Datkof + ([x] DeqP x : atp-eq (P x) P') + ([x] DeqKpi x + : kind-eq (kpi (A x) ([y] K x y)) (kpi A' ([y] K' y))) + <- of-noassm Dof + ([x] DeqM x : tm-eq (M x) M') + <- ({x} + kpi-inj (DeqKpi x) + (DeqA x : tp-eq (A x) A') + ([y] DeqK x y : kind-eq (K x y) (K' y))) + <- ({x} + aapp-compat (DeqP x) (DeqM x) + (DeqAtp x : atp-eq (aapp (P x) (M x)) (aapp P' M'))) + <- ({x} + ksub-compat (DeqK x) (DeqM x) kind-eq/i (Dksub x) + (Dksub' x : ksub ([y] K' y) M' (Ky x))) + <- ksub-closed ([x] Dksub' x) + ([x] DeqKind x : kind-eq (Ky x) Ky'). + +-base : kof-noassm + ([x] kof/base + (Datkof x : at-kof (P x) ktype)) +%% + DeqA + ([_] kind-eq/i) +%% + <- atkof-noassm Datkof + ([x] DeqP x : atp-eq (P x) P') + _ + <- ({x} + base-compat (DeqP x) + (DeqA x : tp-eq (base (P x)) (base P'))). + +-pi : kof-noassm + ([x] kof/pi + (Dkof2 x : {y} vof y (A1 x) -> kof (A2 x y) ktype) + (Dkof1 x : kof (A1 x) ktype)) +%% + Deq' + ([_] kind-eq/i) +%% + <- kof-noassm Dkof1 + ([x] Deq1 x : tp-eq (A1 x) A1') + _ + <- kof-bind-resp1 Deq1 Dkof2 + ([x] Dkof2' x : {y} vof y A1' -> kof (A2 x y) ktype) + <- ({y} {e} + kof-noassm ([x] Dkof2' x y e) + ([x] Deq2 x y : tp-eq (A2 x y) (A2' y)) + ([_] kind-eq/i)) + <- ({x} pi-compat (Deq1 x) (Deq2 x) + (Deq' x + : tp-eq (pi (A1 x) [y] A2 x y) (pi A1' [y] A2' y))). + +-lam : kof-noassm + ([x] kof/lam + ([y] [d] Dkof x y d : kof (B x y) (K x y)) + (DofA x : kof (A x) ktype)) +%% + Deq' + DeqPi +%% + <- kof-noassm DofA + ([x] DeqA x : tp-eq (A x) A') + _ + <- kof-bind-resp1 DeqA Dkof + ([x] [y] [d] Dkof' x y d : kof (B x y) (K x y)) + <- ({y} {d} + kof-noassm ([x] Dkof' x y d) + ([x] DeqB x y : tp-eq (B x y) (B' y)) + ([x] DeqK x y : kind-eq (K x y) (K' y))) + <- ({x} + alam-compat (DeqB x) + (Deq' x : tp-eq (alam ([y] B x y)) (alam ([y] B' y)))) + <- ({x} + kpi-compat (DeqA x) ([y] DeqK x y) + (DeqPi x : kind-eq + (kpi (A x) ([y] K x y)) + (kpi A' ([y] K' y)))). + +%worlds (csig | asig | bind | var) + (atof-noassm _ _ _) + (of-noassm _ _) + (atkof-noassm _ _ _) + (kof-noassm _ _ _). +%total (D1 D2 D3 D4) + (atof-noassm D1 _ _) + (of-noassm D2 _) + (atkof-noassm D3 _ _) + (kof-noassm D4 _ _). + +vof-noassm : ({x:atm} vof Y (B x)) -> ({x:atm} tp-eq (B x) B') -> type. +%mode vof-noassm +X1 -X2. + +- : vof-noassm _ ([x] tp-eq/i). + +%worlds (csig | asig | var | bind) (vof-noassm _ _). +%total {} (vof-noassm _ _). + +vof-noassm-var : ({x} vof x A) -> false -> type. +%mode vof-noassm-var +X1 -X2. +%worlds (csig | asig | var | bind) (vof-noassm-var _ _). +%total {} (vof-noassm-var _ _). + +atof-noassm-var : ({x} at-of x (A x)) -> false -> type. +%mode atof-noassm-var +X1 -X2. + +- : atof-noassm-var ([x] at-of/var _ (Dvof x)) Dfalse + <- vof-noassm-var Dvof Dfalse. + +%worlds (csig | asig | var | bind) (atof-noassm-var _ _). +%total {} (atof-noassm-var _ _). diff --git a/src/subst-effect.thm b/src/subst-effect.thm new file mode 100644 index 0000000..c1efcfe --- /dev/null +++ b/src/subst-effect.thm @@ -0,0 +1,1744 @@ +%%%% head variables %%%% + +headvar : (atm -> atm) -> type. + +headvar/var : headvar ([x] x). +headvar/app : headvar ([x] app (R x) (M x)) + <- headvar ([x] R x). + +%% head variable lemmas %% + +headvar-resp : ({x:atm} atm-eq (R x) (R' x)) -> headvar ([x] R x) + -> headvar ([x] R' x) -> type. +%mode headvar-resp +X1 +X2 -X3. + +- : headvar-resp ([_] atm-eq/i) D D. + +%worlds (csig | asig | var) (headvar-resp _ _ _). +%total {} (headvar-resp _ _ _). + + +rmsub-headvar : rmsub ([x] R x) _ _ -> headvar ([x] R x) -> type. +%mode rmsub-headvar +X1 -X2. + +-var : rmsub-headvar rmsub/var headvar/var. +-app : rmsub-headvar (rmsub/app _ _ D) (headvar/app D') + <- rmsub-headvar D D'. + +%worlds (csig | asig | var) (rmsub-headvar _ _). +%total D (rmsub-headvar D _). + +headvar-closed : headvar ([x] R) -> false -> type. +%mode headvar-closed +X1 -X2. + +- : headvar-closed (headvar/app D) D' + <- headvar-closed D D'. + +%worlds (csig | asig | var) (headvar-closed _ _). +%total D (headvar-closed D _ ). + +headvar-tp-size : ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> ({x} at-ofe (G x) (R x) (B x)) + -> simp A S + -> headvar ([x] R x) + -> ({x} simp (B x) T) +%% + -> stp-leq T S -> type. +%mode headvar-tp-size +X0 +X1 +X2 +X3 +X4 +X5 -X6. + +-var : headvar-tp-size + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + ([x] at-ofe/var _ (DlookA' x : lookup (G x) x (A' x))) + (Dsimp : simp A T) + headvar/var + ([x] Dsimp' x : simp (A' x) S) + %% + Dleq + %% + <- ({x} + append-lookup (Dapp x) + (DlookA x : lookup (G x) x A)) + <- ({x} {d} + lookup-fun (Dord x d) (DlookA x) (DlookA' x) + (DeqAA' x : tp-eq A (A' x))) + <- ({x} tp-eq-sym (DeqAA' x) (DeqA'A x)) + <- ({x} simp-compat (DeqA'A x) stp-eq/i (Dsimp' x) (DsimpAS x : simp A S)) + <- simp-fun (DsimpAS aca) Dsimp + (Deq : stp-eq S T) + <- stp-eq-leq Deq Dleq. + +-closed : headvar-tp-size + ([x] [d] Dord x d : ordered (G x)) + _ + ([x] at-ofe/closed (DofR x : at-of (R x) (B x))) + _ + (Dheadvar : headvar ([x] R x)) + ([x] DsimpB x : simp (B x) T) +%% + Dleq +%% + <- atof-noassm DofR ([x] DeqR x : atm-eq (R x) R') _ + <- headvar-resp ([x] DeqR x) Dheadvar + (Dheadvar' : headvar ([x] R')) + <- headvar-closed Dheadvar' Dfalse + <- false-implies-stp-leq Dfalse Dleq. + +-app : headvar-tp-size + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + ([x] at-ofe/app + (DsubC x : tpsub ([y] C x y) (M x) (Cy x)) + _ + (DofR x : at-ofe (G x) (R x) (pi (B x) [y] C x y))) + (Dsimp : simp A S) + (headvar/app (Dheadvar : headvar R)) + ([x] DsimpCy x : simp (Cy x) T) +%% + Dleq'' +%% + <- ({x} can-simp (B x) (DsimpB x : simp (B x) T1)) + <- ({x} {y} can-simp (C x y) (DsimpC x y : simp (C x y) T2)) + <- headvar-tp-size Dord Dapp DofR Dsimp Dheadvar + ([x] simp/pi ([y] DsimpC x y) (DsimpB x)) + (Dleq : stp-leq (arrow T1 T2) S) + <- ({x} + tpsub-preserves-simp (DsubC x) ([y] DsimpC x y) + (DsimpCy' x : simp (Cy x) T2)) + <- ({x} + simp-fun (DsimpCy' x) (DsimpCy x) + (DeqT2T : stp-eq T2 T)) + <- stp-leq-trans (stp-leq/arr2 stp-leq/eq) Dleq (Dleq' : stp-leq T2 S) + <- stp-leq-compat DeqT2T stp-eq/i Dleq' + (Dleq'' : stp-leq T S). + +-bad : headvar-tp-size + ([x] [d] Dord x d : ordered (G x)) + _ + ([x] at-ofe/var _ (Dlookup x)) + _ + (headvar/app _) + Dsimp +%% + Dleq +%% + <- ({x} {d} + lookup-isvar (Dlookup x) (Dord x d) + (Disvar x : isvar (app _ _) J)) + <- ({x} isvar-app-contra (Disvar x) Dfalse) + <- false-implies-stp-leq Dfalse Dleq. + +%worlds (csig | asig | bind | ovar | var | evar) (headvar-tp-size _ _ _ _ _ _ _). +%total D (headvar-tp-size _ _ _ _ D _ _). + + +closed-headvar-contra : ({x} at-of (R x) (A x)) -> headvar R -> false -> type. +%mode closed-headvar-contra +X1 +X2 -X3. + +- : closed-headvar-contra Datof headvar/var Dfalse + <- atof-noassm-var Datof Dfalse. + +- : closed-headvar-contra ([x] at-of/app _ _ (Datof x)) (headvar/app Dheadvar) + Dfalse + <- closed-headvar-contra Datof Dheadvar Dfalse. + +%worlds (csig | asig | var | bind) (closed-headvar-contra _ _ _). +%total D (closed-headvar-contra D _ _). + + +headvar-contra : ({x2} headvar ([x1] R x1 x2)) -> ({x1} headvar ([x2] R x1 x2)) + -> false -> type. +%mode headvar-contra +X1 +X2 -X3. + +- : headvar-contra + ([x2] headvar/app (Dheadvar1 x2 : headvar ([x1] R x1 x2))) + ([x1] headvar/app (Dheadvar2 x1 : headvar ([x2] R x1 x2))) + Dfalse + <- headvar-contra Dheadvar1 Dheadvar2 Dfalse. + +%worlds (csig | asig | var | bind) (headvar-contra _ _ _). +%total D (headvar-contra D _ _). + +%% the following 2 lemmas are needed in expand.thm %% + +headvar-closed-contra : headvar ([x] R) -> false -> type. +%mode headvar-closed-contra +X1 -X2. + +- : headvar-closed-contra (headvar/app Dheadvar) Dfalse + <- headvar-closed-contra Dheadvar Dfalse. + +%worlds (csig | asig | var | bind) (headvar-closed-contra _ _). +%total D (headvar-closed-contra D _). + +headvar-rrsub-contra : headvar ([x] R x) -> rrsub ([x] R x) _ _ + -> false -> type. +%mode headvar-rrsub-contra +X1 +X2 -X3. + +- : headvar-rrsub-contra + (Dheadvar : headvar ([x] R)) + (rrsub/closed : rrsub ([x] R) M R) + Dfalse + <- headvar-closed-contra Dheadvar Dfalse. + +- : headvar-rrsub-contra (headvar/app Dheadvar) (rrsub/app DsubM DsubR) + Dfalse + <- headvar-rrsub-contra Dheadvar DsubR Dfalse. + +%worlds (csig | asig | var | bind) (headvar-rrsub-contra _ _ _). +%total D (headvar-rrsub-contra D _ _). + + +headvar-stp-size : ({x} {d : isvar x I} sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} at-ofes (G x) (R x) T) + -> headvar R +%% + -> stp-leq T S -> type. +%mode headvar-stp-size +X0 +X1 +X2 +X3 -X4. + +-closed : headvar-stp-size + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] at-ofes/closed + (Dsimp x : simp (A x) T) + (Datof x : at-of (R x) (A x))) + (Dheadvar : headvar ([x] R x)) +%% + Dstpleq +%%% + <- closed-headvar-contra Datof Dheadvar + (Dfalse : false) + <- false-implies-stp-leq Dfalse + (Dstpleq : stp-leq T S). + +-var : headvar-stp-size Dord Dlookup ([x] at-ofes/var (Dlookup' x)) + headvar/var +%% + D +%%% + <- ({x} {d} slookup-fun (Dord x d) (Dlookup x) (Dlookup' x) Deq) + <- stp-leq-compat Deq stp-eq/i stp-leq/eq D. + +-app : headvar-stp-size Dord Dlookup ([x] at-ofes/app _ (Datof x)) + (headvar/app Dheadvar) +%% + Dleq' +%%% + <- headvar-stp-size Dord Dlookup Datof Dheadvar Dleq + <- stp-leq-trans (stp-leq/arr2 stp-leq/eq) Dleq Dleq'. + +-appbad : headvar-stp-size Dord _ ([x] at-ofes/var (Dlookup x)) (headvar/app _) D + <- ({x} {d} slookup-isvar (Dlookup x) (Dord x d) (Disvar x d : isvar _ I)) + <- ({x} {d} isvar-app-contra (Disvar x d) Dfalse) + <- false-implies-stp-leq Dfalse D. + + +%worlds (csig | asig | bind | var | ovar | evar) (headvar-stp-size _ _ _ _ _). +%total D (headvar-stp-size _ _ D _ _). + + +strengthen-atofes : ({x} sappend (scons G1 x S) G2 (G x)) + -> sappend G1 G2 G' + -> ({x} at-ofes (G x) R T) +%% + -> at-ofes G' R T -> type. +%mode strengthen-atofes +X1 +X2 +X3 -X4. + +strengthen-ofes : ({x} sappend (scons G1 x S) G2 (G x)) + -> sappend G1 G2 G' + -> ({x} ofes (G x) M T) +%% + -> ofes G' M T -> type. +%mode strengthen-ofes +X1 +X2 +X3 -X4. + +strengthen-kofes : ({x} sappend (scons G1 x S) G2 (G x)) + -> sappend G1 G2 G' + -> ({x} kofes (G x) A H) +%% + -> kofes G' A H -> type. +%mode strengthen-kofes +X1 +X3 +X3 -X4. + +strengthen-atkofes : ({x} sappend (scons G1 x S) G2 (G x)) + -> sappend G1 G2 G' + -> ({x} at-kofes (G x) P H) +%% + -> at-kofes G' P H -> type. +%mode strengthen-atkofes +X1 +X2 +X3 -X4. + +strengthen-wfkindes : ({x} sappend (scons G1 x S) G2 (G x)) + -> sappend G1 G2 G' + -> ({x} wfkindes (G x) K) +%% + -> wfkindes G' K -> type. +%mode strengthen-wfkindes +X1 +X2 +X3 -X4. + + +-closed : strengthen-atofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + at-ofes/closed + (Dsimp x : simp (A x) T) + (Datof x : at-of R (A x))) +%% + (at-ofes/closed (Dsimp' aca) (Datof' aca)) +%% + <- atof-noassm Datof _ + (Deq : {x} tp-eq (A x) A') + <- ({x} + atof-resp atm-eq/i (Deq x) (Datof x) + (Datof' x : at-of R A')) + <- ({x} + simp-compat (Deq x) stp-eq/i (Dsimp x) + (Dsimp' x : simp A' T)). + +-const : strengthen-atofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + at-ofes/const + (Dsimp x : simp A T) + (Dkofes x : kofes (G x) A sktype) + (Dcof : cof C A)) +%% + (at-ofes/const (Dsimp aca) Dkofes' Dcof) +%% + <- strengthen-kofes Dappend Dappend' Dkofes + (Dkofes' : kofes G' A sktype). + +-var : strengthen-atofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + at-ofes/var + (Dlook x : slookup (G x) Y T)) +%% + (at-ofes/var Dlook') +%% + <- slookup-drop Dappend Dappend' Dlook Dlook'. + +-app : strengthen-atofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + at-ofes/app + (DofM x : ofes (G x) M T) + (DofR x : at-ofes (G x) R (arrow T U))) +%% + (at-ofes/app DofM' DofR') +%% + <- strengthen-atofes Dappend Dappend' DofR DofR' + <- strengthen-ofes Dappend Dappend' DofM DofM'. + +-at : strengthen-ofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + ofes/at + (DofR x : at-ofes (G x) R o)) +%% + (ofes/at DofR') +%% + <- strengthen-atofes Dappend Dappend' DofR DofR'. + +-lam : strengthen-ofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + ofes/lam + (DofM x : {y} ofes (scons (G x) y T) (M y) U)) +%% + (ofes/lam DofM') +%% + <- ({y} + strengthen-ofes + ([x] sappend/cons (Dappend x)) + (sappend/cons Dappend') + ([x] DofM x y) + (DofM' y)). + +-base : strengthen-kofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + kofes/base (Datkofes x : at-kofes (G x) P sktype)) +%% + (kofes/base Datkofes') +%% + <- strengthen-atkofes Dappend Dappend' Datkofes + Datkofes'. + +-pi : strengthen-kofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + kofes/pi + ([y] Dkofes2 x y + : kofes (scons (G x) y T1) (A2 y) sktype) + (Dsimp x : simp A1 T1) + (Dkofes1 x : kofes (G x) A1 sktype)) +%% + (kofes/pi Dkofes2' (Dsimp aca) Dkofes1') +%% + <- strengthen-kofes Dappend Dappend' Dkofes1 + (Dkofes1' : kofes G' A1 sktype) + <- ({y} strengthen-kofes + ([x] sappend/cons (Dappend x)) + (sappend/cons Dappend') + ([x] Dkofes2 x y) + (Dkofes2' y : kofes (scons G' y T1) (A2 y) sktype)). + +-alam : strengthen-kofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + kofes/lam + ([y] DofB x y : kofes (scons (G x) y T) (B y) H)) +%% + (kofes/lam DofB') +%% + <- ({y} + strengthen-kofes + ([x] sappend/cons (Dappend x)) + (sappend/cons Dappend') + ([x] DofB x y) + (DofB' y)). + +-closed : strengthen-atkofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + at-kofes/closed + (Dksimp x : ksimp (K x) H) + (Datkof x : at-kof P (K x))) +%% + (at-kofes/closed (Dksimp' aca) (Datkof' aca)) +%% + <- atkof-noassm Datkof _ + ([x] Deq x : kind-eq (K x) K') + <- ({x} + atkof-resp atp-eq/i (Deq x) (Datkof x) + (Datkof' x : at-kof P K')) + <- ({x} + ksimp-compat (Deq x) skind-eq/i (Dksimp x) + (Dksimp' x : ksimp K' H)). + +-const : strengthen-atkofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + at-kofes/const + (Dksimp x : ksimp K H) + (Dwfkindes x : wfkindes (G x) K) + (Dckof : ckof A K)) +%% + (at-kofes/const (Dksimp aca) Dwfkindes'' Dckof) +%% + <- strengthen-wfkindes Dappend Dappend' Dwfkindes + (Dwfkindes'' : wfkindes G' K). + +-app : strengthen-atkofes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + at-kofes/app + (Dofes x : ofes (G x) M T) + (Datkofes x : at-kofes (G x) P (karrow T H))) +%% + (at-kofes/app Dofes' Datkofes') + <- strengthen-atkofes Dappend Dappend' Datkofes Datkofes' + <- strengthen-ofes Dappend Dappend' Dofes Dofes'. + +-ktype : strengthen-wfkindes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([_] wfkindes/type) + wfkindes/type. + +-kpi : strengthen-wfkindes + ([x] Dappend x : sappend (scons G1 x S) G2 (G x)) + (Dappend' : sappend G1 G2 G') + ([x] + wfkindes/pi + ([y] Dwfkindes x y : wfkindes (scons (G x) y T) (K y)) + (Dsimp x : simp A T) + (Dkofes x : kofes (G x) A sktype)) +%% + (wfkindes/pi Dwfkindes' (Dsimp aca) Dkofes') +%% + <- strengthen-kofes Dappend Dappend' Dkofes + (Dkofes' : kofes G' A sktype) + <- ({y} strengthen-wfkindes + ([x] sappend/cons (Dappend x)) + (sappend/cons Dappend') + ([x] Dwfkindes x y) + (Dwfkindes' y : wfkindes (scons G' y T) (K y))). + + +%worlds (csig | asig | var | bind | ovar | evar) + (strengthen-atofes _ _ _ _) + (strengthen-ofes _ _ _ _) + (strengthen-kofes _ _ _ _) + (strengthen-atkofes _ _ _ _) + (strengthen-wfkindes _ _ _ _). +%total (D1 D2 D3 D4 D5) + (strengthen-atofes _ _ D1 _) + (strengthen-ofes _ _ D2 _) + (strengthen-kofes _ _ D3 _) + (strengthen-atkofes _ _ D4 _) + (strengthen-wfkindes _ _ D5 _). + + + +%%% substitution preserves typing (explicit contexts, simple types) %%% + +rrsubst-es : ({x} {d : isvar x I} sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} ofes (G x) M S) + -> ({x} at-ofes (G x) (R x) T) + -> rrsub ([x] R x) M R' +%% + -> ({x} at-ofes (G x) R' T) -> type. +%mode rrsubst-es +X0 +X1 +X2 +X3 +X4 -X5. + +rmsubst-es : ({x} {d : isvar x I} sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} ofes (G x) M S) + -> ({x} at-ofes (G x) (R x) T) + -> rmsub ([x] R x) M N +%% + -> ({x} ofes (G x) N T) -> type. +%mode rmsubst-es +X0 +X1 +X2 +X3 +X4 -X5. + +subst-es : ({x} {d : isvar x I} sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} ofes (G x) M S) + -> ({x} ofes (G x) (N x) T) + -> sub ([x] N x) M N' +%% + -> ({x} ofes (G x) N' T) -> type. +%mode subst-es +X0 +X1 +X2 +X3 +X4 -X5. + + +-closed : rrsubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] DofR x : at-ofes (G x) R T) + rrsub/closed + DofR. + +-closed : rrsubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + at-ofes/closed + (Dsimp x : simp (A x) T) + (Datof x : at-of (R x) (A x))) + (Dsub : rrsub ([x] R x) M Rx) +%% + ([x] at-ofes/closed (Dsimp' aca) Datof'') +%% + <- atof-noassm Datof + ([x] DeqR x : atm-eq (R x) R') + ([x] DeqA x : tp-eq (A x) A') + <- rrsub-compat DeqR tm-eq/i atm-eq/i Dsub + (Dsub' : rrsub ([_] R') M Rx) + <- rrsub-absent-fun Dsub' + (DeqRx : atm-eq R' Rx) + <- ({x} + atof-resp (DeqR x) (DeqA x) (Datof x) + (Datof' x : at-of R' A')) + <- atof-resp DeqRx tp-eq/i (Datof' aca) + (Datof'' : at-of Rx A') + <- ({x} + simp-compat (DeqA x) stp-eq/i (Dsimp x) + (Dsimp' x : simp A' T)). + +-bad : rrsubst-es + ([x] [d] Dord x d) + _ + _ + ([x] at-ofes/var (Dlook x)) + _ + D + <- ({x} {d} + slookup-isvar (Dlook x) (Dord x d) + (Disvar x d : isvar _ I)) + <- ({x} {d} + isvar-app-contra (Disvar x d) Dfalse) + <- ({x:atm} + false-implies-atofes Dfalse (D x)). + +-app : rrsubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + at-ofes/app + (DofN x : ofes (G x) (N x) T) + (DofR x : at-ofes (G x) (R x) (arrow T U))) + (rrsub/app DsubN DsubR) +%% + ([x] at-ofes/app (DofN' x) (DofR' x)) +%% + <- rrsubst-es Dord Dlook DofM DofR DsubR DofR' + <- subst-es Dord Dlook DofM DofN DsubN DofN'. + +%%% + +-closed : rmsubst-es + ([x] [d] Dord x d: sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + at-ofes/closed + (Dsimp x : simp (A x) T) + (Datof x : at-of (R x) (A x))) + (Dsub : rmsub R M LRx) +%% + D +%% + <- atof-noassm Datof + ([x] DeqR x : atm-eq (R x) R') + ([x] DeqA x : tp-eq (A x) A') + <- rmsub-compat DeqR tm-eq/i tm-eq/i Dsub + (Dsub' : rmsub ([_] R') M LRx) + <- rmsub-absent Dsub' Dfalse + <- ({x} + false-implies-ofes Dfalse (D x)). + +-var : rmsubst-es + ([x] [d] Dord x d: sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + at-ofes/var + (Dlook' x : slookup (G x) x T)) + rmsub/var +%% + DofM' +%% + <- ({x} {d} + slookup-fun (Dord x d) (Dlook x) (Dlook' x) + (Deq : stp-eq S T)) + <- ({x} + ofes-resp sctx-eq/i tm-eq/i Deq (DofM x) + (DofM' x : ofes (G x) M T)). + +-app : rmsubst-es + ([x] [d] Dord x d: sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + at-ofes/app + (DofN x : ofes (G x) (N x) T) + (DofR x : at-ofes (G x) (R x) (arrow T U))) + (rmsub/app + (DsubP : sub P Nx Py) + (DsubN : sub N M Nx) + (DsubR : rmsub R M (lam P))) +%% + ([x] DofP'' x) +%% + <- rmsubst-es Dord Dlook DofM DofR DsubR + ([x] + ofes/lam + (DofP x : {y} ofes (scons (G x) y T) (P y) U)) + <- subst-es Dord Dlook DofM DofN DsubN + (DofN' : {x} ofes (G x) Nx T) + <- ({x} {y} + weaken-ofes (DofN' x) _ _ + (DofN'' x y : ofes (scons (G x) y T) Nx T)) + <- ({x} {d} + extend-sordered T (Dord x d) + (I : nat) + ([y] [e] Dord' x d y e : sordered (scons (G x) y T))) + <- ({x} {d} + subst-es + (Dord' x d) + ([y] slookup/hit) + ([y] DofN'' x y) + ([y] DofP x y) + DsubP + ([y] DofP' x y : ofes (scons (G x) y T) Py U)) + <- ({x} + strengthen-ofes + ([y] sappend/nil) + sappend/nil + ([y] DofP' x y) + (DofP'' x : ofes (G x) Py U)). + +-bad : rmsubst-es ([x] [d] Dord x d) _ _ ([x] at-ofes/var (Dlook x)) _ D + <- ({x} {d} + slookup-isvar (Dlook x) (Dord x d) + (Disvar x d : isvar _ I)) + <- ({x} {d} + isvar-app-contra (Disvar x d) Dfalse) + <- ({x} + false-implies-ofes Dfalse (D x)). + +%% + +-rr : subst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + ofes/at + (DofR x : at-ofes (G x) (R x) o)) + (sub/rr Dsub) +%% + ([x] ofes/at (DofR' x)) +%% + <- rrsubst-es Dord Dlook DofM DofR Dsub DofR'. + +-rm : subst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + ofes/at + (DofR x : at-ofes (G x) (R x) o)) + (sub/rm Dsub) + D + <- rmsubst-es Dord Dlook DofM DofR Dsub D. + +-lam : subst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + ofes/lam + (DofN x : {y} ofes (scons (G x) y T) (N x y) U)) + (sub/lam + (Dsub : {y} sub ([x] N x y) M (Nx y))) +%% + ([x] ofes/lam (DofN' x)) +%% + <- ({x} {d} + extend-sordered _ (Dord x d) I + ([y] [e] Dord' x d y e : sordered (scons (G x) y T))) + <- ({x} {y} + weaken-ofes (DofM x) y T + (DofM' x y : ofes (scons (G x) y T) M S)) + <- ({y} {e} + subst-es + ([x] [d] Dord' x d y e) + ([x] slookup/miss (Dlook x)) + ([x] DofM' x y) + ([x] DofN x y) + (Dsub y) + ([x] DofN' x y : ofes (scons (G x) y T) (Nx y) U)). + + +%worlds (csig | asig | var | ovar | bind | evar) + (rrsubst-es _ _ _ _ _ _) + (rmsubst-es _ _ _ _ _ _) + (subst-es _ _ _ _ _ _). +%total (D1 D2 D3) + (rrsubst-es _ _ _ _ D1 _) + (rmsubst-es _ _ _ _ D2 _) + (subst-es _ _ _ _ D3 _). + +%%% type substitution preserves simple type well-formedness (explicit context) %%% + +atpsubst-es : ({x} {d:isvar x I} sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} ofes (G x) M S) + -> ({x} at-kofes (G x) (P x) H) + -> atpsub ([x] P x) M Px +%% + -> ({x} at-kofes (G x) Px H) -> type. +%mode atpsubst-es +X0 +X1 +X2 +X3 +X4 -X5. + +tpsubst-es : ({x} {d:isvar x I} sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} ofes (G x) M S) + -> ({x} kofes (G x) (A x) H) + -> tpsub ([x] A x) M Ax +%% + -> ({x} kofes (G x) Ax H) -> type. +%mode tpsubst-es +X0 +X1 +X2 +X3 +X4 -X5. + +-closed : atpsubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] Datkofes x + : at-kofes (G x) P H) + (atpsub/closed : atpsub ([x] P) _ P) +%% + Datkofes. + +-closed : atpsubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] at-kofes/closed + (Dksimp x : ksimp (K x) H) + (Datkof x : at-kof (P x) (K x))) + (DsubP : atpsub ([x] P x) M Px) +%% + ([x] at-kofes/closed (Dksimp' aca) Datkof'') +%% + <- atkof-noassm Datkof + ([x] DeqP x : atp-eq (P x) P') + ([x] DeqK x : kind-eq (K x) K') + <- atpsub-compat DeqP tm-eq/i atp-eq/i DsubP + (DsubP' : atpsub ([_] P') M Px) + <- atpsub-absent-fun DsubP' + (DeqPx : atp-eq P' Px) + <- ({x} + atkof-resp (DeqP x) (DeqK x) (Datkof x) + (Datkof' x : at-kof P' K')) + <- atkof-resp DeqPx kind-eq/i (Datkof' aca) + (Datkof'' : at-kof Px K') + <- ({x} + ksimp-compat (DeqK x) skind-eq/i (Dksimp x) + (Dksimp' x : ksimp K' H)). + +-app : atpsubst-es %% app P N + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] at-kofes/app + (DofN x : ofes (G x) (N x) T) + (DofP x : at-kofes (G x) (P x) (karrow T H)) + : at-kofes (G x) (aapp (P x) (N x)) H) + (atpsub/app + (DsubN : sub ([x] N x) M Nx) + (DsubP : atpsub ([x] P x) M Px)) + ([x] at-kofes/app (DofNx x) (DofPx x)) +%% + <- atpsubst-es Dord Dlook DofM DofP DsubP + ([x] DofPx x : at-kofes (G x) Px (karrow T H)) + <- subst-es Dord Dlook DofM DofN DsubN + ([x] DofNx x : ofes (G x) Nx T). + +-base : tpsubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + kofes/base + (Datkofes x : at-kofes (G x) (P x) sktype)) + (tpsub/base + (Datpsub : atpsub ([x] P x) M Px)) +%% + ([x] kofes/base (DatkofesPx x)) +%% + <- atpsubst-es Dord Dlook DofM Datkofes Datpsub DatkofesPx. + + +-pi : tpsubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + kofes/pi + ([y] DkofesB x y : kofes (scons (G x) y T) (B x y) sktype) + (DsimpA x : simp (A x) T) + (DkofesA x : kofes (G x) (A x) sktype) + : kofes (G x) (pi (A x) [y] B x y) sktype) + (tpsub/pi + ([y] DtsubB y : tpsub ([x] B x y) M (Bx y)) + ( DtsubA : tpsub ([x] A x) M Ax)) +%% + ([x] kofes/pi ([y] DkofesBx x y) DsimpAx (DkofesAx x)) +%% + <- tpsubst-es Dord Dlook DofM DkofesA DtsubA + ([x] DkofesAx x : kofes (G x) Ax sktype) + <- tpsub-preserves-simp DtsubA ([x] DsimpA x) + (DsimpAx : simp Ax T) + <- ({x} {d} + extend-sordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : sordered (scons (G x) y T))) + <- ({x} {y} + weaken-ofes (DofM x) y T + (DofM' x y : ofes (scons (G x) y T) M S)) + <- ({y} {e} + tpsubst-es + ([x] [d] Dord' x d y e) + ([x] slookup/miss (Dlook x)) + ([x] DofM' x y) + ([x] DkofesB x y) + (DtsubB y) + ([x] DkofesBx x y + : kofes (scons (G x) y T) (Bx y) sktype)). + +-alam : tpsubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + kofes/lam + ([y] DofB x y : kofes (scons (G x) y T) (B x y) H)) + (tpsub/lam + ([y] Dsub y : tpsub ([x] B x y) M (Bx y))) +%% + ([x] kofes/lam (DofB' x)) +%% + <- ({x} {d} + extend-sordered _ (Dord x d) I + ([y] [e] Dord' x d y e : sordered (scons (G x) y T))) + <- ({x} {y} + weaken-ofes (DofM x) y T + (DofM' x y : ofes (scons (G x) y T) M S)) + <- ({y} {e} + tpsubst-es + ([x] [d] Dord' x d y e) + ([x] slookup/miss (Dlook x)) + ([x] DofM' x y) ([x] DofB x y) (Dsub y) + ([x] DofB' x y : kofes (scons (G x) y T) (Bx y) H)). + + +%worlds (csig | asig | var | ovar | bind) (atpsubst-es _ _ _ _ _ _) (tpsubst-es _ _ _ _ _ _). +%total (D1 D2) (atpsubst-es _ _ _ _ D1 _) (tpsubst-es _ _ _ _ D2 _). + + +%%% kind substitution preserves simple kind well-formedness (explicit context) %%% + +ksubst-es : ({x} {d:isvar x I} sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} ofes (G x) M S) + -> ({x} wfkindes (G x) (K x)) + -> ksub ([x] K x) M K' +%% + -> ({x} wfkindes (G x) K') -> type. +%mode ksubst-es +X1 +X2 +X3 +X4 +X5 -X6. + +-ktype : ksubst-es Dord Dlook DofM + ([x] wfkindes/type) + ksub/type +%% + ([x] wfkindes/type). + +-pi : ksubst-es + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofM x : ofes (G x) M S) + ([x] + wfkindes/pi + ([y] DofK x y : wfkindes (scons (G x) y T) (K x y)) + (DsimpA x : simp (A x) T) + (DofA x : kofes (G x) (A x) sktype) + : wfkindes (G x) (kpi (A x) [y] K x y)) + (ksub/pi + ([y] DsubK y : ksub ([x] K x y) M (Kx y)) + (DsubA : tpsub ([x] A x) M Ax)) +%% + ([x] wfkindes/pi ([y] DofKx x y) DsimpAx (DofAx x)) +%% + <- tpsubst-es Dord Dlook DofM DofA DsubA + ([x] DofAx x : kofes (G x) Ax sktype) + <- tpsub-preserves-simp DsubA ([x] DsimpA x) + (DsimpAx : simp Ax T) + <- ({x} {d} + extend-sordered _ (Dord x d) _ + ([y] [e] Dord' x d y e : sordered (scons (G x) y T))) + <- ({x} {y} + weaken-ofes (DofM x) y T + (DofM' x y : ofes (scons (G x) y T) M S)) + <- ({y} {e} + ksubst-es + ([x] [d] Dord' x d y e) + ([x] slookup/miss (Dlook x)) + ([x] DofM' x y) + ([x] DofK x y) + (DsubK y) + ([x] DofKx x y : wfkindes (scons (G x) y T) (Kx y))). + +%worlds (csig | asig | var | ovar | bind) (ksubst-es _ _ _ _ _ _). +%total D (ksubst-es _ _ _ _ D _). + + +%%%% substitution effectiveness (explicit contexts, simple types, metric) %%%% + +ofes-pi-invert-underbind : ({x:atm} ofes (G x) M (arrow S T)) +%% + -> tm-eq M (lam [x] P x) + -> ({x} {y} ofes (scons (G x) y S) (P y) T) -> type. +%mode ofes-pi-invert-underbind +X1 -X2 -X3. + +- : ofes-pi-invert-underbind ([x] ofes/lam (D x)) tm-eq/i D. + +%worlds (csig | asig | var | bind | ovar) (ofes-pi-invert-underbind _ _ _). +%total {} (ofes-pi-invert-underbind _ _ _). + + +at-invert : ofes G M o -> tm-eq M (at R) -> type. +%mode at-invert +X1 -X2. + +- : at-invert (ofes/at DofR) Deq + <- at-compat atm-eq/i Deq. + +%worlds (csig | asig | var | bind | ovar) (at-invert _ _). +%total D (at-invert D _). + + +rsub : (atm -> atm) -> tm -> type. + +rsub/rrsub : rsub R M + <- rrsub R M _. + +rsub/rmsub : rsub R M + <- rmsub R M _. + + +rsub-sub-at : ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} at-ofes (G x) (R x) o) + -> ({x} ofes (G x) M S) + -> rsub R M +%% + -> sub ([x] at (R x)) M N -> type. +%mode rsub-sub-at +X1 +X2 +X3 +X4 +X5 -X6. + +- : rsub-sub-at _ _ _ _ (rsub/rrsub D) (sub/rr D). + +- : rsub-sub-at + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] DofR x : at-ofes (G x) (R x) o) + ([x] DofM x : ofes (G x) M S) + (rsub/rmsub + (Drmsub : rmsub ([x] R x) M LRx)) +%% + (sub/rm Drmsub') +%% + <- rmsubst-es Dord Dlook DofM DofR Drmsub + ([x] DofLRx x : ofes (G x) LRx o) + <- ({x} + at-invert (DofLRx x) + (Deq x : tm-eq LRx (at Rx))) + <- rmsub-compat ([_] atm-eq/i) tm-eq/i (Deq aca) Drmsub + (Drmsub' : rmsub ([x] R x) M (at Rx)). + +%worlds (csig | asig | var | bind | ovar) (rsub-sub-at _ _ _ _ _ _). +%total {} (rsub-sub-at _ _ _ _ _ _). + + +can-rsub-esm : {S} + ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} at-ofes (G x) (R x) T) + -> ({x} ofes (G x) M S) +%% + -> rsub R M -> type. +%mode can-rsub-esm +X1 +X2 +X3 +X4 +X5 -X6. + +can-sub-esm : {S} + ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} ofes (G x) (N x) T) + -> ({x} ofes (G x) M S) +%% + -> sub N M N' -> type. +%mode can-sub-esm +X1 +X2 +X3 +X4 +X5 -X6. + +can-rsub-app : {S} + ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} at-ofes (G x) (R x) (arrow T U)) + -> ({x} ofes (G x) (N x) T) + -> ({x} ofes (G x) M S) + -> rsub R M + -> sub N M Nx +%% + -> rsub ([x] app (R x) (N x)) M -> type. +%mode can-rsub-app +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9. + + +-closed : can-rsub-esm S + ([x] [d : isvar x I] Dsord x d : sordered (G x)) + ([x] Dlookup x : slookup (G x) x S) + ([x] at-ofes/closed + (Dsimp x : simp (A x) T) + (Datof x : at-of (R x) (A x))) + ([x] DofM x : ofes (G x) M S) + (rsub/rrsub Drrsub) + <- atof-noassm Datof + ([x] Deq x : atm-eq (R x) R') _ + <- ({x} + atm-eq-sym (Deq x) + (Deq' x : atm-eq R' (R x))) + <- rrsub-compat Deq' tm-eq/i atm-eq/i rrsub/closed + (Drrsub : rrsub R M R'). + +%{ +-const : can-rsub-esm S + ([x] [d : isvar x I] Dsord x d : sordered (G x)) + ([x] Dlookup x : slookup (G x) x S) + ([x] at-ofes/const + (Dsimp x : simp (A x) T) + (Dsimpctx x : simpctx (G' x) (G x)) + (Dkofe x : kofe (G' x) (A x)) + (Dcof x : c-of C (A x))) + ([x] DofM x : ofes (G x) M S) + (rsub/rrsub rrsub/closed). +}% + +-closed : can-rsub-esm _ _ _ _ _ (rsub/rrsub rrsub/closed). + +-var : can-rsub-esm _ _ _ _ _ (rsub/rmsub rmsub/var). + +-app : can-rsub-esm S + ([x] [d : isvar x I] Dsord x d : sordered (G x)) + ([x] Dlookup x : slookup (G x) x S) + ([x] at-ofes/app + (DofN x : ofes (G x) (N x) T) + (DofR x : at-ofes (G x) (R x) (arrow T U))) + ([x] DofM x : ofes (G x) M S) + Drsub' + <- can-rsub-esm S Dsord Dlookup DofR DofM Drsub + <- can-sub-esm S Dsord Dlookup DofN DofM Dsub + <- can-rsub-app S Dsord Dlookup DofR DofN DofM Drsub Dsub Drsub'. + +-app-rr : can-rsub-app S + ([x] [d] Dsord x d : sordered (G x)) + ([x] Dlookup x : slookup (G x) x S) + ([x] DofR x : at-ofes (G x) (R x) (arrow T U)) + ([x] DofN x : ofes (G x) (N x) T) + ([x] DofM x : ofes (G x) M S) + (rsub/rrsub + (Drrsub : rrsub R M Rx)) + (Dsub : sub N M Nx) +%% + (rsub/rrsub (rrsub/app Dsub Drrsub)). + +-app-rm : can-rsub-app S + ([x] [d] Dsord x d : sordered (G x)) + ([x] Dlookup x : slookup (G x) x S) + ([x] DofR x : at-ofes (G x) (R x) (arrow T U)) + ([x] DofN x : ofes (G x) (N x) T) + ([x] DofM x : ofes (G x) M S) + (rsub/rmsub + (Drmsub : rmsub ([x] R x) M LRx)) %% LRx should be a lam + (DsubNx : sub ([x] N x) M Nx) +%% + (rsub/rmsub + (rmsub/app + (DsubPy_x aca) + DsubNx + Drmsub')) + <- rmsub-headvar Drmsub + (Dheadvar : headvar ([x] R x)) + <- headvar-stp-size Dsord Dlookup DofR Dheadvar + (Dleq : stp-leq (arrow T U) S) + <- rmsubst-es Dsord Dlookup DofM DofR Drmsub + ([x] DofLRx x : ofes (G x) LRx (arrow T U)) + <- subst-es Dsord Dlookup DofM DofN DsubNx + ([x] DofNx x : ofes (G x) Nx T) + <- ofes-pi-invert-underbind DofLRx + (DeqLRx : tm-eq LRx (lam [y] P y)) + % ([x] [y] DofP x y : ofes (scons (G x) y T) (P y) U) + (DofP : {x} {y} ofes (scons (G x) y T) (P y) U) + <- rmsub-compat ([_] atm-eq/i) tm-eq/i DeqLRx Drmsub + (Drmsub' : rmsub ([x] R x) M (lam [y] P y)) + <- ({x} {y} + weaken-ofes (DofNx x) y T + (DofNx' x y : ofes (scons (G x) y T) Nx T)) + <- ({x} {d} + extend-sordered T (Dsord x d) _ + ([y] [e] Dsord' y e x d : sordered (scons (G x) y T))) + <- employ-stp-leq (arrow T U) S Dleq + <- ({x} {d} + can-sub-esm T ([y] [e] Dsord' y e x d) ([y] slookup/hit) + ([y] DofP x y) ([y] DofNx' x y) + (DsubPy_x x : sub P Nx (Py_x x))). + + +-appbad : can-rsub-esm S + ([x] [d:isvar x I] Dsord x d : sordered (G x)) + _ % ([x] Dlookup x : slookup (G x) x S) + ([x] at-ofes/var + (Dlookup x : slookup (G x) (app (R x) (M x)) T)) + _ +%% + (rsub/rmsub Drmsub) +%%% + <- ({x} {d} + slookup-isvar (Dlookup x) (Dsord x d) + (Disvar x d : isvar _ J)) + <- ({x} {d} + isvar-app-contra (Disvar x d) Dfalse) + <- false-implies-rmsub Dfalse (Drmsub : rmsub _ _ (at aca)). + + +%%%% + +-at : can-sub-esm S + ([x] [d:isvar x I] Dsord x d : sordered (G x)) + ([x] Dlookup x : slookup (G x) x S) + ([x] ofes/at + (DofR x : at-ofes (G x) (R x) o) + : ofes (G x) (at (R x)) o) + ([x] DofM x : ofes (G x) M S) + Dsub + <- can-rsub-esm S Dsord Dlookup DofR DofM + (Drsub : rsub R M) + <- rsub-sub-at Dsord Dlookup DofR DofM Drsub + (Dsub : sub ([x] at (R x)) M _). + +-lam : can-sub-esm S + ([x] [d:isvar x I] Dsord x d : sordered (G x)) + ([x] Dlookup x : slookup (G x) x S) + ([x] ofes/lam %% \x.N : T1 -> T2 + ([y] DofN x y : ofes (scons (G x) y T1) (N x y) T2) + : ofes (G x) (lam [y] N x y) (arrow T1 T2)) + ([x] DofM x : ofes (G x) M S) +%% + (sub/lam Dsub) +%% + <- ({x} {d} + extend-sordered T1 (Dsord x d) + _ + ([y] [e] Dsord' x d y e : sordered (scons (G x) y T1))) + <- ({x} {y} + weaken-slookup (Dlookup x) y T1 + (Dlookup' x y : slookup (scons (G x) y T1) x S)) + <- ({x} {y} + weaken-ofes (DofM x) y T1 + (DofM' x y : ofes (scons (G x) y T1) M S)) + <- ({y} {e} + can-sub-esm S + ([x] [d] Dsord' x d y e) + ([x] Dlookup' x y) + ([x] DofN x y) + ([x] DofM' x y) + (Dsub y : sub ([x] N x y) M (Nx y))). + + + +%worlds (csig | asig | bind | var | ovar) + (can-rsub-esm _ _ _ _ _ _) + (can-sub-esm _ _ _ _ _ _) + (can-rsub-app _ _ _ _ _ _ _ _ _). +%total {(S1 S2 S3) (D1 D2 D3)} + (can-rsub-esm S1 _ _ D1 _ _) + (can-sub-esm S2 _ _ D2 _ _) + (can-rsub-app S3 _ _ D3 _ _ _ _ _). + + +can-atpsub-esm : {S} + ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} at-kofes (G x) (P x) H) + -> ({x} ofes (G x) M S) +%% + -> atpsub ([x] P x) M Px -> type. +%mode can-atpsub-esm +X1 +X2 +X3 +X4 +X5 -X6. + +can-tpsub-esm : {S} + ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} kofes (G x) (B x) H) + -> ({x} ofes (G x) M S) +%% + -> tpsub ([x] B x) M B' -> type. +%mode can-tpsub-esm +X1 +X2 +X3 +X4 +X5 -X6. + +%% can-atpsub-esm + +-closed : can-atpsub-esm S + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] + at-kofes/closed + (DsimpK x : ksimp (K x) H) + (DofP x : at-kof (P x) (K x))) + ([x] DofM x : ofes (G x) M S) +%% + Datpsub +%% + <- atkof-noassm ([x] DofP x) + ([x] Deq x : atp-eq (P x) P') _ + <- ({x} + atp-eq-sym (Deq x) + (Deq' x : atp-eq P' (P x))) + <- atpsub-compat Deq' tm-eq/i atp-eq/i atpsub/closed + (Datpsub : atpsub ([x] P x) M P'). + +-closed : can-atpsub-esm _ _ _ _ _ atpsub/closed. + +-app : can-atpsub-esm S + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] + at-kofes/app + (DofN x : ofes (G x) (N x) T) + (DofP x : at-kofes (G x) (P x) (karrow T H))) + ([x] DofM x : ofes (G x) M S) +%% + (atpsub/app DsubN DsubP) +%% + <- can-sub-esm S Dord Dlook DofN DofM + (DsubN : sub ([x] N x) M Nx) + <- can-atpsub-esm S Dord Dlook DofP DofM + (DsubP : atpsub ([x] P x) M Px). + +%% can-tpsub-esm + +-base : can-tpsub-esm S + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] + kofes/base + (DofP x : at-kofes (G x) (P x) sktype)) + ([x] DofM x : ofes (G x) M S) +%% + (tpsub/base Datpsub) +%% + <- can-atpsub-esm S Dord Dlook DofP DofM + (Datpsub : atpsub ([x] P x) M Px). + +-pi : can-tpsub-esm S + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] + kofes/pi %% pi x:A.B + ([y] DofB x y + : kofes (scons (G x) y T) (B x y) sktype) + (Dsimp x : simp (A x) T) + (DofA x : kofes (G x) (A x) sktype)) + ([x] DofM x : ofes (G x) M S) +%% + (tpsub/pi ([y] DsubB y) DsubA) +%% + %% induct to get DsubA + <- can-tpsub-esm S + ([x] [d] Dord x d) + ([x] Dlook x) + ([x] DofA x) + ([x] DofM x) + (DsubA : tpsub ([x] A x) M Ax) + %% weaken the inputs and induct to get DsubB + <- ({x} {d} + extend-sordered T (Dord x d) + _ + ([y] [e] Dord' x d y e : sordered (scons (G x) y T))) + <- ({x} {y} + weaken-slookup (Dlook x) y T + (Dlook' x y : slookup (scons (G x) y T) x S)) + <- ({x} {y} + weaken-ofes (DofM x) y T + (DofM' x y : ofes (scons (G x) y T) M S)) + <- ({y} {e} + can-tpsub-esm S + ([x] [d] Dord' x d y e) + ([x] Dlook' x y) + ([x] DofB x y) + ([x] DofM' x y) + (DsubB y : tpsub ([x] B x y) M (Bx y))). + +-lam : can-tpsub-esm S + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] + kofes/lam %% \x.B : T -> H + ([y] DofB x y : kofes (scons (G x) y T) (B x y) H) + : kofes (G x) (alam [y] B x y) (karrow T H)) + ([x] DofM x : ofes (G x) M S) +%% + (tpsub/lam Dsub) +%% + <- ({x} {d} + extend-sordered T (Dord x d) _ + ([y] [e] Dord' x d y e : sordered (scons (G x) y T))) + <- ({x} {y} + weaken-slookup (Dlook x) y T + (Dlook' x y : slookup (scons (G x) y T) x S)) + <- ({x} {y} + weaken-ofes (DofM x) y T + (DofM' x y : ofes (scons (G x) y T) M S)) + <- ({y} {e} + can-tpsub-esm S + ([x] [d] Dord' x d y e) + ([x] Dlook' x y) + ([x] DofB x y) + ([x] DofM' x y) + (Dsub y : tpsub ([x] B x y) M (Bx y))). + + + +%worlds (csig | asig | bind | var | ovar) + (can-atpsub-esm _ _ _ _ _ _) + (can-tpsub-esm _ _ _ _ _ _). +%total {(S1 S2) (D1 D2)} + (can-atpsub-esm S1 _ _ D1 _ _) + (can-tpsub-esm S2 _ _ D2 _ _). + + +can-ksub-esm : {S} + ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} wfkindes (G x) (K x)) + -> ({x} ofes (G x) M S) +%% + -> ksub ([x] K x) M K' -> type. +%mode can-ksub-esm +X1 +X2 +X3 +X4 +X5 -X6. + +-type : can-ksub-esm S + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] wfkindes/type) + ([x] DofM x : ofes (G x) M S) +%% + ksub/type. + +-pi : can-ksub-esm S + ([x] [d] Dord x d : sordered (G x)) + ([x] Dlook x : slookup (G x) x S) + ([x] + wfkindes/pi + ([y] DofK x y : wfkindes (scons (G x) y T) (K x y)) + (Dsimp x : simp (A x) T) + (DofA x : kofes (G x) (A x) sktype)) + ([x] DofM x : ofes (G x) M S) +%% + (ksub/pi ([y] DsubK y) DsubA) +%% + <- can-tpsub-esm S Dord Dlook DofA DofM + (DsubA : tpsub ([x] A x) M Ax) + <- ({x} {d} + extend-sordered T (Dord x d) + _ + ([y] [e] Dord' x d y e : sordered (scons (G x) y T))) + <- ({x} {y} + weaken-slookup (Dlook x) y T + (Dlook' x y : slookup (scons (G x) y T) x S)) + <- ({x} {y} + weaken-ofes (DofM x) y T + (DofM' x y : ofes (scons (G x) y T) M S)) + <- ({y} {e} + can-ksub-esm S + ([x] [d] Dord' x d y e) + ([x] Dlook' x y) + ([x] DofK x y) + ([x] DofM' x y) + (DsubK y : ksub ([x] K x y) M (Kx y))). + +%worlds (csig | asig | bind | var | ovar) + (can-ksub-esm _ _ _ _ _ _). +%total {S D} + (can-ksub-esm S _ _ D _ _). + + +%%%% substitution effectiveness (explicit contexts, simple types) %%%% + +can-sub-es : ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} ofes (G x) (N x) T) + -> ({x} ofes (G x) M S) +%% + -> sub ([x] N x) M N' -> type. +%mode can-sub-es +X1 +X2 +X3 +X4 -X5. + +- : can-sub-es Dord Dlookup DofN DofM Dsub + <- can-sub-esm _ Dord Dlookup DofN DofM Dsub. + +%worlds (csig | asig | var | bind | ovar) (can-sub-es _ _ _ _ _). +%total {} (can-sub-es _ _ _ _ _). + +can-tpsub-es : ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} kofes (G x) (B x) H) + -> ({x} ofes (G x) M S) +%% + -> tpsub ([x] B x) M B' -> type. +%mode can-tpsub-es +X1 +X2 +X3 +X4 -X5. + +- : can-tpsub-es Dord Dlook DofB DofM Dsub + <- can-tpsub-esm _ Dord Dlook DofB DofM Dsub. + +%worlds (csig | asig | var | bind | ovar) (can-tpsub-es _ _ _ _ _). +%total {} (can-tpsub-es _ _ _ _ _). + +can-ksub-es : ({x} isvar x I -> sordered (G x)) + -> ({x} slookup (G x) x S) + -> ({x} wfkindes (G x) (K x)) + -> ({x} ofes (G x) M S) +%% + -> ksub ([x] K x) M K' -> type. +%mode can-ksub-es +X1 +X2 +X3 +X4 -X5. + +- : can-ksub-es Dord Dlook DofK DofM Dsub + <- can-ksub-esm _ Dord Dlook DofK DofM Dsub. + +%worlds (csig | asig | var | bind | ovar) (can-ksub-es _ _ _ _ _). +%total {} (can-ksub-es _ _ _ _ _). + + +%%%% substitution effectiveness (explicit contexts) %%% + +can-sub-e : ({x} append (cons G1 x A) (G2 x) (G x)) + -> ({x} isvar x I -> ordered (G x)) + -> ({x} ofe (G x) (N x) (B x)) + -> ofe G1 M A +%% + -> sub ([x] N x) M N' -> type. +%mode can-sub-e +X1 +X2 +X3 +X4 -X5. + +- : can-sub-e + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [d] Dord x d : ordered (G x)) + ([x] DofeN x : ofe (G x) (N x) (B x)) + (DofeM : ofe G1 M A) +%% + Dsub +%% + <- can-simp A + (DsimpA : simp A S) + <- ({x} + can-simp (B x) + (DsimpB x : simp (B x) T)) + <- context-append-simp-lookup' Dappend Dord DsimpA + ([x] Dsimpctx x : simpctx (G x) (G' x)) + ([x] Dslookup x : slookup (G' x) x S) + <- ({x} {d} + ordered-simpctx (Dsimpctx x) (Dord x d) + (Dsord x d : sordered (G' x))) + <- ({x} + weaken-ofe DofeM A x + (DofeM' x : ofe (cons G1 x A) M A)) + <- ({x} + weaken-ofe' (Dappend x) (DofeM' x) + (DofeM'' x : ofe (G x) M A)) + <- ({x} + ofe-simp (Dsimpctx x) DsimpA (DofeM'' x) + (DofesM x : ofes (G' x) M S)) + <- ({x} + ofe-simp (Dsimpctx x) (DsimpB x) (DofeN x) + (DofesN x : ofes (G' x) (N x) T)) + <- can-sub-es Dsord Dslookup DofesN DofesM + (Dsub : sub ([x] N x) M N'). + +%worlds (csig | asig | bind | var | ovar) (can-sub-e _ _ _ _ _). +%total {} (can-sub-e _ _ _ _ _). + +can-tpsub-e : ({x} append (cons G1 x A) (G2 x) (G x)) + -> ({x} isvar x I -> ordered (G x)) + -> ({x} kofe (G x) (B x) (K x)) + -> ofe G1 M A +%% + -> tpsub ([x] B x) M B' -> type. +%mode can-tpsub-e +X1 +X2 +X3 +X4 -X5. + +- : can-tpsub-e + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [d] Dord x d : ordered (G x)) + ([x] DofB x : kofe (G x) (B x) (K x)) + (DofM : ofe G1 M A) +%% + Dtpsub +%% + <- can-simp A + (DsimpA : simp A S) + <- ({x} + can-simp (B x) + (DsimpB x : simp (B x) T)) + <- context-append-simp-lookup' Dappend Dord DsimpA + ([x] Dsimpctx x : simpctx (G x) (G' x)) + ([x] Dslookup x : slookup (G' x) x S) + <- ({x} {d} + ordered-simpctx (Dsimpctx x) (Dord x d) + (Dsord x d : sordered (G' x))) + <- ({x} + weaken-ofe DofM A x + (DofM' x : ofe (cons G1 x A) M A)) + <- ({x} + weaken-ofe' (Dappend x) (DofM' x) + (DofM'' x : ofe (G x) M A)) + <- ({x} + ofe-simp (Dsimpctx x) DsimpA (DofM'' x) + (DofesM x : ofes (G' x) M S)) + <- ({x} + can-ksimp (K x) (DsimpK x : ksimp (K x) K')) + <- ({x} + kofe-simp (Dsimpctx x) (DsimpK x) (DofB x) + (DofesB x : kofes (G' x) (B x) K')) + <- can-tpsub-es Dsord Dslookup DofesB DofesM + (Dtpsub : tpsub ([x] B x) M B'). + +%worlds (csig | asig | bind | var | ovar) (can-tpsub-e _ _ _ _ _). +%total {} (can-tpsub-e _ _ _ _ _). + +can-ksub-e : ({x} append (cons G1 x A) (G2 x) (G x)) + -> ({x} isvar x I -> ordered (G x)) + -> ({x} wfkinde (G x) (K x)) + -> ofe G1 M A +%% + -> ksub ([x] K x) M K' -> type. +%mode can-ksub-e +X1 +X2 +X3 +X4 -X5. + +- : can-ksub-e + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [d] Dord x d : ordered (G x)) + ([x] DofK x : wfkinde (G x) (K x)) + (DofM : ofe G1 M A) +%% + Dksub +%% + <- can-simp A + (DsimpA : simp A S) + <- context-append-simp-lookup' Dappend Dord DsimpA + ([x] Dsimpctx x : simpctx (G x) (G' x)) + ([x] Dslookup x : slookup (G' x) x S) + <- ({x} {d} + ordered-simpctx (Dsimpctx x) (Dord x d) + (Dsord x d : sordered (G' x))) + <- ({x} + weaken-ofe DofM A x + (DofM' x : ofe (cons G1 x A) M A)) + <- ({x} + weaken-ofe' (Dappend x) (DofM' x) + (DofM'' x : ofe (G x) M A)) + <- ({x} + ofe-simp (Dsimpctx x) DsimpA (DofM'' x) + (DofesM x : ofes (G' x) M S)) + <- ({x} + wfkinde-simp (Dsimpctx x) (DofK x) + (DofesK x : wfkindes (G' x) (K x))) + <- can-ksub-es Dsord Dslookup DofesK DofesM + (Dksub : ksub ([x] K x) M K'). + +%worlds (csig | asig | bind | var | ovar) (can-ksub-e _ _ _ _ _). +%total {} (can-ksub-e _ _ _ _ _). + + +%%%% substitution effectiveness %%%% + +can-sub : ({x} vof x A -> of (N x) (B x)) + -> of M A +%% + -> sub ([x] N x) M N' -> type. +%mode can-sub +X1 +X2 -X3. + +- : can-sub + ([x] [d] DofN x d : of (N x) (B x)) + (DofM : of M A) + Dsub + <- of1-to-ofe DofN (DofeN : {x} ofe (cons nil x A) (N x) (B x)) + <- of-to-ofe DofM (DofeM : ofe nil M A) + <- extend-ordered A ordered/nil I Dord + <- can-sub-e ([_] append/nil) ([x] [d:isvar x I] Dord x d) DofeN DofeM + (Dsub : sub ([x] N x) M N'). + +%worlds (csig | asig | bind | var) (can-sub _ _ _). +%total {} (can-sub _ _ _). + + +can-tpsub : ({x} vof x A -> kof (B x) (K x)) + -> of M A +%% + -> tpsub ([x] B x) M B' -> type. +%mode can-tpsub +X1 +X2 -X3. + +- : can-tpsub + ([x] [d] DofB x d : kof (B x) (K x)) + (DofM : of M A) + Dsub + <- kof1-to-kofe DofB ([x] DofeB x : kofe (cons nil x A) (B x) (K x)) + <- of-to-ofe DofM (DofeM : ofe nil M A) + <- extend-ordered A ordered/nil I Dord + <- can-tpsub-e ([_] append/nil) ([x] [d:isvar x I] Dord x d) DofeB DofeM + (Dsub : tpsub ([x] B x) M B'). + +%worlds (csig | asig | bind | var) (can-tpsub _ _ _). +%total {} (can-tpsub _ _ _). + + +can-ksub : ({x} vof x A -> wfkind (K x)) + -> of M A +%% + -> ksub ([x] K x) M K' -> type. +%mode can-ksub +X1 +X2 -X3. + +- : can-ksub + ([x] [d] DofK x d : wfkind (K x)) + (DofM : of M A) + Dsub + <- wfkind1-to-wfkinde DofK ([x] DofeK x : wfkinde (cons nil x A) (K x)) + <- of-to-ofe DofM (DofeM : ofe nil M A) + <- extend-ordered A ordered/nil I Dord + <- can-ksub-e ([_] append/nil) ([x] [d:isvar x I] Dord x d) DofeK DofeM + (Dsub : ksub ([x] K x) M K'). + +%worlds (csig | asig | bind | var) (can-ksub _ _ _). +%total {} (can-ksub _ _ _). + + +%%%% corollaries %%%% + +can-tpsub-context-e : ordered G + -> ({x} ofe (cons G x A) (M x) B) + -> ({y} kofe (cons G y B) (C y) (K y)) +%% + -> ({x} tpsub ([y] C y) (M x) (Cy x)) -> type. +%mode can-tpsub-context-e +X0 +X1 +X2 -X3. + +- : can-tpsub-context-e + (Dord : ordered G) + ([x] DofM x : ofe (cons G x A) (M x) B) + ([y] DofC y : kofe (cons G y B) (C y) (K y)) +%% + ([x] Dtpsub x) +%% + <- extend-ordered _ Dord _ + ([x] [d] Dordx x d : ordered (cons G x A)) + <- ({x} {d} + extend-ordered _ (Dordx x d) J + ([y] [e] Dordy x d y e + : ordered (cons (cons G x A) y B))) + <- ({x} {y} + weakeng-kofe (append/cons append/nil) + (append/cons append/nil) + (DofC y) + (DofC' x y : kofe (cons (cons G x A) y B) (C y) (K y))) + <- ({x} {d:isvar x _} + can-tpsub-e ([_] append/nil) ([y] [e] Dordy x d y e) + ([y] DofC' x y) (DofM x) + (Dtpsub x : tpsub ([y] C y) (M x) (Cy x))). + +%worlds (csig | asig | bind | var | ovar) (can-tpsub-context-e _ _ _ _). +%total {} (can-tpsub-context-e _ _ _ _). + + +can-ksub-context-e : ordered G + -> ({x} ofe (cons G x A) (M x) B) + -> ({y} wfkinde (cons G y B) (K y)) +%% + -> ({x} ksub ([y] K y) (M x) (Ky x)) -> type. +%mode can-ksub-context-e +X0 +X1 +X2 -X3. + +- : can-ksub-context-e + (Dord : ordered G) + ([x] DofM x : ofe (cons G x A) (M x) B) + ([y] DofK y : wfkinde (cons G y B) (K y)) +%% + ([x] Dksub x) +%% + <- extend-ordered _ Dord _ + ([x] [d] Dordx x d : ordered (cons G x A)) + <- ({x} {d} + extend-ordered _ (Dordx x d) J + ([y] [e] Dordy x d y e + : ordered (cons (cons G x A) y B))) + <- ({x} {y} + weakeng-wfkinde (append/cons append/nil) + (append/cons append/nil) + (DofK y) + (DofK' x y : wfkinde (cons (cons G x A) y B) (K y))) + <- ({x} {d:isvar x _} + can-ksub-e ([_] append/nil) ([y] [e] Dordy x d y e) + ([y] DofK' x y) (DofM x) + (Dksub x : ksub ([y] K y) (M x) (Ky x))). + +%worlds (csig | asig | bind | var | ovar) (can-ksub-context-e _ _ _ _). +%total {} (can-ksub-context-e _ _ _ _). + + + diff --git a/src/subst-fun.thm b/src/subst-fun.thm new file mode 100644 index 0000000..52dd5ef --- /dev/null +++ b/src/subst-fun.thm @@ -0,0 +1,224 @@ + +%%%% functionality of substitution %%%% + +%%% lemmas %%% + +rrsub-rmsub-contra : rrsub R M _ -> rmsub R M _ -> false -> type. +%mode rrsub-rmsub-contra +X1 +X2 -X3. + +-app : rrsub-rmsub-contra (rrsub/app _ Drrsub) (rmsub/app _ _ Drmsub) Df + <- rrsub-rmsub-contra Drrsub Drmsub Df. + +-closedapp : rrsub-rmsub-contra rrsub/closed (rmsub/app _ _ Drmsub) Df + <- rrsub-rmsub-contra rrsub/closed Drmsub Df. + +%worlds (csig | asig | var) (rrsub-rmsub-contra _ _ _). +%total D (rrsub-rmsub-contra _ D _). + + +rmsub-absent : rmsub ([_] R) M N -> false -> type. +%mode rmsub-absent +X1 -X2. + +- : rmsub-absent Daosub Df + <- rrsub-rmsub-contra (rrsub/closed) Daosub Df. + +%worlds (csig | asig | var) (rmsub-absent _ _). +%total {} (rmsub-absent _ _). + + +rrsub-absent-fun : rrsub ([_] R) M R' -> atm-eq R R' -> type. +%mode rrsub-absent-fun +X1 -X2. + +sub-absent-fun : sub ([_] N) M N' -> tm-eq N N' -> type. +%mode sub-absent-fun +X1 -X2. + +atpsub-absent-fun : atpsub ([_] P) M P' -> atp-eq P P' -> type. +%mode atpsub-absent-fun +X1 -X2. + +tpsub-absent-fun : tpsub ([_] A) M A' -> tp-eq A A' -> type. +%mode tpsub-absent-fun +X1 -X2. + +ksub-absent-fun : ksub ([_] K) M K' -> kind-eq K K' -> type. +%mode ksub-absent-fun +X1 -X2. + +%% rrsub-absent-fun + +- : rrsub-absent-fun rrsub/closed atm-eq/i. + +- : rrsub-absent-fun (rrsub/app D2 D1) Deq + <- rrsub-absent-fun D1 Deq1 + <- sub-absent-fun D2 Deq2 + <- app-compat Deq1 Deq2 Deq. + +%% sub-absent-fun + +- : sub-absent-fun (sub/rr D) Deq' + <- rrsub-absent-fun D Deq + <- at-compat Deq Deq'. + +- : sub-absent-fun (sub/rm D) Deq + <- rmsub-absent D Dfalse + <- false-implies-tm-eq Dfalse Deq. + +- : sub-absent-fun (sub/lam D) Deq' + <- ({y} sub-absent-fun (D y) (Deq y)) + <- lam-compat Deq Deq'. + +%% atpsub-absent-fun + +- : atpsub-absent-fun atpsub/closed atp-eq/i. + +- : atpsub-absent-fun (atpsub/app D2 D1) Deq + <- atpsub-absent-fun D1 Deq1 + <- sub-absent-fun D2 Deq2 + <- aapp-compat Deq1 Deq2 Deq. + +%% tpsub-absent-fun + +- : tpsub-absent-fun (tpsub/base D) Deq' + <- atpsub-absent-fun D Deq + <- base-compat Deq Deq'. + +- : tpsub-absent-fun (tpsub/pi Dbody Dargtp) Deq + <- ({y} tpsub-absent-fun (Dbody y) (Dbodyeq y)) + <- tpsub-absent-fun Dargtp Dargeq + <- pi-compat Dargeq Dbodyeq Deq. + +- : tpsub-absent-fun (tpsub/lam D) Deq' + <- ({y} tpsub-absent-fun (D y) (Deq y)) + <- alam-compat Deq Deq'. + +%% ksub-absent-fun + +- : ksub-absent-fun ksub/type %{ksub/closed}% kind-eq/i. + +- : ksub-absent-fun (ksub/pi Dbody Dargtp) Deq + <- ({y} ksub-absent-fun (Dbody y) (Dbodyeq y)) + <- tpsub-absent-fun Dargtp Dargeq + <- kpi-compat Dargeq Dbodyeq Deq. + +%worlds (csig | asig | var) (rrsub-absent-fun _ _) (sub-absent-fun _ _) (atpsub-absent-fun _ _) + (tpsub-absent-fun _ _) (ksub-absent-fun _ _). +%total (D1 D2 D3 D4 D5) (rrsub-absent-fun D1 _) (sub-absent-fun D2 _) + (atpsub-absent-fun D3 _) (tpsub-absent-fun D4 _) (ksub-absent-fun D5 _). + + +%%% functionality %%% + +rrsub-fun : rrsub R M R1 -> rrsub R M R2 -> atm-eq R1 R2 -> type. +%mode rrsub-fun +X1 +X2 -X3. + +rmsub-fun : rmsub R M N1 -> rmsub R M N2 -> tm-eq N1 N2 -> type. +%mode rmsub-fun +X1 +X2 -X3. + +sub-fun : sub M N M1 -> sub M N M2 -> tm-eq M1 M2 -> type. +%mode sub-fun +X1 +X2 -X3. + +tpsub-fun : tpsub A M A1 -> tpsub A M A2 -> tp-eq A1 A2 -> type. +%mode tpsub-fun +X1 +X2 -X3. + +atpsub-fun : atpsub P M P1 -> atpsub P M P2 -> atp-eq P1 P2 -> type. +%mode atpsub-fun +X1 +X2 -X3. + +ksub-fun : ksub K M K1 -> ksub K M K2 -> kind-eq K1 K2 -> type. +%mode ksub-fun +X1 +X2 -X3. + + +%% rrsub-fun %% + +-app : rrsub-fun (rrsub/app Dsub1 Drrsub1) (rrsub/app Dsub2 Drrsub2) Deq + <- rrsub-fun Drrsub1 Drrsub2 Deqrrsub + <- sub-fun Dsub1 Dsub2 Deqsub + <- app-compat Deqrrsub Deqsub Deq. + +-closed : rrsub-fun rrsub/closed D Deq + <- rrsub-absent-fun D Deq. + +-closed : rrsub-fun D rrsub/closed Deq' + <- rrsub-absent-fun D Deq + <- atm-eq-sym Deq Deq'. + + +%% rmsub-fun %% + +-var : rmsub-fun rmsub/var rmsub/var tm-eq/i. + +-app : rmsub-fun (rmsub/app Dsub1 Dsub2 Drmsub) + (rmsub/app Dsub1' Dsub2' Drmsub') Deq + <- rmsub-fun Drmsub Drmsub' Dlameq + <- lam-inj Dlameq Dbodyeq + <- sub-fun Dsub2 Dsub2' Deq2 + <- sub-compat Dbodyeq Deq2 tm-eq/i Dsub1 Dsub1'' + <- sub-fun Dsub1'' Dsub1' Deq. + + +%% sub-fun %% + +-rr : sub-fun (sub/rr Drrsub) (sub/rr Drrsub') Deq + <- rrsub-fun Drrsub Drrsub' Dateq + <- at-compat Dateq Deq. + +-rm : sub-fun (sub/rm Drmsub) (sub/rm Drmsub') Deq + <- rmsub-fun Drmsub Drmsub' Deq. + +-rrrm : sub-fun (sub/rr Drr) (sub/rm Drm) Deq + <- rrsub-rmsub-contra Drr Drm Df + <- false-implies-tm-eq Df Deq. + +-rmrr : sub-fun (sub/rm Drm) (sub/rr Drr) Deq + <- rrsub-rmsub-contra Drr Drm Df + <- false-implies-tm-eq Df Deq. + +-lam : sub-fun (sub/lam Dbody) (sub/lam Dbody') Deq + <- ({y} sub-fun (Dbody y) (Dbody' y) (Deqbody y)) + <- lam-compat Deqbody Deq. + + +%% atpsub-fun %% + +-closed : atpsub-fun atpsub/closed D Deq + <- atpsub-absent-fun D Deq. + +-closed : atpsub-fun D atpsub/closed Deq' + <- atpsub-absent-fun D Deq + <- atp-eq-sym Deq Deq'. + +-aapp : atpsub-fun (atpsub/app Dargsub Dfunsub) + (atpsub/app Dargsub' Dfunsub') Deq + <- atpsub-fun Dfunsub Dfunsub' Dfuneq + <- sub-fun Dargsub Dargsub' Dargeq + <- aapp-compat Dfuneq Dargeq Deq. + + +%% tpsub-fun %% + +-base : tpsub-fun (tpsub/base Datpsub) (tpsub/base Datpsub') Deq + <- atpsub-fun Datpsub Datpsub' Datpeq + <- base-compat Datpeq Deq. + +-pi : tpsub-fun (tpsub/pi Dbody Dargtp) (tpsub/pi Dbody' Dargtp') Deq + <- ({y} tpsub-fun (Dbody y) (Dbody' y) (Deqbody y)) + <- tpsub-fun Dargtp Dargtp' Deqarg + <- pi-compat Deqarg Deqbody Deq. + +-lam : tpsub-fun (tpsub/lam Dbody) (tpsub/lam Dbody') Deq + <- ({y} tpsub-fun (Dbody y) (Dbody' y) (Deqbody y)) + <- alam-compat Deqbody Deq. + + +%% ksub-fun %% + +-closed : ksub-fun ksub/type ksub/type kind-eq/i. + +-kpi : ksub-fun (ksub/pi Dbody Dargtp) (ksub/pi Dbody' Dargtp') Deq + <- ({y} ksub-fun (Dbody y) (Dbody' y) (Deqbody y)) + <- tpsub-fun Dargtp Dargtp' Deqarg + <- kpi-compat Deqarg Deqbody Deq. + + +%worlds (csig | asig | var) (rrsub-fun _ _ _) (rmsub-fun _ _ _) (sub-fun _ _ _) (atpsub-fun _ _ _) + (tpsub-fun _ _ _) (ksub-fun _ _ _). +%total (D1 D2 D3 D4 D5 D6) (rrsub-fun D1 _ _) (rmsub-fun D2 _ _) + (sub-fun D3 _ _) (atpsub-fun D4 _ _) (tpsub-fun D5 _ _) (ksub-fun D6 _ _). + + diff --git a/src/substitution.thm b/src/substitution.thm new file mode 100644 index 0000000..0de29ed --- /dev/null +++ b/src/substitution.thm @@ -0,0 +1,3196 @@ +%%%%% substitution permutation (explicit context, simple types) %%%%% + +%% (1) +sub-permute-es : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} ofes (G x1 x2) (M x1 x2) S) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} sub ([x2] M x1 x2) (N2 x1) (M' x1)) + -> ({x2} sub ([x1] M x1 x2) N1 (M` x2)) +%% + -> sub ([x1] M' x1) N1 M`' + -> sub ([x2] M` x2) N2` M`' -> type. +%mode sub-permute-es +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +sub-permute-es' : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} ofes (G x1 x2) (M x1 x2) S) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} sub ([x2] M x1 x2) (N2 x1) (M' x1)) + -> ({x2} sub ([x1] M x1 x2) N1 (M` x2)) +%% + -> sub ([x1] M' x1) N1 M`' + -> sub ([x2] M` x2) N2` M`' -> type. +%mode sub-permute-es' +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +%% (2) +rr-rr-permute-es : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} at-ofes (G x1 x2) (R x1 x2) S) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rrsub ([x2] R x1 x2) (N2 x1) (R' x1)) + -> ({x2} rrsub ([x1] R x1 x2) N1 (R` x2)) +%% + -> rrsub ([x1] R' x1) N1 R`' + -> rrsub ([x2] R` x2) N2` R`' -> type. +%mode rr-rr-permute-es +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +rr-rr-permute-es' : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} at-ofes (G x1 x2) (R x1 x2) S) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rrsub ([x2] R x1 x2) (N2 x1) (R' x1)) + -> ({x2} rrsub ([x1] R x1 x2) N1 (R` x2)) +%% + -> rrsub ([x1] R' x1) N1 R`' + -> rrsub ([x2] R` x2) N2` R`' -> type. +%mode rr-rr-permute-es' +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +%% (3) +rm-rr-permute-es : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} at-ofes (G x1 x2) (R x1 x2) S) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rmsub ([x2] R x1 x2) (N2 x1) (MR' x1)) + -> ({x2} rrsub ([x1] R x1 x2) N1 (R` x2)) +%% + -> sub ([x1] MR' x1) N1 M`' + -> rmsub ([x2] R` x2) N2` M`' -> type. +%mode rm-rr-permute-es +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +rm-rr-permute-es' : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} at-ofes (G x1 x2) (R x1 x2) S) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rmsub ([x2] R x1 x2) (N2 x1) (MR' x1)) + -> ({x2} rrsub ([x1] R x1 x2) N1 (R` x2)) +%% + -> sub ([x1] MR' x1) N1 M`' + -> rmsub ([x2] R` x2) N2` M`' -> type. +%mode rm-rr-permute-es' +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +%% (4) +rr-rm-permute-es : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} at-ofes (G x1 x2) (R x1 x2) S) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rrsub ([x2] R x1 x2) (N2 x1) (R' x1)) + -> ({x2} rmsub ([x1] R x1 x2) N1 (MR` x2)) +%% + -> rmsub ([x1] R' x1) N1 M`' + -> sub ([x2] MR` x2) N2` M`' -> type. +%mode rr-rm-permute-es +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +rr-rm-permute-es' : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} at-ofes (G x1 x2) (R x1 x2) S) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rrsub ([x2] R x1 x2) (N2 x1) (R' x1)) + -> ({x2} rmsub ([x1] R x1 x2) N1 (MR` x2)) +%% + -> rmsub ([x1] R' x1) N1 M`' + -> sub ([x2] MR` x2) N2` M`' -> type. +%mode rr-rm-permute-es' +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +%% sub-permute + +-rrrm : sub-permute-es T1 T2 %% M = (at R) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/at (DofR x1 x2 : at-ofes (G x1 x2) (R x1 x2) o)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/rr (DrrsubN2M x1 : rrsub ([x2] R x1 x2) (N2 x1) (R' x1))) + ([x2] sub/rm (DrmsubN1M x2 : rmsub ([x1] R x1 x2) N1 (at (R` x2)))) +%% + (sub/rm Dsub21) + Dsub12 +%% + <- rr-rm-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofR + DsubN1N2 DrrsubN2M DrmsubN1M + (Dsub21 : rmsub ([x1] R' x1) N1 (at R`')) + (Dsub12 : sub ([x2] (at (R` x2))) N2` (at R`')). + +-rmrr : sub-permute-es T1 T2 %% M = (at R) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/at (DofR x1 x2 : at-ofes (G x1 x2) (R x1 x2) o)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/rm (DrmsubN2M x1 : rmsub ([x2] R x1 x2) (N2 x1) (at (R' x1)))) + ([x2] sub/rr (DrrsubN1M x2 : rrsub ([x1] R x1 x2) N1 (R` x2))) +%% + Dsub21 + (sub/rm Dsub12) +%% + <- rm-rr-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofR + DsubN1N2 DrmsubN2M DrrsubN1M + (Dsub21 : sub ([x1] (at (R' x1))) N1 (at R`')) + (Dsub12 : rmsub ([x2] R` x2) N2` (at R`')). + +-rrrr : sub-permute-es T1 T2 %% M = (at R) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/at (DofR x1 x2 : at-ofes (G x1 x2) (R x1 x2) o)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/rr (DrrsubN2M x1 : rrsub ([x2] R x1 x2) (N2 x1) (R' x1))) + ([x2] sub/rr (DrrsubN1M x2 : rrsub ([x1] R x1 x2) N1 (R` x2))) +%% + (sub/rr Drrsub21) + (sub/rr Drrsub12) +%% + <- rr-rr-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofR + DsubN1N2 DrrsubN2M DrrsubN1M + (Drrsub21 : rrsub ([x1] R' x1) N1 R`') + (Drrsub12 : rrsub ([x2] R` x2) N2` R`'). + +-rmrm : sub-permute-es T1 T2 %% M = (at R) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/at (DofR x1 x2 : at-ofes (G x1 x2) (R x1 x2) o)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/rm (DrmsubN2M x1 : rmsub ([x2] R x1 x2) (N2 x1) (at (R' x1)))) + ([x2] sub/rm (DrmsubN1M x2 : rmsub ([x1] R x1 x2) N1 (at (R` x2)))) +%% + Dsub21 + Dsub12 +%% + <- ({x2} + rmsub-headvar (DrmsubN1M x2) + (Dheadvar1 x2 : headvar ([x1] R x1 x2))) + <- ({x1} + rmsub-headvar (DrmsubN2M x1) + (Dheadvar2 x1 : headvar ([x2] R x1 x2))) + <- headvar-contra ([x2] Dheadvar1 x2) ([x1] Dheadvar2 x1) Dfalse + <- false-implies-sub Dfalse + (Dsub21 : sub ([x1] (at (R' x1))) N1 (at R`')) + <- false-implies-sub' Dfalse + (Dsub12 : sub ([x2] (at (R` x2))) N2` (at R`')). + +-lam : sub-permute-es T1 T2 %% M = (lam [y] N y) : (arr S1 S2) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/lam + ([y] DofM x1 x2 y : ofes (scons (G x1 x2) y S1) (N x1 x2 y) S2)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/lam + ([y] DsubN2N x1 y + : sub ([x2] N x1 x2 y) (N2 x1) (N' x1 y)) + : sub ([x2] lam [y] N x1 x2 y) (N2 x1) (lam [y] N' x1 y)) + ([x2] sub/lam + ([y] DsubN1N x2 y + : sub ([x1] N x1 x2 y) N1 (N` x2 y)) + : sub ([x1] lam [y] N x1 x2 y) N1 (lam [y] N` x2 y)) +%% + (sub/lam Dsub21) + (sub/lam Dsub12) +%% + <- ({x1} {d1} + {x2} {d2} + extend-sordered S1 (Dord x1 d1 x2 d2) _ + ([y] [e:isvar y J] Dord' x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S1))) + <- ({x1} {x2} {y} + weaken-slookup (Dlook1 x1 x2) y S1 + (Dlook1' x1 x2 y + : slookup (scons (G x1 x2) y S1) x1 T1)) + <- ({x1} {x2} {y} + weaken-slookup (Dlook2 x1 x2) y S1 + (Dlook2' x1 x2 y + : slookup (scons (G x1 x2) y S1) x2 T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S1 + (DofN1' x1 x2 y + : ofes (scons (G x1 x2) y S1) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S1 + (DofN2' x1 x2 y + : ofes (scons (G x1 x2) y S1) (N2 x1) T2)) + <- ({y} {e} + sub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord' x1 d1 x2 d2 y e) + ([x1] [x2] Dlook1' x1 x2 y) + ([x1] [x2] Dlook2' x1 x2 y) + ([x1] [x2] DofN1' x1 x2 y) + ([x1] [x2] DofN2' x1 x2 y) + ([x1] [x2] DofM x1 x2 y) + DsubN1N2 ([x1] DsubN2N x1 y) ([x2] DsubN1N x2 y) + (Dsub21 y : sub ([x1] N' x1 y) N1 (N`' y)) + (Dsub12 y : sub ([x2] N` x2 y) N2` (N`' y))). + +%% sub-permute' + +-rrrm : sub-permute-es' T1 T2 %% M = (at R) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/at (DofR x1 x2 : at-ofes (G x1 x2) (R x1 x2) o)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/rr (DrrsubN2M x1 : rrsub ([x2] R x1 x2) (N2 x1) (R' x1))) + ([x2] sub/rm (DrmsubN1M x2 : rmsub ([x1] R x1 x2) N1 (at (R` x2)))) +%% + (sub/rm Dsub21) + Dsub12 +%% + <- rr-rm-permute-es' T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofR + DsubN1N2 DrrsubN2M DrmsubN1M + (Dsub21 : rmsub ([x1] R' x1) N1 (at R`')) + (Dsub12 : sub ([x2] (at (R` x2))) N2` (at R`')). + +-rmrr : sub-permute-es' T1 T2 %% M = (at R) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/at (DofR x1 x2 : at-ofes (G x1 x2) (R x1 x2) o)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/rm (DrmsubN2M x1 : rmsub ([x2] R x1 x2) (N2 x1) (at (R' x1)))) + ([x2] sub/rr (DrrsubN1M x2 : rrsub ([x1] R x1 x2) N1 (R` x2))) +%% + Dsub21 + (sub/rm Dsub12) +%% + <- rm-rr-permute-es' T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofR + DsubN1N2 DrmsubN2M DrrsubN1M + (Dsub21 : sub ([x1] (at (R' x1))) N1 (at R`')) + (Dsub12 : rmsub ([x2] R` x2) N2` (at R`')). + +-rrrr : sub-permute-es' T1 T2 %% M = (at R) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/at (DofR x1 x2 : at-ofes (G x1 x2) (R x1 x2) o)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/rr (DrrsubN2M x1 : rrsub ([x2] R x1 x2) (N2 x1) (R' x1))) + ([x2] sub/rr (DrrsubN1M x2 : rrsub ([x1] R x1 x2) N1 (R` x2))) +%% + (sub/rr Drrsub21) + (sub/rr Drrsub12) +%% + <- rr-rr-permute-es' T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofR + DsubN1N2 DrrsubN2M DrrsubN1M + (Drrsub21 : rrsub ([x1] R' x1) N1 R`') + (Drrsub12 : rrsub ([x2] R` x2) N2` R`'). + +-rmrm : sub-permute-es' T1 T2 %% M = (at R) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/at (DofR x1 x2 : at-ofes (G x1 x2) (R x1 x2) o)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/rm (DrmsubN2M x1 : rmsub ([x2] R x1 x2) (N2 x1) (at (R' x1)))) + ([x2] sub/rm (DrmsubN1M x2 : rmsub ([x1] R x1 x2) N1 (at (R` x2)))) +%% + Dsub21 + Dsub12 +%% + <- ({x2} + rmsub-headvar (DrmsubN1M x2) + (Dheadvar1 x2 : headvar ([x1] R x1 x2))) + <- ({x1} + rmsub-headvar (DrmsubN2M x1) + (Dheadvar2 x1 : headvar ([x2] R x1 x2))) + <- headvar-contra ([x2] Dheadvar1 x2) ([x1] Dheadvar2 x1) Dfalse + <- false-implies-sub Dfalse + (Dsub21 : sub ([x1] (at (R' x1))) N1 (at R`')) + <- false-implies-sub' Dfalse + (Dsub12 : sub ([x2] (at (R` x2))) N2` (at R`')). + +-lam : sub-permute-es' T1 T2 %% M = (lam [y] N y) : (arr S1 S2) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] ofes/lam + ([y] DofM x1 x2 y : ofes (scons (G x1 x2) y S1) (N x1 x2 y) S2)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] sub/lam + ([y] DsubN2N x1 y + : sub ([x2] N x1 x2 y) (N2 x1) (N' x1 y)) + : sub ([x2] lam [y] N x1 x2 y) (N2 x1) (lam [y] N' x1 y)) + ([x2] sub/lam + ([y] DsubN1N x2 y + : sub ([x1] N x1 x2 y) N1 (N` x2 y)) + : sub ([x1] lam [y] N x1 x2 y) N1 (lam [y] N` x2 y)) +%% + (sub/lam Dsub21) + (sub/lam Dsub12) +%% + <- ({x1} {d1} + {x2} {d2} + extend-sordered S1 (Dord x1 d1 x2 d2) _ + ([y] [e:isvar y J] Dord' x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S1))) + <- ({x1} {x2} {y} + weaken-slookup (Dlook1 x1 x2) y S1 + (Dlook1' x1 x2 y + : slookup (scons (G x1 x2) y S1) x1 T1)) + <- ({x1} {x2} {y} + weaken-slookup (Dlook2 x1 x2) y S1 + (Dlook2' x1 x2 y + : slookup (scons (G x1 x2) y S1) x2 T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S1 + (DofN1' x1 x2 y + : ofes (scons (G x1 x2) y S1) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S1 + (DofN2' x1 x2 y + : ofes (scons (G x1 x2) y S1) (N2 x1) T2)) + <- ({y} {e} + sub-permute-es' T1 T2 + ([x1] [d1] [x2] [d2] Dord' x1 d1 x2 d2 y e) + ([x1] [x2] Dlook1' x1 x2 y) + ([x1] [x2] Dlook2' x1 x2 y) + ([x1] [x2] DofN1' x1 x2 y) + ([x1] [x2] DofN2' x1 x2 y) + ([x1] [x2] DofM x1 x2 y) + DsubN1N2 ([x1] DsubN2N x1 y) ([x2] DsubN1N x2 y) + (Dsub21 y : sub ([x1] N' x1 y) N1 (N`' y)) + (Dsub12 y : sub ([x2] N` x2 y) N2` (N`' y))). + +%% rr-rr-permute + +-closed : rr-rr-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 : at-ofes (G x1 x2) (R x1) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] rrsub/closed : rrsub ([x2] R x1) (N2 x1) (R x1)) + ([x2] DsubN1R x2 : rrsub ([x1] R x1) N1 (R` x2)) +%% + (DsubN1R' aca) + DsubN2R` +%% + <- rrsub-closed ([x2] DsubN1R x2) + ([x2] Deq x2 : atm-eq (R` x2) R``) + <- ({x2} + rrsub-compat ([_] atm-eq/i) tm-eq/i (Deq x2) (DsubN1R x2) + (DsubN1R' x2 : rrsub ([x1] R x1) N1 R``)) + <- ({x2} + atm-eq-sym (Deq x2) + (Deq' x2 : atm-eq R`` (R` x2))) + <- rrsub-compat ([x2] Deq' x2) tm-eq/i atm-eq/i + (rrsub/closed : rrsub ([x2] R``) N2` R``) + (DsubN2R` : rrsub ([x2] R` x2) N2` R``). + +-appclosed : rr-rr-permute-es T1 T2 % R = Q M + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 : at-ofes (G x1 x2) (app (Q x2) (M x2)) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] rrsub/app + (DsubN2M x1 : sub ([x2] M x2) (N2 x1) (M' x1)) + (DsubN2Q x1 : rrsub ([x2] Q x2) (N2 x1) (Q' x1))) + ([x2] rrsub/closed + : rrsub ([x1] app (Q x2) (M x2)) N1 (app (Q x2) (M x2))) +%% + (rrsub/app Dsub21M Dsub21Q) + (rrsub/app Dsub12M Dsub12Q) +%% + <- ({x2} + sub-absent (M x2) N1 + (DsubN1M x2 : sub ([x1] M x2) N1 (M x2))) + <- ({x1} {d1} {x2} {d2} + app-ofes-invert (Dord x1 d1 x2 d2) (DofR x1 x2) + (DofQ x1 x2 : at-ofes (G x1 x2) (Q x2) (arrow S2 S)) + (DofM x1 x2 : ofes (G x1 x2) (M x2) S2)) + <- rr-rr-permute-es T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofQ + DsubN1N2 DsubN2Q ([_] rrsub/closed) + (Dsub21Q : rrsub ([x1] Q' x1) N1 Q`') + (Dsub12Q : rrsub ([x2] Q x2) N2` Q`') + <- sub-permute-es T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofM + DsubN1N2 DsubN2M DsubN1M + (Dsub21M : sub ([x1] M' x1) N1 M`') + (Dsub12M : sub ([x2] M x2) N2` M`'). + + +-app : rr-rr-permute-es T1 T2 %% R = (app Q M) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 + : at-ofes (G x1 x2) (app (Q x1 x2) (M x1 x2)) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + rrsub/app + (DsubN2M x1 : sub ([x2] M x1 x2) (N2 x1) (M' x1)) + (DsubN2Q x1 : rrsub ([x2] Q x1 x2) (N2 x1) (Q' x1)) + : rrsub ([x2] app (Q x1 x2) (M x1 x2)) (N2 x1) + (app (Q' x1) (M' x1))) + ([x2] + rrsub/app + (DsubN1M x2 : sub ([x1] M x1 x2) N1 (M` x2)) + (DsubN1Q x2 : rrsub ([x1] Q x1 x2) N1 (Q` x2)) + : rrsub ([x1] app (Q x1 x2) (M x1 x2)) N1 + (app (Q` x2) (M` x2))) +%% + (rrsub/app Dsub21M Dsub21Q) + (rrsub/app Dsub12M Dsub12Q) +%% + <- ({x1} {d1} {x2} {d2} + app-ofes-invert (Dord x1 d1 x2 d2) (DofR x1 x2) + (DofQ x1 x2 : at-ofes (G x1 x2) (Q x1 x2) (arrow S2 S)) + (DofM x1 x2 : ofes (G x1 x2) (M x1 x2) S2)) + <- rr-rr-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofQ + DsubN1N2 DsubN2Q DsubN1Q + (Dsub21Q : rrsub ([x1] Q' x1) N1 Q`') + (Dsub12Q : rrsub ([x2] Q` x2) N2` Q`') + <- sub-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofM + DsubN1N2 DsubN2M DsubN1M + (Dsub21M : sub ([x1] M' x1) N1 M`') + (Dsub12M : sub ([x2] M` x2) N2` M`'). + +%% rr-rr-permute' + +-closed : rr-rr-permute-es' T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 : at-ofes (G x1 x2) (R x1) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] rrsub/closed : rrsub ([x2] R x1) (N2 x1) (R x1)) + ([x2] DsubN1R x2 : rrsub ([x1] R x1) N1 (R` x2)) +%% + (DsubN1R' aca) + DsubN2R` +%% + <- rrsub-closed ([x2] DsubN1R x2) + ([x2] Deq x2 : atm-eq (R` x2) R``) + <- ({x2} + rrsub-compat ([_] atm-eq/i) tm-eq/i (Deq x2) (DsubN1R x2) + (DsubN1R' x2 : rrsub ([x1] R x1) N1 R``)) + <- ({x2} + atm-eq-sym (Deq x2) + (Deq' x2 : atm-eq R`` (R` x2))) + <- rrsub-compat ([x2] Deq' x2) tm-eq/i atm-eq/i + (rrsub/closed : rrsub ([x2] R``) N2` R``) + (DsubN2R` : rrsub ([x2] R` x2) N2` R``). + +-appclosed : rr-rr-permute-es' T1 T2 % R = Q M + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 : at-ofes (G x1 x2) (app (Q x2) (M x2)) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] rrsub/app + (DsubN2M x1 : sub ([x2] M x2) (N2 x1) (M' x1)) + (DsubN2Q x1 : rrsub ([x2] Q x2) (N2 x1) (Q' x1))) + ([x2] rrsub/closed + : rrsub ([x1] app (Q x2) (M x2)) N1 (app (Q x2) (M x2))) +%% + (rrsub/app Dsub21M Dsub21Q) + (rrsub/app Dsub12M Dsub12Q) +%% + <- ({x2} + sub-absent (M x2) N1 + (DsubN1M x2 : sub ([x1] M x2) N1 (M x2))) + <- ({x1} {d1} {x2} {d2} + app-ofes-invert (Dord x1 d1 x2 d2) (DofR x1 x2) + (DofQ x1 x2 : at-ofes (G x1 x2) (Q x2) (arrow S2 S)) + (DofM x1 x2 : ofes (G x1 x2) (M x2) S2)) + <- rr-rr-permute-es' T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofQ + DsubN1N2 DsubN2Q ([_] rrsub/closed) + (Dsub21Q : rrsub ([x1] Q' x1) N1 Q`') + (Dsub12Q : rrsub ([x2] Q x2) N2` Q`') + <- sub-permute-es' T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofM + DsubN1N2 DsubN2M DsubN1M + (Dsub21M : sub ([x1] M' x1) N1 M`') + (Dsub12M : sub ([x2] M x2) N2` M`'). + + +-app : rr-rr-permute-es' T1 T2 %% R = (app Q M) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 + : at-ofes (G x1 x2) (app (Q x1 x2) (M x1 x2)) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + rrsub/app + (DsubN2M x1 : sub ([x2] M x1 x2) (N2 x1) (M' x1)) + (DsubN2Q x1 : rrsub ([x2] Q x1 x2) (N2 x1) (Q' x1)) + : rrsub ([x2] app (Q x1 x2) (M x1 x2)) (N2 x1) + (app (Q' x1) (M' x1))) + ([x2] + rrsub/app + (DsubN1M x2 : sub ([x1] M x1 x2) N1 (M` x2)) + (DsubN1Q x2 : rrsub ([x1] Q x1 x2) N1 (Q` x2)) + : rrsub ([x1] app (Q x1 x2) (M x1 x2)) N1 + (app (Q` x2) (M` x2))) +%% + (rrsub/app Dsub21M Dsub21Q) + (rrsub/app Dsub12M Dsub12Q) +%% + <- ({x1} {d1} {x2} {d2} + app-ofes-invert (Dord x1 d1 x2 d2) (DofR x1 x2) + (DofQ x1 x2 : at-ofes (G x1 x2) (Q x1 x2) (arrow S2 S)) + (DofM x1 x2 : ofes (G x1 x2) (M x1 x2) S2)) + <- rr-rr-permute-es' T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofQ + DsubN1N2 DsubN2Q DsubN1Q + (Dsub21Q : rrsub ([x1] Q' x1) N1 Q`') + (Dsub12Q : rrsub ([x2] Q` x2) N2` Q`') + <- sub-permute-es' T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofM + DsubN1N2 DsubN2M DsubN1M + (Dsub21M : sub ([x1] M' x1) N1 M`') + (Dsub12M : sub ([x2] M` x2) N2` M`'). + + +%% rr-rm-permute %% + +-closed : rr-rm-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 : at-ofes (G x1 x2) (R x1) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + rrsub/closed : rrsub ([x2] R x1) (N2 x1) (R x1)) + ([x2] DsubN1R x2 : rmsub ([x1] R x1) N1 (MR` x2)) +%% + (DsubN1R' aca) + DsubN2MR` +%% + <- rmsub-closed ([x2] DsubN1R x2) + ([x2] Deq x2 : tm-eq (MR` x2) MR``) + <- ({x2} + rmsub-compat ([_] atm-eq/i) tm-eq/i (Deq x2) (DsubN1R x2) + (DsubN1R' x2 : rmsub ([x1] R x1) N1 MR``)) + <- ({x2} + tm-eq-sym (Deq x2) + (Deq' x2 : tm-eq MR`` (MR` x2))) + <- sub-absent MR`` N2` + (DsubN2`MR`` : sub ([_] MR``) N2` MR``) + <- sub-compat ([x2] Deq' x2) tm-eq/i tm-eq/i DsubN2`MR`` + (DsubN2MR` : sub ([x2] MR` x2) N2` MR``). + +-app : rr-rm-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 + : at-ofes (G x1 x2) (app (Q x1 x2) (M x1 x2)) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + rrsub/app + (DsubN2M x1 : sub ([x2] M x1 x2) (N2 x1) (M' x1)) + (DsubN2Q x1 : rrsub ([x2] Q x1 x2) (N2 x1) (Q' x1)) + : rrsub + ([x2] app (Q x1 x2) (M x1 x2)) + (N2 x1) + (app (Q' x1) (M' x1))) + ([x2] + rmsub/app + (DsubM`O x2 : sub ([y] O x2 y) (M` x2) (O` x2)) + (DsubN1M x2 : sub ([x1] M x1 x2) N1 (M` x2)) + (DsubN1Q x2 : rmsub ([x1] Q x1 x2) N1 (lam [y] O x2 y)) + : rmsub ([x1] app (Q x1 x2) (M x1 x2)) N1 (O` x2)) +%% + (rmsub/app (Dsub12O' aca) Dsub21M Dsub21Q) + (Dsub21O'' aca) +%% + <- ({x1} {d1} {x2} {d2} + app-ofes-invert (Dord x1 d1 x2 d2) (DofR x1 x2) + (DofQ x1 x2 : at-ofes (G x1 x2) (Q x1 x2) (arrow S2 S)) + (DofM x1 x2 : ofes (G x1 x2) (M x1 x2) S2)) + %% IH on Q + <- rr-rm-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 + DofQ DsubN1N2 DsubN2Q DsubN1Q + (Dsub21Q : rmsub ([x1] Q' x1) N1 (lam [y] O' y)) + (sub/lam + ([y] DsubN2`O y : sub ([x2] O x2 y) N2` (O' y)) + : sub ([x2] lam [y] O x2 y) N2` (lam [y] O' y)) + %% IH on M + <- sub-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 + DofM DsubN1N2 DsubN2M DsubN1M + (Dsub21M : sub ([x1] M' x1) N1 M`') + (Dsub12M : sub ([x2] M` x2) N2` M`') + %% Weaken a bunch of stuff with the lam-bound var + <- ({x1} {d1:isvar x1 I1} + {x2} {d2:isvar x2 I2} + extend-sordered S2 (Dord x1 d1 x2 d2) J + ([y] [e : isvar y J] + Dord_y x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S2))) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S2 + (DofN1_y x1 x2 y : ofes (scons (G x1 x2) y S2) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S2 + (DofN2_y x1 x2 y : ofes (scons (G x1 x2) y S2) (N2 x1) T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofM x1 x2) y S2 + (DofM_y x1 x2 y : ofes (scons (G x1 x2) y S2) (M x1 x2) S2)) + %% Get typing derivations for the substitutions + <- ({x2} {d2:isvar x2 I2} {y} {e:isvar y J} + subst-es + ([x1] [d1] Dord_y x1 d1 x2 d2 y e) + ([x1] slookup/miss (Dlook1 x1 x2)) + ([x1] DofN1_y x1 x2 y) + ([x1] DofN2_y x1 x2 y) + DsubN1N2 + ([x1] DofN2` x1 x2 y : ofes (scons (G x1 x2) y S2) N2` T2)) + <- ({x2} {d2:isvar x2 I2} {y} {e:isvar y J} + subst-es + ([x1] [d1] Dord_y x1 d1 x2 d2 y e) + ([x1] slookup/miss (Dlook1 x1 x2)) + ([x1] DofN1_y x1 x2 y) + ([x1] DofM_y x1 x2 y) + (DsubN1M x2) + ([x1] DofM` x1 x2 y : ofes (scons (G x1 x2) y S2) (M` x2) S2)) + %% Get typing derivation for O + <- ({x2} {d2:isvar x2 I2} + rmsubst-es + ([x1] [d1] Dord x1 d1 x2 d2) + ([x1] Dlook1 x1 x2) + ([x1] DofN1 x1 x2) + ([x1] DofQ x1 x2) + (DsubN1Q x2) + ([x1] ofes/lam + ([y] DofO x1 x2 y : ofes (scons (G x1 x2) y S2) (O x2 y) S))) + %% Convince twelf that S2 <= T2 + <- ({x2} + rmsub-headvar (DsubN1Q x2) + (Dheadvar x2 : headvar ([x1] Q x1 x2))) + <- ({x2} {d2:isvar x2 I2} + headvar-stp-size + ([x1] [d1] Dord x1 d1 x2 d2) + ([x1] Dlook1 x1 x2) + ([x1] DofQ x1 x2) + (Dheadvar x2) + (Dleq : stp-leq (arrow S2 S) T1)) + <- employ-stp-leq (arrow S2 S) T1 Dleq + %% [N2`/x2] [M`/y] O == [[N2`/x2]M`/y] [N2`/x2] O + <- ({x1} {d1:isvar x1 I1} + sub-permute-es' T2 S2 + ([x2] [d2] [y] [e] Dord_y x1 d1 x2 d2 y e) + ([x2] [y] slookup/miss (Dlook2 x1 x2)) + ([x2] [y] slookup/hit) + ([x2] [y] DofN2` x1 x2 y) + ([x2] [y] DofM` x1 x2 y) + ([x2] [y] DofO x1 x2 y) + Dsub12M DsubM`O DsubN2`O + (Dsub21O x1 : sub ([x2] O` x2) N2` (O`' x1)) + (Dsub12O x1 : sub ([y] O' y) M`' (O`' x1))) + %% Clean up the extraneous variable + <- sub-closed ([x1] Dsub21O x1) + ([x1] Deq1 x1 : tm-eq (O`' x1) O`'1) + <- sub-closed ([x1] Dsub12O x1) + ([x1] Deq2 x1 : tm-eq (O`' x1) O`'2) + <- ({x1} + tm-eq-fun (Deq1 x1) (Deq2 x1) + (Deq' x1 : tm-eq O`'1 O`'2)) + <- ({x1} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq1 x1) (Dsub21O x1) + (Dsub21O' x1 : sub ([x2] O` x2) N2` O`'1)) + <- ({x1} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq2 x1) (Dsub12O x1) + (Dsub12O' x1 : sub ([y] O' y) M`' O`'2)) + <- ({x1} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq' x1) (Dsub21O' x1) + (Dsub21O'' x1 : sub ([x2] O` x2) N2` O`'2)). + + +%% rr-rm-permute' %% + +-closed : rr-rm-permute-es' T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 : at-ofes (G x1 x2) (R x1) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + rrsub/closed : rrsub ([x2] R x1) (N2 x1) (R x1)) + ([x2] DsubN1R x2 : rmsub ([x1] R x1) N1 (MR` x2)) +%% + (DsubN1R' aca) + DsubN2MR` +%% + <- rmsub-closed ([x2] DsubN1R x2) + ([x2] Deq x2 : tm-eq (MR` x2) MR``) + <- ({x2} + rmsub-compat ([_] atm-eq/i) tm-eq/i (Deq x2) (DsubN1R x2) + (DsubN1R' x2 : rmsub ([x1] R x1) N1 MR``)) + <- ({x2} + tm-eq-sym (Deq x2) + (Deq' x2 : tm-eq MR`` (MR` x2))) + <- sub-absent MR`` N2` + (DsubN2`MR`` : sub ([_] MR``) N2` MR``) + <- sub-compat ([x2] Deq' x2) tm-eq/i tm-eq/i DsubN2`MR`` + (DsubN2MR` : sub ([x2] MR` x2) N2` MR``). + +-app : rr-rm-permute-es' T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 + : at-ofes (G x1 x2) (app (Q x1 x2) (M x1 x2)) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + rrsub/app + (DsubN2M x1 : sub ([x2] M x1 x2) (N2 x1) (M' x1)) + (DsubN2Q x1 : rrsub ([x2] Q x1 x2) (N2 x1) (Q' x1)) + : rrsub + ([x2] app (Q x1 x2) (M x1 x2)) + (N2 x1) + (app (Q' x1) (M' x1))) + ([x2] + rmsub/app + (DsubM`O x2 : sub ([y] O x2 y) (M` x2) (O` x2)) + (DsubN1M x2 : sub ([x1] M x1 x2) N1 (M` x2)) + (DsubN1Q x2 : rmsub ([x1] Q x1 x2) N1 (lam [y] O x2 y)) + : rmsub ([x1] app (Q x1 x2) (M x1 x2)) N1 (O` x2)) +%% + (rmsub/app (Dsub12O aca) Dsub21M Dsub21Q) + (Dsub21O aca) +%% + <- ({x1} {d1} {x2} {d2} + app-ofes-invert (Dord x1 d1 x2 d2) (DofR x1 x2) + (DofQ x1 x2 : at-ofes (G x1 x2) (Q x1 x2) (arrow S2 S)) + (DofM x1 x2 : ofes (G x1 x2) (M x1 x2) S2)) + %% IH on Q + <- rr-rm-permute-es' T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 + DofQ DsubN1N2 DsubN2Q DsubN1Q + (Dsub21Q : rmsub ([x1] Q' x1) N1 (lam [y] O' y)) + (sub/lam + ([y] DsubN2`O y : sub ([x2] O x2 y) N2` (O' y)) + : sub ([x2] lam [y] O x2 y) N2` (lam [y] O' y)) + %% IH on M + <- sub-permute-es' T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 + DofM DsubN1N2 DsubN2M DsubN1M + (Dsub21M : sub ([x1] M' x1) N1 M`') + (Dsub12M : sub ([x2] M` x2) N2` M`') + %% Weaken a bunch of stuff with the lam-bound var + <- ({x1} {d1:isvar x1 I1} + {x2} {d2:isvar x2 I2} + extend-sordered S2 (Dord x1 d1 x2 d2) J + ([y] [e : isvar y J] + Dord_y x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S2))) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S2 + (DofN1_y x1 x2 y : ofes (scons (G x1 x2) y S2) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S2 + (DofN2_y x1 x2 y : ofes (scons (G x1 x2) y S2) (N2 x1) T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofM x1 x2) y S2 + (DofM_y x1 x2 y : ofes (scons (G x1 x2) y S2) (M x1 x2) S2)) + %% Get typing derivations for the substitutions + <- ({x2} {d2:isvar x2 I2} {y} {e:isvar y J} + subst-es + ([x1] [d1] Dord_y x1 d1 x2 d2 y e) + ([x1] slookup/miss (Dlook1 x1 x2)) + ([x1] DofN1_y x1 x2 y) + ([x1] DofN2_y x1 x2 y) + DsubN1N2 + ([x1] DofN2` x1 x2 y : ofes (scons (G x1 x2) y S2) N2` T2)) + <- ({x2} {d2:isvar x2 I2} {y} {e:isvar y J} + subst-es + ([x1] [d1] Dord_y x1 d1 x2 d2 y e) + ([x1] slookup/miss (Dlook1 x1 x2)) + ([x1] DofN1_y x1 x2 y) + ([x1] DofM_y x1 x2 y) + (DsubN1M x2) + ([x1] DofM` x1 x2 y : ofes (scons (G x1 x2) y S2) (M` x2) S2)) + %% Get typing derivation for O + <- ({x2} {d2:isvar x2 I2} + rmsubst-es + ([x1] [d1] Dord x1 d1 x2 d2) + ([x1] Dlook1 x1 x2) + ([x1] DofN1 x1 x2) + ([x1] DofQ x1 x2) + (DsubN1Q x2) + ([x1] ofes/lam + ([y] DofO x1 x2 y : ofes (scons (G x1 x2) y S2) (O x2 y) S))) + %% Convince twelf that S2 <= T2 + <- ({x2} + rmsub-headvar (DsubN1Q x2) + (Dheadvar x2 : headvar ([x1] Q x1 x2))) + <- ({x2} {d2:isvar x2 I2} + headvar-stp-size + ([x1] [d1] Dord x1 d1 x2 d2) + ([x1] Dlook1 x1 x2) + ([x1] DofQ x1 x2) + (Dheadvar x2) + (Dleq : stp-leq (arrow S2 S) T1)) + <- employ-stp-leq (arrow S2 S) T1 Dleq + %% [N2`/x2] [M`/y] O == [[N2`/x2]M`/y] [N2`/x2] O + <- ({x1} {d1:isvar x1 I1} + sub-permute-es T2 S2 + ([x2] [d2] [y] [e] Dord_y x1 d1 x2 d2 y e) + ([x2] [y] slookup/miss (Dlook2 x1 x2)) + ([x2] [y] slookup/hit) + ([x2] [y] DofN2` x1 x2 y) + ([x2] [y] DofM` x1 x2 y) + ([x2] [y] DofO x1 x2 y) + Dsub12M DsubM`O DsubN2`O + (Dsub21O x1 : sub ([x2] O` x2) N2` (O`' x1)) + (Dsub12O x1 : sub ([y] O' y) M`' (O`' x1))) + %% Clean up the extraneous variable + <- sub-closed ([x1] Dsub21O x1) + ([x1] Deq1 x1 : tm-eq (O`' x1) O`'1) + <- sub-closed ([x1] Dsub12O x1) + ([x1] Deq2 x1 : tm-eq (O`' x1) O`'2) + <- ({x1} + tm-eq-fun (Deq1 x1) (Deq2 x1) + (Deq' x1 : tm-eq O`'1 O`'2)) + <- ({x1} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq1 x1) (Dsub21O x1) + (Dsub21O' x1 : sub ([x2] O` x2) N2` O`'1)) + <- ({x1} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq2 x1) (Dsub12O x1) + (Dsub12O' x1 : sub ([y] O' y) M`' O`'2)) + <- ({x1} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq' x1) (Dsub21O' x1) + (Dsub21O'' x1 : sub ([x2] O` x2) N2` O`'2)). + +%% rm-rr-permute %% + +-var : rm-rr-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 + : at-ofes (G x1 x2) x2 S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] rmsub/var : rmsub ([x2] x2) (N2 x1) (N2 x1)) + ([x2] rrsub/closed : rrsub ([x1] x2) N1 x2) +%% + DsubN1N2 + rmsub/var. + +-appclosed : rm-rr-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 : at-ofes (G x1 x2) (app (Q x1 x2) (M x1 x2)) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] rmsub/app + (DsubM'O x1 : sub ([y] O x1 y) (M' x1) (O' x1)) + (DsubN2M x1 : sub ([x2] M x1 x2) (N2 x1) (M' x1)) + (DsubN2Q x1 : rmsub ([x2] Q x1 x2) (N2 x1) (lam [y] O x1 y))) + ([x2] DsubN1R x2 + : rrsub ([x1] app (Q x1 x2) (M x1 x2)) N1 (app (Q` x2) (M` x2))) +%% + (Dsub21O'' aca) + (rmsub/app (Dsub12O' aca) DsubN2`M` Dsub12Q) +%% + %% Invert to get typing and substitutions for applicands + <- ({x2} + app-rrsub-invert (DsubN1R x2) + (DsubN1Q x2 : rrsub ([x1] Q x1 x2) N1 (Q` x2)) + (DsubN1M x2 : sub ([x1] M x1 x2) N1 (M` x2))) + <- ({x1} {d1} {x2} {d2} + app-ofes-invert (Dord x1 d1 x2 d2) (DofR x1 x2) + (DofQ x1 x2 : at-ofes (G x1 x2) (Q x1 x2) (arrow S2 S)) + (DofM x1 x2 : ofes (G x1 x2) (M x1 x2) S2)) + %% By IH(3), [N1/x1] \y.O = [N2`/x2] Q` = \y.O` + <- rm-rr-permute-es T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofQ + DsubN1N2 DsubN2Q DsubN1Q + (sub/lam + ([y] DsubN1O y : sub ([x1] O x1 y) N1 (O` y)) + : sub ([x1] lam [y] O x1 y) N1 (lam [y] O` y)) + (Dsub12Q : rmsub ([x2] Q` x2) N2` (lam [y] O` y)) + %% By IH(1), [N1/x1] M' = [N2`/x2] M` = M`' + <- sub-permute-es T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofM + DsubN1N2 DsubN2M DsubN1M + (DsubN1M' : sub ([x1] M' x1) N1 M`') + (DsubN2`M` : sub ([x2] M` x2) N2` M`') + %% Weaken everything with y + <- ({x1} {d1} + {x2} {d2} + extend-sordered S2 (Dord x1 d1 x2 d2) J + ([y] [e:isvar y J] + Dord_y x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S2))) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S2 + (DofN1_y x1 x2 y : ofes (scons (G x1 x2) y S2) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S2 + (DofN2_y x1 x2 y : ofes (scons (G x1 x2) y S2) (N2 x1) T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofM x1 x2) y S2 + (DofM_y x1 x2 y : ofes (scons (G x1 x2) y S2) (M x1 x2) S2)) + %% Get typing derivations for the substitutions + <- ({x1} {d1:isvar x1 I1} {y} {e:isvar y J} + subst-es + ([x2] [d2] Dord_y x1 d1 x2 d2 y e) + ([x2] slookup/miss (Dlook2 x1 x2)) + ([x2] DofN2_y x1 x2 y) + ([x2] DofM_y x1 x2 y) + (DsubN2M x1) + ([x2] DofM'_y x1 x2 y : ofes (scons (G x1 x2) y S2) (M' x1) S2)) + %% Get typing derivation for O + <- ({x1} {d1:isvar x1 I1} + rmsubst-es + ([x2] [d2] Dord x1 d1 x2 d2) + ([x2] Dlook2 x1 x2) + ([x2] DofN2 x1 x2) + ([x2] DofQ x1 x2) + (DsubN2Q x1) + ([x2] ofes/lam + ([y] DofO x1 x2 y : ofes (scons (G x1 x2) y S2) (O x1 y) S))) + %% Convince twelf that S2 <= T2 + <- ({x1} + rmsub-headvar (DsubN2Q x1) + (Dheadvar x1 : headvar ([x2] Q x1 x2))) + <- ({x1} {d1:isvar x1 I1} + headvar-stp-size + ([x2] [d2] Dord x1 d1 x2 d2) + ([x2] Dlook2 x1 x2) + ([x2] DofQ x1 x2) + (Dheadvar x1) + (Dleq : stp-leq (arrow S2 S) T2)) + <- employ-stp-leq (arrow S2 S) T2 Dleq + %% By IH(1), [N1/x1]O' = [M`'/y] O` = O`' + <- ({x2} {d2:isvar x2 I2} + sub-permute-es T1 S2 + ([x1] [d1] [y] [e] Dord_y x1 d1 x2 d2 y e) + ([x1] [y] slookup/miss (Dlook1 x1 x2)) + ([x1] [y] slookup/hit) + ([x1] [y] DofN1_y x1 x2 y) + ([x1] [y] DofM'_y x1 x2 y) + ([x1] [y] DofO x1 x2 y) + DsubN1M' DsubM'O DsubN1O + (Dsub21O x2 : sub ([x1] O' x1) N1 (O`' x2)) + (Dsub12O x2 : sub ([y] O` y) M`' (O`' x2))) + %% Clean up extraneous variable + <- sub-closed ([x2] Dsub21O x2) + ([x2] Deq1 x2 : tm-eq (O`' x2) O`'1) + <- sub-closed ([x2] Dsub12O x2) + ([x2] Deq2 x2 : tm-eq (O`' x2) O`'2) + <- ({x2} + tm-eq-fun (Deq1 x2) (Deq2 x2) + (Deq x2 : tm-eq O`'1 O`'2)) + <- ({x2} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq1 x2) (Dsub21O x2) + (Dsub21O' x2 : sub ([x1] O' x1) N1 O`'1)) + <- ({x2} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq2 x2) (Dsub12O x2) + (Dsub12O' x2 : sub ([y] O` y) M`' O`'2)) + <- ({x2} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq x2) (Dsub21O' x2) + (Dsub21O'' x2 : sub ([x1] O' x1) N1 O`'2)). + + +%% rm-rr-permute' %% + +-var : rm-rr-permute-es' T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 + : at-ofes (G x1 x2) x2 S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] rmsub/var : rmsub ([x2] x2) (N2 x1) (N2 x1)) + ([x2] rrsub/closed : rrsub ([x1] x2) N1 x2) +%% + DsubN1N2 + rmsub/var. + +-appclosed : rm-rr-permute-es' T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofR x1 x2 : at-ofes (G x1 x2) (app (Q x1 x2) (M x1 x2)) S) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] rmsub/app + (DsubM'O x1 : sub ([y] O x1 y) (M' x1) (O' x1)) + (DsubN2M x1 : sub ([x2] M x1 x2) (N2 x1) (M' x1)) + (DsubN2Q x1 : rmsub ([x2] Q x1 x2) (N2 x1) (lam [y] O x1 y))) + ([x2] DsubN1R x2 + : rrsub ([x1] app (Q x1 x2) (M x1 x2)) N1 (app (Q` x2) (M` x2))) +%% + (Dsub21O'' aca) + (rmsub/app (Dsub12O' aca) DsubN2`M` Dsub12Q) +%% + %% Invert to get typing and substitutions for applicands + <- ({x2} + app-rrsub-invert (DsubN1R x2) + (DsubN1Q x2 : rrsub ([x1] Q x1 x2) N1 (Q` x2)) + (DsubN1M x2 : sub ([x1] M x1 x2) N1 (M` x2))) + <- ({x1} {d1} {x2} {d2} + app-ofes-invert (Dord x1 d1 x2 d2) (DofR x1 x2) + (DofQ x1 x2 : at-ofes (G x1 x2) (Q x1 x2) (arrow S2 S)) + (DofM x1 x2 : ofes (G x1 x2) (M x1 x2) S2)) + %% By IH(3), [N1/x1] \y.O = [N2`/x2] Q` = \y.O` + <- rm-rr-permute-es' T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofQ + DsubN1N2 DsubN2Q DsubN1Q + (sub/lam + ([y] DsubN1O y : sub ([x1] O x1 y) N1 (O` y)) + : sub ([x1] lam [y] O x1 y) N1 (lam [y] O` y)) + (Dsub12Q : rmsub ([x2] Q` x2) N2` (lam [y] O` y)) + %% By IH(1), [N1/x1] M' = [N2`/x2] M` = M`' + <- sub-permute-es' T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofM + DsubN1N2 DsubN2M DsubN1M + (DsubN1M' : sub ([x1] M' x1) N1 M`') + (DsubN2`M` : sub ([x2] M` x2) N2` M`') + %% Weaken everything with y + <- ({x1} {d1} + {x2} {d2} + extend-sordered S2 (Dord x1 d1 x2 d2) J + ([y] [e:isvar y J] + Dord_y x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S2))) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S2 + (DofN1_y x1 x2 y : ofes (scons (G x1 x2) y S2) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S2 + (DofN2_y x1 x2 y : ofes (scons (G x1 x2) y S2) (N2 x1) T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofM x1 x2) y S2 + (DofM_y x1 x2 y : ofes (scons (G x1 x2) y S2) (M x1 x2) S2)) + %% Get typing derivations for the substitutions + <- ({x1} {d1:isvar x1 I1} {y} {e:isvar y J} + subst-es + ([x2] [d2] Dord_y x1 d1 x2 d2 y e) + ([x2] slookup/miss (Dlook2 x1 x2)) + ([x2] DofN2_y x1 x2 y) + ([x2] DofM_y x1 x2 y) + (DsubN2M x1) + ([x2] DofM'_y x1 x2 y : ofes (scons (G x1 x2) y S2) (M' x1) S2)) + %% Get typing derivation for O + <- ({x1} {d1:isvar x1 I1} + rmsubst-es + ([x2] [d2] Dord x1 d1 x2 d2) + ([x2] Dlook2 x1 x2) + ([x2] DofN2 x1 x2) + ([x2] DofQ x1 x2) + (DsubN2Q x1) + ([x2] ofes/lam + ([y] DofO x1 x2 y : ofes (scons (G x1 x2) y S2) (O x1 y) S))) + %% Convince twelf that S2 <= T2 + <- ({x1} + rmsub-headvar (DsubN2Q x1) + (Dheadvar x1 : headvar ([x2] Q x1 x2))) + <- ({x1} {d1:isvar x1 I1} + headvar-stp-size + ([x2] [d2] Dord x1 d1 x2 d2) + ([x2] Dlook2 x1 x2) + ([x2] DofQ x1 x2) + (Dheadvar x1) + (Dleq : stp-leq (arrow S2 S) T2)) + <- employ-stp-leq (arrow S2 S) T2 Dleq + %% By IH(1), [N1/x1]O' = [M`'/y] O` = O`' + <- ({x2} {d2:isvar x2 I2} + sub-permute-es' T1 S2 + ([x1] [d1] [y] [e] Dord_y x1 d1 x2 d2 y e) + ([x1] [y] slookup/miss (Dlook1 x1 x2)) + ([x1] [y] slookup/hit) + ([x1] [y] DofN1_y x1 x2 y) + ([x1] [y] DofM'_y x1 x2 y) + ([x1] [y] DofO x1 x2 y) + DsubN1M' DsubM'O DsubN1O + (Dsub21O x2 : sub ([x1] O' x1) N1 (O`' x2)) + (Dsub12O x2 : sub ([y] O` y) M`' (O`' x2))) + %% Clean up extraneous variable + <- sub-closed ([x2] Dsub21O x2) + ([x2] Deq1 x2 : tm-eq (O`' x2) O`'1) + <- sub-closed ([x2] Dsub12O x2) + ([x2] Deq2 x2 : tm-eq (O`' x2) O`'2) + <- ({x2} + tm-eq-fun (Deq1 x2) (Deq2 x2) + (Deq x2 : tm-eq O`'1 O`'2)) + <- ({x2} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq1 x2) (Dsub21O x2) + (Dsub21O' x2 : sub ([x1] O' x1) N1 O`'1)) + <- ({x2} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq2 x2) (Dsub12O x2) + (Dsub12O' x2 : sub ([y] O` y) M`' O`'2)) + <- ({x2} + sub-compat ([_] tm-eq/i) tm-eq/i (Deq x2) (Dsub21O' x2) + (Dsub21O'' x2 : sub ([x1] O' x1) N1 O`'2)). + + +%worlds (csig | asig | var | bind | ovar | evar) + (sub-permute-es _ _ _ _ _ _ _ _ _ _ _ _ _) + (sub-permute-es' _ _ _ _ _ _ _ _ _ _ _ _ _) + (rr-rr-permute-es _ _ _ _ _ _ _ _ _ _ _ _ _) + (rr-rr-permute-es' _ _ _ _ _ _ _ _ _ _ _ _ _) + (rr-rm-permute-es _ _ _ _ _ _ _ _ _ _ _ _ _) + (rr-rm-permute-es' _ _ _ _ _ _ _ _ _ _ _ _ _) + (rm-rr-permute-es _ _ _ _ _ _ _ _ _ _ _ _ _) + (rm-rr-permute-es' _ _ _ _ _ _ _ _ _ _ _ _ _). +%total {(S1 S1' S2 S2' S3 S3' S4 S4') + (T1 T1' T2 T2' T3 T3' T4 T4') + (D1 D1' D2 D2' D3 D3' D4 D4')} + (sub-permute-es S1 T1 _ _ _ _ _ _ _ D1 _ _ _) + (sub-permute-es' T1' S1' _ _ _ _ _ _ _ D1' _ _ _) + (rr-rr-permute-es S2 T2 _ _ _ _ _ _ _ D2 _ _ _) + (rr-rr-permute-es' T2' S2' _ _ _ _ _ _ _ D2' _ _ _) + (rr-rm-permute-es S3 T3 _ _ _ _ _ _ _ D3 _ _ _) + (rr-rm-permute-es' T3' S3' _ _ _ _ _ _ _ D3' _ _ _) + (rm-rr-permute-es S4 T4 _ _ _ _ _ _ _ D4 _ _ _) + (rm-rr-permute-es' T4' S4' _ _ _ _ _ _ _ D4' _ _ _). + + +atpsub-permute-es : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} at-kofes (G x1 x2) (P x1 x2) H) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} atpsub ([x2] P x1 x2) (N2 x1) (P' x1)) + -> ({x2} atpsub ([x1] P x1 x2) N1 (P` x2)) +%% + -> atpsub ([x1] P' x1) N1 P`' + -> atpsub ([x2] P` x2) N2` P`' -> type. +%mode atpsub-permute-es +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +tpsub-permute-es : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} kofes (G x1 x2) (B x1 x2) H) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} tpsub ([x2] B x1 x2) (N2 x1) (B' x1)) + -> ({x2} tpsub ([x1] B x1 x2) N1 (B` x2)) +%% + -> tpsub ([x1] B' x1) N1 B`' + -> tpsub ([x2] B` x2) N2` B`' -> type. +%mode tpsub-permute-es +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +-closed : atpsub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] DofP x1 x2 : at-kofes (G x1 x2) (P x1) H) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] atpsub/closed : atpsub ([x2] P x1) (N2 x1) (P x1)) + ([x2] DsubN1P x2 : atpsub ([x1] P x1) N1 (P` x2)) +%% + (DsubN1P' aca) + DsubN2P` +%% + <- atpsub-closed ([x2] DsubN1P x2) + ([x2] Deq x2 : atp-eq (P` x2) P``) + <- ({x2} + atpsub-compat ([_] atp-eq/i) tm-eq/i (Deq x2) (DsubN1P x2) + (DsubN1P' x2 : atpsub ([x1] P x1) N1 P``)) + <- ({x2} + atp-eq-sym (Deq x2) + (Deq' x2 : atp-eq P`` (P` x2))) + <- atpsub-compat ([x2] Deq' x2) tm-eq/i atp-eq/i + (atpsub/closed : atpsub ([x2] P``) N2` P``) + (DsubN2P` : atpsub ([x2] P` x2) N2` P``). + +-appclosed : atpsub-permute-es T1 T2 % app P N + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] Datkofes x1 x2 + : at-kofes (G x1 x2) (aapp (P x2) (M x2)) H) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + atpsub/app + (DsubN2M x1 : sub ([x2] M x2) (N2 x1) (M' x1)) + (DsubN2P x1 : atpsub ([x2] P x2) (N2 x1) (P' x1))) + ([x2] + atpsub/closed + : atpsub ([x1] aapp (P x2) (M x2)) N1 (aapp (P x2) (M x2))) +%% + (atpsub/app Dsub21M Dsub21P) + (atpsub/app Dsub12M Dsub12P) +%% + <- ({x2} + sub-absent (M x2) N1 + (DsubN1M x2 : sub ([x1] M x2) N1 (M x2))) + <- ({x1} {d1} {x2} {d2} + aapp-kofes-invert (Dord x1 d1 x2 d2) (Datkofes x1 x2) + (DofP x1 x2 : at-kofes (G x1 x2) (P x2) (karrow S2 H')) + (DofM x1 x2 : ofes (G x1 x2) (M x2) S2)) + <- atpsub-permute-es T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofP + DsubN1N2 DsubN2P ([_] atpsub/closed) + (Dsub21P : atpsub ([x1] P' x1) N1 P`') + (Dsub12P : atpsub ([x2] P x2) N2` P`') + <- sub-permute-es T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DofM + DsubN1N2 DsubN2M DsubN1M + (Dsub21M : sub ([x1] M' x1) N1 M`') + (Dsub12M : sub ([x2] M x2) N2` M`'). + +-app : atpsub-permute-es T1 T2 % app P N + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] Datkofes x1 x2 + : at-kofes (G x1 x2) (aapp (P x1 x2) (M x1 x2)) H) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + atpsub/app + (DsubN2M x1 : sub ([x2] M x1 x2) (N2 x1) (M' x1)) + (DsubN2P x1 : atpsub ([x2] P x1 x2) (N2 x1) (P' x1)) + : atpsub ([x2] aapp (P x1 x2) (M x1 x2)) (N2 x1) + (aapp (P' x1) (M' x1))) + ([x2] + atpsub/app + (DsubN1M x2 : sub ([x1] M x1 x2) N1 (M` x2)) + (DsubN1P x2 : atpsub ([x1] P x1 x2) N1 (P` x2)) + : atpsub ([x1] aapp (P x1 x2) (M x1 x2)) N1 + (aapp (P` x2) (M` x2))) +%% + (atpsub/app Dsub21M Dsub21P) + (atpsub/app Dsub12M Dsub12P) +%% + <- ({x1} {d1} {x2} {d2} + aapp-kofes-invert (Dord x1 d1 x2 d2) (Datkofes x1 x2) + (DofP x1 x2 : at-kofes (G x1 x2) (P x1 x2) (karrow S2 H')) + (DofM x1 x2 : ofes (G x1 x2) (M x1 x2) S2)) + <- atpsub-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofP + DsubN1N2 DsubN2P DsubN1P + (Dsub21P : atpsub ([x1] P' x1) N1 P`') + (Dsub12P : atpsub ([x2] P` x2) N2` P`') + <- sub-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofM + DsubN1N2 DsubN2M DsubN1M + (Dsub21M : sub ([x1] M' x1) N1 M`') + (Dsub12M : sub ([x2] M` x2) N2` M`'). + +-base : tpsub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] kofes/base + (DofP x1 x2 : at-kofes (G x1 x2) (P x1 x2) sktype)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] tpsub/base + (DatpsubN2P x1 : atpsub ([x2] P x1 x2) (N2 x1) (P' x1))) + ([x2] tpsub/base + (DatpsubN1P x2 : atpsub ([x1] P x1 x2) N1 (P` x2))) +%% + (tpsub/base Datpsub21) + (tpsub/base Datpsub12) +%% + <- atpsub-permute-es T1 T2 Dord Dlook1 Dlook2 DofN1 DofN2 DofP + DsubN1N2 DatpsubN2P DatpsubN1P + (Datpsub21 : atpsub ([x1] P' x1) N1 P`') + (Datpsub12 : atpsub ([x2] P` x2) N2` P`'). + +-pi : tpsub-permute-es T1 T2 % pi x:A.B + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] kofes/pi + ([y] DkofesB x1 x2 y + : kofes (scons (G x1 x2) y S) (B x1 x2 y) sktype) + (DsimpAS x1 x2 : simp (A x1 x2) S) + (DkofesA x1 x2 : kofes (G x1 x2) (A x1 x2) sktype)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] tpsub/pi + ([y] DsubN2B x1 y + : tpsub ([x2] B x1 x2 y) (N2 x1) (B' x1 y)) + (DsubN2A x1 + : tpsub ([x2] A x1 x2) (N2 x1) (A' x1))) + ([x2] tpsub/pi + ([y] DsubN1B x2 y + : tpsub ([x1] B x1 x2 y) N1 (B` x2 y)) + (DsubN1A x2 + : tpsub ([x1] A x1 x2) N1 (A` x2))) +%% + (tpsub/pi ([y] Dsub21B y) Dsub21A) + (tpsub/pi ([y] Dsub12B y) Dsub12A) +%% + <- tpsub-permute-es T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DkofesA + DsubN1N2 DsubN2A DsubN1A + (Dsub21A : tpsub ([x1] A' x1) N1 A`') + (Dsub12A : tpsub ([x2] A` x2) N2` A`') + <- ({x1} {d1} {x2} {d2} + extend-sordered S (Dord x1 d1 x2 d2) _ + ([y] [e:isvar y _] Dord' x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S))) + <- ({x1} {x2} {y} + weaken-slookup (Dlook1 x1 x2) y S + (Dlook1' x1 x2 y + : slookup (scons (G x1 x2) y S) x1 T1)) + <- ({x1} {x2} {y} + weaken-slookup (Dlook2 x1 x2) y S + (Dlook2' x1 x2 y + : slookup (scons (G x1 x2) y S) x2 T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S + (DofN1' x1 x2 y + : ofes (scons (G x1 x2) y S) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S + (DofN2' x1 x2 y + : ofes (scons (G x1 x2) y S) (N2 x1) T2)) + <- ({y} {e} + tpsub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord' x1 d1 x2 d2 y e) + ([x1] [x2] Dlook1' x1 x2 y) + ([x1] [x2] Dlook2' x1 x2 y) + ([x1] [x2] DofN1' x1 x2 y) + ([x1] [x2] DofN2' x1 x2 y) + ([x1] [x2] DkofesB x1 x2 y) + DsubN1N2 ([x1] DsubN2B x1 y) ([x2] DsubN1B x2 y) + (Dsub21B y : tpsub ([x1] B' x1 y) N1 (B`' y)) + (Dsub12B y : tpsub ([x2] B` x2 y) N2` (B`' y))). + +-alam : tpsub-permute-es T1 T2 %% M = (alam [y] B y) : (S -> H) + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 + : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] kofes/lam + ([y] DofB x1 x2 y + : kofes (scons (G x1 x2) y S) (B x1 x2 y) H)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] tpsub/lam + ([y] DsubN2B x1 y + : tpsub ([x2] B x1 x2 y) (N2 x1) (B' x1 y)) + : tpsub ([x2] alam [y] B x1 x2 y) (N2 x1) + (alam [y] B' x1 y)) + ([x2] tpsub/lam + ([y] DsubN1B x2 y + : tpsub ([x1] B x1 x2 y) N1 (B` x2 y)) + : tpsub ([x1] alam [y] B x1 x2 y) N1 (alam [y] B` x2 y)) +%% + (tpsub/lam Dsub21) + (tpsub/lam Dsub12) +%% + <- ({x1} {d1} + {x2} {d2} + extend-sordered S (Dord x1 d1 x2 d2) _ + ([y] [e:isvar y J] Dord' x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S))) + <- ({x1} {x2} {y} + weaken-slookup (Dlook1 x1 x2) y S + (Dlook1' x1 x2 y + : slookup (scons (G x1 x2) y S) x1 T1)) + <- ({x1} {x2} {y} + weaken-slookup (Dlook2 x1 x2) y S + (Dlook2' x1 x2 y + : slookup (scons (G x1 x2) y S) x2 T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S + (DofN1' x1 x2 y + : ofes (scons (G x1 x2) y S) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S + (DofN2' x1 x2 y + : ofes (scons (G x1 x2) y S) (N2 x1) T2)) + <- ({y} {e} + tpsub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord' x1 d1 x2 d2 y e) + ([x1] [x2] Dlook1' x1 x2 y) + ([x1] [x2] Dlook2' x1 x2 y) + ([x1] [x2] DofN1' x1 x2 y) + ([x1] [x2] DofN2' x1 x2 y) + ([x1] [x2] DofB x1 x2 y) + DsubN1N2 ([x1] DsubN2B x1 y) ([x2] DsubN1B x2 y) + (Dsub21 y : tpsub ([x1] B' x1 y) N1 (B`' y)) + (Dsub12 y : tpsub ([x2] B` x2 y) N2` (B`' y))). + +%worlds (csig | asig | var | bind | ovar) + (atpsub-permute-es _ _ _ _ _ _ _ _ _ _ _ _ _) + (tpsub-permute-es _ _ _ _ _ _ _ _ _ _ _ _ _). +%total {(S1 S2) (T1 T2) (D1 D2)} + (atpsub-permute-es S1 T1 _ _ _ _ _ _ _ D1 _ _ _) + (tpsub-permute-es S2 T2 _ _ _ _ _ _ _ D2 _ _ _). + + + +ksub-permute-es : {T1} {T2} + ({x1} isvar x1 I1 -> {x2} isvar x2 I2 -> sordered (G x1 x2)) + -> ({x1} {x2} slookup (G x1 x2) x1 T1) + -> ({x1} {x2} slookup (G x1 x2) x2 T2) + -> ({x1} {x2} ofes (G x1 x2) N1 T1) + -> ({x1} {x2} ofes (G x1 x2) (N2 x1) T2) + -> ({x1} {x2} wfkindes (G x1 x2) (K x1 x2)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} ksub ([x2] K x1 x2) (N2 x1) (K' x1)) + -> ({x2} ksub ([x1] K x1 x2) N1 (K` x2)) +%% + -> ksub ([x1] K' x1) N1 K`' + -> ksub ([x2] K` x2) N2` K`' -> type. +%mode ksub-permute-es +T1 +T2 +X0 +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +-ktype : ksub-permute-es T1 T2 + _ _ _ _ _ ([x1] [x2] wfkindes/type) _ + ([x1] ksub/type) ([x2] ksub/type) +%% + ksub/type + ksub/type. + +-kpi : ksub-permute-es T1 T2 % kpi x:A.K + ([x1] [d1] [x2] [d2] Dord x1 d1 x2 d2 : sordered (G x1 x2)) + ([x1] [x2] Dlook1 x1 x2 : slookup (G x1 x2) x1 T1) + ([x1] [x2] Dlook2 x1 x2 : slookup (G x1 x2) x2 T2) + ([x1] [x2] DofN1 x1 x2 : ofes (G x1 x2) N1 T1) + ([x1] [x2] DofN2 x1 x2 : ofes (G x1 x2) (N2 x1) T2) + ([x1] [x2] wfkindes/pi + ([y] DwfkindesK x1 x2 y + : wfkindes (scons (G x1 x2) y S) (K x1 x2 y)) + (DsimpAS x1 x2 : simp (A x1 x2) S) + (DkofesA x1 x2 : kofes (G x1 x2) (A x1 x2) sktype)) +%% + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] ksub/pi + ([y] DsubN2K x1 y + : ksub ([x2] K x1 x2 y) (N2 x1) (K' x1 y)) + (DsubN2A x1 + : tpsub ([x2] A x1 x2) (N2 x1) (A' x1))) + ([x2] ksub/pi + ([y] DsubN1K x2 y + : ksub ([x1] K x1 x2 y) N1 (K` x2 y)) + (DsubN1A x2 + : tpsub ([x1] A x1 x2) N1 (A` x2))) +%% + (ksub/pi ([y] Dsub21K y) Dsub21A) + (ksub/pi ([y] Dsub12K y) Dsub12A) +%% + <- tpsub-permute-es T1 T2 + Dord Dlook1 Dlook2 DofN1 DofN2 DkofesA + DsubN1N2 DsubN2A DsubN1A + (Dsub21A : tpsub ([x1] A' x1) N1 A`') + (Dsub12A : tpsub ([x2] A` x2) N2` A`') + <- ({x1} {d1} {x2} {d2} + extend-sordered S (Dord x1 d1 x2 d2) _ + ([y] [e:isvar y _] Dord' x1 d1 x2 d2 y e + : sordered (scons (G x1 x2) y S))) + <- ({x1} {x2} {y} + weaken-slookup (Dlook1 x1 x2) y S + (Dlook1' x1 x2 y + : slookup (scons (G x1 x2) y S) x1 T1)) + <- ({x1} {x2} {y} + weaken-slookup (Dlook2 x1 x2) y S + (Dlook2' x1 x2 y + : slookup (scons (G x1 x2) y S) x2 T2)) + <- ({x1} {x2} {y} + weaken-ofes (DofN1 x1 x2) y S + (DofN1' x1 x2 y + : ofes (scons (G x1 x2) y S) N1 T1)) + <- ({x1} {x2} {y} + weaken-ofes (DofN2 x1 x2) y S + (DofN2' x1 x2 y + : ofes (scons (G x1 x2) y S) (N2 x1) T2)) + <- ({y} {e} + ksub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord' x1 d1 x2 d2 y e) + ([x1] [x2] Dlook1' x1 x2 y) + ([x1] [x2] Dlook2' x1 x2 y) + ([x1] [x2] DofN1' x1 x2 y) + ([x1] [x2] DofN2' x1 x2 y) + ([x1] [x2] DwfkindesK x1 x2 y) + DsubN1N2 ([x1] DsubN2K x1 y) ([x2] DsubN1K x2 y) + (Dsub21K y : ksub ([x1] K' x1 y) N1 (K`' y)) + (Dsub12K y : ksub ([x2] K` x2 y) N2` (K`' y))). + +%worlds (csig | asig | var | bind | ovar) (ksub-permute-es _ _ _ _ _ _ _ _ _ _ _ _ _). +%total {S1 D1} (ksub-permute-es S1 T1 _ _ _ _ _ _ _ D1 _ _ _). + +%% a version of simple subst permutation that looks more like tpsub-permute-e +tpsub-permute-es' : ({x1} isvar x1 I -> sordered (G x1)) + -> ({x1} sappend (scons G1 x1 T1) (G2 x1) (G x1)) + -> ofes G1 N1 T1 + -> ({x1} ofes (G x1) (N2 x1) T2) + -> ({x1} {x2} kofes (scons (G x1) x2 T2) (B x1 x2) H) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} tpsub ([x2] B x1 x2) (N2 x1) (B' x1)) + -> ({x2} tpsub ([x1] B x1 x2) N1 (B` x2)) +%% + -> tpsub ([x1] B' x1) N1 B`' + -> tpsub ([x2] B` x2) N2` B`' -> type. +%mode tpsub-permute-es' +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +- : tpsub-permute-es' + ([x1] [d1 : isvar x1 I1] + Dord x1 d1 : sordered (G x1)) + ([x1] + Dappend x1 : sappend (scons G1 x1 T1) (G2 x1) (G x1)) + (DofN1 : ofes G1 N1 T1) + ([x1] + DofN2 x1 : ofes (G x1) (N2 x1) T2) + ([x1] [x2] + DofB x1 x2 : kofes (scons (G x1) x2 T2) (B x1 x2) H) + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + DsubN2B x1 : tpsub ([x2] B x1 x2) (N2 x1) (B' x1)) + ([x2] + DsubN1B x2 : tpsub ([x1] B x1 x2) N1 (B` x2)) +%% + DsubB21 + DsubB12 +%% + %% come up with the ordered + <- ({x1} {d1} + extend-sordered _ (Dord x1 d1) _ + ([x2] [d2] Dord' x1 d1 x2 d2 + : sordered (scons (G x1) x2 T2))) + %% come up with the lookup + <- ({x1} + sappend-slookup (Dappend x1) + (Dlookup x1 : slookup (G x1) x1 T1)) + %% weaken DofN1 + <- ({x1} + weaken-ofes DofN1 _ _ + (DofN1' x1 : ofes (scons G1 x1 T1) N1 T1)) + <- ({x1} + weaken-ofes' (Dappend x1) (DofN1' x1) + (DofN1'' x1 : ofes (G x1) N1 T1)) + <- ({x1} {x2} + weaken-ofes (DofN1'' x1) _ _ + (DofN1''' x1 x2 : ofes (scons (G x1) x2 T2) N1 T1)) + %% weaken DofN2 + <- ({x1} {x2} + weaken-ofes (DofN2 x1) _ _ + (DofN2' x1 x2 : ofes (scons (G x1) x2 T2) (N2 x1) T2)) + %% go + <- tpsub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord' x1 d1 x2 d2) + ([x1] [x2] slookup/miss (Dlookup x1)) + ([x1] [x2] slookup/hit) + DofN1''' DofN2' DofB + DsubN1N2 DsubN2B DsubN1B + (DsubB21 : tpsub ([x1] B' x1) N1 B`') + (DsubB12 : tpsub ([x2] B` x2) N2` B`'). + +%worlds (csig | asig | var | bind | ovar) (tpsub-permute-es' _ _ _ _ _ _ _ _ _ _). +%total {} (tpsub-permute-es' _ _ _ _ _ _ _ _ _ _). + +ksub-permute-es' : ({x1} isvar x1 I -> sordered (G x1)) + -> ({x1} sappend (scons G1 x1 T1) (G2 x1) (G x1)) + -> ofes G1 N1 T1 + -> ({x1} ofes (G x1) (N2 x1) T2) + -> ({x1} {x2} wfkindes (scons (G x1) x2 T2) (K x1 x2)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} ksub ([x2] K x1 x2) (N2 x1) (K' x1)) + -> ({x2} ksub ([x1] K x1 x2) N1 (K` x2)) +%% + -> ksub ([x1] K' x1) N1 K`' + -> ksub ([x2] K` x2) N2` K`' -> type. +%mode ksub-permute-es' +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +- : ksub-permute-es' + ([x1] [d1] Dord x1 d1 : sordered (G x1)) + ([x1] Dappend x1 : sappend (scons G1 x1 T1) (G2 x1) (G x1)) + (DofN1 : ofes G1 N1 T1) + ([x1] DofN2 x1 : ofes (G x1) (N2 x1) T2) + ([x1] [x2] DofK x1 x2 : wfkindes (scons (G x1) x2 T2) (K x1 x2)) + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] DsubN2K x1 : ksub ([x2] K x1 x2) (N2 x1) (K' x1)) + ([x2] DsubN1K x2 : ksub ([x1] K x1 x2) N1 (K` x2)) +%% + DsubK21 + DsubK12 +%% + %% come up with the ordered + <- ({x1} {d1} + extend-sordered _ (Dord x1 d1) _ + ([x2] [d2] Dord' x1 d1 x2 d2 + : sordered (scons (G x1) x2 T2))) + %% come up with the lookup + <- ({x1} + sappend-slookup (Dappend x1) + (Dlookup x1 : slookup (G x1) x1 T1)) + %% weaken DofN1 + <- ({x1} + weaken-ofes DofN1 _ _ + (DofN1' x1 : ofes (scons G1 x1 T1) N1 T1)) + <- ({x1} + weaken-ofes' (Dappend x1) (DofN1' x1) + (DofN1'' x1 : ofes (G x1) N1 T1)) + <- ({x1} {x2} + weaken-ofes (DofN1'' x1) _ _ + (DofN1''' x1 x2 : ofes (scons (G x1) x2 T2) N1 T1)) + %% weaken DofN2 + <- ({x1} {x2} + weaken-ofes (DofN2 x1) _ _ + (DofN2' x1 x2 : ofes (scons (G x1) x2 T2) (N2 x1) T2)) + %% go + <- ksub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dord' x1 d1 x2 d2) + ([x1] [x2] slookup/miss (Dlookup x1)) + ([x1] [x2] slookup/hit) + DofN1''' DofN2' DofK + DsubN1N2 DsubN2K DsubN1K + (DsubK21 : ksub ([x1] K' x1) N1 K`') + (DsubK12 : ksub ([x2] K` x2) N2` K`'). + + +%worlds (csig | asig | var | bind | ovar) (ksub-permute-es' _ _ _ _ _ _ _ _ _ _). +%total {} (ksub-permute-es' _ _ _ _ _ _ _ _ _ _). + + + +%%%%% substitutiton permutation (explicit contexts) %%%%% + +sub-permute-e : ({x1} isvar x1 I -> ordered (G x1)) + -> ({x1} append (cons G1 x1 A1) (G2 x1) (G x1)) + -> ofe G1 N1 A1 + -> ({x1} ofe (G x1) (N2 x1) (A2 x1)) + -> ({x1} {x2} ofe (cons (G x1) x2 (A2 x1)) (M x1 x2) (C x1 x2)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} sub ([x2] M x1 x2) (N2 x1) (M' x1)) + -> ({x2} sub ([x1] M x1 x2) N1 (M` x2)) +%% + -> sub ([x1] M' x1) N1 M`' + -> sub ([x2] M` x2) N2` M`' -> type. +%mode sub-permute-e +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + + +- : sub-permute-e + ([x1] [d1:isvar x1 I1] + Dord x1 d1 : ordered (G x1)) + ([x1] + Dappend x1 : append (cons G1 x1 A1) (G2 x1) (G x1)) + (DofN1 : ofe G1 N1 A1) + ([x1] + DofN2 x1 : ofe (G x1) (N2 x1) (A2 x1)) + ([x1] [x2] + DofM x1 x2 : ofe (cons (G x1) x2 (A2 x1)) (M x1 x2) (C x1 x2)) + (DsubN2x1 : sub ([x1] N2 x1) N1 N2`) + ([x1] + DsubMx2 x1 : sub ([x2] M x1 x2) (N2 x1) (M' x1)) + ([x2] + DsubMx1 x2 : sub ([x1] M x1 x2) N1 (M` x2)) +%% + DsubMx2x1 + DsubMx1x2 +%% + %% get simplifications + <- can-simp A1 + (DsimpA1 : simp A1 T1) + <- ({x1} + can-simp (A2 x1) + (DsimpA2 x1 : simp (A2 x1) T2)) + <- ({x1} {x2} + can-simp (C x1 x2) + (DsimpC x1 x2 : simp (C x1 x2) S)) + <- context-append-simp-lookup Dappend DsimpA1 + ([x1] Dsimpctx x1 : simpctx (G x1) (G' x1)) + ([x1] Dslookup x1 : slookup (G' x1) x1 T1) + <- ({x1} {d1 : isvar x1 I1} + extend-ordered _ (Dord x1 d1) _ + ([x2] [d2 : isvar x2 I2] + Dord' x1 d1 x2 d2 : ordered (cons (G x1) x2 (A2 x1)))) + <- ({x1} {d1 : isvar x1 I1} + {x2} {d2 : isvar x2 I2} + ordered-simpctx (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) + (Dord' x1 d1 x2 d2) + (Dsord x1 d1 x2 d2 : sordered (scons (G' x1) x2 T2))) + %% weaken and simplify DofN1 + <- ({x1} + weaken-ofe DofN1 _ _ + (DofN1' x1 : ofe (cons G1 x1 A1) N1 A1)) + <- ({x1} + weaken-ofe' (Dappend x1) (DofN1' x1) + (DofN1'' x1 : ofe (G x1) N1 A1)) + <- ({x1} {x2} + weaken-ofe (DofN1'' x1) _ _ + (DofN1''' x1 x2 : ofe (cons (G x1) x2 (A2 x1)) N1 A1)) + <- ({x1} {x2} + ofe-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) + DsimpA1 (DofN1''' x1 x2) + (DofN1'''' x1 x2 : ofes (scons (G' x1) x2 T2) N1 T1)) + %% weaken and simplify DofN2 + <- ({x1} {x2} + weaken-ofe (DofN2 x1) _ _ + (DofN2' x1 x2 : ofe (cons (G x1) x2 (A2 x1)) (N2 x1) (A2 x1))) + <- ({x1} {x2} + ofe-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) + (DsimpA2 x1) (DofN2' x1 x2) + (DofN2'' x1 x2 : ofes (scons (G' x1) x2 T2) (N2 x1) T2)) + %% simplify DofM + <- ({x1} {x2} + ofe-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) + (DsimpC x1 x2) (DofM x1 x2) + (DofM' x1 x2 : ofes (scons (G' x1) x2 T2) (M x1 x2) S)) + %% go + <- sub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dsord x1 d1 x2 d2) + ([x1] [x2] + slookup/miss (Dslookup x1)) + ([x1] [x2] slookup/hit) + DofN1'''' DofN2'' DofM' + DsubN2x1 DsubMx2 DsubMx1 + (DsubMx2x1 : sub ([x1] M' x1) N1 M`') + (DsubMx1x2 : sub ([x2] M` x2) N2` M`'). + +%worlds (csig | asig | var | bind | ovar) (sub-permute-e _ _ _ _ _ _ _ _ _ _). +%total {} (sub-permute-e _ _ _ _ _ _ _ _ _ _). + + +%%% type substitution permutation (explicit context) %%% + +tpsub-permute-e : ({x1} isvar x1 I -> ordered (G x1)) + -> ({x1} append (cons G1 x1 A1) (G2 x1) (G x1)) + -> ofe G1 N1 A1 + -> ({x1} ofe (G x1) (N2 x1) (A2 x1)) + -> ({x1} {x2} + kofe (cons (G x1) x2 (A2 x1)) (B x1 x2) (K x1 x2)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} tpsub ([x2] B x1 x2) (N2 x1) (B' x1)) + -> ({x2} tpsub ([x1] B x1 x2) N1 (B` x2)) +%% + -> tpsub ([x1] B' x1) N1 B`' + -> tpsub ([x2] B` x2) N2` B`' -> type. +%mode tpsub-permute-e +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +- : tpsub-permute-e + ([x1] [d1 : isvar x1 I1] + Dord x1 d1 : ordered (G x1)) + ([x1] + Dappend x1 : append (cons G1 x1 A1) (G2 x1) (G x1)) + (DofN1 : ofe G1 N1 A1) + ([x1] + DofN2 x1 : ofe (G x1) (N2 x1) (A2 x1)) + ([x1] [x2] + DofB x1 x2 + : kofe (cons (G x1) x2 (A2 x1)) (B x1 x2) (K x1 x2)) + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + DsubN2B x1 : tpsub ([x2] B x1 x2) (N2 x1) (B' x1)) + ([x2] + DsubN1B x2 : tpsub ([x1] B x1 x2) N1 (B` x2)) +%% + DsubB21 + DsubB12 +%% + %% get simplifications + <- can-simp A1 (DsimpA1 : simp A1 T1) + <- ({x1} + can-simp (A2 x1) + (DsimpA2 x1 : simp (A2 x1) T2)) + <- ({x1} {x2} + can-ksimp (K x1 x2) + (DsimpK x1 x2 : ksimp (K x1 x2) H)) + <- context-append-simp-lookup Dappend DsimpA1 + ([x1] Dsimpctx x1 : simpctx (G x1) (G' x1)) + ([x1] Dslookup x1 : slookup (G' x1) x1 T1) + <- ({x1} {d1:isvar x1 I1} + extend-ordered _ (Dord x1 d1) _ + ([x2] [d2:isvar x2 I2] + Dord' x1 d1 x2 d2 : ordered (cons (G x1) x2 (A2 x1)))) + <- ({x1} {d1} {x2} {d2} + ordered-simpctx (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) + (Dord' x1 d1 x2 d2) + (Dsord x1 d1 x2 d2 : sordered (scons (G' x1) x2 T2))) + %% weaken and simplify DofN1 + <- ({x1} + weaken-ofe DofN1 _ _ + (DofN1' x1 : ofe (cons G1 x1 A1) N1 A1)) + <- ({x1} + weaken-ofe' (Dappend x1) (DofN1' x1) + (DofN1'' x1 : ofe (G x1) N1 A1)) + <- ({x1} {x2} + weaken-ofe (DofN1'' x1) _ _ + (DofN1''' x1 x2 : ofe (cons (G x1) x2 (A2 x1)) N1 A1)) + <- ({x1} {x2} + ofe-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) DsimpA1 + (DofN1''' x1 x2) + (DofN1'''' x1 x2 : ofes (scons (G' x1) x2 T2) N1 T1)) + %% weaken and simplify DofN2 + <- ({x1} {x2} + weaken-ofe (DofN2 x1) _ _ + (DofN2' x1 x2 : ofe (cons (G x1) x2 (A2 x1)) (N2 x1) (A2 x1))) + <- ({x1} {x2} + ofe-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) (DsimpA2 x1) + (DofN2' x1 x2) + (DofN2'' x1 x2 : ofes (scons (G' x1) x2 T2) (N2 x1) T2)) + %% simplify DofB + <- ({x1} {x2} + kofe-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) + (DsimpK x1 x2) (DofB x1 x2) + (DofB' x1 x2 : kofes (scons (G' x1) x2 T2) (B x1 x2) H)) + %% go + <- tpsub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dsord x1 d1 x2 d2) + ([x1] [x2] slookup/miss (Dslookup x1)) + ([x1] [x2] slookup/hit) + DofN1'''' DofN2'' DofB' + DsubN1N2 DsubN2B DsubN1B + (DsubB21 : tpsub ([x1] B' x1) N1 B`') + (DsubB12 : tpsub ([x2] B` x2) N2` B`'). + +%worlds (csig | asig | var | bind | ovar) (tpsub-permute-e _ _ _ _ _ _ _ _ _ _). +%total {} (tpsub-permute-e _ _ _ _ _ _ _ _ _ _). + +%%% kind substitution permutation (explicit context) %%% + +ksub-permute-e : ({x1} isvar x1 I -> ordered (G x1)) + -> ({x1} append (cons G1 x1 A1) (G2 x1) (G x1)) + -> ofe G1 N1 A1 + -> ({x1} ofe (G x1) (N2 x1) (A2 x1)) + -> ({x1} {x2} + wfkinde (cons (G x1) x2 (A2 x1)) (B x1 x2)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} ksub ([x2] B x1 x2) (N2 x1) (B' x1)) + -> ({x2} ksub ([x1] B x1 x2) N1 (B` x2)) +%% + -> ksub ([x1] B' x1) N1 B`' + -> ksub ([x2] B` x2) N2` B`' -> type. +%mode ksub-permute-e +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 -X9 -X10. + +- : ksub-permute-e + ([x1] [d1 : isvar x1 I1] + Dord x1 d1 : ordered (G x1)) + ([x1] + Dappend x1 : append (cons G1 x1 A1) (G2 x1) (G x1)) + (DofN1 : ofe G1 N1 A1) + ([x1] + DofN2 x1 : ofe (G x1) (N2 x1) (A2 x1)) + ([x1] [x2] + DofB x1 x2 + : wfkinde (cons (G x1) x2 (A2 x1)) (B x1 x2)) + (DsubN1N2 : sub ([x1] N2 x1) N1 N2`) + ([x1] + DsubN2B x1 : ksub ([x2] B x1 x2) (N2 x1) (B' x1)) + ([x2] + DsubN1B x2 : ksub ([x1] B x1 x2) N1 (B` x2)) +%% + DsubB21 + DsubB12 +%% + %% get simplifications + <- can-simp A1 (DsimpA1 : simp A1 T1) + <- ({x1} + can-simp (A2 x1) + (DsimpA2 x1 : simp (A2 x1) T2)) + <- context-append-simp-lookup Dappend DsimpA1 + ([x1] Dsimpctx x1 : simpctx (G x1) (G' x1)) + ([x1] Dslookup x1 : slookup (G' x1) x1 T1) + <- ({x1} {d1:isvar x1 I1} + extend-ordered _ (Dord x1 d1) _ + ([x2] [d2:isvar x2 I2] + Dord' x1 d1 x2 d2 : ordered (cons (G x1) x2 (A2 x1)))) + <- ({x1} {d1} {x2} {d2} + ordered-simpctx (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) + (Dord' x1 d1 x2 d2) + (Dsord x1 d1 x2 d2 : sordered (scons (G' x1) x2 T2))) + %% weaken and simplify DofN1 + <- ({x1} + weaken-ofe DofN1 _ _ + (DofN1' x1 : ofe (cons G1 x1 A1) N1 A1)) + <- ({x1} + weaken-ofe' (Dappend x1) (DofN1' x1) + (DofN1'' x1 : ofe (G x1) N1 A1)) + <- ({x1} {x2} + weaken-ofe (DofN1'' x1) _ _ + (DofN1''' x1 x2 : ofe (cons (G x1) x2 (A2 x1)) N1 A1)) + <- ({x1} {x2} + ofe-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) DsimpA1 + (DofN1''' x1 x2) + (DofN1'''' x1 x2 : ofes (scons (G' x1) x2 T2) N1 T1)) + %% weaken and simplify DofN2 + <- ({x1} {x2} + weaken-ofe (DofN2 x1) _ _ + (DofN2' x1 x2 : ofe (cons (G x1) x2 (A2 x1)) (N2 x1) (A2 x1))) + <- ({x1} {x2} + ofe-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) (DsimpA2 x1) + (DofN2' x1 x2) + (DofN2'' x1 x2 : ofes (scons (G' x1) x2 T2) (N2 x1) T2)) + %% simplify DofB + <- ({x1} {x2} + wfkinde-simp (simpctx/cons (DsimpA2 x1) (Dsimpctx x1)) + (DofB x1 x2) + (DofB' x1 x2 : wfkindes (scons (G' x1) x2 T2) (B x1 x2))) + %% go + <- ksub-permute-es T1 T2 + ([x1] [d1] [x2] [d2] Dsord x1 d1 x2 d2) + ([x1] [x2] slookup/miss (Dslookup x1)) + ([x1] [x2] slookup/hit) + DofN1'''' DofN2'' DofB' + DsubN1N2 DsubN2B DsubN1B + (DsubB21 : ksub ([x1] B' x1) N1 B`') + (DsubB12 : ksub ([x2] B` x2) N2` B`'). + +%worlds (csig | asig | var | bind | ovar) (ksub-permute-e _ _ _ _ _ _ _ _ _ _). +%total {} (ksub-permute-e _ _ _ _ _ _ _ _ _ _). + +%%%%% substitution permutation (implicit context) %%%%% + +%% [N1/x1] [N2/x2] M == [[N1/x1]N2/x2] [N1/x1] M %% + +sub-permute : of N1 A1 + -> ({x1} vof x1 A1 -> of (N2 x1) (A2 x1)) + -> ({x1} vof x1 A1 -> {x2} vof x2 (A2 x1) -> of (M x1 x2) (C x1 x2)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} sub ([x2] M x1 x2) (N2 x1) (M' x1)) + -> ({x2} sub ([x1] M x1 x2) N1 (M` x2)) +%% + -> sub ([x1] M' x1) N1 M`' + -> sub ([x2] M` x2) N2` M`' -> type. +%mode sub-permute +X1 +X2 +X3 +X4 +X5 +X6 -X7 -X8. + +- : sub-permute DofN1 DofN2 DofM DsubN2x1 DsubMx2 DsubMx1 + DsubMx2x1 DsubMx1x2 + <- of-to-ofe DofN1 + (DofeN1 : ofe nil N1 A1) + <- of1-to-ofe DofN2 + (DofeN2 : {x1} ofe (cons nil x1 A1) (N2 x1) (A2 x1)) + <- of2-to-ofe DofM + (DofeM : {x1} {x2} + ofe (cons (cons nil x1 A1) x2 (A2 x1)) (M x1 x2) (C x1 x2)) + <- extend-ordered A1 ordered/nil + I (Dord : {x1} isvar x1 I -> ordered (cons nil x1 A1)) + <- sub-permute-e ([x1] [d] Dord x1 d) ([_] append/nil) + DofeN1 DofeN2 DofeM DsubN2x1 DsubMx2 DsubMx1 + DsubMx2x1 DsubMx1x2. + +%worlds (csig | asig | bind) (sub-permute _ _ _ _ _ _ _ _). +%total {} (sub-permute _ _ _ _ _ _ _ _). + +tpsub-permute : of N1 A1 + -> ({x1} vof x1 A1 -> of (N2 x1) (A2 x1)) + -> ({x1} vof x1 A1 -> {x2} vof x2 (A2 x1) -> kof (M x1 x2) (C x1 x2)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} tpsub ([x2] M x1 x2) (N2 x1) (M' x1)) + -> ({x2} tpsub ([x1] M x1 x2) N1 (M` x2)) +%% + -> tpsub ([x1] M' x1) N1 M`' + -> tpsub ([x2] M` x2) N2` M`' -> type. +%mode tpsub-permute +X1 +X2 +X3 +X4 +X5 +X6 -X7 -X8. + +- : tpsub-permute DofN1 DofN2 DofM DtpsubN2x1 DtpsubMx2 DtpsubMx1 + DtpsubMx2x1 DtpsubMx1x2 + <- of-to-ofe DofN1 + (DofeN1 : ofe nil N1 A1) + <- of1-to-ofe DofN2 + (DofeN2 : {x1} ofe (cons nil x1 A1) (N2 x1) (A2 x1)) + <- kof2-to-kofe DofM + (DofeM : {x1} {x2} + kofe (cons (cons nil x1 A1) x2 (A2 x1)) (M x1 x2) (C x1 x2)) + <- extend-ordered A1 ordered/nil + I (Dord : {x1} isvar x1 I -> ordered (cons nil x1 A1)) + <- tpsub-permute-e ([x1] [d] Dord x1 d) ([_] append/nil) + DofeN1 DofeN2 DofeM DtpsubN2x1 DtpsubMx2 DtpsubMx1 + DtpsubMx2x1 DtpsubMx1x2. + +%worlds (csig | asig | bind) (tpsub-permute _ _ _ _ _ _ _ _). +%total {} (tpsub-permute _ _ _ _ _ _ _ _). + + +%{ +rrsub-permute : of N1 A1 + -> ({x1} vof x1 A1 -> of (N2 x1) (A2 x1)) + -> ({x1} vof x1 A1 -> {x2} vof x2 (A2 x1) -> at-of (R x2 x1) (A x2 x1)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rrsub ([x2] R x2 x1) (N2 x1) (R' x1)) + -> ({x2} rrsub ([x1] R x2 x1) N1 (R` x2)) +%% + -> rrsub ([x1] R' x1) N1 R`' + -> rrsub ([x2] R` x2) N2` R`' -> type. +%mode rrsub-permute +X1 +X2 +X3 +X4 +X5 +X6 -X7 -X8. + +%worlds (csig | asig | bind) (rrsub-permute _ _ _ _ _ _ _ _). +%total {} (rrsub-permute _ _ _ _ _ _ _ _). + + +rrsub-rmsub-permute : of N1 A1 + -> ({x1} vof x1 A1 -> of (N2 x1) (A2 x1)) + -> ({x1} vof x1 A1 -> {x2} vof x2 (A2 x1) -> at-of (R x2 x1) (A x2 x1)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rrsub ([x2] R x2 x1) (N2 x1) (R' x1)) + -> ({x2} rmsub ([x1] R x2 x1) N1 (M` x2)) +%% + -> rmsub ([x1] R' x1) N1 M`' + -> sub ([x2] M` x2) N2` M`' -> type. +%mode rrsub-rmsub-permute +X1 +X2 +X3 +X4 +X5 +X6 -X7 -X8. + +%worlds (csig | asig | bind) (rrsub-rmsub-permute _ _ _ _ _ _ _ _). +%total {} (rrsub-rmsub-permute _ _ _ _ _ _ _ _). + + +rmsub-rrsub-permute : of N1 A1 + -> ({x1} vof x1 A1 -> of (N2 x1) (A2 x1)) + -> ({x1} vof x1 A1 -> {x2} vof x2 (A2 x1) -> at-of (R x2 x1) (A x2 x1)) +%% + -> sub ([x1] N2 x1) N1 N2` + -> ({x1} rrsub ([x2] R x2 x1) (N2 x1) (R' x1)) + -> ({x2} rmsub ([x1] R x2 x1) N1 (M` x2)) +%% + -> rmsub ([x1] R' x1) N1 M`' + -> sub ([x2] M` x2) N2` M`' -> type. +%mode rmsub-rrsub-permute +X1 +X2 +X3 +X4 +X5 +X6 -X7 -X8. + +%worlds (csig | asig | bind) (rmsub-rrsub-permute _ _ _ _ _ _ _ _). +%total {} (rmsub-rrsub-permute _ _ _ _ _ _ _ _). + +}% + + +%%%%% substitution lemma (explicit context) %%%%% + +rrsubst-em : {T:stp} + simp A T +%% + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> rrsub R M R' + -> ({x} at-ofe (G x) (R x) (B x)) +%% + -> tpsub B M B' + -> at-ofe G' R' B' -> type. +%mode rrsubst-em +T +X-1 +X0 +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +rmsubst-em : {T:stp} + simp A T +%% + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> rmsub R M LR + -> ({x} at-ofe (G x) (R x) (B x)) +%% + -> tpsub B M B' + -> ofe G' LR B' -> type. +%mode rmsubst-em +T +X-1 +X0 +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +subst-em : {T:stp} + simp A T +%% + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> sub N M N' + -> tpsub B M B' + -> ({x} ofe (G x) (N x) (B x)) +%% + -> ofe G' N' B' -> type. +%mode subst-em +T +X-1 +X0 +X1 +X2 +X3 +X4 +X5 +X6 -X7. + +atpsubst-em : {T:stp} + simp A T +%% + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> atpsub P M P' + -> ({x} at-kofe (G x) (P x) (K x)) +%% + -> ksub K M K' + -> at-kofe G' P' K' -> type. +%mode atpsubst-em +T +X-1 +X0 +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +tpsubst-em : {T:stp} + simp A T +%% + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> tpsub B M B' + -> ({x} kofe (G x) (B x) (K x)) + -> ksub K M K' +%% + -> kofe G' B' K' -> type. +%mode tpsubst-em +T +X-1 +X0 +X1 +X2 +X3 +X4 +X5 +X6 -X7. + +ksubst-em : {T:stp} + simp A T +%% + -> ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> ksub K M K' + -> ({x} wfkinde (G x) (K x)) +%% + -> wfkinde G' K' -> type. +%mode ksubst-em +T +X-1 +X0 +X1 +X2 +X3 +X4 +X5 -X6. + +-closed : rrsubst-em _ _ + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M G') + (DofM : ofe G1 M A) + (Dsub : rrsub ([x] R x) M Rx) + ([x] at-ofe/closed (Dof x : at-of (R x) (B x))) +%% + (DsubB) + (at-ofe/closed Dof'') +%% + <- atof-noassm Dof + ([x] DeqR x : atm-eq (R x) R') + ([x] DeqB x : tp-eq (B x) B') + <- ({x} tp-eq-sym (DeqB x) (DeqB' x : tp-eq B' (B x))) + <- ({x} atm-eq-sym (DeqR x) (DeqR' x : atm-eq R' (R x))) + <- rrsub-absent _ _ + (DsubR' : rrsub ([_] R') M R') + <- rrsub-compat ([x] DeqR' x) tm-eq/i atm-eq/i DsubR' + (DsubR : rrsub ([x] R x) M R') + <- rrsub-fun DsubR Dsub + (DeqR'Rx : atm-eq R' Rx) + <- ({x} atof-resp (DeqR x) (DeqB x) (Dof x) (Dof' x : at-of R' B')) + <- atof-resp DeqR'Rx tp-eq/i (Dof' aca) + (Dof'' : at-of Rx B') + <- tpsub-absent _ _ + (DsubB' : tpsub ([_] B') M B') + <- tpsub-compat ([x] DeqB' x) tm-eq/i tp-eq/i DsubB' + (DsubB : tpsub ([x] B x) M B'). + +-closed : rmsubst-em _ _ + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M G') + (DofM : ofe G1 M A) + (DsubR : rmsub ([x] R x) M N) + ([x] at-ofe/closed + (DofR x : at-of (R x) (B x))) +%% + Dtpsub + Dofe +%% + <- atof-noassm ([x] DofR x) + ([x] DeqR x : atm-eq (R x) R') _ + <- rmsub-compat DeqR tm-eq/i tm-eq/i DsubR + (DsubR' : rmsub ([_] R') M N) + <- rmsub-absent DsubR' Dfalse + <- false-implies-tpsub Dfalse Dtpsub + <- false-implies-ofe Dfalse Dofe. + + +-const : rrsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M G') + (DofM : ofe G1 M A) + (rrsub/closed : rrsub ([_] const C) M (const C)) + ([x] at-ofe/const + (Dkofe x : kofe (G x) B ktype) + (Dcof : cof C B)) +%% + (DsubB : tpsub ([x] B) M B) + (at-ofe/const DkofB' Dcof : at-ofe G' (const C) B) +%% + <- tpsub-absent _ _ + (DsubB : tpsub ([_] B) M B) + <- tpsubst-em T Dsimp Dord Dapp Dcsub DofM DsubB Dkofe + ksub/type + (DkofB' : kofe G' B ktype). + + +-var : rrsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M G') + (DofM : ofe G1 M A) + rrsub/closed + ([x] at-ofe/var + (Dkof x : kofe (G x) (B x) ktype) + (Dlook x : lookup (G x) X (B x))) +%% + DsubBx + (at-ofe/var DkofBx Dlookup') +%% + <- csub-lookup Dcsub Dlook + (DsubBx : tpsub ([x] B x) M Bx) + (Dlookup' : lookup G' X Bx) + <- tpsubst-em T Dsimp Dord Dapp Dcsub DofM DsubBx Dkof + ksub/type + (DkofBx : kofe G' Bx ktype). + +-var : rmsubst-em _ _ + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M Gx) + (DofM : ofe G1 M A) + rmsub/var + ([x] + at-ofe/var _ (Dlook x : lookup (G x) x (B x))) +%% + Dtpsub' + DofM' +%% + <- ({x} + append-lookup (Dapp x) + (Dlook' x : lookup (G x) x A)) + <- ({x} {d} + lookup-fun (Dord x d) (Dlook' x) (Dlook x) + (DeqAB x : tp-eq A (B x))) + <- tpsub-absent A M (Dtpsub : tpsub ([_] A) M A) + <- tpsub-compat DeqAB tm-eq/i tp-eq/i Dtpsub + (Dtpsub' : tpsub ([x] B x) M A) + <- weaken-ofe-csub Dord Dapp Dcsub DofM (DofM' : ofe Gx M A). + +-app : rrsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M Gx) + (DofM : ofe G1 M A) + (rrsub/app + (DsubNx : sub ([x] N x) M Nx) + (DsubRx : rrsub ([x] R x) M Rx)) + ([x] at-ofe/app + (DsubCy x : tpsub ([y] C x y) (N x) (Cy x)) + (DofN x : ofe (G x) (N x) (B x)) + (DofR x : at-ofe (G x) (R x) (pi (B x) [y] C x y)) + : at-ofe (G x) (app (R x) (N x)) (Cy x)) +%% + DsubCyx + (at-ofe/app + DsubCxy + DofNx + DofRx) +%% + <- rrsubst-em T Dsimp Dord Dapp Dcsub DofM DsubRx DofR + (tpsub/pi + ([y] DsubCx y : tpsub ([x] C x y) M (Cx y)) + (DsubBx : tpsub ([x] B x) M Bx) + : tpsub ([x] pi (B x) [y] C x y) M (pi Bx [y] Cx y)) + (DofRx : at-ofe Gx Rx (pi Bx [y] Cx y)) + <- subst-em T Dsimp Dord Dapp Dcsub DofM DsubNx DsubBx DofN + (DofNx : ofe Gx Nx Bx) + %% simplify context to pass to permutation + <- can-simpctx G1 (DsimpG1 : simpctx G1 G1') + <- ({x} + can-simpctx (G2 x) (DsimpG2 x : simpctx (G2 x) (G2' x))) + <- ({x} + can-simpctx (G x) (DsimpG x : simpctx (G x) (G' x))) + <- ({x} + append-simpctx' (Dapp x) + (simpctx/cons Dsimp DsimpG1) + (DsimpG2 x) + (DsimpG x) + (Dsapp x : sappend (scons G1' x T) (G2' x) (G' x))) + <- ({x} {d} + ordered-simpctx (DsimpG x) (Dord x d) + (Dsord x d : sordered (G' x))) + %% simplify typing derivations + <- ofe-simp DsimpG1 Dsimp DofM + (DofesM : ofes G1' M T) + <- ({x} + can-simp (B x) + (DsimpB x : simp (B x) S)) + <- ({x} + ofe-simp (DsimpG x) (DsimpB x) (DofN x) + (DofesN x : ofes (G' x) (N x) S)) + %% apply simple regularity to get DkofesC + <- ({x} {d} + atofe-reg-kofes (Dord x d) (DofR x) (DsimpG x) + (kofes/pi + ([y] DkofesC x y + : kofes (scons (G' x) y S') (C x y) sktype) + (DsimpB' x : simp (B x) S') + (DkofesB x : kofes (G' x) (B x) sktype))) + <- ({x} + simp-fun (DsimpB x) (DsimpB' x) + (DeqSS' : stp-eq S S')) + <- ({x} + ofes-resp sctx-eq/i tm-eq/i DeqSS' (DofesN x) + (DofesN' x : ofes (G' x) (N x) S')) + %% go + <- tpsub-permute-es' Dsord Dsapp DofesM DofesN' DkofesC + DsubNx DsubCy DsubCx + (DsubCyx : tpsub ([x] Cy x) M Cyx) + (DsubCxy : tpsub ([y] Cx y) Nx Cyx). + +-app : rmsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M Gx) + (DofM : ofe G1 M A) + (rmsub/app + (DsubN2 : sub N1 Nx N2) + (DsubNx : sub N M Nx) + (DsubN1 : rmsub R M (lam N1))) + ([x] at-ofe/app + (DsubCy x : tpsub ([y] C x y) (N x) (Cy x)) + (DofN x : ofe (G x) (N x) (B x)) + (DofR x : at-ofe (G x) (R x) (pi (B x) [y] C x y))) +%% + (DsubCyx : tpsub Cy M Cyx) + DofN2 +%% + <- rmsubst-em T Dsimp Dord Dapp Dcsub DofM DsubN1 DofR + (tpsub/pi + ([y] DsubCx y : tpsub ([x] C x y) M (Cx y)) + (DsubBx : tpsub ([x] B x) M Bx)) + (ofe/lam + (DofBx : kofe Gx Bx ktype) + ([y] DofN1 y : ofe (cons Gx y Bx) (N1 y) (Cx y))) + <- subst-em T Dsimp Dord Dapp Dcsub DofM DsubNx DsubBx DofN + (DofNx : ofe Gx Nx Bx) + %% simplify context to pass to permutation + <- can-simpctx G1 (DsimpG1 : simpctx G1 G1') + <- ({x} + can-simpctx (G2 x) (DsimpG2 x : simpctx (G2 x) (G2' x))) + <- ({x} + can-simpctx (G x) (DsimpG x : simpctx (G x) (G' x))) + <- ({x} + append-simpctx' (Dapp x) + (simpctx/cons Dsimp DsimpG1) + (DsimpG2 x) + (DsimpG x) + (Dsapp x : sappend (scons G1' x T) (G2' x) (G' x))) + <- ({x} {d} + ordered-simpctx (DsimpG x) (Dord x d) + (Dsord x d : sordered (G' x))) + %% simplify typing derivations + <- ofe-simp DsimpG1 Dsimp DofM + (DofesM : ofes G1' M T) + <- ({x} + can-simp (B x) + (DsimpB x : simp (B x) S)) + <- ({x} + ofe-simp (DsimpG x) (DsimpB x) (DofN x) + (DofesN x : ofes (G' x) (N x) S)) + %% apply simple regularity to get DkofesC + <- ({x} {d} + atofe-reg-kofes (Dord x d) (DofR x) (DsimpG x) + (kofes/pi + ([y] DkofesC x y + : kofes (scons (G' x) y S') (C x y) sktype) + (DsimpB' x : simp (B x) S') + (DkofesA x : kofes (G' x) (B x) sktype))) + <- ({x} + simp-fun (DsimpB x) (DsimpB' x) + (DeqSS' : stp-eq S S')) + <- ({x} + ofes-resp sctx-eq/i tm-eq/i DeqSS' (DofesN x) + (DofesN' x : ofes (G' x) (N x) S')) + %% permute + <- tpsub-permute-es' Dsord Dsapp DofesM DofesN' DkofesC + DsubNx DsubCy DsubCx + (DsubCyx : tpsub ([x] Cy x) M Cyx) + (DsubCxy : tpsub ([y] Cx y) Nx Cyx) + %% get DofN2 + <- csub-ordered Dord Dcsub + (Dord' : ordered Gx) + <- extend-ordered Bx Dord' _ + ([x] [d] Dord'' x d : ordered (cons Gx x Bx)) + <- tpsub-preserves-simp DsubBx DsimpB (DsimpBx : simp Bx S) + %% convince twelf that thus S < T + <- ({x} {y} + can-simp (C x y) + (DsimpC x y : simp (C x y) T2)) + <- rmsub-headvar DsubN1 (Dheadvar : headvar R) + <- headvar-tp-size Dord Dapp DofR Dsimp Dheadvar + ([x] simp/pi ([y] DsimpC x y) (DsimpB x)) + (Dleq : stp-leq (arrow S T2) T) + <- employ-stp-leq (arrow S T2) T Dleq + %% go + <- subst-em S DsimpBx Dord'' ([_] append/nil) + csub/base DofNx DsubN2 DsubCxy DofN1 + (DofN2 : ofe Gx N2 Cyx). + +-appclo : rrsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M Gx) + (DofM : ofe G1 M A) + rrsub/closed + ([x] at-ofe/app + (DsubCy x : tpsub ([y] C x y) N (Cy x)) + (DofN x : ofe (G x) N (B x)) + (DofR x : at-ofe (G x) R (pi (B x) [y] C x y)) + : at-ofe (G x) (app R N) (Cy x)) +%% + DsubCyx + (at-ofe/app DsubCxy DofN' DofR') +%% + <- rrsubst-em T Dsimp Dord Dapp Dcsub DofM rrsub/closed DofR + (tpsub/pi + ([y] DsubCx y : tpsub ([x] C x y) M (Cx y)) + (DsubBx : tpsub ([x] B x) M Bx)) + (DofR' : at-ofe Gx R (pi Bx ([y] Cx y))) + <- sub-absent N M + (DsubN : sub ([_] N) M N) + <- subst-em T Dsimp Dord Dapp Dcsub DofM DsubN DsubBx DofN + (DofN' : ofe Gx N Bx) + %% simplify context to pass to permutation + <- can-simpctx G1 (DsimpG1 : simpctx G1 G1') + <- ({x} + can-simpctx (G2 x) (DsimpG2 x : simpctx (G2 x) (G2' x))) + <- ({x} + can-simpctx (G x) (DsimpG x : simpctx (G x) (G' x))) + <- ({x} + append-simpctx' (Dapp x) + (simpctx/cons Dsimp DsimpG1) + (DsimpG2 x) + (DsimpG x) + (Dsapp x : sappend (scons G1' x T) (G2' x) (G' x))) + <- ({x} {d} + ordered-simpctx (DsimpG x) (Dord x d) + (Dsord x d : sordered (G' x))) + %% simplify typing derivations + <- ofe-simp DsimpG1 Dsimp DofM + (DofesM : ofes G1' M T) + <- ({x} + can-simp (B x) + (DsimpB x : simp (B x) S)) + <- ({x} + ofe-simp (DsimpG x) (DsimpB x) (DofN x) + (DofesN x : ofes (G' x) N S)) + %% apply simple regularity to get DkofesC + <- ({x} {d} + atofe-reg-kofes (Dord x d) (DofR x) (DsimpG x) + (kofes/pi ([y] DkofesC x y) (DsimpB' x) (DkofesA x))) + <- ({x} + simp-fun (DsimpB x) (DsimpB' x) + (DeqSS' : stp-eq S S')) + <- ({x} + ofes-resp sctx-eq/i tm-eq/i DeqSS' (DofesN x) + (DofesN' x : ofes (G' x) N S')) + %% go + <- tpsub-permute-es' Dsord Dsapp DofesM DofesN' DkofesC + DsubN DsubCy DsubCx + (DsubCyx : tpsub ([x] Cy x) M Cyx) + (DsubCxy : tpsub ([y] Cx y) N Cyx). + +-appbad : rrsubst-em _ _ Dord _ _ _ + (rrsub/app _ _) + ([x] at-ofe/var _ (Dlookup x)) +%% + Dtpsub + Datofe +%% + <- ({x} {d} + lookup-isvar (Dlookup x) (Dord x d) + (Disvar x : isvar (app _ _) J)) + <- ({x} isvar-app-contra (Disvar x) Dfalse) + <- false-implies-tpsub Dfalse Dtpsub + <- false-implies-atofe Dfalse Datofe. + +-appbad : rmsubst-em _ _ Dord _ _ _ + (rmsub/app _ _ _) + ([x] at-ofe/var _ (Dlookup x)) +%% + Dtpsub + Dofe +%% + <- ({x} {d} + lookup-isvar (Dlookup x) (Dord x d) + (Disvar x : isvar (app _ _) J)) + <- ({x} isvar-app-contra (Disvar x) Dfalse) + <- false-implies-tpsub Dfalse Dtpsub + <- false-implies-ofe Dfalse Dofe. + +-at-r : subst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + (sub/rr (Drrsub : rrsub R M Rx)) + (tpsub/base (Datpsub : atpsub ([x] P x) M Px)) + ([x] ofe/at (DofR x : at-ofe (G x) (R x) (base (P x)))) +%% + (ofe/at DofRx') +%% + <- rrsubst-em T Dsimp Dord Dapp Dcsub DofM Drrsub DofR + (tpsub/base (Datpsub' : atpsub ([x] P x) M Px')) + (DofRx : at-ofe Gx Rx (base Px')) + <- atpsub-fun Datpsub' Datpsub + (DeqPx : atp-eq Px' Px) + <- base-compat DeqPx + (DeqBasePx : tp-eq (base Px') (base Px)) + <- atofe-resp ctx-eq/i atm-eq/i DeqBasePx DofRx + (DofRx' : at-ofe Gx Rx (base Px)). + +-at-m : subst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + (sub/rm (Drmsub : rmsub ([x] R x) M (at Rx))) + (tpsub/base (Datpsub : atpsub ([x] P x) M Px)) + ([x] ofe/at (DofR x : at-ofe (G x) (R x) (base (P x)))) +%% + DofN' +%% + <- rmsubst-em T Dsimp Dord Dapp Dcsub DofM Drmsub DofR + (tpsub/base (Datpsub' : atpsub ([x] P x) M Px')) + (DofN : ofe Gx (at Rx) (base Px')) + <- atpsub-fun Datpsub' Datpsub + (DeqPx : atp-eq Px' Px) + <- base-compat DeqPx + (DeqBasePx : tp-eq (base Px') (base Px)) + <- ofe-resp ctx-eq/i tm-eq/i DeqBasePx DofN + (DofN' : ofe Gx (at Rx) (base Px)). + +-lam : subst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + (sub/lam ([y] DsubN y : sub ([x] N x y) M (Nx y))) + (tpsub/pi + ([y] DsubB2 y : tpsub ([x] B2 x y) M (B2x y)) + (DsubB1 : tpsub ([x] B1 x) M B1x)) + ([x] ofe/lam + (DofB1 x : kofe (G x) (B1 x) ktype) + ([y] DofN x y + : ofe (cons (G x) y (B1 x)) (N x y) (B2 x y))) +%% + (ofe/lam DofB1x ([y] DofNx y)) +%% + <- tpsubst-em T Dsimp Dord Dapp Dcsub DofM DsubB1 DofB1 + ksub/type + (DofB1x : kofe Gx B1x ktype) + <- ({x} {d} + extend-ordered _ (Dord x d) _ + ([y] [e] Dord' x d y e + : ordered (cons (G x) y (B1 x)))) + <- ({y} {e} + subst-em T Dsimp + ([x] [d] Dord' x d y e) + ([x] append/cons (Dapp x)) + (csub/cons DsubB1 Dcsub) + DofM + (DsubN y) + (DsubB2 y) + ([x] DofN x y) + (DofNx y : ofe (cons Gx y B1x) (Nx y) (B2x y))). + +-closed : atpsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + (Dsub : atpsub ([x] P x) M Px) + ([x] at-kofe/closed (DofP x : at-kof (P x) (K x))) +%% + DsubK + (at-kofe/closed DofP'') +%% + <- atkof-noassm DofP + ([x] DeqP x : atp-eq (P x) P') + ([x] DeqK x : kind-eq (K x) K') + <- ({x} kind-eq-sym (DeqK x) (DeqK' x : kind-eq K' (K x))) + <- ({x} atp-eq-sym (DeqP x) (DeqP' x : atp-eq P' (P x))) + <- atpsub-absent _ _ + (DsubP' : atpsub ([x] P') M P') + <- atpsub-compat ([x] DeqP' x) tm-eq/i atp-eq/i DsubP' + (DsubP : atpsub ([x] P x) M P') + <- atpsub-fun DsubP Dsub + (DeqP'Px : atp-eq P' Px) + <- ({x} atkof-resp (DeqP x) (DeqK x) (DofP x) + (DofP' x : at-kof P' K')) + <- atkof-resp DeqP'Px kind-eq/i (DofP' aca) + (DofP'' : at-kof Px K') + <- ksub-absent _ _ + (DsubK' : ksub ([_] K') M K') + <- ksub-compat ([x] DeqK' x) tm-eq/i kind-eq/i DsubK' + (DsubK : ksub ([x] K x) M K'). + +-const : atpsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M Gx) + (DofM : ofe G1 M A) + (atpsub/closed : atpsub ([_] aconst C) M (aconst C)) + ([x] at-kofe/const + (DwfK x : wfkinde (G x) K) + (Dckof : ckof C K)) +%% + DsubK' + (at-kofe/const DwfK' Dckof : at-kofe Gx (aconst C) K) +%% + <- ksub-absent _ _ + (DsubK' : ksub ([_] K) M K) + <- ksubst-em T Dsimp Dord Dapp Dcsub DofM DsubK' DwfK + (DwfK' : wfkinde Gx K). + +-app : atpsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M Gx) + (DofM : ofe G1 M A) + (atpsub/app + (DsubNx : sub ([x] N x) M Nx) + (DsubPx : atpsub ([x] P x) M Px)) + ([x] at-kofe/app + (DsubKy x : ksub ([y] K x y) (N x) (Ky x)) + (DofN x : ofe (G x) (N x) (B x)) + (DofP x : at-kofe (G x) (P x) (kpi (B x) [y] K x y)) + : at-kofe (G x) (aapp (P x) (N x)) (Ky x)) +%% + DsubKyx + (at-kofe/app + DsubKxy + DofNx + DofPx) +%% + <- atpsubst-em T Dsimp Dord Dapp Dcsub DofM DsubPx DofP + (ksub/pi + ([y] DsubKx y : ksub ([x] K x y) M (Kx y)) + (DsubBx : tpsub ([x] B x) M Bx) + : ksub ([x] kpi (B x) [y] K x y) M (kpi Bx [y] Kx y)) + (DofPx : at-kofe Gx Px (kpi Bx [y] Kx y)) + <- subst-em T Dsimp Dord Dapp Dcsub DofM DsubNx DsubBx DofN + (DofNx : ofe Gx Nx Bx) + %% simplify context to pass to permutation + <- can-simpctx G1 (DsimpG1 : simpctx G1 G1') + <- ({x} + can-simpctx (G2 x) (DsimpG2 x : simpctx (G2 x) (G2' x))) + <- ({x} + can-simpctx (G x) (DsimpG x : simpctx (G x) (G' x))) + <- ({x} + append-simpctx' (Dapp x) + (simpctx/cons Dsimp DsimpG1) + (DsimpG2 x) + (DsimpG x) + (Dsapp x : sappend (scons G1' x T) (G2' x) (G' x))) + <- ({x} {d} + ordered-simpctx (DsimpG x) (Dord x d) + (Dsord x d : sordered (G' x))) + %% simplify typing derivations + <- ofe-simp DsimpG1 Dsimp DofM + (DofesM : ofes G1' M T) + <- ({x} + can-simp (B x) + (DsimpB x : simp (B x) S)) + <- ({x} + ofe-simp (DsimpG x) (DsimpB x) (DofN x) + (DofesN x: ofes (G' x) (N x) S)) + %% apply simple regularity to get DwfkindesK + <- ({x} {d} + atkofe-reg-wfkindes (Dord x d) (DofP x) (DsimpG x) + (wfkindes/pi + ([y] DwfkindesK x y + : wfkindes (scons (G' x) y S') (K x y)) + (DsimpB' x : simp (B x) S') + (DkofesB x : kofes (G' x) (B x) sktype))) + <- ({x} + simp-fun (DsimpB x) (DsimpB' x) + (DeqSS' : stp-eq S S')) + <- ({x} + ofes-resp sctx-eq/i tm-eq/i DeqSS' (DofesN x) + (DofesN' x : ofes (G' x) (N x) S')) + %% go + <- ksub-permute-es' Dsord Dsapp DofesM DofesN' DwfkindesK + DsubNx DsubKy DsubKx + (DsubKyx : ksub ([x] Ky x) M Kyx) + (DsubKxy : ksub ([y] Kx y) Nx Kyx). + +-appclo : atpsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub G M Gx) + (DofM : ofe G1 M A) + atpsub/closed + ([x] at-kofe/app + (DsubKy x : ksub ([y] K x y) N (Ky x)) + (DofN x : ofe (G x) N (B x)) + (DofP x : at-kofe (G x) P (kpi (B x) [y] K x y)) + : at-kofe (G x) (aapp P N) (Ky x)) +%% + DsubKyx + (at-kofe/app DsubKxy DofN' DofP') +%% + <- atpsubst-em T Dsimp Dord Dapp Dcsub DofM atpsub/closed DofP + (ksub/pi + ([y] DsubKx y : ksub ([x] K x y) M (Kx y)) + (DsubBx : tpsub ([x] B x) M Bx)) + (DofP' : at-kofe Gx P (kpi Bx ([y] Kx y))) + <- sub-absent N M + (DsubN : sub ([_] N) M N) + <- subst-em T Dsimp Dord Dapp Dcsub DofM DsubN DsubBx DofN + (DofN' : ofe Gx N Bx) + %% simplify context to pass to permutation + <- can-simpctx G1 (DsimpG1 : simpctx G1 G1') + <- ({x} + can-simpctx (G2 x) (DsimpG2 x : simpctx (G2 x) (G2' x))) + <- ({x} + can-simpctx (G x) (DsimpG x : simpctx (G x) (G' x))) + <- ({x} + append-simpctx' (Dapp x) + (simpctx/cons Dsimp DsimpG1) + (DsimpG2 x) + (DsimpG x) + (Dsapp x : sappend (scons G1' x T) (G2' x) (G' x))) + <- ({x} {d} + ordered-simpctx (DsimpG x) (Dord x d) + (Dsord x d : sordered (G' x))) + %% simplify typing derivations + <- ofe-simp DsimpG1 Dsimp DofM + (DofesM : ofes G1' M T) + <- ({x} + can-simp (B x) + (DsimpB x : simp (B x) S)) + <- ({x} + ofe-simp (DsimpG x) (DsimpB x) (DofN x) + (DofesN x : ofes (G' x) N S)) + %% apply simple regularity to get DwfkindesK + <- ({x} {d} + atkofe-reg-wfkindes (Dord x d) (DofP x) (DsimpG x) + (wfkindes/pi + ([y] DwfkindesK x y + : wfkindes (scons (G' x) y S') (K x y)) + (DsimpB' x : simp (B x) S') + (DkofesB x : kofes (G' x) (B x) sktype))) + <- ({x} + simp-fun (DsimpB x) (DsimpB' x) + (DeqSS' : stp-eq S S')) + <- ({x} + ofes-resp sctx-eq/i tm-eq/i DeqSS' (DofesN x) + (DofesN' x : ofes (G' x) N S')) + %% go + <- ksub-permute-es' Dsord Dsapp DofesM DofesN' DwfkindesK + DsubN DsubKy DsubKx + (DsubKyx : ksub ([x] Ky x) M Kyx) + (DsubKxy : ksub ([y] Kx y) N Kyx). + +-base : tpsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + (tpsub/base (Datpsub : atpsub P M Px)) + ([x] kofe/base (DofP x : at-kofe (G x) (P x) ktype)) + ksub/type +%% + (kofe/base DofPx) +%% + <- atpsubst-em T Dsimp Dord Dapp Dcsub DofM Datpsub DofP + ksub/type + (DofPx : at-kofe Gx Px ktype). + +-pi : tpsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + (tpsub/pi + ([y] DsubB2 y : tpsub ([x] B2 x y) M (B2x y)) + (DsubB1 : tpsub ([x] B1 x) M B1x)) + ([x] kofe/pi + ([y] DofB2 x y + : kofe (cons (G x) y (B1 x)) (B2 x y) ktype) + (DofB1 x : kofe (G x) (B1 x) ktype)) + ksub/type +%% + (kofe/pi ([y] DofB2x y) DofB1x) +%% + <- tpsubst-em T Dsimp Dord Dapp Dcsub DofM DsubB1 DofB1 + ksub/type + (DofB1x : kofe Gx B1x ktype) + <- ({x} {d} + extend-ordered _ (Dord x d) _ + ([y] [e] Dord' x d y e + : ordered (cons (G x) y (B1 x)))) + <- ({y} {e} + tpsubst-em T Dsimp + ([x] [d] Dord' x d y e) + ([x] append/cons (Dapp x)) + (csub/cons DsubB1 Dcsub) + DofM + (DsubB2 y) + ([x] DofB2 x y) + ksub/type + (DofB2x y : kofe (cons Gx y B1x) (B2x y) ktype)). + +-alam : tpsubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + (tpsub/lam ([y] DsubC y : tpsub ([x] C x y) M (Cx y))) + ([x] kofe/lam + ([y] DofC x y + : kofe (cons (G x) y (B x)) (C x y) (K x y)) + (DofB x : kofe (G x) (B x) ktype)) + (ksub/pi + ([y] DsubK y : ksub ([x] K x y) M (Kx y)) + (DsubB : tpsub ([x] B x) M Bx)) +%% + (kofe/lam ([y] DofCx y) DofBx) +%% + <- tpsubst-em T Dsimp Dord Dapp Dcsub DofM DsubB DofB + ksub/type + (DofBx : kofe Gx Bx ktype) + <- ({x} {d} + extend-ordered _ (Dord x d) _ + ([y] [e] Dord' x d y e + : ordered (cons (G x) y (B x)))) + <- ({y} {e} + tpsubst-em T Dsimp + ([x] [d] Dord' x d y e) + ([x] append/cons (Dapp x)) + (csub/cons DsubB Dcsub) + DofM + (DsubC y) + ([x] DofC x y) + (DsubK y) + (DofCx y : kofe (cons Gx y Bx) (Cx y) (Kx y))). + +-ktype : ksubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + ksub/type + ([_] wfkinde/tp) + wfkinde/tp. + +-kpi : ksubst-em T (Dsimp : simp A T) + ([x] [d] Dord x d : ordered (G x)) + ([x] Dapp x : append (cons G1 x A) (G2 x) (G x)) + (Dcsub : csub ([x] G x) M Gx) + (DofM : ofe G1 M A) + (ksub/pi + ([y] DsubK y : ksub ([x] K x y) M (Kx y)) + (DsubB : tpsub ([x] B x) M Bx)) + ([x] wfkinde/pi + ([y] DofK x y : wfkinde (cons (G x) y (B x)) (K x y)) + (DofB x : kofe (G x) (B x) ktype)) +%% + (wfkinde/pi ([y] DofKx y) DofBx) +%% + <- tpsubst-em T Dsimp Dord Dapp Dcsub DofM DsubB DofB + ksub/type + (DofBx : kofe Gx Bx ktype) + <- ({x} {d} + extend-ordered _ (Dord x d) _ + ([y] [e] Dord' x d y e + : ordered (cons (G x) y (B x)))) + <- ({y} {e} + ksubst-em T Dsimp + ([x] [d] Dord' x d y e) + ([x] append/cons (Dapp x)) + (csub/cons DsubB Dcsub) + DofM + (DsubK y) + ([x] DofK x y) + (DofKx y : wfkinde (cons Gx y Bx) (Kx y))). + + +%worlds (csig | asig | bind | var | ovar) + (rrsubst-em _ _ _ _ _ _ _ _ _ _) + (rmsubst-em _ _ _ _ _ _ _ _ _ _) + (subst-em _ _ _ _ _ _ _ _ _ _) + (atpsubst-em _ _ _ _ _ _ _ _ _ _) + (tpsubst-em _ _ _ _ _ _ _ _ _ _) + (ksubst-em _ _ _ _ _ _ _ _ _). +%total {(T1 T2 T3 T4 T5 T6) (D1 D2 D3 D4 D5 D6)} + (rrsubst-em T1 _ _ _ _ _ _ D1 _ _) + (rmsubst-em T2 _ _ _ _ _ _ D2 _ _) + (subst-em T3 _ _ _ _ _ _ _ D3 _) + (atpsubst-em T4 _ _ _ _ _ _ D4 _ _) + (tpsubst-em T5 _ _ _ _ _ _ D5 _ _) + (ksubst-em T6 _ _ _ _ _ _ D6 _). + + + +subst-e : ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> sub N M N' + -> tpsub B M B' + -> ({x} ofe (G x) (N x) (B x)) +%% + -> ofe G' N' B' -> type. +%mode subst-e +X0 +X1 +X2 +X3 +X4 +X5 +X6 -X7. + + +- : subst-e Dord Dapp Dcsub Dof Dsub Dtpsub Dof' D + <- can-simp _ Dsimp + <- subst-em _ Dsimp Dord Dapp Dcsub Dof Dsub Dtpsub Dof' D. + + +%worlds (csig | asig | var | bind | ovar) (subst-e _ _ _ _ _ _ _ _). +%total {} (subst-e _ _ _ _ _ _ _ _). + + +tpsubst-e : ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> tpsub B M B' + -> ({x} kofe (G x) (B x) (K x)) + -> ksub K M K' +%% + -> kofe G' B' K' -> type. +%mode tpsubst-e +X0 +X1 +X2 +X3 +X4 +X5 +X6 -X7. + + +- : tpsubst-e Dord Dapp Dcsub Dof Dtpsub Dkof Dksub D + <- can-simp _ Dsimp + <- tpsubst-em _ Dsimp Dord Dapp Dcsub Dof Dtpsub Dkof Dksub D. + + +%worlds (csig | asig | bind | var | ovar) (tpsubst-e _ _ _ _ _ _ _ _). +%total {} (tpsubst-e _ _ _ _ _ _ _ _). + + +ksubst-e : ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> csub G M G' + -> ofe G1 M A + -> ksub ([x] K x) M K' + -> ({x} wfkinde (G x) (K x)) +%% + -> wfkinde G' K' -> type. +%mode ksubst-e +X1 +X2 +X3 +X4 +X5 +X6 -X7. + +- : ksubst-e Dord Dapp Dcsub Dof Dksub Dkof D + <- can-simp _ Dsimp + <- ksubst-em _ Dsimp Dord Dapp Dcsub Dof Dksub Dkof D. + +%worlds (csig | asig | bind | var | ovar) (ksubst-e _ _ _ _ _ _ _). +%total {} (ksubst-e _ _ _ _ _ _ _). + + +%%%%% substitution lemma %%%%% + +subst : sub ([x] M x) N Mx + -> tpsub ([x] B x) N Bx + -> ({x} vof x A -> of (M x) (B x)) + -> of N A +%% + -> of Mx Bx -> type. +%mode subst +X1 +X2 +X3 +X4 -X5. + +- : subst + (Dsub : sub ([x] M x) N Mx) + (Dtpsub : tpsub ([x] B x) N Bx) + (DofM : {x} vof x A -> of (M x) (B x)) + (DofN : of N A) +%% + Dof +%% + <- of1-to-ofe DofM + (DofeM : {x} ofe (cons nil x A) (M x) (B x)) + <- of-to-ofe DofN + (DofeN : ofe nil N A) + <- extend-ordered _ ordered/nil _ + ([x] [d] Dord x d : ordered (cons nil x A)) + <- subst-e Dord + ([_] append/nil) csub/base DofeN Dsub Dtpsub DofeM + (Dofe : ofe nil Mx Bx) + <- ofe-to-of Dofe (Dof : of Mx Bx). + +%worlds (csig | asig | var | bind | ovar) (subst _ _ _ _ _). +%total {} (subst _ _ _ _ _). + + +tpsubst : tpsub ([x] B x) N Bx + -> ksub ([x] K x) N Kx + -> ({x} vof x A -> kof (B x) (K x)) + -> of N A +%% + -> kof Bx Kx -> type. +%mode tpsubst +X0 +X1 +X2 +X3 -X4. + + +- : tpsubst + (Dtpsub : tpsub ([x] B x) N Bx) + (Dksub : ksub ([x] K x) N Kx) + (DofB : {x} vof x A -> kof (B x) (K x)) + (DofN : of N A) +%% + DofBx +%% + <- kof1-to-kofe DofB + (DofeB : {x} kofe (cons nil x A) (B x) (K x)) + <- of-to-ofe DofN + (DofeN : ofe nil N A) + <- extend-ordered _ ordered/nil _ + ([x] [d] Dord x d : ordered (cons nil x A)) + <- tpsubst-e Dord ([_] append/nil) csub/base DofeN Dtpsub DofeB + Dksub + (DofeBx : kofe nil Bx Kx) + <- kofe-to-kof DofeBx + (DofBx : kof Bx Kx). + +%worlds (csig | asig | bind | var | ovar) (tpsubst _ _ _ _ _). +%total {} (tpsubst _ _ _ _ _). + + +ksubst : ksub ([x] K x) N Kx + -> ({x} vof x A -> wfkind (K x)) + -> of N A +%% + -> wfkind Kx -> type. +%mode ksubst +X1 +X2 +X3 -X4. + +- : ksubst + (Dksub : ksub ([x] K x) N Kx) + (DofK : {x} vof x A -> wfkind (K x)) + (DofN : of N A) +%% + DofKx +%% + <- wfkind1-to-wfkinde DofK + (DofeK : {x} wfkinde (cons nil x A) (K x)) + <- of-to-ofe DofN + (DofeN : ofe nil N A) + <- extend-ordered _ ordered/nil _ + ([x] [d] Dord x d : ordered (cons nil x A)) + <- ksubst-e Dord ([_] append/nil) csub/base DofeN Dksub DofeK + (DofeKx : wfkinde nil Kx) + <- wfkinde-to-wfkind DofeKx + (DofKx : wfkind Kx). + +%worlds (csig | asig | bind | var | ovar) (ksubst _ _ _ _). +%total {} (ksubst _ _ _ _). + diff --git a/src/trans-explicit.thm b/src/trans-explicit.thm new file mode 100644 index 0000000..5ecb49d --- /dev/null +++ b/src/trans-explicit.thm @@ -0,0 +1,1747 @@ + +%%%% Weakening %%%% + +weakeng-transe : append G1 G2 G + -> append (cons G1 X B) G2 G' + -> transe G EM M A +%% + -> transe G' EM M A -> type. +%mode weakeng-transe +X1 +X2 +X3 -X4. + +weakeng-tptranse : append G1 G2 G + -> append (cons G1 X B) G2 G' + -> tptranse G EM M A +%% + -> tptranse G' EM M A -> type. +%mode weakeng-tptranse +X1 +X2 +X3 -X4. + +-const : weakeng-transe _ _ + (transe/const Dexp Dsimp Dkof Dcof) + (transe/const Dexp Dsimp Dkof Dcof). + +-var : weakeng-transe Dapp Dapp' + (transe/var Dexp Dsimp Dkof Dlook Dvtrans) + (transe/var Dexp Dsimp Dkof' Dlook' Dvtrans) + <- weakeng-kofe Dapp Dapp' Dkof Dkof' + <- weakeng-lookup Dapp Dapp' Dlook Dlook'. + +-vari : weakeng-transe Dapp Dapp' + (transe/vari Dexpand Dsimp Dkof Dvof Dvtrans) + (transe/vari Dexpand Dsimp Dkof Dvof Dvtrans). + +-app : weakeng-transe Dapp Dapp' + (transe/app Dtpsub Dsub Dtrans2 Dtrans1) + (transe/app Dtpsub Dsub Dtrans2' Dtrans1') + <- weakeng-transe Dapp Dapp' Dtrans1 Dtrans1' + <- weakeng-transe Dapp Dapp' Dtrans2 Dtrans2'. + +-lam : weakeng-transe Dapp Dapp' + (transe/lam ([x] [ex] [xt] DtransM x ex xt) DtransA) + (transe/lam ([x] [ex] [xt] DtransM' x ex xt) DtransA') + <- ({x} {ex} {xt} + weakeng-transe (append/cons Dapp) (append/cons Dapp') + (DtransM x ex xt) (DtransM' x ex xt)) + <- weakeng-tptranse Dapp Dapp' DtransA DtransA'. + +%% + +-const : weakeng-tptranse Dapp Dapp' + (tptranse/const Dexpand Dsimp Dwf Dcof) + (tptranse/const Dexpand Dsimp Dwf Dcof). + +-app : weakeng-tptranse Dapp Dapp' + (tptranse/app Dksub Dsub Dtranse Dtptranse) + (tptranse/app Dksub Dsub Dtranse' Dtptranse') + <- weakeng-transe Dapp Dapp' Dtranse Dtranse' + <- weakeng-tptranse Dapp Dapp' Dtptranse Dtptranse'. + +-pi : weakeng-tptranse Dapp Dapp' + (tptranse/pi ([x] [ex] [xt] DtransB x ex xt) DtransA) + (tptranse/pi ([x] [ex] [xt] DtransB' x ex xt) DtransA') + <- weakeng-tptranse Dapp Dapp' DtransA DtransA' + <- ({x} {ex} {xt} + weakeng-tptranse (append/cons Dapp) (append/cons Dapp') + (DtransB x ex xt) (DtransB' x ex xt)). + +-lam : weakeng-tptranse Dapp Dapp' + (tptranse/lam ([x] [ex] [xt] DtransB x ex xt) DtransA) + (tptranse/lam ([x] [ex] [xt] DtransB' x ex xt) DtransA') + <- weakeng-tptranse Dapp Dapp' DtransA DtransA' + <- ({x} {ex} {xt} + weakeng-tptranse (append/cons Dapp) (append/cons Dapp') + (DtransB x ex xt) (DtransB' x ex xt)). + +%worlds (csig | asig | var | bind | tvar | tbind | tobind) + (weakeng-transe _ _ _ _) + (weakeng-tptranse _ _ _ _). +%total (D1 D2) + (weakeng-transe _ _ D1 _) + (weakeng-tptranse _ _ D2 _). + +weaken-transe : transe G EM M B + -> {X} {A} transe (cons G X A) EM M B -> type. +%mode weaken-transe +X1 +X +A -X2. + +- : weaken-transe Dtrans X S Dtrans' + <- weakeng-transe append/nil append/nil Dtrans Dtrans'. + +%worlds (csig | asig | var | bind | tbind | tobind) (weaken-transe _ _ _ _). +%total {} (weaken-transe _ _ _ _). + +weaken-transe' : append G1 G2 G -> transe G1 EM M B + -> transe G EM M B -> type. +%mode weaken-transe' +X2 +X3 -X4. + +-nil : weaken-transe' append/nil D D. + +-cons : weaken-transe' (append/cons Dapp) Dtrans Dtrans'' + <- weaken-transe' Dapp Dtrans Dtrans' + <- weaken-transe Dtrans' _ _ Dtrans''. + +%worlds (csig | asig | bind | tbind | tobind) (weaken-transe' _ _ _). +%total D (weaken-transe' D _ _). + +%%%% Cut %%%% + +%% uses metric defined in explicit-lemmas.thm +mtrans : trans EM M A -> metric -> type. +mtptrans : tptrans EA A K -> metric -> type. +mktrans : ktrans EK K -> metric -> type. + +mtrans/const : mtrans (trans/const _ _ Dkof _) (msing Dkof') + <- mkof Dkof Dkof'. + +mtrans/var : mtrans (trans/var _ _ Dkof _ _) (msing Dkof') + <- mkof Dkof Dkof'. + +mtrans/app : mtrans (trans/app _ _ DtransN DtransM) (mpair Nm Mm) + <- mtrans DtransM Mm + <- mtrans DtransN Nm. + +mtrans/lam : mtrans (trans/lam DtransM DtransA) (mpair Mm Am) + <- mtptrans DtransA Am + <- ({x} {d} {ex} {xt} + mtrans (DtransM x d ex xt) Mm). + +mtptrans/const : mtptrans (tptrans/const _ _ Dwfkind _) (msing Dmwfkind) + <- mwfkind Dwfkind Dmwfkind. + +mtptrans/app : mtptrans (tptrans/app _ _ DtransN DtransM) (mpair Nm Mm) + <- mtptrans DtransM Mm + <- mtrans DtransN Nm. + +mtptrans/pi : mtptrans (tptrans/pi DtransB DtransA) (mpair Bm Am) + <- mtptrans DtransA Am + <- ({x} {d} {ex} {xt} + mtptrans (DtransB x d ex xt) Bm). + +mtptrans/lam : mtptrans (tptrans/lam DtransB DtransA) (mpair Bm Am) + <- mtptrans DtransA Am + <- ({x} {d} {ex} {xt} + mtptrans (DtransB x d ex xt) Bm). + +mktrans/type : mktrans ktrans/type munit. + +mktrans/pi : mktrans (ktrans/pi Dktrans Dtptrans) (mpair Km Am) + <- mtptrans Dtptrans Am + <- ({x} {d} {ex} {xt} + mktrans (Dktrans x d ex xt) Km). + +%% + +mtranse : transe G EM M A -> metric -> type. +mtptranse : tptranse G EM M A -> metric -> type. +mktranse : ktranse G EK K -> metric -> type. + +mtranse/const : mtranse (transe/const _ _ Dkof _) (msing Dkof') + <- mkof Dkof Dkof'. + +mtranse/var : mtranse (transe/var _ _ Dkof _ _) (msing Dkof') + <- mkofe Dkof Dkof'. + +mtranse/vari : mtranse (transe/vari _ _ Dkof _ _) (msing Dkof') + <- mkof Dkof Dkof'. + +mtranse/app : mtranse (transe/app _ _ DtransN DtransM) (mpair Nm Mm) + <- mtranse DtransM Mm + <- mtranse DtransN Nm. + +mtranse/lam : mtranse (transe/lam DtransB DtransA) (mpair Bm Am) + <- mtptranse DtransA Am + <- ({x} {ex} {xt} + mtranse (DtransB x ex xt) Bm). + +mtptranse/const : mtptranse (tptranse/const _ _ Dwfkind _) (msing Dmwfkind) + <- mwfkind Dwfkind Dmwfkind. + +mtptranse/app : mtptranse (tptranse/app _ _ DtransN DtransM) + (mpair Nm Mm) + <- mtptranse DtransM Mm + <- mtranse DtransN Nm. + +mtptranse/lam : mtptranse (tptranse/lam DtransB DtransA) (mpair Bm Am) + <- mtptranse DtransA Am + <- ({x} {ex} {xt} + mtptranse (DtransB x ex xt) Bm). + +mtptranse/pi : mtptranse (tptranse/pi DtransB DtransA) (mpair Bm Am) + <- mtptranse DtransA Am + <- ({x} {ex} {xt} + mtptranse (DtransB x ex xt) Bm). + +mktranse/type : mktranse ktranse/type munit. + +mktranse/pi : mktranse (ktranse/pi Dktrans Dtptrans) (mpair Km Am) + <- mtptranse Dtptrans Am + <- ({x} {ex} {xt} + mktranse (Dktrans x ex xt) Km). + + +can-mtptrans : {D : tptrans EA A K} mtptrans D Dm -> type. +%mode can-mtptrans +X1 -X2. + +can-mtrans : {D : trans EM M A} mtrans D Dm -> type. +%mode can-mtrans +X1 -X2. + +-const : can-mtrans (trans/const _ _ Dkof _) (mtrans/const Dkof') + <- can-mkof Dkof Dkof'. + +-var : can-mtrans (trans/var _ _ Dkof _ _) (mtrans/var Dmkof) + <- can-mkof Dkof Dmkof. + +-app : can-mtrans (trans/app _ _ DtransN DtransM) + (mtrans/app DmtransN DmtransM) + <- can-mtrans DtransN DmtransN + <- can-mtrans DtransM DmtransM. + +-lam : can-mtrans + (trans/lam + ([x] [d] [ex] [xt] DtransM x d ex xt) + DtransA) + (mtrans/lam + ([x] [d] [ex] [xt] DmtransM x d ex xt) + DmtransA) + <- ({x} {d} {ex} {xt} + can-mtrans (DtransM x d ex xt) + (DmtransM x d ex xt)) + <- can-mtptrans DtransA DmtransA. + +%% + +-const : can-mtptrans (tptrans/const _ _ Dwfkind _) (mtptrans/const Dmwfkind) + <- can-mwfkind Dwfkind Dmwfkind. + +-lam : can-mtptrans + (tptrans/lam + ([x] [d] [ex] [xt] DtransM x d ex xt) + DtransA) + (mtptrans/lam + ([x] [d] [ex] [xt] DmtransM x d ex xt) + DmtransA) + <- ({x} {d} {ex} {xt} + can-mtptrans (DtransM x d ex xt) + (DmtransM x d ex xt)) + <- can-mtptrans DtransA DmtransA. + +-app : can-mtptrans (tptrans/app _ _ DtransN DtransM) + (mtptrans/app DmtransN DmtransM) + <- can-mtrans DtransN DmtransN + <- can-mtptrans DtransM DmtransM. + +-pi : can-mtptrans + (tptrans/pi + ([x] [d] [ex] [xt] DtransM x d ex xt) + DtransA) + (mtptrans/pi + ([x] [d] [ex] [xt] DmtransM x d ex xt) + DmtransA) + <- ({x} {d} {ex} {xt} + can-mtptrans (DtransM x d ex xt) + (DmtransM x d ex xt)) + <- can-mtptrans DtransA DmtransA. + + +%worlds (csig | asig | bind | tbind | tobind) (can-mtrans _ _) (can-mtptrans _ _). +%total (D1 D2) (can-mtrans D1 _) (can-mtptrans D2 _). + +can-mktrans : {D : ktrans EK K} mktrans D Dm -> type. +%mode can-mktrans +X1 -X2. + +-type : can-mktrans ktrans/type mktrans/type. + +-pi : can-mktrans + (ktrans/pi ([x] [d] [ex] [xt] Dktrans x d ex xt) Dtptrans) + (mktrans/pi Dmktrans Dmtptrans) + <- ({x} {d} {ex} {xt} + can-mktrans (Dktrans x d ex xt) (Dmktrans x d ex xt)) + <- can-mtptrans Dtptrans Dmtptrans. + +%worlds (csig | asig | bind | tbind | tobind) (can-mktrans _ _). +%total D (can-mktrans D _). + + +%% + +cut-trans-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + trans (EM ex) (M x) (B x)} + ({x} {d} {ex} {xt} mtrans (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + transe (G x) (EM ex) (M x) (B x)} + ({x} {ex} {xt} mtranse (D' x ex xt) Mm) -> type. +%mode cut-trans-m +Mm +D +Dm +Dlook -D' -D'm. + +cut-tptrans-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + tptrans (EM ex) (M x) (B x)} + ({x} {d} {ex} {xt} mtptrans (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + tptranse (G x) (EM ex) (M x) (B x)} + ({x} {ex} {xt} mtptranse (D' x ex xt) Mm) -> type. +%mode cut-tptrans-m +Mm +D +Dm +Dlook -D' -D'm. + +cut-transe-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + transe (G x) (EM ex) (M x) (B x)} + ({x} {d} {ex} {xt} mtranse (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + transe (G x) (EM ex) (M x) (B x)} + ({x} {ex} {xt} mtranse (D' x ex xt) Mm) -> type. +%mode cut-transe-m +Mm +D +Dm +Dlook -D' -D'm. + +cut-tptranse-m : {Mm} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + tptranse (G x) (EM ex) (M x) (B x)} + ({x} {d} {ex} {xt} mtptranse (D x d ex xt) Mm) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + tptranse (G x) (EM ex) (M x) (B x)} + ({x} {ex} {xt} mtptranse (D' x ex xt) Mm) -> type. +%mode cut-tptranse-m +Mm +D +Dm +Dlook -D' -D'm. + +-const : cut-trans-m _ + ([x] [d] [ex] [xt] + trans/const + (Dexpand x : expand (const C) T (N x)) + (Dsimp x : simp B T) + (Dkof x d : kof B ktype) + (Dcof : cof C B)) + ([x] [d] [ex] [xt] mtrans/const (Dmkof x d)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/const + (Dexpand x) + (Dsimp x) + Dkof' + Dcof) + ([x] [ex] [xt] mtranse/const Dmkof') +%% + <- strengthen-for-cut-kof _ Dkof Dmkof + (Dkof' : kof B ktype) + Dmkof'. + +-varoth : cut-trans-m _ + ([x] [d] [ex] [xt] + trans/var + (Dexpand x : expand Y T (N x)) + (Dsimp x : simp B T) + (Dkof x d : kof B ktype) + (Dvof : vof Y B) + (Dvtrans : vtrans EY Y)) + ([x] [d] [ex] [xt] + mtrans/var + (Dmkof x d : mkof (Dkof x d) Mkof)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/vari + (Dexpand x) + (Dsimp x) + Dkof' + Dvof + Dvtrans) + ([x] [ex] [xt] mtranse/vari Dmkof') +%% + <- strengthen-for-cut-kof _ Dkof Dmkof + (Dkof' : kof B ktype) + (Dmkof' : mkof Dkof' Mkof). + +-varsam : cut-trans-m _ + ([x] [d] [ex] [xt] + trans/var + (Dexpand x : expand x T (N x)) + (Dsimp x : simp A T) + (Dkof x d : kof A ktype) + d + xt) + ([x] [d] [ex] [xt] + mtrans/var + (Dmkof x d : mkof (Dkof x d) Mkof)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/var + (Dexpand x) + (Dsimp x) + (Dkofe x) + (Dlook x) + xt) + ([x] [ex] [xt] mtranse/var (Dmkofe x)) +%% + <- cut-kof _ Dkof Dmkof Dlook + ([x] Dkofe x : kofe (G x) A ktype) + ([x] Dmkofe x). + +-lam : cut-trans-m _ + ([x] [d] [ex] [xt] + trans/lam + ([y] [e] [ey] [yt] + DtransM x d ex xt y e ey yt + : trans (EM ex ey) (M x y) (B x y)) + (DtransA x d ex xt + : tptrans (EA ex) (A x) ktype)) + ([x] [d] [ex] [xt] + mtrans/lam + ([y] [e] [ey] [yt] DmtransM x d ex xt y e ey yt) + (DmtransA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + transe/lam + ([y] [ey] [yt] DtranseM' x ex xt y ey yt) + (DtranseA x ex xt)) + ([x] [ex] [xt] + mtranse/lam + ([y] [ey] [yt] DmtranseM' x ex xt y ey yt) + (DmtranseA x ex xt)) +%% + <- ({x} {d} {ex} {xt} + cut-trans-m _ + ([y] [e] [ey] [yt] DtransM x d ex xt y e ey yt) + ([y] [e] [ey] [yt] DmtransM x d ex xt y e ey yt) + ([y] lookup/hit) + ([y] [ey] [yt] DtranseM x d ex xt y ey yt + : transe (cons (G x) y (A x)) + (EM ex ey) (M x y) (B x y)) + ([y] [ey] [yt] DmtranseM x d ex xt y ey yt)) + <- ({y} {ey} {yt} + cut-transe-m _ + ([x] [d] [ex] [xt] DtranseM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmtranseM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DtranseM' x ex xt y ey yt + : transe (cons (G x) y (A x)) + (EM ex ey) (M x y) (B x y)) + ([x] [ex] [xt] DmtranseM' x ex xt y ey yt)) + <- cut-tptrans-m _ DtransA DmtransA Dlook + ([x] [ex] [xt] DtranseA x ex xt + : tptranse (G x) (EA ex) (A x) ktype) + ([x] [ex] [xt] DmtranseA x ex xt). + +-app : cut-trans-m _ + ([x] [d] [ex] [xt] + trans/app + (Dtpsub x : tpsub ([y] C x y) (N x) (Cy x)) + (Dsub x : sub ([y] M x y) (N x) (My x)) + (DtransN x d ex xt : trans (EN ex) (N x) (B x)) + (DtransM x d ex xt + : trans (EM ex) (lam ([y] M x y)) + (pi (B x) ([y] C x y)))) + ([x] [d] [ex] [xt] + mtrans/app + (DmtransN x d ex xt) + (DmtransM x d ex xt)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/app + (Dtpsub x) + (Dsub x) + (DtranseN x ex xt) + (DtranseM x ex xt)) + ([x] [ex] [xt] + mtranse/app + (DmtranseN x ex xt) + (DmtranseM x ex xt)) +%% + <- cut-trans-m _ DtransN DmtransN Dlook + ([x] [ex] [xt] DtranseN x ex xt + : transe (G x) (EN ex) (N x) (B x)) + ([x] [ex] [xt] DmtranseN x ex xt) + <- cut-trans-m _ DtransM DmtransM Dlook + ([x] [ex] [xt] DtranseM x ex xt + : transe (G x) (EM ex) (lam [y] M x y) + (pi (B x) [y] C x y)) + ([x] [ex] [xt] DmtranseM x ex xt). + +%% + +-const : cut-tptrans-m _ + ([x] [d] [ex] [xt] + tptrans/const + (Dexpand x : tpexpand (aconst C) T (N x)) + (Dsimp x : ksimp B T) + (Dkof x d : wfkind B) + (Dcof : ckof C B)) + ([x] [d] [ex] [xt] mtptrans/const (Dmkof x d)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + tptranse/const + (Dexpand x) + (Dsimp x) + Dkof'' + Dcof) + ([x] [ex] [xt] mtptranse/const Dmkof'') +%% + <- strengthen-for-cut-wfkind _ Dkof Dmkof + (Dkof'' : wfkind B) + Dmkof''. + +-app : cut-tptrans-m _ + ([x] [d] [ex] [xt] + tptrans/app + (Dtpsub x : ksub ([y] C x y) (N x) (Cy x)) + (Dsub x : tpsub ([y] M x y) (N x) (My x)) + (DtransN x d ex xt : trans (EN ex) (N x) (B x)) + (DtransM x d ex xt + : tptrans (EM ex) (alam ([y] M x y)) + (kpi (B x) ([y] C x y)))) + ([x] [d] [ex] [xt] + mtptrans/app + (DmtransN x d ex xt) + (DmtransM x d ex xt)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + tptranse/app + (Dtpsub x) + (Dsub x) + (DtranseN x ex xt) + (DtranseM x ex xt)) + ([x] [ex] [xt] + mtptranse/app + (DmtranseN x ex xt) + (DmtranseM x ex xt)) +%% + <- cut-trans-m _ DtransN DmtransN Dlook + ([x] [ex] [xt] DtranseN x ex xt + : transe (G x) (EN ex) (N x) (B x)) + ([x] [ex] [xt] DmtranseN x ex xt) + <- cut-tptrans-m _ DtransM DmtransM Dlook + ([x] [ex] [xt] DtranseM x ex xt + : tptranse (G x) (EM ex) (alam [y] M x y) + (kpi (B x) [y] C x y)) + ([x] [ex] [xt] DmtranseM x ex xt). + +-lam : cut-tptrans-m _ + ([x] [d] [ex] [xt] + tptrans/lam + ([y] [e] [ey] [yt] + DtransM x d ex xt y e ey yt + : tptrans (EM ex ey) (M x y) (B x y)) + (DtransA x d ex xt + : tptrans (EA ex) (A x) ktype)) + ([x] [d] [ex] [xt] + mtptrans/lam + ([y] [e] [ey] [yt] DmtransM x d ex xt y e ey yt) + (DmtransA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + tptranse/lam + ([y] [ey] [yt] DtranseM' x ex xt y ey yt) + (DtranseA x ex xt)) + ([x] [ex] [xt] + mtptranse/lam + ([y] [ey] [yt] DmtranseM' x ex xt y ey yt) + (DmtranseA x ex xt)) +%% + <- ({x} {d} {ex} {xt} + cut-tptrans-m _ + ([y] [e] [ey] [yt] DtransM x d ex xt y e ey yt) + ([y] [e] [ey] [yt] DmtransM x d ex xt y e ey yt) + ([y] lookup/hit) + ([y] [ey] [yt] DtranseM x d ex xt y ey yt + : tptranse (cons (G x) y (A x)) + (EM ex ey) (M x y) (B x y)) + ([y] [ey] [yt] DmtranseM x d ex xt y ey yt)) + <- ({y} {ey} {yt} + cut-tptranse-m _ + ([x] [d] [ex] [xt] DtranseM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmtranseM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DtranseM' x ex xt y ey yt + : tptranse (cons (G x) y (A x)) + (EM ex ey) (M x y) (B x y)) + ([x] [ex] [xt] DmtranseM' x ex xt y ey yt)) + <- cut-tptrans-m _ DtransA DmtransA Dlook + ([x] [ex] [xt] DtranseA x ex xt + : tptranse (G x) (EA ex) (A x) ktype) + ([x] [ex] [xt] DmtranseA x ex xt). + +-pi : cut-tptrans-m _ + ([x] [d] [ex] [xt] + tptrans/pi + ([y] [e] [ey] [yt] + DtransM x d ex xt y e ey yt + : tptrans (EM ex ey) (M x y) ktype) + (DtransA x d ex xt + : tptrans (EA ex) (A x) ktype)) + ([x] [d] [ex] [xt] + mtptrans/pi + ([y] [e] [ey] [yt] DmtransM x d ex xt y e ey yt) + (DmtransA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + tptranse/pi + ([y] [ey] [yt] DtranseM' x ex xt y ey yt) + (DtranseA x ex xt)) + ([x] [ex] [xt] + mtptranse/pi + ([y] [ey] [yt] DmtranseM' x ex xt y ey yt) + (DmtranseA x ex xt)) +%% + <- ({x} {d} {ex} {xt} + cut-tptrans-m _ + ([y] [e] [ey] [yt] DtransM x d ex xt y e ey yt) + ([y] [e] [ey] [yt] DmtransM x d ex xt y e ey yt) + ([y] lookup/hit) + ([y] [ey] [yt] DtranseM x d ex xt y ey yt + : tptranse (cons (G x) y (A x)) + (EM ex ey) (M x y) ktype) + ([y] [ey] [yt] DmtranseM x d ex xt y ey yt)) + <- ({y} {ey} {yt} + cut-tptranse-m _ + ([x] [d] [ex] [xt] DtranseM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmtranseM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DtranseM' x ex xt y ey yt + : tptranse (cons (G x) y (A x)) + (EM ex ey) (M x y) ktype) + ([x] [ex] [xt] DmtranseM' x ex xt y ey yt)) + <- cut-tptrans-m _ DtransA DmtransA Dlook + ([x] [ex] [xt] DtranseA x ex xt + : tptranse (G x) (EA ex) (A x) ktype) + ([x] [ex] [xt] DmtranseA x ex xt). + +%% + +-const : cut-transe-m _ + ([x] [d] [ex] [xt] + transe/const + (Dexpand x : expand (const C) T (N x)) + (Dsimp x : simp B T) + (Dkof x d : kof B ktype) + (Dcof : cof C B)) + ([x] [d] [ex] [xt] mtranse/const (Dmkof x d)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/const + (Dexpand x) + (Dsimp x) + Dkof'' + Dcof) + ([x] [ex] [xt] mtranse/const Dmkof'') +%% + <- strengthen-for-cut-kof _ Dkof Dmkof + (Dkof'' : kof B ktype) + Dmkof''. + +-var : cut-transe-m _ + ([x] [d] [ex] [xt] + transe/var + (Dexpand x : expand (Y x) T (M x)) + (Dsimp x : simp (B x) T) + (Dkof x d : kofe (G x) (B x) ktype) + (Dlook x : lookup (G x) (Y x) (B x)) + (Dtrans x ex xt : vtrans (EY ex) (Y x))) + ([x] [d] [ex] [xt] mtranse/var (Dmkof x d)) + ([x] Dlook' x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/var + (Dexpand x) + (Dsimp x) + (Dkof' x) + (Dlook x) + (Dtrans x ex xt)) + ([x] [ex] [xt] mtranse/var (Dmkof' x)) +%% + <- cut-kofe _ Dkof Dmkof Dlook' + ([x] Dkof' x : kofe (G x) (B x) ktype) + ([x] Dmkof' x). + +-varisam : cut-transe-m _ + ([x] [d] [ex] [xt] + transe/vari + (Dexpand x : expand x T (M x)) + (Dsimp x : simp A T) + (Dkof x d : kof A ktype) + d + xt) + ([x] [d] [ex] [xt] mtranse/vari (Dmkof x d)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/var + (Dexpand x) + (Dsimp x) + (Dkofe x) + (Dlook x) + xt) + ([x] [ex] [xt] mtranse/var (Dmkofe x)) +%% + <- cut-kof _ Dkof Dmkof Dlook + ([x] Dkofe x : kofe (G x) A ktype) + ([x] Dmkofe x). + +-varioth : cut-transe-m _ + ([x] [d] [ex] [xt] + transe/vari + (Dexpand x : expand Y T (M x)) + (Dsimp x : simp B T) + (Dkof x d : kof B ktype) + (Dvof : vof Y B) + (Dvtrans : vtrans EY Y)) + ([x] [d] [ex] [xt] mtranse/vari (Dmkof x d)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/vari + (Dexpand x) + (Dsimp x) + Dkof' + Dvof + Dvtrans) + ([x] [ex] [xt] mtranse/vari Dmkof') +%% + <- strengthen-for-cut-kof _ Dkof Dmkof + (Dkof' : kof B ktype) + Dmkof'. + +-lam : cut-transe-m _ + ([x] [d] [ex] [xt] + transe/lam + ([y] [ey] [yt] + DtransM x d ex xt y ey yt + : transe (cons (G x) y (A x)) + (EM ex ey) (M x y) (B x y)) + (DtransA x d ex xt + : tptranse (G x) (EA ex) (A x) ktype)) + ([x] [d] [ex] [xt] + mtranse/lam + ([y] [ey] [yt] DmtransM x d ex xt y ey yt) + (DmtransA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + transe/lam + ([y] [ey] [yt] DtranseM' x ex xt y ey yt) + (DtranseA x ex xt)) + ([x] [ex] [xt] + mtranse/lam + ([y] [ey] [yt] DmtranseM' x ex xt y ey yt) + (DmtranseA x ex xt)) +%% + <- ({y} {ey} {yt} + cut-transe-m _ + ([x] [d] [ex] [xt] DtransM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmtransM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DtranseM' x ex xt y ey yt + : transe (cons (G x) y (A x)) + (EM ex ey) (M x y) (B x y)) + ([x] [ex] [xt] DmtranseM' x ex xt y ey yt)) + <- cut-tptranse-m _ DtransA DmtransA Dlook + ([x] [ex] [xt] DtranseA x ex xt + : tptranse (G x) (EA ex) (A x) ktype) + ([x] [ex] [xt] DmtranseA x ex xt). + +-app : cut-transe-m _ + ([x] [d] [ex] [xt] + transe/app + (Dtpsub x : tpsub ([y] C x y) (N x) (Cy x)) + (Dsub x : sub ([y] M x y) (N x) (My x)) + (DtransN x d ex xt + : transe (G x) (EN ex) (N x) (B x)) + (DtransM x d ex xt + : transe (G x) (EM ex) (lam ([y] M x y)) + (pi (B x) ([y] C x y)))) + ([x] [d] [ex] [xt] + mtranse/app + (DmtransN x d ex xt) + (DmtransM x d ex xt)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + transe/app + (Dtpsub x) + (Dsub x) + (DtranseN x ex xt) + (DtranseM x ex xt)) + ([x] [ex] [xt] + mtranse/app + (DmtranseN x ex xt) + (DmtranseM x ex xt)) +%% + <- cut-transe-m _ DtransN DmtransN Dlook + ([x] [ex] [xt] DtranseN x ex xt + : transe (G x) (EN ex) (N x) (B x)) + ([x] [ex] [xt] DmtranseN x ex xt) + <- cut-transe-m _ DtransM DmtransM Dlook + ([x] [ex] [xt] DtranseM x ex xt + : transe (G x) (EM ex) (lam [y] M x y) + (pi (B x) [y] C x y)) + ([x] [ex] [xt] DmtranseM x ex xt). + +%% + +-const : cut-tptranse-m _ + ([x] [d] [ex] [xt] + tptranse/const + (Dexpand x : tpexpand (aconst C) T (N x)) + (Dsimp x : ksimp B T) + (Dkof x d : wfkind B) + (Dcof : ckof C B)) + ([x] [d] [ex] [xt] mtptranse/const (Dmkof x d)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + tptranse/const + (Dexpand x) + (Dsimp x) + Dkof'' + Dcof) + ([x] [ex] [xt] + mtptranse/const + Dmkof'') +%% + <- strengthen-for-cut-wfkind _ Dkof Dmkof + (Dkof'' : wfkind B) + Dmkof''. + +-app : cut-tptranse-m _ + ([x] [d] [ex] [xt] + tptranse/app + (Dtpsub x : ksub ([y] C x y) (N x) (Cy x)) + (Dsub x : tpsub ([y] M x y) (N x) (My x)) + (DtransN x d ex xt + : transe (G x) (EN ex) (N x) (B x)) + (DtransM x d ex xt + : tptranse (G x) (EM ex) (alam ([y] M x y)) + (kpi (B x) ([y] C x y)))) + ([x] [d] [ex] [xt] + mtptranse/app + (DmtransN x d ex xt) + (DmtransM x d ex xt)) + ([x] Dlook x : lookup (G x) x A) +%% + ([x] [ex] [xt] + tptranse/app + (Dtpsub x) + (Dsub x) + (DtranseN x ex xt) + (DtranseM x ex xt)) + ([x] [ex] [xt] + mtptranse/app + (DmtranseN x ex xt) + (DmtranseM x ex xt)) +%% + <- cut-transe-m _ DtransN DmtransN Dlook + ([x] [ex] [xt] DtranseN x ex xt + : transe (G x) (EN ex) (N x) (B x)) + ([x] [ex] [xt] DmtranseN x ex xt) + <- cut-tptranse-m _ DtransM DmtransM Dlook + ([x] [ex] [xt] DtranseM x ex xt + : tptranse (G x) (EM ex) (alam [y] M x y) + (kpi (B x) [y] C x y)) + ([x] [ex] [xt] DmtranseM x ex xt). + +-pi : cut-tptranse-m _ + ([x] [d] [ex] [xt] + tptranse/pi + ([y] [ey] [yt] + DtransM x d ex xt y ey yt + : tptranse (cons (G x) y (A x)) + (EM ex ey) (M x y) ktype) + (DtransA x d ex xt + : tptranse (G x) (EA ex) (A x) ktype)) + ([x] [d] [ex] [xt] + mtptranse/pi + ([y] [ey] [yt] DmtransM x d ex xt y ey yt) + (DmtransA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + tptranse/pi + ([y] [ey] [yt] DtranseM' x ex xt y ey yt) + (DtranseA x ex xt)) + ([x] [ex] [xt] + mtptranse/pi + ([y] [ey] [yt] DmtranseM' x ex xt y ey yt) + (DmtranseA x ex xt)) +%% + <- ({y} {ey} {yt} + cut-tptranse-m _ + ([x] [d] [ex] [xt] DtransM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmtransM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DtranseM' x ex xt y ey yt + : tptranse (cons (G x) y (A x)) + (EM ex ey) (M x y) ktype) + ([x] [ex] [xt] DmtranseM' x ex xt y ey yt)) + <- cut-tptranse-m _ DtransA DmtransA Dlook + ([x] [ex] [xt] DtranseA x ex xt + : tptranse (G x) (EA ex) (A x) ktype) + ([x] [ex] [xt] DmtranseA x ex xt). + + +-lam : cut-tptranse-m _ + ([x] [d] [ex] [xt] + tptranse/lam + ([y] [ey] [yt] + DtransM x d ex xt y ey yt + : tptranse (cons (G x) y (A x)) + (EM ex ey) (M x y) (B x y)) + (DtransA x d ex xt + : tptranse (G x) (EA ex) (A x) ktype)) + ([x] [d] [ex] [xt] + mtptranse/lam + ([y] [ey] [yt] DmtransM x d ex xt y ey yt) + (DmtransA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + tptranse/lam + ([y] [ey] [yt] DtranseM' x ex xt y ey yt) + (DtranseA x ex xt)) + ([x] [ex] [xt] + mtptranse/lam + ([y] [ey] [yt] DmtranseM' x ex xt y ey yt) + (DmtranseA x ex xt)) +%% + <- ({y} {ey} {yt} + cut-tptranse-m _ + ([x] [d] [ex] [xt] DtransM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmtransM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DtranseM' x ex xt y ey yt + : tptranse (cons (G x) y (A x)) + (EM ex ey) (M x y) (B x y)) + ([x] [ex] [xt] DmtranseM' x ex xt y ey yt)) + <- cut-tptranse-m _ DtransA DmtransA Dlook + ([x] [ex] [xt] DtranseA x ex xt + : tptranse (G x) (EA ex) (A x) ktype) + ([x] [ex] [xt] DmtranseA x ex xt). + +%worlds (csig | asig | bind | tvar | tbind | tobind) + (cut-trans-m _ _ _ _ _ _) + (cut-tptrans-m _ _ _ _ _ _) + (cut-transe-m _ _ _ _ _ _) + (cut-tptranse-m _ _ _ _ _ _). +%total (M1 M2 M3 M4) + (cut-trans-m M1 _ _ _ _ _) + (cut-tptrans-m M2 _ _ _ _ _) + (cut-transe-m M3 _ _ _ _ _) + (cut-tptranse-m M4 _ _ _ _ _). + +cut-ktrans-m : {Km} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + ktrans (EK ex) (K x)} + ({x} {d} {ex} {xt} mktrans (D x d ex xt) Km) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + ktranse (G x) (EK ex) (K x)} + ({x} {ex} {xt} mktranse (D' x ex xt) Km) -> type. +%mode cut-ktrans-m +Mm +D +Dm +Dlook -D' -Dm'. + +cut-ktranse-m : {Km} + {D : {x} {d:vof x A} {ex} {xt:vtrans ex x} + ktranse (G x) (EK ex) (K x)} + ({x} {d} {ex} {xt} mktranse (D x d ex xt) Km) + -> ({x} lookup (G x) x A) +%% + -> {D' : {x} {ex} {xt:vtrans ex x} + ktranse (G x) (EK ex) (K x)} + ({x} {ex} {xt} mktranse (D' x ex xt) Km) -> type. +%mode cut-ktranse-m +Mm +D +Dm +Dlook -D' -Dm'. + +-type : cut-ktrans-m _ + ([x] [d] [ex] [xt] ktrans/type) + ([x] [d] [ex] [xt] mktrans/type) + _ + ([x] [ex] [xt] ktranse/type) + ([x] [ex] [xt] mktranse/type). + +-pi : cut-ktrans-m _ + ([x] [d] [ex] [xt] + ktrans/pi + ([y] [e] [ey] [yt] + DtransM x d ex xt y e ey yt + : ktrans (EM ex ey) (M x y)) + (DtransA x d ex xt + : tptrans (EA ex) (A x) ktype)) + ([x] [d] [ex] [xt] + mktrans/pi + ([y] [e] [ey] [yt] DmtransM x d ex xt y e ey yt) + (DmtransA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + ktranse/pi + ([y] [ey] [yt] DtranseM' x ex xt y ey yt) + (DtranseA x ex xt)) + ([x] [ex] [xt] + mktranse/pi + ([y] [ey] [yt] DmtranseM' x ex xt y ey yt) + (DmtranseA x ex xt)) +%% + <- ({x} {d} {ex} {xt} + cut-ktrans-m _ + ([y] [e] [ey] [yt] DtransM x d ex xt y e ey yt) + ([y] [e] [ey] [yt] DmtransM x d ex xt y e ey yt) + ([y] lookup/hit) + ([y] [ey] [yt] DtranseM x d ex xt y ey yt + : ktranse (cons (G x) y (A x)) (EM ex ey) (M x y)) + ([y] [ey] [yt] DmtranseM x d ex xt y ey yt)) + <- ({y} {ey} {yt} + cut-ktranse-m _ + ([x] [d] [ex] [xt] DtranseM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmtranseM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DtranseM' x ex xt y ey yt + : ktranse (cons (G x) y (A x)) (EM ex ey) (M x y)) + ([x] [ex] [xt] DmtranseM' x ex xt y ey yt)) + <- cut-tptrans-m _ DtransA DmtransA Dlook + ([x] [ex] [xt] DtranseA x ex xt + : tptranse (G x) (EA ex) (A x) ktype) + ([x] [ex] [xt] DmtranseA x ex xt). + +%% + +-type : cut-ktranse-m _ + ([x] [d] [ex] [xt] ktranse/type) + ([x] [d] [ex] [xt] mktranse/type) + _ + ([x] [ex] [xt] ktranse/type) + ([x] [ex] [xt] mktranse/type). + +-pi : cut-ktranse-m _ + ([x] [d] [ex] [xt] + ktranse/pi + ([y] [ey] [yt] + DtransM x d ex xt y ey yt + : ktranse (cons (G x) y (A x)) (EM ex ey) (M x y)) + (DtransA x d ex xt + : tptranse (G x) (EA ex) (A x) ktype)) + ([x] [d] [ex] [xt] + mktranse/pi + ([y] [ey] [yt] DmtransM x d ex xt y ey yt) + (DmtransA x d ex xt)) + ([x] Dlook x : lookup (G x) x C) +%% + ([x] [ex] [xt] + ktranse/pi + ([y] [ey] [yt] DtranseM' x ex xt y ey yt) + (DtranseA x ex xt)) + ([x] [ex] [xt] + mktranse/pi + ([y] [ey] [yt] DmtranseM' x ex xt y ey yt) + (DmtranseA x ex xt)) +%% + <- ({y} {ey} {yt} + cut-ktranse-m _ + ([x] [d] [ex] [xt] DtransM x d ex xt y ey yt) + ([x] [d] [ex] [xt] DmtransM x d ex xt y ey yt) + ([x] lookup/miss (Dlook x)) + ([x] [ex] [xt] DtranseM' x ex xt y ey yt + : ktranse (cons (G x) y (A x)) (EM ex ey) (M x y)) + ([x] [ex] [xt] DmtranseM' x ex xt y ey yt)) + <- cut-tptranse-m _ DtransA DmtransA Dlook + ([x] [ex] [xt] DtranseA x ex xt + : tptranse (G x) (EA ex) (A x) ktype) + ([x] [ex] [xt] DmtranseA x ex xt). + +%worlds (csig | asig | bind | tvar | tbind | tobind) + (cut-ktrans-m _ _ _ _ _ _) + (cut-ktranse-m _ _ _ _ _ _). +%total (M1 M2) + (cut-ktrans-m M1 _ _ _ _ _) + (cut-ktranse-m M2 _ _ _ _ _). + +%% + +cut-trans : ({x} vof x A -> {ex} vtrans ex x + -> trans (EM ex) (M x) (B x)) + -> ({x} lookup (G x) x A) +%% + -> ({x} {ex} vtrans ex x + -> transe (G x) (EM ex) (M x) (B x)) -> type. +%mode cut-trans +X1 +X2 -X3. + +- : cut-trans Dtrans Dlook Dtranse + <- ({x} {d} {ex} {xt} + can-mtrans (Dtrans x d ex xt) + (Dmtrans x d ex xt)) + <- cut-trans-m _ Dtrans Dmtrans Dlook Dtranse _. + +%worlds (csig | asig | bind | tbind | tobind) (cut-trans _ _ _). +%total {} (cut-trans _ _ _). + +cut-tptrans : ({x} vof x A -> {ex} vtrans ex x + -> tptrans (EM ex) (M x) (B x)) + -> ({x} lookup (G x) x A) +%% + -> ({x} {ex} vtrans ex x + -> tptranse (G x) (EM ex) (M x) (B x)) -> type. +%mode cut-tptrans +X1 +X2 -X3. + +- : cut-tptrans Dtrans Dlook Dtranse + <- ({x} {d} {ex} {xt} + can-mtptrans (Dtrans x d ex xt) + (Dmtrans x d ex xt)) + <- cut-tptrans-m _ Dtrans Dmtrans Dlook Dtranse _. + +%worlds (csig | asig | bind | tbind | tobind) (cut-tptrans _ _ _). +%total {} (cut-tptrans _ _ _). + +cut-ktrans : ({x} vof x A -> {ex} vtrans ex x + -> ktrans (EK ex) (K x)) + -> ({x} lookup (G x) x A) +%% + -> ({x} {ex} vtrans ex x + -> ktranse (G x) (EK ex) (K x)) -> type. +%mode cut-ktrans +X1 +X2 -X3. + +- : cut-ktrans Dtrans Dlook Dtranse + <- ({x} {d} {ex} {xt} + can-mktrans (Dtrans x d ex xt) + (Dmtrans x d ex xt)) + <- cut-ktrans-m _ Dtrans Dmtrans Dlook Dtranse _. + +%worlds (csig | asig | bind | tbind | tobind) (cut-ktrans _ _ _). +%total {} (cut-ktrans _ _ _). + +%%%% + +trans1-to-transe : ({x} vof x A -> {ex} vtrans ex x + -> trans (EM ex) (M x) (B x)) + -> ({x} {ex} vtrans ex x + -> transe (cons nil x A) (EM ex) (M x) (B x)) -> type. +%mode trans1-to-transe +X1 -X2. + +- : trans1-to-transe + ([x] [d:vof x A] [ex] [xt:vtrans ex x] + Dtrans x d ex xt : trans (EM ex) (M x) (B x)) + ([x] [ex] [xt] Dtranse x ex xt) + <- cut-trans Dtrans ([_] lookup/hit) Dtranse. + +%worlds (csig | asig | bind | tbind | tobind) (trans1-to-transe _ _). +%total {} (trans1-to-transe _ _). + + +tptrans1-to-tptranse : ({x} vof x A -> {ex} vtrans ex x + -> tptrans (EM ex) (M x) (B x)) + -> ({x} {ex} vtrans ex x + -> tptranse + (cons nil x A) (EM ex) (M x) (B x)) -> type. +%mode tptrans1-to-tptranse +X1 -X2. + +- : tptrans1-to-tptranse + ([x] [d:vof x A] [ex] [xt:vtrans ex x] + Dtrans x d ex xt : tptrans (EM ex) (M x) (B x)) + ([x] [ex] [xt] Dtranse x ex xt) + <- cut-tptrans Dtrans ([_] lookup/hit) Dtranse. + +%worlds (csig | asig | bind | tbind | tobind) (tptrans1-to-tptranse _ _). +%total {} (tptrans1-to-tptranse _ _). + + +ktrans1-to-ktranse : ({x} vof x A -> {ex} vtrans ex x + -> ktrans (EM ex) (M x)) + -> ({x} {ex} vtrans ex x + -> ktranse + (cons nil x A) (EM ex) (M x)) -> type. +%mode ktrans1-to-ktranse +X1 -X2. + +- : ktrans1-to-ktranse + ([x] [d:vof x A] [ex] [xt:vtrans ex x] + Dtrans x d ex xt : ktrans (EM ex) (M x)) + ([x] [ex] [xt] Dtranse x ex xt) + <- cut-ktrans Dtrans ([_] lookup/hit) Dtranse. + +%worlds (csig | asig | bind | tbind | tobind) (ktrans1-to-ktranse _ _). +%total {} (ktrans1-to-ktranse _ _). + + +trans-to-transe-nil : trans EM M A -> transe nil EM M A -> type. +%mode trans-to-transe-nil +X1 -X2. + +tptrans-to-tptranse-nil : tptrans EM M A -> tptranse nil EM M A -> type. +%mode tptrans-to-tptranse-nil +X1 -X2. + +-const : trans-to-transe-nil + (trans/const + (Dexpand : expand (const C) T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (Dcof : cof C A)) + (transe/const Dexpand Dsimp Dkof Dcof). + +-var : trans-to-transe-nil + (trans/var + (Dexpand : expand X T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (Dvof : vof X A) + (Dvtrans : vtrans EX X)) + (transe/vari Dexpand Dsimp Dkof Dvof Dvtrans). + +-app : trans-to-transe-nil + (trans/app + (Dtpsub : tpsub ([x] A x) N Ax) + (Dsub : sub ([x] M x) N Mx) + (DtransN : trans EN N B) + (DtransM : trans EM (lam [x] M x) (pi B [x] A x))) + (transe/app Dtpsub Dsub DtranseN DtranseM) + <- trans-to-transe-nil DtransN DtranseN + <- trans-to-transe-nil DtransM DtranseM. + +-lam : trans-to-transe-nil + (trans/lam + ([x] [d:vof x A] + [ex] [xt:vtrans ex x] + DtransM x d ex xt : trans (EM ex) (M x) (B x)) + (DtransA : tptrans EA A ktype)) + (transe/lam DtranseM DtranseA) + <- trans1-to-transe DtransM + ([x] [ex] [xt] DtranseM x ex xt + : transe (cons nil x A) (EM ex) (M x) (B x)) + <- tptrans-to-tptranse-nil DtransA DtranseA. + +%% + + +-const : tptrans-to-tptranse-nil + (tptrans/const Dexpand Dsimp Dkof Dcof) + (tptranse/const Dexpand Dsimp Dkof Dcof). + +-app : tptrans-to-tptranse-nil + (tptrans/app Dtpsub Dsub DtransN DtransM) + (tptranse/app Dtpsub Dsub DtranseN DtranseM) + <- trans-to-transe-nil DtransN DtranseN + <- tptrans-to-tptranse-nil DtransM DtranseM. + +-lam : tptrans-to-tptranse-nil + (tptrans/lam + ([x] [d:vof x A] + [ex] [xt:vtrans ex x] + DtransM x d ex xt : tptrans (EM ex) (M x) (B x)) + (DtransA : tptrans EA A ktype)) + (tptranse/lam DtranseM DtranseA) + <- tptrans1-to-tptranse DtransM + ([x] [ex] [xt] DtranseM x ex xt + : tptranse (cons nil x A) (EM ex) (M x) (B x)) + <- tptrans-to-tptranse-nil DtransA DtranseA. + +-pi : tptrans-to-tptranse-nil + (tptrans/pi + ([x] [d:vof x A] + [ex] [xt:vtrans ex x] + DtransM x d ex xt : tptrans (EM ex) (M x) ktype) + (DtransA : tptrans EA A ktype)) + (tptranse/pi DtranseM DtranseA) + <- tptrans1-to-tptranse DtransM + ([x] [ex] [xt] DtranseM x ex xt + : tptranse (cons nil x A) (EM ex) (M x) ktype) + <- tptrans-to-tptranse-nil DtransA DtranseA. + +%worlds (csig | asig | bind | tbind | tobind) + (trans-to-transe-nil _ _) + (tptrans-to-tptranse-nil _ _). +%total (D1 D2) + (trans-to-transe-nil D1 _) + (tptrans-to-tptranse-nil D2 _). + +ktrans-to-ktranse-nil : ktrans EK K -> ktranse nil EK K -> type. +%mode ktrans-to-ktranse-nil +X1 -X2. + +-type : ktrans-to-ktranse-nil ktrans/type ktranse/type. + +-pi : ktrans-to-ktranse-nil + (ktrans/pi + ([x] [d:vof x A] + [ex] [xt:vtrans ex x] + DtransK x d ex xt : ktrans (EK ex) (K x)) + (DtransA : tptrans EA A ktype)) + (ktranse/pi DtranseK DtranseA) + <- ktrans1-to-ktranse DtransK + ([x] [ex] [xt] DtranseK x ex xt + : ktranse (cons nil x A) (EK ex) (K x)) + <- tptrans-to-tptranse-nil DtransA DtranseA. + +%worlds (csig | asig | bind | tbind | tobind) (ktrans-to-ktranse-nil _ _). +%total D (ktrans-to-ktranse-nil D _). + + +trans-to-transe : {G} trans EM M A -> transe G EM M A -> type. +%mode trans-to-transe +G +X1 -X2. + +- : trans-to-transe G (Dtrans : trans EM M A) + Dtranse + <- trans-to-transe-nil Dtrans (Dtransenil : transe nil EM M A) + <- append-nil _ (Dappend : append nil G G) + <- weaken-transe' Dappend Dtransenil + (Dtranse : transe G EM M A). + +%worlds (csig | asig | bind | tbind | tobind) (trans-to-transe _ _ _). +%total {} (trans-to-transe _ _ _). + + +%% other direction (transe to trans) %% + +kof-to-kofi : {G} kof A K -> kofi G A K -> type. +%mode kof-to-kofi +G +X1 -X2. + +- : kof-to-kofi nil Dkof (kofi/nil Dkof). + +- : kof-to-kofi (cons G X A) Dkof (kofi/cons ([_] Dkof')) + <- kof-to-kofi G Dkof Dkof'. + +%worlds (csig | asig | bind | var | ofblock) (kof-to-kofi _ _ _). +%total G (kof-to-kofi G _ _). + +transi : ctx -> etm -> tm -> tp -> type. +tptransi : ctx -> etp -> tp -> kind -> type. +ktransi : ctx -> ekind -> kind -> type. + +transi/nil : transi nil EM M A + <- trans EM M A. +transi/cons : transi (cons G X B) EM M A + <- (vof X B -> transi G EM M A). + +tptransi/nil : tptransi nil EM M A + <- tptrans EM M A. +tptransi/cons : tptransi (cons G X B) EM M A + <- (vof X B -> tptransi G EM M A). + +ktransi/nil : ktransi nil EK K + <- ktrans EK K. +ktransi/cons : ktransi (cons G X A) EK K + <- (vof X A -> ktransi G EK K). + + +transi-const : {G} expand (const C) T M + -> simp A T + -> kof A ktype + -> cof C A +%% + -> transi G (econst C) M A -> type. +%mode transi-const +G +X1 +X2 +X3 +X4 -X5. + +-nil : transi-const nil + Dexpand Dsimp Dkof Dcof + (transi/nil (trans/const Dexpand Dsimp Dkof Dcof)). + +-cons : transi-const (cons G X B) + Dexpand Dsimp Dkof Dcof + (transi/cons ([d] Dtransi)) + <- transi-const G Dexpand Dsimp Dkof Dcof Dtransi. + +%worlds (csig | asig | bind | tvar | tbind | tobind) (transi-const _ _ _ _ _ _). +%total G (transi-const G _ _ _ _ _). + +transi-vari : {G} expand X T M + -> simp A T + -> kofi G A ktype + -> vof X A + -> vtrans EX X +%% + -> transi G EX M A -> type. +%mode transi-vari +G +X1 +X2 +X3 +X4 +X5 -X6. + +-nil : transi-vari nil Dexpand Dsimp (kofi/nil Dkof) Dvof Dvtrans + (transi/nil (trans/var Dexpand Dsimp Dkof Dvof Dvtrans)). + +-cons : transi-vari (cons G X B) + Dexpand Dsimp + (kofi/cons ([d:vof X B] Dkofi d : kofi G A ktype)) + Dvof Dvtrans + (transi/cons ([d] Dtransi d)) + <- ({d} + transi-vari G Dexpand Dsimp (Dkofi d) Dvof Dvtrans + (Dtransi d)). + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (transi-vari _ _ _ _ _ _ _). +%total G (transi-vari G _ _ _ _ _ _). + + +transi-var : expand X T M + -> simp A T + -> kofi G A ktype + -> lookup G X A + -> vtrans EX X +%% + -> transi G EX M A -> type. +%mode transi-var +X1 +X2 +X3 +X4 +X5 -X6. + +-hit : transi-var Dexpand Dsimp + (kofi/cons + (Dkofi : vof X A -> kofi G A ktype) + : kofi (cons G X A) A ktype) + (lookup/hit : lookup (cons G X A) X A) + Dvtrans + (transi/cons Dtransi) + <- ({d:vof X A} + transi-vari _ Dexpand Dsimp (Dkofi d) d Dvtrans + (Dtransi d)). + +-miss : transi-var Dexpand Dsimp + (kofi/cons + ([d:vof Y B] Dkofi d : kofi G A ktype) + : kofi (cons G Y B) A ktype) + (lookup/miss + (Dlook : lookup G X A) + : lookup (cons G Y B) X A) + Dvtrans + (transi/cons Dtransi) + <- ({d:vof Y B} + transi-var Dexpand Dsimp (Dkofi d) Dlook Dvtrans + (Dtransi d : transi G EX M A)). + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (transi-var _ _ _ _ _ _). +%total D (transi-var _ _ _ D _ _). + +transi-app : tpsub ([x] B x) N Bx + -> sub ([x] M x) N Mx + -> transi G EN N A + -> transi G EM (lam [x] M x) (pi A [x] B x) +%% + -> transi G (eapp EM EN) Mx Bx -> type. +%mode transi-app +X1 +X2 +X3 +X4 -X5. + +-nil : transi-app + Dtpsub Dsub (transi/nil DtransN) (transi/nil DtransM) + (transi/nil (trans/app Dtpsub Dsub DtransN DtransM)). + +-cons : transi-app Dtpsub Dsub + (transi/cons + ([d:vof X B] DtransiN d : transi G EN N A)) + (transi/cons + ([d:vof X B] DtransiM d + : transi G EM (lam [x] M x) (pi A ([x] C x)))) + (transi/cons D) + <- ({d} transi-app Dtpsub Dsub (DtransiN d) (DtransiM d) (D d)). + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (transi-app _ _ _ _ _). +%total D (transi-app _ _ D _ _). + +transi-lam : ({x} {ex} vtrans ex x -> transi (cons G x A) (EM ex) (M x) (B x)) + -> tptransi G EA A ktype +%% + -> transi G (elam EA [ex] EM ex) (lam [x] M x) (pi A [x] B x) + -> type. +%mode transi-lam +X1 +X2 -X3. + +-nil : transi-lam + ([x] [ex] [xt] transi/cons ([d] transi/nil (DtransM x d ex xt))) + (tptransi/nil DtransA) + (transi/nil (trans/lam DtransM DtransA)). + +-cons : transi-lam + ([x] [ex] [xt] + transi/cons ([d] transi/cons ([e] DtransM x d ex xt e))) + (tptransi/cons DtransA) + (transi/cons Dtransi) + <- ({e} + transi-lam + ([x] [ex] [xt] transi/cons ([d] DtransM x d ex xt e)) + (DtransA e) + (Dtransi e)). + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (transi-lam _ _ _). +%total D (transi-lam _ D _). + +%% + + +tptransi-const : {G} tpexpand (aconst C) T M + -> ksimp A T + -> wfkind A + -> ckof C A +%% + -> tptransi G (eaconst C) M A -> type. +%mode tptransi-const +G +X1 +X2 +X3 +X4 -X5. + +-nil : tptransi-const nil + Dexpand Dsimp Dkof Dcof + (tptransi/nil (tptrans/const Dexpand Dsimp Dkof Dcof)). + +-cons : tptransi-const (cons G X B) + Dexpand Dsimp Dkof Dcof + (tptransi/cons ([d] Dtransi)) + <- tptransi-const G Dexpand Dsimp Dkof Dcof Dtransi. + +%worlds (csig | asig | bind | tvar | tbind | tobind) (tptransi-const _ _ _ _ _ _). +%total G (tptransi-const G _ _ _ _ _). + +tptransi-app : ksub ([x] B x) N Bx + -> tpsub ([x] M x) N Mx + -> transi G EN N A + -> tptransi G EM (alam [x] M x) (kpi A [x] B x) +%% + -> tptransi G (eaapp EM EN) Mx Bx -> type. +%mode tptransi-app +X1 +X2 +X3 +X4 -X5. + +-nil : tptransi-app + Dtpsub Dsub (transi/nil DtransN) (tptransi/nil DtransM) + (tptransi/nil (tptrans/app Dtpsub Dsub DtransN DtransM)). + +-cons : tptransi-app Dtpsub Dsub + (transi/cons + ([d:vof X B] DtransiN d : transi G EN N A)) + (tptransi/cons + ([d:vof X B] DtransiM d + : tptransi G EM (alam [x] M x) (kpi A ([x] C x)))) + (tptransi/cons D) + <- ({d} tptransi-app Dtpsub Dsub (DtransiN d) (DtransiM d) (D d)). + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (tptransi-app _ _ _ _ _). +%total D (tptransi-app _ _ D _ _). + +tptransi-lam : ({x} {ex} vtrans ex x -> tptransi (cons G x A) (EM ex) (M x) (B x)) + -> tptransi G EA A ktype +%% + -> tptransi G (ealam EA [ex] EM ex) (alam [x] M x) (kpi A [x] B x) + -> type. +%mode tptransi-lam +X1 +X2 -X3. + +-nil : tptransi-lam + ([x] [ex] [xt] tptransi/cons ([d] tptransi/nil (DtransM x d ex xt))) + (tptransi/nil DtransA) + (tptransi/nil (tptrans/lam DtransM DtransA)). + +-cons : tptransi-lam + ([x] [ex] [xt] + tptransi/cons ([d] tptransi/cons ([e] DtransM x d ex xt e))) + (tptransi/cons DtransA) + (tptransi/cons Dtransi) + <- ({e} + tptransi-lam + ([x] [ex] [xt] tptransi/cons ([d] DtransM x d ex xt e)) + (DtransA e) + (Dtransi e)). + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (tptransi-lam _ _ _). +%total D (tptransi-lam _ D _). + +tptransi-pi : ({x} {ex} vtrans ex x -> tptransi (cons G x A) (EM ex) (M x) ktype) + -> tptransi G EA A ktype +%% + -> tptransi G (epi EA [ex] EM ex) (pi A [x] M x) ktype + -> type. +%mode tptransi-pi +X1 +X2 -X3. + +-nil : tptransi-pi + ([x] [ex] [xt] tptransi/cons ([d] tptransi/nil (DtransM x d ex xt))) + (tptransi/nil DtransA) + (tptransi/nil (tptrans/pi DtransM DtransA)). + +-cons : tptransi-pi + ([x] [ex] [xt] + tptransi/cons ([d] tptransi/cons ([e] DtransM x d ex xt e))) + (tptransi/cons DtransA) + (tptransi/cons Dtransi) + <- ({e} + tptransi-pi + ([x] [ex] [xt] tptransi/cons ([d] DtransM x d ex xt e)) + (DtransA e) + (Dtransi e)). + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (tptransi-pi _ _ _). +%total D (tptransi-pi _ D _). + +ktransi-pi : ({x} {ex} vtrans ex x -> ktransi (cons G x A) (EK ex) (K x)) + -> tptransi G EA A ktype +%% + -> ktransi G (ekpi EA ([ex] EK ex)) (kpi A ([x] K x)) -> type. +%mode ktransi-pi +X1 +X2 -X3. + +-nil : ktransi-pi + ([x] [ex] [xt] ktransi/cons ([d] ktransi/nil (DtransM x d ex xt))) + (tptransi/nil DtransA) + (ktransi/nil (ktrans/pi DtransM DtransA)). + +-cons : ktransi-pi + ([x] [ex] [xt] + ktransi/cons ([d] ktransi/cons ([e] DtransM x d ex xt e))) + (tptransi/cons DtransA) + (ktransi/cons Dtransi) + <- ({e} + ktransi-pi + ([x] [ex] [xt] ktransi/cons ([d] DtransM x d ex xt e)) + (DtransA e) + (Dtransi e)). + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (ktransi-pi _ _ _). +%total D (ktransi-pi _ D _). + +ktransi-type : {G} ktransi G ektype ktype -> type. +%mode ktransi-type +G -D. + +-nil : ktransi-type nil (ktransi/nil ktrans/type). + +-cons : ktransi-type (cons G X A) (ktransi/cons ([_] D)) + <- ktransi-type G D. + +%worlds (csig | asig | bind | ofblock | tvar | tbind | tobind) (ktransi-type _ _). +%total G (ktransi-type G _). + + +%% + +transe-to-transi : transe G EM M A -> transi G EM M A -> type. +%mode transe-to-transi +X1 -X2. + +tptranse-to-tptransi : tptranse G EM M A -> tptransi G EM M A -> type. +%mode tptranse-to-tptransi +X1 -X2. + +-const : transe-to-transi + (transe/const + (Dexpand : expand (const C) T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (Dcof : cof C A)) + Dtransi + <- transi-const G Dexpand Dsimp Dkof Dcof Dtransi. + +-vari : transe-to-transi + (transe/vari Dexpand Dsimp Dkof Dvof Dvtrans) + Dtransi + <- kof-to-kofi G Dkof Dkofi + <- transi-vari G Dexpand Dsimp Dkofi Dvof Dvtrans Dtransi. + +-var : transe-to-transi + (transe/var Dexpand Dsimp Dkofe Dlook Dvtrans) + Dtransi + <- kofe-to-kofi Dkofe Dkofi + <- transi-var Dexpand Dsimp Dkofi Dlook Dvtrans + Dtransi. + +-app : transe-to-transi + (transe/app Dtpsub Dsub DtranseN DtranseM) + Dtransi + <- transe-to-transi DtranseN DtransiN + <- transe-to-transi DtranseM DtransiM + <- transi-app Dtpsub Dsub DtransiN DtransiM Dtransi. + +-lam : transe-to-transi + (transe/lam ([x] [ex] [xt] DtransM x ex xt) DtransA) + Dtransi + <- tptranse-to-tptransi DtransA DtransiA + <- ({x} {ex} {xt} + transe-to-transi (DtransM x ex xt) + (DtransiM x ex xt)) + <- transi-lam DtransiM DtransiA + Dtransi. + +%% + +-const : tptranse-to-tptransi + (tptranse/const Dexpand Dsimp Dwf Dcof) + Dtransi + <- tptransi-const _ Dexpand Dsimp Dwf Dcof Dtransi. + +-app : tptranse-to-tptransi + (tptranse/app Dtpsub Dsub DtranseN DtranseM) + Dtransi + <- transe-to-transi DtranseN DtransiN + <- tptranse-to-tptransi DtranseM DtransiM + <- tptransi-app Dtpsub Dsub DtransiN DtransiM Dtransi. + +-pi : tptranse-to-tptransi + (tptranse/pi ([x] [ex] [xt] DtransM x ex xt) DtransA) + Dtransi + <- tptranse-to-tptransi DtransA DtransiA + <- ({x} {ex} {xt} + tptranse-to-tptransi (DtransM x ex xt) + (DtransiM x ex xt)) + <- tptransi-pi DtransiM DtransiA + Dtransi. + +-lam : tptranse-to-tptransi + (tptranse/lam ([x] [ex] [xt] DtransM x ex xt) DtransA) + Dtransi + <- tptranse-to-tptransi DtransA DtransiA + <- ({x} {ex} {xt} + tptranse-to-tptransi (DtransM x ex xt) + (DtransiM x ex xt)) + <- tptransi-lam DtransiM DtransiA + Dtransi. + +%worlds (csig | asig | bind | tvar | tbind | tobind) + (transe-to-transi _ _) + (tptranse-to-tptransi _ _). +%total (D1 D2) + (transe-to-transi D1 _) + (tptranse-to-tptransi D2 _). + +ktranse-to-ktransi : ktranse G EK K -> ktransi G EK K -> type. +%mode ktranse-to-ktransi +X1 -X2. + +-type : ktranse-to-ktransi ktranse/type D + <- ktransi-type _ D. + +-pi : ktranse-to-ktransi + (ktranse/pi ([x] [ex] [xt] DtransM x ex xt) DtransA) + Dtransi + <- tptranse-to-tptransi DtransA DtransiA + <- ({x} {ex} {xt} + ktranse-to-ktransi (DtransM x ex xt) + (DtransiM x ex xt)) + <- ktransi-pi DtransiM DtransiA + Dtransi. + +%worlds (csig | asig | bind | tvar | tbind | tobind) (ktranse-to-ktransi _ _). +%total D (ktranse-to-ktransi D _). + + +transe-to-trans : transe nil EM M A -> trans EM M A -> type. +%mode transe-to-trans +X1 -X2. + +- : transe-to-trans Dtranse Dtrans + <- transe-to-transi Dtranse (transi/nil Dtrans). + +%worlds (csig | asig | bind | tbind | tobind) (transe-to-trans _ _). +%total {} (transe-to-trans _ _). + +tptranse-to-tptrans : tptranse nil EM M A -> tptrans EM M A -> type. +%mode tptranse-to-tptrans +X1 -X2. + +- : tptranse-to-tptrans Dtranse Dtrans + <- tptranse-to-tptransi Dtranse (tptransi/nil Dtrans). + +%worlds (csig | asig | bind | tbind | tobind) (tptranse-to-tptrans _ _). +%total {} (tptranse-to-tptrans _ _). + +ktranse-to-ktrans : ktranse nil EM M -> ktrans EM M -> type. +%mode ktranse-to-ktrans +X1 -X2. + +- : ktranse-to-ktrans Dtranse Dtrans + <- ktranse-to-ktransi Dtranse (ktransi/nil Dtrans). + +%worlds (csig | asig | bind | tbind | tobind) (ktranse-to-ktrans _ _). +%total {} (ktranse-to-ktrans _ _). + diff --git a/src/trans-fun.thm b/src/trans-fun.thm new file mode 100644 index 0000000..f7b6da8 --- /dev/null +++ b/src/trans-fun.thm @@ -0,0 +1,312 @@ + +cof-fun : cof C A -> cof C A' -> tp-eq A A' -> type. +%mode cof-fun +X1 +X2 -X3. + +- : cof-fun D D' tp-eq/i. + +%worlds (csig | asig | var) (cof-fun _ _ _). +%total {} (cof-fun _ _ _). + +ckof-fun : ckof C K -> ckof C K' -> kind-eq K K' -> type. +%mode ckof-fun +X1 +X2 -X3. + +- : ckof-fun D D' kind-eq/i. + +%worlds (csig | asig | var) (ckof-fun _ _ _). +%total {} (ckof-fun _ _ _). + + +vtrans-fun : vtrans EX X -> vtrans EX X' -> atm-eq X X' -> type. +%mode vtrans-fun +X1 +X2 -X3. + +- : vtrans-fun _ _ atm-eq/i. + +%worlds (var | tobind) (vtrans-fun _ _ _). +%total {} (vtrans-fun _ _ _). + + +trans-fun : trans EM M A -> trans EM M' A' + -> tm-eq M M' + -> tp-eq A A' -> type. +%mode trans-fun +X1 +X2 -X3 -X4. + +tptrans-fun : tptrans EA A K -> tptrans EA A' K' + -> tp-eq A A' + -> kind-eq K K' -> type. +%mode tptrans-fun +X1 +X2 -X3 -X4. + +-const : trans-fun + (trans/const + (Dexpand : expand (const C) T M) + (Dsimp : simp A T) + _ + (DofC : cof C A)) + (trans/const + (Dexpand' : expand (const C) T' M') + (Dsimp' : simp A' T') + _ + (DofC' : cof C A')) +%% + DeqMM' + DeqAA' +%% + <- cof-fun DofC DofC' + (DeqAA' : tp-eq A A') + <- simp-compat DeqAA' stp-eq/i Dsimp + (DsimpA'T : simp A' T) + <- simp-fun Dsimp' DsimpA'T + (DeqT'T : stp-eq T' T) + <- expand-resp atm-eq/i DeqT'T tm-eq/i Dexpand' + (DexpandTM' : expand (const C) T M') + <- expand-fun Dexpand DexpandTM' + (DeqMM' : tm-eq M M'). + +-var : trans-fun + (trans/var + (Dexp : expand X T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (DofX : vof X A) + (Dvtrans : vtrans EM X)) + (trans/var + (Dexp' : expand X T' M') + (Dsimp' : simp A T') + (Dkof' : kof A ktype) + (DofX : vof X A) + (Dvtrans : vtrans EM X)) +%% + DeqMM' + tp-eq/i +%% + <- simp-fun Dsimp Dsimp' + (DeqTT' : stp-eq T T') + <- expand-resp atm-eq/i DeqTT' tm-eq/i Dexp + (Dexp'' : expand X T' M) + <- expand-fun Dexp' Dexp'' + (DeqM'M : tm-eq M' M) + <- tm-eq-sym DeqM'M + (DeqMM' : tm-eq M M'). + +-app : trans-fun + (trans/app + (DsubA : tpsub ([x] A x) N Ax) + (DsubM : sub ([x] M x) N Mx) + (DtransN : trans EN N B) + (DtransM : trans EM (lam ([x] M x)) (pi B ([x] A x))) + : trans (eapp EM EN) Mx Ax) + (trans/app + (DsubA' : tpsub ([x] A' x) N' Ax') + (DsubM' : sub ([x] M' x) N' Mx') + (DtransN' : trans EN N' B') + (DtransM' : trans EM (lam ([x] M' x)) (pi B' ([x] A' x))) + : trans (eapp EM EN) Mx' Ax') +%% + DeqMx + DeqAx +%% + <- trans-fun DtransN DtransN' + (DeqNN' : tm-eq N N') + (DeqB : tp-eq B B') + <- trans-fun DtransM DtransM' + (DeqLam : tm-eq (lam ([x] M x)) (lam ([x] M' x))) + (DeqPi : tp-eq (pi B ([x] A x)) (pi B' ([x] A' x))) + <- lam-inj DeqLam + ([x] DeqMM' x : tm-eq (M x) (M' x)) + <- sub-compat ([x] DeqMM' x) DeqNN' tm-eq/i DsubM + (DsubM'' : sub ([x] M' x) N' Mx) + <- sub-fun DsubM'' DsubM' + (DeqMx : tm-eq Mx Mx') + %% + <- pi-inj DeqPi + _ + ([x] DeqAA' x : tp-eq (A x) (A' x)) + <- tpsub-compat ([x] DeqAA' x) DeqNN' tp-eq/i DsubA + (DsubA'' : tpsub ([x] A' x) N' Ax) + <- tpsub-fun DsubA'' DsubA' + (DeqAx : tp-eq Ax Ax'). + +-lam : trans-fun + (trans/lam + ([x] [d:vof x A] [ex] [tr:vtrans ex x] + DtransM x d ex tr : trans (EM ex) (M x) (B x)) + (DtransA : tptrans EA A ktype)) + (trans/lam + ([x] [d:vof x A'] [ex] [tr:vtrans ex x] + DtransM' x d ex tr : trans (EM ex) (M' x) (B' x)) + (DtransA' : tptrans EA A' ktype)) +%% + DeqLam + DeqPi +%% + <- tptrans-fun DtransA DtransA' + (DeqAA' : tp-eq A A') + _ + <- trans-resp-underbind DeqAA' DtransM + ([x] [d] [ex] [tr] + DtransM'' x d ex tr : trans (EM ex) (M x) (B x)) + <- ({x} {d} {ex} {tr} + trans-fun (DtransM'' x d ex tr) (DtransM' x d ex tr) + (DeqM x : tm-eq (M x) (M' x)) + (DeqBB' x : tp-eq (B x) (B' x))) + <- lam-compat ([x] DeqM x) + (DeqLam : tm-eq (lam ([x] M x)) (lam ([x] M' x))) + <- pi-compat DeqAA' DeqBB' + (DeqPi : tp-eq (pi A ([x] B x)) (pi A' ([x] B' x))). + +%%%% + +-const : tptrans-fun + (tptrans/const + (Dexpand : tpexpand (aconst C) H A) + (Dsimp : ksimp K H) + (DofK : wfkind K) + (DofC : ckof C K)) + (tptrans/const + (Dexpand' : tpexpand (aconst C) H' A') + (Dsimp' : ksimp K' H') + (DofK' : wfkind K') + (DofC' : ckof C K')) +%% + DeqAA' + DeqKK' +%% + <- ckof-fun DofC DofC' + (DeqKK' : kind-eq K K') + <- ksimp-compat DeqKK' skind-eq/i Dsimp + (DsimpK'H : ksimp K' H) + <- ksimp-fun Dsimp' DsimpK'H + (DeqH'H : skind-eq H' H) + <- tpexpand-resp atp-eq/i DeqH'H tp-eq/i Dexpand' + (DexpandHA' : tpexpand (aconst C) H A') + <- tpexpand-fun Dexpand DexpandHA' + (DeqAA' : tp-eq A A'). + +-app : tptrans-fun + (tptrans/app + (Dksub : ksub ([x] K x) N Kx) + (Dsub : tpsub ([x] A x) N Ax) + (DtransN : trans EN N B) + (DtransA : tptrans EA (alam ([x] A x)) (kpi B ([x] K x)))) + (tptrans/app + (Dksub' : ksub ([x] K' x) N' Kx') + (Dsub' : tpsub ([x] A' x) N' Ax') + (DtransN' : trans EN N' B') + (DtransA' : tptrans EA (alam ([x] A' x)) (kpi B' ([x] K' x)))) +%% + DeqAx + DeqKx +%% + <- trans-fun DtransN DtransN' + (DeqNN' : tm-eq N N') + (DeqB : tp-eq B B') + <- tptrans-fun DtransA DtransA' + (DeqLam : tp-eq (alam ([x] A x)) (alam ([x] A' x))) + (DeqPi : kind-eq (kpi B [x] K x) (kpi B' [x] K' x)) + <- alam-inj DeqLam + ([x] DeqAA' x : tp-eq (A x) (A' x)) + <- tpsub-compat ([x] DeqAA' x) DeqNN' tp-eq/i Dsub + (Dsub'' : tpsub ([x] A' x) N' Ax) + <- tpsub-fun Dsub'' Dsub' + (DeqAx : tp-eq Ax Ax') + %% + <- kpi-inj DeqPi + _ + ([x] DeqK x : kind-eq (K x) (K' x)) + <- ksub-compat DeqK DeqNN' kind-eq/i Dksub + (Dksub'' : ksub ([x] K' x) N' Kx) + <- ksub-fun Dksub'' Dksub' + (DeqKx : kind-eq Kx Kx'). + +-lam : tptrans-fun + (tptrans/lam + ([x] [d:vof x A] [ex] [tr:vtrans ex x] + DtransB x d ex tr : tptrans (EB ex) (B x) (K x)) + (DtransA : tptrans EA A ktype)) + (tptrans/lam + ([x] [d:vof x A'] [ex] [tr:vtrans ex x] + DtransB' x d ex tr : tptrans (EB ex) (B' x) (K' x)) + (DtransA' : tptrans EA A' ktype)) +%% + DeqLam + DeqPi +%% + <- tptrans-fun DtransA DtransA' + (DeqAA' : tp-eq A A') + _ + <- tptrans-resp-underbind DeqAA' DtransB + ([x] [d] [ex] [tr] + DtransB'' x d ex tr : tptrans (EB ex) (B x) (K x)) + <- ({x} {d} {ex} {tr} + tptrans-fun (DtransB'' x d ex tr) (DtransB' x d ex tr) + (DeqB x : tp-eq (B x) (B' x)) + (DeqK x : kind-eq (K x) (K' x))) + <- alam-compat ([x] DeqB x) + (DeqLam : tp-eq (alam ([x] B x)) (alam ([x] B' x))) + %% + <- kpi-compat DeqAA' DeqK + (DeqPi : kind-eq (kpi A [x] K x) (kpi A' [x] K' x)). + +-pi : tptrans-fun + (tptrans/pi + ([x] [dx] [ex] [tr] DtransB x dx ex tr + : tptrans (EB ex) (B x) ktype) + (DtransA : tptrans EA A ktype)) + (tptrans/pi + ([x] [dx] [ex] [tr] DtransB' x dx ex tr + : tptrans (EB ex) (B' x) ktype) + (DtransA' : tptrans EA A' ktype)) +%% + DeqPi + kind-eq/i +%% + <- tptrans-fun DtransA DtransA' + (DeqAA' : tp-eq A A') + _ + <- tptrans-resp-underbind DeqAA' DtransB + ([x] [dx] [ex] [tr] DtransB'' x dx ex tr + : tptrans (EB ex) (B x) ktype) + <- ({x} {d} {ex} {tr} + tptrans-fun (DtransB'' x d ex tr) (DtransB' x d ex tr) + (DeqBB' x : tp-eq (B x) (B' x)) + kind-eq/i) + <- pi-compat DeqAA' ([x] DeqBB' x) + (DeqPi : tp-eq (pi A ([x] B x)) (pi A' ([x] B' x))). + + +%worlds (csig | asig | var | bind | ovar | tbind) + (tptrans-fun _ _ _ _) (trans-fun _ _ _ _). +%total (D1 D2) + (tptrans-fun _ D1 _ _) (trans-fun _ D2 _ _). + + +ktrans-fun : ktrans EK K -> ktrans EK K' -> kind-eq K K' -> type. +%mode ktrans-fun +X1 +X2 -X3. + +-type : ktrans-fun ktrans/type ktrans/type kind-eq/i. + +-pi : ktrans-fun + (ktrans/pi + ([x] [d:vof x A] [ex] [tr] + DtransK x d ex tr : ktrans (EK ex) (K x)) + (DtransA : tptrans EA A ktype)) + (ktrans/pi + ([x] [d':vof x A'] [ex] [tr] + DtransK' x d' ex tr : ktrans (EK ex) (K' x)) + (DtransA' : tptrans EA A' ktype)) +%% + DeqPi +%% + <- tptrans-fun DtransA DtransA' + (DeqAA' : tp-eq A A') + _ + <- ktrans-resp-underbind DeqAA' DtransK + ([x] [d] [ex] [tr] DtransK'' x d ex tr + : ktrans (EK ex) (K x)) + <- ({x} {d} {ex} {tr} + ktrans-fun (DtransK'' x d ex tr) (DtransK' x d ex tr) + (DeqKK' x : kind-eq (K x) (K' x))) + <- kpi-compat DeqAA' ([x] DeqKK' x) + (DeqPi : kind-eq (kpi A ([x] K x)) (kpi A' ([x] K' x))). + +%worlds (csig | asig | bind | tbind) (ktrans-fun _ _ _). +%total D (ktrans-fun _ D _). diff --git a/src/trans-reg.thm b/src/trans-reg.thm new file mode 100644 index 0000000..8c51bf4 --- /dev/null +++ b/src/trans-reg.thm @@ -0,0 +1,281 @@ + +trans-reg : trans EM M A -> of M A -> type. +%mode trans-reg +X1 -X2. + +tptrans-reg : tptrans EA A K -> kof A K -> type. +%mode tptrans-reg +X1 -X2. + +-const : trans-reg + (trans/const + (Dexpand : expand (const C) T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (Dcof : cof C A)) + Dof + <- expand-reg (at-of/const Dkof Dcof) Dsimp Dexpand + (Dof : of M A). + +-var : trans-reg + (trans/var + (Dexpand : expand X T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (Dvof : vof X A) + (Dvtrans : vtrans EX X %{A}%)) + Dof + <- expand-reg (at-of/var Dkof Dvof) Dsimp Dexpand + (Dof : of M A). + +-app : trans-reg + (trans/app + (DsubA : tpsub ([x] A x) N Ax) + (DsubM : sub ([x] M x) N Mx) + (DtransN : trans EN N B) + (DtransM : trans EM (lam ([x] M x)) (pi B ([x] A x)))) + DofMx + <- trans-reg DtransM + (of/lam + _ + ([x] [d] DofM x d : of (M x) (A x))) + <- trans-reg DtransN + (DofN : of N B) + <- subst DsubM DsubA DofM DofN + (DofMx : of Mx Ax). + +-lam : trans-reg + (trans/lam + ([x] [d:vof x A] + [ex] [xt : vtrans ex x] % vtrans ex x A + DtransM x d ex xt : trans (EM ex) (M x) (B x)) + (DtransA : tptrans EA A ktype)) + (of/lam DofA ([x] [d] DofM x d)) + <- tptrans-reg DtransA (DofA : kof A ktype) + <- ({x} {d} {ex} {xt} + trans-reg (DtransM x d ex xt) + (DofM x d : of (M x) (B x))). + +%% + +-const : tptrans-reg + (tptrans/const + (Dexpand : tpexpand (aconst C) H A) + (Dsimp : ksimp K H) + (Dwfkind : wfkind K) + (Dcof : ckof C K)) + DofA + <- tpexpand-reg (at-kof/const Dwfkind Dcof) Dsimp Dexpand + (DofA : kof A K). + +-app : tptrans-reg + (tptrans/app + (DsubA : ksub ([x] A x) N Ax) + (DsubM : tpsub ([x] M x) N Mx) + (DtransN : trans EN N B) + (DtransM : tptrans EM (alam ([x] M x)) (kpi B ([x] A x)))) + DofMx + <- tptrans-reg DtransM + (kof/lam + ([x] [d] DofM x d : kof (M x) (A x)) + _) + <- trans-reg DtransN + (DofN : of N B) + <- tpsubst DsubM DsubA DofM DofN + (DofMx : kof Mx Ax). + +-lam : tptrans-reg + (tptrans/lam + ([x] [d:vof x A] + [ex] [xt : vtrans ex x] % vtrans ex x A + DtransM x d ex xt : tptrans (EM ex) (M x) (B x)) + (DtransA : tptrans EA A ktype)) + (kof/lam ([x] [d] DofM x d) DofA) + <- tptrans-reg DtransA (DofA : kof A ktype) + <- ({x} {d} {ex} {xt} + tptrans-reg (DtransM x d ex xt) + (DofM x d : kof (M x) (B x))). + +-pi : tptrans-reg + (tptrans/pi + ([x] [d:vof x A] + [ex] [xt : vtrans ex x] % vtrans ex x A + DtransM x d ex xt : tptrans (EM ex) (M x) ktype) + (DtransA : tptrans EA A ktype)) + (kof/pi ([x] [d] DofM x d) DofA) + <- tptrans-reg DtransA (DofA : kof A ktype) + <- ({x} {d} {ex} {xt} + tptrans-reg (DtransM x d ex xt) + (DofM x d : kof (M x) ktype)). + +%worlds (csig | asig | bind | tbind | tobind) (trans-reg _ _) (tptrans-reg _ _). +%total (D1 D2) (trans-reg D1 _) (tptrans-reg D2 _). + + +%{ Not needed: an "ofe (lam _ _) _" derivation can be inverted inline. +%% inversion %% + +ofe-lam-invert : ofe G (lam [x] M x) (pi A [x] B x) + -> kofe G A ktype + -> ({x} ofe (cons G x A) (M x) (B x)) -> type. +%mode ofe-lam-invert +X1 -X2 -X3. + +-lam : ofe-lam-invert + (ofe/lam DofA DofM) DofA DofM. + +%worlds (var) (ofe-lam-invert _ _ _). +%total {} (ofe-lam-invert _ _ _). +}% + +trans-reg-e : ordered G -> transe G EM M A -> ofe G M A -> type. +%mode trans-reg-e +X0 +X1 -X2. + +tptrans-reg-e : ordered G -> tptranse G EA A K -> kofe G A K -> type. +%mode tptrans-reg-e +X0 +X1 -X2. + +-const : trans-reg-e + _ + (transe/const + (Dexpand : expand (const C) T M) + (Dsimp : simp A T) + (DofA : kof A ktype) + (Dcof : cof C A)) + Dofe + <- expand-reg (at-of/const DofA Dcof) Dsimp Dexpand + (Dof : of M A) + <- of-to-ofe Dof (Dofenil : ofe nil M A) + <- append-nil _ Dappend + <- weaken-ofe' Dappend Dofenil (Dofe : ofe G M A). + +-var : trans-reg-e + (Dord : ordered G) + (transe/var + (Dexpand : expand X T M) + (Dsimp : simp A T) + %% (DofA : kof A ktype) + (DofeA : kofe G A ktype) + (Dlook : lookup G X A) + (Dvtrans : vtrans EX X)) + DofM + <- expand-reg-e Dord (at-ofe/var DofeA Dlook) Dsimp Dexpand + (DofM : ofe G M A). + +-vari : trans-reg-e _ + (transe/vari + (Dexpand : expand X T M) + (Dsimp : simp A T) + (Dkof : kof A ktype) + (Dvof : vof X A) + (Dvtrans : vtrans EX X %{A}%)) + Dofe + <- expand-reg (at-of/var Dkof Dvof) Dsimp Dexpand + (Dof : of M A) + <- of-to-ofe Dof (Dofenil : ofe nil M A) + <- append-nil _ Dappend + <- weaken-ofe' Dappend Dofenil (Dofe : ofe G M A). + +-app : trans-reg-e Dord + (transe/app + (DsubA : tpsub ([x] A x) N Ax) + (DsubM : sub ([x] M x) N Mx) + (DtransN : transe G EN N B) + (DtransM : transe G EM (lam [x] M x) (pi B [x] A x))) + DofMx + <- trans-reg-e Dord DtransM + % (DofeM : ofe G (lam [x] M x) (pi B [x] A x)) % XXX covers? + (ofe/lam + (DofA : kofe G B ktype) + ([x] DofM x : ofe (cons G x B) (M x) (A x))) + <- trans-reg-e Dord DtransN + (DofN : ofe G N B) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x B)) + <- subst-e Dord' ([_] append/nil) csub/base + DofN DsubM DsubA DofM + (DofMx : ofe G Mx Ax). + +-lam : trans-reg-e Dord + (transe/lam + ([x] [ex] [xt:vtrans ex x] % vtrans ex x A + DtransM x ex xt + : transe (cons G x A) (EM ex) (M x) (B x)) + (DtransA : tptranse G EA A ktype)) + (ofe/lam + DofA + DofM) + <- tptrans-reg-e Dord DtransA + (DofA : kofe G A ktype) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x A)) + <- ({x} {d} {ex} {xt} + trans-reg-e (Dord' x d) (DtransM x ex xt) + (DofM x : ofe (cons G x A) (M x) (B x))). + +%% + +-const : tptrans-reg-e _ + (tptranse/const + Dexpand Dsimp Dwf Dcof) + Dkofe + <- tpexpand-reg (at-kof/const Dwf Dcof) Dsimp Dexpand + Dkof + <- kof-to-kofe Dkof Dkofenil + <- append-nil _ Dappend + <- weaken-kofe' Dappend Dkofenil Dkofe. + +-app : tptrans-reg-e Dord + (tptranse/app + (Dksub : ksub ([x] K x) N Kx) + (Dtpsub : tpsub ([x] A x) N Ax) + (DtransN : transe G EN N B) + (DtransA : tptranse G EA (alam [x] A x) (kpi B [x] K x))) + DofAx + <- tptrans-reg-e Dord DtransA + (kofe/lam + ([x] DofA x : kofe (cons G x B) (A x) (K x)) + (DofB : kofe G B ktype)) + <- trans-reg-e Dord DtransN + (DofN : ofe G N B) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x B)) + <- tpsubst-e Dord' ([_] append/nil) csub/base + DofN Dtpsub DofA Dksub + (DofAx : kofe G Ax Kx). + +-lam : tptrans-reg-e Dord + (tptranse/lam + ([x] [ex] [xt:vtrans ex x] % vtrans ex x A + DtransM x ex xt + : tptranse (cons G x A) (EM ex) (M x) (B x)) + (DtransA : tptranse G EA A ktype)) + (kofe/lam + DofM + DofA) + <- tptrans-reg-e Dord DtransA + (DofA : kofe G A ktype) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x A)) + <- ({x} {d} {ex} {xt} + tptrans-reg-e (Dord' x d) (DtransM x ex xt) + (DofM x : kofe (cons G x A) (M x) (B x))). + +-pi : tptrans-reg-e Dord + (tptranse/pi + ([x] [ex] [xt:vtrans ex x] % vtrans ex x A + DtransM x ex xt + : tptranse (cons G x A) (EM ex) (M x) ktype) + (DtransA : tptranse G EA A ktype)) + (kofe/pi + DofM + DofA) + <- tptrans-reg-e Dord DtransA + (DofA : kofe G A ktype) + <- extend-ordered _ Dord _ + ([x] [d] Dord' x d : ordered (cons G x A)) + <- ({x} {d} {ex} {xt} + tptrans-reg-e (Dord' x d) (DtransM x ex xt) + (DofM x : kofe (cons G x A) (M x) ktype)). + +%worlds (csig | asig | bind | tbind | tobind) + (trans-reg-e _ _ _) (tptrans-reg-e _ _ _). +%total (D1 D2) (trans-reg-e _ D1 _) (tptrans-reg-e _ D2 _). + + diff --git a/src/trans-sub.thm b/src/trans-sub.thm new file mode 100644 index 0000000..0150f89 --- /dev/null +++ b/src/trans-sub.thm @@ -0,0 +1,683 @@ + +trans-sub-e : ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> ({x} {ex} vtrans ex x + -> transe (G x) (EN ex) (N x) (B x)) + -> trans EM M A + -> csub ([x] G x) M Gx +%% + -> sub ([x] N x) M Nx + -> tpsub ([x] B x) M Bx + -> transe Gx (EN EM) Nx Bx -> type. +%mode trans-sub-e +X0 +X1 +X2 +X3 +X4 -X5 -X6 -X7. + +tptrans-sub-e : ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> ({x} {ex} vtrans ex x + -> tptranse (G x) (EB ex) (B x) (K x)) + -> trans EM M A + -> csub ([x] G x) M Gx +%% + -> tpsub ([x] B x) M Bx + -> ksub ([x] K x) M Kx + -> tptranse Gx (EB EM) Bx Kx -> type. +%mode tptrans-sub-e +X0 +X1 +X2 +X3 +X4 -X5 -X6 -X7. + +-const : trans-sub-e _ _ + ([x] [ex] [xt:vtrans ex x] + transe/const + (Dexpand x : expand (const C) T (N x)) + (Dsimp x : simp B T) + (DofB x : kof B ktype) + (Dcof : cof C B)) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + DsubN + DsubB + (transe/const + (Dexpand' aca) + (Dsimp aca) + (DofB aca) + Dcof) +%% + <- strengthen-expand Dexpand + ([x] DeqN x : tm-eq (N x) N') + <- ({x} tm-eq-sym (DeqN x) (DeqN' x : tm-eq N' (N x))) + <- ({x} + expand-resp atm-eq/i stp-eq/i (DeqN x) (Dexpand x) + (Dexpand' x : expand (const C) T N')) + <- sub-absent _ _ (DsubN' : sub ([_] N') M N') + <- sub-compat DeqN' tm-eq/i tm-eq/i DsubN' + (DsubN : sub ([x] N x) M N') + <- tpsub-absent _ _ (DsubB : tpsub ([_] B) M B). + +-varsam : trans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + transe/var + (Dexpand x : expand x T (N x)) + (DsimpA' x : simp (A' x) T) + % (DofA' x : kof (A' x) ktype) + (DofA' x : kofe (G x) (A' x) ktype) + (DlookA' x : lookup (G x) x (A' x)) + xt) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + DsubN' + DsubA' + DtranseM' +%% + %% Change A' to A in stuff + <- ({x} append-lookup (Dappend x) + (DlookA x : lookup (G x) x A)) + <- ({x} {d} + lookup-fun (Dord x d) (DlookA' x) (DlookA x) + (DeqA'A x : tp-eq (A' x) A)) + <- ({x} kofe-resp ctx-eq/i (DeqA'A x) kind-eq/i (DofA' x) + (DofA x : kofe (G x) A ktype)) + <- ({x} + lookup-compat ctx-eq/i atm-eq/i (DeqA'A x) (DlookA' x) + (Dlook x : lookup (G x) x A)) + <- ({x} + simp-compat (DeqA'A x) stp-eq/i (DsimpA' x) + (Dsimp x : simp A T)) + %% Get a bunch of typing assumptions to pass to + %% expand-sub + %{ + <- ({x} + kof-to-kofe (DofA x) + (DofenilA x : kofe nil A ktype)) + <- ({x} + append-nil _ (Dappend' x : append nil (G x) (G x))) + <- ({x} + weaken-kofe' (Dappend' x) (DofenilA x) + (DofeA x : kofe (G x) A ktype)) + }% + <- ({x} {d} + expand-reg-e (Dord x d) + (at-ofe/var (DofA x) (Dlook x)) + (Dsimp x) (Dexpand x) + (DofeN x : ofe (G x) (N x) A)) + <- trans-to-transe _ DtransM + (DtranseM : transe G1 EM M A) + <- ({x} {d} + ordered-append (Dappend x) (Dord x d) + (DordCons x d : ordered (cons G1 x A))) + <- ({x} {d} + ordered-cons (DordCons x d) + (Dord1 x d : ordered G1)) + <- strengthen-ordered Dord1 + (Dord1' : ordered G1) + <- trans-reg-e Dord1' DtranseM + (DofeM : ofe G1 M A) + <- can-sub-e Dappend Dord DofeN DofeM + (DsubN : sub ([x] N x) M M') + %% main important lemma use + <- expand-rmsub _ Dexpand DsubN headvar/var + (Drmsub : rmsub ([x] x) M M') + <- rmsub-fun Drmsub rmsub/var + (DeqMM' : tm-eq M' M) + <- sub-compat ([_] tm-eq/i) tm-eq/i DeqMM' DsubN + (DsubN' : sub ([x] N x) M M) + %% Get other outputs + <- trans-to-transe _ DtransM + (DtranseM' : transe Gx EM M A) + %% + <- tpsub-absent _ _ (DsubA : tpsub ([x] A) M A) + <- ({x} tp-eq-sym (DeqA'A x) (DeqAA' x : tp-eq A (A' x))) + <- tpsub-compat ([x] DeqAA' x) tm-eq/i tp-eq/i DsubA + (DsubA' : tpsub ([x] A' x) M A). + + +-varoth : trans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + transe/var + (Dexpand x : expand Y T (N x)) + (DsimpB x : simp (B x) T) + (DofB x : kofe (G x) (B x) ktype) + (DlookB x : lookup (G x) Y (B x)) + (Dvtrans : vtrans EY Y)) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + DsubN + DsubB + (transe/var + (Dexpand' aca) + DsimpBx + DofBx + DlookBx + Dvtrans) +%% + <- csub-lookup Dcsub DlookB + (DsubB : tpsub ([x] B x) M Bx) + (DlookBx : lookup Gx Y Bx) + <- tpsub-simp DsubB DsimpB + (DsimpBx : simp Bx T) + <- trans-reg DtransM (DofM : of M A) + <- of-to-ofe DofM (DofenilM : ofe nil M A) + <- append-nil _ (DappendG1 : append nil G1 G1) + <- weaken-ofe' DappendG1 DofenilM + (DofeM : ofe G1 M A) + <- tpsubst-e Dord Dappend Dcsub DofeM + DsubB DofB ksub/type + (DofBx : kofe Gx Bx ktype) + %% + <- strengthen-expand Dexpand + ([x] DeqN x : tm-eq (N x) N') + <- sub-absent _ _ + (DsubN' : sub ([_] N') M N') + <- ({x} tm-eq-sym (DeqN x) (DeqN' x : tm-eq N' (N x))) + <- sub-compat DeqN' tm-eq/i tm-eq/i DsubN' + (DsubN : sub ([x] N x) M N') + <- ({x} + expand-resp atm-eq/i stp-eq/i (DeqN x) (Dexpand x) + (Dexpand' x : expand Y T N')). + +-vari : trans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + transe/vari + (Dexpand x : expand Y T (N x)) + (DsimpB x : simp B T) + (DofB x : kof B ktype) + (Dvof : vof Y B) + (Dvtrans : vtrans EY Y)) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + DsubN + DsubB + (transe/vari + (Dexpand' aca) + (DsimpB aca) + (DofB aca) + Dvof + Dvtrans) +%% + <- strengthen-expand Dexpand + ([x] DeqN x : tm-eq (N x) N') + <- ({x} + expand-resp atm-eq/i stp-eq/i (DeqN x) (Dexpand x) + (Dexpand' x : expand Y T N')) + %% + <- tpsub-absent _ _ + (DsubB : tpsub ([x] B) M B) + %% + <- sub-absent _ _ + (DsubN' : sub ([x] N') M N') + <- ({x} tm-eq-sym (DeqN x) (DeqN' x : tm-eq N' (N x))) + <- sub-compat DeqN' tm-eq/i tm-eq/i DsubN' + (DsubN : sub ([x] N x) M N'). + +-app : trans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + transe/app + (DsubCy x : tpsub ([y] C x y) (N x) (Cy x)) + (DsubLy x : sub ([y] L x y) (N x) (Ly x)) + (DtransN x ex xt : transe (G x) (EN ex) (N x) (B x)) + (DtransL x ex xt + : transe (G x) (EL ex) (lam ([y] L x y)) + (pi (B x) ([y] C x y)))) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + DsubLyx + DsubCyx + (transe/app + DsubCxy + DsubLxy + DtransNx + DtransLx) +%% + <- trans-sub-e Dord Dappend DtransN DtransM Dcsub + (DsubN : sub ([x] N x) M Nx) + (DsubB : tpsub ([x] B x) M Bx) + (DtransNx : transe Gx (EN EM) Nx Bx) + <- trans-sub-e Dord Dappend DtransL DtransM Dcsub + (sub/lam + ([y] DsubLx y : sub ([x] L x y) M (Lx y))) + (tpsub/pi + ([y] DsubCx y : tpsub ([x] C x y) M (Cx y)) + (DsubB' : tpsub ([x] B x) M Bx')) + (DtransLx' + : transe Gx (EL EM) (lam ([y] Lx y)) (pi Bx' ([y] Cx y))) + <- tpsub-fun DsubB' DsubB + (DeqBx : tp-eq Bx' Bx) + <- pi-compat DeqBx ([_] tp-eq/i) + (DeqPi : tp-eq (pi Bx' ([y] Cx y)) (pi Bx ([y] Cx y))) + <- transe-resp ctx-eq/i etm-eq/i tm-eq/i DeqPi DtransLx' + (DtransLx + : transe Gx (EL EM) (lam ([y] Lx y)) (pi Bx ([y] Cx y))) + %% The remainder of this case is to call sub-permute + %% M is well-typed + <- trans-reg DtransM + (DofM : of M A) + <- of-to-ofe DofM (DofenilM : ofe nil M A) + <- append-nil _ (DappendNil : append nil G1 G1) + <- weaken-ofe' DappendNil DofenilM (DofeM : ofe G1 M A) + %% N is well-typed + <- ({x} {d} {ex} {xt} + trans-reg-e (Dord x d) (DtransN x ex xt) + (DofN x : ofe (G x) (N x) (B x))) + %% L is well-typed + <- ({x} {d} {ex} {xt} + trans-reg-e (Dord x d) (DtransL x ex xt) + (ofe/lam + (DofB x) + ([y] DofL x y + : ofe (cons (G x) y (B x)) (L x y) (C x y)))) + %% C is well-formed + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : ordered (cons (G x) y (B x)))) + <- ({x} {d} {y} {e} + ofe-reg (Dord' x d y e) (DofL x y) + (DofC x y : kofe (cons (G x) y (B x)) (C x y) ktype)) + %% go + <- sub-permute-e Dord Dappend DofeM DofN DofL + DsubN DsubLy DsubLx + (DsubLyx : sub ([x] Ly x) M Lyx) + (DsubLxy : sub ([y] Lx y) Nx Lyx) + <- tpsub-permute-e Dord Dappend DofeM DofN DofC + DsubN DsubCy DsubCx + (DsubCyx : tpsub ([x] Cy x) M Cyx) + (DsubCxy : tpsub ([y] Cx y) Nx Cyx). + +-lam : trans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + transe/lam + ([y] [ey] [yt:vtrans ey y] + DtransN x ex xt y ey yt + : transe (cons (G x) y (B x)) + (EN ex ey) (N x y) (C x y)) + (DtransB x ex xt + : tptranse (G x) (EB ex) (B x) ktype)) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + (sub/lam + DsubN) + (tpsub/pi + DsubC + DsubB) + (transe/lam + DtransNx + DtransBx) +%% + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- tptrans-sub-e Dord Dappend DtransB DtransM Dcsub + (DsubB : tpsub ([x] B x) M Bx) + _ + (DtransBx + : tptranse Gx (EB EM) Bx ktype) + <- ({y} {e} {ey} {yt} + trans-sub-e ([x] [d] Dord' x d y e) + ([x] append/cons (Dappend x)) + ([x] [ex] [xt] DtransN x ex xt y ey yt) DtransM + (csub/cons DsubB Dcsub) + (DsubN y : sub ([x] N x y) M (Nx y)) + (DsubC y : tpsub ([x] C x y) M (Cx y)) + (DtransNx y ey yt + : transe _ (EN EM ey) (Nx y) (Cx y))). + +%% + +-const : tptrans-sub-e _ _ + ([x] [ex] [xt:vtrans ex x] + tptranse/const + (Dexpand x : tpexpand (aconst C) T (N x)) + (Dsimp x : ksimp B T) + (DofB x : wfkind B) + (Dcof : ckof C B)) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + DsubN + DsubB + (tptranse/const + (Dexpand' aca) + (Dsimp aca) + (DofB aca) + Dcof) +%% + <- strengthen-tpexpand Dexpand + ([x] DeqN x : tp-eq (N x) N') + <- ({x} tp-eq-sym (DeqN x) (DeqN' x : tp-eq N' (N x))) + <- ({x} + tpexpand-resp atp-eq/i skind-eq/i (DeqN x) (Dexpand x) + (Dexpand' x : tpexpand (aconst C) T N')) + <- tpsub-absent _ _ (DsubN' : tpsub ([_] N') M N') + <- tpsub-compat DeqN' tm-eq/i tp-eq/i DsubN' + (DsubN : tpsub ([x] N x) M N') + %% + <- ksub-absent _ _ (DsubB : ksub ([_] B) M B). + +-app : tptrans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + tptranse/app + (DsubCy x : ksub ([y] C x y) (N x) (Cy x)) + (DsubLy x : tpsub ([y] L x y) (N x) (Ly x)) + (DtransN x ex xt : transe (G x) (EN ex) (N x) (B x)) + (DtransL x ex xt + : tptranse (G x) (EL ex) (alam ([y] L x y)) + (kpi (B x) ([y] C x y)))) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + DsubLyx + DsubCyx + (tptranse/app + DsubCxy + DsubLxy + DtransNx + DtransLx) +%% + <- trans-sub-e Dord Dappend DtransN DtransM Dcsub + (DsubN : sub ([x] N x) M Nx) + (DsubB : tpsub ([x] B x) M Bx) + (DtransNx : transe Gx (EN EM) Nx Bx) + <- tptrans-sub-e Dord Dappend DtransL DtransM Dcsub + (tpsub/lam + ([y] DsubLx y : tpsub ([x] L x y) M (Lx y))) + (ksub/pi + ([y] DsubCx y : ksub ([x] C x y) M (Cx y)) + (DsubB' : tpsub ([x] B x) M Bx')) + (DtransLx' + : tptranse Gx (EL EM) (alam ([y] Lx y)) + (kpi Bx' ([y] Cx y))) + <- tpsub-fun DsubB' DsubB + (DeqBx : tp-eq Bx' Bx) + <- kpi-compat DeqBx ([_] kind-eq/i) + (DeqPi : kind-eq (kpi Bx' ([y] Cx y)) (kpi Bx ([y] Cx y))) + <- tptranse-resp ctx-eq/i etp-eq/i tp-eq/i DeqPi DtransLx' + (DtransLx + : tptranse Gx (EL EM) (alam ([y] Lx y)) + (kpi Bx ([y] Cx y))) + %% The remainder of this case is to call sub-permute + %% M is well-typed + <- trans-reg DtransM + (DofM : of M A) + <- of-to-ofe DofM (DofenilM : ofe nil M A) + <- append-nil _ (DappendNil : append nil G1 G1) + <- weaken-ofe' DappendNil DofenilM (DofeM : ofe G1 M A) + %% N is well-typed + <- ({x} {d} {ex} {xt} + trans-reg-e (Dord x d) (DtransN x ex xt) + (DofN x : ofe (G x) (N x) (B x))) + %% L is well-typed + <- ({x} {d} {ex} {xt} + tptrans-reg-e (Dord x d) (DtransL x ex xt) + (kofe/lam + ([y] DofL x y + : kofe (cons (G x) y (B x)) (L x y) (C x y)) + (DofB x))) + %% extend the context + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e + : ordered (cons (G x) y (B x)))) + %% go + <- tpsub-permute-e Dord Dappend DofeM DofN DofL + DsubN DsubLy DsubLx + (DsubLyx : tpsub ([x] Ly x) M Lyx) + (DsubLxy : tpsub ([y] Lx y) Nx Lyx) + <- ({x} {d} {y} {e} + kofe-reg (Dord' x d y e) (DofL x y) + (DofC x y : wfkinde (cons (G x) y (B x)) (C x y))) + <- ksub-permute-e Dord Dappend DofeM DofN DofC + DsubN DsubCy DsubCx + (DsubCyx : ksub ([x] Cy x) M Cyx) + (DsubCxy : ksub ([y] Cx y) Nx Cyx). + +-lam : tptrans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + tptranse/lam + ([y] [ey] [yt:vtrans ey y] + DtransN x ex xt y ey yt + : tptranse (cons (G x) y (B x)) + (EN ex ey) (N x y) (C x y)) + (DtransB x ex xt + : tptranse (G x) (EB ex) (B x) ktype)) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + (tpsub/lam + DsubN) + (ksub/pi + DsubC + DsubB) + (tptranse/lam + DtransNx + DtransBx) +%% + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- tptrans-sub-e Dord Dappend DtransB DtransM Dcsub + (DsubB : tpsub ([x] B x) M Bx) + _ + (DtransBx + : tptranse Gx (EB EM) Bx ktype) + <- ({y} {e} {ey} {yt} + tptrans-sub-e ([x] [d] Dord' x d y e) + ([x] append/cons (Dappend x)) + ([x] [ex] [xt] DtransN x ex xt y ey yt) DtransM + (csub/cons DsubB Dcsub) + (DsubN y : tpsub ([x] N x y) M (Nx y)) + (DsubC y : ksub ([x] C x y) M (Cx y)) + (DtransNx y ey yt + : tptranse _ (EN EM ey) (Nx y) (Cx y))). + +-pi : tptrans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + tptranse/pi + ([y] [ey] [yt:vtrans ey y] + DtransN x ex xt y ey yt + : tptranse (cons (G x) y (B x)) + (EN ex ey) (N x y) ktype) + (DtransB x ex xt + : tptranse (G x) (EB ex) (B x) ktype)) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + (tpsub/pi DsubN DsubB) + ksub/type + (tptranse/pi DtransNx DtransBx) +%% + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- tptrans-sub-e Dord Dappend DtransB DtransM Dcsub + (DsubB : tpsub ([x] B x) M Bx) + _ + (DtransBx + : tptranse Gx (EB EM) Bx ktype) + <- ({y} {e} {ey} {yt} + tptrans-sub-e ([x] [d] Dord' x d y e) + ([x] append/cons (Dappend x)) + ([x] [ex] [xt] DtransN x ex xt y ey yt) DtransM + (csub/cons DsubB Dcsub) + (DsubN y : tpsub ([x] N x y) M (Nx y)) + ksub/type + (DtransNx y ey yt + : tptranse _ (EN EM ey) (Nx y) ktype)). + + +%worlds (csig | asig | bind | tbind | tobind) + (trans-sub-e _ _ _ _ _ _ _ _) + (tptrans-sub-e _ _ _ _ _ _ _ _). +%total (D1 D2) + (trans-sub-e _ _ D1 _ _ _ _ _) + (tptrans-sub-e _ _ D2 _ _ _ _ _). + +ktrans-sub-e : ({x} isvar x I -> ordered (G x)) + -> ({x} append (cons G1 x A) (G2 x) (G x)) + -> ({x} {ex} vtrans ex x + -> ktranse (G x) (EK ex) (K x)) + -> trans EM M A + -> csub ([x] G x) M Gx +%% + -> ksub ([x] K x) M Kx + -> ktranse Gx (EK EM) Kx -> type. +%mode ktrans-sub-e +X1 +X2 +X3 +X4 +X5 -X6 -X7. + +-type : ktrans-sub-e _ _ ([x] [ex] [xt] ktranse/type) _ _ + ksub/type + ktranse/type. + +-pi : ktrans-sub-e + ([x] [d:isvar x I] Dord x d : ordered (G x)) + ([x] Dappend x : append (cons G1 x A) (G2 x) (G x)) + ([x] [ex] [xt:vtrans ex x] + ktranse/pi + ([y] [ey] [yt:vtrans ey y] + DtransN x ex xt y ey yt + : ktranse (cons (G x) y (B x)) (EN ex ey) (N x y)) + (DtransB x ex xt + : tptranse (G x) (EB ex) (B x) ktype)) + (DtransM : trans EM M A) + (Dcsub : csub ([x] G x) M Gx) +%% + (ksub/pi DsubN DsubB) + (ktranse/pi DtransNx DtransBx) +%% + <- ({x} {d} + extend-ordered _ (Dord x d) J + ([y] [e] Dord' x d y e : ordered (cons (G x) y (B x)))) + <- tptrans-sub-e Dord Dappend DtransB DtransM Dcsub + (DsubB : tpsub ([x] B x) M Bx) + _ + (DtransBx + : tptranse Gx (EB EM) Bx ktype) + <- ({y} {e} {ey} {yt} + ktrans-sub-e ([x] [d] Dord' x d y e) + ([x] append/cons (Dappend x)) + ([x] [ex] [xt] DtransN x ex xt y ey yt) DtransM + (csub/cons DsubB Dcsub) + (DsubN y : ksub ([x] N x y) M (Nx y)) + (DtransNx y ey yt + : ktranse _ (EN EM ey) (Nx y))). + + +%worlds (csig | asig | bind | tbind | tobind) + (ktrans-sub-e _ _ _ _ _ _ _). +%total D (ktrans-sub-e _ _ D _ _ _ _). + +trans-sub : ({x} vof x A + -> {ex} vtrans ex x -> trans (EN ex) (N x) (B x)) + -> trans EM M A +%% + -> sub ([x] N x) M Nx + -> tpsub ([x] B x) M Bx + -> trans (EN EM) Nx Bx -> type. +%mode trans-sub +X1 +X2 -X3 -X4 -X5. + +- : trans-sub + ([x] [d] [ex] [xt] + DtransN x d ex xt : trans (EN ex) (N x) (B x)) + (DtransM : trans EM M A) +%% + Dsub + Dtpsub + Dtrans +%% + <- trans1-to-transe DtransN + ([x] [ex] [xt] + DtranseN x ex xt : transe (cons nil x A) (EN ex) (N x) (B x)) + <- extend-ordered _ ordered/nil _ + ([x] [d] Dord x d : ordered (cons nil x A)) + <- trans-sub-e Dord ([x] append/nil) DtranseN DtransM csub/base + (Dsub : sub ([x] N x) M Nx) + (Dtpsub : tpsub ([x] B x) M Bx) + (Dtranse : transe nil (EN EM) Nx Bx) + <- transe-to-trans Dtranse + (Dtrans : trans (EN EM) Nx Bx). + +%worlds (csig | asig | bind | tbind) (trans-sub _ _ _ _ _). +%total D (trans-sub D _ _ _ _). + +tptrans-sub : ({x} vof x A + -> {ex} vtrans ex x + -> tptrans (EB ex) (B x) (K x)) + -> trans EM M A +%% + -> tpsub ([x] B x) M Bx + -> ksub ([x] K x) M Kx + -> tptrans (EB EM) Bx Kx -> type. +%mode tptrans-sub +X1 +X2 -X3 -X4 -X5. + +- : tptrans-sub + ([x] [d] [ex] [xt] + DtransN x d ex xt : tptrans (EN ex) (N x) (B x)) + (DtransM : trans EM M A) +%% + Dsub + Dtpsub + Dtrans +%% + <- tptrans1-to-tptranse DtransN + ([x] [ex] [xt] + DtranseN x ex xt : tptranse (cons nil x A) (EN ex) (N x) (B x)) + <- extend-ordered _ ordered/nil _ + ([x] [d] Dord x d : ordered (cons nil x A)) + <- tptrans-sub-e Dord ([x] append/nil) DtranseN DtransM csub/base + (Dsub : tpsub ([x] N x) M Nx) + (Dtpsub : ksub ([x] B x) M Bx) + (Dtranse : tptranse nil (EN EM) Nx Bx) + <- tptranse-to-tptrans Dtranse + (Dtrans : tptrans (EN EM) Nx Bx). + +%worlds (csig | asig | bind | tbind) (tptrans-sub _ _ _ _ _). +%total D (tptrans-sub D _ _ _ _). + +ktrans-sub : ({x} vof x A + -> {ex} vtrans ex x + -> ktrans (EK ex) (K x)) + -> trans EM M A +%% + -> ksub ([x] K x) M Kx + -> ktrans (EK EM) Kx -> type. +%mode ktrans-sub +X1 +X2 -X3 -X4. + +- : ktrans-sub + ([x] [d] [ex] [xt] + DtransK x d ex xt : ktrans (EK ex) (K x)) + (DtransM : trans EM M A) +%% + Dsub + Dtrans +%% + <- ktrans1-to-ktranse DtransK + ([x] [ex] [xt] + DtranseK x ex xt : ktranse (cons nil x A) (EK ex) (K x)) + <- extend-ordered _ ordered/nil _ + ([x] [d] Dord x d : ordered (cons nil x A)) + <- ktrans-sub-e Dord ([x] append/nil) DtranseK DtransM csub/base + (Dsub : ksub ([x] K x) M Kx) + (Dtranse : ktranse nil (EK EM) Kx) + <- ktranse-to-ktrans Dtranse + (Dtrans : ktrans (EK EM) Kx). + +%worlds (csig | asig | bind | tbind) (ktrans-sub _ _ _ _). +%total {} (ktrans-sub _ _ _ _). + diff --git a/src/translate.elf b/src/translate.elf new file mode 100644 index 0000000..149c926 --- /dev/null +++ b/src/translate.elf @@ -0,0 +1,172 @@ + +ktrans : ekind -> kind -> type. +tptrans : etp -> tp -> kind -> type. +vtrans : etm -> atm -> type. +trans : etm -> tm -> tp -> type. + + +ktrans/type : ktrans ektype ktype. + +ktrans/pi : ktrans (ekpi EA ([ex] EK ex)) (kpi A ([x] K x)) + <- tptrans EA A ktype + <- ({x} vof x A + -> {ex} vtrans ex x + -> ktrans (EK ex) (K x)). + +tptrans/const : tptrans (eaconst C) A K + <- ckof C K + <- wfkind K +% <- kclosed K + <- ksimp K H + <- tpexpand (aconst C) H A. + +tptrans/app : tptrans (eaapp EA EN) Ax Kx + <- tptrans EA (alam ([x] A x)) (kpi B ([x] K x)) + <- trans EN N B + <- tpsub ([x] A x) N Ax + <- ksub ([x] K x) N Kx. + +tptrans/pi : tptrans (epi EA ([ex] EB ex)) (pi A ([x] B x)) ktype + <- tptrans EA A ktype + <- ({x} vof x A + -> {ex} vtrans ex x + -> tptrans (EB ex) (B x) ktype). + +tptrans/lam : tptrans (ealam EA ([ex] EB ex)) (alam ([x] B x)) + (kpi A ([x] K x)) + <- tptrans EA A ktype + <- ({x} vof x A + -> {ex} vtrans ex x + -> tptrans (EB ex) (B x) (K x)). + + +trans/const : trans (econst C) M A + <- cof C A + <- kof A ktype +% <- tclosed A + <- simp A T + <- expand (const C) T M. + +trans/var : trans EM M A + <- vtrans EM X + <- vof X A + <- kof A ktype + <- simp A T + <- expand X T M. + +trans/app : trans (eapp EM EN) Mx Ax + <- trans EM (lam ([x] M x)) (pi B ([x] A x)) + <- trans EN N B + <- sub ([x] M x) N Mx + <- tpsub ([x] A x) N Ax. + +trans/lam : trans (elam EA ([ex] EM ex)) (lam ([x] M x)) + (pi A ([x] B x)) + <- tptrans EA A ktype + <- ({x} vof x A + -> {ex} vtrans ex x + -> trans (EM ex) (M x) (B x)). + +- : (vtrans _ _ -> vtrans _ _) -> type. + +%block tvar : block {x:atm} {ex:etm} + {tr:vtrans ex x}. + +%block tbind : some {A:tp} + block {x:atm} {d:vof x A} + {ex:etm} {xt:vtrans ex x}. + +%block tobind : some {I:nat} {A:tp} + block {x:atm} {d:isvar x I} + {ex:etm} %{ed:eisvar ex I}% + {xt:vtrans ex x}. + +%% Signature Translation %% +%% XXX move? Is it right? +%block tcsig : some {A:tp} {EA:etp} {dt:tptrans EA A ktype} + block {c:ctm} {d:cof c A} {ed:ecof c EA}. + + + +%% XXX not sure this is a good block. + +%{ +%block tevar : some {R:atm} + block {ex:etm} {tr:vtrans ex R}. +}% + +%%% explicit contexts version %%% + +ktranse : ctx -> ekind -> kind -> type. +tptranse : ctx -> etp -> tp -> kind -> type. +transe : ctx -> etm -> tm -> tp -> type. + +%% + +ktranse/type : ktranse G ektype ktype. + +ktranse/pi : ktranse G (ekpi EA ([ex] EK ex)) (kpi A ([x] K x)) + <- tptranse G EA A ktype + <- ({x} {ex} vtrans ex x + -> ktranse (cons G x A) (EK ex) (K x)). + +%% + +tptranse/const : tptranse G (eaconst C) A K + <- ckof C K + <- wfkind K +% <- kclosed K + <- ksimp K H + <- tpexpand (aconst C) H A. + +tptranse/app : tptranse G (eaapp EA EN) Ax Kx + <- tptranse G EA (alam ([x] A x)) (kpi B ([x] K x)) + <- transe G EN N B + <- tpsub ([x] A x) N Ax + <- ksub ([x] K x) N Kx. + +tptranse/pi : tptranse G (epi EA ([ex] EB ex)) (pi A ([x] B x)) ktype + <- tptranse G EA A ktype + <- ({x} {ex} vtrans ex x + -> tptranse (cons G x A) (EB ex) (B x) ktype). + +tptranse/lam : tptranse G (ealam EA ([ex] EB ex)) (alam ([x] B x)) + (kpi A ([x] K x)) + <- tptranse G EA A ktype + <- ({x} {ex} vtrans ex x + -> tptranse (cons G x A) (EB ex) (B x) (K x)). + +%% + +transe/const : transe G (econst C) M A + <- cof C A + <- kof A ktype +% <- tclosed A + <- simp A T + <- expand (const C) T M. + +transe/var : transe G EM M A + <- vtrans EM X + <- lookup G X A + <- kofe G A ktype %% was <- kof A ktype, changed 10/26/09. + <- simp A T + <- expand X T M. + +transe/vari : transe G EM M A + <- vtrans EM X + <- vof X A + <- kof A ktype + <- simp A T + <- expand X T M. + +transe/app : transe G (eapp EM EN) Mx Ax + <- transe G EM (lam [x] M x) (pi B ([x] A x)) + <- transe G EN N B + <- sub ([x] M x) N Mx + <- tpsub ([x] A x) N Ax. + +transe/lam : transe G (elam EA ([ex] EM ex)) (lam ([x] M x)) + (pi A ([x] B x)) + <- tptranse G EA A ktype + <- ({x} {ex} vtrans ex x + -> transe (cons G x A) (EM ex) (M x) (B x)).