From c570bc0c6b515813a1337c9043773404e29fa14e Mon Sep 17 00:00:00 2001 From: Ailrun Date: Fri, 4 Oct 2024 23:38:34 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20Beluga-l?= =?UTF-8?q?ang/McLTT@44c863346b29a2b5d4c30ea2a037cb9175e2f6b1=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext/prop-eq/Mcltt.Core.Syntactic.CtxSub.html | 48 +- ext/prop-eq/Mcltt.Core.Syntactic.Presup.html | 2645 +++++++++-------- ext/prop-eq/Mcltt.Core.Syntactic.Syntax.html | 2 +- ...ltt.Core.Syntactic.System.Definitions.html | 303 +- .../Mcltt.Core.Syntactic.System.Lemmas.html | 1468 +++++---- ext/prop-eq/Mcltt.LibTactics.html | 10 +- ext/prop-eq/indexpage.html | 94 +- ext/prop-eq/toc.html | 5 +- 8 files changed, 2449 insertions(+), 2126 deletions(-) diff --git a/ext/prop-eq/Mcltt.Core.Syntactic.CtxSub.html b/ext/prop-eq/Mcltt.Core.Syntactic.CtxSub.html index 13afcad..e952702 100644 --- a/ext/prop-eq/Mcltt.Core.Syntactic.CtxSub.html +++ b/ext/prop-eq/Mcltt.Core.Syntactic.CtxSub.html @@ -121,13 +121,21 @@

Mcltt.Core.Syntactic.CtxSub

eqrec related cases
-    1-3:assert {{ Δ, B Γ, B }} by mauto;
-      assert {{ Γ, B B[Wk] : Type@i }} by mauto;
-      assert {{ Δ, B B[Wk] : Type@i }} by mauto;
-      assert {{ Δ, B, B[Wk] Γ, B, B[Wk] }} by (econstructor; mauto 4);
-      assert {{ Γ, B, B[Wk] Eq (B[Wk][Wk]) #1 #0 : Type@i }} by (econstructor; mauto 4);
-      assert {{ Δ, B, B[Wk] Eq (B[Wk][Wk]) #1 #0 : Type@i }} by (econstructor; mauto 4);
-      assert {{ Δ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0 Γ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0 }} by mauto;
+    1-3: assert {{ Δ, B Γ, B }} by mauto;
+      assert {{ Γ, B s Wk : Γ }} by mauto 3;
+      assert {{ Γ, B B[Wk] : Type@i }} by mauto 3;
+      assert {{ Γ, B, B[Wk] s Wk : Γ, B }} by mauto 4;
+      assert {{ Γ, B, B[Wk] s WkWk : Γ }} by mauto 3;
+      assert {{ Δ, B s Wk : Δ }} by mauto 3;
+      assert {{ Δ, B B[Wk] : Type@i }} by mauto 3;
+      assert {{ Δ, B, B[Wk] s Wk : Δ, B }} by mauto 4;
+      assert {{ Δ, B, B[Wk] s WkWk : Δ }} by mauto 3;
+      assert {{ Δ, B, B[Wk] B[WkWk] : Type@i }} by mauto 3;
+      assert {{ Δ, B, B[Wk] B[WkWk] : Type@i }} by mauto 3;
+      assert {{ Δ, B, B[Wk] Γ, B, B[Wk] }} by (econstructor; mauto 4);
+      assert {{ Γ, B, B[Wk] Eq B[WkWk] #1 #0 : Type@i }} by (econstructor; mauto 3; eapply wf_conv; mauto 4);
+      assert {{ Δ, B, B[Wk] Eq B[WkWk] #1 #0 : Type@i }} by (econstructor; mauto 3; eapply wf_conv; mauto 4);
+      assert {{ Δ, B, B[Wk], Eq B[WkWk] #1 #0 Γ, B, B[Wk], Eq B[WkWk] #1 #0 }} by mauto 3;
      econstructor; mauto 2.

@@ -138,39 +146,39 @@

Mcltt.Core.Syntactic.CtxSub

      inversion_clear HΓΔ as [|Δ0 ? ? C'].
-      assert (exists D, {{ #x : D Δ0 }} /\ {{ Δ0 D B }}) as [D [i0 ?]] by mauto.
+      assert (exists D, {{ #x : D Δ0 }} /\ {{ Δ0 D B }}) as [D [i0 ?]] by mauto.
      destruct_conjs.
-      assert {{ Δ0, C' }} by mauto.
-      assert {{ Δ0, C' D[Wk] B[Wk] }}...
+      assert {{ Δ0, C' }} by mauto.
+      assert {{ Δ0, C' D[Wk] B[Wk] }}...
    - eapply wf_subtyp_pi with (i := i); firstorder mauto 4.
  Qed.

-  Corollary ctxsub_exp : forall {Γ Δ M A}, {{ Δ Γ }} -> {{ Γ M : A }} -> {{ Δ M : A }}.
+  Corollary ctxsub_exp : forall {Γ Δ M A}, {{ Δ Γ }} -> {{ Γ M : A }} -> {{ Δ M : A }}.
  Proof.
    eauto using ctxsub_exp_helper.
  Qed.

-  Corollary ctxsub_exp_eq : forall {Γ Δ M M' A}, {{ Δ Γ }} -> {{ Γ M M' : A }} -> {{ Δ M M' : A }}.
+  Corollary ctxsub_exp_eq : forall {Γ Δ M M' A}, {{ Δ Γ }} -> {{ Γ M M' : A }} -> {{ Δ M M' : A }}.
  Proof.
    eauto using ctxsub_exp_eq_helper.
  Qed.

-  Corollary ctxsub_sub : forall {Γ Δ σ Γ'}, {{ Δ Γ }} -> {{ Γ s σ : Γ' }} -> {{ Δ s σ : Γ' }}.
+  Corollary ctxsub_sub : forall {Γ Δ σ Γ'}, {{ Δ Γ }} -> {{ Γ s σ : Γ' }} -> {{ Δ s σ : Γ' }}.
  Proof.
    eauto using ctxsub_sub_helper.
  Qed.

-  Corollary ctxsub_sub_eq : forall {Γ Δ σ σ' Γ'}, {{ Δ Γ }} -> {{ Γ s σ σ' : Γ' }} -> {{ Δ s σ σ' : Γ' }}.
+  Corollary ctxsub_sub_eq : forall {Γ Δ σ σ' Γ'}, {{ Δ Γ }} -> {{ Γ s σ σ' : Γ' }} -> {{ Δ s σ σ' : Γ' }}.
  Proof.
    eauto using ctxsub_sub_eq_helper.
  Qed.

-  Corollary ctxsub_subtyp : forall {Γ Δ A B}, {{ Δ Γ }} -> {{ Γ A B }} -> {{ Δ A B }}.
+  Corollary ctxsub_subtyp : forall {Γ Δ A B}, {{ Δ Γ }} -> {{ Γ A B }} -> {{ Δ A B }}.
  Proof.
    eauto using ctxsub_subtyp_helper.
  Qed.
@@ -184,11 +192,11 @@

Mcltt.Core.Syntactic.CtxSub

Export ctxsub_judg.

-Lemma wf_ctx_sub_trans : forall Γ0 Γ1,
-    {{ Γ0 Γ1 }} ->
-    forall Γ2,
-    {{ Γ1 Γ2 }} ->
-    {{ Γ0 Γ2 }}.
+Lemma wf_ctx_sub_trans : forall Γ0 Γ1,
+    {{ Γ0 Γ1 }} ->
+    forall Γ2,
+    {{ Γ1 Γ2 }} ->
+    {{ Γ0 Γ2 }}.
Proof.
  induction 1; intros; progressive_inversion; [constructor |].
  eapply wf_ctx_sub_extend with (i := max i i0);
diff --git a/ext/prop-eq/Mcltt.Core.Syntactic.Presup.html b/ext/prop-eq/Mcltt.Core.Syntactic.Presup.html index af6d673..3af971e 100644 --- a/ext/prop-eq/Mcltt.Core.Syntactic.Presup.html +++ b/ext/prop-eq/Mcltt.Core.Syntactic.Presup.html @@ -33,1449 +33,1478 @@

Mcltt.Core.Syntactic.Presup

From Mcltt.Core.Syntactic Require Export CtxEq.
Import Syntax_Notations.
+
+Lemma presup_exp_eq_natrec_cong_right : forall {Γ i A A' MZ' MS' M M'},
+    {{ Γ, A : Type@i }} ->
+    {{ Γ, A' : Type@i }} ->
+    {{ Γ, A A' : Type@i }} ->
+    {{ Γ MZ' : A[Id,,zero] }} ->
+    {{ Γ, , A MS' : A[WkWk,,succ #1] }} ->
+    {{ Γ M : }} ->
+    {{ Γ M' : }} ->
+    {{ Γ M M' : }} ->
+    {{ Γ rec M' return A' | zero -> MZ' | succ -> MS' end : A[Id,,M] }}.
+Proof.
+  intros.
+  assert {{ Γ }} by mauto 2.
+  assert {{ Γ s Id,,M : Γ, }} by mauto 3.
+  assert {{ Γ s Id,,M' : Γ, }} by mauto 3.
+  assert {{ Γ s Id,,M Id,,M' : Γ, }} by mauto 3.
+  assert {{ Γ A[Id,,M] A'[Id,,M'] : Type@i }} by (transitivity {{{ A[Id,,M'] }}}; mauto 2).
+  assert {{ Γ s Id,,zero : Γ, }} by mauto 3.
+  assert {{ Γ MZ' : A'[Id,,zero] }} by mauto 4.
+  assert {{ Γ, , A s WkWk,,succ #1 : Γ, }} by mauto 3.
+  assert {{ Γ, , A MS' : A'[WkWk,,succ #1] }} by mauto 4.
+  assert {{ Γ, , A Γ, , A' }} by mauto 4.
+  assert {{ Γ, , A' MS' : A'[WkWk,,succ #1] }} by mauto 3.
+  eapply wf_conv; mauto 2.
+Qed.
+
#[local]
-Ltac gen_presup_ctx H :=
-  match type of H with
-  | {{ ^?Γ ^?Δ }} =>
-      let := fresh "HΓ" in
-      let := fresh "HΔ" in
-      pose proof presup_ctx_eq H as [ ]
-  | {{ ^?Γ ^?Δ }} =>
-      let := fresh "HΓ" in
-      let := fresh "HΔ" in
-      pose proof presup_ctx_sub H as [ ]
-  end.
+Hint Resolve presup_exp_eq_natrec_cong_right : mcltt.
+ +
+Lemma presup_exp_eq_natrec_sub_left : forall {Γ σ Δ i A MZ MS M},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ , A : Type@i }} ->
+    {{ Δ MZ : A[Id,,zero] }} ->
+    {{ Δ, , A MS : A[WkWk,,succ #1] }} ->
+    {{ Δ M : }} ->
+    {{ Γ rec M return A | zero -> MZ | succ -> MS end[σ] : A[σ,,M[σ]] }}.
+Proof.
+  intros.
+  assert {{ Δ }} by mauto 2.
+  assert {{ Γ s σ,,M[σ] : Δ, }} by mauto 3.
+  assert {{ Γ A[σ,,M[σ]] : Type@i }} by mauto 2.
+  assert {{ Δ s Id,,M : Δ, }} by mauto 3.
+  assert {{ Γ s (Id,,M)σ σ,,M[σ] : Δ, }} by mauto 2.
+  assert {{ Γ A[(Id,,M)σ] A[σ,,M[σ]] : Type@i }} by mauto 3.
+  assert {{ Γ A[Id,,M][σ] A[σ,,M[σ]] : Type@i }} by mauto 3.
+  eapply wf_conv; mauto 3.
+Qed.

#[local]
-Ltac gen_presup_IH presup_exp_eq presup_sub_eq presup_subtyp H :=
-  match type of H with
-  | {{ ^?Γ ^?M ^?N : ^?A }} =>
-      let := fresh "HΓ" in
-      let i := fresh "i" in
-      let HM := fresh "HM" in
-      let HN := fresh "HN" in
-      let HAi := fresh "HAi" in
-      pose proof presup_exp_eq _ _ _ _ H as [ [HM [HN [i HAi]]]]
- | {{ ^?Γ s ^ ^: ^?Δ }} =>
-      let := fresh "HΓ" in
-      let Hσ := fresh "Hσ" in
-      let Hτ := fresh "Hτ" in
-      let := fresh "HΔ" in
-      pose proof presup_sub_eq _ _ _ _ H as [ [Hσ [Hτ ]]]
- | {{ ^?Γ ^?M ^?N }} =>
-      let := fresh "HΓ" in
-      let i := fresh "i" in
-      let HM := fresh "HM" in
-      let HN := fresh "HN" in
-      pose proof presup_subtyp _ _ _ H as [ [i [HM HN]]]
- | {{ ^?Γ ^?M : ^?A }} =>
-      let := fresh "HΓ" in
-      let i := fresh "i" in
-      let HAi := fresh "HAi" in
-      pose proof presup_exp H as [ [i HAi]]
- | {{ ^?Γ s ^: ^?Δ }} =>
-      let := fresh "HΓ" in
-      let := fresh "HΔ" in
-      pose proof presup_sub H as [ ]
-  | _ => gen_presup_ctx H
-  end.
+Hint Resolve presup_exp_eq_natrec_sub_left : mcltt.
+ +
+Lemma presup_exp_eq_natrec_sub_right : forall {Γ σ Δ i A MZ MS M},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ , A : Type@i }} ->
+    {{ Δ MZ : A[Id,,zero] }} ->
+    {{ Δ, , A MS : A[WkWk,,succ #1] }} ->
+    {{ Δ M : }} ->
+    {{ Γ rec M[σ] return A[q σ] | zero -> MZ[σ] | succ -> MS[q (q σ)] end : A[σ,,M[σ]] }}.
+Proof.
+  intros.
+  assert {{ Γ }} by mauto 2.
+  assert {{ Δ }} by mauto 2.
+  assert {{ Γ, s q σ : Δ, }} by mauto 2.
+  assert {{ Γ, , A[q σ] s q (q σ) : Δ, , A }} by mauto 2.
+  assert {{ Γ, A[q σ] : Type@i }} by mauto 3.
+  (* Possible lemma? *)
+  assert (forall N, {{ Γ N : }} -> {{ Γ A[q σ][Id,,N] : Type@i }} /\ {{ Γ A[q σ][Id,,N] A[σ,,N] : Type@i }}).
+  {
+    intros.
+    assert {{ Γ N : [σ] }} by mauto 3.
+    assert {{ Γ s Id,,N : Γ, }} by mauto 3.
+    assert {{ Γ s q σ(Id,,N) σ,,N : Δ, }} by mauto 3.
+    assert {{ Γ s σ,,N : Δ, }} by mauto 2.
+    assert {{ Γ A[q σ(Id,,N)] A[σ,,N] : Type@i }} by mauto 3.
+    split; mauto 3.
+  }
+  (* Assertion for M *)
+  assert {{ Γ M[σ] : }} by mauto 3.
+  (* Assertion for type *)
+  assert ({{ Γ A[q σ][Id,,M[σ]] : Type@i }} /\ {{ Γ A[q σ][Id,,M[σ]] A[σ,,M[σ]] : Type@i }}) as [] by mauto 3.
+  (* Assertion for MZ *)
+  assert {{ Δ zero : }} by mauto 2.
+  assert {{ Δ s Id,,zero : Δ, }} by mauto 2.
+  assert {{ Γ zero[σ] zero : }} by mauto 2.
+  assert {{ Γ s σ,,zero[σ] σ,,zero : Δ, }} by mauto 3.
+  assert {{ Γ s (Id,,zero)σ σ,,zero : Δ, }} by mauto 3.
+  assert ({{ Γ A[q σ][Id,,zero] : Type@i }} /\ {{ Γ A[q σ][Id,,zero] A[σ,,zero] : Type@i }}) as [] by mauto 3.
+  assert {{ Γ A[(Id,,zero)σ] A[σ,,zero] : Type@i }} by mauto 3.
+  assert {{ Γ A[q σ][Id,,zero] A[Id,,zero][σ] : Type@i }} by (etransitivity; [| symmetry]; mauto 3).
+  assert {{ Γ MZ[σ] : A[q σ][Id,,zero] }} by mauto 4.
+  (* Assertion for MS *)
+  assert {{ Δ, , A s WkWk,,succ #1 : Δ, }} by mauto 2.
+  assert {{ Γ, , A[q σ] s WkWk,,succ #1 : Γ, }} by mauto 2.
+  assert {{ Γ, , A[q σ] s q σ(WkWk,,succ #1) (WkWk,,succ #1)q (q σ) : Δ, }} by mauto 2.
+  assert {{ Γ, , A[q σ] A[q σ][WkWk,,succ #1] A[WkWk,,succ #1][q (q σ)] : Type@i }} by mauto 2.
+  assert {{ Γ, , A[q σ] MS[q (q σ)] : A[q σ][WkWk,,succ #1] }} by (eapply wf_conv; mauto 2).
+  (* Final *)
+  eapply wf_conv; mauto 3.
+Qed.

-Lemma presup_exp_eq : forall {Γ M M' A}, {{ Γ M M' : A }} -> {{ Γ }} /\ {{ Γ M : A }} /\ {{ Γ M' : A }} /\ exists i, {{ Γ A : Type@i }}
-with presup_sub_eq : forall {Γ Δ σ σ'}, {{ Γ s σ σ' : Δ }} -> {{ Γ }} /\ {{ Γ s σ : Δ }} /\ {{ Γ s σ' : Δ }} /\ {{ Δ }}
-with presup_subtyp : forall {Γ M M'}, {{ Γ M M' }} -> {{ Γ }} /\ exists i, {{ Γ M : Type@i }} /\ {{ Γ M' : Type@i }}.
-Proof with mautosolve 4.
-  1: set (WkWksucc := {{{ WkWk ,, succ #1 }}}).
-  all: inversion_clear 1; (on_all_hyp: gen_presup_IH presup_exp_eq presup_sub_eq presup_subtyp);
-    clear presup_exp_eq presup_sub_eq presup_subtyp;
-    repeat split; mauto 4;
-    try (rename B into C); try (rename B' into C'); try (rename A0 into B); try (rename A' into B');
-    try (rename N into L); try (rename N' into L');
-    try (rename M0 into N); try (rename MZ into NZ); try (rename MS into NS);
-    try (rename M'0 into N'); try (rename MZ' into NZ'); try (rename MS' into NS');
-    try (rename M' into N').
+#[local]
+Hint Resolve presup_exp_eq_natrec_sub_right : mcltt.
+ +
+Lemma presup_exp_eq_beta_succ_right : forall {Γ i A MZ MS M},
+    {{ Γ, A : Type@i }} ->
+    {{ Γ MZ : A[Id,,zero] }} ->
+    {{ Γ, , A MS : A[WkWk,,succ #1] }} ->
+    {{ Γ M : }} ->
+    {{ Γ MS[Id,,M,,rec M return A | zero -> MZ | succ -> MS end] : A[Id,,succ M] }}.
+Proof.
+  intros.
+  set (WkWksucc := {{{ WkWk,,succ #1 }}}).
+  set (recM := {{{ rec M return A | zero -> MZ | succ -> MS end }}}).
+  set (IdMrecM := {{{ Id,,M,,recM }}}).
+  assert {{ Γ }} by mauto 2.
+  (* Assertion for type *)
+  assert {{ Γ : Type@0 }} by mauto 3.
+  assert {{ Γ recM : A[Id,,M] }} by mauto 4.
+  assert {{ Γ, s Wk : Γ }} by mauto 3.
+  assert {{ Γ, , A s Wk : Γ, }} by mauto 3.
+  assert {{ Γ, , A s WkWk : Γ }} by mauto 2.
+  assert {{ Γ s WkWksuccIdMrecM (WkWk)IdMrecM,,(succ #1)[IdMrecM] : Γ, }}
+    by (eapply sub_eq_extend_compose_nat; mauto 3).
+  assert {{ Γ s IdMrecM : Γ, , A }} by mauto 3.
+  assert {{ Γ s (WkWk)IdMrecM : Γ }} by mauto 2.
+  assert {{ Γ s (WkWk)IdMrecM Wk(WkIdMrecM) : Γ }} by mauto 2.
+  assert {{ Γ s Id,,M : Γ, }} by mauto 2.
+  assert {{ Γ s Wk(WkIdMrecM) Wk(Id,,M) : Γ }} by mauto 4.
+  assert {{ Γ s (WkWk)IdMrecM Id : Γ }} by mauto 4.
+  assert {{ Γ #1[IdMrecM] #0[Id,,M] : }} by mauto 3.
+  assert {{ Γ #1[IdMrecM] M : }} by mauto 4.
+  assert {{ Γ succ #1[IdMrecM] succ M : }} by mauto 2.
+  assert {{ Γ (succ #1)[IdMrecM] succ M : }} by mauto 4.
+  assert {{ Γ s (WkWk)IdMrecM,,(succ #1)[IdMrecM] Id,,succ M : Γ , }} by mauto 2.
+  assert {{ Γ s WkWksuccIdMrecM : Γ, }} by mauto 3.
+  assert {{ Γ s Id,,succ M : Γ, }} by mauto 3.
+  assert {{ Γ s WkWksuccIdMrecM Id,,succ M : Γ , }} by mauto 2.
+  assert {{ Γ A[WkWksuccIdMrecM] A[Id,,succ M] : Type@i }} by mauto 2.
+  enough {{ Γ A[WkWksucc][IdMrecM] A[Id,,succ M] : Type@i }}; mauto 4.
+Qed.

-
+#[local]
+Hint Resolve presup_exp_eq_beta_succ_right : mcltt.
+ +
+Lemma presup_exp_eq_fn_cong_right : forall {Γ i A A' j B M'},
+    {{ Γ A : Type@i }} ->
+    {{ Γ A' : Type@i }} ->
+    {{ Γ A A' : Type@i }} ->
+    {{ Γ, A B : Type@j }} ->
+    {{ Γ , A M' : B }} ->
+    {{ Γ λ A' M' : Π A B }}.
+Proof.
+  intros.
+  assert {{ Γ }} by mauto 2.
+  assert {{ Γ A : Type@(max i j) }} by mauto 2 using lift_exp_max_left.
+  assert {{ Γ A A' : Type@(max i j) }} by mauto 2 using lift_exp_eq_max_left.
+  assert {{ Γ, A B : Type@(max i j) }} by mauto 2 using lift_exp_max_right.
+  assert {{ Γ Π A B Π A' B : Type@(max i j) }} by mauto 3.
+  assert {{ Γ, A' M' : B }} by mauto 4.
+  assert {{ Γ Π A B : Type@(max i j) }} by mauto 2.
+  enough {{ Γ λ A' M' : Π A' B }}; mauto 3.
+Qed.
-
-presup_exp_eq cases -
-
-  - assert {{ Γ s Id ,, N Id ,, N' : Γ, }} by mauto 4.
-    assert {{ Γ B[Id ,, N] B[Id ,, N'] : Type@i }} by mauto 3.
-    assert {{ Γ B[Id ,, N] B'[Id ,, N'] : Type@i }} by mauto 4.
-    assert {{ Γ NZ' : B'[Id ,, zero] }} by (eapply wf_conv; mauto 3).
-    assert {{ Γ, , B NS' : B'[WkWksucc] }} by (eapply wf_conv; mauto 3).
-    assert {{ Γ, , B' NS' : B'[WkWksucc] }} by mauto 4.
-    assert {{ Γ rec N' return B' | zero -> NZ' | succ -> NS' end : B'[Id ,, N'] }} by mauto 3.
-    eapply wf_conv...
+
+#[local]
+Hint Resolve presup_exp_eq_fn_cong_right : mcltt.
+ +
+Lemma presup_exp_eq_fn_sub_right : forall {Γ σ Δ i A j B M},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ, A B : Type@j }} ->
+    {{ Δ, A M : B }} ->
+    {{ Γ λ A[σ] M[q σ] : (Π A B)[σ] }}.
+Proof.
+  intros.
+  assert {{ Δ A : Type@(max i j) }} by mauto 2 using lift_exp_max_left.
+  assert {{ Δ, A B : Type@(max i j) }} by mauto 2 using lift_exp_max_right.
+  assert {{ Γ A[σ] : Type@(max i j) }} by mauto 2.
+  assert {{ Γ, A[σ] B[q σ] : Type@(max i j) }} by mauto 3.
+  assert {{ Γ Π A[σ] B[q σ] : Type@(max i j) }} by mauto 2.
+  assert {{ Γ Π A[σ] B[q σ] Π A[σ] B[q σ] : Type@(max i j) }} by mauto 2.
+  assert {{ Γ, A[σ] M[q σ] : B[q σ] }} by mauto 3.
+  assert {{ Γ λ A[σ] M[q σ] : Π A[σ] B[q σ] }} by mauto 3.
+  eapply wf_conv; mauto 3.
+Qed.

-  - assert {{ Γ B[(Id,,N)][σ] B[(Id,,N)σ] : Type@i }} by mauto 3.
-    assert {{ Γ s (Id,,N)σ σ,,N[σ] : Δ, }} by mauto 3.
-    assert {{ Γ B[(Id,,N)σ] B[σ,,N[σ]] : Type@i }} by mauto 4.
-    eapply wf_conv...
+#[local]
+Hint Resolve presup_exp_eq_fn_sub_right : mcltt.
+ +
+Lemma presup_exp_eq_app_cong_right : forall {Γ i A B M' N N'},
+    {{ Γ A : Type@i }} ->
+    {{ Γ , A B : Type@i }} ->
+    {{ Γ M' : Π A B }} ->
+    {{ Γ N : A }} ->
+    {{ Γ N' : A }} ->
+    {{ Γ N N' : A }} ->
+    {{ Γ M' N' : B[Id,,N] }}.
+Proof.
+  intros.
+  assert {{ Γ }} by mauto 2.
+  assert {{ Γ s Id Id : Γ }} by mauto 2.
+  assert {{ Γ A A[Id] : Type@i }} by mauto 3.
+  assert {{ Γ N N' : A[Id] }} by mauto 2.
+  assert {{ Γ s Id,,N Id,,N' : Γ, A }} by mauto 2.
+  assert {{ Γ B[Id,,N] B[Id,,N'] : Type@i }} by mauto 3.
+  eapply wf_conv; mauto 3.
+Qed.

-  - assert {{ Γ s Id,,N[σ] : Γ, }} by mauto 4.
-    assert {{ Γ, s q σ : Δ, }} by mauto 2.
-    assert {{ Γ, B[q σ] : Type@i }} by mauto 2.
-    assert {{ Γ B[q σ][(Id,,N[σ])] B[q σ(Id,,N[σ])] : Type@i }} by mauto 2.
-    assert {{ Γ s q σ(Id,,N[σ]) σ,,N[σ] : Δ, }} by mauto 3.
-    assert {{ Γ B[q σ(Id,,N[σ])] B[σ,,N[σ]] : Type@i }} by mauto 3.
-    assert {{ Γ B[q σ][Id,,N[σ]] B[σ,,N[σ]] : Type@i }} by mauto 3.
-    assert {{ Γ NZ[σ] : B[Id ,, zero][σ] }} by mauto 3.
-    assert {{ Γ [σ] : Type@0 }} by mauto 3.
-    assert {{ Γ zero : [σ] }} by mauto 3.
-    assert {{ Γ s q σ(Id ,, zero) σ ,, zero : Δ, }} by mauto 3.
-    assert {{ Γ s σ Idσ : Δ }} by mauto 3.
-    assert {{ Γ s σ ,, zero Idσ ,, zero[σ] : Δ, }} by mauto 4.
-    assert {{ Γ s Idσ ,, zero[σ] (Id ,, zero)σ : Δ, }} by mauto.
-    assert {{ Γ s Id ,, zero : Γ, }} by mauto 2.
-    assert {{ Γ s q σ(Id ,, zero) (Id ,, zero)σ : Δ, }} by mauto 3.
-    assert {{ Γ B[q σ(Id ,, zero)] B[(Id ,, zero)σ] : Type@i }} by mauto 3.
-    assert {{ Γ B[q σ][Id ,, zero] B[Id ,, zero][σ] : Type@i }} by mauto 3.
-    assert {{ Γ NZ[σ] : B[q σ][Id ,, zero] }} by mauto 4.
-    set (Γ' := {{{ Γ, , B[q σ] }}}).
-    assert {{ Γ' s q (q σ) : Δ, , B }} by mauto 2.
-    assert {{ Γ' s q σWkWksucc WkWksuccq (q σ) : Δ, }} by mauto 2.
-    assert {{ Γ' s WkWksucc : Γ, }} by mauto 2.
-    assert {{ Γ' B[WkWksucc][q (q σ)] B[q σ][WkWksucc] : Type@i }} by mauto 4.
-    assert {{ Γ' NS[q (q σ)] : B[q σ][WkWksucc] }} by mauto 4.
-    eapply wf_conv...
+#[local]
+Hint Resolve presup_exp_eq_app_cong_right : mcltt.
+ +
+Lemma presup_exp_eq_app_sub_left : forall {Γ σ Δ i A B M N},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ , A B : Type@i }} ->
+    {{ Δ M : Π A B }} ->
+    {{ Δ N : A }} ->
+    {{ Γ (M N)[σ] : B[σ,,N[σ]] }}.
+Proof.
+  intros.
+  assert {{ Δ }} by mauto 2.
+  assert {{ Γ, A[σ] s q σ : Δ, A }} by mauto 2.
+  assert {{ Γ M[σ] : (Π A B)[σ] }} by mauto 3.
+  assert {{ Γ Π A[σ] B[q σ] : Type@i }} by mauto 4.
+  assert {{ Γ M[σ] : Π A[σ] B[q σ] }} by mauto 3.
+  assert {{ Δ N : A[Id] }} by mauto 2.
+  assert {{ Γ s (Id,,N)σ Idσ,,N[σ] : Δ, A }} by mauto 3.
+  assert {{ Γ s (Id,,N)σ σ,,N[σ] : Δ, A }} by mauto 3.
+  assert {{ Δ s Id,,N : Δ, A }} by mauto 3.
+  assert {{ Γ s (Id,,N)σ : Δ, A }} by mauto 3.
+  assert {{ Γ B[(Id,,N)σ] B[σ,,N[σ]] : Type@i }} by mauto 2.
+  assert {{ Γ s σ,,N[σ] : Δ, A }} by mauto 3.
+  assert {{ Γ B[σ,,N[σ]] : Type@i }} by mauto 2.
+  assert {{ Γ B[Id,,N][σ] B[σ,,N[σ]] : Type@i }} by mauto 3.
+  eapply wf_conv; mauto 3.
+Qed.

-  - eexists...
+#[local]
+Hint Resolve presup_exp_eq_app_sub_left : mcltt.
+ +
+Lemma presup_exp_eq_app_sub_right : forall {Γ σ Δ i A B M N},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ , A B : Type@i }} ->
+    {{ Δ M : Π A B }} ->
+    {{ Δ N : A }} ->
+    {{ Γ M[σ] N[σ] : B[σ,,N[σ]] }}.
+Proof.
+  intros.
+  assert {{ Γ A[σ] : Type@i }} by mauto 3.
+  assert {{ Γ, A[σ] s q σ : Δ, A }} by mauto 2.
+  assert {{ Γ, A[σ] B[q σ] : Type@i }} by mauto 2.
+  assert {{ Γ M[σ] : Π A[σ] B[q σ] }} by (eapply wf_conv; mauto 2).
+  assert {{ Γ N[σ] : A[σ] }} by mauto 2.
+  assert {{ Γ s q σ(Id,,N[σ]) σ,,N[σ] : Δ, A }} by mauto 2.
+  assert {{ Γ s Id,,N[σ] : Γ, A[σ] }} by mauto 2.
+  assert {{ Γ s q σ(Id,,N[σ]) : Δ, A }} by mauto 2.
+  assert {{ Γ B[q σ(Id,,N[σ])] B[σ,,N[σ]] : Type@i }} by mauto 2.
+  assert {{ Γ B[q σ][Id,,N[σ]] : Type@i }} by mauto 2.
+  assert {{ Γ B[q σ][Id,,N[σ]] B[σ,,N[σ]] : Type@i }} by mauto 3.
+  eapply wf_conv; mauto 3.
+Qed.

-  - set (recN := {{{ rec N return B | zero -> NZ | succ -> NS end }}}).
-    set (IdNrecN := {{{ Id ,, N ,, recN }}}).
-    assert {{ Γ : Type@0 }} by mauto 3.
-    assert {{ Γ recN : B[Id ,, N] }} by mauto 4.
-    assert {{ Γ, s Wk : Γ }} by mauto 2.
-    assert {{ Γ, , B s Wk : Γ, }} by mauto 2.
-    assert {{ Γ, , B s WkWk : Γ }} by mauto 2.
-    assert {{ Γ s WkWksuccIdNrecN (WkWk)IdNrecN ,, (succ #1)[IdNrecN] : Γ, }}
-      by (eapply sub_eq_extend_compose_nat; mauto 3).
-    assert {{ Γ s IdNrecN : Γ, , B }} by mauto 3.
-    assert {{ Γ s (WkWk)IdNrecN : Γ }} by mauto 2.
-    assert {{ Γ s (WkWk)IdNrecN Wk(WkIdNrecN) : Γ }} by mauto 2.
-    assert {{ Γ s Id,,N : Γ, }} by mauto 2.
-    assert {{ Γ s Wk(WkIdNrecN) Wk(Id,,N) : Γ }} by mauto 4.
-    assert {{ Γ s (WkWk)IdNrecN Id : Γ }} by mauto 4.
-    assert {{ Γ #1[IdNrecN] #0[Id ,, N] : }} by mauto 3.
-    assert {{ Γ #1[IdNrecN] N : }} by mauto 4.
-    assert {{ Γ succ #1[IdNrecN] succ N : }} by mauto 2.
-    assert {{ Γ (succ #1)[IdNrecN] succ N : }} by mauto 4.
-    assert {{ Γ s (WkWk)IdNrecN ,, (succ #1)[IdNrecN] Id ,, succ N : Γ , }} by mauto 2.
-    assert {{ Γ s WkWksuccIdNrecN : Γ, }} by mauto 3.
-    assert {{ Γ s Id,,succ N : Γ, }} by mauto 3.
-    assert {{ Γ s WkWksuccIdNrecN Id ,, succ N : Γ , }} by mauto 2.
-    assert {{ Γ B[WkWksuccIdNrecN] B[Id,,succ N] : Type@i }} by mauto 2.
-    enough {{ Γ B[WkWksucc][IdNrecN] B[Id,,succ N] : Type@i }}...
+#[local]
+Hint Resolve presup_exp_eq_app_sub_right : mcltt.
+ +
+Lemma presup_exp_eq_pi_eta_right : forall {Γ i A B M},
+    {{ Γ A : Type@i }} ->
+    {{ Γ , A B : Type@i }} ->
+    {{ Γ M : Π A B }} ->
+    {{ Γ λ A (M[Wk] #0) : Π A B }}.
+Proof.
+  intros.
+  assert {{ Γ, A s Wk : Γ }} by mauto 3.
+  assert {{ Γ, A, A[Wk] s q Wk : Γ, A }} by mauto 3.
+  assert {{ Γ, A A[Wk] : Type@i }} by mauto 2.
+  assert {{ Γ, A, A[Wk] B[q Wk] : Type@i }} by mauto 3.
+  assert {{ Γ, A M[Wk] : Π A[Wk] B[q Wk] }} by (eapply wf_conv; mauto 3).
+  assert {{ Γ, A #0 : A[Wk] }} by mauto 3.
+  assert {{ Γ, A s q Wk(Id,,#0) Id : Γ, A }} by mauto 4.
+  assert {{ Γ, A s Id,,#0 : Γ, A, A[Wk] }} by mauto 2.
+  assert {{ Γ, A B[q Wk][Id,,#0] B[Id] : Type@i }} by (transitivity {{{ B[q Wk(Id,,#0)] }}}; mauto 3).
+  econstructor; mauto 3.
+  eapply wf_conv; mauto 3.
+Qed.

-  - eexists...
+#[local]
+Hint Resolve presup_exp_eq_pi_eta_right : mcltt.
+ +
+Lemma presup_exp_eq_prop_eq_var0 : forall {Γ i A},
+  {{ Γ A : Type@i }} ->
+  {{ Γ, A, A[Wk] #0 : A[WkWk] }}.
+Proof.
+  intros.
+  assert {{ Γ, A }} by mauto 3.
+  assert {{ Γ, A s Wk : Γ }} by mauto 2.
+  assert {{ Γ, A, A[Wk] }} by mauto 3.
+  mauto 3.
+Qed.

-  - mauto.
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_var0 : mcltt.

-  - mauto.
+Lemma presup_exp_eq_prop_eq_var1 : forall {Γ i A},
+  {{ Γ A : Type@i }} ->
+  {{ Γ, A, A[Wk] #1 : A[WkWk] }}.
+Proof.
+  intros.
+  assert {{ Γ, A }} by mauto 3.
+  assert {{ Γ, A s Wk : Γ }} by mauto 2.
+  assert {{ Γ, A, A[Wk] }} by mauto 3.
+  mauto 4.
+Qed.

-  - assert {{ Γ B : Type@(max i i0) }} by mauto 2 using lift_exp_max_left.
-    assert {{ Γ B B' : Type@(max i i0) }} by mauto 2 using lift_exp_eq_max_left.
-    assert {{ Γ, B C : Type@(max i i0) }} by mauto 2 using lift_exp_max_right.
-    assert {{ Γ Π B C Π B' C : Type@(max i i0) }} by mauto 3.
-    assert {{ Γ, B' N' : C }} by mauto 4.
-    enough {{ Γ λ B' N' : Π B' C }}...
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_var1 : mcltt.

-  - assert {{ Γ B : Type@(max i i0) }} by mauto 2 using lift_exp_max_left.
-    assert {{ Γ, B C : Type@(max i i0) }} by mauto 2 using lift_exp_max_right...
+Lemma presup_exp_eq_prop_eq_wf : forall {Γ i A},
+  {{ Γ A : Type@i }} ->
+  {{ Γ, A, A[Wk] Eq A[WkWk] #1 #0 : Type@i }}.
+Proof.
+  intros.
+  assert {{ Γ, A }} by mauto 3.
+  assert {{ Γ, A s Wk : Γ }} by mauto 2.
+  assert {{ Γ, A, A[Wk] }} by mauto 3.
+  assert {{ Γ, A, A[Wk] s WkWk : Γ }} by mauto 3.
+  assert {{ Γ, A, A[Wk] A[WkWk] : Type@i }} by mauto 3.
+  mauto 4.
+Qed.

-  - assert {{ Δ B : Type@(max i i0) }} by mauto 2 using lift_exp_max_left.
-    assert {{ Δ, B C : Type@(max i i0) }} by mauto 2 using lift_exp_max_right.
-    assert {{ Γ B[σ] : Type@(max i i0) }} by mauto 2.
-    assert {{ Γ, B[σ] C[q σ] : Type@(max i i0) }} by mauto 3.
-    assert {{ Γ Π B[σ] C[q σ] : Type@(max i i0) }} by mauto 2.
-    assert {{ Γ Π B[σ] C[q σ] Π B[σ] C[q σ] : Type@(max i i0) }} by mauto 2.
-    assert {{ Γ, B[σ] N[q σ] : C[q σ] }} by mauto 3.
-    assert {{ Γ λ B[σ] N[q σ] : Π B[σ] C[q σ] }} by mauto 3.
-    eapply wf_conv...
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_wf : mcltt.
+ +
+Lemma presup_exp_eq_prop_eq_sub_helper2 : forall {Γ σ Δ i A M1 M2},
+  {{ Γ s σ : Δ }} ->
+  {{ Δ A : Type@i }} ->
+  {{ Δ M1 : A }} ->
+  {{ Δ M2 : A }} ->
+  {{ Γ s σ,,M1[σ],,M2[σ] : Δ, A, A[Wk] }}.
+Proof.
+  intros.
+  assert {{ Δ, A }} by mauto 3.
+  assert {{ Δ, A s Wk : Δ }} by mauto 2.
+  assert {{ Γ s σ,,M1[σ] : Δ, A }} by mauto 3.
+  assert {{ Γ A[Wk][σ,,M1[σ]] A[σ] : Type@i }} by mauto 3.
+  assert {{ Γ M2[σ] : A[σ] }} by mauto 2.
+  assert {{ Γ A[Wk][σ,,M1[σ]] : Type@i }} by mauto 3.
+  assert {{ Γ M2[σ] : A[Wk][σ,,M1[σ]] }} by mauto 3.
+  mauto 4.
+Qed.

-  - assert {{ Δ B : Type@(max i i0) }} by mauto 2 using lift_exp_max_left.
-    assert {{ Δ, B C : Type@(max i i0) }} by mauto 2 using lift_exp_max_right.
-    enough {{ Δ Π B C : Type@(max i i0) }}...
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_sub_helper2 : mcltt.
+ +
+Lemma presup_exp_eq_prop_eq_typ_sub2_eq : forall {Γ σ Δ i A M1 M2},
+  {{ Γ s σ : Δ }} ->
+  {{ Δ A : Type@i }} ->
+  {{ Δ M1 : A }} ->
+  {{ Δ M2 : A }} ->
+  {{ Γ (Eq A[WkWk] #1 #0)[σ,,M1[σ],,M2[σ]] (Eq A M1 M2)[σ] : Type@i }}.
+Proof.
+  intros.
+  assert {{ Δ, A }} by mauto 3.
+  assert {{ Δ, A s Wk : Δ }} by mauto 2.
+  assert {{ Γ M1[σ] : A[σ] }} by mauto 2.
+  assert {{ Γ s σ,,M1[σ] : Δ, A }} by mauto 2.
+  assert {{ Δ, A A[Wk] : Type@i }} by mauto 2.
+  assert {{ Γ A[Wk][σ,,M1[σ]] : Type@i }} by mauto 3.
+  assert {{ Γ A[Wk][σ,,M1[σ]] A[σ] : Type@i }} by mauto 2.
+  assert {{ Γ M2[σ] : A[σ] }} by mauto 2.
+  assert {{ Γ M2[σ] : A[Wk][σ,,M1[σ]] }} by mauto 3.
+  assert {{ Γ s σ,,M1[σ],,M2[σ] : Δ, A, A[Wk] }} by mauto 2.
+  assert {{ Δ, A, A[Wk] s WkWk : Δ }} by mauto 4.
+  assert {{ Δ, A, A[Wk] A[WkWk] : Type@i }} by mauto 2.
+  assert {{ Γ A[WkWk][σ,,M1[σ],,M2[σ]] : Type@i }} by mauto 2.
+  enough {{ Γ Eq A[WkWk][σ,,M1[σ],,M2[σ]] #1[σ,,M1[σ],,M2[σ]] #0[σ,,M1[σ],,M2[σ]] Eq A[σ] M1[σ] M2[σ] : Type@i }}
+    by (etransitivity; [| etransitivity]; [| eassumption |]; econstructor; mauto 2).
+  assert {{ Γ A[σ] : Type@i }} by mauto 2.
+  econstructor; mauto 2; eapply wf_exp_eq_conv; mauto 4 using sub_lookup_var0, sub_lookup_var1.
+Qed.

-  - assert {{ Γ s Id Id : Γ }} by mauto 2.
-    assert {{ Γ B B[Id] : Type@i }} by mauto 3.
-    assert {{ Γ L L' : B[Id] }} by mauto 4.
-    assert {{ Γ s Id ,, L Id ,, L' : Γ, B }} by mauto 2.
-    assert {{ Γ C[Id ,, L] C[Id ,, L'] : Type@i }} by mauto 3.
-    eapply wf_conv...
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_typ_sub2_eq : mcltt.
+ +
+Lemma presup_exp_eq_prop_eq_sub_helper3 : forall {Γ σ Δ i A M1 M2 N},
+  {{ Γ s σ : Δ }} ->
+  {{ Δ A : Type@i }} ->
+  {{ Δ M1 : A }} ->
+  {{ Δ M2 : A }} ->
+  {{ Δ N : Eq A M1 M2 }} ->
+  {{ Γ s σ,,M1[σ],,M2[σ],,N[σ] : Δ, A, A[Wk], Eq A[WkWk] #1 #0 }}.
+Proof.
+  intros.
+  assert {{ Γ s σ,,M1[σ],,M2[σ] : Δ, A, A[Wk] }} by mauto 3.
+  assert {{ Δ, A, A[Wk] Eq A[WkWk] #1 #0 : Type@i }} by mauto 2.
+  assert {{ Γ (Eq A[WkWk] #1 #0)[σ,,M1[σ],,M2[σ]] : Type@i }} by mauto 2.
+  assert {{ Γ N[σ] : (Eq A[WkWk] #1 #0)[σ,,M1[σ],,M2[σ]] }} by (eapply wf_conv; mauto 3).
+  mauto 3.
+Qed.

-  - assert {{ Γ N[σ] : Π B[σ] C[q σ] }} by (eapply wf_conv; mauto).
-    assert {{ Δ L : B[Id] }} by mauto 4.
-    assert {{ Γ s (Id ,, L)σ Idσ ,, L[σ] : Δ, B }} by mauto 3.
-    assert {{ Γ s (Id ,, L)σ σ ,, L[σ] : Δ, B }} by mauto 3.
-    assert {{ Δ s Id ,, L : Δ, B }} by mauto 3.
-    assert {{ Γ s (Id ,, L)σ : Δ, B }} by mauto 3.
-    assert {{ Γ C[(Id ,, L)σ] C[σ ,, L[σ]] : Type@i }} by mauto 2.
-    assert {{ Γ C[Id ,, L][σ] C[σ ,, L[σ]] : Type@i }} by mauto 3.
-    eapply wf_conv...
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_sub_helper3 : mcltt.
+ +
+Lemma presup_exp_eq_prop_eq_id_sub_helper2 : forall {Γ i A M1 M2},
+  {{ Γ A : Type@i }} ->
+  {{ Γ M1 : A }} ->
+  {{ Γ M2 : A }} ->
+  {{ Γ s Id,,M1,,M2 : Γ, A, A[Wk] }}.
+Proof.
+  intros.
+  assert {{ Γ }} by mauto 2.
+  assert {{ Γ s Id : Γ }} by mauto 2.
+  assert {{ Γ s Id,,M1 : Γ, A }} by mauto 2.
+  assert {{ Γ, A }} by mauto 3.
+  assert {{ Γ, A A[Wk] : Type@i }} by mauto 3.
+  assert {{ Γ A[Wk][Id,,M1] : Type@i }} by mauto 2.
+  assert {{ Γ A[Wk][Id,,M1] A : Type@i }} by mauto 2.
+  assert {{ Γ M2 : A[Wk][Id,,M1] }} by mauto 3.
+  mauto 2.
+Qed.

-  - assert {{ Γ B[σ] : Type@i }} by mauto 2.
-    assert {{ Γ, B[σ] s q σ : Δ, B }} by mauto 2.
-    assert {{ Γ, B[σ] C[q σ] : Type@i }} by mauto 2.
-    assert {{ Γ N[σ] : Π B[σ] C[q σ] }} by (eapply wf_conv; mauto 2).
-    assert {{ Γ L[σ] : B[σ] }} by mauto 2.
-    assert {{ Γ s q σ(Id ,, L[σ]) σ ,, L[σ] : Δ, B }} by mauto 2.
-    assert {{ Γ s Id ,, L[σ] : Γ, B[σ] }} by mauto 2.
-    assert {{ Γ s q σ(Id ,, L[σ]) : Δ, B }} by mauto 2.
-    assert {{ Γ C[q σ(Id ,, L[σ])] C[σ ,, L[σ]] : Type@i }} by mauto 2.
-    assert {{ Γ C[q σ][(Id ,, L[σ])] C[σ ,, L[σ]] : Type@i }} by mauto 3.
-    eapply wf_conv...
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_id_sub_helper2 : mcltt.
+ +
+Lemma presup_exp_eq_prop_eq_typ_id_sub2_eq : forall {Γ i A M1 M2},
+  {{ Γ A : Type@i }} ->
+  {{ Γ M1 : A }} ->
+  {{ Γ M2 : A }} ->
+  {{ Γ (Eq A[WkWk] #1 #0)[Id,,M1,,M2] Eq A M1 M2 : Type@i }}.
+Proof.
+  intros.
+  assert {{ Γ, A }} by mauto 3.
+  assert {{ Γ, A s Wk : Γ }} by mauto 2.
+  assert {{ Γ s Id,,M1 : Γ, A }} by mauto 2.
+  assert {{ Γ, A A[Wk] : Type@i }} by mauto 2.
+  assert {{ Γ A[Wk][Id,,M1] : Type@i }} by mauto 3.
+  assert {{ Γ A[Wk][Id,,M1] A : Type@i }} by mauto 2.
+  assert {{ Γ M2 : A[Wk][Id,,M1] }} by mauto 3.
+  assert {{ Γ s Id,,M1,,M2 : Γ, A, A[Wk] }} by mauto 2.
+  assert {{ Γ, A, A[Wk] s WkWk : Γ }} by mauto 4.
+  assert {{ Γ, A, A[Wk] A[WkWk] : Type@i }} by mauto 2.
+  assert {{ Γ A[WkWk][Id,,M1,,M2] : Type@i }} by mauto 2.
+  transitivity {{{ Eq A[WkWk][Id,,M1,,M2] #1[Id,,M1,,M2] #0[Id,,M1,,M2] }}}; [econstructor; mautosolve 2 |].
+  econstructor; mauto 2; eapply wf_exp_eq_conv; mauto 4 using id_sub_lookup_var0, id_sub_lookup_var1.
+Qed.

-  - eexists...
- -
-  - set (Id0 := {{{ Id ,, #0 }}}).
-    assert {{ Γ, B s Wk : Γ }} by mauto 2.
-    assert {{ Γ, B B[Wk] : Type@i }} by mauto 2.
-    assert {{ Γ, B, B[Wk] s Wk : Γ, B }} by mauto 3.
-    assert {{ Γ, B, B[Wk] s q Wk : Γ, B }} by mauto 2.
-    assert {{ Γ, B, B[Wk] C[q Wk] : Type@i }} by mauto 2.
-    assert {{ Γ, B M[Wk] : (Π B C)[Wk] }} by mauto 2.
-    assert {{ Γ, B M[Wk] : Π B[Wk] C[q Wk] }} by mauto 4.
-    assert {{ Γ, B #0 : B[Wk] }} by mauto 2.
-    assert {{ Γ, B s Id0 : Γ, B, B[Wk] }} by mauto 2.
-    assert {{ Γ, B M[Wk] #0 : C[q Wk][Id0] }} by mauto 2.
-    assert {{ Γ, B M[Wk] #0 : C[q Wk Id0] }} by (eapply wf_conv; mauto 3).
-    assert {{ Γ, B B[Wk][Id] B[Wk] : Type@i }} by mauto 2.
-    assert {{ Γ, B #0 : B[Wk][Id] }} by mauto 2.
-    assert {{ Γ, B, B[Wk] s WkWk : Γ }} by mauto 2.
-    assert {{ Γ, B s (WkWk)Id0 : Γ }} by mauto 2.
-    assert {{ Γ, B s Id WkId0 : Γ, B }} by mauto 3.
-    assert {{ Γ, B s WkId Wk(WkId0) : Γ }} by mauto 3.
-    assert {{ Γ, B s WkId (WkWk)Id0 : Γ }} by mauto 4.
-    assert {{ Γ, B, B[Wk] #0 : B[Wk][Wk] }} by mauto 3.
-    assert {{ Γ, B, B[Wk] #0 : B[WkWk] }} by (eapply wf_conv; mauto 3).
-    assert {{ Γ, B s q Wk Id0 (WkWk)Id0 ,, #0[Id0] : Γ, B }} by mauto 3.
-    assert {{ Γ, B s (WkWk)Id0 Wk(WkId0) : Γ }} by mauto 2.
-    assert {{ Γ, B s (WkWk)Id0 WkId : Γ }} by mauto 2.
-    assert {{ Γ, B #0[Id0] #0 : B[Wk][Id] }} by mauto 3.
-    assert {{ Γ, B #0 #0[Id] : B[Wk][Id] }} by mauto 3.
-    assert {{ Γ, B #0[Id0] #0[Id] : B[Wk][Id] }} by mauto 2.
-    assert {{ Γ, B #0[Id0] #0[Id] : B[WkId] }} by (eapply wf_exp_eq_conv; mauto 4).
-    assert {{ Γ, B B[WkId] B[(WkWk)Id0] : Type@i }} by mauto 3.
-    assert {{ Γ, B #0[Id0] #0[Id] : B[(WkWk)Id0] }} by mauto 3.
-    assert {{ Γ, B s (WkWk)Id0 ,, #0[Id0] WkId ,, #0[Id] : Γ, B }} by mauto 2.
-    assert {{ Γ, B s WkId ,, #0[Id] Id : Γ, B }} by mauto 4.
-    assert {{ Γ, B s q Wk Id0 Id : Γ, B }} by mauto 3.
-    assert {{ Γ, B C[q Wk Id0] C[Id] : Type@i }} by mauto 3.
-    enough {{ Γ, B M[Wk] #0 : C }}...
- -
-  - econstructor...
-  - eapply wf_conv...
-  - assert {{ Γ s σ ,, M1[σ] : Δ, B}} by mauto.
-    assert {{ Δ , B B[Wk] : Type@i }} by mauto 4.
-    assert {{ Δ , B , B[Wk] B[Wk][Wk] : Type@i }} by mauto 4.
-    assert {{ Γ B[Wk][σ ,, M1[σ]] : Type@i}} by mauto.
-    assert {{ Γ B[Wk][σ ,, M1[σ]] B[σ] : Type@i}}.
-    {
-      transitivity {{{B[Wk (σ,,M1[σ])]}}};
-        [mauto | eapply exp_eq_sub_cong_typ2'; mauto].
-    }
-    assert {{ Γ M2[σ] : B[Wk][σ ,, M1[σ]]}}.
-    {
-      eapply wf_conv with (A:={{{B[σ]}}});
-        mauto 2.
-    }
-    assert {{ Γ s σ ,, M1[σ] ,, M2[σ] : Δ, B, B[Wk]}} by mauto 4.
-    assert {{ Δ, B, B[Wk] Eq (B[Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 4).
- -
-    assert {{Γ B[Wk][Wk][σ,,M1[σ],,M2[σ]] B[σ] : Type@i}}.
-    {
-      transitivity {{{B[Wk][Wk (σ,,M1[σ],,M2[σ])]}}};
-        [mauto 4 | transitivity {{{B[Wk][σ,,M1[σ]]}}}];
-        [| transitivity {{{B[Wk (σ,,M1[σ])]}}};
-           [mauto 4 | ]];
-        eapply exp_eq_sub_cong_typ2';
-        mauto 4.
-    }
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_typ_id_sub2_eq : mcltt.
+
-    eapply wf_conv;
-      [econstructor | |]; mauto 3.
-    + eapply exp_sub_typ; try eassumption.
-      econstructor; mauto 2.
-      eapply wf_conv; mauto 2.
-      transitivity {{{Eq (B[σ]) (M1[σ]) (M2[σ])}}};
-        [mauto 4 | symmetry].
-      etransitivity;
-        [econstructor; mauto |].
- -
-      econstructor; eauto.
-      * eapply wf_exp_eq_conv; mauto 4 using sub_lookup_var1.
-      * eapply wf_exp_eq_conv;
-          [eapply sub_lookup_var0 with (B:=B)| |];
-          mauto 4.
- -
-    + assert {{ Δ s Id ,, M1 : Δ, B}} by mauto 4.
-      assert {{ Δ , B B[Wk] : Type@i }} by mauto 4.
-      assert {{ Δ , B , B[Wk] B[Wk][Wk] : Type@i }} by mauto 4.
-      assert {{ Δ B[Wk][Id,,M1] B : Type@i }}.
-      {
-        transitivity {{{B[Wk (Id,,M1)]}}};
-          [| transitivity {{{B[Id]}}}];
-          mauto 3.
-        eapply exp_eq_sub_cong_typ2'; mauto 3.
-      }
-      assert {{ Δ s Id ,, M1 ,, M2 : Δ, B , B[Wk]}}.
-      {
-        econstructor; mauto 3.
-        eapply wf_conv; mauto 2.
-      }
-      assert {{ Δ B[Wk][Wk][Id ,, M1 ,, M2] B : Type@i }}.
-      {
-        transitivity {{{B[Wk][Wk (Id ,, M1 ,, M2)]}}};
-          [| transitivity {{{B[Wk][Id ,, M1]}}}];
-          mauto 4.
-        eapply exp_eq_sub_cong_typ2'; mauto 4.
-        eapply wf_sub_eq_p_extend; mauto 4.
-      }
-      assert {{ Δ L : (Eq (B[Wk][Wk]) #1 #0) [ Id ,, M1 ,, M2]}}.
-      {
-        eapply wf_conv; mauto 2.
-        symmetry.
-        etransitivity.
-        - eapply wf_exp_eq_eq_sub; mauto.
-        - econstructor; mauto 3.
-          + eapply wf_exp_eq_conv;
-              [eapply id_sub_lookup_var1 with (B:=B) | |];
-              mauto 4.
-          + eapply wf_exp_eq_conv;
-              [eapply id_sub_lookup_var0 with (B:=B) | |];
-              mauto 4.
-      }
-      assert {{ Δ s Id ,, M1 ,, M2 ,, L : Δ, B , B[Wk], Eq (B[Wk][Wk]) #1 #0}} by mauto 4.
- -
-      transitivity {{{ C[(Id,,M1,,M2,,L) σ ] }}};
-        [eapply exp_eq_sub_compose_typ | eapply exp_eq_sub_cong_typ2'];
-        mauto 3.
+Lemma presup_exp_eq_prop_eq_id_sub_helper3 : forall {Γ i A M1 M2 N},
+  {{ Γ A : Type@i }} ->
+  {{ Γ M1 : A }} ->
+  {{ Γ M2 : A }} ->
+  {{ Γ N : Eq A M1 M2 }} ->
+  {{ Γ s Id,,M1,,M2,,N : Γ, A, A[Wk], Eq A[WkWk] #1 #0 }}.
+Proof.
+  intros.
+  assert {{ Γ s Id,,M1,,M2 : Γ, A, A[Wk] }} by mauto 3.
+  assert {{ Γ, A, A[Wk] Eq A[WkWk] #1 #0 : Type@i }} by mauto 2.
+  assert {{ Γ (Eq A[WkWk] #1 #0)[Id,,M1,,M2] : Type@i }} by mauto 2.
+  assert {{ Γ N : (Eq A[WkWk] #1 #0)[Id,,M1,,M2] }} by (eapply wf_conv; mauto 3).
+  mauto 3.
+Qed.

-      transitivity {{{(Id,,M1,,M2) σ ,, L[σ]}}};
-        [econstructor; mauto 3 |].
-      econstructor; mauto 3.
-      * transitivity {{{(Id,,M1) σ ,, M2[σ]}}}.
-        econstructor; mauto 4.
-        econstructor; mauto 3.
-        eapply exp_eq_refl.
-        eapply wf_conv; mauto 3.
-        eapply exp_eq_sub_cong_typ2'; mauto 3.
-      * eapply exp_eq_refl.
-        eapply wf_conv; mauto 3.
- -
-  - assert {{ Δ s Id ,, M1 : Δ, B}} by mauto 4.
-    assert {{ Δ , B B[Wk] : Type@i }} by mauto 4.
-    assert {{ Δ , B , B[Wk] B[Wk][Wk] : Type@i }} by mauto 4.
-    assert {{ Γ B[Wk][σ ,, M1[σ]] : Type@i}} by mauto.
-    assert {{ Γ B[σ] : Type @ i }} by mauto 3.
-    assert {{ Γ M1[σ] : B[σ] }} by mauto 3.
-    assert {{ Γ M2[σ] : B[σ] }} by mauto 3.
-    assert {{ Γ B[Wk][σ ,, M1[σ]] B[σ] : Type@i}}.
-    {
-      transitivity {{{B[Wk (σ,,M1[σ])]}}};
-        [| eapply exp_eq_sub_cong_typ2']; mauto 4.
-    }
-    assert {{ Γ M2[σ] : B[Wk][σ ,, M1[σ]]}} by mauto 3.
-    assert {{ Γ s σ,, M1[σ] : Δ,B}} by mauto 3.
-    assert {{ Γ s σ ,, M1[σ] ,, M2[σ] : Δ, B, B[Wk]}} by mauto 3.
-    assert {{ Δ, B, B[Wk] Eq (B[Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 4).
- -
-    assert {{Γ B[Wk][Wk][σ,,M1[σ],,M2[σ]] B[σ] : Type@i}}.
-    {
-      transitivity {{{B[Wk][Wk (σ,,M1[σ],,M2[σ])]}}};
-        [mauto 4 | transitivity {{{B[Wk][σ,,M1[σ]]}}}];
-        mauto 2.
-      eapply exp_eq_sub_cong_typ2';
-        mauto 4.
-    }
-    assert {{ Γ L[σ] : (Eq B M1 M2)[σ] }} by mauto 3.
-    assert {{ Γ L[σ] : Eq (B[σ]) (M1[σ]) (M2[σ]) }} by (eapply wf_conv; mauto 3).
-    assert {{ Γ #1[σ,,M1[σ],,M2[σ]] M1[σ] : B[Wk][Wk][σ,,M1[σ],,M2[σ]] }}.
-    {
-      eapply wf_exp_eq_conv;
-        [eapply sub_lookup_var1 with (B:=B) | |];
-        mauto 4.
-    }
-    assert {{ Γ #0[σ,,M1[σ],,M2[σ]] M2[σ] : B[Wk][Wk][σ,,M1[σ],,M2[σ]] }}.
-    {
-      eapply wf_exp_eq_conv;
-        [eapply sub_lookup_var0 with (B:=B) | |];
-        mauto 4.
-    }
-    assert {{ Γ L[σ] : (Eq (B[Wk][Wk]) #1 #0)[σ,,M1[σ],,M2[σ]] }}.
-    {
-      eapply wf_conv; mauto 2.
-      symmetry.
-      etransitivity.
-      - eapply wf_exp_eq_eq_sub; mauto.
-      - econstructor; mauto 3.
-    }
-    assert {{ Γ s σ,,M1[σ],,M2[σ],,L[σ] : Δ,B,B[Wk],Eq (B[Wk][Wk]) #1 #0}} by mauto 3.
-    assert {{Γ, B[σ] s q σ : Δ, B}} by mauto 4.
-    assert {{Γ, B[σ] B[σ][Wk] : Type@i}} by mauto 4.
-    assert {{Γ, B[σ], B[σ][Wk] B[σ][Wk][Wk] : Type@i}} by mauto.
-    assert {{Γ, B[σ], B[σ][Wk] Eq (B[σ][Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 3; mauto).
-    assert {{Γ, B[σ] B[Wk][q σ] B[σ][Wk] : Type@i}}.
-    {
-      transitivity {{{B[Wk q σ]}}};
-        [mauto 3 | transitivity {{{B[σ Wk]}}}];
-        [eapply exp_eq_sub_cong_typ2'; mauto 3 | mauto].
-    }
-    assert {{ Γ, B[σ], B[Wk][q σ] Γ, B[σ], B[σ][Wk]}} by (econstructor; mauto 3).
-    assert {{Γ, B[σ], B[σ][Wk] s q (q σ) : Δ, B, B[Wk]}}.
-    {
-      eapply ctxeq_sub; [| eapply sub_q]; mauto 2.
-    }
-    assert {{Γ, B[σ],B[σ][Wk] B[Wk][q σ Wk] : Type@i}} by mauto.
-    assert {{Γ, B[σ],B[σ][Wk] B[Wk][q σ Wk] B[σ][Wk][Wk] : Type@i}}.
-    {
-      transitivity {{{B[Wk][q σ][Wk]}}};
-        [mauto |].
-      eapply exp_eq_sub_cong_typ1; mauto 3.
-    }
-    assert {{Γ, B[σ],B[σ][Wk] B[Wk][Wk][q (q σ)] B[σ][Wk][Wk] : Type@i}}.
-    {
-      transitivity {{{B[Wk][Wk q (q σ)]}}};
-        [mauto 4| transitivity {{{B[Wk][q σ Wk]}}}];
-        [eapply exp_eq_sub_cong_typ2'; mauto 4 | trivial].
-    }
-    assert {{Γ, B[σ], B[σ][Wk] #1 : B[σ][Wk][Wk]}} by mauto.
-    assert {{Γ, B[σ], B[σ][Wk] Eq (B[σ][Wk][Wk]) #0 #0 : Type@i}} by (econstructor; mauto 3).
-    assert {{Γ, B[σ], B[σ][Wk] (Eq (B[Wk][Wk]) #1 #0)[q (q σ)] Eq (B[σ][Wk][Wk]) #1 #0 : Type@i}}.
-    {
-      transitivity {{{Eq (B[Wk][Wk][q (q σ)]) (#1[q (q σ)]) (#0[q (q σ)])}}};
-        [econstructor; mauto 4 |].
-      econstructor; mauto 2.
-      - eapply wf_exp_eq_conv;
-          [eapply ctxeq_exp_eq;[eassumption | eapply exp_eq_var_1_sub_q_sigma] | |];
-          mauto 2.
-      - eapply wf_exp_eq_conv.
-        econstructor; [mauto 4 | eauto | eapply wf_conv; mauto].
-        + mauto 2.
-        + mauto 4.
-    }
-    assert {{Γ, B[σ], B[σ][Wk], Eq (B[σ][Wk][Wk]) #1 #0 s q (q (q σ)) : Δ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0}}.
-    {
-      eapply ctxeq_sub; [| eapply sub_q]; mauto 2.
-      econstructor; mauto 3.
-    }
-    assert {{Γ, B[σ] s Id,,#0 : Γ, B[σ], B[σ][Wk]}} by mauto 4.
-    assert {{Γ, B[σ] B[σ][Wk][Wk][Id,,#0] B[σ][Wk] : Type@i}}.
-    {
-      transitivity {{{B[σ][Wk][Wk (Id,,#0)]}}};
-        [mauto 4 |].
-      transitivity {{{B[σ][Wk][Id]}}};
-        [| mauto 3].
-      eapply exp_eq_sub_cong_typ2'; mauto 4.
-    }
-
-    assert {{Γ, B[σ] s Id,,#0,,refl (B[σ][Wk]) #0 : Γ, B[σ], B[σ][Wk], Eq (B[σ][Wk][Wk]) #1 #0}}.
-    {
-      econstructor; mauto 3.
-      eapply wf_conv;
-        [econstructor | |];
-        mauto 2.
-      - mauto 3.
-      - symmetry.
-        etransitivity; [econstructor; mauto 3 |].
-        econstructor; eauto.
-        + eapply wf_exp_eq_conv; mauto 2.
-          transitivity {{{#0[Id]}}}.
-          * eapply wf_exp_eq_conv; [econstructor | |];
-              mauto 3.
-            mauto 4.
-          * eapply wf_exp_eq_conv; mauto 4.
-        + eapply wf_exp_eq_conv;
-            [econstructor | |].
-          * mauto 3.
-          * mauto 2.
-          * mauto 4.
-          * mauto 2.
-          * etransitivity; mauto 2.
-    }
-    assert {{Γ, B[σ] s q (q σ) (Id,,#0) q σ,,#0 : Δ, B, B[Wk]}}.
-    {
-      eapply sub_eq_q_sigma_id_extend;
-        mauto 2.
-      eapply wf_conv; mauto 3.
-    }
-    assert {{Γ, B[σ] #0 : B[σ][Wk][Wk][Id,,#0]}} by (eapply wf_conv; mauto 3).
-    assert {{Γ, B[σ] #0[Id,,#0] #0 : B[σ][Wk][Id]}} by (econstructor; mauto 3).
-    assert {{Γ, B[σ] #0[Id,,#0] #0 : B[σ][Wk]}} by mauto 3.
-    assert {{Γ, B[σ] #0[Id,,#0] #0 : B[σ][Wk][Wk][Id,,#0]}} by mauto 4.
-    assert {{Γ, B[σ] (Eq (B[σ][Wk][Wk]) #0 #0)[Id,,#0] Eq (B[σ][Wk]) #0 #0 : Type@i}}.
-    {
-      etransitivity; econstructor; mauto 3.
-    }
-    assert {{Γ, B[σ] s (q (q σ) Wk) (Id,,#0,,refl (B[σ][Wk]) #0) : Δ, B, B[Wk]}}.
-    {
-      econstructor; mauto 3.
-      econstructor; mauto 3.
-    }
-    assert {{Γ, B[σ] s (q (q σ) Wk) (Id,,#0,,refl (B[σ][Wk]) #0)
-                   q (q σ) (Id,,#0) : Δ, B, B[Wk]}}.
-    {
-      transitivity {{{q (q σ) (Wk (Id,,#0,,refl (B[σ][Wk]) #0))}}};
-        [mauto 4 |].
-      econstructor; mauto 3.
-      eapply wf_sub_eq_p_extend with (A:={{{Eq (B[σ][Wk][Wk]) #0 #0}}}); mauto 2.
- -
-      eapply wf_conv;
-        [econstructor; mauto 3 | eapply exp_sub_typ; mauto 3 |].
- -
-      symmetry.
-      etransitivity;
-        [econstructor; mauto 3 |].
-      econstructor; mauto 3.
-    }
-    assert {{Γ, B[σ] s (q (q σ) Wk) (Id,,#0,,refl (B[σ][Wk]) #0)
-                   q σ,,#0 : Δ, B, B[Wk]}} by mauto 4.
-    assert {{Γ, B[σ] B[σ][Wk][Wk][Id,,#0] B[Wk][q σ] : Type@i}} by mauto 3.
-    assert {{Γ, B[σ] B[Wk][Wk][q σ,,#0] B[Wk][q σ] : Type@i}}.
-    {
-      transitivity {{{B[Wk][Wk (q σ,,#0)]}}};
-        [eapply exp_eq_sub_compose_typ; mauto 4 |].
-      symmetry.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-      symmetry.
-      mauto 4.
-    }
-    assert {{Γ, B[σ] s q σ,,#0 : Δ, B, B[Wk] }} by (econstructor; mauto 3).
-    assert {{Γ, B[σ] B[Wk][Wk][q σ,,#0] : Type@i}} by mauto 3.
-    assert {{Γ, B[σ] B[Wk][Wk][q σ,,#0] B[σ][Wk] : Type@i}} by mauto 4.
-    assert {{ Γ, B[σ] #0[q σ,,#0] # 0 : B[σ][Wk] }}.
-    {
-      eapply wf_exp_eq_conv;
-        [econstructor | |];
-        mauto 2.
-      mauto 3.
-    }
-    assert {{ Γ, B[σ] #0[q σ,,#0] # 0 : B[Wk][Wk][q σ,,#0] }} by mauto 3.
+#[export]
+Hint Resolve presup_exp_eq_prop_eq_id_sub_helper3 : mcltt.
+ +
+Lemma presup_exp_eq_refl_sub_right : forall {Γ σ Δ i A M},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ M : A }} ->
+    {{ Γ refl A[σ] M[σ] : (Eq A M M)[σ] }}.
+Proof.
+  intros.
+  assert {{ Δ }} by mauto 2.
+  assert {{ Γ A[σ] : Type@i }} by mauto 2.
+  assert {{ Γ M[σ] : A[σ] }} by mauto 2.
+  assert {{ Γ (Eq A M M)[σ] : Type@i }} by mauto 3.
+  assert {{ Γ (Eq A M M)[σ] Eq A[σ] M[σ] M[σ] : Type@i }} by mauto 3.
+  eapply wf_conv; mauto 2.
+Qed.

-    assert {{ Γ, B[σ] s σ Wk : Δ }} by mauto 4.
-    assert {{ Γ, B[σ] # 0 : B[σ][Wk] }} by mauto 2.
-    assert {{ Γ, B[σ] B[σ][Wk] B[σ Wk] : Type@i }} by mauto 4.
-    assert {{ Γ, B[σ] # 0 : B[σ Wk] }} by mauto 3.
+#[local]
+Hint Resolve presup_exp_eq_refl_sub_right : mcltt.
+ +
+Lemma presup_exp_eq_eqrec_sub_left : forall {Γ σ Δ i A M1 M2 j B N BR},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ M1 : A }} ->
+    {{ Δ M2 : A }} ->
+    {{ Δ, A, A[Wk], Eq A[WkWk] #1 #0 B : Type@j }} ->
+    {{ Δ, A BR : B[Id,,#0,,refl A[Wk] #0] }} ->
+    {{ Δ N : Eq A M1 M2 }} ->
+    {{ Γ eqrec N as Eq A M1 M2 return B | refl -> BR end[σ] : B[σ,,M1[σ],,M2[σ],,N[σ]] }}.
+Proof.
+  intros.
+  set (IdM1 := {{{ Id,,M1 }}}).
+  set (IdM1M2 := {{{ IdM1,,M2 }}}).
+  set (IdM1M2N := {{{ IdM1M2,,N }}}).
+  setM1 := {{{ σ,,M1[σ] }}}).
+  setM1M2 := {{{ σM1,,M2[σ] }}}).
+  setM1M2N := {{{ σM1M2,,N[σ] }}}).
+  eapply wf_conv; mauto 3.
+  transitivity {{{ B[IdM1M2Nσ] }}}; [mauto 3 |].
+  eapply exp_eq_sub_cong_typ2'; mauto 3.
+  assert {{ Γ (Eq A[WkWk] #1 #0)[σM1M2] : Type@i }} by mauto 4.
+  assert {{ Δ N : (Eq A[WkWk] #1 #0)[IdM1M2] }} by (eapply wf_conv; mauto 4).
+  transitivity {{{ (IdM1M2σ),,N[σ] }}}; [econstructor; mautosolve 2 | symmetry].
+  assert {{ Γ N[σ] : (Eq A M1 M2)[σ] }} by mauto 2.
+  assert {{ Γ (Eq A[WkWk] #1 #0)[σM1M2] (Eq A M1 M2)[σ] : Type@i }} by mauto 2.
+  assert {{ Γ N[σ] : (Eq A[WkWk] #1 #0)[σM1M2] }} by mauto 3.
+  enough {{ Γ s σM1M2 IdM1M2σ : Δ, A, A[Wk] }} by (econstructor; mauto 3).
+  assert {{ Δ, A }} by mauto 2.
+  assert {{ Δ, A s Wk : Δ }} by mauto 2.
+  assert {{ Δ, A A[Wk] : Type@i }} by mauto 2.
+  assert {{ Γ M1[σ] : A[σ] }} by mauto 2.
+  assert {{ Γ A[Wk][σM1] : Type@i }} by mauto 3.
+  assert {{ Γ A[Wk][σM1] A[σ] : Type@i }} by mauto 2.
+  assert {{ Γ M2[σ] : A[Wk][σM1] }} by (eapply wf_conv; mauto 2).
+  assert {{ Δ A[Wk][IdM1] : Type@i }} by mauto 3.
+  assert {{ Δ A[Wk][IdM1] A : Type@i }} by mauto 2.
+  assert {{ Δ M2 : A[Wk][IdM1] }} by (eapply wf_conv; mauto 2).
+  transitivity {{{ (IdM1σ),,M2[σ] }}}; econstructor; mautosolve 3.
+Qed.

-    assert {{ Γ, B[σ] #1[q σ,,#0] # 0 : B[σ][Wk] }}.
-    {
-      eapply wf_exp_eq_conv with (A:={{{B[σ Wk]}}});
-        [eapply sub_lookup_var1; eauto | |];
+#[local]
+Hint Resolve presup_exp_eq_eqrec_sub_left : mcltt.
+ +
+Lemma presup_exp_eq_eqrec_sub_right : forall {Γ σ Δ i A M1 M2 j B N BR},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ M1 : A }} ->
+    {{ Δ M2 : A }} ->
+    {{ Δ, A, A[Wk], Eq A[WkWk] #1 #0 B : Type@j }} ->
+    {{ Δ, A BR : B[Id,,#0,,refl A[Wk] #0] }} ->
+    {{ Δ N : Eq A M1 M2 }} ->
+    {{ Γ eqrec N[σ] as Eq A[σ] M1[σ] M2[σ] return B[q (q (q σ))] | refl -> BR[q σ] end : B[σ,,M1[σ],,M2[σ],,N[σ]] }}.
+Proof.
+  intros.
+  assert {{ Δ s Id,,M1 : Δ, A }} by mauto 4.
+  assert {{ Δ, A }} by mauto 2.
+  assert {{ Δ , A A[Wk] : Type@i }} by mauto 3.
+  assert {{ Δ, A, A[Wk] }} by mauto 3.
+  assert {{ Δ, A, A[Wk] s WkWk : Δ }} by mauto 4.
+  assert {{ Δ , A , A[Wk] A[WkWk] : Type@i }} by mauto 2.
+  assert {{ Γ A[Wk][σ,,M1[σ]] : Type@i}} by mauto 4.
+  assert {{ Γ A[σ] : Type@i }} by mauto 2.
+  assert {{ Γ M1[σ] : A[σ] }} by mauto 2.
+  assert {{ Γ M2[σ] : A[σ] }} by mauto 2.
+  assert {{ Γ A[Wk][σ,,M1[σ]] A[σ] : Type@i}}.
+  {
+    transitivity {{{ A[Wk(σ,,M1[σ])] }}};
+      [| eapply exp_eq_sub_cong_typ2']; mauto 4.
+  }
+  assert {{ Γ M2[σ] : A[Wk][σ,,M1[σ]] }} by mauto 3.
+  assert {{ Γ s σ,, M1[σ] : Δ, A }} by mauto 2.
+  assert {{ Γ s σ,,M1[σ],,M2[σ] : Δ, A, A[Wk] }} by mauto 2.
+  assert {{ Δ, A, A[Wk] Eq A[WkWk] #1 #0 : Type@i }} by mauto 2.
+ +
+  assert {{ Δ, A s Wk : Δ }} by mauto 2.
+  assert {{ Δ, A, A[Wk] s Wk : Δ, A }} by mauto 2.
+  assert {{Γ A[WkWk][σ,,M1[σ],,M2[σ]] A[σ] : Type@i}}
+    by (transitivity {{{ A[Wk][Wk][σ,,M1[σ],,M2[σ]] }}}; mauto 4).
+  assert {{ Γ N[σ] : (Eq A M1 M2)[σ] }} by mauto 3.
+  assert {{ Γ #1[σ,,M1[σ],,M2[σ]] M1[σ] : A[WkWk][σ,,M1[σ],,M2[σ]] }}
+    by (eapply wf_exp_eq_conv; [eapply sub_lookup_var1 | |]; mauto 3).
+  assert {{ Γ #0[σ,,M1[σ],,M2[σ]] M2[σ] : A[WkWk][σ,,M1[σ],,M2[σ]] }}
+    by (eapply wf_exp_eq_conv; [eapply sub_lookup_var0 | |]; mauto 3).
+  assert {{ Γ N[σ] : (Eq A[WkWk] #1 #0)[σ,,M1[σ],,M2[σ]] }}
+    by (eapply wf_conv; mauto 2; mauto 3).
+  assert {{ Γ s σ,,M1[σ],,M2[σ],,N[σ] : Δ, A, A[Wk], Eq A[WkWk] #1 #0 }} by mauto 2.
+  assert {{ Γ, A[σ] s q σ : Δ, A }} by mauto 2.
+  assert {{ Γ, A[σ] s Wk : Γ }} by mauto 3.
+  assert {{ Γ, A[σ] A[σ][Wk] : Type@i }} by mauto 2.
+  assert {{ Γ, A[σ], A[σ][Wk] }} by mauto 3.
+  assert {{ Γ, A[σ], A[σ][Wk] s Wk : Γ, A[σ] }} by mauto 2.
+  assert {{ Γ, A[σ], A[σ][Wk] A[σ][WkWk] : Type@i }} by mauto 3.
+  assert {{ Γ, A[σ], A[σ][Wk] Eq A[σ][WkWk] # 1 # 0 : Type@i }} by (econstructor; mauto 2).
+  assert {{ Γ, A[σ] A[Wk][q σ] A[σ][Wk] : Type@i }} by mauto 3.
+  assert {{ Γ, A[σ], A[Wk][q σ] Γ, A[σ], A[σ][Wk] }} by (econstructor; mauto 3).
+  assert {{ Γ, A[σ], A[σ][Wk] s q (q σ) : Δ, A, A[Wk] }} by mauto 3.
+  assert {{ Γ, A[σ], A[σ][Wk] A[Wk][q σWk] : Type@i }} by mauto 3.
+  assert {{ Γ, A[σ], A[σ][Wk] A[Wk][q σWk] A[σ][WkWk] : Type@i }}.
+  {
+    transitivity {{{ A[Wk][q σ][Wk] }}}; [mauto 3 |].
+    transitivity {{{ A[σ][Wk][Wk] }}}; [| mauto 2].
+    eapply exp_eq_sub_cong_typ1; mauto 3.
+  }
+  assert {{ Γ, A[σ],A[σ][Wk] A[WkWk][q (q σ)] A[σ][WkWk] : Type@i }}.
+  {
+    transitivity {{{ A[Wk][q σWk] }}}; [| eassumption].
+    transitivity {{{ A[Wk][Wk][q (q σ)] }}}; [eapply exp_eq_sub_cong_typ1; mauto 3 |].
+    transitivity {{{ A[Wk][Wkq (q σ)] }}}; [mauto 2 |].
+    eapply exp_eq_sub_cong_typ2'; mauto 3.
+  }
+  assert {{ Γ, A[σ], A[σ][Wk] Eq A[σ][WkWk] #0 #0 : Type@i }} by (econstructor; mauto 2).
+  assert {{ Γ, A[σ], A[σ][Wk] (Eq A[WkWk] #1 #0)[q (q σ)] Eq A[σ][WkWk] #1 #0 : Type@i }}.
+  {
+    transitivity {{{ Eq (A[WkWk][q (q σ)]) (#1[q (q σ)]) (#0[q (q σ)]) }}};
+      [econstructor; mauto 2 |].
+    econstructor; mauto 2.
+    - eapply wf_exp_eq_conv;
+        [eapply ctxeq_exp_eq; [eassumption | eapply exp_eq_var_1_sub_q_sigma] | |];
        mauto 2.
-    }
-    assert {{ Γ, B[σ] #1[q σ,,#0] # 0 : B[Wk][Wk][q σ,,#0] }} by mauto 3.
- -
-    assert {{Γ, B[σ] s q (q (q σ)) (Id,,#0,,refl (B[σ][Wk]) #0)
-                   (q (q σ) (Id,,#0)),,refl (B[σ][Wk]) #0
-          : Δ, B, B[Wk], Eq (B[Wk][Wk]) # 1 # 0}}.
-    {
-      etransitivity;
-        [eapply wf_sub_eq_extend_compose; mauto 2; mauto 4 |].
- -
-      - eapply wf_conv; mauto 3.
-        + mauto.
-        + symmetry.
-          transitivity {{{(Eq (B[Wk][Wk]) #1 #0)[q (q σ)][Wk]}}};
-            [mauto |].
-          eapply exp_eq_sub_cong_typ1; mauto 4.
-      - econstructor; mauto 3.
- -
-        eapply wf_exp_eq_conv.
-        econstructor; mauto 3.
-        + eapply wf_conv; [econstructor | |]; mauto 3.
-        + eapply exp_sub_typ; mauto 3.
-        + etransitivity; eauto.
-          symmetry.
-          etransitivity; [| etransitivity].
-          * eapply exp_eq_sub_cong_typ2'; mauto 3.
-          * econstructor; mauto 4.
-          * econstructor; mauto 2.
-    }
-
-    assert {{ Δ, B, B[Wk]}} by mauto 3.
-    assert {{Δ, B, B[Wk] #0 : B[Wk][Wk]}} by mauto 4.
-    assert {{Δ, B, B[Wk] #1 : B[Wk][Wk]}} by mauto 4.
-    assert {{Γ, B[σ] B[Wk][Wk][q (q σ) (Id,,#0)] B[Wk][q σ] : Type@i}} by mauto 4.
-    assert {{Γ, B[σ] B[Wk][Wk][q (q σ) (Id,,#0)] B[σ][Wk] : Type@i}} by mauto 4.
- -
-    assert {{ Γ, B[σ] #0[q (q σ) (Id,,#0)] # 0 : B[σ][Wk] }}.
-    {
-      transitivity {{{#0[q σ,,#0]}}}.
-      - symmetry.
-        eapply wf_exp_eq_conv;
-          [econstructor | |]; mauto 2.
-      - eauto.
-    }
-    assert {{ Γ, B[σ] #0[q (q σ) (Id,,#0)] # 0 : B[Wk][Wk][q (q σ) (Id,,#0)] }} by
-      (eapply wf_exp_eq_conv; mauto 3).
- -
-    assert {{ Γ, B[σ] #1[q (q σ) (Id,,#0)] # 0 : B[σ][Wk] }}.
-    {
-      transitivity {{{#1[q σ,,#0]}}}.
-      - symmetry.
-        eapply wf_exp_eq_conv;
-          [econstructor | |]; mauto 2.
-      - eauto.
-    }
-    assert {{ Γ, B[σ] #1[q (q σ) (Id,,#0)] # 0 : B[Wk][Wk][q (q σ) (Id,,#0)] }} by
-      (eapply wf_exp_eq_conv; mauto 3).
- -
-    assert {{Γ, B[σ] s q (q (q σ)) (Id,,#0,,refl (B[σ][Wk]) #0)
-                   q σ,,#0,,refl (B[σ][Wk]) #0 : Δ, B, B[Wk], Eq (B[Wk][Wk]) # 1 # 0}}.
-    {
-      etransitivity; eauto.
-      econstructor; mauto 3.
-      eapply exp_eq_refl.
-      eapply wf_conv; mauto 3.
-      symmetry.
-      etransitivity.
-      - econstructor; mauto 2.
-      - econstructor; mauto 2.
-    }
-
-    assert {{Γ, B[σ] s Id q σ : Δ, B}} by mauto 3.
-    assert {{Γ, B[σ] s Id q σ q σ : Δ, B}} by mauto 3.
-    assert {{Γ, B[σ] #0[q σ] #0 : B[σ Wk]}} by mauto 3.
-    assert {{Γ, B[σ] #0[q σ] #0 : B[σ][Wk]}} by mauto 3.
-    assert {{Γ, B[σ] #0[q σ] #0 : B[Wk][q σ]}} by mauto 4.
-    assert {{Γ, B[σ] s (Id,,#0) q σ : Δ, B, B[Wk]}} by (econstructor; mauto 3).
-    assert {{Γ, B[σ] s (Id,,#0) q σ q σ,,#0 : Δ, B, B[Wk]}}.
-    {
-      etransitivity.
-      - eapply wf_sub_eq_extend_compose; mauto 3.
-      - econstructor; mauto 3.
-        eapply wf_exp_eq_conv; mauto 2.
-        eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-
-    assert {{Δ, B B[Wk][Wk][Id,,#0] B[Wk] : Type@i }}.
-    {
-      transitivity {{{B[Wk][Wk (Id,,#0)]}}}; [ |transitivity{{{B[Wk][Id]}}}].
-      - eapply exp_eq_sub_compose_typ; mauto 3.
-      - eapply exp_eq_sub_cong_typ2'; mauto 3.
-        econstructor; mauto 3.
-      - mauto 3.
-    }
-    assert {{Δ, B #0[Id ,, #0] #0 : B[Wk]}}.
-    {
-      eapply wf_exp_eq_conv;
-      [econstructor | |]; mauto 3.
-    }
-    assert {{Δ, B B[Wk][Wk][Id,,#0] : Type@i }} by (eapply exp_sub_typ; mauto 3).
-    assert {{Δ, B #0[Id ,, #0] #0 : B[Wk][Wk][Id,,#0]}} by (eapply wf_exp_eq_conv; mauto 2).
-    assert {{Δ, B #1[Id ,, #0] #0 : B[Wk]}}.
-    {
-      transitivity {{{#0[Id]}}}; mauto 3.
-      eapply wf_exp_eq_conv;
-        [econstructor | |]; mauto 3.
-      eapply wf_conv; mauto 3.
-      symmetry.
-      mauto 3.
-    }
-    assert {{Δ, B #1[Id ,, #0] #0 : B[Wk][Wk][Id,,#0]}} by (eapply wf_exp_eq_conv; mauto 2).
- -
-    assert {{Δ, B refl (B[Wk]) #0 : (Eq (B[Wk][Wk]) #1 #0)[Id ,, #0]}}.
-    {
-      eapply wf_conv; mauto 3.
-      - mauto 4.
-      - symmetry.
-        etransitivity.
-        + econstructor; mauto 3.
-        + econstructor; mauto 3.
-    }
-
-    assert {{ Γ, B[σ] (Eq B[Wk] #0 #0)[q σ] Eq B[σ][Wk] #0 #0 : Type@i }}.
-    {
-      etransitivity;
-        [econstructor; mauto 2 |];
-        mauto 3.
-    }
+    - eapply wf_exp_eq_conv.
+      econstructor; [mauto 2 | eauto | eapply wf_conv; mauto 2].
+      + mauto 2.
+      + mauto 3.
+  }
+  assert {{ Γ, A[σ], A[σ][Wk], Eq A[σ][WkWk] #1 #0 s q (q (q σ)) : Δ, A, A[Wk], Eq A[WkWk] #1 #0 }}.
+  {
+    eapply ctxeq_sub; [| eapply sub_q]; mauto 2.
+    econstructor; mauto 3.
+  }
+  assert {{ Γ, A[σ] #0 : A[σ][Wk] }} by mauto 3.
+  assert {{ Γ, A[σ] s Id,,#0 : Γ, A[σ], A[σ][Wk] }} by mauto 4.
+  assert {{ Γ, A[σ] A[σ][WkWk][Id,,#0] A[σ][Wk] : Type@i }}
+    by (transitivity {{{ A[σ][Wk][Wk][Id,,#0] }}}; [symmetry |]; mauto 3).
+ +
+  assert {{ Γ, A[σ] s Id,,#0,,refl A[σ][Wk] #0 : Γ, A[σ], A[σ][Wk], Eq A[σ][WkWk] #1 #0 }}.
+  {
+    econstructor; mauto 2.
+    eapply wf_conv;
+      [econstructor | |];
+      mauto 2.
+    symmetry.
+    etransitivity; [econstructor; mauto 3 |].
+    econstructor; eauto.
+    - eapply wf_exp_eq_conv; mauto 2.
+      transitivity {{{#0[Id]}}}; mauto 2.
+      eapply wf_exp_eq_conv; [econstructor | |]; mauto 3.
+    - eapply wf_exp_eq_conv; [econstructor | |]; mauto 3.
+      transitivity {{{ A[σ][Wk] }}}; mauto 3.
+  }
+  assert {{ Γ, A[σ] s q (q σ) (Id,,#0) q σ,,#0 : Δ, A, A[Wk] }}.
+  {
+    eapply sub_eq_q_sigma_id_extend; mauto 2.
+    eapply wf_conv; mauto 2.
+  }
+  assert {{ Γ, A[σ] #0 : A[σ][WkWk][Id,,#0] }} by (eapply wf_conv; mauto 2).
+  assert {{ Γ, A[σ] #0[Id,,#0] #0 : A[σ][Wk][Id] }} by (econstructor; mauto 3).
+  assert {{ Γ, A[σ] #0[Id,,#0] #0 : A[σ][Wk] }} by mauto 3.
+  assert {{ Γ, A[σ] #0[Id,,#0] #0 : A[σ][WkWk][Id,,#0] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ, A[σ] (Eq A[σ][WkWk] #0 #0)[Id,,#0] Eq A[σ][Wk] #0 #0 : Type@i }}
+    by (etransitivity; econstructor; mauto 2).
+  assert {{ Γ, A[σ] s (q (q σ)Wk)(Id,,#0,,refl A[σ][Wk] #0) : Δ, A, A[Wk] }}.
+  {
+    econstructor; [eassumption |].
+    econstructor; mauto 3.
+  }
+  assert {{ Γ, A[σ] s (q (q σ)Wk)(Id,,#0,,refl A[σ][Wk] #0) q (q σ)(Id,,#0) : Δ, A, A[Wk] }}.
+  {
+    transitivity {{{ q (q σ)(Wk(Id,,#0,,refl A[σ][Wk] #0)) }}}; [mauto 4 |].
+    econstructor; mauto 2.
+    eapply wf_sub_eq_p_extend with (A:={{{ Eq A[σ][WkWk] #0 #0 }}}); mauto 2.
+    eapply wf_conv; mauto 3.
+  }
+  assert {{ Γ, A[σ] s (q (q σ) Wk) (Id,,#0,,refl A[σ][Wk] #0) q σ,,#0 : Δ, A, A[Wk] }} by mauto 4.
+  assert {{ Γ, A[σ] A[σ][WkWk][Id,,#0] A[Wk][q σ] : Type@i }} by mauto 3.
+  assert {{ Γ, A[σ] #0 : A[Wk][q σ] }} by mauto 3.
+  assert {{ Γ, A[σ] A[WkWk][q σ,,#0] A[Wk][q σ] : Type@i }}
+    by (transitivity {{{ A[Wk][Wk][q σ,,#0] }}}; [eapply exp_eq_sub_cong_typ1 |]; mauto 3).
+  assert {{Γ, A[σ] s q σ,,#0 : Δ, A, A[Wk] }} by mauto 2.
+  assert {{Γ, A[σ] A[WkWk][q σ,,#0] : Type@i}} by mauto 2.
+  assert {{Γ, A[σ] A[WkWk][q σ,,#0] A[σ][Wk] : Type@i}} by mauto 2.
+  assert {{ Γ, A[σ] #0[q σ,,#0] # 0 : A[σ][Wk] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ, A[σ] #0[q σ,,#0] # 0 : A[WkWk][q σ,,#0] }} by mauto 3.
+
-    assert {{ Γ, B[σ] B[Wk][Wk][(Id,,#0)q σ] B[σ][Wk] : Type@i }} by mauto 3.
+  assert {{ Γ, A[σ] s σWk : Δ }} by mauto 2.
+  assert {{ Γ, A[σ] A[σ][Wk] A[σ Wk] : Type@i }} by mauto 2.
+  assert {{ Γ, A[σ] #0 : A[σWk] }} by mauto 3.

-    assert {{ Γ, B[σ] #1[(Id,,#0)q σ] #0 : B[σ][Wk] }}.
-    {
-      transitivity {{{#1[q σ,,#0]}}};
-        [eapply wf_exp_eq_conv |];
-        mauto 3.
-    }
-    assert {{ Γ, B[σ] #1[(Id,,#0)q σ] #0 : B[Wk][Wk][(Id,,#0)q σ] }} by mauto 4.
+  assert {{ Γ, A[σ] #1[q σ,,#0] #0 : A[σ][Wk] }}
+    by (eapply wf_exp_eq_conv; [eapply sub_lookup_var1 | |]; mauto 2).
+  assert {{ Γ, A[σ] #1[q σ,,#0] #0 : A[WkWk][q σ,,#0] }} by mauto 3.

-    assert {{ Γ, B[σ] #0[(Id,,#0)q σ] #0 : B[σ][Wk] }}.
-    {
-      transitivity {{{#0[q σ,,#0]}}};
-        [eapply wf_exp_eq_conv |];
-        mauto 3.
-    }
-    assert {{ Γ, B[σ] #0[(Id,,#0)q σ] #0 : B[Wk][Wk][(Id,,#0)q σ] }} by mauto 4.
+  assert {{ Γ, A[σ], A[σ][Wk], Eq A[σ][WkWk] #1 #0 }} by mauto 2.
+  assert {{ Γ, A[σ] s q (q (q σ))(Id,,#0,,refl A[σ][Wk] #0) (q (q σ)(Id,,#0)),,refl A[σ][Wk] #0 : Δ, A, A[Wk], Eq A[WkWk] #1 #0 }}.
+  {
+    etransitivity;
+      [eapply wf_sub_eq_extend_compose; mauto 2; mauto 3 |].
+ +
+    - eapply wf_conv; mauto 2.
+      + mauto 4.
+      + symmetry.
+        transitivity {{{ (Eq A[WkWk] #1 #0)[q (q σ)][Wk] }}};
+          [mauto 4 |].
+        eapply exp_eq_sub_cong_typ1; mauto 2.
+    - econstructor; mauto 2.
+ +
+      eapply wf_exp_eq_conv; mauto 3.
+      + econstructor; mauto 3.
+        eapply wf_conv; [econstructor | |]; mauto 3.
+      + etransitivity; mauto 2.
+        symmetry.
+        etransitivity; [| etransitivity].
+        * eapply exp_eq_sub_cong_typ2'; mauto 2.
+        * econstructor; mauto 2.
+        * econstructor; mauto 2.
+  }
+
+  assert {{ Γ, A[σ] A[WkWk][q (q σ)(Id,,#0)] A[Wk][q σ] : Type@i }} by (etransitivity; mauto 3).
+  assert {{ Γ, A[σ] A[WkWk][q (q σ)(Id,,#0)] A[σ][Wk] : Type@i }} by mauto 2.
+ +
+  assert {{ Γ, A[σ] #0[q (q σ)(Id,,#0)] #0 : A[σ][Wk] }}.
+  {
+    transitivity {{{ #0[q σ,,#0] }}}; [| eassumption].
+    eapply wf_exp_eq_conv; [econstructor; [| eassumption] | |]; mauto 3.
+  }
+  assert {{ Γ, A[σ] #0[q (q σ)(Id,,#0)] #0 : A[WkWk][q (q σ)(Id,,#0)] }}
+    by (eapply wf_exp_eq_conv; mauto 3).
+ +
+  assert {{ Γ, A[σ] #1[q (q σ)(Id,,#0)] #0 : A[σ][Wk] }}.
+  {
+    transitivity {{{ #1[q σ,,#0] }}}; [| eassumption].
+    eapply wf_exp_eq_conv; [econstructor; [| eassumption] | |]; mauto 3.
+  }
+  assert {{ Γ, A[σ] #1[q (q σ)(Id,,#0)] #0 : A[WkWk][q (q σ) (Id,,#0)] }}
+    by (eapply wf_exp_eq_conv; mauto 3).
+ +
+  assert {{ Γ, A[σ] s q (q (q σ))(Id,,#0,,refl A[σ][Wk] #0) q σ,,#0,,refl A[σ][Wk] #0 : Δ, A, A[Wk], Eq A[WkWk] #1 #0 }}.
+  {
+    etransitivity; [eassumption |].
+    econstructor; mauto 2.
+    eapply exp_eq_refl.
+    eapply wf_conv; mauto 3.
+    symmetry.
+    etransitivity; econstructor; mauto 2.
+  }
+
+  assert {{ Γ, A[σ] s Id q σ : Δ, A }} by mauto 3.
+  assert {{ Γ, A[σ] s Id q σ q σ : Δ, A }} by mauto 2.
+  assert {{ Γ, A[σ] #0[q σ] #0 : A[σ Wk] }} by mauto 2.
+  assert {{ Γ, A[σ] #0[q σ] #0 : A[σ][Wk] }} by mauto 3.
+  assert {{ Γ, A[σ] #0[q σ] #0 : A[Wk][q σ] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ, A[σ] s (Id,,#0)q σ : Δ, A, A[Wk] }} by (econstructor; mauto 3).
+  assert {{ Γ, A[σ] s (Id,,#0)q σ q σ,,#0 : Δ, A, A[Wk] }}.
+  {
+    etransitivity.
+    - eapply wf_sub_eq_extend_compose; mauto 3.
+    - econstructor; mauto 3.
+      eapply wf_exp_eq_conv; mauto 2.
+      eapply exp_eq_sub_cong_typ2'; mauto 2.
+  }
+
+  assert {{ Δ, A A[WkWk][Id,,#0] A[Wk] : Type@i }}
+    by (transitivity {{{ A[Wk][Wk][Id,,#0] }}}; [eapply exp_eq_sub_cong_typ1 |]; mauto 3).
+  assert {{ Δ, A #0[Id,,#0] #0 : A[Wk] }} by (eapply wf_exp_eq_conv; [econstructor | |]; mauto 3).
+  assert {{ Δ, A A[WkWk][Id,,#0] : Type@i }} by (eapply exp_sub_typ; mauto 3).
+  assert {{ Δ, A #0[Id,,#0] #0 : A[WkWk][Id,,#0] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Δ, A #1[Id,,#0] #0 : A[Wk] }}.
+  {
+    transitivity {{{ #0[Id] }}}; mauto 3.
+    eapply wf_exp_eq_conv; [econstructor | |]; mauto 3.
+    eapply wf_conv; mauto 3.
+    symmetry; mauto 3.
+  }
+  assert {{ Δ, A #1[Id,,#0] #0 : A[WkWk][Id,,#0] }} by (eapply wf_exp_eq_conv; mauto 2).
+ +
+  assert {{ Δ, A refl A[Wk] #0 : (Eq A[WkWk] #1 #0)[Id,,#0] }}.
+  {
+    eapply wf_conv; [mauto 3 | |].
+    - mauto 4.
+    - symmetry.
+      etransitivity; econstructor; mauto 3.
+  }
+
+  assert {{ Γ, A[σ] (Eq A[Wk] #0 #0)[q σ] Eq A[σ][Wk] #0 #0 : Type@i }}
+    by (etransitivity; [econstructor; mauto 2 |]; mauto 3).
+  assert {{ Γ, A[σ] A[WkWk][(Id,,#0)q σ] A[σ][Wk] : Type@i }} by mauto 3.
+  assert {{ Γ, A[σ] #1[(Id,,#0)q σ] #0 : A[σ][Wk] }}
+    by (transitivity {{{ #1[q σ,,#0] }}}; [eapply wf_exp_eq_conv |]; mauto 2; econstructor; mauto 3).
+  assert {{ Γ, A[σ] #1[(Id,,#0)q σ] #0 : A[WkWk][(Id,,#0)q σ] }} by (eapply wf_exp_eq_conv; mauto 2).
+ +
+  assert {{ Γ, A[σ] #0[(Id,,#0)q σ] #0 : A[σ][Wk] }}.
+  {
+    transitivity {{{ #0[q σ,,#0] }}};
+      [eapply wf_exp_eq_conv; [| | eassumption] |]; mauto 2.
+    econstructor; mauto 3.
+  }
+  assert {{ Γ, A[σ] #0[(Id,,#0)q σ] #0 : A[WkWk][(Id,,#0)q σ] }} by (eapply wf_exp_eq_conv; mauto 2).

-    assert {{ Γ, B[σ] (Eq B[Wk][Wk] #1 #0)[(Id,,#0)q σ] Eq B[σ][Wk] #0 #0 : Type@i }}.
-    {
-      etransitivity; econstructor; mauto 2.
-    }
+  assert {{ Γ, A[σ] (Eq A[WkWk] #1 #0)[(Id,,#0)q σ] Eq A[σ][Wk] #0 #0 : Type@i }}
+    by (etransitivity; econstructor; mauto 2).
+
-    assert {{Γ, B[σ] s (Id,,#0,,refl (B[Wk]) #0) q σ
-                   q σ,,#0,,refl (B[σ][Wk]) #0 : Δ, B, B[Wk], Eq (B[Wk][Wk]) # 1 # 0}}.
-    {
+  assert {{ Γ, A[σ] s (Id,,#0,,refl A[Wk] #0) q σ q σ,,#0,,refl A[σ][Wk] #0 : Δ, A, A[Wk], Eq A[WkWk] #1 #0 }}.
+  {
+    etransitivity.
+    - eapply wf_sub_eq_extend_compose; mauto 3.
+    - econstructor; mauto 2.
      etransitivity.
-      - eapply wf_sub_eq_extend_compose; mauto 3.
-      - econstructor; mauto 2.
-        etransitivity.
-        + eapply wf_exp_eq_conv;
-            [eapply wf_exp_eq_refl_sub; mauto 3 |
-             eapply exp_sub_typ; mauto 3 |].
-          mauto 3.
-        + eapply wf_exp_eq_conv;
-            [econstructor | |];
-            mauto 2.
-          etransitivity; mauto 2.
-    }
-
-    assert {{ Δ, B s Id,,#0,,refl B[Wk] #0 : ((Δ, B), B[Wk]), Eq B[Wk][Wk] #1 #0 }} by mauto 4.
- -
-    assert {{ Γ s Id,,M1[σ] : Γ,B[σ]}} by mauto 2.
-    assert {{ Γ B[σ][Wk][Id ,, M1[σ]] B[σ] : Type@i}}.
-    {
-      etransitivity;
-        [eapply exp_eq_sub_compose_typ; mauto 3 |];
-        transitivity {{{B[σ][Id]}}}; mauto 2.
-      symmetry.
-      eapply exp_eq_sub_cong_typ2';
+      + eapply wf_exp_eq_conv;
+          [eapply wf_exp_eq_refl_sub; mauto 3 |
+            eapply exp_sub_typ; mauto 3 |].
        mauto 3.
-    }
-    assert {{ Γ M2[σ] : B[σ][Wk][Id ,, M1[σ]]}} by mauto 4.
-    assert {{ Γ s Id ,, M1[σ] ,, M2[σ] : Γ, B[σ], B[σ][Wk]}} by mauto 3.
- -
-    assert {{ Γ B[σ][Wk][Wk][Id,,M1[σ],,M2[σ]] B[σ] : Type@i }}.
-    {
-      etransitivity;
-        [eapply exp_eq_sub_compose_typ; mauto 3 |];
-        transitivity {{{B[σ][Wk][Id,,M1[σ]]}}}; mauto 3.
-      symmetry.
-      eapply exp_eq_sub_cong_typ2';
-        mauto 3.
-    }
+      + eapply wf_exp_eq_conv;
+          [econstructor | |];
+          mauto 2.
+        etransitivity; mauto 2.
+  }

-    assert {{ Γ #1[Id,,M1[σ],,M2[σ]] M1[σ] : B[σ] }}.
-    {
-      transitivity {{{#0[Id,,M1[σ]]}}};
-        [eapply wf_exp_eq_conv | eapply wf_exp_eq_conv; econstructor];
-        mauto 3.
-    }
-    assert {{ Γ #1[Id,,M1[σ],,M2[σ]] M1[σ] : B[σ][Wk][Wk][Id,,M1[σ],,M2[σ]] }} by mauto 4.
+  assert {{ Δ, A s Id,,#0,,refl A[Wk] #0 : Δ, A, A[Wk], Eq A[WkWk] #1 #0 }} by (econstructor; mauto 3).

-    assert {{ Γ #0[Id,,M1[σ],,M2[σ]] M2[σ] : B[σ] }}
-      by (eapply wf_exp_eq_conv; mauto 3).
-    assert {{ Γ #0[Id,,M1[σ],,M2[σ]] M2[σ] : B[σ][Wk][Wk][Id,,M1[σ],,M2[σ]] }} by mauto 4.
+  assert {{ Γ s Id,,M1[σ] : Γ,A[σ]}} by mauto 2.
+  assert {{ Γ A[σ][Wk][Id,,M1[σ]] A[σ] : Type@i}}.
+  {
+    etransitivity;
+      [eapply exp_eq_sub_compose_typ; mauto 3 |];
+      transitivity {{{ A[σ][Id] }}}; mauto 2.
+    symmetry.
+    eapply exp_eq_sub_cong_typ2'; mauto 3.
+  }
+  assert {{ Γ M2[σ] : A[σ][Wk][Id,,M1[σ]] }} by (eapply wf_conv; revgoals; mauto 2).
+  assert {{ Γ s Id,,M1[σ],,M2[σ] : Γ, A[σ], A[σ][Wk] }} by mauto 2.

-    assert {{ Γ (Eq B[σ][Wk][Wk] #1 #0)[Id ,, M1[σ] ,, M2[σ]] Eq B[σ] M1[σ] M2[σ] : Type@i }}
-      by (etransitivity; econstructor; mauto 3).
-    assert {{ Γ L[σ] : (Eq B[σ][Wk][Wk] #1 #0)[Id ,, M1[σ] ,, M2[σ]] }} by mauto 4.
+  assert {{ Γ A[σ][WkWk][Id,,M1[σ],,M2[σ]] A[σ] : Type@i }} by mauto 2.

-    assert {{ Γ s Id ,, M1[σ] ,, M2[σ] ,, L[σ] : Γ, B[σ], B[σ][Wk], Eq B[σ][Wk][Wk] #1 #0}} by mauto 3.
+  assert {{ Γ #1[Id,,M1[σ],,M2[σ]] M1[σ] : A[σ] }}.
+  {
+    transitivity {{{#0[Id,,M1[σ]]}}};
+      [eapply wf_exp_eq_conv | eapply wf_exp_eq_conv; econstructor];
+      mauto 3.
+  }
+  assert {{ Γ #1[Id,,M1[σ],,M2[σ]] M1[σ] : A[σ][WkWk][Id,,M1[σ],,M2[σ]] }} by (eapply wf_exp_eq_conv; mauto 2).

-    assert {{ (Γ, B[σ]), B[σ][Wk] B[Wk][q σWk] B[σ][Wk][Wk] : Type@i }}.
-    {
-      transitivity {{{B[Wk][q σ][Wk]}}};
-        [symmetry;
-         eapply exp_eq_sub_compose_typ; mauto 3 |].
-      eapply exp_eq_sub_cong_typ1; mauto 3.
-    }
-
-    assert {{ (Γ, B[σ]), B[σ][Wk] #0 : B[Wk][q σWk] }}
-      by (eapply wf_conv; mauto 3).
+  assert {{ Γ #0[Id,,M1[σ],,M2[σ]] M2[σ] : A[σ] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ #0[Id,,M1[σ],,M2[σ]] M2[σ] : A[σ][WkWk][Id,,M1[σ],,M2[σ]] }} by (eapply wf_exp_eq_conv; mauto 2).

-    assert {{ ((Γ, B[σ]), B[σ][Wk]), Eq B[σ][Wk][Wk] #1 #0 s q (q σ)Wk : Δ,B,B[Wk] }} by mauto 4.
-    assert {{ ((Γ, B[σ]), B[σ][Wk]), Eq B[σ][Wk][Wk] #1 #0 (Eq B[Wk][Wk] #1 #0)[q (q σ)Wk] (Eq B[σ][Wk][Wk] #1 #0)[Wk] : Type@i }}.
-    {
-      transitivity {{{(Eq B[Wk][Wk] #1 #0)[q (q σ)][Wk]}}};
-        [symmetry;
-         eapply exp_eq_sub_compose_typ; mauto 3 |].
-      eapply exp_eq_sub_cong_typ1; mauto 3.
-    }
+  assert {{ Γ (Eq A[σ][WkWk] #1 #0)[Id,,M1[σ],,M2[σ]] Eq A[σ] M1[σ] M2[σ] : Type@i }}
+    by (etransitivity; econstructor; mauto 2).
+  assert {{ Γ (Eq A M1 M2)[σ] Eq A[σ] M1[σ] M2[σ] : Type@i }} by mauto 2.
+  assert {{ Γ N[σ] : (Eq A[σ][WkWk] #1 #0)[Id,,M1[σ],,M2[σ]] }}
+    by (eapply wf_conv; mauto 2; transitivity {{{ (Eq A M1 M2)[σ] }}}; [| etransitivity]; mauto 2).
+
+  assert {{ Γ s Id,,M1[σ],,M2[σ],,N[σ] : Γ, A[σ], A[σ][Wk], Eq A[σ][WkWk] #1 #0}} by mauto 3.
+
-    assert {{ Δ,B,B[Wk] Eq B[Wk][Wk] #1 #0 : Type@i }} by mauto 3.
-    assert {{ ((Γ, B[σ]), B[σ][Wk]), Eq B[σ][Wk][Wk] #1 #0 #0 : (Eq B[Wk][Wk] #1 #0)[q (q σ)Wk] }}.
-    {
-      eapply wf_conv; mauto 3.
-    }
+  assert {{ Γ, A[σ], A[σ][Wk] A[Wk][q σWk] A[σ][WkWk] : Type@i }} by mauto 3.
+
-    assert {{ Γ s (q σ Wk) (Id,,M1[σ],,M2[σ]) : Δ, B }}
-             by (econstructor; mauto 4).
-    assert {{ Γ s (q σ Wk) (Id,,M1[σ],,M2[σ]) σ,,M1[σ] : Δ, B }}.
-    {
-      etransitivity;
-        [eapply wf_sub_eq_compose_assoc; mauto 3 |].
-      etransitivity;
-        [eapply wf_sub_eq_compose_cong;
-         [eapply wf_sub_eq_p_extend with (A:={{{B[σ][Wk]}}}) | eapply sub_eq_refl] |];
-        mauto 3.
-    }
-
-    assert {{ Γ B[Wk][(q σWk)(Id,,M1[σ],,M2[σ])] B[σ] : Type@i }}.
-    {
-      transitivity {{{B[Wk][σ,,M1[σ]]}}};
-        [eapply exp_eq_sub_cong_typ2' |]; mauto 3.
-    }
-    assert {{ Γ #0[Id,,M1[σ],,M2[σ]] M2[σ] : B[Wk][(q σWk)(Id,,M1[σ],,M2[σ])] }} by mauto 4.
-    assert {{ Γ s q (q σ) (Id,,M1[σ],,M2[σ]) σ,,M1[σ],,M2[σ] : Δ, B, B[Wk] }}.
-    {
-      etransitivity;
-        [eapply wf_sub_eq_extend_compose; mauto 4 |].
-      econstructor; mauto 2.
-    }
-    assert {{ Γ s (q (q σ)Wk)(Id,,M1[σ],,M2[σ],,L[σ]) : (Δ, B), B[Wk] }}
-      by (econstructor; mauto 4).
-    assert {{ Γ s (q (q σ) Wk) (Id,,M1[σ],,M2[σ],,L[σ]) σ,,M1[σ],,M2[σ] : Δ, B, B[Wk] }}.
-    {
-      etransitivity;
-        [eapply wf_sub_eq_compose_assoc; mauto 3 |].
-      etransitivity;
-        [eapply wf_sub_eq_compose_cong;
-         [eapply wf_sub_eq_p_extend with (A:={{{Eq B[σ][Wk][Wk] #1 #0}}}) | eapply sub_eq_refl] |];
-        mauto 3.
-    }
-
-    assert {{ Γ (Eq B[Wk][Wk] #1 #0)[σ,,M1[σ],,M2[σ]] Eq B[σ] M1[σ] M2[σ] : Type@i }}.
-    {
-      etransitivity;
-        econstructor; mauto 3.
-    }
-    assert {{ Γ (Eq B[Wk][Wk] #1 #0)[(q (q σ)Wk)(Id,,M1[σ],,M2[σ],,L[σ])] Eq B[σ] M1[σ] M2[σ] : Type@i }}.
-    {
-      transitivity {{{(Eq B[Wk][Wk] #1 #0)[σ,,M1[σ],,M2[σ]]}}};
-        [eapply exp_eq_sub_cong_typ2' |]; mauto 3.
-    }
-    assert {{ Γ #0[Id,,M1[σ],,M2[σ],,L[σ]] L[σ] : (Eq B[Wk][Wk] #1 #0)[(q (q σ)Wk)(Id,,M1[σ],,M2[σ],,L[σ])] }}.
-    {
-      eapply wf_exp_eq_conv with (A:={{{Eq B[σ] M1[σ] M2[σ]}}});
-        econstructor; mauto 3.
-    }
-    assert {{ Γ s q (q (q σ)) (Id,,M1[σ],,M2[σ],,L[σ]) σ,,M1[σ],,M2[σ],,L[σ] : Δ, B, B[Wk], Eq B[Wk][Wk] #1 #0 }}.
-    {
-      etransitivity;
-        [eapply wf_sub_eq_extend_compose; mauto 4 |].
-      econstructor; mauto 2.
-    }
-
-    assert {{Γ, B[σ] s (Id,,#0,,refl (B[Wk]) #0) q σ
-                   q (q (q σ)) (Id,,#0,,refl (B[σ][Wk]) #0)
-          : Δ, B, B[Wk], Eq (B[Wk][Wk]) # 1 # 0}} by mauto 3.
+  assert {{ Γ, A[σ], A[σ][Wk] #0 : A[Wk][q σWk] }} by (eapply wf_conv; mauto 3).

-    eapply wf_conv;
-    [econstructor | |];
-      mauto 2.
-    + eapply wf_conv; mauto 3.
-    + etransitivity;
-        [eapply exp_eq_sub_compose_typ | eapply exp_eq_sub_cong_typ2'];
-        mauto 3.
+  assert {{ Γ, A[σ], A[σ][Wk], Eq A[σ][WkWk] #1 #0 s q (q σ)Wk : Δ,A,A[Wk] }} by mauto 3.
+  assert {{ Γ, A[σ], A[σ][Wk], Eq A[σ][WkWk] #1 #0 (Eq A[WkWk] #1 #0)[q (q σ)Wk] (Eq A[σ][WkWk] #1 #0)[Wk] : Type@i }}.
+  {
+    transitivity {{{ (Eq A[WkWk] #1 #0)[q (q σ)][Wk] }}};
+      [symmetry;
+       eapply exp_eq_sub_compose_typ; mauto 3 |].
+    eapply exp_eq_sub_cong_typ1; mauto 3.
+  }
+
+  assert {{ Γ, A[σ], A[σ][Wk], Eq A[σ][WkWk] #1 #0 #0 : (Eq A[WkWk] #1 #0)[q (q σ)Wk] }}
+    by (eapply wf_conv; mauto 2).

-  - eexists.
-    eapply exp_sub_typ; mauto 2.
-    assert {{ Δ s Id ,, M1 : Δ, B}} by mauto 4.
-    assert {{ Δ , B B[Wk] : Type@i }} by mauto 4.
-    assert {{ Δ , B , B[Wk] B[Wk][Wk] : Type@i }} by mauto 4.
-    assert {{ Γ B[Wk][σ ,, M1[σ]] : Type@i}} by mauto.
-    assert {{ Γ B[σ] : Type @ i }} by mauto 3.
-    assert {{ Γ M1[σ] : B[σ] }} by mauto 3.
-    assert {{ Γ M2[σ] : B[σ] }} by mauto 3.
-    assert {{ Γ B[Wk][σ ,, M1[σ]] B[σ] : Type@i}}.
-    {
-      transitivity {{{B[Wk (σ,,M1[σ])]}}};
-        [| eapply exp_eq_sub_cong_typ2']; mauto 4.
-    }
-    assert {{ Γ M2[σ] : B[Wk][σ ,, M1[σ]]}} by mauto 3.
-    assert {{ Γ s σ,, M1[σ] : Δ,B}} by mauto 3.
-    assert {{ Γ s σ ,, M1[σ] ,, M2[σ] : Δ, B, B[Wk]}} by mauto 3.
-    assert {{ Δ, B, B[Wk] Eq (B[Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 4).
- -
-    assert {{Γ B[Wk][Wk][σ,,M1[σ],,M2[σ]] B[σ] : Type@i}}.
-    {
-      transitivity {{{B[Wk][Wk (σ,,M1[σ],,M2[σ])]}}};
-        [mauto 4 | transitivity {{{B[Wk][σ,,M1[σ]]}}}];
-        mauto 2.
-      eapply exp_eq_sub_cong_typ2';
-        mauto 4.
-    }
-    assert {{ Γ L[σ] : (Eq B M1 M2)[σ] }} by mauto 3.
-    assert {{ Γ L[σ] : Eq (B[σ]) (M1[σ]) (M2[σ]) }} by (eapply wf_conv; mauto 3).
-    assert {{ Γ L[σ] : (Eq (B[Wk][Wk]) #1 #0)[σ,,M1[σ],,M2[σ]] }}.
-    {
-      eapply wf_conv; mauto 2.
-      symmetry.
-      etransitivity.
-      - eapply wf_exp_eq_eq_sub; mauto.
-      - econstructor; mauto 3.
-        + eapply wf_exp_eq_conv;
-            [eapply sub_lookup_var1 with (B:=B) | |];
-            mauto 4.
-        + eapply wf_exp_eq_conv;
-            [eapply sub_lookup_var0 with (B:=B) | |];
-            mauto 4.
-    }
-    mauto 3.
+  assert {{ Γ s (q σWk)(Id,,M1[σ],,M2[σ]) : Δ, A }} by (econstructor; mauto 2).
+  assert {{ Γ s (q σWk)(Id,,M1[σ],,M2[σ]) σ,,M1[σ] : Δ, A }}.
+  {
+    etransitivity; [eapply wf_sub_eq_compose_assoc; mauto 3 |].
+    etransitivity;
+      [eapply wf_sub_eq_compose_cong;
+       [eapply wf_sub_eq_p_extend with (A:={{{A[σ][Wk]}}}) | eapply sub_eq_refl] |];
+      mauto 3.
+  }
+
+  assert {{ Γ A[Wk][(q σWk)(Id,,M1[σ],,M2[σ])] A[σ] : Type@i }}.
+  {
+    transitivity {{{ A[Wk][σ,,M1[σ]] }}};
+      [eapply exp_eq_sub_cong_typ2' |]; mauto 3.
+  }
+  assert {{ Γ #0[Id,,M1[σ],,M2[σ]] M2[σ] : A[Wk][(q σWk)(Id,,M1[σ],,M2[σ])] }} by (eapply wf_exp_eq_conv; revgoals; mauto 2).
+  assert {{ Γ s q (q σ)(Id,,M1[σ],,M2[σ]) σ,,M1[σ],,M2[σ] : Δ, A, A[Wk] }}
+    by (etransitivity; [eapply wf_sub_eq_extend_compose; mauto 2 | econstructor; mauto 2]).
+  assert {{ Γ s (q (q σ)Wk)(Id,,M1[σ],,M2[σ],,N[σ]) : Δ, A, A[Wk] }} by mauto 2.
+  assert {{ Γ s (q (q σ) Wk) (Id,,M1[σ],,M2[σ],,N[σ]) σ,,M1[σ],,M2[σ] : Δ, A, A[Wk] }}.
+  {
+    etransitivity;
+      [eapply wf_sub_eq_compose_assoc; mauto 2 |].
+    etransitivity;
+      [eapply wf_sub_eq_compose_cong;
+       [eapply wf_sub_eq_p_extend with (A:={{{ Eq A[σ][WkWk] #1 #0 }}}) | eapply sub_eq_refl] |];
+      mauto 3.
+  }
+
+  assert {{ Γ (Eq A[WkWk] #1 #0)[σ,,M1[σ],,M2[σ]] Eq A[σ] M1[σ] M2[σ] : Type@i }}
+    by (etransitivity; econstructor; mauto 3).
+  assert {{ Γ (Eq A[WkWk] #1 #0)[(q (q σ)Wk)(Id,,M1[σ],,M2[σ],,N[σ])] Eq A[σ] M1[σ] M2[σ] : Type@i }}.
+  {
+    transitivity {{{ (Eq A[WkWk] #1 #0)[σ,,M1[σ],,M2[σ]] }}};
+      [eapply exp_eq_sub_cong_typ2' |]; mauto 3.
+  }
+  assert {{ Γ #0[Id,,M1[σ],,M2[σ],,N[σ]] N[σ] : (Eq A[WkWk] #1 #0)[(q (q σ)Wk)(Id,,M1[σ],,M2[σ],,N[σ])] }}
+    by (eapply wf_exp_eq_conv with (A:={{{ Eq A[σ] M1[σ] M2[σ] }}}); [econstructor | |]; mauto 3).
+  assert {{ Γ s q (q (q σ))(Id,,M1[σ],,M2[σ],,N[σ]) σ,,M1[σ],,M2[σ],,N[σ] : Δ, A, A[Wk], Eq A[WkWk] #1 #0 }}.
+  {
+    etransitivity; [eapply wf_sub_eq_extend_compose; mauto 2 |].
+    econstructor; mauto 2.
+  }
+
+  assert {{Γ, A[σ] s (Id,,#0,,refl A[Wk] #0) q σ q (q (q σ))(Id,,#0,,refl A[σ][Wk] #0) : Δ, A, A[Wk], Eq A[WkWk] #1 #0}}
+    by mauto 3.
+ +
+  eapply wf_conv; [econstructor | |]; mauto 3.
+  - eapply wf_conv; mauto 2; mauto 3.
+  - etransitivity;
+      [eapply exp_eq_sub_compose_typ | eapply exp_eq_sub_cong_typ2'];
+      mauto 3.
+Qed.

-  - eapply wf_conv; [mauto 3 | mauto 2 |].
-    symmetry. mauto 3.
+#[local]
+Hint Resolve presup_exp_eq_eqrec_sub_right : mcltt.
+ +
+Lemma presup_exp_eq_refl_cong_right : forall {Γ i A A' M M'},
+    {{ Γ A : Type@i }} ->
+    {{ Γ A' : Type@i }} ->
+    {{ Γ A A' : Type@i }} ->
+    {{ Γ M : A }} ->
+    {{ Γ M' : A }} ->
+    {{ Γ M M' : A }} ->
+    {{ Γ refl A' M' : Eq A M M }}.
+Proof.
+  intros.
+  eapply wf_conv; mauto 3.
+  symmetry; mauto 3.
+Qed.

-  - assert {{ Γ s Id ,, M1 : Γ, B}} by mauto 4.
-    assert {{ Γ , B B[Wk] : Type@i }} by mauto 4.
-    assert {{ Γ , B , B[Wk] B[Wk][Wk] : Type@i }} by mauto 4.
-    assert {{ Γ B[Wk][Id,,M1] B : Type@i }}.
-    {
-      transitivity {{{B[Wk (Id,,M1)]}}};
-        [| transitivity {{{B[Id]}}}];
-        mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-    assert {{ Γ s Id ,, M1 ,, M2 : Γ, B , B[Wk]}}.
-    {
-      econstructor; mauto 3.
-      eapply wf_conv; mauto 2.
-    }
-    assert {{ Γ B[Wk][Wk][Id ,, M1 ,, M2] B : Type@i }}.
-    {
-      transitivity {{{B[Wk][Wk (Id ,, M1 ,, M2)]}}};
-        [| transitivity {{{B[Wk][Id ,, M1]}}}];
-        mauto 4.
-      eapply exp_eq_sub_cong_typ2'; mauto 4.
-      eapply wf_sub_eq_p_extend; mauto 4.
-    }
-    assert {{ Γ, B, B[Wk] Eq (B[Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 4).
-    assert {{ Γ #1[Id,,M1,,M2] M1 : B[Wk][Wk][Id,,M1,,M2] }}.
-    {
-      eapply wf_exp_eq_conv;
-        [eapply id_sub_lookup_var1 with (B:=B) | |];
-        mauto 4.
-    }
-    assert {{ Γ #0[Id,,M1,,M2] M2 : B[Wk][Wk][Id,,M1,,M2] }}.
-    {
-      eapply wf_exp_eq_conv;
-        [eapply id_sub_lookup_var0 with (B:=B) | |];
-        mauto 4.
-    }
-    assert {{ Γ L : (Eq (B[Wk][Wk]) #1 #0) [ Id ,, M1 ,, M2]}}.
-    {
-      eapply wf_conv; mauto 2.
-      symmetry.
-      etransitivity.
-      - eapply wf_exp_eq_eq_sub; mauto.
-      - econstructor; mauto 3.
-    }
-    assert {{ Γ s Id ,, M1 ,, M2 ,, L : Γ, B , B[Wk], Eq (B[Wk][Wk]) #1 #0}} by mauto 4.
-    assert {{ Γ Eq B' M1' M2' : Type @ i }} by mauto 4.
-    assert {{ Γ Eq B' M1' M2' Eq B M1 M2 : Type @ i }} by (symmetry; mauto 3).
- -
-    assert {{ Γ, B Γ, B' }} by mauto 3.
-    assert {{ Γ , B B'[Wk] : Type@i }} by mauto 4.
-    assert {{ Γ , B' B'[Wk] : Type@i }} by mauto 4.
-    assert {{ Γ, B B[Wk] B'[Wk] : Type@i }} by mauto 3.
-    assert {{ Γ, B' B[Wk] B'[Wk] : Type@i }} by mauto 3.
-    assert {{ Γ, B, B[Wk] Γ, B', B'[Wk] }} by mauto 4.
- -
-    assert {{ Γ, B', B'[Wk] Eq (B[Wk][Wk]) # 1 # 0 : Type@i }} by mauto 3.
-    assert {{ Γ, B', B'[Wk] Eq (B'[Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 4).
-    assert {{ Γ, B, B[Wk] Eq (B'[Wk][Wk]) # 1 # 0 : Type@i }} by mauto 3.
-    assert {{ (Γ, B), B[Wk] Eq B[Wk][Wk] #1 #0 Eq B'[Wk][Wk] #1 #0 : Type@i }} by (econstructor; mauto 4).
- -
-    assert {{ Γ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0 Γ, B', B'[Wk], Eq (B'[Wk][Wk]) #1 #0 }} by mauto 3.
- -
-    assert {{ Γ, B Eq B[Wk] #0 #0 : Type@i }} by (econstructor; mauto 2).
-    assert {{ Γ, B Eq B'[Wk] #0 #0 Eq B[Wk] #0 #0 : Type@i }} by (econstructor; mauto 3).
- -
-    assert {{ Γ, B refl B'[Wk] #0 : Eq (B[Wk]) #0 #0 }}.
-    {
-      eapply wf_conv;
-      [econstructor | |]; mauto 3.
-    }
-    assert {{ Γ, B refl B[Wk] #0 : Eq (B[Wk]) #0 #0 }} by mauto 4.
-    assert {{ Γ, B refl B[Wk] #0 refl B'[Wk] #0 : Eq (B[Wk]) #0 #0 }} by mauto 3.
-    assert {{ Γ, B s Id,,#0 : Γ, B, B[Wk] }} by mauto 3.
-    assert {{ (Γ, B), B[Wk] #1 : B[Wk][Wk] }} by mauto 4.
-    assert {{ Γ, B s Wk(Id,,#0) : Γ, B }} by (econstructor; mauto 3).
-    assert {{ Γ, B B[Wk][Wk][Id,,#0] B[Wk] : Type@i }}.
-    {
-      transitivity {{{B[Wk][Wk (Id,,#0)]}}};
-        [eapply exp_eq_sub_compose_typ |
-         transitivity {{{B[Wk][Id]}}} ];
-        mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-    assert {{ Γ, B #1[Id,,#0] #0 : B[Wk] }}.
-    {
-      transitivity {{{#0[Id]}}}.
-      - eapply wf_exp_eq_conv;
-          [eapply wf_exp_eq_var_S_sub with (A:={{{B[Wk]}}}) | |];
-          mauto 3.
-      - mauto 3.
-    }
-    assert {{ Γ, B #1[Id,,#0] #0 : B[Wk][Wk][Id,,#0] }} by mauto 4.
-    assert {{ Γ, B #0[Id,,#0] #0 : B[Wk] }}.
-    {
-      eapply wf_exp_eq_conv;
-        [eapply wf_exp_eq_var_0_sub with (A:={{{B[Wk]}}}) | |];
+#[local]
+Hint Resolve presup_exp_eq_refl_cong_right : mcltt.
+ +
+Lemma presup_exp_eq_eqrec_cong_right : forall {Γ i A A' M1 M1' M2 M2' j B B' BR BR' N N'},
+    {{ Γ A : Type@i }} ->
+    {{ Γ M1 : A }} ->
+    {{ Γ M2 : A }} ->
+    {{ Γ A' : Type@i }} ->
+    {{ Γ A A' : Type@i }} ->
+    {{ Γ M1' : A }} ->
+    {{ Γ M1 M1' : A }} ->
+    {{ Γ M2' : A }} ->
+    {{ Γ M2 M2' : A }} ->
+    {{ Γ, A, A[Wk], Eq A[WkWk] #1 #0 B : Type@j }} ->
+    {{ Γ, A, A[Wk], Eq A[WkWk] #1 #0 B' : Type@j }} ->
+    {{ Γ, A, A[Wk], Eq A[WkWk] #1 #0 B B' : Type@j }} ->
+    {{ Γ, A BR : B[Id,,#0,,refl A[Wk] #0] }} ->
+    {{ Γ, A BR' : B[Id,,#0,,refl A[Wk] #0] }} ->
+    {{ Γ, A BR BR' : B[Id,,#0,,refl A[Wk] #0] }} ->
+    {{ Γ N : Eq A M1 M2 }} ->
+    {{ Γ N' : Eq A M1 M2 }} ->
+    {{ Γ N N' : Eq A M1 M2 }} ->
+    {{ Γ eqrec N' as Eq A' M1' M2' return B' | refl -> BR' end : B[Id,,M1,,M2,,N] }}.
+Proof.
+  intros.
+  assert {{ Γ }} by mauto 4.
+  assert {{ Γ s Id,,M1 : Γ, A}} by mauto 4.
+  assert {{ Γ, A }} by mauto 4.
+  assert {{ Γ, A A[Wk] : Type@i }} by mauto 4.
+  assert {{ Γ, A, A[Wk] }} by mauto 4.
+  assert {{ Γ, A, A[Wk] s WkWk : Γ }} by mauto 4.
+  assert {{ Γ, A, A[Wk] A[WkWk] : Type@i }} by mauto 2.
+  assert {{ Γ A[Wk][Id,,M1] A : Type@i }} by mauto 2.
+  assert {{ Γ s Id,,M1,,M2 : Γ, A, A[Wk]}} by mauto 2.
+  assert {{ Γ A[WkWk][Id,,M1,,M2] A : Type@i }}.
+  {
+    eapply exp_eq_sub_compose_double_weaken_id_double_extend_typ; revgoals; try eassumption.
+    eapply wf_conv; mauto 3.
+  }
+  assert {{ Γ, A, A[Wk] Eq A[WkWk] # 1 # 0 : Type@i }} by (econstructor; mauto 3; eapply var_compose_subs; mauto 2).
+  assert {{ Γ #1[Id,,M1,,M2] M1 : A[WkWk][Id,,M1,,M2] }}
+    by (eapply wf_exp_eq_conv; mauto 2 using id_sub_lookup_var1).
+  assert {{ Γ #0[Id,,M1,,M2] M2 : A[WkWk][Id,,M1,,M2] }}
+    by (eapply wf_exp_eq_conv; mauto 2 using id_sub_lookup_var0).
+  assert {{ Γ N : (Eq A[WkWk] #1 #0)[Id,,M1,,M2]}}.
+  {
+    eapply wf_conv; mauto 2.
+    symmetry; mauto 2.
+  }
+  assert {{ Γ s Id,,M1,,M2,,N : Γ, A , A[Wk], Eq A[WkWk] #1 #0}} by mauto 2.
+  assert {{ Γ Eq A' M1' M2' : Type@i }} by mauto 4.
+  assert {{ Γ Eq A' M1' M2' Eq A M1 M2 : Type @ i }} by mauto 3.
+ +
+  assert {{ Γ, A Γ, A' }} by mauto 3.
+  assert {{ Γ , A A'[Wk] : Type@i }} by mauto 3.
+  assert {{ Γ , A' A'[Wk] : Type@i }} by mauto 2.
+  assert {{ Γ, A A[Wk] A'[Wk] : Type@i }} by mauto 3.
+  assert {{ Γ, A' A[Wk] A'[Wk] : Type@i }} by mauto 2.
+  assert {{ Γ, A, A[Wk] Γ, A', A'[Wk] }} by mauto 3.
+ +
+  assert {{ Γ, A', A'[Wk] Eq A[WkWk] # 1 # 0 : Type@i }} by mauto 2.
+  assert {{ Γ, A', A'[Wk] Eq A'[WkWk] # 1 # 0 : Type@i }} by (econstructor; mauto 3).
+  assert {{ Γ, A, A[Wk] Eq A'[WkWk] # 1 # 0 : Type@i }} by mauto 3.
+  assert {{ Γ, A, A[Wk] Eq A[WkWk] #1 #0 Eq A'[WkWk] #1 #0 : Type@i }} by (econstructor; mauto 3).
+ +
+  assert {{ Γ, A, A[Wk], Eq A[WkWk] #1 #0 Γ, A', A'[Wk], Eq A'[WkWk] #1 #0 }} by mauto 3.
+ +
+  assert {{ Γ, A Eq A[Wk] #0 #0 : Type@i }} by (econstructor; mauto 2).
+  assert {{ Γ, A Eq A'[Wk] #0 #0 Eq A[Wk] #0 #0 : Type@i }} by (econstructor; mauto 3).
+ +
+  assert {{ Γ, A refl A'[Wk] #0 : Eq A[Wk] #0 #0 }}
+    by (eapply wf_conv; [econstructor | |]; mauto 3).
+  assert {{ Γ, A refl A[Wk] #0 : Eq A[Wk] #0 #0 }} by mauto 3.
+  assert {{ Γ, A refl A[Wk] #0 refl A'[Wk] #0 : Eq A[Wk] #0 #0 }} by mauto 3.
+  assert {{ Γ, A s Id,,#0 : Γ, A, A[Wk] }} by mauto 3.
+  assert {{ Γ, A s Wk : Γ }} by mauto 2.
+  assert {{ Γ, A, A[Wk] #1 : A[WkWk] }} by mauto 2.
+  assert {{ Γ, A s Wk(Id,,#0) : Γ, A }} by (econstructor; mauto 2).
+  assert {{ Γ, A A[WkWk][Id,,#0] A[Wk] : Type@i }}.
+  {
+    transitivity {{{ A[Wk][Wk][Id,,#0] }}}; [| mauto 3].
+    eapply exp_eq_sub_cong_typ1; mauto 2.
+    symmetry; mauto 3.
+  }
+  assert {{ Γ, A #1[Id,,#0] #0 : A[Wk] }}.
+  {
+    transitivity {{{ #0[Id] }}}.
+    - eapply wf_exp_eq_conv;
+        [eapply wf_exp_eq_var_S_sub with (A:={{{A[Wk]}}}) | |];
        mauto 3.
-    }
-    assert {{ Γ, B #0[Id,,#0] #0 : B[Wk][Wk][Id,,#0] }} by mauto 4.
-    assert {{ Γ, B (Eq B[Wk][Wk] #1 #0)[Id,,#0] Eq (B[Wk]) #0 #0 : Type@i }}.
-    {
-      etransitivity; econstructor; mauto 3.
-    }
-    assert {{ Γ, B refl B'[Wk] #0 : (Eq B[Wk][Wk] #1 #0)[Id,,#0] }} by mauto 4.
-    assert {{ Γ, B refl B[Wk] #0 : (Eq B[Wk][Wk] #1 #0)[Id,,#0] }} by mauto 4.
-    assert {{ Γ, B s Id,,#0,,refl B'[Wk] #0 : Γ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0 }} by mauto 4.
-    assert {{ Γ, B s Id,,#0,,refl B[Wk] #0 : Γ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0 }} by mauto 4.
+    - mauto 3.
+  }
+  assert {{ Γ, A #1[Id,,#0] #0 : A[WkWk][Id,,#0] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ, A #0[Id,,#0] #0 : A[Wk] }}.
+  {
+    eapply wf_exp_eq_conv;
+      [eapply wf_exp_eq_var_0_sub with (A:={{{A[Wk]}}}) | |];
+      mauto 3.
+  }
+  assert {{ Γ, A #0[Id,,#0] #0 : A[WkWk][Id,,#0] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ, A (Eq A[WkWk] #1 #0)[Id,,#0] Eq A[Wk] #0 #0 : Type@i }}
+    by (etransitivity; econstructor; mauto 3).
+  assert {{ Γ, A refl A'[Wk] #0 : (Eq A[WkWk] #1 #0)[Id,,#0] }} by (eapply wf_conv; mauto 2).
+  assert {{ Γ, A refl A[Wk] #0 : (Eq A[WkWk] #1 #0)[Id,,#0] }} by (eapply wf_conv; mauto 2).
+  assert {{ Γ, A s Id,,#0,,refl A'[Wk] #0 : Γ, A, A[Wk], Eq A[WkWk] #1 #0 }} by mauto 2.
+  assert {{ Γ, A s Id,,#0,,refl A[Wk] #0 : Γ, A, A[Wk], Eq A[WkWk] #1 #0 }} by mauto 2.

-    assert {{ Γ, B s Id,,#0,,refl B[Wk] #0 Id,,#0,,refl B'[Wk] #0 : Γ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0 }}
-      by (econstructor; mauto 4).
+  assert {{ Γ, A s Id,,#0,,refl A[Wk] #0 Id,,#0,,refl A'[Wk] #0 : Γ, A, A[Wk], Eq A[WkWk] #1 #0 }}
+    by (econstructor; [| | eapply wf_exp_eq_conv]; mauto 2).

-    assert {{ Γ, B C[Id,,#0,,refl B[Wk] #0] C'[Id,,#0,,refl B'[Wk] #0] : Type@j }}.
-    {
-      etransitivity;
-        [eapply exp_eq_sub_cong_typ2' |
-          eapply exp_eq_sub_cong_typ1];
-        mauto 3.
-    }
+  assert {{ Γ, A B[Id,,#0,,refl A[Wk] #0] B'[Id,,#0,,refl A'[Wk] #0] : Type@j }}.
+  {
+    etransitivity;
+      [eapply exp_eq_sub_cong_typ2' |
+        eapply exp_eq_sub_cong_typ1];
+      mauto 3.
+  }

-    assert {{ Γ M1 M1' : B[Id] }} by (eapply wf_exp_eq_conv; mauto 3).
-    assert {{ Γ s Id,,M1 Id,,M1' : Γ, B }} by mauto 3.
-    assert {{ Γ M2 M2' : B[Wk][Id,,M1] }} by (eapply wf_exp_eq_conv; mauto 3).
-    assert {{ Γ s Id,,M1,,M2 Id,,M1',,M2' : Γ, B, B[Wk] }} by mauto 3.
+  assert {{ Γ M1 M1' : A[Id] }} by (eapply wf_exp_eq_conv; mauto 3).
+  assert {{ Γ s Id,,M1 Id,,M1' : Γ, A }} by mauto 2.
+  assert {{ Γ M2 M2' : A[Wk][Id,,M1] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ s Id,,M1,,M2 Id,,M1',,M2' : Γ, A, A[Wk] }} by mauto 2.

-    assert {{ Γ (Eq B[Wk][Wk] #1 #0)[Id,,M1,,M2] Eq B M1 M2 : Type@i }}.
-    {
-      etransitivity;
-        econstructor; mauto 3.
-    }
-    assert {{ Γ s Id,,M1,,M2,,L Id,,M1',,M2',,L' : Γ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0 }}
-      by (econstructor; mauto 4).
+  assert {{ Γ (Eq A[WkWk] #1 #0)[Id,,M1,,M2] Eq A M1 M2 : Type@i }} by mauto 2.
+  assert {{ Γ s Id,,M1,,M2,,N Id,,M1',,M2',,N' : Γ, A, A[Wk], Eq (A[WkWk]) #1 #0 }}
+    by (econstructor; [| | eapply wf_exp_eq_conv]; mauto 2).

-    assert {{ Γ s Id ,, M1' : Γ, B}} by mauto 4.
-    assert {{ Γ B[Wk][Id,,M1'] B : Type@i }}.
-    {
-      transitivity {{{B[Wk (Id,,M1')]}}};
-        [| transitivity {{{B[Id]}}}];
-        mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-    assert {{ Γ M2' : B[Wk][Id,,M1'] }} by mauto 4.
-    assert {{ Γ s Id,,M1',,M2' : Γ, B, B[Wk]}} by mauto 3.
- -
-    assert {{ Γ (Eq B[Wk][Wk] #1 #0)[Id,,M1',,M2'] Eq B M1 M2 : Type@i }}.
-    {
-      etransitivity;
-        [eapply exp_eq_sub_cong_typ2' | ];
-        cycle 1.
-      - eauto.
-      - symmetry. eauto.
-      - eauto.
-      - eauto.
-    }
-    assert {{ Γ L' : (Eq B[Wk][Wk] #1 #0)[Id,,M1',,M2'] }} by mauto 4.
-    assert {{ Γ s Id,,M1',,M2',,L' : ((Γ, B), B[Wk]), Eq B[Wk][Wk] #1 #0 }} by mauto 3.
+  assert {{ Γ s Id,,M1' : Γ, A}} by mauto 2.
+  assert {{ Γ A[Wk][Id,,M1'] A : Type@i }}.
+  {
+    transitivity {{{A[Wk (Id,,M1')]}}};
+      [| transitivity {{{A[Id]}}}];
+      mauto 2.
+    eapply exp_eq_sub_cong_typ2'; mauto 2.
+  }
+  assert {{ Γ M2' : A[Wk][Id,,M1'] }} by (eapply wf_conv; mauto 2).
+  assert {{ Γ s Id,,M1',,M2' : Γ, A, A[Wk]}} by mauto 2.

+  assert {{ Γ (Eq A[WkWk] #1 #0)[Id,,M1',,M2'] Eq A M1 M2 : Type@i }}
+    by (transitivity {{{ Eq A M1' M2' }}}; [mauto 2 | econstructor; mauto 2]).
+  assert {{ Γ N' : (Eq A[WkWk] #1 #0)[Id,,M1',,M2'] }} by (eapply wf_conv; mauto 2).
+  assert {{ Γ s Id,,M1',,M2',,N' : Γ, A, A[Wk], Eq A[WkWk] #1 #0 }} by mauto 2.
+ +
+  eapply wf_conv;
+    [econstructor; mauto 3 | mauto 2 | ].
+  - eapply ctxeq_exp; eauto.
    eapply wf_conv;
-      [econstructor; mauto 3 | mauto 2 | ].
-    + eapply ctxeq_exp; eauto.
-      eapply wf_conv;
-        mauto 2.
-    + etransitivity;
-        [eapply exp_eq_sub_cong_typ2' |
-          eapply exp_eq_sub_cong_typ1];
-        mauto 3.
+      mauto 2.
+  - etransitivity;
+      [eapply exp_eq_sub_cong_typ2' |
+        eapply exp_eq_sub_cong_typ1];
+      mauto 2.
+Qed.

-  - eexists.
-    eapply exp_sub_typ; mauto 2.
-    assert {{ Γ s Id ,, M1 : Γ, B}} by mauto 4.
-    assert {{ Γ , B B[Wk] : Type@i }} by mauto 4.
-    assert {{ Γ , B , B[Wk] B[Wk][Wk] : Type@i }} by mauto 4.
-    assert {{ Γ B[Wk][Id,,M1] B : Type@i }}.
-    {
-      transitivity {{{B[Wk (Id,,M1)]}}};
-        [| transitivity {{{B[Id]}}}];
+#[local]
+Hint Resolve presup_exp_eq_eqrec_cong_right : mcltt.
+ +
+Lemma presup_exp_eq_eqrec_beta_right : forall {Γ i A M j B BR},
+    {{ Γ A : Type@i }} ->
+    {{ Γ M : A }} ->
+    {{ Γ , A , A[Wk], Eq A[WkWk] #1 #0 B : Type@j }} ->
+    {{ Γ , A BR : B[Id,,#0,,refl A[Wk] #0] }} ->
+    {{ Γ BR[Id,,M] : B[Id,,M,,M,,refl A M] }}.
+Proof.
+  intros.
+  assert {{ Γ s Id,,M : Γ, A }} by mauto 4.
+  assert {{ Γ, A A[Wk] : Type@i }} by mauto 4.
+  assert {{ Γ, A, A[Wk] s Wk : Γ, A }} by mauto 4.
+  assert {{ Γ, A, A[Wk] s WkWk : Γ }} by mauto 4.
+  assert {{ Γ, A, A[Wk] A[WkWk] : Type@i }} by mauto 4.
+  assert {{ Γ A[Wk][Id,,M] A : Type@i }} by mauto 3.
+  assert {{ Γ s Id,,M,,M : Γ, A, A[Wk] }} by mauto 2.
+  assert {{ Γ A[WkWk][Id,,M,,M] A : Type@i }}.
+  {
+    eapply exp_eq_sub_compose_double_weaken_id_double_extend_typ; mauto 2.
+    eapply wf_conv; mauto 2.
+  }
+  assert {{ Γ, A, A[Wk] Eq A[WkWk] # 1 # 0 : Type@i }} by mauto 2.
+  assert {{ Γ refl A M : Eq A M M}} by mauto 2.
+  assert {{ Γ refl A M : (Eq A[WkWk] #1 #0)[Id,,M,,M]}}.
+  {
+    eapply wf_conv; mauto 2.
+    symmetry.
+    mauto 3.
+  }
+  assert {{Γ, A s Id,,#0 : Γ, A, A[Wk] }} by mauto 4.
+ +
+  assert {{ Γ, A refl A[Wk] #0 : Eq A[Wk] #0 #0 }} by mauto 4.
+  assert {{ Γ, A, A[Wk] #1 : A[WkWk] }} by mauto 2.
+  assert {{ Γ, A }} by mauto 2.
+  assert {{ Γ, A s Wk : Γ }} by mauto 2.
+  assert {{ Γ, A s Wk(Id,,#0) : Γ, A }} by mauto 2.
+  assert {{ Γ, A A[WkWk][Id,,#0] A[Wk] : Type@i }}
+    by (transitivity {{{ A[Wk][Wk][Id,,#0] }}}; [symmetry |]; mauto 3).
+  assert {{ Γ, A #1[Id,,#0] #0 : A[Wk] }}.
+  {
+    transitivity {{{ #0[Id] }}}.
+    - eapply wf_exp_eq_conv;
+        [eapply wf_exp_eq_var_S_sub with (A:={{{A[Wk]}}}) | |];
        mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-    assert {{ Γ s Id ,, M1 ,, M2 : Γ, B , B[Wk]}}.
-    {
-      econstructor; mauto 3.
-      eapply wf_conv; mauto 2.
-    }
-    assert {{ Γ B[Wk][Wk][Id ,, M1 ,, M2] B : Type@i }}.
-    {
-      transitivity {{{B[Wk][Wk (Id ,, M1 ,, M2)]}}};
-        [| transitivity {{{B[Wk][Id ,, M1]}}}];
+    - mauto 3.
+  }
+  assert {{ Γ, A #1[Id,,#0] #0 : A[WkWk][Id,,#0] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ, A #0[Id,,#0] #0 : A[Wk] }}.
+  {
+    eapply wf_exp_eq_conv;
+      [eapply wf_exp_eq_var_0_sub with (A:={{{A[Wk]}}}) | |];
+      mauto 3.
+  }
+  assert {{ Γ, A #0[Id,,#0] #0 : A[WkWk][Id,,#0] }} by (eapply wf_exp_eq_conv; mauto 2).
+  assert {{ Γ, A (Eq A[WkWk] #1 #0)[Id,,#0] Eq A[Wk] #0 #0 : Type@i }}
+    by (etransitivity; econstructor; mauto 2).
+  assert {{ Γ, A refl A[Wk] #0 : (Eq A[WkWk] #1 #0)[Id,,#0] }} by (eapply wf_conv; mauto 2).
+  assert {{ Γ, A s Id,,#0,,refl A[Wk] #0 : Γ, A, A[Wk], Eq A[WkWk] #1 #0 }} by mauto 2.
+ +
+  assert {{ Γ, A #0 : A[Wk][Id] }} by mauto 3.
+ +
+  assert {{ Γ A[Wk][Id(Id,,M)] A : Type@i }}.
+  {
+    transitivity {{{ A[Wk][Id,,M] }}}; mauto 3.
+    eapply exp_eq_sub_cong_typ2'; mauto 3.
+  }
+  assert {{ Γ s Id : Γ }} by mauto 3.
+  assert {{ Γ #0[Id,,M] M : A }}
+    by (eapply wf_exp_eq_conv with (A:={{{A[Id]}}}); mauto 3).
+  assert {{ Γ A[Wk][Id(Id,,M)] : Type@i }} by mauto 4.
+  assert {{ Γ #0[Id,,M] M : A[Wk][Id(Id,,M)] }} by mauto 3.
+ +
+  assert {{ Γ s Id(Id,,M),,#0[Id,,M] Id,,M,,M : (Γ, A), A[Wk] }} by mauto 3.
+  assert {{ Γ s (Id,,#0)(Id,,M) Id,,M,,M : (Γ, A), A[Wk] }}.
+  {
+    etransitivity;
+      [eapply wf_sub_eq_extend_compose |];
+      mauto 2.
+  }
+
+  assert {{ Γ #1[Id,,M,,M] M : A }}.
+  {
+    transitivity {{{ #0[Id,,M] }}}.
+    - eapply wf_exp_eq_conv;
+        [eapply wf_exp_eq_var_S_sub with (A:={{{ A[Wk] }}}) | |];
        mauto 4.
-      eapply exp_eq_sub_cong_typ2'; mauto 4.
-      eapply wf_sub_eq_p_extend; mauto 4.
-    }
-    assert {{ Γ, B, B[Wk] Eq (B[Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 4).
-    assert {{ Γ L : (Eq (B[Wk][Wk]) #1 #0) [ Id ,, M1 ,, M2]}}.
-    {
-      eapply wf_conv; mauto 2.
-      symmetry.
-      etransitivity.
-      - eapply wf_exp_eq_eq_sub; mauto.
-      - econstructor; mauto 3.
-        + eapply wf_exp_eq_conv;
-            [eapply id_sub_lookup_var1 with (B:=B) | |];
-            mauto 4.
-        + eapply wf_exp_eq_conv;
-            [eapply id_sub_lookup_var0 with (B:=B) | |];
-            mauto 4.
-    }
-    mauto 3.
+    - mauto 3.
+  }
+  assert {{ Γ s Wk(Id,,M,,M) : Γ, A }} by (eapply wf_sub_conv; mauto 2).
+  assert {{ Γ s Wk(Id,,M,,M) Id,,M : Γ, A }}
+    by (econstructor; [| | eapply wf_conv]; mauto 2).
+  assert {{ Γ A[WkWk][Id,,M,,M] A : Type@i }} by mauto 3.
+  assert {{ Γ #1[Id,,M,,M] M : A[WkWk][Id,,M,,M] }} by (eapply wf_exp_eq_conv; mauto 2).
+ +
+  assert {{ Γ #0[Id,,M,,M] M : A }}.
+  {
+    eapply wf_exp_eq_conv with (A:={{{A[Wk][Id,,M]}}});
+      [econstructor | |];
+      mauto 4.
+  }
+  assert {{ Γ #0[Id,,M,,M] M : A[WkWk][Id,,M,,M] }} by (eapply wf_exp_eq_conv; mauto 2).

-  - clear HAi1 HAi2.
-    assert {{ Γ s Id ,, N : Γ, B}} by mauto 4.
-    assert {{ Γ , B B[Wk] : Type@i }} by mauto 4.
-    assert {{ Γ , B , B[Wk] B[Wk][Wk] : Type@i }} by mauto 4.
-    assert {{ Γ B[Wk][Id,,N] B : Type@i }}.
-    {
-      transitivity {{{B[Wk (Id,,N)]}}};
-        [| transitivity {{{B[Id]}}}];
-        mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-    assert {{ Γ s Id ,, N ,, N : Γ, B , B[Wk]}}.
-    {
-      econstructor; mauto 3.
-      eapply wf_conv; mauto 2.
-    }
-    assert {{ Γ B[Wk][Wk][Id ,, N ,, N] B : Type@i }}.
-    {
-      transitivity {{{B[Wk][Wk (Id ,, N ,, N)]}}};
-        [| transitivity {{{B[Wk][Id ,, N]}}}];
-        mauto 4.
-      eapply exp_eq_sub_cong_typ2'; mauto 4.
-      eapply wf_sub_eq_p_extend; mauto 4.
-    }
-    assert {{ Γ, B, B[Wk] Eq (B[Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 4).
-    assert {{ Γ refl B N : Eq B N N}} by mauto 3.
-    assert {{ Γ refl B N : (Eq (B[Wk][Wk]) #1 #0) [ Id ,, N ,, N]}}.
-    {
-      eapply wf_conv; mauto 2.
-      symmetry.
-      etransitivity.
-      - eapply wf_exp_eq_eq_sub; mauto.
-      - econstructor; mauto 3.
-        + eapply wf_exp_eq_conv;
-            [eapply id_sub_lookup_var1 with (B:=B) | |];
-            mauto 4.
-        + eapply wf_exp_eq_conv;
-            [eapply id_sub_lookup_var0 with (B:=B) | |];
-            mauto 4.
-    }
-    assert {{Γ, B s Id,, #0 : Γ, B, B[Wk] }} by mauto 3.
- -
-    assert {{ Γ, B refl B[Wk] #0 : Eq (B[Wk]) #0 #0 }} by mauto 4.
-    assert {{ Γ, B s Id,,#0 : Γ, B, B[Wk] }} by mauto 3.
-    assert {{ (Γ, B), B[Wk] #1 : B[Wk][Wk] }} by mauto 4.
-    assert {{ Γ, B s Wk(Id,,#0) : Γ, B }} by (econstructor; mauto 3).
-    assert {{ Γ, B B[Wk][Wk][Id,,#0] B[Wk] : Type@i }}.
-    {
-      transitivity {{{B[Wk][Wk (Id,,#0)]}}};
-        [eapply exp_eq_sub_compose_typ |
-         transitivity {{{B[Wk][Id]}}} ];
-        mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-    assert {{ Γ, B #1[Id,,#0] #0 : B[Wk] }}.
-    {
-      transitivity {{{#0[Id]}}}.
-      - eapply wf_exp_eq_conv;
-          [eapply wf_exp_eq_var_S_sub with (A:={{{B[Wk]}}}) | |];
-          mauto 3.
-      - mauto 3.
-    }
-    assert {{ Γ, B #1[Id,,#0] #0 : B[Wk][Wk][Id,,#0] }} by mauto 4.
-    assert {{ Γ, B #0[Id,,#0] #0 : B[Wk] }}.
-    {
-      eapply wf_exp_eq_conv;
-        [eapply wf_exp_eq_var_0_sub with (A:={{{B[Wk]}}}) | |];
-        mauto 3.
-    }
-    assert {{ Γ, B #0[Id,,#0] #0 : B[Wk][Wk][Id,,#0] }} by mauto 4.
-    assert {{ Γ, B (Eq B[Wk][Wk] #1 #0)[Id,,#0] Eq (B[Wk]) #0 #0 : Type@i }}.
-    {
-      etransitivity; econstructor; mauto 3.
-    }
-    assert {{ Γ, B refl B[Wk] #0 : (Eq B[Wk][Wk] #1 #0)[Id,,#0] }} by mauto 4.
-    assert {{ Γ, B s Id,,#0,,refl B[Wk] #0 : Γ, B, B[Wk], Eq (B[Wk][Wk]) #1 #0 }} by mauto 4.
+  assert {{ Γ (Eq A[WkWk] #1 #0)[(Id,,#0)(Id,,M)] Eq A M M : Type@i }}
+    by (etransitivity; [eapply exp_eq_sub_cong_typ2' | ]; mauto 2).

-    assert {{ Γ, B #0 : B[Wk][Id] }} by mauto 3.
+  assert {{ Γ (Eq A[WkWk] #1 #0)[Id,,#0][Id,,M] Eq A M M : Type@i }}
+    by (etransitivity; mauto 4).
+  assert {{ Γ Eq A M M : Type@i }} by mauto 2.

-    assert {{ Γ B[Wk][Id(Id,,N)] B : Type@i }}.
-    {
-      transitivity {{{B[Wk][Id,,N]}}}; mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-    assert {{ Γ #0[Id,,N] N : B }}.
-    {
-      eapply wf_exp_eq_conv with (A:={{{B[Id]}}}); mauto 4.
-    }
-    assert {{ Γ B[Wk][Id(Id,,N)] : Type@i }} by mauto 4.
-    assert {{ Γ #0[Id,,N] N : B[Wk][Id(Id,,N)] }} by mauto 3.
+  assert {{ Γ #0[Id,,M] M : A }} by eassumption.
+  assert {{ Γ #0[Id,,M] M : A[Wk][Id,,M] }} by (eapply wf_exp_eq_conv; mauto 2).

-    assert {{ Γ s Id(Id,,N),,#0[Id,,N] Id,,N,,N : (Γ, B), B[Wk] }} by mauto 3.
-    assert {{ Γ s (Id,,#0)(Id,,N) Id,,N,,N : (Γ, B), B[Wk] }}.
-    {
-      etransitivity;
-        [eapply wf_sub_eq_extend_compose |];
-        mauto 2.
-    }
-
-    assert {{ Γ #1[Id,,N,,N] N : B }}.
-    {
-      transitivity {{{#0[Id,,N]}}}.
-      - eapply wf_exp_eq_conv;
-          [eapply wf_exp_eq_var_S_sub with (A:={{{B[Wk]}}}) | |];
-          mauto 4.
-      - mauto 3.
-    }
-    assert {{ Γ s Wk(Id,,N,,N) : Γ, B }} by mauto 4.
-    assert {{ Γ s Wk(Id,,N,,N) Id,,N : Γ, B }}
-      by (econstructor; mauto 4).
-    assert {{ Γ B[Wk][Wk][Id,,N,,N] B : Type@i }}.
-    {
-      transitivity {{{B[Wk][Wk (Id,,N,,N)]}}};
-        [eapply exp_eq_sub_compose_typ |];
-        mauto 3.
-    }
-    assert {{ Γ #1[Id,,N,,N] N : B[Wk][Wk][Id,,N,,N] }} by mauto 4.
+  assert {{ Γ (refl A[Wk] #0)[Id,,M] refl A M : Eq A M M }}.
+  {
+    etransitivity.
+    - eapply wf_exp_eq_conv;
+        [eapply wf_exp_eq_refl_sub | | ]; mauto 4.
+    - eapply wf_exp_eq_conv; [econstructor | | econstructor]; mauto 3.
+  }
+
+  assert {{ Γ (refl A[Wk] #0)[Id,,M] refl A M : (Eq A[WkWk] #1 #0)[(Id,,#0)(Id,,M)] }}
+    by (eapply wf_exp_eq_conv; mauto 3).
+ +
+  eapply wf_conv; mauto 3.
+  etransitivity.
+  - eapply exp_eq_sub_compose_typ; mauto 2.
+  - symmetry.
+    eapply exp_eq_sub_cong_typ2'; mauto 2.
+    symmetry.
+    etransitivity;
+      [eapply wf_sub_eq_extend_compose |];
+      mauto 2.
+Qed.

-    assert {{ Γ #0[Id,,N,,N] N : B }}.
-    {
-      eapply wf_exp_eq_conv with (A:={{{B[Wk][Id,,N]}}});
-        [econstructor | |];
-        mauto 4.
-    }
-    assert {{ Γ #0[Id,,N,,N] N : B[Wk][Wk][Id,,N,,N] }} by mauto 4.
- -
-    assert {{ Γ (Eq B[Wk][Wk] #1 #0)[(Id,,#0)(Id,,N)] Eq B N N : Type@i }}.
-    {
-      etransitivity;
-        [eapply exp_eq_sub_cong_typ2' | ]; mauto 2.
-      etransitivity;
-        econstructor; mauto 3.
-    }
-
-    assert {{ Γ (Eq B[Wk][Wk] #1 #0)[Id,,#0][Id,,N] Eq B N N : Type@i }}.
-    {
-      etransitivity; eauto.
-      eapply exp_eq_sub_compose_typ; mauto 3.
-    }
-    assert {{ Γ Eq B N N : Type@i }} by mauto 3.
- -
-    assert {{ Γ #0[Id,,N] N : B }}.
-    {
-      eapply wf_exp_eq_conv with (A:={{{B[Id]}}});
-        [econstructor | |];
-        mauto 4.
-    }
-    assert {{ Γ #0[Id,,N] N : B[Wk][Id,,N] }} by mauto 4.
+#[local]
+Hint Resolve presup_exp_eq_eqrec_beta_right : mcltt.
+ +
+Lemma presup_exp_eq_var_0_sub_left : forall {Γ σ Δ i A M},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Γ M : A[σ] }} ->
+    {{ Γ #0[σ,,M] : A[σ] }}.
+Proof.
+  intros.
+  assert {{ Δ, A }} by mauto 3.
+  assert {{ Δ, A #0 : A[Wk] }} by mauto 2.
+  eapply wf_conv; mauto 3.
+Qed.

-    assert {{ Γ (refl B[Wk] #0)[Id,,N] refl B N : Eq B N N }}.
-    {
-      etransitivity.
-      - eapply wf_exp_eq_conv;
-          [eapply wf_exp_eq_refl_sub | | ]; mauto 4.
-      - eapply wf_exp_eq_conv; [econstructor | | econstructor]; mauto 3.
-    }
+#[local]
+Hint Resolve presup_exp_eq_var_0_sub_left : mcltt.
+ +
+Lemma presup_exp_eq_var_S_sub_left : forall {Γ σ Δ i A M B x},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Γ M : A[σ] }} ->
+    {{ #x : B Δ }} ->
+    {{ Γ #(S x)[σ,,M] : B[σ] }}.
+Proof.
+  intros.
+  assert {{ Δ }} by mauto 2.
+  assert {{ Δ, A }} by mauto 2.
+  assert (exists j, {{ Δ B : Type@j }}) as [j] by mauto 2.
+  assert {{ Δ, A #(S x) : B[Wk] }} by mauto 3.
+  eapply wf_conv; mauto 3.
+Qed.
+
-    assert {{ Γ (refl B[Wk] #0)[Id,,N] refl B N : (Eq B[Wk][Wk] #1 #0)[(Id,,#0)(Id,,N)] }}
-             by (eapply wf_exp_eq_conv; mauto 4).
+#[local]
+Hint Resolve presup_exp_eq_var_S_sub_left : mcltt.
+ +
+Lemma presup_exp_eq_sub_cong_right : forall {Γ σ σ' Δ i A M M'},
+    {{ Δ A : Type@i }} ->
+    {{ Δ M : A }} ->
+    {{ Δ M' : A }} ->
+    {{ Δ M M' : A }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ s σ' : Δ }} ->
+    {{ Γ s σ σ' : Δ }} ->
+    {{ Γ M'[σ'] : A[σ] }}.
+Proof.
+  intros.
+  eapply wf_conv; mauto 2.
+  eapply exp_eq_sub_cong_typ2'; mauto 2.
+Qed.

-    eapply wf_conv; mauto 3.
-    etransitivity.
-    + eapply exp_eq_sub_compose_typ; mauto 2.
-    + symmetry.
-      eapply exp_eq_sub_cong_typ2'; mauto 2.
-      symmetry.
-      etransitivity;
-        [eapply wf_sub_eq_extend_compose |];
-        mauto 2.
+#[local]
+Hint Resolve presup_exp_eq_sub_cong_right : mcltt.
+ +
+Lemma presup_exp_eq_sub_compose_right : forall {Γ τ Γ' σ Γ'' i A M},
+    {{ Γ s τ : Γ' }} ->
+    {{ Γ' s σ : Γ'' }} ->
+    {{ Γ'' A : Type@i }} ->
+    {{ Γ'' M : A }} ->
+    {{ Γ M[σ][τ] : A[σ τ] }}.
+Proof.
+  intros.
+  eapply wf_conv; mauto 3.
+Qed.

-  - eexists.
-    eapply exp_sub_typ; mauto 2.
-    assert {{ Γ s Id ,, N : Γ, B}} by mauto 4.
-    assert {{ Γ , B B[Wk] : Type@i }} by mauto 4.
-    assert {{ Γ , B , B[Wk] B[Wk][Wk] : Type@i }} by mauto 4.
-    assert {{ Γ B[Wk][Id,,N] B : Type@i }}.
-    {
-      transitivity {{{B[Wk (Id,,N)]}}};
-        [| transitivity {{{B[Id]}}}];
-        mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 3.
-    }
-    assert {{ Γ s Id ,, N ,, N : Γ, B , B[Wk]}}.
-    {
-      econstructor; mauto 3.
-      eapply wf_conv; mauto 2.
-    }
-    assert {{ Γ B[Wk][Wk][Id ,, N ,, N] B : Type@i }}.
-    {
-      transitivity {{{B[Wk][Wk (Id ,, N ,, N)]}}};
-        [| transitivity {{{B[Wk][Id ,, N]}}}];
-        mauto 4.
-      eapply exp_eq_sub_cong_typ2'; mauto 4.
-      eapply wf_sub_eq_p_extend; mauto 4.
-    }
-    assert {{ Γ, B, B[Wk] Eq (B[Wk][Wk]) # 1 # 0 : Type@i }} by (econstructor; mauto 4).
-    assert {{ Γ refl B N : Eq B N N}} by mauto 3.
-    assert {{ Γ refl B N : (Eq (B[Wk][Wk]) #1 #0) [ Id ,, N ,, N]}}.
-    {
-      eapply wf_conv; mauto 2.
-      symmetry.
-      etransitivity.
-      - eapply wf_exp_eq_eq_sub; mauto.
-      - econstructor; mauto 3.
-        + eapply wf_exp_eq_conv;
-            [eapply id_sub_lookup_var1 with (B:=B) | |];
-            mauto 4.
-        + eapply wf_exp_eq_conv;
-            [eapply id_sub_lookup_var0 with (B:=B) | |];
-            mauto 4.
-    }
-    mauto 3.
+#[local]
+Hint Resolve presup_exp_eq_sub_compose_right : mcltt.
+ +
+#[local]
+Ltac gen_presup_ctx H :=
+  match type of H with
+  | {{ ^?Γ ^?Δ }} =>
+      let := fresh "HΓ" in
+      let := fresh "HΔ" in
+      pose proof presup_ctx_eq H as [ ]
+  | {{ ^?Γ ^?Δ }} =>
+      let := fresh "HΓ" in
+      let := fresh "HΔ" in
+      pose proof presup_ctx_sub H as [ ]
+  end.

-  - assert {{ Γ s Wk(σ ,, N') σ : Δ }} by mauto 3.
-    assert {{ Γ B[Wk(σ ,, N')] B[σ] : Type@i }} by mauto 4.
-    assert {{ Δ, B }} by mauto 2.
-    assert {{ Δ, B s Wk : Δ }} by mauto 2.
-    assert {{ Γ s σ ,, N' : Δ, B }} by mauto 2.
-    assert {{ Γ B[Wk][σ ,, N'] B[σ] : Type@i }} by mauto 3.
-    enough {{ Γ #0[σ ,, N'] : B[Wk][σ ,, N'] }}...
+#[local]
+Ltac gen_presup_IH presup_exp_eq presup_sub_eq presup_subtyp H :=
+  match type of H with
+  | {{ ^?Γ ^?M ^?N : ^?A }} =>
+      let := fresh "HΓ" in
+      let i := fresh "i" in
+      let HM := fresh "HM" in
+      let HN := fresh "HN" in
+      let HAi := fresh "HAi" in
+      pose proof presup_exp_eq _ _ _ _ H as [ [HM [HN [i HAi]]]]
+ | {{ ^?Γ s ^ ^: ^?Δ }} =>
+      let := fresh "HΓ" in
+      let Hσ := fresh "Hσ" in
+      let Hτ := fresh "Hτ" in
+      let := fresh "HΔ" in
+      pose proof presup_sub_eq _ _ _ _ H as [ [Hσ [Hτ ]]]
+ | {{ ^?Γ ^?M ^?N }} =>
+      let := fresh "HΓ" in
+      let i := fresh "i" in
+      let HM := fresh "HM" in
+      let HN := fresh "HN" in
+      pose proof presup_subtyp _ _ _ H as [ [i [HM HN]]]
+ | {{ ^?Γ ^?M : ^?A }} =>
+      let := fresh "HΓ" in
+      let i := fresh "i" in
+      let HAi := fresh "HAi" in
+      pose proof presup_exp H as [ [i HAi]]
+ | {{ ^?Γ s ^: ^?Δ }} =>
+      let := fresh "HΓ" in
+      let := fresh "HΔ" in
+      pose proof presup_sub H as [ ]
+  | _ => gen_presup_ctx H
+  end.

-  - assert (exists i, {{ Δ C : Type@i }}) as [i'] by mauto 2.
-    assert {{ Γ s Wk(σ ,, N) σ : Δ }} by mauto 2.
-    assert {{ Γ C[Wk(σ ,, N)] C[σ] : Type@i' }} by mauto 4.
-    assert {{ Δ, B s Wk : Δ }} by mauto 3.
-    assert {{ Γ s σ ,, N : Δ, B }} by mauto 2.
-    assert {{ Γ C[Wk][σ ,, N] C[σ] : Type@i' }} by mauto 3.
-    assert {{ Δ, B #(S x) : C[Wk] }} by mauto 4.
-    enough {{ Γ #(S x)[σ ,, N] : C[Wk][σ ,, N] }}...
+Lemma presup_exp_eq : forall {Γ M M' A}, {{ Γ M M' : A }} -> {{ Γ }} /\ {{ Γ M : A }} /\ {{ Γ M' : A }} /\ exists i, {{ Γ A : Type@i }}
+with presup_sub_eq : forall {Γ Δ σ σ'}, {{ Γ s σ σ' : Δ }} -> {{ Γ }} /\ {{ Γ s σ : Δ }} /\ {{ Γ s σ' : Δ }} /\ {{ Δ }}
+with presup_subtyp : forall {Γ M M'}, {{ Γ M M' }} -> {{ Γ }} /\ exists i, {{ Γ M : Type@i }} /\ {{ Γ M' : Type@i }}.
+Proof with mautosolve 4.
+  all: inversion_clear 1; (on_all_hyp: gen_presup_IH presup_exp_eq presup_sub_eq presup_subtyp);
+    clear presup_exp_eq presup_sub_eq presup_subtyp;
+    repeat split; try mautosolve 3;
+    try (eexists; unshelve solve [mauto 4 using lift_exp_max_left, lift_exp_max_right]; constructor).

-  - assert (exists i, {{ Δ C : Type@i }}) as []...
+  all: try (econstructor; mautosolve 4).

-presup_sub_eq cases +presup_exp_eq cases
-  - econstructor...
- -
-  - assert {{ Γ B[σ] B[σ'] : Type@i }} by mauto 2.
-    eapply wf_conv...
- -
-  - assert {{ Γ N'[Id] : A[Id] }}...
+  - eexists; eapply exp_sub_typ; mauto 4 using lift_exp_max_left, lift_exp_max_right.

-  - assert {{ Γ N[σ][τ] : B[σ][τ] }} by mauto 3.
-    eapply wf_conv...
+  - match_by_head1 ctx_lookup ltac:(fun H => directed destruct (presup_ctx_lookup_typ ltac:(eassumption) H))...

-  - econstructor...
+
-
+
+presup_sub_eq cases +
+
  - econstructor; mauto 3.
    eapply wf_conv...

-  - mauto.
- -
-  - assert (exists i, {{ Γ0 A : Type@i }}) as [] by mauto 2.
-    assert {{ Γ #0[σ] : A[Wk][σ] }} by mauto 3.
-    enough {{ Γ #0[σ] : A[Wkσ] }} by mauto 4.
+  - assert (exists i, {{ Γ0 A : Type@i }}) as [] by mauto 2.
+    assert {{ Γ #0[σ] : A[Wk][σ] }} by mauto 3.
+    enough {{ Γ #0[σ] : A[Wkσ] }} by mauto 4.
    eapply wf_conv...

@@ -1485,9 +1514,7 @@

Mcltt.Core.Syntactic.Presup

presup_subtyp cases
-  - exists (max i i0); split; mauto 3 using lift_exp_max_left, lift_exp_max_right.
  - exists (max (S i) (S j)); split; mauto 3 using lift_exp_max_left, lift_exp_max_right.
-  - mauto.
Qed.

diff --git a/ext/prop-eq/Mcltt.Core.Syntactic.Syntax.html b/ext/prop-eq/Mcltt.Core.Syntactic.Syntax.html index 2c9cfdd..4da8434 100644 --- a/ext/prop-eq/Mcltt.Core.Syntactic.Syntax.html +++ b/ext/prop-eq/Mcltt.Core.Syntactic.Syntax.html @@ -289,7 +289,7 @@

Mcltt.Core.Syntactic.Syntax


  Notation "⋅" := nil (in custom exp at level 0) : mcltt_scope.
-  Notation "x , y" := (cons y x) (in custom exp at level 50, format "x , y") : mcltt_scope.
+  Notation "x , y" := (cons y x) (in custom exp at level 50, left associativity, format "x , y") : mcltt_scope.

  Notation "n{{{ x }}}" := x (at level 0, x custom nf at level 99, format "'n{{{' x '}}}'") : mcltt_scope.
diff --git a/ext/prop-eq/Mcltt.Core.Syntactic.System.Definitions.html b/ext/prop-eq/Mcltt.Core.Syntactic.System.Definitions.html index f38dacb..e70057b 100644 --- a/ext/prop-eq/Mcltt.Core.Syntactic.System.Definitions.html +++ b/ext/prop-eq/Mcltt.Core.Syntactic.System.Definitions.html @@ -129,9 +129,9 @@

Mcltt.Core.Syntactic.System.Definitions

  `( {{ Γ A : Type@i }} ->
     {{ Γ M1 : A }} ->
     {{ Γ M2 : A }} ->
-     {{ Γ N : Eq A M1 M2 }} ->
-     {{ Γ , A , A[Wk], Eq (A[Wk][Wk]) #1 #0 B : Type@j }} ->
-     {{ Γ , A BR : B [Id,,#0,,refl (A[Wk]) #0 ] }} ->
+     {{ Γ , A , A[Wk], Eq A[WkWk] #1 #0 B : Type@j }} ->
+     {{ Γ , A BR : B[Id,,#0,,refl A[Wk] #0] }} ->
+     {{ Γ N : Eq A M1 M2 }} ->
     {{ Γ eqrec N as Eq A M1 M2 return B | refl -> BR end : B[Id,,M1,,M2,,N] }} )

| wf_exp_sub :
@@ -233,13 +233,13 @@

Mcltt.Core.Syntactic.System.Definitions

     {{ Γ MZ : A[Id,,zero] }} ->
     {{ Γ , , A MS : A[WkWk,,succ(#1)] }} ->
     {{ Γ M : }} ->
-     {{ Γ rec (succ M) return A | zero -> MZ | succ -> MS end MS[Id,,M,,rec M return A | zero -> MZ | succ -> MS end] : A[Id,,succ M] }} )
+     {{ Γ rec succ M return A | zero -> MZ | succ -> MS end MS[Id,,M,,rec M return A | zero -> MZ | succ -> MS end] : A[Id,,succ M] }} )

| wf_exp_eq_pi_sub :
  `( {{ Γ s σ : Δ }} ->
     {{ Δ A : Type@i }} ->
     {{ Δ , A B : Type@i }} ->
-     {{ Γ (Π A B)[σ] Π (A[σ]) (B[q σ]) : Type@i }} )
+     {{ Γ (Π A B)[σ] Π A[σ] B[q σ] : Type@i }} )
| wf_exp_eq_pi_cong :
  `( {{ Γ A : Type@i }} ->
     {{ Γ A A' : Type@i }} ->
@@ -285,22 +285,22 @@

Mcltt.Core.Syntactic.System.Definitions

     {{ Δ A : Type@i }} ->
     {{ Δ M : A }} ->
     {{ Δ N : A }} ->
-     {{ Γ (Eq A M N)[σ] Eq (A[σ]) (M[σ]) (N[σ]) : Type@i }} )
+     {{ Γ (Eq A M N)[σ] Eq A[σ] M[σ] N[σ] : Type@i }} )
| wf_exp_eq_refl_sub :
  `( {{ Γ s σ : Δ }} ->
     {{ Δ A : Type@i }} ->
     {{ Δ M : A }} ->
-     {{ Γ (refl A M)[σ] refl (A[σ]) (M[σ]) : (Eq A M M)[σ] }} )
+     {{ Γ (refl A M)[σ] refl A[σ] M[σ] : (Eq A M M)[σ] }} )
| wf_exp_eq_eqrec_sub :
  `( {{ Γ s σ : Δ }} ->
     {{ Δ A : Type@i }} ->
     {{ Δ M1 : A }} ->
     {{ Δ M2 : A }} ->
-     {{ Δ N : Eq A M1 M2 }} ->
-     {{ Δ , A , A[Wk], Eq (A[Wk][Wk]) #1 #0 B : Type@j }} ->
-     {{ Δ , A BR : B [Id,,#0,,refl (A[Wk]) #0 ] }} ->
-     {{ Γ (eqrec N as Eq A M1 M2 return B | refl -> BR end)[σ]
-           eqrec (N[σ]) as Eq (A[σ]) (M1[σ]) (M2[σ]) return B[q (q (q σ))] | refl -> BR[q σ] end
+     {{ Δ , A , A[Wk], Eq A[WkWk] #1 #0 B : Type@j }} ->
+     {{ Δ , A BR : B[Id,,#0,,refl A[Wk] #0] }} ->
+     {{ Δ N : Eq A M1 M2 }} ->
+     {{ Γ eqrec N as Eq A M1 M2 return B | refl -> BR end[σ]
+           eqrec N[σ] as Eq A[σ] M1[σ] M2[σ] return B[q (q (q σ))] | refl -> BR[q σ] end
         : B[σ,,M1[σ],,M2[σ],,N[σ]] }} )
| wf_exp_eq_eq_cong :
  `( {{ Γ A A' : Type@i }} ->
@@ -318,56 +318,55 @@

Mcltt.Core.Syntactic.System.Definitions

     {{ Γ A A' : Type@i }} ->
     {{ Γ M1 M1' : A }} ->
     {{ Γ M2 M2' : A }} ->
-     {{ Γ N N' : Eq A M1 M2 }} ->
-     {{ Γ , A , A[Wk], Eq (A[Wk][Wk]) #1 #0 B B' : Type@j }} ->
-     {{ Γ , A BR BR' : B [Id,,#0,,refl (A[Wk]) #0 ] }} ->
+     {{ Γ , A , A[Wk], Eq A[WkWk] #1 #0 B B' : Type@j }} ->
+     {{ Γ , A BR BR' : B[Id,,#0,,refl A[Wk] #0] }} ->
+     {{ Γ N N' : Eq A M1 M2 }} ->
     {{ Γ eqrec N as Eq A M1 M2 return B | refl -> BR end
           eqrec N' as Eq A' M1' M2' return B' | refl -> BR' end
         : B[Id,,M1,,M2,,N] }} )
| wf_exp_eq_eqrec_beta :
  `( {{ Γ A : Type@i }} ->
     {{ Γ M : A }} ->
-     {{ Γ N : Eq A M M }} ->
-     {{ Γ , A , A[Wk], Eq (A[Wk][Wk]) #1 #0 B : Type@j }} ->
-     {{ Γ , A BR : B [Id,,#0,,refl (A[Wk]) #0 ] }} ->
-     {{ Γ eqrec refl A M as Eq A M M return B | refl -> BR end
-           BR[Id,,M]
-         : B[Id,,M,,M,,refl A M] }} )
+     {{ Γ , A , A[Wk], Eq A[WkWk] #1 #0 B : Type@j }} ->
+     {{ Γ , A BR : B[Id,,#0,,refl A[Wk] #0] }} ->
+     {{ Γ eqrec refl A M as Eq A M M return B | refl -> BR end
+           BR[Id,,M]
+         : B[Id,,M,,M,,refl A M] }} )

| wf_exp_eq_var :
-  `( {{ Γ }} ->
-     {{ #x : A Γ }} ->
-     {{ Γ #x #x : A }} )
+  `( {{ Γ }} ->
+     {{ #x : A Γ }} ->
+     {{ Γ #x #x : A }} )
| wf_exp_eq_var_0_sub :
-  `( {{ Γ s σ : Δ }} ->
-     {{ Δ A : Type@i }} ->
-     {{ Γ M : A[σ] }} ->
-     {{ Γ #0[σ ,, M] M : A[σ] }} )
+  `( {{ Γ s σ : Δ }} ->
+     {{ Δ A : Type@i }} ->
+     {{ Γ M : A[σ] }} ->
+     {{ Γ #0[σ ,, M] M : A[σ] }} )
| wf_exp_eq_var_S_sub :
-  `( {{ Γ s σ : Δ }} ->
-     {{ Δ A : Type@i }} ->
-     {{ Γ M : A[σ] }} ->
-     {{ #x : B Δ }} ->
-     {{ Γ #(S x)[σ ,, M] #x[σ] : B[σ] }} )
+  `( {{ Γ s σ : Δ }} ->
+     {{ Δ A : Type@i }} ->
+     {{ Γ M : A[σ] }} ->
+     {{ #x : B Δ }} ->
+     {{ Γ #(S x)[σ ,, M] #x[σ] : B[σ] }} )
| wf_exp_eq_var_weaken :
-  `( {{ Γ , B }} ->
-     {{ #x : A Γ }} ->
-     {{ Γ , B #x[Wk] #(S x) : A[Wk] }} )
+  `( {{ Γ , B }} ->
+     {{ #x : A Γ }} ->
+     {{ Γ , B #x[Wk] #(S x) : A[Wk] }} )
| wf_exp_eq_sub_cong :
-  `( {{ Δ M M' : A }} ->
-     {{ Γ s σ σ' : Δ }} ->
-     {{ Γ M[σ] M'[σ'] : A[σ] }} )
+  `( {{ Δ M M' : A }} ->
+     {{ Γ s σ σ' : Δ }} ->
+     {{ Γ M[σ] M'[σ'] : A[σ] }} )
| wf_exp_eq_sub_id :
-  `( {{ Γ M : A }} ->
-     {{ Γ M[Id] M : A }} )
+  `( {{ Γ M : A }} ->
+     {{ Γ M[Id] M : A }} )
| wf_exp_eq_sub_compose :
-  `( {{ Γ s τ : Γ' }} ->
-     {{ Γ' s σ : Γ'' }} ->
-     {{ Γ'' M : A }} ->
-     {{ Γ M[σ τ] M[σ][τ] : A[σ τ] }} )
+  `( {{ Γ s τ : Γ' }} ->
+     {{ Γ' s σ : Γ'' }} ->
+     {{ Γ'' M : A }} ->
+     {{ Γ M[σ τ] M[σ][τ] : A[σ τ] }} )
| wf_exp_eq_subtyp :
-  `( {{ Γ M M' : A }} ->
-     {{ Γ A' : Type@i }} ->
+  `( {{ Γ M M' : A }} ->
+     {{ Γ A' : Type@i }} ->
     
@@ -376,67 +375,67 @@

Mcltt.Core.Syntactic.System.Definitions

-     {{ Γ A A' }} ->
-     {{ Γ M M' : A' }} )
+     {{ Γ A A' }} ->
+     {{ Γ M M' : A' }} )
| wf_exp_eq_sym :
-  `( {{ Γ M M' : A }} ->
-     {{ Γ M' M : A }} )
+  `( {{ Γ M M' : A }} ->
+     {{ Γ M' M : A }} )
| wf_exp_eq_trans :
-  `( {{ Γ M M' : A }} ->
-     {{ Γ M' M'' : A }} ->
-     {{ Γ M M'' : A }} )
+  `( {{ Γ M M' : A }} ->
+     {{ Γ M' M'' : A }} ->
+     {{ Γ M M'' : A }} )
where "Γ ⊢ M ≈ M' : A" := (wf_exp_eq Γ A M M') (in custom judg) : type_scope

with wf_sub_eq : ctx -> ctx -> sub -> sub -> Prop :=
| wf_sub_eq_id :
-  `( {{ Γ }} ->
-     {{ Γ s Id Id : Γ }} )
+  `( {{ Γ }} ->
+     {{ Γ s Id Id : Γ }} )
| wf_sub_eq_weaken :
-  `( {{ Γ , A }} ->
-     {{ Γ , A s Wk Wk : Γ }} )
+  `( {{ Γ , A }} ->
+     {{ Γ , A s Wk Wk : Γ }} )
| wf_sub_eq_compose_cong :
-  `( {{ Γ s τ τ' : Γ' }} ->
-     {{ Γ' s σ σ' : Γ'' }} ->
-     {{ Γ s σ τ σ' τ' : Γ'' }} )
+  `( {{ Γ s τ τ' : Γ' }} ->
+     {{ Γ' s σ σ' : Γ'' }} ->
+     {{ Γ s σ τ σ' τ' : Γ'' }} )
| wf_sub_eq_extend_cong :
-  `( {{ Γ s σ σ' : Δ }} ->
-     {{ Δ A : Type@i }} ->
-     {{ Γ M M' : A[σ] }} ->
-     {{ Γ s (σ ,, M) (σ' ,, M') : Δ , A }} )
+  `( {{ Γ s σ σ' : Δ }} ->
+     {{ Δ A : Type@i }} ->
+     {{ Γ M M' : A[σ] }} ->
+     {{ Γ s (σ ,, M) (σ' ,, M') : Δ , A }} )
| wf_sub_eq_id_compose_right :
-  `( {{ Γ s σ : Δ }} ->
-     {{ Γ s Id σ σ : Δ }} )
+  `( {{ Γ s σ : Δ }} ->
+     {{ Γ s Id σ σ : Δ }} )
| wf_sub_eq_id_compose_left :
-  `( {{ Γ s σ : Δ }} ->
-     {{ Γ s σ Id σ : Δ }} )
+  `( {{ Γ s σ : Δ }} ->
+     {{ Γ s σ Id σ : Δ }} )
| wf_sub_eq_compose_assoc :
-  `( {{ Γ' s σ : Γ }} ->
-     {{ Γ'' s σ' : Γ' }} ->
-     {{ Γ''' s σ'' : Γ'' }} ->
-     {{ Γ''' s (σ σ') σ'' σ (σ' σ'') : Γ }} )
+  `( {{ Γ' s σ : Γ }} ->
+     {{ Γ'' s σ' : Γ' }} ->
+     {{ Γ''' s σ'' : Γ'' }} ->
+     {{ Γ''' s (σ σ') σ'' σ (σ' σ'') : Γ }} )
| wf_sub_eq_extend_compose :
-  `( {{ Γ' s σ : Γ'' }} ->
-     {{ Γ'' A : Type@i }} ->
-     {{ Γ' M : A[σ] }} ->
-     {{ Γ s τ : Γ' }} ->
-     {{ Γ s (σ ,, M) τ ((σ τ) ,, M[τ]) : Γ'' , A }} )
+  `( {{ Γ' s σ : Γ'' }} ->
+     {{ Γ'' A : Type@i }} ->
+     {{ Γ' M : A[σ] }} ->
+     {{ Γ s τ : Γ' }} ->
+     {{ Γ s (σ ,, M) τ ((σ τ) ,, M[τ]) : Γ'' , A }} )
| wf_sub_eq_p_extend :
-  `( {{ Γ' s σ : Γ }} ->
-     {{ Γ A : Type@i }} ->
-     {{ Γ' M : A[σ] }} ->
-     {{ Γ' s Wk (σ ,, M) σ : Γ }} )
+  `( {{ Γ' s σ : Γ }} ->
+     {{ Γ A : Type@i }} ->
+     {{ Γ' M : A[σ] }} ->
+     {{ Γ' s Wk (σ ,, M) σ : Γ }} )
| wf_sub_eq_extend :
-  `( {{ Γ' s σ : Γ , A }} ->
-     {{ Γ' s σ ((Wk σ) ,, #0[σ]) : Γ , A }} )
+  `( {{ Γ' s σ : Γ , A }} ->
+     {{ Γ' s σ ((Wk σ) ,, #0[σ]) : Γ , A }} )
| wf_sub_eq_sym :
-  `( {{ Γ s σ σ' : Δ }} ->
-     {{ Γ s σ' σ : Δ }} )
+  `( {{ Γ s σ σ' : Δ }} ->
+     {{ Γ s σ' σ : Δ }} )
| wf_sub_eq_trans :
-  `( {{ Γ s σ σ' : Δ }} ->
-     {{ Γ s σ' σ'' : Δ }} ->
-     {{ Γ s σ σ'' : Δ }} )
+  `( {{ Γ s σ σ' : Δ }} ->
+     {{ Γ s σ' σ'' : Δ }} ->
+     {{ Γ s σ σ'' : Δ }} )
| wf_sub_eq_subtyp :
-  `( {{ Γ s σ σ' : Δ }} ->
+  `( {{ Γ s σ σ' : Δ }} ->
     
@@ -445,9 +444,9 @@

Mcltt.Core.Syntactic.System.Definitions

-     {{ Δ' }} ->
-     {{ Δ Δ' }} ->
-     {{ Γ s σ σ' : Δ' }} )
+     {{ Δ' }} ->
+     {{ Δ Δ' }} ->
+     {{ Γ s σ σ' : Δ' }} )
where "Γ ⊢s S1 ≈ S2 : Δ" := (wf_sub_eq Γ Δ S1 S2) (in custom judg) : type_scope

with wf_subtyp : ctx -> typ -> typ -> Prop :=
@@ -468,25 +467,25 @@

Mcltt.Core.Syntactic.System.Definitions

-  `( {{ Γ M' : Type@i }} ->
-     {{ Γ M M' : Type@i }} ->
-     {{ Γ M M' }} )
+  `( {{ Γ M' : Type@i }} ->
+     {{ Γ M M' : Type@i }} ->
+     {{ Γ M M' }} )
| wf_subtyp_trans :
-  `( {{ Γ M M' }} ->
-     {{ Γ M' M'' }} ->
-     {{ Γ M M'' }} )
+  `( {{ Γ M M' }} ->
+     {{ Γ M' M'' }} ->
+     {{ Γ M M'' }} )
| wf_subtyp_univ :
-  `( {{ Γ }} ->
+  `( {{ Γ }} ->
     i < j ->
-     {{ Γ Type@i Type@j }} )
+     {{ Γ Type@i Type@j }} )
| wf_subtyp_pi :
-  `( {{ Γ A : Type@i }} ->
-     {{ Γ A' : Type@i }} ->
-     {{ Γ A A' : Type@i }} ->
-     {{ Γ , A B : Type@i }} ->
-     {{ Γ , A' B' : Type@i }} ->
-     {{ Γ , A' B B' }} ->
-     {{ Γ Π A B Π A' B' }} )
+  `( {{ Γ A : Type@i }} ->
+     {{ Γ A' : Type@i }} ->
+     {{ Γ A A' : Type@i }} ->
+     {{ Γ , A B : Type@i }} ->
+     {{ Γ , A' B' : Type@i }} ->
+     {{ Γ , A' B B' }} ->
+     {{ Γ Π A B Π A' B' }} )
where "Γ ⊢ A ⊆ A'" := (wf_subtyp Γ A A') (in custom judg) : type_scope.

@@ -519,15 +518,15 @@

Mcltt.Core.Syntactic.System.Definitions

Inductive wf_ctx_eq : ctx -> ctx -> Prop :=
| wf_ctx_eq_empty : {{ }}
| wf_ctx_eq_extend :
-  `( {{ Γ Δ }} ->
-     {{ Γ A : Type@i }} ->
-     {{ Γ A' : Type@i }} ->
-     {{ Δ A : Type@i }} ->
-     {{ Δ A' : Type@i }} ->
-     {{ Γ A A' : Type@i }} ->
-     {{ Δ A A' : Type@i }} ->
-     {{ Γ , A Δ , A' }} )
-where "⊢ Γ ≈ Γ'" := (wf_ctx_eq Γ Γ') (in custom judg) : type_scope.
+  `( {{ Γ Δ }} ->
+     {{ Γ A : Type@i }} ->
+     {{ Γ A' : Type@i }} ->
+     {{ Δ A : Type@i }} ->
+     {{ Δ A' : Type@i }} ->
+     {{ Γ A A' : Type@i }} ->
+     {{ Δ A A' : Type@i }} ->
+     {{ Γ , A Δ , A' }} )
+where "⊢ Γ ≈ Γ'" := (wf_ctx_eq Γ Γ') (in custom judg) : type_scope.

#[export]
@@ -535,7 +534,7 @@

Mcltt.Core.Syntactic.System.Definitions


#[export]
-Instance wf_exp_eq_PER Γ A : PER (wf_exp_eq Γ A).
+Instance wf_exp_eq_PER Γ A : PER (wf_exp_eq Γ A).
Proof.
  split.
  - eauto using wf_exp_eq_sym.
@@ -544,7 +543,7 @@

Mcltt.Core.Syntactic.System.Definitions


#[export]
-Instance wf_sub_eq_PER Γ Δ : PER (wf_sub_eq Γ Δ).
+Instance wf_sub_eq_PER Γ Δ : PER (wf_sub_eq Γ Δ).
Proof.
  split.
  - eauto using wf_sub_eq_sym.
@@ -560,7 +559,7 @@

Mcltt.Core.Syntactic.System.Definitions


#[export]
-Instance wf_subtyp_Transitive Γ : Transitive (wf_subtyp Γ).
+Instance wf_subtyp_Transitive Γ : Transitive (wf_subtyp Γ).
Proof.
  hnf; mauto.
Qed.
@@ -574,7 +573,7 @@

Mcltt.Core.Syntactic.System.Definitions


-Lemma presup_ctx_sub : forall {Γ Δ}, {{ Γ Δ }} -> {{ Γ }} /\ {{ Δ }}.
+Lemma presup_ctx_sub : forall {Γ Δ}, {{ Γ Δ }} -> {{ Γ }} /\ {{ Δ }}.
Proof with mautosolve.
  induction 1; destruct_pairs...
Qed.
@@ -584,7 +583,7 @@

Mcltt.Core.Syntactic.System.Definitions

Hint Resolve presup_ctx_sub : mcltt.

-Lemma presup_ctx_sub_left : forall {Γ Δ}, {{ Γ Δ }} -> {{ Γ }}.
+Lemma presup_ctx_sub_left : forall {Γ Δ}, {{ Γ Δ }} -> {{ Γ }}.
Proof with easy.
  intros * ?%presup_ctx_sub...
Qed.
@@ -594,7 +593,7 @@

Mcltt.Core.Syntactic.System.Definitions

Hint Resolve presup_ctx_sub_left : mcltt.

-Lemma presup_ctx_sub_right : forall {Γ Δ}, {{ Γ Δ }} -> {{ Δ }}.
+Lemma presup_ctx_sub_right : forall {Γ Δ}, {{ Γ Δ }} -> {{ Δ }}.
Proof with easy.
  intros * ?%presup_ctx_sub...
Qed.
@@ -604,7 +603,7 @@

Mcltt.Core.Syntactic.System.Definitions

Hint Resolve presup_ctx_sub_right : mcltt.

-Lemma presup_subtyp_right : forall {Γ A B}, {{ Γ A B }} -> exists i, {{ Γ B : Type@i }}.
+Lemma presup_subtyp_right : forall {Γ A B}, {{ Γ A B }} -> exists i, {{ Γ B : Type@i }}.
Proof with mautosolve.
  induction 1...
Qed.
@@ -622,13 +621,13 @@

Mcltt.Core.Syntactic.System.Definitions


-Lemma wf_exp_subtyp' : forall Γ A A' M,
-    {{ Γ M : A }} ->
-    {{ Γ A A' }} ->
-    {{ Γ M : A' }}.
+Lemma wf_exp_subtyp' : forall Γ A A' M,
+    {{ Γ M : A }} ->
+    {{ Γ A A' }} ->
+    {{ Γ M : A' }}.
Proof.
  intros.
-  assert (exists i, {{ Γ A' : Type@i }}) as [] by mauto.
+  assert (exists i, {{ Γ A' : Type@i }}) as [] by mauto.
  econstructor; mauto.
Qed.
@@ -639,10 +638,10 @@

Mcltt.Core.Syntactic.System.Definitions

Remove Hints wf_exp_subtyp : mcltt.

-Lemma wf_sub_subtyp' : forall Γ Δ Δ' σ,
-    {{ Γ s σ : Δ }} ->
-    {{ Δ Δ' }} ->
-    {{ Γ s σ : Δ' }}.
+Lemma wf_sub_subtyp' : forall Γ Δ Δ' σ,
+    {{ Γ s σ : Δ }} ->
+    {{ Δ Δ' }} ->
+    {{ Γ s σ : Δ' }}.
Proof.
  intros.
  econstructor; mauto.
@@ -655,13 +654,13 @@

Mcltt.Core.Syntactic.System.Definitions

Remove Hints wf_sub_subtyp : mcltt.

-Lemma wf_exp_eq_subtyp' : forall Γ A A' M M',
-    {{ Γ M M' : A }} ->
-    {{ Γ A A' }} ->
-    {{ Γ M M' : A' }}.
+Lemma wf_exp_eq_subtyp' : forall Γ A A' M M',
+    {{ Γ M M' : A }} ->
+    {{ Γ A A' }} ->
+    {{ Γ M M' : A' }}.
Proof.
  intros.
-  assert (exists i, {{ Γ A' : Type@i }}) as [] by mauto.
+  assert (exists i, {{ Γ A' : Type@i }}) as [] by mauto.
  econstructor; mauto.
Qed.
@@ -672,10 +671,10 @@

Mcltt.Core.Syntactic.System.Definitions

Remove Hints wf_exp_eq_subtyp : mcltt.

-Lemma wf_sub_eq_subtyp' : forall Γ Δ Δ' σ σ',
-    {{ Γ s σ σ' : Δ }} ->
-    {{ Δ Δ' }} ->
-    {{ Γ s σ σ' : Δ' }}.
+Lemma wf_sub_eq_subtyp' : forall Γ Δ Δ' σ σ',
+    {{ Γ s σ σ' : Δ }} ->
+    {{ Δ Δ' }} ->
+    {{ Γ s σ σ' : Δ' }}.
Proof.
  intros.
  econstructor; mauto.
@@ -688,29 +687,29 @@

Mcltt.Core.Syntactic.System.Definitions

Remove Hints wf_sub_eq_subtyp : mcltt.

-Add Parametric Morphism Γ T : (wf_exp_eq Γ T)
-    with signature wf_exp_eq Γ T ==> eq ==> iff as wf_exp_eq_morphism_iff1.
+Add Parametric Morphism Γ T : (wf_exp_eq Γ T)
+    with signature wf_exp_eq Γ T ==> eq ==> iff as wf_exp_eq_morphism_iff1.
Proof.
  split; mauto.
Qed.

-Add Parametric Morphism Γ T : (wf_exp_eq Γ T)
-    with signature eq ==> wf_exp_eq Γ T ==> iff as wf_exp_eq_morphism_iff2.
+Add Parametric Morphism Γ T : (wf_exp_eq Γ T)
+    with signature eq ==> wf_exp_eq Γ T ==> iff as wf_exp_eq_morphism_iff2.
Proof.
  split; mauto.
Qed.

-Add Parametric Morphism Γ Δ : (wf_sub_eq Γ Δ)
-    with signature wf_sub_eq Γ Δ ==> eq ==> iff as wf_sub_eq_morphism_iff1.
+Add Parametric Morphism Γ Δ : (wf_sub_eq Γ Δ)
+    with signature wf_sub_eq Γ Δ ==> eq ==> iff as wf_sub_eq_morphism_iff1.
Proof.
  split; mauto.
Qed.

-Add Parametric Morphism Γ Δ : (wf_sub_eq Γ Δ)
-    with signature eq ==> wf_sub_eq Γ Δ ==> iff as wf_sub_eq_morphism_iff2.
+Add Parametric Morphism Γ Δ : (wf_sub_eq Γ Δ)
+    with signature eq ==> wf_sub_eq Γ Δ ==> iff as wf_sub_eq_morphism_iff2.
Proof.
  split; mauto.
Qed.
@@ -731,14 +730,14 @@

Mcltt.Core.Syntactic.System.Definitions


#[export]
-Instance wf_exp_eq_per_elem Γ T : PERElem _ (wf_exp Γ T) (wf_exp_eq Γ T).
+Instance wf_exp_eq_per_elem Γ T : PERElem _ (wf_exp Γ T) (wf_exp_eq Γ T).
Proof.
  intros a Ha. mauto.
Qed.

#[export]
-Instance wf_sub_eq_per_elem Γ Δ : PERElem _ (wf_sub Γ Δ) (wf_sub_eq Γ Δ).
+Instance wf_sub_eq_per_elem Γ Δ : PERElem _ (wf_sub Γ Δ) (wf_sub_eq Γ Δ).
Proof.
  intros a Ha. mauto.
Qed.
diff --git a/ext/prop-eq/Mcltt.Core.Syntactic.System.Lemmas.html b/ext/prop-eq/Mcltt.Core.Syntactic.System.Lemmas.html index b82eb8d..cbb1840 100644 --- a/ext/prop-eq/Mcltt.Core.Syntactic.System.Lemmas.html +++ b/ext/prop-eq/Mcltt.Core.Syntactic.System.Lemmas.html @@ -37,14 +37,12 @@

Mcltt.Core.Syntactic.System.Lemmas

-

Core Presuppositions

- -
- -

Basic inversion

+

Basic Context Properties

+ +
Lemma ctx_lookup_lt : forall {Γ A x},
    {{ #x : A Γ }} ->
    x < length Γ.
@@ -55,23 +53,31 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve ctx_lookup_lt : mcltt.

-Lemma ctx_decomp : forall {Γ A}, {{ Γ , A }} -> {{ Γ }} /\ exists i, {{ Γ A : Type@i }}.
-Proof with now eauto.
-  inversion 1...
+Lemma functional_ctx_lookup : forall {Γ A A' x},
+    {{ #x : A Γ }} ->
+    {{ #x : A' Γ }} ->
+    A = A'.
+Proof with mautosolve.
+  intros * Hx Hx'; gen A'.
+  induction Hx as [|* ? IHHx]; intros; inversion_clear Hx';
+    f_equal;
+    intuition.
Qed.

-#[export]
-Hint Resolve ctx_decomp : mcltt.
+Lemma ctx_decomp : forall {Γ A}, {{ Γ , A }} -> {{ Γ }} /\ exists i, {{ Γ A : Type@i }}.
+Proof with now eauto.
+  inversion 1...
+Qed.

-Corollary ctx_decomp_left : forall {Γ A}, {{ Γ , A }} -> {{ Γ }}.
+Corollary ctx_decomp_left : forall {Γ A}, {{ Γ , A }} -> {{ Γ }}.
Proof with easy.
  intros * ?%ctx_decomp...
Qed.

-Corollary ctx_decomp_right : forall {Γ A}, {{ Γ , A }} -> exists i, {{ Γ A : Type@i }}.
+Corollary ctx_decomp_right : forall {Γ A}, {{ Γ , A }} -> exists i, {{ Γ A : Type@i }}.
Proof with easy.
  intros * ?%ctx_decomp...
Qed.
@@ -84,25 +90,29 @@

Mcltt.Core.Syntactic.System.Lemmas

+

Core Presuppositions

+ +
+

Context Presuppositions


-Lemma presup_ctx_eq : forall {Γ Δ}, {{ Γ Δ }} -> {{ Γ }} /\ {{ Δ }}.
+Lemma presup_ctx_eq : forall {Γ Δ}, {{ Γ Δ }} -> {{ Γ }} /\ {{ Δ }}.
Proof with mautosolve.
  induction 1; destruct_pairs...
Qed.

-Corollary presup_ctx_eq_left : forall {Γ Δ}, {{ Γ Δ }} -> {{ Γ }}.
+Corollary presup_ctx_eq_left : forall {Γ Δ}, {{ Γ Δ }} -> {{ Γ }}.
Proof with easy.
  intros * ?%presup_ctx_eq...
Qed.

-Corollary presup_ctx_eq_right : forall {Γ Δ}, {{ Γ Δ }} -> {{ Δ }}.
+Corollary presup_ctx_eq_right : forall {Γ Δ}, {{ Γ Δ }} -> {{ Δ }}.
Proof with easy.
  intros * ?%presup_ctx_eq...
Qed.
@@ -112,19 +122,19 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve presup_ctx_eq presup_ctx_eq_left presup_ctx_eq_right : mcltt.

-Lemma presup_sub : forall {Γ Δ σ}, {{ Γ s σ : Δ }} -> {{ Γ }} /\ {{ Δ }}.
+Lemma presup_sub : forall {Γ Δ σ}, {{ Γ s σ : Δ }} -> {{ Γ }} /\ {{ Δ }}.
Proof with mautosolve.
  induction 1; destruct_pairs...
Qed.

-Corollary presup_sub_left : forall {Γ Δ σ}, {{ Γ s σ : Δ }} -> {{ Γ }}.
+Corollary presup_sub_left : forall {Γ Δ σ}, {{ Γ s σ : Δ }} -> {{ Γ }}.
Proof with easy.
  intros * ?%presup_sub...
Qed.

-Corollary presup_sub_right : forall {Γ Δ σ}, {{ Γ s σ : Δ }} -> {{ Δ }}.
+Corollary presup_sub_right : forall {Γ Δ σ}, {{ Γ s σ : Δ }} -> {{ Δ }}.
Proof with easy.
  intros * ?%presup_sub...
Qed.
@@ -142,7 +152,7 @@

Mcltt.Core.Syntactic.System.Lemmas


-Lemma presup_exp_ctx : forall {Γ M A}, {{ Γ M : A }} -> {{ Γ }}.
+Lemma presup_exp_ctx : forall {Γ M A}, {{ Γ M : A }} -> {{ Γ }}.
Proof with mautosolve.
  induction 1...
Qed.
@@ -160,19 +170,19 @@

Mcltt.Core.Syntactic.System.Lemmas


-Lemma presup_sub_eq_ctx : forall {Γ Δ σ σ'}, {{ Γ s σ σ' : Δ }} -> {{ Γ }} /\ {{ Δ }}.
+Lemma presup_sub_eq_ctx : forall {Γ Δ σ σ'}, {{ Γ s σ σ' : Δ }} -> {{ Γ }} /\ {{ Δ }}.
Proof with mautosolve.
  induction 1; destruct_pairs...
Qed.

-Corollary presup_sub_eq_ctx_left : forall {Γ Δ σ σ'}, {{ Γ s σ σ' : Δ }} -> {{ Γ }}.
+Corollary presup_sub_eq_ctx_left : forall {Γ Δ σ σ'}, {{ Γ s σ σ' : Δ }} -> {{ Γ }}.
Proof with easy.
  intros * ?%presup_sub_eq_ctx...
Qed.

-Corollary presup_sub_eq_ctx_right : forall {Γ Δ σ σ'}, {{ Γ s σ σ' : Δ }} -> {{ Δ }}.
+Corollary presup_sub_eq_ctx_right : forall {Γ Δ σ σ'}, {{ Γ s σ σ' : Δ }} -> {{ Δ }}.
Proof with easy.
  intros * ?%presup_sub_eq_ctx...
Qed.
@@ -182,7 +192,7 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve presup_sub_eq_ctx presup_sub_eq_ctx_left presup_sub_eq_ctx_right : mcltt.

-Lemma presup_exp_eq_ctx : forall {Γ M M' A}, {{ Γ M M' : A }} -> {{ Γ }}.
+Lemma presup_exp_eq_ctx : forall {Γ M M' A}, {{ Γ M M' : A }} -> {{ Γ }}.
Proof with mautosolve 2.
  induction 1...
Qed.
@@ -205,21 +215,21 @@

Mcltt.Core.Syntactic.System.Lemmas


-Lemma wf_cumu : forall Γ A i,
-    {{ Γ A : Type@i }} ->
-    {{ Γ A : Type@(S i) }}.
+Lemma wf_cumu : forall Γ A i,
+    {{ Γ A : Type@i }} ->
+    {{ Γ A : Type@(S i) }}.
Proof with mautosolve.
  intros.
-  enough {{ Γ }}...
+  enough {{ Γ }}...
Qed.

-Lemma wf_exp_eq_cumu : forall Γ A A' i,
-    {{ Γ A A' : Type@i }} ->
-    {{ Γ A A' : Type@(S i) }}.
+Lemma wf_exp_eq_cumu : forall Γ A A' i,
+    {{ Γ A A' : Type@i }} ->
+    {{ Γ A A' : Type@(S i) }}.
Proof with mautosolve.
  intros.
-  enough {{ Γ }}...
+  enough {{ Γ }}...
Qed.

@@ -227,9 +237,9 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_cumu wf_exp_eq_cumu : mcltt.

-Lemma wf_ctx_sub_refl : forall Γ Δ,
-    {{ Γ Δ }} ->
-    {{ Γ Δ }}.
+Lemma wf_ctx_sub_refl : forall Γ Δ,
+    {{ Γ Δ }} ->
+    {{ Γ Δ }}.
Proof. induction 1; mauto. Qed.

@@ -237,17 +247,17 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_ctx_sub_refl : mcltt.

-Lemma wf_conv : forall Γ M A i A',
-    {{ Γ M : A }} ->
+Lemma wf_conv : forall Γ M A i A',
+    {{ Γ M : A }} ->
    
The next argument will be removed in SystemOpt
-    {{ Γ A' : Type@i }} ->
-    {{ Γ A A' : Type@i }} ->
-    {{ Γ M : A' }}.
+    {{ Γ A' : Type@i }} ->
+    {{ Γ A A' : Type@i }} ->
+    {{ Γ M : A' }}.
Proof. mauto. Qed.

@@ -255,10 +265,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_conv : mcltt.

-Lemma wf_sub_conv : forall Γ σ Δ Δ',
-  {{ Γ s σ : Δ }} ->
-  {{ Δ Δ' }} ->
-  {{ Γ s σ : Δ' }}.
+Lemma wf_sub_conv : forall Γ σ Δ Δ',
+  {{ Γ s σ : Δ }} ->
+  {{ Δ Δ' }} ->
+  {{ Γ s σ : Δ' }}.
Proof. mauto. Qed.

@@ -266,17 +276,17 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_sub_conv : mcltt.

-Lemma wf_exp_eq_conv : forall Γ M M' A A' i,
-   {{ Γ M M' : A }} ->
+Lemma wf_exp_eq_conv : forall Γ M M' A A' i,
+   {{ Γ M M' : A }} ->
   
The next argument will be removed in SystemOpt
-   {{ Γ A' : Type@i }} ->
-   {{ Γ A A' : Type@i }} ->
-   {{ Γ M M' : A' }}.
+   {{ Γ A' : Type@i }} ->
+   {{ Γ A A' : Type@i }} ->
+   {{ Γ M M' : A' }}.
Proof. mauto. Qed.

@@ -284,10 +294,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_exp_eq_conv : mcltt.

-Lemma wf_sub_eq_conv : forall Γ σ σ' Δ Δ',
-    {{ Γ s σ σ' : Δ }} ->
-    {{ Δ Δ' }} ->
-    {{ Γ s σ σ' : Δ' }}.
+Lemma wf_sub_eq_conv : forall Γ σ σ' Δ Δ',
+    {{ Γ s σ σ' : Δ }} ->
+    {{ Δ Δ' }} ->
+    {{ Γ s σ σ' : Δ' }}.
Proof. mauto. Qed.

@@ -295,7 +305,7 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_sub_eq_conv : mcltt.

-Add Parametric Morphism Γ : (wf_sub_eq Γ)
+Add Parametric Morphism Γ : (wf_sub_eq Γ)
    with signature wf_ctx_eq ==> eq ==> eq ==> iff as wf_sub_eq_morphism_iff3.
Proof.
  intros Δ Δ' H **; split; [| symmetry in H]; mauto.
@@ -310,10 +320,10 @@

Mcltt.Core.Syntactic.System.Lemmas


-Lemma lift_exp_ge : forall {Γ A n m},
-    n <= m ->
-    {{ Γ A : Type@n }} ->
-    {{ Γ A : Type@m }}.
+Lemma lift_exp_ge : forall {Γ A n m},
+    n <= m ->
+    {{ Γ A : Type@n }} ->
+    {{ Γ A : Type@m }}.
Proof with mautosolve.
  induction 1...
Qed.
@@ -323,28 +333,28 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve lift_exp_ge : mcltt.

-Corollary lift_exp_max_left : forall {Γ A n} m,
-    {{ Γ A : Type@n }} ->
-    {{ Γ A : Type@(max n m) }}.
+Corollary lift_exp_max_left : forall {Γ A n} m,
+    {{ Γ A : Type@n }} ->
+    {{ Γ A : Type@(max n m) }}.
Proof with mautosolve.
  intros.
  assert (n <= max n m) by lia...
Qed.

-Corollary lift_exp_max_right : forall {Γ A} n {m},
-    {{ Γ A : Type@m }} ->
-    {{ Γ A : Type@(max n m) }}.
+Corollary lift_exp_max_right : forall {Γ A} n {m},
+    {{ Γ A : Type@m }} ->
+    {{ Γ A : Type@(max n m) }}.
Proof with mautosolve.
  intros.
  assert (m <= max n m) by lia...
Qed.

-Lemma lift_exp_eq_ge : forall {Γ A A' n m},
-    n <= m ->
-    {{ Γ A A': Type@n }} ->
-    {{ Γ A A' : Type@m }}.
+Lemma lift_exp_eq_ge : forall {Γ A A' n m},
+    n <= m ->
+    {{ Γ A A': Type@n }} ->
+    {{ Γ A A' : Type@m }}.
Proof with mautosolve.
  induction 1; subst...
Qed.
@@ -354,18 +364,18 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve lift_exp_eq_ge : mcltt.

-Corollary lift_exp_eq_max_left : forall {Γ A A' n} m,
-    {{ Γ A A' : Type@n }} ->
-    {{ Γ A A' : Type@(max n m) }}.
+Corollary lift_exp_eq_max_left : forall {Γ A A' n} m,
+    {{ Γ A A' : Type@n }} ->
+    {{ Γ A A' : Type@(max n m) }}.
Proof with mautosolve.
  intros.
  assert (n <= max n m) by lia...
Qed.

-Corollary lift_exp_eq_max_right : forall {Γ A A'} n {m},
-    {{ Γ A A' : Type@m }} ->
-    {{ Γ A A' : Type@(max n m) }}.
+Corollary lift_exp_eq_max_right : forall {Γ A A'} n {m},
+    {{ Γ A A' : Type@m }} ->
+    {{ Γ A A' : Type@(max n m) }}.
Proof with mautosolve.
  intros.
  assert (m <= max n m) by lia...
@@ -381,9 +391,9 @@

Mcltt.Core.Syntactic.System.Lemmas


-Lemma exp_eq_refl : forall {Γ M A},
-    {{ Γ M : A }} ->
-    {{ Γ M M : A }}.
+Lemma exp_eq_refl : forall {Γ M A},
+    {{ Γ M : A }} ->
+    {{ Γ M M : A }}.
Proof. mauto. Qed.

@@ -391,14 +401,14 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_refl : mcltt.

-Lemma exp_eq_trans_typ_max : forall {Γ i i' A A' A''},
-    {{ Γ A A' : Type@i }} ->
-    {{ Γ A' A'' : Type@i' }} ->
-    {{ Γ A A'' : Type@(max i i') }}.
+Lemma exp_eq_trans_typ_max : forall {Γ i i' A A' A''},
+    {{ Γ A A' : Type@i }} ->
+    {{ Γ A' A'' : Type@i' }} ->
+    {{ Γ A A'' : Type@(max i i') }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ A A' : Type@(max i i') }} by eauto using lift_exp_eq_max_left.
-  assert {{ Γ A' A'' : Type@(max i i') }} by eauto using lift_exp_eq_max_right...
+  assert {{ Γ A A' : Type@(max i i') }} by eauto using lift_exp_eq_max_left.
+  assert {{ Γ A' A'' : Type@(max i i') }} by eauto using lift_exp_eq_max_right...
Qed.

@@ -406,15 +416,27 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_trans_typ_max : mcltt.

-Lemma sub_eq_refl : forall {Γ σ Δ},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ s σ σ : Δ }}.
+Lemma sub_eq_refl : forall {Γ σ Δ},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ s σ σ : Δ }}.
Proof. mauto. Qed.

#[export]
Hint Resolve sub_eq_refl : mcltt.
+
+Lemma ctx_eq_refl : forall {Γ},
+    {{ Γ }} ->
+    {{ Γ Γ }}.
+Proof.
+  induction 1; mauto 4.
+Qed.
+ +
+#[export]
+Hint Resolve ctx_eq_refl : mcltt.
+
@@ -425,10 +447,10 @@

Mcltt.Core.Syntactic.System.Lemmas


-Lemma exp_sub_typ : forall {Δ Γ A σ i},
-    {{ Δ A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ A[σ] : Type@i }}.
+Lemma exp_sub_typ : forall {Δ Γ A σ i},
+    {{ Δ A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ A[σ] : Type@i }}.
Proof with mautosolve 3.
  intros.
  econstructor; mauto 3.
@@ -440,15 +462,15 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_sub_typ : mcltt.

-Lemma presup_ctx_lookup_typ : forall {Γ A x},
-    {{ Γ }} ->
-    {{ #x : A Γ }} ->
-    exists i, {{ Γ A : Type@i }}.
+Lemma presup_ctx_lookup_typ : forall {Γ A x},
+    {{ Γ }} ->
+    {{ #x : A Γ }} ->
+    exists i, {{ Γ A : Type@i }}.
Proof with mautosolve 4.
  intros * .
  induction 1; inversion_clear ;
-    [assert {{ Γ, A Type@i[Wk] Type@i : Type@(S i) }} by mauto 4
-    | assert (exists i, {{ Γ A : Type@i }}) as [] by eauto]; econstructor...
+    [assert {{ Γ, A Type@i[Wk] Type@i : Type@(S i) }} by mauto 4
+    | assert (exists i, {{ Γ A : Type@i }}) as [] by eauto]; econstructor...
Qed.

@@ -456,32 +478,32 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve presup_ctx_lookup_typ : mcltt.

-Lemma exp_eq_sub_cong_typ1 : forall {Δ Γ A A' σ i},
-    {{ Δ A A' : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ A[σ] A'[σ] : Type@i }}.
+Lemma exp_eq_sub_cong_typ1 : forall {Δ Γ A A' σ i},
+    {{ Δ A A' : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ A[σ] A'[σ] : Type@i }}.
Proof with mautosolve 3.
  intros.
  eapply wf_exp_eq_conv...
Qed.

-Lemma exp_eq_sub_cong_typ2' : forall {Δ Γ A σ τ i},
-    {{ Δ A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ s σ τ : Δ }} ->
-    {{ Γ A[σ] A[τ] : Type@i }}.
+Lemma exp_eq_sub_cong_typ2' : forall {Δ Γ A σ τ i},
+    {{ Δ A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ s σ τ : Δ }} ->
+    {{ Γ A[σ] A[τ] : Type@i }}.
Proof with mautosolve 3.
  intros.
  eapply wf_exp_eq_conv...
Qed.

-Lemma exp_eq_sub_compose_typ : forall {Ψ Δ Γ A σ τ i},
-    {{ Ψ A : Type@i }} ->
-    {{ Δ s σ : Ψ }} ->
-    {{ Γ s τ : Δ }} ->
-    {{ Γ A[σ][τ] A[στ] : Type@i }}.
+Lemma exp_eq_sub_compose_typ : forall {Ψ Δ Γ A σ τ i},
+    {{ Ψ A : Type@i }} ->
+    {{ Δ s σ : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ Γ A[σ][τ] A[στ] : Type@i }}.
Proof with mautosolve 3.
  intros.
  eapply wf_exp_eq_conv...
@@ -492,34 +514,99 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_sub_cong_typ1 exp_eq_sub_cong_typ2' exp_eq_sub_compose_typ : mcltt.

-Lemma exp_eq_typ_sub_sub : forall {Γ Δ Ψ σ τ i},
-    {{ Δ s σ : Ψ }} ->
-    {{ Γ s τ : Δ }} ->
-    {{ Γ Type@i[σ][τ] Type@i : Type@(S i) }}.
-Proof. mauto. Qed.
+Lemma exp_eq_sub_compose_weaken_extend_typ : forall {Γ σ Δ i A j B M},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ B : Type@j }} ->
+    {{ Γ M : B[σ] }} ->
+    {{ Γ A[Wk][σ,,M] A[σ] : Type@i }}.
+Proof with mautosolve 3.
+  intros.
+  assert {{ Δ, B s Wk : Δ }} by mauto 4.
+  transitivity {{{ A[Wk(σ,,M)] }}}; [mautosolve 4 |].
+  eapply exp_eq_sub_cong_typ2'...
+Qed.

#[export]
-Hint Resolve exp_eq_typ_sub_sub : mcltt.
+Hint Resolve exp_eq_sub_compose_weaken_extend_typ : mcltt.
+ +
+Lemma exp_eq_sub_compose_weaken_id_extend_typ : forall {Γ i A j B M},
+    {{ Γ A : Type@i }} ->
+    {{ Γ B : Type@j }} ->
+    {{ Γ M : B }} ->
+    {{ Γ A[Wk][Id,,M] A : Type@i }}.
+Proof with mautosolve 4.
+  intros.
+  assert {{ Γ B[Id] : Type@_ }} by mauto 4.
+  assert {{ Γ B B[Id] }} by mauto 4.
+  assert {{ Γ M : B[Id] }} by mauto 2.
+  transitivity {{{ A[Id] }}}...
+Qed.
+ +
#[export]
-Hint Rewrite -> @exp_eq_sub_compose_typ @exp_eq_typ_sub_sub using mauto 4 : mcltt.
+Hint Resolve exp_eq_sub_compose_weaken_id_extend_typ : mcltt.

-Lemma functional_ctx_lookup : forall {Γ A A' x},
-    {{ #x : A Γ }} ->
-    {{ #x : A' Γ }} ->
-    A = A'.
-Proof with mautosolve.
-  intros * Hx Hx'; gen A'.
-  induction Hx as [|* ? IHHx]; intros; inversion_clear Hx';
-    f_equal;
-    intuition.
+Lemma exp_eq_sub_compose_double_weaken_double_extend_typ : forall {Γ σ Δ i A j B M k C N},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ B : Type@j }} ->
+    {{ Γ M : B[σ] }} ->
+    {{ Δ, B C : Type@k }} ->
+    {{ Γ N : C[σ,,M] }} ->
+    {{ Γ A[WkWk][σ,,M,,N] A[σ] : Type@i }}.
+Proof with mautosolve 4.
+  intros.
+  assert {{ Δ, B s Wk : Δ }} by mauto 4.
+  assert {{ Δ, B, C s Wk : Δ, B }} by mauto 4.
+  transitivity {{{ A[Wk][Wk][σ,,M,,N] }}}; [eapply exp_eq_sub_cong_typ1; mautosolve 3 |].
+  transitivity {{{ A[Wk][σ,,M] }}}...
Qed.

-Lemma vlookup_0_typ : forall {Γ i},
-    {{ Γ }} ->
-    {{ Γ, Type@i # 0 : Type@i }}.
+#[export]
+Hint Resolve exp_eq_sub_compose_double_weaken_double_extend_typ : mcltt.
+ +
+Lemma exp_eq_sub_compose_double_weaken_id_double_extend_typ : forall {Γ i A j B M k C N},
+    {{ Γ A : Type@i }} ->
+    {{ Γ B : Type@j }} ->
+    {{ Γ M : B }} ->
+    {{ Γ, B C : Type@k }} ->
+    {{ Γ N : C[Id,,M] }} ->
+    {{ Γ A[WkWk][Id,,M,,N] A : Type@i }}.
+Proof with mautosolve 4.
+  intros.
+  assert {{ Γ B[Id] : Type@_ }} by mauto 4.
+  assert {{ Γ B B[Id] }} by mauto 4.
+  assert {{ Γ M : B[Id] }} by mauto 2.
+  transitivity {{{ A[Id] }}}...
+Qed.
+ +
+#[export]
+Hint Resolve exp_eq_sub_compose_double_weaken_id_double_extend_typ : mcltt.
+ +
+Lemma exp_eq_typ_sub_sub : forall {Γ Δ Ψ σ τ i},
+    {{ Δ s σ : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ Γ Type@i[σ][τ] Type@i : Type@(S i) }}.
+Proof. mauto. Qed.
+ +
+#[export]
+Hint Resolve exp_eq_typ_sub_sub : mcltt.
+#[export]
+Hint Rewrite -> @exp_eq_sub_compose_typ @exp_eq_typ_sub_sub using mauto 4 : mcltt.
+ +
+Lemma vlookup_0_typ : forall {Γ i},
+    {{ Γ }} ->
+    {{ Γ, Type@i #0 : Type@i }}.
Proof with mautosolve 4.
  intros.
  eapply wf_conv; mauto 4.
@@ -527,13 +614,13 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma vlookup_1_typ : forall {Γ i A j},
-    {{ Γ, Type@i A : Type@j }} ->
-    {{ Γ, Type@i, A # 1 : Type@i }}.
+Lemma vlookup_1_typ : forall {Γ i A j},
+    {{ Γ, Type@i A : Type@j }} ->
+    {{ Γ, Type@i, A #1 : Type@i }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ, Type@i s Wk : Γ }} by mauto 4.
-  assert {{ Γ, Type@i, A s Wk : Γ, Type@i }} by mauto 4.
+  assert {{ Γ, Type@i s Wk : Γ }} by mauto 4.
+  assert {{ Γ, Type@i, A s Wk : Γ, Type@i }} by mauto 4.
  eapply wf_conv...
Qed.
@@ -542,10 +629,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve vlookup_0_typ vlookup_1_typ : mcltt.

-Lemma exp_sub_typ_helper : forall {Γ σ Δ M i},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M : Type@i }} ->
-    {{ Γ M : Type@i[σ] }}.
+Lemma exp_sub_typ_helper : forall {Γ σ Δ M i},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M : Type@i }} ->
+    {{ Γ M : Type@i[σ] }}.
Proof.
  intros.
  do 2 (econstructor; mauto 4).
@@ -556,10 +643,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_sub_typ_helper : mcltt.

-Lemma exp_eq_var_0_sub_typ : forall {Γ σ Δ M i},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M : Type@i }} ->
-    {{ Γ #0[σ,,M] M : Type@i }}.
+Lemma exp_eq_var_0_sub_typ : forall {Γ σ Δ M i},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M : Type@i }} ->
+    {{ Γ #0[σ,,M] M : Type@i }}.
Proof with mautosolve 4.
  intros.
  eapply wf_exp_eq_conv; mauto 3.
@@ -567,16 +654,16 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma exp_eq_var_1_sub_typ : forall {Γ σ Δ A i M j},
-    {{ Γ s σ : Δ }} ->
-    {{ Δ A : Type@i }} ->
-    {{ Γ M : A[σ] }} ->
-    {{ #0 : Type@j[Wk] Δ }} ->
-    {{ Γ #1[σ,,M] #0[σ] : Type@j }}.
+Lemma exp_eq_var_1_sub_typ : forall {Γ σ Δ A i M j},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Γ M : A[σ] }} ->
+    {{ #0 : Type@j[Wk] Δ }} ->
+    {{ Γ #1[σ,,M] #0[σ] : Type@j }}.
Proof with mautosolve 4.
  inversion 4 as [? Δ'|]; subst.
-  assert {{ Δ' }} by mauto 4.
-  assert {{ Δ', Type@j s Wk : Δ' }} by mauto 4.
+  assert {{ Δ' }} by mauto 4.
+  assert {{ Δ', Type@j s Wk : Δ' }} by mauto 4.
  eapply wf_exp_eq_conv...
Qed.
@@ -587,16 +674,16 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Rewrite -> @exp_eq_var_0_sub_typ @exp_eq_var_1_sub_typ : mcltt.

-Lemma exp_eq_var_0_weaken_typ : forall {Γ A i},
-    {{ Γ, A }} ->
-    {{ #0 : Type@i[Wk] Γ }} ->
-    {{ Γ, A #0[Wk] #1 : Type@i }}.
+Lemma exp_eq_var_0_weaken_typ : forall {Γ A i},
+    {{ Γ, A }} ->
+    {{ #0 : Type@i[Wk] Γ }} ->
+    {{ Γ, A #0[Wk] #1 : Type@i }}.
Proof with mautosolve 3.
  inversion_clear 1.
  inversion 1 as [? Γ'|]; subst.
-  assert {{ Γ' }} by mauto.
-  assert {{ Γ', Type@i s Wk : Γ' }} by mauto 4.
-  assert {{ Γ', Type@i, A s Wk : Γ', Type@i }} by mauto 4.
+  assert {{ Γ' }} by mauto.
+  assert {{ Γ', Type@i s Wk : Γ' }} by mauto 4.
+  assert {{ Γ', Type@i, A s Wk : Γ', Type@i }} by mauto 4.
  eapply wf_exp_eq_conv...
Qed.
@@ -605,10 +692,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_var_0_weaken_typ : mcltt.

-Lemma sub_extend_typ : forall {Γ σ Δ M i},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M : Type@i }} ->
-    {{ Γ s σ,,M : Δ, Type@i }}.
+Lemma sub_extend_typ : forall {Γ σ Δ M i},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M : Type@i }} ->
+    {{ Γ s σ,,M : Δ, Type@i }}.
Proof with mautosolve 4.
  intros.
  econstructor...
@@ -619,11 +706,11 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_extend_typ : mcltt.

-Lemma sub_eq_extend_cong_typ : forall {Γ σ σ' Δ M M' i},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ s σ σ' : Δ }} ->
-    {{ Γ M M' : Type@i }} ->
-    {{ Γ s σ,,M σ',,M' : Δ, Type@i }}.
+Lemma sub_eq_extend_cong_typ : forall {Γ σ σ' Δ M M' i},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ s σ σ' : Δ }} ->
+    {{ Γ M M' : Type@i }} ->
+    {{ Γ s σ,,M σ',,M' : Δ, Type@i }}.
Proof with mautosolve 4.
  intros.
  econstructor; mauto 3.
@@ -631,25 +718,25 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma sub_eq_extend_compose_typ : forall {Γ τ Γ' σ Γ'' A i M j},
-    {{ Γ' s σ : Γ'' }} ->
-    {{ Γ'' A : Type@i }} ->
-    {{ Γ' M : Type@j }} ->
-    {{ Γ s τ : Γ' }} ->
-    {{ Γ s (σ,,M) τ (σ τ),,M[τ] : Γ'', Type@j }}.
+Lemma sub_eq_extend_compose_typ : forall {Γ τ Γ' σ Γ'' A i M j},
+    {{ Γ' s σ : Γ'' }} ->
+    {{ Γ'' A : Type@i }} ->
+    {{ Γ' M : Type@j }} ->
+    {{ Γ s τ : Γ' }} ->
+    {{ Γ s (σ,,M) τ (σ τ),,M[τ] : Γ'', Type@j }}.
Proof with mautosolve 4.
  intros.
  econstructor...
Qed.

-Lemma sub_eq_p_extend_typ : forall {Γ σ Γ' M i},
-    {{ Γ' s σ : Γ }} ->
-    {{ Γ' M : Type@i }} ->
-    {{ Γ' s Wk (σ,,M) σ : Γ }}.
+Lemma sub_eq_p_extend_typ : forall {Γ σ Γ' M i},
+    {{ Γ' s σ : Γ }} ->
+    {{ Γ' M : Type@i }} ->
+    {{ Γ' s Wk (σ,,M) σ : Γ }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ Type@i : Type@(S i) }} by mauto.
+  assert {{ Γ Type@i : Type@(S i) }} by mauto.
  econstructor; mauto 3.
Qed.
@@ -658,37 +745,19 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_eq_extend_cong_typ sub_eq_extend_compose_typ sub_eq_p_extend_typ : mcltt.

-Lemma sub_eq_wk_var0_id : forall {Γ A i},
-    {{ Γ A : Type@i }} ->
-    {{ Γ, A s Wk,,#0 Id : Γ, A }}.
-Proof with mautosolve 4.
-  intros * ?.
-  assert {{ Γ, A }} by mauto 3.
-  assert {{ Γ, A s (WkId),,#0[Id] Id : Γ, A }} by mauto.
-  assert {{ Γ, A s Wk WkId : Γ }} by mauto.
-  enough {{ Γ, A #0 #0[Id] : A[Wk] }}...
-Qed.
- -
-#[export]
-Hint Resolve sub_eq_wk_var0_id : mcltt.
-#[export]
-Hint Rewrite -> @sub_eq_wk_var0_id using mauto 4 : mcltt.
- -
-Lemma exp_eq_sub_sub_compose_cong_typ : forall {Γ Δ Δ' Ψ σ τ σ' τ' A i},
-    {{ Ψ A : Type@i }} ->
-    {{ Δ s σ : Ψ }} ->
-    {{ Δ' s σ' : Ψ }} ->
-    {{ Γ s τ : Δ }} ->
-    {{ Γ s τ' : Δ' }} ->
-    {{ Γ s στ σ'τ' : Ψ }} ->
-    {{ Γ A[σ][τ] A[σ'][τ'] : Type@i }}.
+Lemma exp_eq_sub_sub_compose_cong_typ : forall {Γ Δ Δ' Ψ σ τ σ' τ' A i},
+    {{ Ψ A : Type@i }} ->
+    {{ Δ s σ : Ψ }} ->
+    {{ Δ' s σ' : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ Γ s τ' : Δ' }} ->
+    {{ Γ s στ σ'τ' : Ψ }} ->
+    {{ Γ A[σ][τ] A[σ'][τ'] : Type@i }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ A[σ][τ] A[στ] : Type@i }} by mauto.
-  assert {{ Γ A[στ] A[σ'τ'] : Type@i }} by mauto.
-  enough {{ Γ A[σ'τ'] A[σ'][τ'] : Type@i }}...
+  assert {{ Γ A[σ][τ] A[στ] : Type@i }} by mauto.
+  assert {{ Γ A[στ] A[σ'τ'] : Type@i }} by mauto.
+  enough {{ Γ A[σ'τ'] A[σ'][τ'] : Type@i }}...
Qed.

@@ -705,10 +774,10 @@

Mcltt.Core.Syntactic.System.Lemmas


-Lemma exp_sub_nat : forall {Δ Γ M σ},
-    {{ Δ M : }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M[σ] : }}.
+Lemma exp_sub_nat : forall {Δ Γ M σ},
+    {{ Δ M : }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M[σ] : }}.
Proof with mautosolve 3.
  intros.
  econstructor; mauto 3.
@@ -720,32 +789,32 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_sub_nat : mcltt.

-Lemma exp_eq_sub_cong_nat1 : forall {Δ Γ M M' σ},
-    {{ Δ M M' : }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M[σ] M'[σ] : }}.
+Lemma exp_eq_sub_cong_nat1 : forall {Δ Γ M M' σ},
+    {{ Δ M M' : }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M[σ] M'[σ] : }}.
Proof with mautosolve 3.
  intros.
  eapply wf_exp_eq_conv...
Qed.

-Lemma exp_eq_sub_cong_nat2 : forall {Δ Γ M σ τ},
-    {{ Δ M : }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ s σ τ : Δ }} ->
-    {{ Γ M[σ] M[τ] : }}.
+Lemma exp_eq_sub_cong_nat2 : forall {Δ Γ M σ τ},
+    {{ Δ M : }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ s σ τ : Δ }} ->
+    {{ Γ M[σ] M[τ] : }}.
Proof with mautosolve.
  intros.
  eapply wf_exp_eq_conv...
Qed.

-Lemma exp_eq_sub_compose_nat : forall {Ψ Δ Γ M σ τ},
-    {{ Ψ M : }} ->
-    {{ Δ s σ : Ψ }} ->
-    {{ Γ s τ : Δ }} ->
-    {{ Γ M[σ][τ] M[στ] : }}.
+Lemma exp_eq_sub_compose_nat : forall {Ψ Δ Γ M σ τ},
+    {{ Ψ M : }} ->
+    {{ Δ s σ : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ Γ M[σ][τ] M[στ] : }}.
Proof with mautosolve 4.
  intros.
  eapply wf_exp_eq_conv...
@@ -756,10 +825,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_sub_nat exp_eq_sub_cong_nat1 exp_eq_sub_cong_nat2 exp_eq_sub_compose_nat : mcltt.

-Lemma exp_eq_nat_sub_sub : forall {Γ Δ Ψ σ τ},
-    {{ Δ s σ : Ψ }} ->
-    {{ Γ s τ : Δ }} ->
-    {{ Γ [σ][τ] : Type@0 }}.
+Lemma exp_eq_nat_sub_sub : forall {Γ Δ Ψ σ τ},
+    {{ Δ s σ : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ Γ [σ][τ] : Type@0 }}.
Proof. mauto. Qed.

@@ -767,11 +836,11 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_nat_sub_sub : mcltt.

-Lemma exp_eq_nat_sub_sub_to_nat_sub : forall {Γ Δ Ψ Ψ' σ τ σ'},
-    {{ Δ s σ : Ψ }} ->
-    {{ Γ s τ : Δ }} ->
-    {{ Γ s σ' : Ψ' }} ->
-    {{ Γ [σ][τ] [σ'] : Type@0 }}.
+Lemma exp_eq_nat_sub_sub_to_nat_sub : forall {Γ Δ Ψ Ψ' σ τ σ'},
+    {{ Δ s σ : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ Γ s σ' : Ψ' }} ->
+    {{ Γ [σ][τ] [σ'] : Type@0 }}.
Proof. mauto. Qed.

@@ -779,9 +848,86 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_nat_sub_sub_to_nat_sub : mcltt.

-Lemma vlookup_0_nat : forall {Γ},
-    {{ Γ }} ->
-    {{ Γ, # 0 : }}.
+Lemma exp_eq_sub_compose_weaken_extend_nat : forall {Γ σ Δ M i B N},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ M : }} ->
+    {{ Δ B : Type@i }} ->
+    {{ Γ N : B[σ] }} ->
+    {{ Γ M[Wk][σ,,N] M[σ] : }}.
+Proof with mautosolve 3.
+  intros.
+  assert {{ Δ, B s Wk : Δ }} by mauto 4.
+  transitivity {{{ M[Wk(σ,,N)] }}}; [mauto 4 |].
+  eapply exp_eq_sub_cong_nat2...
+Qed.
+ +
+#[export]
+Hint Resolve exp_eq_sub_compose_weaken_extend_nat : mcltt.
+ +
+Lemma exp_eq_sub_compose_weaken_id_extend_nat : forall {Γ M i B N},
+    {{ Γ M : }} ->
+    {{ Γ B : Type@i }} ->
+    {{ Γ N : B }} ->
+    {{ Γ M[Wk][Id,,N] M : }}.
+Proof with mautosolve 4.
+  intros.
+  assert {{ Γ B[Id] : Type@_ }} by mauto 4.
+  assert {{ Γ B B[Id] }} by mauto 4.
+  assert {{ Γ N : B[Id] }} by mauto 2.
+  transitivity {{{ M[Id] }}}...
+Qed.
+ +
+#[export]
+Hint Resolve exp_eq_sub_compose_weaken_id_extend_nat : mcltt.
+ +
+Lemma exp_eq_sub_compose_double_weaken_double_extend_nat : forall {Γ σ Δ M i B N j C L},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ M : }} ->
+    {{ Δ B : Type@i }} ->
+    {{ Γ N : B[σ] }} ->
+    {{ Δ, B C : Type@j }} ->
+    {{ Γ L : C[σ,,N] }} ->
+    {{ Γ M[WkWk][σ,,N,,L] M[σ] : }}.
+Proof with mautosolve 4.
+  intros.
+  assert {{ Δ, B s Wk : Δ }} by mauto 4.
+  assert {{ Δ, B, C s Wk : Δ, B }} by mauto 4.
+  transitivity {{{ M[Wk][Wk][σ,,N,,L] }}}; [eapply exp_eq_sub_cong_nat1; mautosolve 3 |].
+  transitivity {{{ M[Wk][σ,,N] }}}...
+Qed.
+ +
+#[export]
+Hint Resolve exp_eq_sub_compose_double_weaken_double_extend_nat : mcltt.
+ +
+Lemma exp_eq_sub_compose_double_weaken_id_double_extend_nat : forall {Γ M i B N j C L},
+    {{ Γ M : }} ->
+    {{ Γ B : Type@i }} ->
+    {{ Γ N : B }} ->
+    {{ Γ, B C : Type@j }} ->
+    {{ Γ L : C[Id,,N] }} ->
+    {{ Γ M[WkWk][Id,,N,,L] M : }}.
+Proof with mautosolve 4.
+  intros.
+  assert {{ Γ B[Id] : Type@_ }} by mauto 4.
+  assert {{ Γ B B[Id] }} by mauto 4.
+  assert {{ Γ N : B[Id] }} by mauto 2.
+  transitivity {{{ M[Id] }}}...
+Qed.
+ +
+#[export]
+Hint Resolve exp_eq_sub_compose_double_weaken_id_double_extend_nat : mcltt.
+ +
+Lemma vlookup_0_nat : forall {Γ},
+    {{ Γ }} ->
+    {{ Γ, # 0 : }}.
Proof with mautosolve 4.
  intros.
  eapply wf_conv; mauto 4.
@@ -789,13 +935,13 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma vlookup_1_nat : forall {Γ A i},
-    {{ Γ, A : Type@i }} ->
-    {{ Γ, , A # 1 : }}.
+Lemma vlookup_1_nat : forall {Γ A i},
+    {{ Γ, A : Type@i }} ->
+    {{ Γ, , A # 1 : }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ, s Wk : Γ }} by mauto 4.
-  assert {{ Γ, , A s Wk : Γ, }} by mauto 4.
+  assert {{ Γ, s Wk : Γ }} by mauto 4.
+  assert {{ Γ, , A s Wk : Γ, }} by mauto 4.
  eapply wf_conv...
Qed.
@@ -804,10 +950,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve vlookup_0_nat vlookup_1_nat : mcltt.

-Lemma exp_sub_nat_helper : forall {Γ σ Δ M},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M : }} ->
-    {{ Γ M : [σ] }}.
+Lemma exp_sub_nat_helper : forall {Γ σ Δ M},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M : }} ->
+    {{ Γ M : [σ] }}.
Proof.
  intros.
  do 2 (econstructor; mauto 4).
@@ -818,10 +964,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_sub_nat_helper : mcltt.

-Lemma exp_eq_var_0_sub_nat : forall {Γ σ Δ M},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M : }} ->
-    {{ Γ #0[σ,,M] M : }}.
+Lemma exp_eq_var_0_sub_nat : forall {Γ σ Δ M},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M : }} ->
+    {{ Γ #0[σ,,M] M : }}.
Proof with mautosolve 3.
  intros.
  eapply wf_exp_eq_conv; mauto 3.
@@ -829,16 +975,16 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma exp_eq_var_1_sub_nat : forall {Γ σ Δ A i M},
-    {{ Γ s σ : Δ }} ->
-    {{ Δ A : Type@i }} ->
-    {{ Γ M : A[σ] }} ->
-    {{ #0 : [Wk] Δ }} ->
-    {{ Γ #1[σ,,M] #0[σ] : }}.
+Lemma exp_eq_var_1_sub_nat : forall {Γ σ Δ A i M},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Γ M : A[σ] }} ->
+    {{ #0 : [Wk] Δ }} ->
+    {{ Γ #1[σ,,M] #0[σ] : }}.
Proof with mautosolve 4.
  inversion 4 as [? Δ'|]; subst.
-  assert {{ Γ #1[σ,, M] #0[σ] : [Wk][σ] }} by mauto 4.
-  assert {{ Γ [Wk][σ] : Type@0 }}...
+  assert {{ Γ #1[σ,, M] #0[σ] : [Wk][σ] }} by mauto 4.
+  assert {{ Γ [Wk][σ] : Type@0 }}...
Qed.

@@ -846,15 +992,15 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_var_0_sub_nat exp_eq_var_1_sub_nat : mcltt.

-Lemma exp_eq_var_0_weaken_nat : forall {Γ A},
-    {{ Γ, A }} ->
-    {{ #0 : [Wk] Γ }} ->
-    {{ Γ, A #0[Wk] #1 : }}.
+Lemma exp_eq_var_0_weaken_nat : forall {Γ A},
+    {{ Γ, A }} ->
+    {{ #0 : [Wk] Γ }} ->
+    {{ Γ, A #0[Wk] #1 : }}.
Proof with mautosolve 4.
  inversion 1; subst.
  inversion 1 as [? Γ'|]; subst.
-  assert {{ Γ', , A #0[Wk] # 1 : [Wk][Wk] }} by mauto 4.
-  assert {{ Γ', , A [Wk][Wk] : Type@0 }}...
+  assert {{ Γ', , A #0[Wk] # 1 : [Wk][Wk] }} by mauto 4.
+  assert {{ Γ', , A [Wk][Wk] : Type@0 }}...
Qed.

@@ -862,10 +1008,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_var_0_weaken_nat : mcltt.

-Lemma sub_extend_nat : forall {Γ σ Δ M},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M : }} ->
-    {{ Γ s σ,,M : Δ , }}.
+Lemma sub_extend_nat : forall {Γ σ Δ M},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M : }} ->
+    {{ Γ s σ,,M : Δ , }}.
Proof with mautosolve 3.
  intros.
  econstructor...
@@ -876,11 +1022,11 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_extend_nat : mcltt.

-Lemma sub_eq_extend_cong_nat : forall {Γ σ σ' Δ M M'},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ s σ σ' : Δ }} ->
-    {{ Γ M M' : }} ->
-    {{ Γ s σ,,M σ',,M' : Δ , }}.
+Lemma sub_eq_extend_cong_nat : forall {Γ σ σ' Δ M M'},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ s σ σ' : Δ }} ->
+    {{ Γ M M' : }} ->
+    {{ Γ s σ,,M σ',,M' : Δ , }}.
Proof with mautosolve 4.
  intros.
  econstructor; mauto 3.
@@ -888,24 +1034,24 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma sub_eq_extend_compose_nat : forall {Γ τ Γ' σ Γ'' M},
-    {{ Γ' s σ : Γ'' }} ->
-    {{ Γ' M : }} ->
-    {{ Γ s τ : Γ' }} ->
-    {{ Γ s (σ,,M) τ (σ τ),,M[τ] : Γ'' , }}.
+Lemma sub_eq_extend_compose_nat : forall {Γ τ Γ' σ Γ'' M},
+    {{ Γ' s σ : Γ'' }} ->
+    {{ Γ' M : }} ->
+    {{ Γ s τ : Γ' }} ->
+    {{ Γ s (σ,,M) τ (σ τ),,M[τ] : Γ'' , }}.
Proof with mautosolve 3.
  intros.
  econstructor...
Qed.

-Lemma sub_eq_p_extend_nat : forall {Γ σ Γ' M},
-    {{ Γ' s σ : Γ }} ->
-    {{ Γ' M : }} ->
-    {{ Γ' s Wk (σ,,M) σ : Γ }}.
+Lemma sub_eq_p_extend_nat : forall {Γ σ Γ' M},
+    {{ Γ' s σ : Γ }} ->
+    {{ Γ' M : }} ->
+    {{ Γ' s Wk (σ,,M) σ : Γ }}.
Proof with mautosolve 3.
  intros.
-  assert {{ Γ : Type@0 }} by mauto.
+  assert {{ Γ : Type@0 }} by mauto.
  econstructor...
Qed.
@@ -914,19 +1060,19 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_eq_extend_cong_nat sub_eq_extend_compose_nat sub_eq_p_extend_nat : mcltt.

-Lemma exp_eq_sub_sub_compose_cong_nat : forall {Γ Δ Δ' Ψ σ τ σ' τ' M},
-    {{ Ψ M : }} ->
-    {{ Δ s σ : Ψ }} ->
-    {{ Δ' s σ' : Ψ }} ->
-    {{ Γ s τ : Δ }} ->
-    {{ Γ s τ' : Δ' }} ->
-    {{ Γ s στ σ'τ' : Ψ }} ->
-    {{ Γ M[σ][τ] M[σ'][τ'] : }}.
+Lemma exp_eq_sub_sub_compose_cong_nat : forall {Γ Δ Δ' Ψ σ τ σ' τ' M},
+    {{ Ψ M : }} ->
+    {{ Δ s σ : Ψ }} ->
+    {{ Δ' s σ' : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ Γ s τ' : Δ' }} ->
+    {{ Γ s στ σ'τ' : Ψ }} ->
+    {{ Γ M[σ][τ] M[σ'][τ'] : }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ M[σ][τ] M[στ] : }} by mauto.
-  assert {{ Γ M[στ] M[σ'τ'] : }} by mauto.
-  enough {{ Γ M[σ'τ'] M[σ'][τ'] : }}...
+  assert {{ Γ M[σ][τ] M[στ] : }} by mauto.
+  assert {{ Γ M[στ] M[σ'τ'] : }} by mauto.
+  enough {{ Γ M[σ'τ'] M[σ'][τ'] : }}...
Qed.

@@ -943,22 +1089,40 @@

Mcltt.Core.Syntactic.System.Lemmas


-Lemma exp_eq_sub_sub_compose_cong : forall {Γ Δ Δ' Ψ σ τ σ' τ' M A i},
-    {{ Ψ A : Type@i }} ->
-    {{ Ψ M : A }} ->
-    {{ Δ s σ : Ψ }} ->
-    {{ Δ' s σ' : Ψ }} ->
-    {{ Γ s τ : Δ }} ->
-    {{ Γ s τ' : Δ' }} ->
-    {{ Γ s στ σ'τ' : Ψ }} ->
-    {{ Γ M[σ][τ] M[σ'][τ'] : A[στ] }}.
+Lemma sub_eq_weaken_var0_id : forall {Γ A i},
+    {{ Γ A : Type@i }} ->
+    {{ Γ, A s Wk,,#0 Id : Γ, A }}.
+Proof with mautosolve 4.
+  intros * ?.
+  assert {{ Γ, A }} by mauto 3.
+  assert {{ Γ, A s (WkId),,#0[Id] Id : Γ, A }} by mauto.
+  assert {{ Γ, A s Wk WkId : Γ }} by mauto.
+  enough {{ Γ, A #0 #0[Id] : A[Wk] }}...
+Qed.
+ +
+#[export]
+Hint Resolve sub_eq_weaken_var0_id : mcltt.
+#[export]
+Hint Rewrite -> @sub_eq_weaken_var0_id using mauto 4 : mcltt.
+ +
+Lemma exp_eq_sub_sub_compose_cong : forall {Γ Δ Δ' Ψ σ τ σ' τ' M A i},
+    {{ Ψ A : Type@i }} ->
+    {{ Ψ M : A }} ->
+    {{ Δ s σ : Ψ }} ->
+    {{ Δ' s σ' : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ Γ s τ' : Δ' }} ->
+    {{ Γ s στ σ'τ' : Ψ }} ->
+    {{ Γ M[σ][τ] M[σ'][τ'] : A[στ] }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ A[στ] A[σ'τ'] : Type@i }} by mauto.
-  assert {{ Γ M[σ][τ] M[στ] : A[στ] }} by mauto.
-  assert {{ Γ M[στ] M[σ'τ'] : A[στ] }} by mauto.
-  assert {{ Γ M[σ'τ'] M[σ'][τ'] : A[σ'τ'] }} by mauto.
-  enough {{ Γ M[σ'τ'] M[σ'][τ'] : A[στ] }} by mauto.
+  assert {{ Γ A[στ] A[σ'τ'] : Type@i }} by mauto.
+  assert {{ Γ M[σ][τ] M[στ] : A[στ] }} by mauto.
+  assert {{ Γ M[στ] M[σ'τ'] : A[στ] }} by mauto.
+  assert {{ Γ M[σ'τ'] M[σ'][τ'] : A[σ'τ'] }} by mauto.
+  enough {{ Γ M[σ'τ'] M[σ'][τ'] : A[στ] }} by mauto.
  eapply wf_exp_eq_conv...
Qed.
@@ -967,13 +1131,13 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_sub_sub_compose_cong : mcltt.

-Lemma ctxeq_ctx_lookup : forall {Γ Δ A x},
-    {{ Γ Δ }} ->
-    {{ #x : A Γ }} ->
-    exists B i,
-      {{ #x : B Δ }} /\
-        {{ Γ A B : Type@i }} /\
-        {{ Δ A B : Type@i }}.
+Lemma ctxeq_ctx_lookup : forall {Γ Δ A x},
+    {{ Γ Δ }} ->
+    {{ #x : A Γ }} ->
+    exists B i,
+      {{ #x : B Δ }} /\
+        {{ Γ A B : Type@i }} /\
+        {{ Δ A B : Type@i }}.
Proof with mautosolve.
  intros * HΓΔ Hx; gen Δ.
  induction Hx as [|* ? IHHx]; inversion_clear 1 as [|? ? ? ? ? HΓΔ'];
@@ -985,10 +1149,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve ctxeq_ctx_lookup : mcltt.

-Lemma sub_id_on_typ : forall {Γ M A i},
-    {{ Γ A : Type@i }} ->
-    {{ Γ M : A }} ->
-    {{ Γ M : A[Id] }}.
+Lemma sub_id_on_typ : forall {Γ M A i},
+    {{ Γ A : Type@i }} ->
+    {{ Γ M : A }} ->
+    {{ Γ M : A[Id] }}.
Proof with mautosolve 4.
  intros.
  eapply wf_conv...
@@ -999,10 +1163,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_id_on_typ : mcltt.

-Lemma sub_id_extend : forall {Γ M A i},
-    {{ Γ A : Type@i }} ->
-    {{ Γ M : A }} ->
-    {{ Γ s Id,,M : Γ, A }}.
+Lemma sub_id_extend : forall {Γ M A i},
+    {{ Γ A : Type@i }} ->
+    {{ Γ M : A }} ->
+    {{ Γ s Id,,M : Γ, A }}.
Proof with mautosolve 4.
  intros.
  econstructor...
@@ -1013,10 +1177,38 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_id_extend : mcltt.

-Lemma sub_eq_p_id_extend : forall {Γ M A i},
-    {{ Γ A : Type@i }} ->
-    {{ Γ M : A }} ->
-    {{ Γ s Wk (Id,,M) Id : Γ }}.
+Lemma sub_eq_id_on_typ : forall {Γ M M' A i},
+    {{ Γ A : Type@i }} ->
+    {{ Γ M M' : A }} ->
+    {{ Γ M M' : A[Id] }}.
+Proof with mautosolve 4.
+  intros.
+  eapply wf_exp_eq_conv...
+Qed.
+ +
+#[export]
+Hint Resolve sub_eq_id_on_typ : mcltt.
+ +
+Lemma sub_eq_id_extend_cong : forall {Γ M M' A i},
+    {{ Γ A : Type@i }} ->
+    {{ Γ M M' : A }} ->
+    {{ Γ s Id,,M Id,,M' : Γ, A }}.
+Proof with mautosolve 4.
+  intros.
+  econstructor; mauto 3.
+Qed.
+ +
+#[export]
+Hint Resolve sub_eq_id_extend_cong : mcltt.
+ +
+Lemma sub_eq_p_id_extend : forall {Γ M A i},
+    {{ Γ A : Type@i }} ->
+    {{ Γ M : A }} ->
+    {{ Γ s Wk (Id,,M) Id : Γ }}.
Proof with mautosolve 4.
  intros.
  econstructor...
@@ -1029,43 +1221,41 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Rewrite -> @sub_eq_p_id_extend using mauto 4 : mcltt.

-Lemma sub_q : forall {Γ A i σ Δ},
-    {{ Δ A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, A[σ] s q σ : Δ, A }}.
+Lemma sub_q : forall {Γ A i σ Δ},
+    {{ Δ A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, A[σ] s q σ : Δ, A }}.
Proof with mautosolve 3.
  intros.
-  assert {{ Γ A[σ] : Type@i }} by mauto 4.
-  assert {{ Γ, A[σ] s Wk : Γ }} by mauto 4.
-  assert {{ Γ, A[σ] # 0 : A[σ][Wk] }} by mauto 4.
+  assert {{ Γ A[σ] : Type@i }} by mauto 4.
+  assert {{ Γ, A[σ] s Wk : Γ }} by mauto 4.
+  assert {{ Γ, A[σ] # 0 : A[σ][Wk] }} by mauto 4.
  econstructor; mauto 3.
  eapply wf_conv...
Qed.

-Lemma sub_q_typ : forall {Γ σ Δ i},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, Type@i s q σ : Δ, Type@i }}.
+Lemma sub_q_typ : forall {Γ σ Δ i},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, Type@i s q σ : Δ, Type@i }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ }} by mauto 3.
-  assert {{ Γ, Type@i s Wk : Γ }} by mauto 4.
-  assert {{ Γ, Type@i s σ Wk : Δ }} by mauto 4.
-  assert {{ Γ, Type@i # 0 : Type@i[Wk] }} by mauto 4.
-  assert {{ Γ, Type@i # 0 : Type@i }}...
+  assert {{ Γ }} by mauto 3.
+  assert {{ Γ, Type@i s Wk : Γ }} by mauto 4.
+  assert {{ Γ, Type@i s σ Wk : Δ }} by mauto 4.
+  assert {{ Γ, Type@i # 0 : Type@i }}...
Qed.

-Lemma sub_q_nat : forall {Γ σ Δ},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, s q σ : Δ, }}.
+Lemma sub_q_nat : forall {Γ σ Δ},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, s q σ : Δ, }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ }} by mauto 3.
-  assert {{ Γ, s Wk : Γ }} by mauto 4.
-  assert {{ Γ, s σ Wk : Δ }} by mauto 4.
-  assert {{ Γ, # 0 : [Wk] }} by mauto 4.
-  assert {{ Γ, # 0 : }}...
+  assert {{ Γ }} by mauto 3.
+  assert {{ Γ, s Wk : Γ }} by mauto 4.
+  assert {{ Γ, s σ Wk : Δ }} by mauto 4.
+  assert {{ Γ, # 0 : }}...
Qed.

@@ -1073,25 +1263,25 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_q sub_q_typ sub_q_nat : mcltt.

-Lemma exp_eq_var_1_sub_q_sigma_nat : forall {Γ A i σ Δ},
-    {{ Δ, A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, , A[q σ] #1[q (q σ)] #1 : }}.
+Lemma exp_eq_var_1_sub_q_sigma_nat : forall {Γ A i σ Δ},
+    {{ Δ, A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, , A[q σ] #1[q (q σ)] #1 : }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ, s q σ : Δ, }} by mauto.
-  assert {{ Γ, , A[q σ] }} by mauto 3.
-  assert {{ Δ, #0 : }} by mauto.
-  assert {{ Γ, , A[q σ] #0 : A[q σ][Wk] }} by mauto 4.
-  assert {{ Γ, , A[q σ] A[q σWk] A[q σ][Wk] : Type@i }} by mauto 4.
-  assert {{ Γ, , A[q σ] #0 : A[q σWk] }} by (eapply wf_conv; mauto 4).
-  assert {{ Γ, , A[q σ] s q σWk : Δ, }} by mauto 4.
-  assert {{ Γ, , A[q σ] #1[q (q σ)] #0[q σWk] : }} by mauto 4.
-  assert {{ Γ, , A[q σ] #0[q σWk] #0[q σ][Wk] : }} by mauto 4.
-  assert {{ Γ, s σWk : Δ }} by mauto 4.
-  assert {{ Γ, #0 : [σWk] }} by (eapply wf_conv; mauto 4).
-  assert {{ Γ, #0[q σ] #0 : }} by mauto 4.
-  assert {{ Γ, , A[q σ] #0[q σ][Wk] #0[Wk] : }} by mauto 4.
+  assert {{ Γ, s q σ : Δ, }} by mauto.
+  assert {{ Γ, , A[q σ] }} by mauto 3.
+  assert {{ Δ, #0 : }} by mauto.
+  assert {{ Γ, , A[q σ] #0 : A[q σ][Wk] }} by mauto 4.
+  assert {{ Γ, , A[q σ] A[q σWk] A[q σ][Wk] : Type@i }} by mauto 4.
+  assert {{ Γ, , A[q σ] #0 : A[q σWk] }} by (eapply wf_conv; mauto 4).
+  assert {{ Γ, , A[q σ] s q σWk : Δ, }} by mauto 4.
+  assert {{ Γ, , A[q σ] #1[q (q σ)] #0[q σWk] : }} by mauto 4.
+  assert {{ Γ, , A[q σ] #0[q σWk] #0[q σ][Wk] : }} by mauto 4.
+  assert {{ Γ, s σWk : Δ }} by mauto 4.
+  assert {{ Γ, #0 : [σWk] }} by (eapply wf_conv; mauto 4).
+  assert {{ Γ, #0[q σ] #0 : }} by mauto 4.
+  assert {{ Γ, , A[q σ] #0[q σ][Wk] #0[Wk] : }} by mauto 4.
  econstructor...
Qed.
@@ -1100,48 +1290,48 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve exp_eq_var_1_sub_q_sigma_nat : mcltt.

-Lemma sub_id_extend_zero : forall {Γ},
-    {{ Γ }} ->
-    {{ Γ s Id,,zero : Γ, }}.
+Lemma sub_id_extend_zero : forall {Γ},
+    {{ Γ }} ->
+    {{ Γ s Id,,zero : Γ, }}.
Proof. mauto. Qed.

-Lemma sub_weak_compose_weak_extend_succ_var_1 : forall {Γ A i},
-    {{ Γ, A : Type@i }} ->
-    {{ Γ, , A s (Wk Wk),,succ #1 : Γ, }}.
+Lemma sub_weak_compose_weak_extend_succ_var_1 : forall {Γ A i},
+    {{ Γ, A : Type@i }} ->
+    {{ Γ, , A s (Wk Wk),,succ #1 : Γ, }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ, , A s Wk : Γ, }} by mauto 4.
-  enough {{ Γ, , A s Wk Wk : Γ }}...
+  assert {{ Γ, , A s Wk : Γ, }} by mauto 4.
+  enough {{ Γ, , A s Wk Wk : Γ }}...
Qed.

-Lemma sub_eq_id_extend_nat_compose_sigma : forall {Γ M σ Δ},
-    {{ Γ s σ : Δ }} ->
-    {{ Δ M : }} ->
-    {{ Γ s (Id,,M) σ σ,,M[σ] : Δ, }}.
+Lemma sub_eq_id_extend_nat_compose_sigma : forall {Γ M σ Δ},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ M : }} ->
+    {{ Γ s (Id,,M) σ σ,,M[σ] : Δ, }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ s (Id,,M) σ (Id σ),,M[σ] : Δ, }} by mauto 4.
-  enough {{ Γ s (Id σ),,M[σ] σ,,M[σ] : Δ, }} by mauto 4.
+  assert {{ Γ s (Id,,M) σ (Id σ),,M[σ] : Δ, }} by mauto 4.
+  enough {{ Γ s (Id σ),,M[σ] σ,,M[σ] : Δ, }} by mauto 4.
  eapply sub_eq_extend_cong_nat...
Qed.

-Lemma sub_eq_id_extend_compose_sigma : forall {Γ M A σ Δ i},
-    {{ Γ s σ : Δ }} ->
-    {{ Δ A : Type@i }} ->
-    {{ Δ M : A }} ->
-    {{ Γ s (Id,,M) σ σ,,M[σ] : Δ, A }}.
+Lemma sub_eq_id_extend_compose_sigma : forall {Γ M A σ Δ i},
+    {{ Γ s σ : Δ }} ->
+    {{ Δ A : Type@i }} ->
+    {{ Δ M : A }} ->
+    {{ Γ s (Id,,M) σ σ,,M[σ] : Δ, A }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Δ s Id : Δ }} by mauto.
-  assert {{ Δ M : A[Id] }} by mauto.
-  assert {{ Γ s (Id,,M) σ (Id σ),,M[σ] : Δ, A }} by mauto 3.
-  assert {{ Γ M[σ] : A[Id][σ] }} by mauto.
-  assert {{ Γ A[Id][σ] A[Idσ] : Type@i }} by mauto.
-  assert {{ Γ M[σ] : A[Idσ] }} by mauto 4.
-  enough {{ Γ M[σ] M[σ] : A[Idσ] }}...
+  assert {{ Δ s Id : Δ }} by mauto.
+  assert {{ Δ M : A[Id] }} by mauto.
+  assert {{ Γ s (Id,,M) σ (Id σ),,M[σ] : Δ, A }} by mauto 3.
+  assert {{ Γ M[σ] : A[Id][σ] }} by mauto.
+  assert {{ Γ A[Id][σ] A[Idσ] : Type@i }} by mauto.
+  assert {{ Γ M[σ] : A[Idσ] }} by mauto 4.
+  enough {{ Γ M[σ] M[σ] : A[Idσ] }}...
Qed.

@@ -1149,17 +1339,17 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_id_extend_zero sub_weak_compose_weak_extend_succ_var_1 sub_eq_id_extend_nat_compose_sigma sub_eq_id_extend_compose_sigma : mcltt.

-Lemma sub_eq_sigma_compose_weak_id_extend : forall {Γ M A i σ Δ},
-    {{ Γ A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M : A }} ->
-    {{ Γ s (σ Wk) (Id,,M) σ : Δ }}.
+Lemma sub_eq_sigma_compose_weak_id_extend : forall {Γ M A i σ Δ},
+    {{ Γ A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M : A }} ->
+    {{ Γ s (σ Wk) (Id,,M) σ : Δ }}.
Proof with mautosolve.
  intros.
-  assert {{ Γ s Id,,M : Γ, A }} by mauto.
-  assert {{ Γ s (σ Wk) (Id,,M) σ (Wk (Id,,M)) : Δ }} by mauto 4.
-  assert {{ Γ s Wk (Id,,M) Id : Γ }} by mauto.
-  enough {{ Γ s σ (Wk (Id,,M)) σ Id : Δ }} by mauto.
+  assert {{ Γ s Id,,M : Γ, A }} by mauto.
+  assert {{ Γ s (σ Wk) (Id,,M) σ (Wk (Id,,M)) : Δ }} by mauto 4.
+  assert {{ Γ s Wk (Id,,M) Id : Γ }} by mauto.
+  enough {{ Γ s σ (Wk (Id,,M)) σ Id : Δ }} by mauto.
  econstructor...
Qed.
@@ -1168,26 +1358,26 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_eq_sigma_compose_weak_id_extend : mcltt.

-Lemma sub_eq_q_sigma_id_extend : forall {Γ M A i σ Δ},
-    {{ Δ A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ M : A[σ] }} ->
-    {{ Γ s q σ (Id,,M) σ,,M : Δ, A }}.
+Lemma sub_eq_q_sigma_id_extend : forall {Γ M A i σ Δ},
+    {{ Δ A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ M : A[σ] }} ->
+    {{ Γ s q σ (Id,,M) σ,,M : Δ, A }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ }} by mauto 3.
-  assert {{ Γ A[σ] : Type@i }} by mauto.
-  assert {{ Γ M : A[σ] }} by mauto.
-  assert {{ Γ s Id,,M : Γ, A[σ] }} by mauto.
-  assert {{ Γ, A[σ] s Wk : Γ }} by mauto.
-  assert {{ Γ, A[σ] #0 : A[σ][Wk] }} by mauto.
-  assert {{ Γ, A[σ] #0 : A[σWk] }} by (eapply wf_conv; mauto 3).
-  assert {{ Γ s q σ (Id,,M) ((σ Wk) (Id,,M)),,#0[Id,,M] : Δ, A }} by mauto.
-  assert {{ Γ s (σ Wk) (Id,,M) σ : Δ }} by mauto.
-  assert {{ Γ M : A[σ][Id] }} by mauto 4.
-  assert {{ Γ #0[Id,,M] M : A[σ][Id] }} by mauto 3.
-  assert {{ Γ #0[Id,,M] M : A[σ] }} by mauto.
-  enough {{ Γ #0[Id,,M] M : A[(σ Wk) (Id,,M)] }} by mauto.
+  assert {{ Γ }} by mauto 3.
+  assert {{ Γ A[σ] : Type@i }} by mauto.
+  assert {{ Γ M : A[σ] }} by mauto.
+  assert {{ Γ s Id,,M : Γ, A[σ] }} by mauto.
+  assert {{ Γ, A[σ] s Wk : Γ }} by mauto.
+  assert {{ Γ, A[σ] #0 : A[σ][Wk] }} by mauto.
+  assert {{ Γ, A[σ] #0 : A[σWk] }} by (eapply wf_conv; mauto 3).
+  assert {{ Γ s q σ (Id,,M) ((σ Wk) (Id,,M)),,#0[Id,,M] : Δ, A }} by mauto.
+  assert {{ Γ s (σ Wk) (Id,,M) σ : Δ }} by mauto.
+  assert {{ Γ M : A[σ][Id] }} by mauto 4.
+  assert {{ Γ #0[Id,,M] M : A[σ][Id] }} by mauto 3.
+  assert {{ Γ #0[Id,,M] M : A[σ] }} by mauto.
+  enough {{ Γ #0[Id,,M] M : A[(σ Wk) (Id,,M)] }} by mauto.
  eapply wf_exp_eq_conv...
Qed.
@@ -1198,15 +1388,15 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Rewrite -> @sub_eq_q_sigma_id_extend using mauto 4 : mcltt.

-Lemma sub_eq_p_q_sigma : forall {Γ A i σ Δ},
-    {{ Δ A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, A[σ] s Wk q σ σ Wk : Δ }}.
+Lemma sub_eq_p_q_sigma : forall {Γ A i σ Δ},
+    {{ Δ A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, A[σ] s Wk q σ σ Wk : Δ }}.
Proof with mautosolve 3.
  intros.
-  assert {{ Γ, A[σ] s Wk : Γ }} by mauto 4.
-  assert {{ Γ, A[σ] #0 : A[σ][Wk] }} by mauto 3.
-  enough {{ Γ, A[σ] #0 : A[σ Wk] }} by mauto.
+  assert {{ Γ, A[σ] s Wk : Γ }} by mauto 4.
+  assert {{ Γ, A[σ] #0 : A[σ][Wk] }} by mauto 3.
+  enough {{ Γ, A[σ] #0 : A[σ Wk] }} by mauto.
  eapply wf_conv...
Qed.
@@ -1215,12 +1405,12 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_eq_p_q_sigma : mcltt.

-Lemma sub_eq_p_q_sigma_nat : forall {Γ σ Δ},
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, s Wk q σ σ Wk : Δ }}.
+Lemma sub_eq_p_q_sigma_nat : forall {Γ σ Δ},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, s Wk q σ σ Wk : Δ }}.
Proof with mautosolve.
  intros.
-  assert {{ Γ, #0 : }}...
+  assert {{ Γ, #0 : }}...
Qed.

@@ -1228,22 +1418,22 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_eq_p_q_sigma_nat : mcltt.

-Lemma sub_eq_p_p_q_q_sigma_nat : forall {Γ A i σ Δ},
-    {{ Δ, A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, , A[q σ] s Wk (Wk q (q σ)) (σ Wk) Wk : Δ }}.
+Lemma sub_eq_p_p_q_q_sigma_nat : forall {Γ A i σ Δ},
+    {{ Δ, A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, , A[q σ] s Wk (Wk q (q σ)) (σ Wk) Wk : Δ }}.
Proof with mautosolve 3.
  intros.
-  assert {{ Γ, A[q σ] : Type@i }} by mauto.
-  assert {{ Γ, , A[q σ] }} by mauto 3.
-  assert {{ Δ, }} by mauto 3.
-  assert {{ Γ, , A[q σ] s Wkq (q σ) q σ Wk : Δ, }} by mauto.
-  assert {{ Γ, , A[q σ] s Wk(Wkq (q σ)) Wk (q σ Wk) : Δ }} by mauto 3.
-  assert {{ Δ, s Wk : Δ }} by mauto.
-  assert {{ Γ, s q σ : Δ, }} by mauto.
-  assert {{ Γ, , A[q σ] s Wk (q σ Wk) (Wk q σ) Wk : Δ }} by mauto 4.
-  assert {{ Γ, s Wk q σ σ Wk : Δ }} by mauto.
-  enough {{ Γ, , A[q σ] s (Wk q σ) Wk (σ Wk) Wk : Δ }}...
+  assert {{ Γ, A[q σ] : Type@i }} by mauto.
+  assert {{ Γ, , A[q σ] }} by mauto 3.
+  assert {{ Δ, }} by mauto 3.
+  assert {{ Γ, , A[q σ] s Wkq (q σ) q σ Wk : Δ, }} by mauto.
+  assert {{ Γ, , A[q σ] s Wk(Wkq (q σ)) Wk (q σ Wk) : Δ }} by mauto 3.
+  assert {{ Δ, s Wk : Δ }} by mauto.
+  assert {{ Γ, s q σ : Δ, }} by mauto.
+  assert {{ Γ, , A[q σ] s Wk (q σ Wk) (Wk q σ) Wk : Δ }} by mauto 4.
+  assert {{ Γ, s Wk q σ σ Wk : Δ }} by mauto.
+  enough {{ Γ, , A[q σ] s (Wk q σ) Wk (σ Wk) Wk : Δ }}...
Qed.

@@ -1251,52 +1441,52 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve sub_eq_p_p_q_q_sigma_nat : mcltt.

-Lemma sub_eq_q_sigma_compose_weak_weak_extend_succ_var_1 : forall {Γ A i σ Δ},
-    {{ Δ, A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, , A[q σ] s q σ ((Wk Wk),,succ #1) ((Wk Wk),,succ #1) q (q σ) : Δ, }}.
+Lemma sub_eq_q_sigma_compose_weak_weak_extend_succ_var_1 : forall {Γ A i σ Δ},
+    {{ Δ, A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, , A[q σ] s q σ ((Wk Wk),,succ #1) ((Wk Wk),,succ #1) q (q σ) : Δ, }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Δ, , A }} by mauto 3.
-  assert {{ Γ, }} by mauto 3.
-  assert {{ Γ, s Wk : Γ }} by mauto 3.
-  assert {{ Γ, s σWk : Δ }} by mauto 3.
-  assert {{ Γ, A[q σ] : Type@i }} by mauto 3.
-  set (Γ' := {{{ Γ, , A[q σ] }}}).
+  assert {{ Δ, , A }} by mauto 3.
+  assert {{ Γ, }} by mauto 3.
+  assert {{ Γ, s Wk : Γ }} by mauto 3.
+  assert {{ Γ, s σWk : Δ }} by mauto 3.
+  assert {{ Γ, A[q σ] : Type@i }} by mauto 3.
+  set (Γ' := {{{ Γ, , A[q σ] }}}).
  set (WkWksucc := {{{ (WkWk),,succ #1 }}}).
-  assert {{ Γ' }} by mauto 2.
-  assert {{ Γ' s WkWk : Γ }} by mauto 4.
-  assert {{ Γ' s WkWksucc : Γ, }} by mauto.
-  assert {{ Γ, #0 : }} by mauto.
-  assert {{ Γ' s q σWkWksucc ((σWk)WkWksucc),,#0[WkWksucc] : Δ, }} by mautosolve 3.
-  assert {{ Γ' #1 : [Wk][Wk] }} by mauto.
-  assert {{ Γ' [Wk][Wk] : Type@0 }} by mauto 3.
-  assert {{ Γ' #1 : }} by mauto 2.
-  assert {{ Γ' succ #1 : }} by mauto.
-  assert {{ Γ' s WkWkWksucc : Γ }} by mauto 4.
-  assert {{ Γ' s WkWkWksucc WkWk : Γ }} by mauto 4.
-  assert {{ Γ s σ σ : Δ }} by mauto.
-  assert {{ Γ' s σ(WkWkWksucc) σ(WkWk) : Δ }} by mauto 3.
-  assert {{ Γ' s (σWk)WkWksucc σ(WkWk) : Δ }} by mauto 3.
-  assert {{ Γ' s σ(WkWk) (σWk)Wk : Δ }} by mauto 4.
-  assert {{ Γ' s (σWk)Wk Wk(Wkq (q σ)) : Δ }} by mauto.
-  assert {{ Δ, s Wk : Δ }} by mauto 4.
-  assert {{ Δ, , A s Wk : Δ, }} by mauto 4.
-  assert {{ Δ, , A s WkWk : Δ }} by mauto 4.
-  assert {{ Γ' s q (q σ) : Δ, , A }} by mauto.
-  assert {{ Γ' s Wk(Wkq (q σ)) (WkWk)q (q σ) : Δ }} by mauto 3.
-  assert {{ Γ' s σ(WkWk) (WkWk)q (q σ) : Δ }} by mauto 3.
-  assert {{ Γ' #0[WkWksucc] succ #1 : }} by mauto.
-  assert {{ Γ' succ #1[q (q σ)] succ #1 : }} by mauto 3.
-  assert {{ Δ, , A #1 : }} by mauto 2.
-  assert {{ Γ' succ #1 (succ #1)[q (q σ)] : }} by mauto 4.
-  assert {{ Γ' #0[WkWksucc] (succ #1)[q (q σ)] : }} by mauto 2.
-  assert {{ Γ' s (σWk)WkWksucc : Δ }} by mauto 3.
-  assert {{ Γ' s ((σWk)WkWksucc),,#0[WkWksucc] ((WkWk)q (q σ)),,(succ #1)[q (q σ)] : Δ, }} by mauto 3.
-  assert {{ Δ, , A #1 : [Wk][Wk] }} by mauto 4.
-  assert {{ Δ, , A [Wk][Wk] : Type@0 }} by mauto 3.
-  assert {{ Δ, , A succ #1 : }} by mauto.
-  enough {{ Γ' s ((WkWk)q (q σ)),,(succ #1)[q (q σ)] WkWksuccq (q σ) : Δ, }}...
+  assert {{ Γ' }} by mauto 2.
+  assert {{ Γ' s WkWk : Γ }} by mauto 4.
+  assert {{ Γ' s WkWksucc : Γ, }} by mauto.
+  assert {{ Γ, #0 : }} by mauto.
+  assert {{ Γ' s q σWkWksucc ((σWk)WkWksucc),,#0[WkWksucc] : Δ, }} by mautosolve 3.
+  assert {{ Γ' #1 : [Wk][Wk] }} by mauto.
+  assert {{ Γ' [Wk][Wk] : Type@0 }} by mauto 3.
+  assert {{ Γ' #1 : }} by mauto 2.
+  assert {{ Γ' succ #1 : }} by mauto.
+  assert {{ Γ' s WkWkWksucc : Γ }} by mauto 4.
+  assert {{ Γ' s WkWkWksucc WkWk : Γ }} by mauto 4.
+  assert {{ Γ s σ σ : Δ }} by mauto.
+  assert {{ Γ' s σ(WkWkWksucc) σ(WkWk) : Δ }} by mauto 3.
+  assert {{ Γ' s (σWk)WkWksucc σ(WkWk) : Δ }} by mauto 3.
+  assert {{ Γ' s σ(WkWk) (σWk)Wk : Δ }} by mauto 4.
+  assert {{ Γ' s (σWk)Wk Wk(Wkq (q σ)) : Δ }} by mauto.
+  assert {{ Δ, s Wk : Δ }} by mauto 4.
+  assert {{ Δ, , A s Wk : Δ, }} by mauto 4.
+  assert {{ Δ, , A s WkWk : Δ }} by mauto 4.
+  assert {{ Γ' s q (q σ) : Δ, , A }} by mauto.
+  assert {{ Γ' s Wk(Wkq (q σ)) (WkWk)q (q σ) : Δ }} by mauto 3.
+  assert {{ Γ' s σ(WkWk) (WkWk)q (q σ) : Δ }} by mauto 3.
+  assert {{ Γ' #0[WkWksucc] succ #1 : }} by mauto.
+  assert {{ Γ' succ #1[q (q σ)] succ #1 : }} by mauto 3.
+  assert {{ Δ, , A #1 : }} by mauto 2.
+  assert {{ Γ' succ #1 (succ #1)[q (q σ)] : }} by mauto 4.
+  assert {{ Γ' #0[WkWksucc] (succ #1)[q (q σ)] : }} by mauto 2.
+  assert {{ Γ' s (σWk)WkWksucc : Δ }} by mauto 3.
+  assert {{ Γ' s ((σWk)WkWksucc),,#0[WkWksucc] ((WkWk)q (q σ)),,(succ #1)[q (q σ)] : Δ, }} by mauto 3.
+  assert {{ Δ, , A #1 : [Wk][Wk] }} by mauto 4.
+  assert {{ Δ, , A [Wk][Wk] : Type@0 }} by mauto 3.
+  assert {{ Δ, , A succ #1 : }} by mauto.
+  enough {{ Γ' s ((WkWk)q (q σ)),,(succ #1)[q (q σ)] WkWksuccq (q σ) : Δ, }}...
Qed.

@@ -1313,9 +1503,9 @@

Mcltt.Core.Syntactic.System.Lemmas


-Fact wf_subtyp_refl : forall {Γ A i},
-    {{ Γ A : Type@i }} ->
-    {{ Γ A A }}.
+Fact wf_subtyp_refl : forall {Γ A i},
+    {{ Γ A : Type@i }} ->
+    {{ Γ A A }}.
Proof. mauto. Qed.

@@ -1323,10 +1513,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_subtyp_refl : mcltt.

-Lemma wf_subtyp_ge : forall {Γ i j},
-    {{ Γ }} ->
-    i <= j ->
-    {{ Γ Type@i Type@j }}.
+Lemma wf_subtyp_ge : forall {Γ i j},
+    {{ Γ }} ->
+    i <= j ->
+    {{ Γ Type@i Type@j }}.
Proof.
  induction 2; mauto 4.
Qed.
@@ -1336,18 +1526,18 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_subtyp_ge : mcltt.

-Lemma wf_subtyp_sub : forall {Δ A A'},
-    {{ Δ A A' }} ->
-    forall Γ σ,
-    {{ Γ s σ : Δ }} ->
-    {{ Γ A[σ] A'[σ] }}.
+Lemma wf_subtyp_sub : forall {Δ A A'},
+    {{ Δ A A' }} ->
+    forall Γ σ,
+    {{ Γ s σ : Δ }} ->
+    {{ Γ A[σ] A'[σ] }}.
Proof.
  induction 1; intros; mauto 4.
  - transitivity {{{ Type@i }}}; [econstructor; mauto 4 |].
    transitivity {{{ Type@j }}}; [| econstructor; mauto 4].
    mauto 3.
-  - transitivity {{{ Π (A[σ]) (B[q σ]) }}}; [econstructor; mauto |].
-    transitivity {{{ Π (A'[σ]) (B'[q σ]) }}}; [ | econstructor; mauto 4].
+  - transitivity {{{ Π (A[σ]) (B[q σ]) }}}; [econstructor; mauto |].
+    transitivity {{{ Π (A'[σ]) (B'[q σ]) }}}; [ | econstructor; mauto 4].
    eapply wf_subtyp_pi with (i := i); mauto 4.
Qed.
@@ -1356,10 +1546,10 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve wf_subtyp_sub : mcltt.

-Lemma wf_subtyp_univ_weaken : forall {Γ i j A},
-    {{ Γ Type@i Type@j }} ->
-    {{ Γ, A }} ->
-    {{ Γ, A Type@i Type@j }}.
+Lemma wf_subtyp_univ_weaken : forall {Γ i j A},
+    {{ Γ Type@i Type@j }} ->
+    {{ Γ, A }} ->
+    {{ Γ, A Type@i Type@j }}.
Proof.
  intros.
  eapply wf_subtyp_sub with (σ := {{{ Wk }}}) in H.
@@ -1369,13 +1559,13 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma ctx_sub_ctx_lookup : forall {Γ Δ},
-    {{ Δ Γ }} ->
-    forall {A x},
-      {{ #x : A Γ }} ->
-      exists B,
-        {{ #x : B Δ }} /\
-          {{ Δ B A }}.
+Lemma ctx_sub_ctx_lookup : forall {Γ Δ},
+    {{ Δ Γ }} ->
+    forall {A x},
+      {{ #x : A Γ }} ->
+      exists B,
+        {{ #x : B Δ }} /\
+          {{ Δ B A }}.
Proof with (do 2 eexists; repeat split; mautosolve).
  induction 1; intros * Hx; progressive_inversion.
  dependent destruction Hx.
@@ -1388,34 +1578,50 @@

Mcltt.Core.Syntactic.System.Lemmas

Hint Resolve ctx_sub_ctx_lookup : mcltt.

-Lemma sub_lookup_var0 : forall Δ Γ σ M1 M2 B i,
-    {{Δ s σ : Γ}} ->
-    {{Γ B : Type@i}} ->
-    {{Δ M1 : B[σ]}} ->
-    {{Δ M2 : B[σ]}} ->
-    {{Δ #0[σ,,M1,,M2] M2 : B[σ]}}.
+Lemma var_compose_subs : forall {Γ τ Δ σ Ψ i A x},
+    {{ Ψ A : Type@i }} ->
+    {{ Δ s σ : Ψ }} ->
+    {{ Γ s τ : Δ }} ->
+    {{ #x : A[σ][τ] Γ }} ->
+    {{ Γ #x : A[στ] }}.
Proof.
  intros.
-  assert {{ Γ , B B[Wk] : Type@i }} by mauto.
-  assert {{ Δ s σ ,, M1 : Γ, B}} by mauto 4.
-  assert {{ Δ B[Wk][σ,,M1] : Type @ i }} by mauto 4.
-  assert {{ Δ B[Wk][σ,,M1] B[σ] : Type @ i }}.
+  eapply wf_conv; mauto 3.
+Qed.
+ +
+#[export]
+Hint Resolve var_compose_subs : mcltt.
+ +
+Lemma sub_lookup_var0 : forall Δ Γ σ M1 M2 B i,
+    {{Δ s σ : Γ}} ->
+    {{Γ B : Type@i}} ->
+    {{Δ M1 : B[σ]}} ->
+    {{Δ M2 : B[σ]}} ->
+    {{Δ #0[σ,,M1,,M2] M2 : B[σ]}}.
+Proof.
+  intros.
+  assert {{ Γ , B B[Wk] : Type@i }} by mauto.
+  assert {{ Δ s σ ,, M1 : Γ, B}} by mauto 4.
+  assert {{ Δ B[Wk][σ,,M1] : Type @ i }} by mauto 4.
+  assert {{ Δ B[Wk][σ,,M1] B[σ] : Type @ i }}.
  {
-    transitivity {{{B[Wk (σ,,M1)]}}}.
+    transitivity {{{B[Wk (σ,,M1)]}}}.
    - eapply exp_eq_sub_compose_typ; mauto 4.
    - eapply exp_eq_sub_cong_typ2'; mauto 4.
  }
  eapply wf_exp_eq_conv;
-    [eapply wf_exp_eq_var_0_sub with (A := {{{B[Wk]}}}) | |];
+    [eapply wf_exp_eq_var_0_sub with (A := {{{B[Wk]}}}) | |];
    mauto 4.
Qed.

-Lemma id_sub_lookup_var0 : forall Γ M1 M2 B i,
-    {{Γ B : Type@i}} ->
-    {{Γ M1 : B}} ->
-    {{Γ M2 : B}} ->
-    {{Γ #0[Id,,M1,,M2] M2 : B}}.
+Lemma id_sub_lookup_var0 : forall Γ M1 M2 B i,
+    {{Γ B : Type@i}} ->
+    {{Γ M1 : B}} ->
+    {{Γ M2 : B}} ->
+    {{Γ #0[Id,,M1,,M2] M2 : B}}.
Proof.
  intros.
  eapply wf_exp_eq_conv;
@@ -1424,24 +1630,24 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma sub_lookup_var1 : forall Δ Γ σ M1 M2 B i,
-    {{Δ s σ : Γ}} ->
-    {{Γ B : Type@i}} ->
-    {{Δ M1 : B[σ]}} ->
-    {{Δ M2 : B[σ]}} ->
-    {{Δ #1[σ,,M1,,M2] M1 : B[σ]}}.
+Lemma sub_lookup_var1 : forall Δ Γ σ M1 M2 B i,
+    {{Δ s σ : Γ}} ->
+    {{Γ B : Type@i}} ->
+    {{Δ M1 : B[σ]}} ->
+    {{Δ M2 : B[σ]}} ->
+    {{Δ #1[σ,,M1,,M2] M1 : B[σ]}}.
Proof.
  intros.
-  assert {{ Γ , B B[Wk] : Type@i }} by mauto.
-  assert {{ Δ s σ ,, M1 : Γ, B}} by mauto 4.
-  assert {{ Δ B[Wk][σ,,M1] : Type @ i }} by mauto 4.
-  assert {{ Δ B[Wk][σ,,M1] B[σ] : Type @ i }}.
+  assert {{ Γ , B B[Wk] : Type@i }} by mauto.
+  assert {{ Δ s σ ,, M1 : Γ, B}} by mauto 4.
+  assert {{ Δ B[Wk][σ,,M1] : Type @ i }} by mauto 4.
+  assert {{ Δ B[Wk][σ,,M1] B[σ] : Type @ i }}.
  {
-    transitivity {{{B[Wk (σ,,M1)]}}}.
+    transitivity {{{B[Wk (σ,,M1)]}}}.
    - eapply exp_eq_sub_compose_typ; mauto 4.
    - eapply exp_eq_sub_cong_typ2'; mauto 4.
  }
-  transitivity {{{#0[σ,,M1]}}}.
+  transitivity {{{#0[σ,,M1]}}}.
  - eapply wf_exp_eq_conv;
      [eapply wf_exp_eq_var_S_sub | |];
      mauto 4.
@@ -1452,11 +1658,11 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma id_sub_lookup_var1 : forall Γ M1 M2 B i,
-    {{Γ B : Type@i}} ->
-    {{Γ M1 : B}} ->
-    {{Γ M2 : B}} ->
-    {{Γ #1[Id,,M1,,M2] M1 : B}}.
+Lemma id_sub_lookup_var1 : forall Γ M1 M2 B i,
+    {{Γ B : Type@i}} ->
+    {{Γ M1 : B}} ->
+    {{Γ M2 : B}} ->
+    {{Γ #1[Id,,M1,,M2] M1 : B}}.
Proof.
  intros.
  eapply wf_exp_eq_conv;
@@ -1465,113 +1671,111 @@

Mcltt.Core.Syntactic.System.Lemmas

Qed.

-Lemma exp_eq_var_1_sub_q_sigma : forall {Γ A i B j σ Δ},
-    {{ Δ B : Type@j }} ->
-    {{ Δ, B A : Type@i }} ->
-    {{ Γ s σ : Δ }} ->
-    {{ Γ, B[σ], A[q σ] #1[q (q σ)] #1 : B[σ][Wk][Wk] }}.
+Lemma exp_eq_var_1_sub_q_sigma : forall {Γ A i B j σ Δ},
+    {{ Δ B : Type@j }} ->
+    {{ Δ, B A : Type@i }} ->
+    {{ Γ s σ : Δ }} ->
+    {{ Γ, B[σ], A[q σ] #1[q (q σ)] #1 : B[σ][WkWk] }}.
Proof with mautosolve 4.
  intros.
-  assert {{ Γ, B[σ] s q σ : Δ, B }} by mauto.
-  assert {{ Γ, B[σ], A[q σ] }} by mauto 3.
-  assert {{ Δ, B B[Wk] : Type@j }} by mauto.
-  assert {{ Δ, B #0 : B[Wk] }} by mauto.
-  assert {{ Γ, B[σ], A[q σ] #0 : A[q σ][Wk] }} by mauto 4.
-  assert {{ Γ, B[σ], A[q σ] A[q σWk] A[q σ][Wk] : Type@i }} by mauto 4.
-  assert {{ Γ, B[σ], A[q σ] #0 : A[q σWk] }} by (eapply wf_conv; mauto 4).
-  assert {{ Γ, B[σ], A[q σ] s q σWk : Δ, B }} by mauto 4.
-  assert {{ Γ B[σ] : Type@j }} by mauto 3.
-  assert {{ Γ,B[σ] B[σ][Wk] : Type@j }} by mauto 4.
-  assert {{Γ, B[σ], A[q σ] B[σ][Wk][Wk] : Type@j}} by mauto 4.
-  assert {{Γ, B[σ],A[q σ] B[Wk][q σ Wk] : Type@j}} by mauto.
-  assert {{Γ, B[σ] B[Wk][q σ] B[σ][Wk] : Type@j}}.
-  {
-    transitivity {{{B[Wk q σ]}}};
-      [mauto 4 | transitivity {{{B[σ Wk]}}}];
-      [eapply exp_eq_sub_cong_typ2'; mauto 4 | mauto].
-  }
-  assert {{Γ, B[σ],A[q σ] B[Wk][q σ Wk] B[σ][Wk][Wk] : Type@j}}.
-  {
-    transitivity {{{B[Wk][q σ][Wk]}}};
-      [mauto 4 |].
-    eapply exp_eq_sub_cong_typ1; mauto 3.
-  }
-  assert {{ Γ, B[σ], A[q σ] #1[q (q σ)] #0[q σWk] : B[σ][Wk][Wk] }} by mauto 3.
-  assert {{ Γ, B[σ], A[q σ] #0[q σWk] #0[q σ][Wk] : B[σ][Wk][Wk] }} by mauto 4.
-  assert {{ Γ, B[σ] s σWk : Δ }} by mauto 4.
-  assert {{ Γ, B[σ] #0 : B[σWk] }}.
-  {
-    eapply wf_conv with (A:={{{B[σ][Wk]}}}); mauto 2; mauto 4.
-  }
-  assert {{ Γ, B[σ] #0[q σ] #0 : B[σ Wk] }} by mauto 4.
-  assert {{ Γ, B[σ], A[q σ] #0[q σ][Wk] #0[Wk] : B[σ Wk][Wk] }} by mauto 4.
-  assert {{ Γ, B[σ], A[q σ] B[σ Wk][Wk] B[σ][Wk][Wk] : Type@j}}.
-  {
-    eapply exp_eq_sub_cong_typ1; mauto 3.
-    symmetry.
-    mauto 4.
-  }
-  assert {{ Γ, B[σ], A[q σ] #0[q σ][Wk] #0[Wk] : B[σ][Wk][Wk] }} by mauto 4.
-  etransitivity; mauto 2.
-  transitivity {{{#0[q σ][Wk]}}}; mauto 3.
+  assert {{ Δ }} by mauto 2.
+  assert {{ Γ, B[σ] s q σ : Δ, B }} by mauto 2.
+  assert {{ Γ, B[σ] }} by mauto 3.
+  assert {{ Γ, B[σ], A[q σ] }} by mauto 3.
+  assert {{ Δ, B B[Wk] : Type@j }} by mauto 4.
+  assert {{ Δ, B #0 : B[Wk] }} by mauto 3.
+  assert {{ Γ, B[σ], A[q σ] #0 : A[q σ][Wk] }} by mauto 2.
+  assert {{ Γ, B[σ], A[q σ] A[q σWk] A[q σ][Wk] : Type@i }} by mauto 4.
+  assert {{ Γ, B[σ], A[q σ] s q σWk : Δ, B }} by mauto 3.
+  assert {{ Γ, B[σ], A[q σ] #0 : A[q σWk] }} by mauto 3.
+  assert {{ Γ B[σ] : Type@j }} by mauto 2.
+  assert {{ Γ, B[σ] s Wk : Γ }} by mauto 2.
+  assert {{ Γ, B[σ], A[q σ] s Wk : Γ, B[σ] }} by mauto 2.
+  assert {{ Γ, B[σ] B[σ][Wk] : Type@j }} by mauto 2.
+  assert {{ Γ, B[σ], A[q σ] B[σ][Wk][Wk] : Type@j }} by mauto 2.
+  assert {{ Γ, B[σ] B[Wk][q σ] B[σ][Wk] : Type@j }} by (eapply exp_eq_sub_sub_compose_cong_typ; mauto 3).
+  assert {{Γ, B[σ],A[q σ] B[Wk][q σ Wk] B[σ][Wk][Wk] : Type@j}} by (transitivity {{{ B[Wk][q σ][Wk] }}}; mauto 3).
+  assert {{ Γ, B[σ], A[q σ] #1[q (q σ)] #0[q σWk] : B[σ][Wk][Wk] }} by mauto 3.
+  assert {{ Γ, B[σ], A[q σ] #0[q σWk] #0[q σ][Wk] : B[σ][Wk][Wk] }} by mauto 3.
+  assert {{ Γ, B[σ] s σWk : Δ }} by mauto 2.
+  assert {{ Γ, B[σ] #0 : B[σWk] }} by mauto 2.
+  assert {{ Γ, B[σ] #0[q σ] #0 : B[σ Wk] }} by mauto 2.
+  assert {{ Γ, B[σ], A[q σ] #0[q σ][Wk] #0[Wk] : B[σ Wk][Wk] }} by mauto 3.
+  assert {{ Γ, B[σ], A[q σ] B[σ Wk][Wk] B[σ][Wk][Wk] : Type@j}} by mauto 4.
+  assert {{ Γ, B[σ], A[q σ] #0[q σ][Wk] #0[Wk] : B[σ][Wk][Wk] }} by mauto 2.
+  assert {{ Γ, B[σ], A[q σ] #1[q (q σ)] #1 : B[σ][Wk][Wk] }} by (do 2 etransitivity; mauto 2).
+  assert {{ Γ, B[σ], A[q σ] s WkWk : Γ }} by mauto 2.
+  assert {{ Γ, B[σ], A[q σ] B[σ][WkWk] : Type@j }} by mauto 2.
+  eapply wf_exp_eq_conv; mauto 2.
Qed.

-

Types Presuppositions

+

Type Presuppositions


-Lemma presup_exp_typ : forall {Γ M A},
-    {{ Γ M : A }} ->
-    exists i, {{ Γ A : Type@i }}.
+Lemma presup_exp_typ : forall {Γ M A},
+    {{ Γ M : A }} ->
+    exists i, {{ Γ A : Type@i }}.
Proof.
-  induction 1; assert {{ Γ }} by mauto 3; destruct_conjs; mauto 3.
-  - enough {{ Γ s Id,,M : Γ, }}; mauto 3.
+  induction 1; assert {{ Γ }} by mauto 3; destruct_conjs; mauto 3.
+ +
+  - enough {{ Γ s Id,,M : Γ, }}; mauto 3.
+ +
  - eexists; mauto 4 using lift_exp_max_left, lift_exp_max_right.
-  - enough {{ Γ s Id,,N : Γ, A }}; mauto 3.
-  - assert {{ Γ s Id,,M1 : Γ, A }} by mauto 3.
-    assert {{ Γ, A s Wk : Γ }} by mauto 3.
-    assert {{ Γ, A A[Wk] : Type@i }} by mauto 3.
-    assert {{ Γ, A, A[Wk] s Wk : Γ, A }} by mauto 4.
-    assert {{ Γ, A, A[Wk] A[Wk][Wk] : Type@i }} by mauto 3.
-    assert {{ Γ A[Wk][Id,,M1] : Type@i }} by mauto 3.
-    assert {{ Γ A[Wk][Id,,M1] A : Type@i }}.
-    {
-      transitivity {{{ A[Wk(Id,,M1)] }}}; mauto 3.
-      transitivity {{{ A[Id] }}}; mauto 4.
-    }
-    assert {{ Γ s Id,,M1,,M2 : Γ, A, A[Wk] }} by mauto 4.
-    assert {{ Γ A[Wk][Wk][Id ,, M1 ,, M2] A : Type@i }}.
-    {
-      transitivity {{{ A[Wk][Wk(Id,,M1,,M2)] }}}; mauto 3.
-      transitivity {{{ A[Wk][Id,,M1] }}}; mauto 3.
-      eapply exp_eq_sub_cong_typ2'; mauto 4.
-    }
-    enough {{ Γ s Id,,M1,,M2,,N : Γ, A, A[Wk], Eq A[Wk][Wk] #1 #0 }} by mauto 3.
-    assert {{ Γ, A, A[Wk] Eq A[Wk][Wk] #1 #0 : Type@i }} by (econstructor; mauto 4).
-    econstructor; mauto 3.
-    eapply wf_conv; mauto 2.
-    transitivity {{{ Eq A[Wk][Wk][Id,,M1,,M2] #1[Id,,M1,,M2] #0[Id,,M1,,M2] }}}.
-    + econstructor; mauto 3 using id_sub_lookup_var0, id_sub_lookup_var1.
-    + symmetry; econstructor; mauto 4.
-Qed.
- -
-Lemma presup_exp : forall {Γ M A},
-    {{ Γ M : A }} ->
-    {{ Γ }} /\ exists i, {{ Γ A : Type@i }}.
+ +
+  - enough {{ Γ s Id,,N : Γ, A }}; mauto 3.
+ +
+  - enough {{ Γ s Id,,M1,,M2,,N : Γ, A, A[Wk], Eq A[WkWk] #1 #0 }} by mauto 3.
+    assert {{ Γ, A s Wk : Γ }} by mauto 3.
+    assert {{ Γ, A A[Wk] : Type@i }} by mauto 3.
+    assert {{ Γ, A, A[Wk] s Wk : Γ, A }} by mauto 4.
+    assert {{ Γ, A, A[Wk] A[WkWk] : Type@i }} by mauto 3.
+    assert {{ Γ, A, A[Wk] Eq A[WkWk] #1 #0 : Type@i }} by (econstructor; mauto 3; eapply wf_conv; mauto 4).
+ +
+    assert {{ Γ s Id,,M1 : Γ, A }} by mauto 3.
+    assert {{ Γ M2 : A[Wk][Id,,M1] }} by (eapply wf_conv; [| | symmetry]; mauto 2).
+    assert {{ Γ s Id,,M1,,M2 : Γ, A, A[Wk] }} by mauto 3.
+    econstructor; [mautosolve 3 | mautosolve 3 |].
+    eapply wf_conv; [| | symmetry]; mauto 3.
+    transitivity {{{ Eq A[WkWk][Id,,M1,,M2] #1[Id,,M1,,M2] #0[Id,,M1,,M2] }}}.
+    + econstructor; mauto 3 using id_sub_lookup_var0, id_sub_lookup_var1; eapply wf_conv; mauto 4.
+    + assert {{ Γ M2 : A }} by eassumption. (* re-assert to help search process *)
+      assert {{ Γ M1 : A[WkWk][Id,,M1,,M2] }} by (eapply wf_conv; [| | symmetry]; mauto 2).
+      assert {{ Γ M2 : A[WkWk][Id,,M1,,M2] }} by (eapply wf_conv; [| | symmetry]; mauto 2).
+      econstructor; mauto 3 using id_sub_lookup_var0, id_sub_lookup_var1.
+Qed.
+ +
+Lemma presup_exp : forall {Γ M A},
+    {{ Γ M : A }} ->
+    {{ Γ }} /\ exists i, {{ Γ A : Type@i }}.
Proof.
  mauto 4 using presup_exp_typ.
Qed.

-Lemma no_closed_neutral : forall {A} {W : ne},
-    ~ {{ W : A }}.
+
+ +
+

Consistency Helper

+ +
+
+ +
+Lemma no_closed_neutral : forall {A} {W : ne},
+    ~ {{ W : A }}.
Proof.
  intros * H.
  dependent induction H; destruct W;
diff --git a/ext/prop-eq/Mcltt.LibTactics.html b/ext/prop-eq/Mcltt.LibTactics.html index 4e08a00..0a70c59 100644 --- a/ext/prop-eq/Mcltt.LibTactics.html +++ b/ext/prop-eq/Mcltt.LibTactics.html @@ -51,7 +51,7 @@

Mcltt.LibTactics

-

Generalization of Variables

+

Generalization of Variables

@@ -66,7 +66,7 @@

Mcltt.LibTactics

-

Marking-based Tactics

+

Marking-based Tactics

@@ -121,7 +121,7 @@

Mcltt.LibTactics

-

Simple helper

+

Simple helper

@@ -281,7 +281,7 @@

Mcltt.LibTactics

-

McLTT automation

+

McLTT automation

@@ -555,7 +555,7 @@

Mcltt.LibTactics

-

Helper Instances for Generalized Rewriting

+

Helper Instances for Generalized Rewriting

diff --git a/ext/prop-eq/indexpage.html b/ext/prop-eq/indexpage.html index 6afcb1d..d13c36e 100644 --- a/ext/prop-eq/indexpage.html +++ b/ext/prop-eq/indexpage.html @@ -56,7 +56,7 @@ Z _ other -(480 entries) +(521 entries) Notation Index @@ -184,7 +184,7 @@ Z _ other -(206 entries) +(247 entries) Constructor Index @@ -478,6 +478,7 @@

Global Index

ctxsub_judg.ctxsub_exp_helper [lemma, in Mcltt.Core.Syntactic.CtxSub]
ctxsub_judg [module, in Mcltt.Core.Syntactic.CtxSub]
ctx_sub_ctx_lookup [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+ctx_eq_refl [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
ctx_decomp_right [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
ctx_decomp_left [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
ctx_decomp [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
@@ -502,6 +503,10 @@

Global Index

exp_eq_var_1_sub_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_var_0_sub_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_sub_nat_helper [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_double_weaken_id_double_extend_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_double_weaken_double_extend_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_weaken_id_extend_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_weaken_extend_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_nat_sub_sub_to_nat_sub [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_nat_sub_sub [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_sub_compose_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
@@ -514,6 +519,10 @@

Global Index

exp_eq_var_0_sub_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_sub_typ_helper [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_typ_sub_sub [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_double_weaken_id_double_extend_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_double_weaken_double_extend_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_weaken_id_extend_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_weaken_extend_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_sub_compose_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_sub_cong_typ2' [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_sub_cong_typ1 [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
@@ -623,6 +632,35 @@

Global Index

presup_subtyp [lemma, in Mcltt.Core.Syntactic.Presup]
presup_sub_eq [lemma, in Mcltt.Core.Syntactic.Presup]
presup_exp_eq [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_sub_compose_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_sub_cong_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_var_S_sub_left [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_var_0_sub_left [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_eqrec_beta_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_eqrec_cong_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_refl_cong_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_eqrec_sub_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_eqrec_sub_left [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_refl_sub_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_id_sub_helper3 [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_typ_id_sub2_eq [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_id_sub_helper2 [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_sub_helper3 [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_typ_sub2_eq [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_sub_helper2 [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_wf [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_var1 [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_var0 [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_pi_eta_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_app_sub_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_app_sub_left [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_app_cong_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_fn_sub_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_fn_cong_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_beta_succ_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_natrec_sub_right [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_natrec_sub_left [lemma, in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_natrec_cong_right [lemma, in Mcltt.Core.Syntactic.Presup]


Q

q [definition, in Mcltt.Core.Syntactic.Syntax]


S

@@ -643,13 +681,15 @@

Global Index

sub_q_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_q [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_p_id_extend [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+sub_eq_id_extend_cong [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+sub_eq_id_on_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_id_extend [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_id_on_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
+sub_eq_weaken_var0_id [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_p_extend_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_extend_compose_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_extend_cong_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_extend_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
-sub_eq_wk_var0_id [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_p_extend_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_extend_compose_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_extend_cong_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
@@ -716,6 +756,7 @@

Global Index

there [constructor, in Mcltt.Core.Syntactic.System.Definitions]
typ [abbreviation, in Mcltt.Core.Syntactic.Syntax]


V

+var_compose_subs [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
vlookup_1_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
vlookup_0_nat [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
vlookup_1_typ [lemma, in Mcltt.Core.Syntactic.System.Lemmas]
@@ -1019,6 +1060,7 @@

Lemma Index

ctxsub_judg.ctxsub_exp_eq_helper [in Mcltt.Core.Syntactic.CtxSub]
ctxsub_judg.ctxsub_exp_helper [in Mcltt.Core.Syntactic.CtxSub]
ctx_sub_ctx_lookup [in Mcltt.Core.Syntactic.System.Lemmas]
+ctx_eq_refl [in Mcltt.Core.Syntactic.System.Lemmas]
ctx_decomp_right [in Mcltt.Core.Syntactic.System.Lemmas]
ctx_decomp_left [in Mcltt.Core.Syntactic.System.Lemmas]
ctx_decomp [in Mcltt.Core.Syntactic.System.Lemmas]
@@ -1037,6 +1079,10 @@

Lemma Index

exp_eq_var_1_sub_nat [in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_var_0_sub_nat [in Mcltt.Core.Syntactic.System.Lemmas]
exp_sub_nat_helper [in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_double_weaken_id_double_extend_nat [in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_double_weaken_double_extend_nat [in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_weaken_id_extend_nat [in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_weaken_extend_nat [in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_nat_sub_sub_to_nat_sub [in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_nat_sub_sub [in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_sub_compose_nat [in Mcltt.Core.Syntactic.System.Lemmas]
@@ -1049,6 +1095,10 @@

Lemma Index

exp_eq_var_0_sub_typ [in Mcltt.Core.Syntactic.System.Lemmas]
exp_sub_typ_helper [in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_typ_sub_sub [in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_double_weaken_id_double_extend_typ [in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_double_weaken_double_extend_typ [in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_weaken_id_extend_typ [in Mcltt.Core.Syntactic.System.Lemmas]
+exp_eq_sub_compose_weaken_extend_typ [in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_sub_compose_typ [in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_sub_cong_typ2' [in Mcltt.Core.Syntactic.System.Lemmas]
exp_eq_sub_cong_typ1 [in Mcltt.Core.Syntactic.System.Lemmas]
@@ -1114,6 +1164,35 @@

Lemma Index

presup_subtyp [in Mcltt.Core.Syntactic.Presup]
presup_sub_eq [in Mcltt.Core.Syntactic.Presup]
presup_exp_eq [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_sub_compose_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_sub_cong_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_var_S_sub_left [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_var_0_sub_left [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_eqrec_beta_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_eqrec_cong_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_refl_cong_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_eqrec_sub_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_eqrec_sub_left [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_refl_sub_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_id_sub_helper3 [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_typ_id_sub2_eq [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_id_sub_helper2 [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_sub_helper3 [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_typ_sub2_eq [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_sub_helper2 [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_wf [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_var1 [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_prop_eq_var0 [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_pi_eta_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_app_sub_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_app_sub_left [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_app_cong_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_fn_sub_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_fn_cong_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_beta_succ_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_natrec_sub_right [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_natrec_sub_left [in Mcltt.Core.Syntactic.Presup]
+presup_exp_eq_natrec_cong_right [in Mcltt.Core.Syntactic.Presup]


S

sub_lookup_var1 [in Mcltt.Core.Syntactic.System.Lemmas]
sub_lookup_var0 [in Mcltt.Core.Syntactic.System.Lemmas]
@@ -1131,13 +1210,15 @@

Lemma Index

sub_q_typ [in Mcltt.Core.Syntactic.System.Lemmas]
sub_q [in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_p_id_extend [in Mcltt.Core.Syntactic.System.Lemmas]
+sub_eq_id_extend_cong [in Mcltt.Core.Syntactic.System.Lemmas]
+sub_eq_id_on_typ [in Mcltt.Core.Syntactic.System.Lemmas]
sub_id_extend [in Mcltt.Core.Syntactic.System.Lemmas]
sub_id_on_typ [in Mcltt.Core.Syntactic.System.Lemmas]
+sub_eq_weaken_var0_id [in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_p_extend_nat [in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_extend_compose_nat [in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_extend_cong_nat [in Mcltt.Core.Syntactic.System.Lemmas]
sub_extend_nat [in Mcltt.Core.Syntactic.System.Lemmas]
-sub_eq_wk_var0_id [in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_p_extend_typ [in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_extend_compose_typ [in Mcltt.Core.Syntactic.System.Lemmas]
sub_eq_extend_cong_typ [in Mcltt.Core.Syntactic.System.Lemmas]
@@ -1151,6 +1232,7 @@

Lemma Index

sub_q_eq [in Mcltt.Core.Syntactic.Corollaries]
sub_id_typ [in Mcltt.Core.Syntactic.Corollaries]


V

+var_compose_subs [in Mcltt.Core.Syntactic.System.Lemmas]
vlookup_1_nat [in Mcltt.Core.Syntactic.System.Lemmas]
vlookup_0_nat [in Mcltt.Core.Syntactic.System.Lemmas]
vlookup_1_typ [in Mcltt.Core.Syntactic.System.Lemmas]
@@ -1492,7 +1574,7 @@

Definition Index

Z _ other -(480 entries) +(521 entries) Notation Index @@ -1620,7 +1702,7 @@

Definition Index

Z _ other -(206 entries) +(247 entries) Constructor Index diff --git a/ext/prop-eq/toc.html b/ext/prop-eq/toc.html index c9950de..adeddae 100644 --- a/ext/prop-eq/toc.html +++ b/ext/prop-eq/toc.html @@ -55,7 +55,10 @@

Mcltt.Core.Syntactic.

Mcltt.Core.Syntactic.System.Lemmas