diff --git a/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.CoreLemmas.html b/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.CoreLemmas.html index dbb6f08..fb6da3f 100644 --- a/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.CoreLemmas.html +++ b/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.CoreLemmas.html @@ -602,10 +602,45 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Lemma functional_glu_univ_elem : forall i a P P' El El',
-    {{ DG a glu_univ_elem i P El }} ->
-    {{ DG a glu_univ_elem i P' El' }} ->
-    (P <∙> P') /\ (El <∙> El').
+ + +
+

Morphism instances for eq_glu_*_preds

+ +
+
+Add Parametric Morphism i m n : (eq_glu_typ_pred i m n)
+    with signature glu_typ_pred_equivalence ==> glu_exp_pred_equivalence ==> eq ==> eq ==> iff as eq_glu_typ_pred_morphism_iff.
+Proof with mautosolve.
+  split; intros []; econstructor; intuition.
+Qed.
+ +
+Add Parametric Morphism i m n : (eq_glu_typ_pred i m n)
+    with signature glu_typ_pred_equivalence ==> glu_exp_pred_equivalence ==> glu_typ_pred_equivalence as eq_glu_typ_pred_morphism_glu_typ_pred_equivalence.
+Proof with mautosolve.
+  split; intros []; econstructor; intuition.
+Qed.
+ +
+Add Parametric Morphism i m n IR : (eq_glu_exp_pred i m n IR)
+    with signature glu_typ_pred_equivalence ==> glu_exp_pred_equivalence ==> eq ==> eq ==> eq ==> eq ==> iff as eq_glu_exp_pred_morphism_iff.
+Proof with mautosolve.
+  split; intros []; destruct_glu_eq; repeat (econstructor; intuition).
+Qed.
+ +
+Add Parametric Morphism i m n IR : (eq_glu_exp_pred i m n IR)
+    with signature glu_typ_pred_equivalence ==> glu_exp_pred_equivalence ==> glu_exp_pred_equivalence as eq_glu_exp_pred_morphism_glu_exp_pred_equivalence.
+Proof with mautosolve.
+  split; intros []; destruct_glu_eq; repeat (econstructor; intuition).
+Qed.
+ +
+Lemma functional_glu_univ_elem : forall i a P P' El El',
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem i P' El' }} ->
+    (P <∙> P') /\ (El <∙> El').
Proof.
  simpl.
  intros * Ha Ha'. gen P' El'.
@@ -628,8 +663,8 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

        [rename equiv_n into equiv0_n; assert (equiv_n : in_rel n n) by intuition
        | assert (equiv0_n : in_rel0 n n) by intuition];
        destruct_rel_mod_eval;
-        [assert (exists m0n, {{ $| m0 & n |↘ m0n }} /\ {{ Δ M0[σ] N : OT[σ,,N] ® m0n OEl n equiv_n }}) by intuition
-        | assert (exists m0n, {{ $| m0 & n |↘ m0n }} /\ {{ Δ M0[σ] N : OT[σ,,N] ® m0n OEl0 n equiv0_n }}) by intuition];
+        [assert (exists m0n, {{ $| m0 & n |↘ m0n }} /\ {{ Δ M0[σ] N : OT[σ,,N] ® m0n OEl n equiv_n }}) by intuition
+        | assert (exists m0n, {{ $| m0 & n |↘ m0n }} /\ {{ Δ M0[σ] N : OT[σ,,N] ® m0n OEl0 n equiv0_n }}) by intuition];
        destruct_conjs;
        assert ((OP n equiv_n <∙> OP0 n equiv0_n) /\ (OEl n equiv_n <∙> OEl0 n equiv0_n)) as [] by mauto 3;
        eexists; split; intuition.
@@ -639,9 +674,8 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

    split; [intros Γ C | intros Γ M C m'].
    + split; intros []; econstructor; intuition.
    + split; intros []; econstructor; intuition;
-      match_by_head1 glu_eq ltac:(fun H => destruct H);
+        destruct_glu_eq;
        econstructor; intros; apply_equiv_right; mauto 4.
-      apply_equiv_left; mauto 4.
Qed.

@@ -675,18 +709,18 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

  clear_dups.

-Lemma glu_univ_elem_pi_clean_inversion1 : forall {i a ρ B in_rel P El},
-  {{ DF a a per_univ_elem i in_rel }} ->
-  {{ DG Π a ρ B glu_univ_elem i P El }} ->
-  exists IP IEl (OP : forall c (equiv_c_c : {{ Dom c c in_rel }}), glu_typ_pred)
-     (OEl : forall c (equiv_c_c : {{ Dom c c in_rel }}), glu_exp_pred) elem_rel,
-      {{ DG a glu_univ_elem i IP IEl }} /\
-        (forall c (equiv_c : {{ Dom c c in_rel }}) b,
-            {{ B ρ c b }} ->
-            {{ DG b glu_univ_elem i OP _ equiv_c OEl _ equiv_c }}) /\
-        {{ DF Π a ρ B Π a ρ B per_univ_elem i elem_rel }} /\
-        (P <∙> pi_glu_typ_pred i in_rel IP IEl OP) /\
-        (El <∙> pi_glu_exp_pred i in_rel IP IEl elem_rel OEl).
+Lemma glu_univ_elem_pi_clean_inversion1 : forall {i a ρ B in_rel P El},
+  {{ DF a a per_univ_elem i in_rel }} ->
+  {{ DG Π a ρ B glu_univ_elem i P El }} ->
+  exists IP IEl (OP : forall c (equiv_c_c : {{ Dom c c in_rel }}), glu_typ_pred)
+     (OEl : forall c (equiv_c_c : {{ Dom c c in_rel }}), glu_exp_pred) elem_rel,
+      {{ DG a glu_univ_elem i IP IEl }} /\
+        (forall c (equiv_c : {{ Dom c c in_rel }}) b,
+            {{ B ρ c b }} ->
+            {{ DG b glu_univ_elem i OP _ equiv_c OEl _ equiv_c }}) /\
+        {{ DF Π a ρ B Π a ρ B per_univ_elem i elem_rel }} /\
+        (P <∙> pi_glu_typ_pred i in_rel IP IEl OP) /\
+        (El <∙> pi_glu_exp_pred i in_rel IP IEl elem_rel OEl).
Proof.
  intros *.
  simpl.
@@ -697,44 +731,44 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

  do 5 eexists.
  repeat split.
  1,3: eassumption.
-  1: instantiate (1 := fun c equiv_c Γ A M m => forall (b : domain) Pb Elb,
-                          {{ B ρ c b }} ->
-                          {{ DG b glu_univ_elem i Pb Elb }} ->
-                          {{ Γ M : A ® m Elb }}).
-  1: instantiate (1 := fun c equiv_c Γ A => forall (b : domain) Pb Elb,
-                          {{ B ρ c b }} ->
-                          {{ DG b glu_univ_elem i Pb Elb }} ->
-                          {{ Γ A ® Pb }}).
+  1: instantiate (1 := fun c equiv_c Γ A M m => forall (b : domain) Pb Elb,
+                          {{ B ρ c b }} ->
+                          {{ DG b glu_univ_elem i Pb Elb }} ->
+                          {{ Γ M : A ® m Elb }}).
+  1: instantiate (1 := fun c equiv_c Γ A => forall (b : domain) Pb Elb,
+                          {{ B ρ c b }} ->
+                          {{ DG b glu_univ_elem i Pb Elb }} ->
+                          {{ Γ A ® Pb }}).
  2-5: intros []; econstructor; mauto.
  all: intros.
-  - assert {{ Dom c c in_rel0 }} as equiv0_c by intuition.
-    assert {{ DG b glu_univ_elem i OP c equiv0_c OEl c equiv0_c }} by mauto 3.
+  - assert {{ Dom c c in_rel0 }} as equiv0_c by intuition.
+    assert {{ DG b glu_univ_elem i OP c equiv0_c OEl c equiv0_c }} by mauto 3.
    apply -> simple_glu_univ_elem_morphism_iff; [| reflexivity | |]; [eauto | |].
    + intros ? ? ? ?.
      split; intros; handle_functional_glu_univ_elem; intuition.
    + intros ? ?.
      split; [intros; handle_functional_glu_univ_elem |]; intuition.
-  - assert {{ Dom m m in_rel0 }} as equiv0_m by intuition.
-    assert {{ DG b glu_univ_elem i OP m equiv0_m OEl m equiv0_m }} by mauto 3.
+  - assert {{ Dom m m in_rel0 }} as equiv0_m by intuition.
+    assert {{ DG b glu_univ_elem i OP m equiv0_m OEl m equiv0_m }} by mauto 3.
    handle_functional_glu_univ_elem.
    intuition.
  - match_by_head per_univ_elem ltac:(fun H => directed invert_per_univ_elem H).
    destruct_rel_mod_eval.
    intuition.
-  - assert {{ Dom n n in_rel0 }} as equiv0_n by intuition.
-    assert (exists mn : domain, {{ $| m & n |↘ mn }} /\ {{ Δ M[σ] N : OT[σ,,N] ® mn OEl n equiv0_n }}) by mauto 3.
+  - assert {{ Dom n n in_rel0 }} as equiv0_n by intuition.
+    assert (exists mn : domain, {{ $| m & n |↘ mn }} /\ {{ Δ M[σ] N : OT[σ,,N] ® mn OEl n equiv0_n }}) by mauto 3.
    destruct_conjs.
    eexists.
    intuition.
-    assert {{ DG b glu_univ_elem i OP n equiv0_n OEl n equiv0_n }} by mauto 3.
+    assert {{ DG b glu_univ_elem i OP n equiv0_n OEl n equiv0_n }} by mauto 3.
    handle_functional_glu_univ_elem.
    intuition.
-  - assert (exists mn : domain,
-               {{ $| m & n |↘ mn }} /\
-                 (forall (b : domain) (Pb : glu_typ_pred) (Elb : glu_exp_pred),
-                     {{ B ρ n b }} ->
-                     {{ DG b glu_univ_elem i Pb Elb }} ->
-                     {{ Δ M[σ] N : OT[σ,,N] ® mn Elb }})) by intuition.
+  - assert (exists mn : domain,
+               {{ $| m & n |↘ mn }} /\
+                 (forall (b : domain) (Pb : glu_typ_pred) (Elb : glu_exp_pred),
+                     {{ B ρ n b }} ->
+                     {{ DG b glu_univ_elem i Pb Elb }} ->
+                     {{ Δ M[σ] N : OT[σ,,N] ® mn Elb }})) by intuition.
    destruct_conjs.
    match_by_head per_univ_elem ltac:(fun H => directed invert_per_univ_elem H).
    handle_per_univ_elem_irrel.
@@ -746,18 +780,18 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Lemma glu_univ_elem_pi_clean_inversion2 : forall {i a ρ B in_rel IP IEl P El},
-  {{ DF a a per_univ_elem i in_rel }} ->
-  {{ DG a glu_univ_elem i IP IEl }} ->
-  {{ DG Π a ρ B glu_univ_elem i P El }} ->
-  exists (OP : forall c (equiv_c_c : {{ Dom c c in_rel }}), glu_typ_pred)
-     (OEl : forall c (equiv_c_c : {{ Dom c c in_rel }}), glu_exp_pred) elem_rel,
-    (forall c (equiv_c : {{ Dom c c in_rel }}) b,
-        {{ B ρ c b }} ->
-        {{ DG b glu_univ_elem i OP _ equiv_c OEl _ equiv_c }}) /\
-      {{ DF Π a ρ B Π a ρ B per_univ_elem i elem_rel }} /\
-      (P <∙> pi_glu_typ_pred i in_rel IP IEl OP) /\
-      (El <∙> pi_glu_exp_pred i in_rel IP IEl elem_rel OEl).
+Lemma glu_univ_elem_pi_clean_inversion2 : forall {i a ρ B in_rel IP IEl P El},
+  {{ DF a a per_univ_elem i in_rel }} ->
+  {{ DG a glu_univ_elem i IP IEl }} ->
+  {{ DG Π a ρ B glu_univ_elem i P El }} ->
+  exists (OP : forall c (equiv_c_c : {{ Dom c c in_rel }}), glu_typ_pred)
+     (OEl : forall c (equiv_c_c : {{ Dom c c in_rel }}), glu_exp_pred) elem_rel,
+    (forall c (equiv_c : {{ Dom c c in_rel }}) b,
+        {{ B ρ c b }} ->
+        {{ DG b glu_univ_elem i OP _ equiv_c OEl _ equiv_c }}) /\
+      {{ DF Π a ρ B Π a ρ B per_univ_elem i elem_rel }} /\
+      (P <∙> pi_glu_typ_pred i in_rel IP IEl OP) /\
+      (El <∙> pi_glu_exp_pred i in_rel IP IEl elem_rel OEl).
Proof.
  intros *.
  simpl.
@@ -779,11 +813,11 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

  + basic_invert_glu_univ_elem H.

-Lemma glu_nat_resp_per_nat : forall m n,
-    {{ Dom m n per_nat }} ->
-    forall Γ M,
-      glu_nat Γ M m ->
-      glu_nat Γ M n.
+Lemma glu_nat_resp_per_nat : forall m n,
+    {{ Dom m n per_nat }} ->
+    forall Γ M,
+      glu_nat Γ M m ->
+      glu_nat Γ M n.
Proof.
  induction 1; intros; progressive_inversion; mauto.
  econstructor.
@@ -810,15 +844,15 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

  eauto; intuition.

-Lemma glu_univ_elem_resp_per_univ_elem : forall i a a' R,
-    {{ DF a a' per_univ_elem i R }} ->
-    forall P El,
-    {{ DG a glu_univ_elem i P El }} ->
-    {{ DG a' glu_univ_elem i P El }} /\
-      (forall Γ M A m m',
-          {{ Γ M : A ® m El }} ->
-          {{ Dom m m' R }} ->
-          {{ Γ M : A ® m' El }}).
+Lemma glu_univ_elem_resp_per_univ_elem : forall i a a' R,
+    {{ DF a a' per_univ_elem i R }} ->
+    forall P El,
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a' glu_univ_elem i P El }} /\
+      (forall Γ M A m m',
+          {{ Γ M : A ® m El }} ->
+          {{ Dom m m' R }} ->
+          {{ Γ M : A ® m' El }}).
Proof.
  simpl.
  intros * Hper * Horig.
@@ -925,10 +959,10 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Lemma glu_univ_elem_resp_per_univ : forall i a a' P El,
-    {{ Dom a a' per_univ i }} ->
-    {{ DG a glu_univ_elem i P El }} ->
-    {{ DG a' glu_univ_elem i P El }}.
+Lemma glu_univ_elem_resp_per_univ : forall i a a' P El,
+    {{ Dom a a' per_univ i }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a' glu_univ_elem i P El }}.
Proof.
  intros * [? H] ?.
  eapply glu_univ_elem_resp_per_univ_elem in H; eauto.
@@ -936,12 +970,12 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Lemma glu_univ_elem_resp_per_elem : forall i a a' R P El Γ M A m m',
-    {{ DF a a' per_univ_elem i R }} ->
-    {{ DG a glu_univ_elem i P El }} ->
-    {{ Γ M : A ® m El }} ->
-    {{ Dom m m' R }} ->
-    {{ Γ M : A ® m' El }}.
+Lemma glu_univ_elem_resp_per_elem : forall i a a' R P El Γ M A m m',
+    {{ DF a a' per_univ_elem i R }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Dom m m' R }} ->
+    {{ Γ M : A ® m' El }}.
Proof.
  intros * H ?.
  eapply glu_univ_elem_resp_per_univ_elem in H; eauto.
@@ -952,12 +986,12 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

-

Morphism instances for glu_univ_elem

+

Morphism instances for glu_univ_elem

-Add Parametric Morphism i : (glu_univ_elem i)
-    with signature glu_typ_pred_equivalence ==> glu_exp_pred_equivalence ==> per_univ i ==> iff as glu_univ_elem_morphism_iff.
+Add Parametric Morphism i : (glu_univ_elem i)
+    with signature glu_typ_pred_equivalence ==> glu_exp_pred_equivalence ==> per_univ i ==> iff as glu_univ_elem_morphism_iff.
Proof with mautosolve.
  intros P P' HPP' El El' HElEl' a a' Haa'.
  rewrite HPP', HElEl'.
@@ -966,8 +1000,8 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Add Parametric Morphism i R : (glu_univ_elem i)
-    with signature glu_typ_pred_equivalence ==> glu_exp_pred_equivalence ==> per_univ_elem i R ==> iff as glu_univ_elem_morphism_iff'.
+Add Parametric Morphism i R : (glu_univ_elem i)
+    with signature glu_typ_pred_equivalence ==> glu_exp_pred_equivalence ==> per_univ_elem i R ==> iff as glu_univ_elem_morphism_iff'.
Proof with mautosolve.
  intros P P' HPP' El El' HElEl' **.
  rewrite HPP', HElEl'.
@@ -994,9 +1028,9 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

  repeat saturate_glu_by_per1.

-Lemma per_univ_glu_univ_elem : forall i a,
-    {{ Dom a a per_univ i }} ->
-    exists P El, {{ DG a glu_univ_elem i P El }}.
+Lemma per_univ_glu_univ_elem : forall i a,
+    {{ Dom a a per_univ i }} ->
+    exists P El, {{ DG a glu_univ_elem i P El }}.
Proof.
  simpl.
  intros * [? Hper].
@@ -1008,22 +1042,22 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

    do 2 eexists.
    glu_univ_elem_econstructor; try (eassumption + reflexivity).
    + saturate_refl; eassumption.
-    + instantiate (1 := fun (c : domain) (equiv_c : in_rel c c) Γ A M m =>
-                          forall b P El,
-                            {{ B' ρ' c b }} ->
-                            glu_univ_elem i P El b ->
-                            {{ Γ M : A ® m El }}).
-      instantiate (1 := fun (c : domain) (equiv_c : in_rel c c) Γ A =>
-                          forall b P El,
-                            {{ B' ρ' c b }} ->
-                            glu_univ_elem i P El b ->
-                            {{ Γ A ® P }}).
+    + instantiate (1 := fun (c : domain) (equiv_c : in_rel c c) Γ A M m =>
+                          forall b P El,
+                            {{ B' ρ' c b }} ->
+                            glu_univ_elem i P El b ->
+                            {{ Γ M : A ® m El }}).
+      instantiate (1 := fun (c : domain) (equiv_c : in_rel c c) Γ A =>
+                          forall b P El,
+                            {{ B' ρ' c b }} ->
+                            glu_univ_elem i P El b ->
+                            {{ Γ A ® P }}).
      intros.
      (on_all_hyp: destruct_rel_by_assumption in_rel).
      handle_per_univ_elem_irrel.
      rewrite simple_glu_univ_elem_morphism_iff; try (eassumption + reflexivity);
        split; intros; handle_functional_glu_univ_elem; intuition.
-    + enough {{ DF Π a ρ B Π a' ρ' B' per_univ_elem i elem_rel }} by (etransitivity; [symmetry |]; eassumption).
+    + enough {{ DF Π a ρ B Π a' ρ' B' per_univ_elem i elem_rel }} by (etransitivity; [symmetry |]; eassumption).
      per_univ_elem_econstructor; mauto.
      intros.
      (on_all_hyp: destruct_rel_by_assumption in_rel).
@@ -1041,9 +1075,9 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Hint Resolve per_univ_glu_univ_elem : mctt.

-Corollary per_univ_elem_glu_univ_elem : forall i a R,
-    {{ DF a a per_univ_elem i R }} ->
-    exists P El, {{ DG a glu_univ_elem i P El }}.
+Corollary per_univ_elem_glu_univ_elem : forall i a R,
+    {{ DF a a per_univ_elem i R }} ->
+    exists P El, {{ DG a glu_univ_elem i P El }}.
Proof.
  intros.
  apply per_univ_glu_univ_elem; mauto.
@@ -1076,16 +1110,16 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Hint Rewrite -> sub_decompose_q using solve [mauto 4] : mctt.

-Lemma glu_univ_elem_mut_monotone : forall i a P El,
-    {{ DG a glu_univ_elem i P El }} ->
-    forall Δ σ Γ,
-      {{ Δ w σ : Γ }} ->
-      (forall A,
-        {{ Γ A ® P }} ->
-        {{ Δ A[σ] ® P }}) /\
-    (forall M A m,
-      {{ Γ M : A ® m El }} ->
-      {{ Δ M[σ] : A[σ] ® m El }}).
+Lemma glu_univ_elem_mut_monotone : forall i a P El,
+    {{ DG a glu_univ_elem i P El }} ->
+    forall Δ σ Γ,
+      {{ Δ w σ : Γ }} ->
+      (forall A,
+        {{ Γ A ® P }} ->
+        {{ Δ A[σ] ® P }}) /\
+    (forall M A m,
+      {{ Γ M : A ® m El }} ->
+      {{ Δ M[σ] : A[σ] ® m El }}).
Proof.
  simpl. induction 1 using glu_univ_elem_ind;
    split; intros;
@@ -1128,12 +1162,12 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

      deepexec H1 ltac:(fun H => pose proof H).
      autorewrite with mctt in *.
      repeat eexists; eauto.
-      assert {{ Δ0 s σ0,,N : Δ, IT[σ] }}.
+      assert {{ Δ0 s σ0,,N : Δ, IT[σ] }}.
      {
        econstructor; mauto 2.
        bulky_rewrite.
      }
-      assert {{Δ0 M[σ][σ0] N M[σσ0] N : OT [σσ0,,N]}}.
+      assert {{Δ0 M[σ][σ0] N M[σσ0] N : OT [σσ0,,N]}}.
      {
        rewrite <- @sub_eq_q_sigma_id_extend; mauto 4.
        rewrite <- @exp_eq_sub_compose_typ; mauto 3;
@@ -1141,7 +1175,7 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

          mauto 4.
        symmetry.
        bulky_rewrite_in H4.
-        assert {{ Δ0 Π IT[σσ0] (OT[q (σσ0)]) (Π IT OT)[σσ0] : Type@_ }} by mauto.
+        assert {{ Δ0 Π IT[σσ0] (OT[q (σσ0)]) (Π IT OT)[σσ0] : Type@_ }} by mauto.
        eapply wf_exp_eq_conv'; mauto 4.
      }

@@ -1171,17 +1205,17 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

    + eapply IHglu_univ_elem; eauto.
    + eapply IHglu_univ_elem; eauto.
    + destruct_glu_eq; econstructor; eauto; intros.
-      * transitivity {{{(refl B M'')[σ]}}}; [mauto 3 |].
+      * transitivity {{{(refl B M'')[σ]}}}; [mauto 3 |].
        eapply wf_exp_eq_conv';
          [eapply wf_exp_eq_refl_sub'; gen_presups; eauto |].
        symmetry.
-        transitivity {{{(Eq B M N)[σ]}}}; mauto 2.
+        transitivity {{{(Eq B M N)[σ]}}}; mauto 2.
        eapply exp_eq_sub_cong_typ1; eauto.
        econstructor; mauto.
      * mauto.
      * mauto.
      * eapply IHglu_univ_elem; eauto.
-      * assert {{ Δ0 w σ σ0 : Γ }} by mauto 4.
+      * assert {{ Δ0 w σ σ0 : Γ }} by mauto 4.
        bulky_rewrite.
        etransitivity;
          [| deepexec H14 ltac:(fun H => apply H)].
@@ -1207,11 +1241,11 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Lemma glu_univ_elem_typ_monotone : forall i a P El Δ σ Γ A,
-    {{ DG a glu_univ_elem i P El }} ->
-    {{ Γ A ® P }} ->
-    {{ Δ w σ : Γ }} ->
-    {{ Δ A[σ] ® P }}.
+Lemma glu_univ_elem_typ_monotone : forall i a P El Δ σ Γ A,
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ Γ A ® P }} ->
+    {{ Δ w σ : Γ }} ->
+    {{ Δ A[σ] ® P }}.
Proof.
  intros * H; intros.
  eapply glu_univ_elem_mut_monotone in H; eauto.
@@ -1219,11 +1253,11 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Lemma glu_univ_elem_exp_monotone : forall i a P El Δ σ Γ M A m,
-    {{ DG a glu_univ_elem i P El }} ->
-    {{ Γ M : A ® m El }} ->
-    {{ Δ w σ : Γ }} ->
-    {{ Δ M[σ] : A[σ] ® m El }}.
+Lemma glu_univ_elem_exp_monotone : forall i a P El Δ σ Γ M A m,
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Δ w σ : Γ }} ->
+    {{ Δ M[σ] : A[σ] ® m El }}.
Proof.
  intros * H; intros.
  eapply glu_univ_elem_mut_monotone in H; eauto.
@@ -1231,7 +1265,7 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Add Parametric Morphism i a : (glu_elem_bot i a)
+Add Parametric Morphism i a : (glu_elem_bot i a)
    with signature wf_ctx_eq ==> eq ==> eq ==> eq ==> iff as glu_elem_bot_morphism_iff1.
Proof.
  intros Γ Γ' HΓΓ' *.
@@ -1239,32 +1273,32 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Add Parametric Morphism i a Γ : (glu_elem_bot i a Γ)
-    with signature wf_exp_eq Γ {{{ Type@i }}} ==> eq ==> eq ==> iff as glu_elem_bot_morphism_iff2.
+Add Parametric Morphism i a Γ : (glu_elem_bot i a Γ)
+    with signature wf_exp_eq Γ {{{ Type@i }}} ==> eq ==> eq ==> iff as glu_elem_bot_morphism_iff2.
Proof.
  intros A A' HAA' *.
  split; intros []; econstructor; mauto 3; [rewrite <- HAA' | | rewrite -> HAA' |];
    try eassumption;
    intros;
-    assert {{ Δ A[σ] A'[σ] : Type@i }} as HAσA'σ by mauto 4;
+    assert {{ Δ A[σ] A'[σ] : Type@i }} as HAσA'σ by mauto 4;
    [rewrite <- HAσA'σ | rewrite -> HAσA'σ];
    mauto.
Qed.

-Add Parametric Morphism i a Γ A : (glu_elem_bot i a Γ A)
-    with signature wf_exp_eq Γ A ==> eq ==> iff as glu_elem_bot_morphism_iff3.
+Add Parametric Morphism i a Γ A : (glu_elem_bot i a Γ A)
+    with signature wf_exp_eq Γ A ==> eq ==> iff as glu_elem_bot_morphism_iff3.
Proof.
  intros M M' HMM' *.
  split; intros []; econstructor; mauto 3; try (gen_presup HMM'; eassumption);
    intros;
-    assert {{ Δ M[σ] M'[σ] : A[σ] }} as HMσM'σ by mauto 4;
+    assert {{ Δ M[σ] M'[σ] : A[σ] }} as HMσM'σ by mauto 4;
    [rewrite <- HMσM'σ | rewrite -> HMσM'σ];
    mauto.
Qed.

-Add Parametric Morphism i a : (glu_elem_top i a)
+Add Parametric Morphism i a : (glu_elem_top i a)
    with signature wf_ctx_eq ==> eq ==> eq ==> eq ==> iff as glu_elem_top_morphism_iff1.
Proof.
  intros Γ Γ' HΓΓ' *.
@@ -1272,32 +1306,32 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Add Parametric Morphism i a Γ : (glu_elem_top i a Γ)
-    with signature wf_exp_eq Γ {{{ Type@i }}} ==> eq ==> eq ==> iff as glu_elem_top_morphism_iff2.
+Add Parametric Morphism i a Γ : (glu_elem_top i a Γ)
+    with signature wf_exp_eq Γ {{{ Type@i }}} ==> eq ==> eq ==> iff as glu_elem_top_morphism_iff2.
Proof.
  intros A A' HAA' *.
  split; intros []; econstructor; mauto 3; [rewrite <- HAA' | | rewrite -> HAA' |];
    try eassumption;
    intros;
-    assert {{ Δ A[σ] A'[σ] : Type@i }} as HAσA'σ by mauto 4;
+    assert {{ Δ A[σ] A'[σ] : Type@i }} as HAσA'σ by mauto 4;
    [rewrite <- HAσA'σ | rewrite -> HAσA'σ];
    mauto.
Qed.

-Add Parametric Morphism i a Γ A : (glu_elem_top i a Γ A)
-    with signature wf_exp_eq Γ A ==> eq ==> iff as glu_elem_top_morphism_iff3.
+Add Parametric Morphism i a Γ A : (glu_elem_top i a Γ A)
+    with signature wf_exp_eq Γ A ==> eq ==> iff as glu_elem_top_morphism_iff3.
Proof.
  intros M M' HMM' *.
  split; intros []; econstructor; mauto 3; try (gen_presup HMM'; eassumption);
    intros;
-    assert {{ Δ M[σ] M'[σ] : A[σ] }} as HMσM'σ by mauto 4;
+    assert {{ Δ M[σ] M'[σ] : A[σ] }} as HMσM'σ by mauto 4;
    [rewrite <- HMσM'σ | rewrite -> HMσM'σ];
    mauto.
Qed.

-Add Parametric Morphism i a : (glu_typ_top i a)
+Add Parametric Morphism i a : (glu_typ_top i a)
    with signature wf_ctx_eq ==> eq ==> iff as glu_typ_top_morphism_iff1.
Proof.
  intros Γ Γ' HΓΓ' *.
@@ -1305,14 +1339,14 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Qed.

-Add Parametric Morphism i a Γ : (glu_typ_top i a Γ)
-    with signature wf_exp_eq Γ {{{ Type@i }}} ==> iff as glu_typ_top_morphism_iff2.
+Add Parametric Morphism i a Γ : (glu_typ_top i a Γ)
+    with signature wf_exp_eq Γ {{{ Type@i }}} ==> iff as glu_typ_top_morphism_iff2.
Proof.
  intros A A' HAA' *.
  split; intros []; econstructor; mauto 3;
    try (gen_presup HAA'; eassumption);
    intros;
-    assert {{ Δ A[σ] A'[σ] : Type@i }} as HAσA'σ by mauto 4;
+    assert {{ Δ A[σ] A'[σ] : Type@i }} as HAσA'σ by mauto 4;
    [rewrite <- HAσA'σ | rewrite -> HAσA'σ];
    mauto.
Qed.
@@ -1321,7 +1355,7 @@

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

-

Simple Morphism instance for glu_ctx_env

+

Simple Morphism instance for glu_ctx_env

diff --git a/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.Definitions.html b/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.Definitions.html index c25b8fa..4bef162 100644 --- a/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.Definitions.html +++ b/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.Definitions.html @@ -184,7 +184,7 @@

Mctt.Core.Soundness.LogicalRelation.Definitions

       {{ Γ M' : A ® b v glu_eq B M N m n R El }} }.

-Variant eq_glu_exp_pred i m n R P El : glu_exp_pred :=
+Variant eq_glu_exp_pred i m n R (P : glu_typ_pred) (El : glu_exp_pred) : glu_exp_pred :=
  | mk_eq_glu_exp_pred :
    `{ {{ Γ M' : A }} ->
       {{ Γ A Eq B M N : Type@i }} ->
diff --git a/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.Lemmas.html b/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.Lemmas.html new file mode 100644 index 0000000..61f52cc --- /dev/null +++ b/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.Lemmas.html @@ -0,0 +1,1492 @@ + + + + + + + + + + + + + +
+
+

Mctt.Core.Soundness.LogicalRelation.Lemmas

+ +
+From Coq Require Import Equivalence Morphisms Morphisms_Prop Morphisms_Relations Relation_Definitions RelationClasses.
+ +
+From Mctt Require Import LibTactics.
+From Mctt.Core Require Import Base.
+From Mctt.Core.Completeness Require Import FundamentalTheorem.
+From Mctt.Core.Semantic Require Import Realizability.
+From Mctt.Core.Soundness Require Export Realizability.
+Import Domain_Notations.
+ +
+Add Parametric Morphism i a Γ A M : (glu_elem_bot i a Γ A M)
+    with signature per_bot ==> iff as glu_elem_bot_morphism_iff4.
+Proof.
+  intros m m' Hmm' *.
+  split; intros []; econstructor; mauto 3;
+    try (etransitivity; mauto 4);
+    intros;
+    specialize (Hmm' (length Δ)) as [? []];
+    functional_read_rewrite_clear;
+    mauto.
+Qed.
+ +
+Add Parametric Morphism i a Γ A M R (H : per_univ_elem i R a a) : (glu_elem_top i a Γ A M)
+    with signature R ==> iff as glu_elem_top_morphism_iff4.
+Proof.
+  intros m m' Hmm' *.
+  split; intros []; econstructor; mauto 3;
+    pose proof (per_elem_then_per_top H Hmm') as Hmm'';
+    try (etransitivity; mauto 4);
+    intros;
+    specialize (Hmm'' (length Δ)) as [? []];
+    functional_read_rewrite_clear;
+    mauto.
+Qed.
+ +
+Lemma glu_univ_elem_typ_unique_upto_exp_eq : forall {i j a P P' El El' Γ A A'},
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem j P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A' ® P' }} ->
+    {{ Γ A A' : Type@(max i j) }}.
+Proof with mautosolve 4.
+  intros.
+  assert {{ Γ A ® glu_typ_top i a }} as [] by mauto 3.
+  assert {{ Γ A' ® glu_typ_top j a }} as [] by mauto 3.
+  match_by_head per_top_typ ltac:(fun H => destruct (H (length Γ)) as [V []]).
+  clear_dups.
+  functional_read_rewrite_clear.
+  assert {{ Γ A : Type@(max i j) }} by mauto 4 using lift_exp_max_left.
+  assert {{ Γ A' : Type@(max i j) }} by mauto 4 using lift_exp_max_right.
+  assert {{ Γ A[Id] V : Type@i }} by mauto 4.
+  assert {{ Γ A[Id] V : Type@(max i j) }} by mauto 4 using lift_exp_eq_max_left.
+  assert {{ Γ A'[Id] V : Type@j }} by mauto 4.
+  assert {{ Γ A'[Id] V : Type@(max i j) }} by mauto 4 using lift_exp_eq_max_right.
+  autorewrite with mctt in *...
+Qed.
+ +
+#[export]
+Hint Resolve glu_univ_elem_typ_unique_upto_exp_eq : mctt.
+ +
+Lemma glu_univ_elem_typ_unique_upto_exp_eq_ge : forall {i j a P P' El El' Γ A A'},
+    i <= j ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem j P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A' ® P' }} ->
+    {{ Γ A A' : Type@j }}.
+Proof with mautosolve 4.
+  intros.
+  replace j with (max i j) by lia...
+Qed.
+ +
+#[export]
+Hint Resolve glu_univ_elem_typ_unique_upto_exp_eq_ge : mctt.
+ +
+Lemma glu_univ_elem_typ_unique_upto_exp_eq' : forall {i a P El Γ A A'},
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A' ® P }} ->
+    {{ Γ A A' : Type@i }}.
+Proof. mautosolve 4. Qed.
+ +
+#[export]
+Hint Resolve glu_univ_elem_typ_unique_upto_exp_eq' : mctt.
+ +
+Lemma glu_univ_elem_per_univ_elem_typ_escape : forall {i a a' elem_rel P P' El El' Γ A A'},
+    {{ DF a a' per_univ_elem i elem_rel }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a' glu_univ_elem i P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A' ® P' }} ->
+    {{ Γ A A' : Type@i }}.
+Proof with mautosolve 4.
+  simpl in *.
+  intros * Hper Hglu Hglu' HA HA'.
+  assert {{ DG a glu_univ_elem i P' El' }} by (setoid_rewrite Hper; eassumption).
+  handle_functional_glu_univ_elem...
+Qed.
+ +
+#[export]
+Hint Resolve glu_univ_elem_per_univ_elem_typ_escape : mctt.
+ +
+Lemma glu_univ_elem_per_univ_typ_escape : forall {i a a' P P' El El' Γ A A'},
+    {{ Dom a a' per_univ i }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a' glu_univ_elem i P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A' ® P' }} ->
+    {{ Γ A A' : Type@i }}.
+Proof.
+  intros * [] **...
+  mauto 4.
+Qed.
+ +
+#[export]
+Hint Resolve glu_univ_elem_per_univ_typ_escape : mctt.
+ +
+Lemma glu_univ_elem_exp_unique_upto_exp_eq : forall {i j a P P' El El' Γ A A' M M' m},
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem j P' El' }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Γ M' : A' ® m El' }} ->
+    {{ Γ M M' : A }}.
+Proof.
+  intros.
+  assert {{ Γ M : A ® m glu_elem_top i a }} as [] by mauto 3.
+  assert {{ Γ M' : A' ® m glu_elem_top j a }} as [] by mauto 3.
+  assert {{ Γ A A' : Type@(max i j) }} by mauto 3.
+  match_by_head per_top ltac:(fun H => destruct (H (length Γ)) as [W []]).
+  clear_dups.
+  assert {{ Γ M[Id] W : A[Id] }} by mauto 4.
+  assert {{ Γ M[Id] W : A }} by (gen_presups; mauto 4).
+  assert {{ Γ M : A }} by mauto 4.
+  assert {{ Γ M'[Id] W : A'[Id] }} by mauto 4.
+  assert {{ Γ M'[Id] W : A' }} by (gen_presups; mauto 4).
+  assert {{ Γ M'[Id] W : A }} by (gen_presups; mauto 4).
+  assert {{ Γ M' : A }} by mauto 4.
+  transitivity {{{M[Id]}}}; [mauto 3 |].
+  transitivity W; [mauto 3 |].
+  mauto 4.
+Qed.
+ +
+#[export]
Hint Resolve glu_univ_elem_exp_unique_upto_exp_eq : mctt.
+ +
+Lemma glu_univ_elem_exp_unique_upto_exp_eq' : forall {i a P El Γ M M' m A},
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Γ M' : A ® m El }} ->
+    {{ Γ M M' : A }}.
+Proof. mautosolve 4. Qed.
+ +
+#[export]
+Hint Resolve glu_univ_elem_exp_unique_upto_exp_eq' : mctt.
+ +
+Lemma glu_univ_elem_per_univ_typ_iff : forall {i a a' P P' El El'},
+    {{ Dom a a' per_univ i }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a' glu_univ_elem i P' El' }} ->
+    (P <∙> P') /\ (El <∙> El').
+Proof.
+  intros * Hper **.
+  eapply functional_glu_univ_elem;
+    [eassumption | rewrite Hper];
+    eassumption.
+Qed.
+ +
+Corollary glu_univ_elem_cumu_ge : forall {i j a P El},
+    i <= j ->
+    {{ DG a glu_univ_elem i P El }} ->
+    exists P' El', {{ DG a glu_univ_elem j P' El' }}.
+Proof.
+  intros.
+  assert {{ Dom a a per_univ i }} as [R] by mauto.
+  assert {{ DF a a per_univ_elem j R }} by mauto.
+  mauto.
+Qed.
+ +
+#[export]
+Hint Resolve glu_univ_elem_cumu_ge : mctt.
+ +
+Corollary glu_univ_elem_cumu_max_left : forall {i j a P El},
+    {{ DG a glu_univ_elem i P El }} ->
+    exists P' El', {{ DG a glu_univ_elem (max i j) P' El' }}.
+Proof.
+  intros.
+  assert (i <= max i j) by lia.
+  mauto.
+Qed.
+ +
+Corollary glu_univ_elem_cumu_max_right : forall {i j a P El},
+    {{ DG a glu_univ_elem j P El }} ->
+    exists P' El', {{ DG a glu_univ_elem (max i j) P' El' }}.
+Proof.
+  intros.
+  assert (j <= max i j) by lia.
+  mauto.
+Qed.
+ +
+Section glu_univ_elem_cumulativity.
+  #[local]
+  Lemma glu_univ_elem_cumulativity_ge : forall {i j a P P' El El'},
+      i <= j ->
+      {{ DG a glu_univ_elem i P El }} ->
+      {{ DG a glu_univ_elem j P' El' }} ->
+      (forall Γ A, {{ Γ A ® P }} -> {{ Γ A ® P' }}) /\
+        (forall Γ A M m, {{ Γ M : A ® m El }} -> {{ Γ M : A ® m El' }}) /\
+        (forall Γ A M m, {{ Γ A ® P }} -> {{ Γ M : A ® m El' }} -> {{ Γ M : A ® m El }}).
+  Proof with mautosolve 4.
+    simpl.
+    intros * Hge Hglu Hglu'. gen El' P' j.
+    induction Hglu using glu_univ_elem_ind; repeat split; intros;
+      try assert {{ DF a a per_univ_elem j in_rel }} by mauto 2;
+      invert_glu_univ_elem Hglu';
+      handle_functional_glu_univ_elem;
+      simpl in *;
+      try solve [repeat split; intros; destruct_conjs; mauto 2 | intuition mauto 3].
+ +
+    - rename x into IP'.
+      rename x0 into IEl'.
+      rename x1 into OP'.
+      rename x2 into OEl'.
+      destruct_by_head pi_glu_typ_pred.
+      econstructor; intros; mauto 4.
+      + assert {{ Δ IT[σ] ® IP }} by mauto.
+        enough (forall Γ A, {{ Γ A ® IP }} -> {{ Γ A ® IP' }}) by mauto 4.
+        eapply proj1...
+      + match_by_head per_univ_elem ltac:(fun H => directed invert_per_univ_elem H).
+        apply_relation_equivalence.
+        destruct_rel_mod_eval.
+        handle_per_univ_elem_irrel.
+        assert (forall Γ A, {{ Γ A ® OP m equiv_m }} -> {{ Γ A ® OP' m equiv_m }}) by (eapply proj1; mauto).
+        enough {{ Δ OT[σ,,M] ® OP m equiv_m }} by mauto.
+        enough {{ Δ M : IT[σ] ® m IEl }} by mauto.
+        eapply IHHglu...
+    - rename x into IP'.
+      rename x0 into IEl'.
+      rename x1 into OP'.
+      rename x2 into OEl'.
+      destruct_by_head pi_glu_exp_pred.
+      handle_per_univ_elem_irrel.
+      econstructor; intros; mauto 4.
+      + enough (forall Γ A, {{ Γ A ® IP }} -> {{ Γ A ® IP' }}) by mauto 4.
+        eapply proj1...
+      + match_by_head per_univ_elem ltac:(fun H => directed invert_per_univ_elem H).
+        handle_per_univ_elem_irrel.
+        destruct_rel_mod_eval.
+        destruct_rel_mod_app.
+        handle_per_univ_elem_irrel.
+        eexists; split; mauto 4.
+        assert (forall Γ A M m, {{ Γ M : A ® m OEl n equiv_n }} -> {{ Γ M : A ® m OEl' n equiv_n }}) by (eapply proj1, proj2; mauto 4).
+        enough {{ Δ M[σ] N : OT[σ,,N] ® fa OEl n equiv_n }} by mauto 4.
+        assert {{ Δ N : IT[σ] ® n IEl }} by (eapply IHHglu; mauto 3).
+        assert (exists mn, {{ $| m & n |↘ mn }} /\ {{ Δ M[σ] N : OT[σ,,N] ® mn OEl n equiv_n }}) by mauto 4.
+        destruct_conjs.
+        functional_eval_rewrite_clear...
+    - rename x into IP'.
+      rename x0 into IEl'.
+      rename x1 into OP'.
+      rename x2 into OEl'.
+      destruct_by_head pi_glu_typ_pred.
+      destruct_by_head pi_glu_exp_pred.
+      handle_per_univ_elem_irrel.
+      econstructor; intros; mauto.
+      match_by_head per_univ_elem ltac:(fun H => directed invert_per_univ_elem H).
+      handle_per_univ_elem_irrel.
+      destruct_rel_mod_eval.
+      destruct_rel_mod_app.
+      handle_per_univ_elem_irrel.
+      match goal with
+      | _: {{ B ρ n ^?a }} |- _ =>
+          rename a into b
+      end.
+      eexists; split; mauto 4.
+      assert (forall Γ A M m, {{ Γ A ® OP n equiv_n }} -> {{ Γ M : A ® m OEl' n equiv_n }} -> {{ Γ M : A ® m OEl n equiv_n }}) by (eapply proj2, proj2; eauto 3).
+      assert {{ Δ OT[σ,,N] ® OP n equiv_n }} by mauto 4.
+      enough {{ Δ M[σ] N : OT[σ,,N] ® fa OEl' n equiv_n }} by mauto 4.
+      assert {{ Δ N : IT[σ] ® n IEl' }} by (eapply IHHglu; mauto 3).
+      assert {{ Δ IT[σ] ® IP' }} by (eapply glu_univ_elem_trm_typ; mauto 2).
+      assert {{ Δ IT0[σ] ® IP' }} by mauto 2.
+      assert {{ Δ IT[σ] IT0[σ] : Type@j }} as HITeq by mauto 2.
+      assert {{ Δ N : IT0[σ] ® n IEl' }} by (rewrite <- HITeq; mauto 3).
+      assert (exists mn, {{ $| m & n |↘ mn }} /\ {{ Δ M[σ] N : OT0[σ,,N] ® mn OEl' n equiv_n }}) by mauto 3.
+      destruct_conjs.
+      functional_eval_rewrite_clear.
+      assert {{ DG b glu_univ_elem j OP' n equiv_n OEl' n equiv_n }} by mauto 3.
+      assert {{ Δ OT0[σ,,N] ® OP' n equiv_n }} by (eapply glu_univ_elem_trm_typ; mauto 3).
+      enough {{ Δ OT[σ,,N] OT0[σ,,N] : Type@j }} as ->...
+ +
+    - invert_glu_rel1.
+      econstructor; intros; firstorder mauto 3.
+    - invert_glu_rel1.
+      handle_per_univ_elem_irrel.
+ +
+      econstructor; intros; firstorder mauto 3.
+      destruct_glu_eq; econstructor; firstorder mauto 3.
+    - repeat invert_glu_rel1.
+      handle_per_univ_elem_irrel.
+ +
+      econstructor; intros; firstorder mauto 3.
+      assert {{ Γ w Id : Γ }} by mauto 4.
+      assert (P Γ {{{ B[Id] }}}) as HB by mauto 3.
+      bulky_rewrite_in HB.
+      assert (P0 Γ B) as HB' by firstorder.
+      assert (P0 Γ {{{ B0[Id] }}}) as HB0 by mauto 3.
+      bulky_rewrite_in HB0.
+      assert {{ Γ B0 B : Type@j }} by mauto 3.
+      assert (El Γ {{{ B[Id] }}} {{{ M0[Id] }}} m) as HM0 by mauto 3.
+      bulky_rewrite_in HM0.
+      assert (El0 Γ B M0 m) as HM0' by firstorder.
+      assert (El Γ {{{ B[Id] }}} {{{ N[Id] }}} n) as HN by mauto 3.
+      bulky_rewrite_in HN.
+      assert (El0 Γ B N n) as HN' by firstorder.
+      assert (El0 Γ {{{ B0[Id] }}} {{{ M[Id] }}} m) as HM by mauto 3.
+      bulky_rewrite_in HM.
+      assert (El0 Γ {{{ B0[Id] }}} {{{ N0[Id] }}} n) as HN0 by mauto 3.
+      bulky_rewrite_in HN0.
+      assert {{ Γ M0 M : B }} by mauto 3.
+      assert {{ Γ N N0 : B }} by mauto 3.
+ +
+      destruct_glu_eq; econstructor; apply_equiv_left; mauto 3.
+      + bulky_rewrite.
+        eapply wf_exp_eq_conv'; [econstructor |]; mauto 3.
+        transitivity M; mauto 3.
+        bulky_rewrite.
+      + transitivity M; mauto 3.
+        transitivity M''; mauto 3.
+        transitivity N0; mauto 3.
+      + intros.
+        assert (P Δ {{{ B[σ] }}}) by mauto 3.
+        assert {{ Δ B0[σ] B[σ] : Type@j }} by mauto 3.
+        assert {{ Γ M'' M0 : B }} by (transitivity M; mauto 3).
+        assert {{ Δ M''[σ] M0[σ] : B[σ] }} by mauto 4.
+        assert (El0 Δ {{{ B0[σ] }}} {{{M''[σ]}}} m') as HEl0 by mauto 3.
+        bulky_rewrite_in HEl0.
+        firstorder.
+ +
+    - destruct_by_head neut_glu_exp_pred.
+      econstructor; mauto.
+      destruct_by_head neut_glu_typ_pred.
+      econstructor...
+    - destruct_by_head neut_glu_exp_pred.
+      econstructor...
+  Qed.
+End glu_univ_elem_cumulativity.
+ +
+Corollary glu_univ_elem_typ_cumu_ge : forall {i j a P P' El El' Γ A},
+    i <= j ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem j P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A ® P' }}.
+Proof.
+  intros.
+  eapply glu_univ_elem_cumulativity_ge; mauto 4.
+Qed.
+ +
+Corollary glu_univ_elem_typ_cumu_max_left : forall {i j a P P' El El' Γ A},
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem (max i j) P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A ® P' }}.
+Proof.
+  intros.
+  assert (i <= max i j) by lia.
+  eapply glu_univ_elem_typ_cumu_ge; mauto 4.
+Qed.
+ +
+Corollary glu_univ_elem_typ_cumu_max_right : forall {i j a P P' El El' Γ A},
+    {{ DG a glu_univ_elem j P El }} ->
+    {{ DG a glu_univ_elem (max i j) P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A ® P' }}.
+Proof.
+  intros.
+  assert (j <= max i j) by lia.
+  eapply glu_univ_elem_typ_cumu_ge; mauto 4.
+Qed.
+ +
+Corollary glu_univ_elem_exp_cumu_ge : forall {i j a P P' El El' Γ A M m},
+    i <= j ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem j P' El' }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Γ M : A ® m El' }}.
+Proof.
+  intros. gen m M A Γ.
+  eapply glu_univ_elem_cumulativity_ge; mauto 4.
+Qed.
+ +
+Corollary glu_univ_elem_exp_cumu_max_left : forall {i j a P P' El El' Γ A M m},
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem (max i j) P' El' }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Γ M : A ® m El' }}.
+Proof.
+  intros.
+  assert (i <= max i j) by lia.
+  eapply glu_univ_elem_exp_cumu_ge; mauto 4.
+Qed.
+ +
+Corollary glu_univ_elem_exp_cumu_max_right : forall {i j a P P' El El' Γ A M m},
+    {{ DG a glu_univ_elem j P El }} ->
+    {{ DG a glu_univ_elem (max i j) P' El' }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Γ M : A ® m El' }}.
+Proof.
+  intros.
+  assert (j <= max i j) by lia.
+  eapply glu_univ_elem_exp_cumu_ge; mauto 4.
+Qed.
+ +
+Corollary glu_univ_elem_exp_lower : forall {i j a P P' El El' Γ A M m},
+    i <= j ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem j P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ M : A ® m El' }} ->
+    {{ Γ M : A ® m El }}.
+Proof.
+  intros * ? ? ?. gen m M A Γ.
+  eapply glu_univ_elem_cumulativity_ge; mauto 4.
+Qed.
+ +
+Corollary glu_univ_elem_exp_lower_max_left : forall {i j a P P' El El' Γ A M m},
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a glu_univ_elem (max i j) P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ M : A ® m El' }} ->
+    {{ Γ M : A ® m El }}.
+Proof.
+  intros.
+  assert (i <= max i j) by lia.
+  eapply glu_univ_elem_exp_lower; mauto 4.
+Qed.
+ +
+Corollary glu_univ_elem_exp_lower_max_right : forall {i j a P P' El El' Γ A M m},
+    {{ DG a glu_univ_elem j P El }} ->
+    {{ DG a glu_univ_elem (max i j) P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ M : A ® m El' }} ->
+    {{ Γ M : A ® m El }}.
+Proof.
+  intros.
+  assert (j <= max i j) by lia.
+  eapply glu_univ_elem_exp_lower; mauto 4.
+Qed.
+ +
+Lemma glu_univ_elem_exp_conv : forall {i j k a a' P P' El El' Γ A M m},
+    {{ Dom a a' per_univ k }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a' glu_univ_elem j P' El' }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Γ A ® P' }} ->
+    {{ Γ M : A ® m El' }}.
+Proof.
+  intros * [] ? ? ? ?.
+  assert {{ Dom a a' per_univ (max i k) }} as Haa' by (eexists; mauto using per_univ_elem_cumu_max_right).
+  assert (exists P El, {{ DG a glu_univ_elem (max i k) P El }}) as [Pik [Elik]] by mauto using glu_univ_elem_cumu_max_left.
+  assert {{ DG a' glu_univ_elem (max i k) Pik Elik }} by (setoid_rewrite <- Haa'; eassumption).
+  assert {{ Γ M : A ® m Elik }} by (eapply glu_univ_elem_exp_cumu_max_left; [| | eassumption]; eassumption).
+  assert (exists P El, {{ DG a' glu_univ_elem (max j (max i k)) P El }}) as [Ptop [Eltop]] by mauto using glu_univ_elem_cumu_max_right.
+  assert {{ Γ M : A ® m Eltop }} by (eapply glu_univ_elem_exp_cumu_max_right; [| | eassumption]; eassumption).
+  eapply glu_univ_elem_exp_lower_max_left; mauto.
+Qed.
+ +
+Lemma glu_univ_elem_per_subtyp_typ_escape : forall {i a a' P P' El El' Γ A A'},
+    {{ Sub a <: a' at i }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a' glu_univ_elem i P' El' }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ A' ® P' }} ->
+    {{ Γ A A' }}.
+Proof.
+  intros * Hsubtyp Hglu Hglu' HA HA'.
+  gen A' A Γ. gen El' El P' P.
+  induction Hsubtyp using per_subtyp_ind; intros; subst;
+    saturate_refl_for per_univ_elem;
+    try solve [simpl in *; bulky_rewrite; mauto 3];
+    invert_glu_univ_elem Hglu;
+    handle_functional_glu_univ_elem;
+    handle_per_univ_elem_irrel;
+    destruct_by_head pi_glu_typ_pred;
+    saturate_glu_by_per;
+    invert_glu_univ_elem Hglu';
+    handle_functional_glu_univ_elem.
+  - bulky_rewrite.
+    mauto 3.
+  - destruct_by_head pi_glu_typ_pred.
+    rename x into IP. rename x0 into IEl. rename x1 into OP. rename x2 into OEl.
+    rename A0 into A'. rename IT0 into IT'. rename OT0 into OT'.
+    rename x3 into OP'. rename x4 into OEl'.
+    assert {{ Γ IT ® IP }}.
+    {
+      assert {{ Γ IT[Id] ® IP }} by mauto 4.
+      simpl in *.
+      autorewrite with mctt in *; mauto 3.
+    }
+    assert {{ Γ IT' ® IP }}.
+    {
+      assert {{ Γ IT'[Id] ® IP }} by mauto 4.
+      simpl in *.
+      autorewrite with mctt in *; mauto 3.
+    }
+    do 2 bulky_rewrite1.
+    assert {{ Γ IT IT' : Type@i }} by mauto 4.
+    enough {{ Γ, IT' OT OT' }} by mauto 3.
+    assert {{ Dom ⇑! a (length Γ) ⇑! a' (length Γ) in_rel }} as equiv_len_len' by (eapply per_bot_then_per_elem; mauto 4).
+    assert {{ Dom ⇑! a (length Γ) ⇑! a (length Γ) in_rel }} as equiv_len_len by (eapply per_bot_then_per_elem; mauto 4).
+    assert {{ Dom ⇑! a' (length Γ) ⇑! a' (length Γ) in_rel }} as equiv_len'_len' by (eapply per_bot_then_per_elem; mauto 4).
+    handle_per_univ_elem_irrel.
+    match_by_head per_univ_elem ltac:(fun H => directed invert_per_univ_elem H).
+    apply_relation_equivalence.
+    destruct_rel_mod_eval.
+    handle_per_univ_elem_irrel.
+    match goal with
+    | _: {{ B ρ ⇑! a (length Γ) ^?a0 }},
+        _: {{ B' ρ' ⇑! a' (length Γ) ^?a0' }} |- _ =>
+        rename a0 into b;
+        rename a0' into b'
+    end.
+    assert {{ DG b glu_univ_elem i OP d{{{ ⇑! a (length Γ) }}} equiv_len_len OEl d{{{ ⇑! a (length Γ) }}} equiv_len_len }} by mauto 4.
+    assert {{ DG b' glu_univ_elem i OP' d{{{ ⇑! a' (length Γ) }}} equiv_len'_len' OEl' d{{{ ⇑! a' (length Γ) }}} equiv_len'_len' }} by mauto 4.
+    assert {{ Γ, IT' OT ® OP d{{{ ⇑! a (length Γ) }}} equiv_len_len }}.
+    {
+      assert {{ Γ, IT #0 : IT[Wk] ® ⇑! a (length Γ) IEl }} by (eapply var0_glu_elem; mauto 3).
+      assert {{ Γ, IT' Γ, IT }} as -> by mauto.
+      assert {{ Γ, IT OT[Wk,,#0] OT : Type@i }} as <- by (bulky_rewrite1; mauto 2).
+      mauto 4.
+    }
+    assert {{ Γ, IT' OT' ® OP' d{{{ ⇑! a' (length Γ) }}} equiv_len'_len' }}.
+    {
+      assert {{ Γ, IT' #0 : IT'[Wk] ® ⇑! a' (length Γ) IEl }} by (eapply var0_glu_elem; mauto 3).
+      assert {{ Γ, IT' OT'[Wk,,#0] ® OP' d{{{ ⇑! a' (length Γ) }}} equiv_len'_len' }} by mauto 4.
+      assert {{ Γ, IT' OT'[Wk,,#0] OT' : Type@i }} as <- by (bulky_rewrite1; mauto 2).
+      mauto 4.
+    }
+    mauto 3.
+  - match_by_head (per_bot b b') ltac:(fun H => specialize (H (length Γ)) as [V []]).
+    simpl in *.
+    destruct_conjs.
+    assert {{ Γ A[Id] A : Type@i }} as <- by mauto 4.
+    assert {{ Γ A'[Id] A' : Type@i }} as <- by mauto 3.
+    assert {{ Γ A'[Id] V : Type@i }} as -> by mauto 4.
+    eapply wf_subtyp_refl'.
+    mauto 4.
+Qed.
+ +
+#[export]
+Hint Resolve glu_univ_elem_per_subtyp_typ_escape : mctt.
+ +
+Lemma glu_univ_elem_per_subtyp_trm_if : forall {i a a' P P' El El' Γ A A' M m},
+    {{ Sub a <: a' at i }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ DG a' glu_univ_elem i P' El' }} ->
+    {{ Γ A' ® P' }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Γ M : A' ® m El' }}.
+Proof.
+  intros * Hsubtyp Hglu Hglu' HA HA'.
+  assert {{ Γ A A' }} by (eapply glu_univ_elem_per_subtyp_typ_escape; only 4: eapply glu_univ_elem_trm_typ; mauto).
+  gen m M A' A. gen Γ. gen El' El P' P.
+  induction Hsubtyp using per_subtyp_ind; intros; subst;
+    saturate_refl_for per_univ_elem.
+  1-3,5:
+    invert_glu_univ_elem Hglu;
+  handle_functional_glu_univ_elem;
+  handle_per_univ_elem_irrel;
+  repeat invert_glu_rel1;
+  saturate_glu_by_per;
+  invert_glu_univ_elem Hglu';
+  handle_functional_glu_univ_elem;
+  repeat invert_glu_rel1;
+  try solve [simpl in *; intuition mauto 3].
+  - simpl in *.
+    destruct_conjs.
+    intuition mauto 3.
+    assert (exists P El, {{ DG m glu_univ_elem j P El }}) as [? [?]] by mauto 3.
+    do 2 eexists; split; mauto 3.
+    eapply glu_univ_elem_typ_cumu_ge; revgoals; mautosolve 3.
+  - rename A0 into A'.
+    rename IT0 into IT'. rename OT0 into OT'.
+    rename x into IP. rename x0 into IEl.
+    rename x1 into OP. rename x2 into OEl.
+    rename x3 into OP'. rename x4 into OEl'.
+    handle_per_univ_elem_irrel.
+    econstructor; mauto 3.
+    + enough {{ Sub Π a ρ B <: Π a' ρ' B' at i }} by (eapply per_elem_subtyping; try eassumption).
+      econstructor; mauto 3.
+    + intros.
+      assert {{ Γ w Id : Γ }} by mauto 3.
+      assert {{ Γ IT ® IP }}.
+      {
+        assert {{ Γ IT[Id] ® IP }} by mauto 3.
+        simpl in *.
+        autorewrite with mctt in *; mauto 3.
+      }
+      assert {{ Γ IT' ® IP }}.
+      {
+        assert {{ Γ IT'[Id] ® IP }} by mauto 3.
+        simpl in *.
+        autorewrite with mctt in *; mauto 3.
+      }
+      assert {{ Δ IT'[σ] IT[σ] : Type@i }} by (symmetry; mauto 4 using glu_univ_elem_per_univ_typ_escape).
+      assert {{ Δ N : IT'[σ] ® n IEl }} by (simpl; bulky_rewrite1; eassumption).
+      assert (exists mn : domain, {{ $| m & n |↘ mn }} /\ {{Δ M[σ] N : OT'[σ,,N] ® mn OEl n equiv_n }}) by mauto 3.
+      destruct_conjs.
+      eexists; split; mauto 3.
+      match_by_head per_univ_elem ltac:(fun H => directed invert_per_univ_elem H).
+      destruct_rel_mod_eval.
+      handle_per_univ_elem_irrel.
+      match goal with
+      | _: {{ B ρ n ^?a }},
+          _: {{ B' ρ' n ^?a' }} |- _ =>
+          rename a into b;
+          rename a' into b'
+      end.
+      assert {{ DG b glu_univ_elem i OP n equiv_n OEl n equiv_n }} by mauto 3.
+      assert {{ DG b' glu_univ_elem i OP' n equiv_n OEl' n equiv_n }} by mauto 3.
+      assert {{ Δ OT'[σ,,N] ® OP n equiv_n }} by (eapply glu_univ_elem_trm_typ; mauto 3).
+      assert {{ Sub b <: b' at i }} by mauto 3.
+      assert {{ Δ OT'[σ,,N] OT[σ,,N] }} by mauto 3.
+      intuition.
+  - match_by_head1 (per_bot b b') ltac:(fun H => destruct (H (length Γ)) as [V []]).
+    econstructor; mauto 3.
+    + econstructor; mauto 3.
+    + intros.
+      match_by_head1 (per_bot b b') ltac:(fun H => destruct (H (length Δ)) as [? []]).
+      functional_read_rewrite_clear.
+      assert {{ Δ A[σ] A'[σ] }} by mauto 3.
+      assert {{ Δ M[σ] M' : A[σ] }} by mauto 3.
+      mauto 3.
+  - assert {{ Γ A ® P }} by (eapply glu_univ_elem_trm_typ; eauto).
+    assert {{ Γ A A' : Type@i }} by mauto 4.
+    rewrite H in *.
+    rewrite H4 in *.
+    handle_functional_glu_univ_elem.
+    trivial.
+Qed.
+ +
+Lemma glu_univ_elem_per_subtyp_trm_conv : forall {i j k a a' P P' El El' Γ A A' M m},
+    {{ Sub a <: a' at i }} ->
+    {{ DG a glu_univ_elem j P El }} ->
+    {{ DG a' glu_univ_elem k P' El' }} ->
+    {{ Γ A' ® P' }} ->
+    {{ Γ M : A ® m El }} ->
+    {{ Γ M : A' ® m El' }}.
+Proof.
+  intros.
+  assert {{ Sub a <: a' at (max i (max j k)) }} by mauto using per_subtyp_cumu_left.
+  assert (j <= max i (max j k)) by lia.
+  assert (exists P El, {{ DG a glu_univ_elem (max i (max j k)) P El }}) as [Ptop [Eltop]] by mauto using glu_univ_elem_cumu_ge.
+  assert (k <= max i (max j k)) by lia.
+  assert (exists P El, {{ DG a' glu_univ_elem (max i (max j k)) P El }}) as [Ptop' [Eltop']] by mauto using glu_univ_elem_cumu_ge.
+  assert {{ Γ A' ® Ptop' }} by (eapply glu_univ_elem_typ_cumu_ge; mauto).
+  assert {{ Γ M : A ® m Eltop }} by (eapply @glu_univ_elem_exp_cumu_ge with (i := j); mauto).
+  assert {{ Γ M : A' ® m Eltop' }} by (eapply glu_univ_elem_per_subtyp_trm_if; mauto).
+  eapply glu_univ_elem_exp_lower; mauto.
+Qed.
+ +
+
+ + +
+ +
+Lemma mk_glu_rel_typ_with_sub' : forall {i Δ A σ ρ a},
+    {{ A ρ a }} ->
+    (exists P El, {{ DG a glu_univ_elem i P El }}) ->
+    (forall P El, {{ DG a glu_univ_elem i P El }} -> {{ Δ A[σ] ® P }}) ->
+    glu_rel_typ_with_sub i Δ A σ ρ.
+Proof.
+  intros * ? [? []] HEl.
+  econstructor; mauto.
+  eapply HEl; mauto.
+Qed.
+ +
+#[export]
+Hint Resolve mk_glu_rel_typ_with_sub' : mctt.
+ +
+Lemma mk_glu_rel_typ_with_sub'' : forall {i Δ A σ ρ a},
+    {{ A ρ a }} ->
+    {{ Dom a a per_univ i }} ->
+    (forall P El, {{ DG a glu_univ_elem i P El }} -> {{ Δ A[σ] ® P }}) ->
+    glu_rel_typ_with_sub i Δ A σ ρ.
+Proof.
+  intros * ? [] ?.
+  assert (exists P El, {{ DG a glu_univ_elem i P El }}) as [? []] by mauto.
+  eapply mk_glu_rel_typ_with_sub'; mauto.
+Qed.
+ +
+#[export]
+Hint Resolve mk_glu_rel_typ_with_sub'' : mctt.
+ +
+Lemma mk_glu_rel_exp_with_sub' : forall {i Δ A M σ ρ a m},
+    {{ A ρ a }} ->
+    {{ M ρ m }} ->
+    (exists P El, {{ DG a glu_univ_elem i P El }}) ->
+    (forall P El, {{ DG a glu_univ_elem i P El }} -> {{ Δ M[σ] : A[σ] ® m El }}) ->
+    glu_rel_exp_with_sub i Δ M A σ ρ.
+Proof.
+  intros * ? ? [? []] HEl.
+  econstructor; mauto.
+  eapply HEl; mauto.
+Qed.
+ +
+#[export]
+Hint Resolve mk_glu_rel_exp_with_sub' : mctt.
+ +
+Lemma mk_glu_rel_exp_with_sub'' : forall {i Δ A M σ ρ a m},
+    {{ A ρ a }} ->
+    {{ M ρ m }} ->
+    {{ Dom a a per_univ i }} ->
+    (forall P El, {{ DG a glu_univ_elem i P El }} -> {{ Δ M[σ] : A[σ] ® m El }}) ->
+    glu_rel_exp_with_sub i Δ M A σ ρ.
+Proof.
+  intros * ? ? [] ?.
+  assert (exists P El, {{ DG a glu_univ_elem i P El }}) as [? []] by mauto.
+  eapply mk_glu_rel_exp_with_sub'; mauto.
+Qed.
+ +
+#[export]
+Hint Resolve mk_glu_rel_exp_with_sub'' : mctt.
+ +
+Lemma glu_rel_exp_with_sub_implies_glu_rel_exp_sub_with_typ : forall {i Δ A M σ Γ ρ},
+  {{ Δ s σ : Γ }} ->
+  glu_rel_exp_with_sub i Δ M A σ ρ ->
+  glu_rel_exp_with_sub (S i) Δ A {{{ Type@i }}} σ ρ.
+Proof.
+  intros * ? [].
+  econstructor; mauto.
+  assert {{ Δ A[σ] : Type@i }} by mauto using glu_univ_elem_trm_univ_lvl.
+  repeat split; try do 2 eexists; mauto 3.
+  split; mauto 4.
+  eapply glu_univ_elem_trm_typ; mauto 3.
+Qed.
+ +
+#[export]
+Hint Resolve glu_rel_exp_with_sub_implies_glu_rel_exp_sub_with_typ : mctt.
+ +
+Lemma glu_rel_exp_with_sub_implies_glu_rel_typ_with_sub : forall {i Δ A j σ ρ},
+  glu_rel_exp_with_sub i Δ A {{{ Type@j }}} σ ρ ->
+  glu_rel_typ_with_sub j Δ A σ ρ.
+Proof.
+  intros * [].
+  simplify_evals.
+  match_by_head1 glu_univ_elem invert_glu_univ_elem.
+  apply_predicate_equivalence.
+  unfold univ_glu_exp_pred' in *.
+  destruct_conjs.
+  econstructor; mauto 3.
+Qed.
+ +
+#[export]
+Hint Resolve glu_rel_exp_with_sub_implies_glu_rel_typ_with_sub : mctt.
+ +
+Lemma glu_rel_typ_with_sub_implies_glu_rel_exp_with_sub : forall {Δ A j σ Γ ρ},
+  {{ Δ s σ : Γ }} ->
+  glu_rel_typ_with_sub j Δ A σ ρ ->
+  glu_rel_exp_with_sub (S j) Δ A {{{ Type@j }}} σ ρ.
+Proof.
+  intros * ? [].
+  simplify_evals.
+  econstructor; mauto.
+  assert {{ Δ A[σ] : Type@j }} by mauto 4 using glu_univ_elem_univ_lvl.
+  repeat split; try do 2 eexists; mauto 3.
+Qed.
+ +
+#[export]
+Hint Resolve glu_rel_typ_with_sub_implies_glu_rel_exp_with_sub : mctt.
+ +
+
+ +
+

Lemmas for glu_ctx_env

+ +
+
+ +
+Lemma glu_ctx_env_sub_resp_ctx_eq : forall {Γ Sb},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    forall {Δ Δ' σ ρ},
+      {{ Δ s σ ® ρ Sb }} ->
+      {{ Δ Δ' }} ->
+      {{ Δ' s σ ® ρ Sb }}.
+Proof.
+  induction 1; intros * HSb Hctxeq;
+    apply_predicate_equivalence;
+    simpl in *;
+    mauto 4.
+ +
+  destruct_by_head cons_glu_sub_pred.
+  econstructor; mauto 4.
+  rewrite <- Hctxeq; eassumption.
+Qed.
+ +
+Add Parametric Morphism Sb Γ (H : glu_ctx_env Sb Γ) : Sb
+    with signature wf_ctx_eq ==> eq ==> eq ==> iff as glu_ctx_env_sub_morphism_iff1.
+Proof.
+  intros.
+  split; intros; eapply glu_ctx_env_sub_resp_ctx_eq; mauto.
+Qed.
+ +
+Lemma glu_ctx_env_sub_resp_sub_eq : forall {Γ Sb},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    forall {Δ σ σ' ρ},
+      {{ Δ s σ ® ρ Sb }} ->
+      {{ Δ s σ σ' : Γ }} ->
+      {{ Δ s σ' ® ρ Sb }}.
+Proof.
+  induction 1; intros * HSb Hsubeq;
+    apply_predicate_equivalence;
+    simpl in *;
+    gen_presup Hsubeq;
+    try eassumption.
+ +
+  destruct_by_head cons_glu_sub_pred.
+  econstructor; mauto 4.
+  assert {{ Γ, A s Wk : Γ }} by mauto 3.
+  assert {{ Δ A[Wk][σ] A[Wk][σ'] : Type@i }} as <- by mauto 3.
+  assert {{ Δ #0[σ] #0[σ'] : A[Wk][σ] }} as <- by mauto 3.
+  eassumption.
+Qed.
+ +
+Add Parametric Morphism Sb Γ (H : glu_ctx_env Sb Γ) Δ : (Sb Δ)
+    with signature wf_sub_eq Δ Γ ==> eq ==> iff as glu_ctx_env_sub_morphism_iff2.
+Proof.
+  split; intros; eapply glu_ctx_env_sub_resp_sub_eq; mauto.
+Qed.
+ +
+Lemma cons_glu_sub_pred_resp_wf_sub_eq : forall {i Γ A Sb Δ σ σ' ρ},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ Γ A : Type@i }} ->
+    {{ Δ s σ σ' : Γ, A }} ->
+    {{ Δ s σ ® ρ cons_glu_sub_pred i Γ A Sb }} ->
+    {{ Δ s σ' ® ρ cons_glu_sub_pred i Γ A Sb }}.
+Proof.
+  intros * Hglu HA Heq Hσ.
+  dependent destruction Hσ.
+  gen_presup Heq.
+  assert {{ Δ s Wkσ : Γ }} by mauto 3.
+  assert {{ Δ s Wkσ' : Γ }} by mauto 3.
+  assert {{ Δ s Wkσ Wkσ' : Γ }} by mauto 3.
+  econstructor; mauto 3.
+  - assert {{ Δ A[Wk][σ] A[Wk][σ'] : Type@i }} as <- by mauto 4.
+    assert {{ Δ #0[σ] #0[σ'] : A[Wk][σ] }} as <-; mauto 3.
+  - assert {{ Δ s Wkσ Wkσ' : Γ }} as <-; eassumption.
+Qed.
+ +
+Add Parametric Morphism i Γ A Sb Δ (Hglu : {{ EG Γ glu_ctx_env Sb }}) (HA : {{ Γ A : Type@i }}) : (cons_glu_sub_pred i Γ A Sb Δ)
+    with signature wf_sub_eq Δ {{{ Γ, A }}} ==> eq ==> iff as cons_glu_sub_pred_morphism_iff.
+Proof.
+  split; mauto using cons_glu_sub_pred_resp_wf_sub_eq.
+Qed.
+ +
+Lemma glu_ctx_env_per_env : forall {Γ Sb env_rel Δ σ ρ},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ EF Γ Γ per_ctx_env env_rel }} ->
+    {{ Δ s σ ® ρ Sb }} ->
+    {{ Dom ρ ρ env_rel }}.
+Proof.
+  intros * Hglu Hper.
+  gen ρ σ Δ env_rel.
+  induction Hglu; intros;
+    invert_per_ctx_env Hper;
+    apply_predicate_equivalence;
+    handle_per_ctx_env_irrel;
+    mauto 3.
+ +
+  rename i0 into j.
+  inversion_clear_by_head cons_glu_sub_pred.
+  assert {{ Dom ρ ρ tail_rel }} by intuition.
+  destruct_rel_typ.
+  handle_per_univ_elem_irrel.
+  assert (exists P' El', {{ DG a glu_univ_elem (max i j) P' El' }}) as [? []] by mauto 3 using glu_univ_elem_cumu_max_left.
+  eexists; eapply glu_univ_elem_per_elem; mauto using per_univ_elem_cumu_max_right.
+  eapply glu_univ_elem_exp_cumu_max_left; [| | eassumption]; eassumption.
+Qed.
+ +
+Lemma glu_ctx_env_wf_ctx : forall {Γ Sb},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ Γ }}.
+Proof.
+  induction 1; intros; mauto.
+Qed.
+ +
+Lemma glu_ctx_env_sub_escape : forall {Γ Sb},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    forall Δ σ ρ,
+      {{ Δ s σ ® ρ Sb }} ->
+      {{ Δ s σ : Γ }}.
+Proof.
+  induction 1; intros;
+    handle_functional_glu_univ_elem;
+    destruct_by_head cons_glu_sub_pred;
+    eassumption.
+Qed.
+ +
+#[export]
+Hint Resolve glu_ctx_env_wf_ctx glu_ctx_env_sub_escape : mctt.
+ +
+Lemma glu_ctx_env_per_ctx_env : forall {Γ Sb},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    exists env_rel, {{ EF Γ Γ per_ctx_env env_rel }}.
+Proof.
+  intros.
+  enough {{ Γ }} by eassumption.
+  mauto using completeness_fundamental_ctx.
+Qed.
+ +
+#[export]
+Hint Resolve glu_ctx_env_per_ctx_env : mctt.
+ +
+Lemma glu_ctx_env_resp_per_ctx_helper : forall {Γ Γ' Sb Sb'},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ EG Γ' glu_ctx_env Sb' }} ->
+    {{ Γ Γ' }} ->
+    (Sb -∙> Sb').
+Proof.
+  intros * Hglu Hglu' HΓΓ'.
+  gen Sb' Γ'.
+  induction Hglu; intros;
+    destruct (completeness_fundamental_ctx_eq _ _ HΓΓ') as [env_relΓ Hper];
+    apply_predicate_equivalence;
+    handle_per_univ_elem_irrel;
+    dependent destruction Hglu';
+    apply_predicate_equivalence;
+    invert_per_ctx_env Hper;
+    handle_per_ctx_env_irrel;
+    try firstorder.
+ +
+  rename i0 into j.
+  rename Γ0 into Γ'.
+  rename A0 into A'.
+  rename TSb0 into TSb'.
+  rename i1 into k.
+  inversion HΓΓ' as [|? ? l]; subst.
+  assert (TSb -∙> TSb') by intuition.
+  intros Δ σ ρ [].
+  saturate_refl_for per_ctx_env.
+  assert {{ Dom ρ0 ρ0 tail_rel }}
+    by (eapply glu_ctx_env_per_env; [| | eassumption]; eassumption).
+  assert {{ Δ0 s Wkσ0 ® ρ0 TSb' }} by intuition.
+  assert (glu_rel_typ_with_sub j Δ0 A' {{{ Wkσ0 }}} d{{{ ρ0 }}}) as [] by mauto 3.
+  destruct_rel_typ.
+  handle_functional_glu_univ_elem.
+  rename a0 into a'.
+  rename El0 into El'.
+  rename P0 into P'.
+  econstructor; mauto 4.
+  assert (exists Pmax Elmax, {{ DG a glu_univ_elem (max i l) Pmax Elmax }}) as [Pmax [Elmax]]
+ by mauto using glu_univ_elem_cumu_max_left.
+  assert (i <= max i l) by lia.
+  assert {{ Δ0 #0[σ0] : A'[Wk][σ0] ® ^(ρ0 0) Elmax }}.
+  {
+    assert {{ Γ, A s Wk : Γ }} by mauto 3.
+    assert {{ Δ0 A[Wk][σ0] A'[Wk][σ0] : Type@l }} by mauto 3.
+    assert {{ Δ0 A[Wk][σ0] A'[Wk][σ0] : Type@(max i l) }} as <- by mauto 2 using lift_exp_eq_max_right.
+    eapply glu_univ_elem_exp_cumu_ge; mauto 3.
+  }
+  eapply glu_univ_elem_exp_conv; [eexists | | | |]; intuition.
+  autorewrite with mctt.
+  eassumption.
+Qed.
+ +
+Corollary functional_glu_ctx_env : forall {Γ Sb Sb'},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ EG Γ glu_ctx_env Sb' }} ->
+    (Sb <∙> Sb').
+Proof.
+  intros.
+  assert {{ Γ Γ }} by mauto using glu_ctx_env_wf_ctx.
+  split; eapply glu_ctx_env_resp_per_ctx_helper; eassumption.
+Qed.
+ +
+Ltac apply_functional_glu_ctx_env1 :=
+  let tactic_error o1 o2 := fail 2 "functional_glu_ctx_env biconditional between" o1 "and" o2 "cannot be solved" in
+  match goal with
+  | H1 : {{ EG ^?Γ glu_ctx_env ?Sb1 }},
+      H2 : {{ EG ^?Γ glu_ctx_env ?Sb2 }} |- _ =>
+      assert_fails (unify Sb1 Sb2);
+      match goal with
+      | H : Sb1 <∙> Sb2 |- _ => fail 1
+      | _ => assert (Sb1 <∙> Sb2) by (eapply functional_glu_ctx_env; [apply H1 | apply H2]) || tactic_error Sb1 Sb2
+      end
+  end.
+ +
+Ltac apply_functional_glu_ctx_env :=
+  repeat apply_functional_glu_ctx_env1.
+ +
+Ltac handle_functional_glu_ctx_env :=
+  functional_eval_rewrite_clear;
+  fold glu_typ_pred in *;
+  fold glu_exp_pred in *;
+  apply_functional_glu_ctx_env;
+  apply_predicate_equivalence;
+  clear_dups.
+ +
+Lemma glu_ctx_env_cons_clean_inversion : forall {Γ TSb A Sb},
+  {{ EG Γ glu_ctx_env TSb }} ->
+  {{ EG Γ, A glu_ctx_env Sb }} ->
+  exists i,
+    {{ Γ A : Type@i }} /\
+      (forall Δ σ ρ,
+          {{ Δ s σ ® ρ TSb }} ->
+          glu_rel_typ_with_sub i Δ A σ ρ) /\
+      (Sb <∙> cons_glu_sub_pred i Γ A TSb).
+Proof.
+  intros.
+  simpl in *.
+  match_by_head glu_ctx_env progressive_invert.
+  apply_functional_glu_ctx_env.
+  eexists; intuition.
+  assert (Sb <∙> cons_glu_sub_pred i Γ A TSb0) as -> by eassumption.
+  intros Δ σ ρ.
+  split; intros [];
+    econstructor; intuition.
+Qed.
+ +
+Ltac invert_glu_ctx_env H :=
+  (unshelve eapply (glu_ctx_env_cons_clean_inversion _) in H; shelve_unifiable; [eassumption |];
+   destruct H as [? [? []]])
+  + dependent destruction H.
+ +
+Lemma glu_ctx_env_subtyp_sub_if : forall Γ Γ' Sb Sb' Δ σ ρ,
+    {{ Γ Γ' }} ->
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ EG Γ' glu_ctx_env Sb' }} ->
+    {{ Δ s σ ® ρ Sb }} ->
+    {{ Δ s σ ® ρ Sb' }}.
+Proof.
+  intros * Hsubtyp Hglu Hglu'.
+  gen ρ σ Δ. gen Sb' Sb.
+  induction Hsubtyp; intros;
+    invert_glu_ctx_env Hglu;
+    invert_glu_ctx_env Hglu';
+    handle_functional_glu_ctx_env;
+    eauto.
+ +
+  rename Δ into Γ'.
+  rename i0 into j.
+  rename i1 into k.
+  rename TSb0 into TSb'.
+  destruct_by_head cons_glu_sub_pred.
+  assert (glu_rel_typ_with_sub k Δ A' {{{ Wkσ }}} d{{{ ρ }}}) as [] by intuition.
+  rename a0 into a'.
+  rename P0 into P'.
+  rename El0 into El'.
+  assert (exists tail_rel, {{ EF Γ Γ per_ctx_env tail_rel }}) as [tail_rel] by mauto 3 using glu_ctx_env_per_ctx_env.
+  assert {{ Dom ρ ρ tail_rel }} by (eapply glu_ctx_env_per_env; revgoals; eassumption).
+  assert {{ Γ, A Γ', A' }} by mauto 3.
+  econstructor; mauto; intuition.
+  assert {{ Γ A A' }} as [] by mauto 3 using completeness_fundamental_subtyp.
+  destruct_conjs.
+  handle_per_ctx_env_irrel.
+  (on_all_hyp_rev: destruct_rel_by_assumption tail_rel).
+  destruct_by_head rel_exp.
+  handle_functional_glu_ctx_env.
+  eapply glu_univ_elem_per_subtyp_trm_conv; mauto 3.
+  autorewrite with mctt.
+  eassumption.
+Qed.
+ +
+Lemma glu_ctx_env_sub_monotone : forall Γ Sb,
+    {{ EG Γ glu_ctx_env Sb }} ->
+    forall Δ' σ Δ τ ρ,
+      {{ Δ s τ ® ρ Sb }} ->
+      {{ Δ' w σ : Δ }} ->
+      {{ Δ' s τ σ ® ρ Sb }}.
+Proof.
+  induction 1; intros * HSb Hσ;
+    apply_predicate_equivalence;
+    simpl in *;
+    mauto 3.
+ +
+  destruct_by_head cons_glu_sub_pred.
+  econstructor; mauto 3.
+  - assert {{ Δ' #0[σ0][σ] : A[Wk][σ0][σ] ® ^(ρ 0) El }} by (eapply glu_univ_elem_exp_monotone; mauto 3).
+    assert {{ Γ, A #0 : A[Wk] }} by mauto 3.
+    assert {{ Γ, A s Wk : Γ }} by mauto 3.
+    assert {{ Δ' #0[σ0σ] #0[σ0][σ] : A[Wk][σ0σ] }} as -> by mauto 3.
+    assert {{ Δ' s σ : Δ }} by mauto 3.
+    assert {{ Δ' A[Wk][σ0][σ] A[Wk][σ0σ] : Type@i }} as <- by mauto 3.
+    eassumption.
+  - assert {{ Δ' s σ : Δ }} by mauto 3.
+    assert {{ Γ, A s Wk : Γ }} by mauto 3.
+    assert {{ Δ' s (Wk σ0) σ Wk (σ0 σ) : Γ }} as <- by mauto 3.
+    mauto 3.
+Qed.
+ +
+Lemma cons_glu_sub_pred_helper : forall {Γ Sb Δ σ ρ A a i P El M c},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ Δ s σ ® ρ Sb }} ->
+    {{ Γ A : Type@i }} ->
+    {{ A ρ a }} ->
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ Δ M : A[σ] ® c El }} ->
+    {{ Δ s σ,,M ® ρ c cons_glu_sub_pred i Γ A Sb }}.
+Proof.
+  intros.
+  assert {{ Δ s σ : Γ }} by mauto 2.
+  assert {{ Δ M : A[σ] }} by mauto 2 using glu_univ_elem_trm_escape.
+  assert {{ Δ s σ,,M : Γ, A }} by mauto 2.
+  econstructor; mauto 3;
+    autorewrite with mctt; mauto 3.
+ +
+  assert {{ Δ #0[σ,,M] M : A[σ] }} as ->; mauto 2.
+Qed.
+ +
+#[export]
+Hint Resolve cons_glu_sub_pred_helper : mctt.
+ +
+Lemma initial_env_glu_rel_exp : forall {Γ ρ Sb},
+    initial_env Γ ρ ->
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ Γ s Id ® ρ Sb }}.
+Proof.
+  intros * Hinit .
+  gen ρ.
+  induction ; intros * Hinit;
+    dependent destruction Hinit;
+    apply_predicate_equivalence;
+    try solve [econstructor; mauto].
+ +
+  assert (glu_rel_typ_with_sub i Γ A {{{ Id }}} ρ) as [] by mauto.
+  functional_eval_rewrite_clear.
+  econstructor; mauto.
+  - match goal with
+    | H: P Γ {{{ A[Id] }}} |- _ =>
+        bulky_rewrite_in H
+    end.
+    eapply realize_glu_elem_bot; mauto.
+    assert {{ Γ }} by mauto 3.
+    assert {{ Γ, A s Wk : Γ }} by mauto 4.
+    assert {{ Γ, A A[Wk] : Type@i }} by mauto 4.
+    assert {{ Γ, A A[Wk] A[Wk][Id] : Type@i }} as <- by mauto 3.
+    assert {{ Γ, A #0 #0[Id] : A[Wk] }} as <- by mauto.
+    eapply var_glu_elem_bot; mauto.
+  - assert {{ Γ, A s Wk : Γ }} by mauto 4.
+    assert {{ Γ, A s WkId : Γ }} by mauto 4.
+    assert {{ Γ, A s IdWk WkId : Γ }} as <- by (transitivity {{{ Wk }}}; mauto 3).
+    eapply glu_ctx_env_sub_monotone; mauto 4.
+Qed.
+ +
+
+ +
+

Tactics for glu_rel_*

+ +
+
+ +
+Ltac destruct_glu_rel_by_assumption sub_glu_rel H :=
+  repeat
+    match goal with
+    | H' : {{ ^?Δ s ^® ^ ?sub_glu_rel0 }} |- _ =>
+        unify sub_glu_rel0 sub_glu_rel;
+        destruct (H _ _ _ H') as [];
+        destruct_conjs;
+        mark_with H' 1
+    end;
+  unmark_all_with 1.
+Ltac destruct_glu_rel_exp_with_sub :=
+  repeat
+    match goal with
+    | H : (forall Δ σ ρ, {{ Δ s σ ® ρ ?sub_glu_rel }} -> glu_rel_exp_with_sub _ _ _ _ _ _) |- _ =>
+        destruct_glu_rel_by_assumption sub_glu_rel H; mark H
+    | H : glu_rel_exp_with_sub _ _ _ _ _ _ |- _ =>
+        dependent destruction H
+    end;
+  unmark_all.
+Ltac destruct_glu_rel_sub_with_sub :=
+  repeat
+    match goal with
+    | H : (forall Δ σ ρ, {{ Δ s σ ® ρ ?sub_glu_rel }} -> glu_rel_sub_with_sub _ _ _ _ _) |- _ =>
+        destruct_glu_rel_by_assumption sub_glu_rel H; mark H
+    | H : glu_rel_exp_with_sub _ _ _ _ _ _ |- _ =>
+        dependent destruction H
+    end;
+  unmark_all.
+Ltac destruct_glu_rel_typ_with_sub :=
+  repeat
+    match goal with
+    | H : (forall Δ σ ρ, {{ Δ s σ ® ρ ?sub_glu_rel }} -> glu_rel_typ_with_sub _ _ _ _ _) |- _ =>
+        destruct_glu_rel_by_assumption sub_glu_rel H; mark H
+    | H : glu_rel_exp_with_sub _ _ _ _ _ _ |- _ =>
+        dependent destruction H
+    end;
+  unmark_all.
+ +
+
+ +
+

Lemmas about glu_rel_exp

+ +
+
+ +
+Lemma glu_rel_exp_clean_inversion1 : forall {Γ Sb M A},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ Γ M : A }} ->
+    exists i,
+    forall Δ σ ρ,
+      {{ Δ s σ ® ρ Sb }} ->
+      glu_rel_exp_with_sub i Δ M A σ ρ.
+Proof.
+  intros * ? [].
+  destruct_conjs.
+  eexists; intros.
+  handle_functional_glu_ctx_env.
+  mauto.
+Qed.
+ +
+Definition glu_rel_exp_clean_inversion2_result i Sb M A :=
+  forall Δ σ ρ,
+    {{ Δ s σ ® ρ Sb }} ->
+    glu_rel_exp_with_sub i Δ M A σ ρ.
+ +
+Lemma glu_rel_exp_clean_inversion2 : forall {i Γ Sb M A},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ Γ A : Type@i }} ->
+    {{ Γ M : A }} ->
+    glu_rel_exp_clean_inversion2_result i Sb M A.
+Proof.
+  unfold glu_rel_exp_clean_inversion2_result.
+  intros * ? HA HM.
+  eapply glu_rel_exp_clean_inversion1 in HA; [| eassumption].
+  eapply glu_rel_exp_clean_inversion1 in HM; [| eassumption].
+  destruct_conjs.
+  intros.
+  destruct_glu_rel_exp_with_sub.
+  simplify_evals.
+  match_by_head glu_univ_elem ltac:(fun H => directed invert_glu_univ_elem H).
+  apply_predicate_equivalence.
+  unfold univ_glu_exp_pred' in *.
+  destruct_conjs.
+  econstructor; mauto 3.
+  eapply glu_univ_elem_exp_conv; revgoals; mauto 3.
+Qed.
+ +
+Ltac invert_glu_rel_exp H :=
+  (unshelve eapply (glu_rel_exp_clean_inversion2 _ _) in H; shelve_unifiable; [eassumption | eassumption |];
+   unfold glu_rel_exp_clean_inversion2_result in H)
+  + (unshelve eapply (glu_rel_exp_clean_inversion1 _) in H; shelve_unifiable; [eassumption |];
+     destruct H as [])
+  + (inversion H; subst).
+ +
+Lemma glu_rel_exp_to_wf_exp : forall {Γ A M},
+    {{ Γ M : A }} ->
+    {{ Γ M : A }}.
+Proof.
+  intros * [Sb].
+  destruct_conjs.
+  assert (exists env_rel, {{ EF Γ Γ per_ctx_env env_rel }}) as [env_rel] by mauto 3.
+  assert (exists ρ ρ', initial_env Γ ρ /\ initial_env Γ ρ' /\ {{ Dom ρ ρ' env_rel }}) as [ρ] by mauto using per_ctx_then_per_env_initial_env.
+  destruct_conjs.
+  functional_initial_env_rewrite_clear.
+  assert {{ Γ s Id ® ρ Sb }} by (eapply initial_env_glu_rel_exp; mauto 3).
+  destruct_glu_rel_exp_with_sub.
+  enough {{ Γ M[Id] : A[Id] }} as HId; mauto 3 using glu_univ_elem_trm_escape.
+Qed.
+ +
+#[export]
+Hint Resolve glu_rel_exp_to_wf_exp : mctt.
+ +
+
+ +
+

Lemmas about glu_rel_sub

+ +
+
+ +
+Lemma glu_rel_sub_clean_inversion1 : forall {Γ Sb τ Γ'},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ Γ s τ : Γ' }} ->
+    exists Sb' : glu_sub_pred,
+      glu_ctx_env Sb' Γ' /\ (forall (Δ : ctx) (σ : sub) (ρ : env), Sb Δ σ ρ -> glu_rel_sub_with_sub Δ τ Sb' σ ρ).
+Proof.
+  intros * ? [? []].
+  destruct_conjs.
+  handle_functional_glu_ctx_env.
+  eexists; split; mauto 3.
+  intros.
+  rewrite_predicate_equivalence_right.
+  mauto 3.
+Qed.
+ +
+Lemma glu_rel_sub_clean_inversion2 : forall {Γ τ Γ' Sb'},
+    {{ EG Γ' glu_ctx_env Sb' }} ->
+    {{ Γ s τ : Γ' }} ->
+    exists Sb : glu_sub_pred,
+      glu_ctx_env Sb Γ /\ (forall (Δ : ctx) (σ : sub) (ρ : env), Sb Δ σ ρ -> glu_rel_sub_with_sub Δ τ Sb' σ ρ).
+Proof.
+  intros * ? [? [Sb'0]].
+  destruct_conjs.
+  handle_functional_glu_ctx_env.
+  eexists; split; mauto 3.
+  intros.
+  assert (glu_rel_sub_with_sub Δ τ Sb'0 σ ρ) as [] by mauto 3.
+  econstructor; mauto 3.
+  rewrite_predicate_equivalence_right.
+  mauto 3.
+Qed.
+ +
+Lemma glu_rel_sub_clean_inversion3 : forall {Γ Sb τ Γ' Sb'},
+    {{ EG Γ glu_ctx_env Sb }} ->
+    {{ EG Γ' glu_ctx_env Sb' }} ->
+    {{ Γ s τ : Γ' }} ->
+    forall (Δ : ctx) (σ : sub) (ρ : env), Sb Δ σ ρ -> glu_rel_sub_with_sub Δ τ Sb' σ ρ.
+Proof.
+  intros * ? ? Hglu.
+  eapply glu_rel_sub_clean_inversion2 in Hglu; [| eassumption].
+  destruct_conjs.
+  handle_functional_glu_ctx_env.
+  intros.
+  rewrite_predicate_equivalence_right.
+  mauto 3.
+Qed.
+ +
+Ltac invert_glu_rel_sub H :=
+  (unshelve eapply (glu_rel_sub_clean_inversion3 _ _) in H; shelve_unifiable; [eassumption | eassumption |])
+  + (unshelve eapply (glu_rel_sub_clean_inversion2 _) in H; shelve_unifiable; [eassumption |];
+     destruct H as [? []])
+  + (unshelve eapply (glu_rel_sub_clean_inversion1 _) in H; shelve_unifiable; [eassumption |];
+     destruct H as [? []])
+  + (inversion H; subst).
+ +
+Lemma glu_rel_sub_wf_sub : forall {Γ σ Δ},
+    {{ Γ s σ : Δ }} ->
+    {{ Γ s σ : Δ }}.
+Proof.
+  intros * [SbΓ [SbΔ]].
+  destruct_conjs.
+  assert (exists env_relΓ, {{ EF Γ Γ per_ctx_env env_relΓ }}) as [env_relΓ] by mauto 3.
+  assert (exists ρ ρ', initial_env Γ ρ /\ initial_env Γ ρ' /\ {{ Dom ρ ρ' env_relΓ }}) as [ρ] by mauto 3 using per_ctx_then_per_env_initial_env.
+  destruct_conjs.
+  functional_initial_env_rewrite_clear.
+  assert {{ Γ s Id ® ρ SbΓ }} by (eapply initial_env_glu_rel_exp; mauto 3).
+  destruct_glu_rel_sub_with_sub.
+  mauto 3.
+Qed.
+ +
+#[export]
+Hint Resolve glu_rel_sub_wf_sub : mctt.
+
+
+ +
+ + + diff --git a/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.html b/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.html new file mode 100644 index 0000000..ee5c601 --- /dev/null +++ b/ext/prop-eq/Mctt.Core.Soundness.LogicalRelation.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + +
+
+

Mctt.Core.Soundness.LogicalRelation

+ +
+From Mctt.Core.Soundness.LogicalRelation Require Export Core Lemmas.
+
+
+ +
+ + + diff --git a/ext/prop-eq/Mctt.Core.Soundness.Realizability.html b/ext/prop-eq/Mctt.Core.Soundness.Realizability.html new file mode 100644 index 0000000..20b1a43 --- /dev/null +++ b/ext/prop-eq/Mctt.Core.Soundness.Realizability.html @@ -0,0 +1,496 @@ + + + + + + + + + + + + + +
+
+

Mctt.Core.Soundness.Realizability

+ +
+From Coq Require Import Nat.
+ +
+From Mctt Require Import LibTactics.
+From Mctt.Core Require Import Base.
+From Mctt.Core.Semantic Require Import Realizability.
+From Mctt.Core.Soundness.LogicalRelation Require Export Core.
+Import Domain_Notations.
+ +
+Open Scope list_scope.
+ +
+Lemma wf_ctx_sub_ctx_lookup : forall n A Γ,
+    {{ #n : A Γ }} ->
+    forall Δ,
+      {{ Δ Γ}} ->
+      exists Δ1 A0 Δ2 A',
+        Δ = Δ1 ++ A0 :: Δ2 /\
+          n = length Δ1 /\
+          A' = iter (S n) (fun A => {{{ A[Wk] }}}) A0 /\
+          {{ #n : A' Δ }} /\
+          {{ Δ A' A }}.
+Proof.
+  induction 1; intros; progressive_inversion.
+  - exists nil.
+    repeat eexists; mauto 4.
+  - edestruct IHctx_lookup as [Δ1 [? [? [? [? [? [? []]]]]]]]; eauto 3.
+    exists (A0 :: Δ1). subst.
+    repeat eexists; mauto 4.
+Qed.
+ +
+Lemma var_arith : forall Γ1 Γ2 (A : typ),
+    length (Γ1 ++ A :: Γ2) - length Γ2 - 1 = length Γ1.
+Proof.
+  intros.
+  rewrite List.length_app. simpl.
+  lia.
+Qed.
+ +
+Lemma var_weaken_gen : forall Δ σ Γ,
+    {{ Δ w σ : Γ }} ->
+    forall Γ1 Γ2 A0,
+      Γ = Γ1 ++ A0 :: Γ2 ->
+      {{ Δ #(length Γ1)[σ] #(length Δ - length Γ2 - 1) : ^(iter (S (length Γ1)) (fun A => {{{ A[Wk] }}}) A0)[σ] }}.
+Proof.
+  induction 1; intros; subst; gen_presups.
+  - pose proof (app_ctx_vlookup _ _ _ _ ltac:(eassumption) eq_refl) as Hvar.
+    gen_presup Hvar.
+    clear_dups.
+    apply wf_sub_id_inversion in Hτ.
+    pose proof (wf_ctx_sub_length _ _ Hτ).
+    transitivity {{{ #(length Γ1)[Id] }}}; [mauto 3 |].
+    replace (length Γ) with (length (Γ1 ++ {{{ Γ2, A0 }}})) by lia.
+    rewrite var_arith, H.
+    bulky_rewrite.
+  - pose proof (app_ctx_vlookup _ _ _ _ HΔ0 eq_refl) as Hvar.
+    pose proof (app_ctx_lookup Γ1 A0 Γ2 _ eq_refl).
+    gen_presup Hvar.
+    clear_dups.
+    assert {{ Δ', A }} by mauto 3.
+    assert {{ Δ', A s Wk : ^(Γ1 ++ {{{ Γ2, A0 }}}) }} by mauto 3.
+    transitivity {{{ #(length Γ1)[Wkτ] }}}; [mauto 3 |].
+    rewrite H1.
+    etransitivity; [eapply wf_exp_eq_sub_compose; mauto 3 |].
+    pose proof (wf_ctx_sub_length _ _ H0).
+ +
+    rewrite <- @exp_eq_sub_compose_typ; mauto 2.
+    deepexec wf_ctx_sub_ctx_lookup ltac:(fun H => destruct H as [Γ1' [? [Γ2' [? [-> [? [-> []]]]]]]]).
+    repeat rewrite List.length_app in *.
+    replace (length Γ1) with (length Γ1') in * by lia.
+    clear_refl_eqs.
+    replace (length Γ2) with (length Γ2') by (simpl in *; lia).
+ +
+    etransitivity.
+    + eapply wf_exp_eq_sub_cong; [ |mauto 3].
+      eapply wf_exp_eq_subtyp'.
+      * eapply wf_exp_eq_var_weaken; [mauto 3|]; eauto.
+      * mauto 4.
+    + eapply wf_exp_eq_subtyp'.
+      * eapply IHweakening with (Γ1 := A :: _).
+        reflexivity.
+      * eapply wf_subtyp_subst; [ |mauto 3].
+        simpl. eapply wf_subtyp_subst; mauto 3.
+Qed.
+ +
+Lemma var_glu_elem_bot : forall a i P El Γ A,
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ, A #0 : A[Wk] ® !(length Γ) glu_elem_bot i a }}.
+Proof.
+  intros. saturate_glu_info.
+  econstructor; mauto 4.
+  - eapply glu_univ_elem_typ_monotone; eauto.
+    mauto 4.
+  - intros. progressive_inversion.
+    exact (var_weaken_gen _ _ _ H2 nil _ _ eq_refl).
+Qed.
+ +
+#[local]
+Hint Rewrite -> wf_sub_eq_extend_compose using mauto 4 : mctt.
+ +
+Theorem realize_glu_univ_elem_gen : forall a i P El,
+    {{ DG a glu_univ_elem i P El }} ->
+    (forall Γ A R,
+        {{ DF a a per_univ_elem i R }} ->
+        {{ Γ A ® P }} ->
+        {{ Γ A ® glu_typ_top i a }}) /\
+      (forall Γ M A m,
+          
+ +
+We repeat this to get the relation between a and P + more easily after applying induction 1. +
+
+          {{ DG a glu_univ_elem i P El }} ->
+          {{ Γ M : A ® m glu_elem_bot i a }} ->
+          {{ Γ M : A ® a m El }}) /\
+      (forall Γ M A m R,
+          
+ +
+We repeat this to get the relation between a and P + more easily after applying induction 1. +
+
+          {{ DG a glu_univ_elem i P El }} ->
+          {{ Γ M : A ® m El }} ->
+          {{ DF a a per_univ_elem i R }} ->
+          {{ Dom m m R }} ->
+          {{ Γ M : A ® m glu_elem_top i a }}).
+Proof.
+  simpl. induction 1 using glu_univ_elem_ind.
+  all:split; [| split]; intros;
+    apply_equiv_left;
+    gen_presups;
+    try match_by_head1 per_univ_elem ltac:(fun H => pose proof (per_univ_then_per_top_typ H));
+    match_by_head glu_elem_bot ltac:(fun H => destruct H as []);
+    destruct_all.
+  - econstructor; eauto; intros.
+    progressive_inversion.
+    transitivity {{{ Type@j[σ] }}}; mauto 4.
+  - handle_functional_glu_univ_elem.
+    match_by_head glu_univ_elem invert_glu_univ_elem.
+    clear_dups.
+    apply_equiv_left.
+    repeat split; eauto.
+    repeat eexists.
+    + glu_univ_elem_econstructor; eauto; reflexivity.
+    + simpl. repeat split.
+      * rewrite <- H5. trivial.
+      * intros.
+        saturate_weakening_escape.
+        rewrite <- wf_exp_eq_typ_sub; try eassumption.
+        rewrite <- H5.
+        firstorder.
+  - deepexec glu_univ_elem_per_univ ltac:(fun H => pose proof H).
+    firstorder.
+    specialize (H _ _ _ H10) as [? []].
+    econstructor; mauto 3.
+    + apply_equiv_left. trivial.
+    + intros.
+      saturate_weakening_escape.
+      deepexec H ltac:(fun H => destruct H).
+      progressive_invert H16.
+      deepexec H20 ltac:(fun H => pose proof H).
+      functional_read_rewrite_clear.
+      bulky_rewrite.
+ +
+  - econstructor; eauto; intros.
+    progressive_inversion.
+    transitivity {{{ [σ] }}}; mauto 3.
+  - handle_functional_glu_univ_elem.
+    match_by_head glu_univ_elem invert_glu_univ_elem.
+    apply_equiv_left.
+    repeat split; eauto.
+    econstructor; trivial.
+ +
+    intros.
+    saturate_weakening_escape.
+    assert {{ Δ A[σ] [σ] : Type @ i }} by mauto 3.
+    rewrite <- wf_exp_eq_nat_sub; try eassumption.
+    mauto 3.
+  - econstructor; mauto 3.
+    + bulky_rewrite. mauto 3.
+    + apply_equiv_left. trivial.
+    + intros.
+      saturate_weakening_escape.
+      bulky_rewrite.
+      mauto using glu_nat_readback.
+ +
+  - match_by_head pi_glu_typ_pred progressive_invert.
+    handle_per_univ_elem_irrel.
+    invert_per_univ_elem H6.
+    econstructor; eauto; intros.
+    + gen_presups. trivial.
+    + saturate_weakening_escape.
+      assert {{ Γ w Id : Γ }} by mauto 4.
+      assert {{ Δ IT[σ] ® IP }} by mauto 3.
+      assert (IP Γ {{{ IT[Id] }}}) as HITId by mauto 3.
+      bulky_rewrite_in HITId.
+      assert {{ Γ IT[Id] IT : Type@i }} by mauto 3.
+      dir_inversion_clear_by_head read_typ.
+      assert {{ Γ IT ® glu_typ_top i a }} as [] by mauto 3.
+      bulky_rewrite.
+      simpl. apply wf_exp_eq_pi_cong'; [firstorder |].
+      pose proof (var_per_elem (length Δ) H0).
+      destruct_rel_mod_eval.
+      simplify_evals.
+      destruct (H2 _ ltac:(eassumption) _ ltac:(eassumption)) as [? []].
+      assert (IEl {{{ Δ, IT[σ] }}} {{{ IT[σ][Wk] }}} {{{ #0 }}} d{{{ ⇑! a (length Δ) }}}) by mauto 3 using var_glu_elem_bot.
+      autorewrite with mctt in H31.
+      specialize (H14 {{{ Δ, IT[σ] }}} {{{ σWk }}} _ _ ltac:(mauto) ltac:(eassumption) ltac:(eassumption)).
+      specialize (H8 _ _ _ ltac:(eassumption) ltac:(eassumption)) as [].
+      etransitivity; [| eapply H33]; mauto 3.
+  - handle_functional_glu_univ_elem.
+    apply_equiv_left.
+    invert_glu_rel1.
+    econstructor; try eapply per_bot_then_per_elem; eauto.
+ +
+    intros.
+    saturate_weakening_escape.
+    saturate_glu_info.
+    match_by_head1 per_univ_elem invert_per_univ_elem.
+    destruct_rel_mod_eval.
+    simplify_evals.
+    eexists; repeat split; mauto 3.
+    eapply H2; eauto.
+    assert {{ Δ M[σ] : A[σ] }} by mauto 3.
+    bulky_rewrite_in H23.
+    unshelve (econstructor; eauto).
+    + trivial.
+    + eassert {{ Δ M[σ] N : ^_ }} by (eapply wf_app'; eassumption).
+      autorewrite with mctt in H25.
+      trivial.
+    + mauto using domain_app_per.
+    + intros.
+      saturate_weakening_escape.
+      progressive_invert H26.
+      destruct (H15 _ _ _ _ _ ltac:(eassumption) ltac:(eassumption) ltac:(eassumption) equiv_n).
+      handle_functional_glu_univ_elem.
+      autorewrite with mctt.
+ +
+      etransitivity.
+      * rewrite sub_decompose_q_typ; mauto 4.
+      * simpl.
+        rewrite <- @sub_eq_q_sigma_id_extend; mauto 4.
+        rewrite <- @exp_eq_sub_compose_typ; mauto 3;
+          [eapply wf_exp_eq_app_cong' |].
+        -- specialize (H12 _ {{{σ σ0}}} _ ltac:(mauto 3) ltac:(eassumption)).
+           rewrite wf_exp_eq_sub_compose with (M := M) in H12; mauto 3.
+           bulky_rewrite_in H12.
+        -- rewrite <- @exp_eq_sub_compose_typ; mauto 3.
+        -- econstructor; mauto 3.
+           autorewrite with mctt.
+           rewrite <- @exp_eq_sub_compose_typ; mauto 3.
+ +
+  - handle_functional_glu_univ_elem.
+    handle_per_univ_elem_irrel.
+    pose proof H8.
+    invert_per_univ_elem H8.
+    econstructor; mauto 3.
+    + invert_glu_rel1. trivial.
+    + eapply glu_univ_elem_trm_typ; eauto.
+    + intros.
+      saturate_weakening_escape.
+      invert_glu_rel1. clear_dups.
+      progressive_invert H20.
+ +
+      assert {{ Γ w Id : Γ }} by mauto 4.
+      pose proof (H10 _ _ H24).
+      specialize (H10 _ _ H19).
+      assert {{ Γ IT[Id] IT : Type@i }} by mauto 3.
+      bulky_rewrite_in H25.
+      destruct (H11 _ _ _ ltac:(eassumption) ltac:(eassumption)) as [].
+      specialize (H29 _ _ _ H19 H9).
+      rewrite H5 in *.
+      autorewrite with mctt.
+      eassert {{ Δ M[σ] : ^_ }} by (mauto 2).
+      autorewrite with mctt in H30.
+      rewrite @wf_exp_eq_pi_eta' with (M := {{{ M[σ] }}}); [| trivial].
+      cbn [nf_to_exp].
+      eapply wf_exp_eq_fn_cong'; eauto.
+ +
+      pose proof (var_per_elem (length Δ) H0).
+      destruct_rel_mod_eval.
+      simplify_evals.
+      destruct (H2 _ ltac:(eassumption) _ ltac:(eassumption)) as [? []].
+      specialize (H12 _ _ _ _ ltac:(trivial) (var_glu_elem_bot _ _ _ _ _ _ H H10)).
+      autorewrite with mctt in H12.
+      specialize (H14 {{{Δ, IT[σ]}}} {{{σ Wk}}} _ _ ltac:(mauto) ltac:(eassumption) ltac:(eassumption)) as [? []].
+      apply_equiv_left.
+      destruct_rel_mod_app.
+      simplify_evals.
+      deepexec H1 ltac:(fun H => pose proof H).
+      specialize (H33 _ _ _ _ _ ltac:(eassumption) ltac:(eassumption) ltac:(eassumption) ltac:(eassumption)) as [].
+      specialize (H40 _ {{{Id}}} _ ltac:(mauto 3) ltac:(eassumption)).
+      do 2 (rewrite wf_exp_eq_sub_id in H40; mauto 3).
+      etransitivity; [|eassumption].
+      simpl.
+      assert {{ Δ, IT[σ] #0 : IT[σWk] }} by (rewrite <- @exp_eq_sub_compose_typ; mauto 3).
+      rewrite <- @sub_eq_q_sigma_id_extend; mauto 4.
+      rewrite <- @exp_eq_sub_compose_typ; mauto 2.
+      2:eapply sub_q; mauto 4.
+      2:gen_presup H41; econstructor; mauto 3.
+      eapply wf_exp_eq_app_cong'; [| mauto 3].
+      symmetry.
+      rewrite <- wf_exp_eq_pi_sub; mauto 4.
+ +
+  - match_by_head eq_glu_typ_pred progressive_invert.
+    econstructor; eauto; intros.
+    + gen_presups; trivial.
+    + saturate_weakening_escape.
+      assert {{ Γ w Id : Γ }} by mauto 4.
+      assert (P Γ {{{ B[Id] }}}) as HB by mauto 3.
+      bulky_rewrite_in HB.
+      assert (El Γ {{{ B[Id] }}} {{{ M[Id] }}} m) as HM by mauto 3.
+      bulky_rewrite_in HM.
+      assert (El Γ {{{ B[Id] }}} {{{ N[Id] }}} n) as HN by mauto 3.
+      bulky_rewrite_in HN.
+      dir_inversion_clear_by_head read_typ.
+      assert {{ Γ B ® glu_typ_top i a }} as [] by mauto 3.
+      assert {{ Γ M : B ® m glu_elem_top i a }} as [] by mauto 3.
+      assert {{ Γ N : B ® n glu_elem_top i a }} as [] by mauto 3.
+      bulky_rewrite.
+      simpl.
+      eapply wf_exp_eq_eq_cong; firstorder.
+ +
+  - handle_functional_glu_univ_elem.
+    invert_glu_rel1.
+    mauto.
+ +
+  - handle_functional_glu_univ_elem.
+    invert_glu_rel1.
+    econstructor; intros; mauto 3.
+ +
+    saturate_weakening_escape.
+    destruct_glu_eq;
+      dir_inversion_clear_by_head read_nf.
+    + pose proof (PER_refl1 _ _ _ _ _ H25).
+      gen_presups.
+      assert {{ Γ w Id : Γ }} by mauto 4.
+      assert (P Γ {{{ B[Id] }}}) as HB by mauto 3.
+      bulky_rewrite_in HB.
+      assert (El Γ {{{ B[Id] }}} {{{ M''[Id] }}} m') as HM'' by mauto 3.
+      bulky_rewrite_in HM''.
+      assert {{ Γ B ® glu_typ_top i a }} as [] by mauto 3.
+      assert {{ Γ N : B ® m' glu_elem_top i a }} as [] by mauto 3.
+      assert {{ Γ Eq B M N Eq B N N : Type@i }} by (eapply wf_exp_eq_eq_cong; mauto 3).
+      assert {{ Γ Eq B M'' M'' Eq B N N : Type@i }} by (eapply wf_exp_eq_eq_cong; mauto 3).
+      assert {{ Γ A Eq B N N : Type@i }} by mauto 3.
+      assert {{ Γ refl B M'' refl B N : Eq B M'' M'' }} by mauto 3.
+      assert {{ Γ refl B M'' refl B N : Eq B N N }} by mauto 3.
+      assert {{ Γ M' refl B N : A }} by mauto 4.
+      simpl.
+ +
+      transitivity {{{ (refl B N)[σ] }}}; [mauto 3 |].
+      bulky_rewrite.
+      transitivity {{{ refl (B[σ]) (N[σ]) }}};
+        [ eapply wf_exp_eq_conv'; [econstructor |]; mauto 3 |].
+      econstructor; mauto 3.
+    + firstorder.
+ +
+  - econstructor; eauto.
+    intros.
+    progressive_inversion.
+    firstorder.
+  - handle_functional_glu_univ_elem.
+    apply_equiv_left.
+    econstructor; eauto.
+  - handle_functional_glu_univ_elem.
+    invert_glu_rel1.
+    econstructor; eauto.
+    + intros s. destruct (H3 s) as [? []].
+      mauto.
+    + intros.
+      progressive_inversion.
+      specialize (H11 (length Δ)) as [? []].
+      firstorder.
+Qed.
+ +
+Corollary realize_glu_typ_top : forall a i P El,
+    {{ DG a glu_univ_elem i P El }} ->
+    forall Γ A,
+      {{ Γ A ® P }} ->
+      {{ Γ A ® glu_typ_top i a }}.
+Proof.
+  intros.
+  pose proof H.
+  eapply glu_univ_elem_per_univ in H.
+  simpl in *. destruct_all.
+  eapply realize_glu_univ_elem_gen; eauto.
+Qed.
+ +
+Theorem realize_glu_elem_bot : forall a i P El,
+    {{ DG a glu_univ_elem i P El }} ->
+    forall Γ A M m,
+      {{ Γ M : A ® m glu_elem_bot i a }} ->
+      {{ Γ M : A ® a m El }}.
+Proof.
+  intros.
+  eapply realize_glu_univ_elem_gen; eauto.
+Qed.
+ +
+Theorem realize_glu_elem_top : forall a i P El,
+    {{ DG a glu_univ_elem i P El }} ->
+    forall Γ A M m,
+      {{ Γ M : A ® m El }} ->
+      {{ Γ M : A ® m glu_elem_top i a }}.
+Proof.
+  intros.
+  pose proof H.
+  eapply glu_univ_elem_per_univ in H.
+  simpl in *. destruct_all.
+  eapply realize_glu_univ_elem_gen; eauto.
+  eapply glu_univ_elem_per_elem; eauto.
+Qed.
+ +
+#[export]
+Hint Resolve realize_glu_typ_top realize_glu_elem_top : mctt.
+ +
+Corollary var0_glu_elem : forall {i a P El Γ A},
+    {{ DG a glu_univ_elem i P El }} ->
+    {{ Γ A ® P }} ->
+    {{ Γ, A #0 : A[Wk] ® ⇑! a (length Γ) El }}.
+Proof.
+  intros.
+  eapply realize_glu_elem_bot; mauto 4.
+  eauto using var_glu_elem_bot.
+Qed.
+
+
+ +
+ + + diff --git a/ext/prop-eq/Mctt.Core.Syntactic.Syntax.html b/ext/prop-eq/Mctt.Core.Syntactic.Syntax.html index e13b4e3..0dabada 100644 --- a/ext/prop-eq/Mctt.Core.Syntactic.Syntax.html +++ b/ext/prop-eq/Mctt.Core.Syntactic.Syntax.html @@ -37,7 +37,7 @@

Mctt.Core.Syntactic.Syntax

-

Concrete Syntax Tree

+

Concrete Syntax Tree

@@ -79,7 +79,7 @@

Mctt.Core.Syntactic.Syntax

-

Abstract Syntac Tree

+

Abstract Syntac Tree

@@ -172,7 +172,7 @@

Mctt.Core.Syntactic.Syntax

-

Syntactic Normal/Neutral Form

+

Syntactic Normal/Neutral Form

@@ -249,7 +249,7 @@

Mctt.Core.Syntactic.Syntax

-

Syntactic Notations

+

Syntactic Notations

diff --git a/ext/prop-eq/Mctt.Core.Syntactic.System.Lemmas.html b/ext/prop-eq/Mctt.Core.Syntactic.System.Lemmas.html index 3ec2190..e00c0a2 100644 --- a/ext/prop-eq/Mctt.Core.Syntactic.System.Lemmas.html +++ b/ext/prop-eq/Mctt.Core.Syntactic.System.Lemmas.html @@ -37,7 +37,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Basic Context Properties

+

Basic Context Properties

@@ -94,11 +94,11 @@

Mctt.Core.Syntactic.System.Lemmas

-

Core Presuppositions

+

Core Presuppositions

-

Context Presuppositions

+

Context Presuppositions

@@ -209,7 +209,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Immediate Results of Context Presuppositions

+

Immediate Results of Context Presuppositions

@@ -389,7 +389,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Additional Lemmas for Syntactic PERs

+

Additional Lemmas for Syntactic PERs

@@ -445,7 +445,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Lemmas for exp of {{{ Type@i }}}

+

Lemmas for exp of {{{ Type@i }}}

@@ -772,7 +772,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Lemmas for exp of {{{ }}}

+

Lemmas for exp of {{{ }}}

@@ -1087,7 +1087,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Other Tedious Lemmas

+

Other Tedious Lemmas

@@ -1501,7 +1501,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Lemmas for wf_subtyp

+

Lemmas for wf_subtyp

@@ -1717,7 +1717,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Type Presuppositions

+

Type Presuppositions

@@ -1772,7 +1772,7 @@

Mctt.Core.Syntactic.System.Lemmas

-

Consistency Helper

+

Consistency Helper

diff --git a/ext/prop-eq/Mctt.LibTactics.html b/ext/prop-eq/Mctt.LibTactics.html index 35b8d24..e810b9e 100644 --- a/ext/prop-eq/Mctt.LibTactics.html +++ b/ext/prop-eq/Mctt.LibTactics.html @@ -51,7 +51,7 @@

Mctt.LibTactics

-

Generalization of Variables

+

Generalization of Variables

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

Mctt.LibTactics

-

Marking-based Tactics

+

Marking-based Tactics

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

Mctt.LibTactics

-

Simple helper

+

Simple helper

@@ -283,7 +283,7 @@

Mctt.LibTactics

-

McTT automation

+

McTT automation

@@ -557,7 +557,7 @@

Mctt.LibTactics

-

Helper Instances for Generalized Rewriting

+

Helper Instances for Generalized Rewriting

diff --git a/ext/prop-eq/dep.html b/ext/prop-eq/dep.html index 9d4c3fc..3d84f2c 100644 --- a/ext/prop-eq/dep.html +++ b/ext/prop-eq/dep.html @@ -27,112 +27,112 @@
- - + + - -Mctt + +Mctt Core - -Core + +Core Core/Completeness - -Completeness + +Completeness Core/Completeness/Consequences - -Consequences + +Consequences Core/Completeness/LogicalRelation - -LogicalRelation + +LogicalRelation Core/Semantic - -Semantic + +Semantic Core/Semantic/Evaluation - -Evaluation + +Evaluation Core/Semantic/PER - -PER + +PER Core/Semantic/Readback - -Readback + +Readback Core/Soundness - -Soundness + +Soundness Core/Soundness/LogicalRelation - -LogicalRelation + +LogicalRelation Core/Soundness/Weakening - -Weakening + +Weakening Core/Syntactic - -Syntactic + +Syntactic Core/Syntactic/System - -System + +System @@ -140,10 +140,10 @@ Mctt.Core.Completeness.Consequences.Rules - - - -Rules + + + +Rules @@ -151,10 +151,10 @@ Mctt.Core.Completeness.Consequences.Types - - - -Types + + + +Types @@ -162,10 +162,10 @@ Mctt.Core.Completeness.LogicalRelation.Definitions - - - -Definitions + + + +Definitions @@ -173,101 +173,118 @@ Mctt.Core.Completeness.LogicalRelation.Lemmas - - - -Lemmas + + + +Lemmas - + Mctt.Core.Completeness.LogicalRelation.Definitions->Mctt.Core.Completeness.LogicalRelation.Lemmas - - + + Mctt.Core.Completeness.LogicalRelation - - - -LogicalRelation + + + +LogicalRelation - + Mctt.Core.Completeness.LogicalRelation.Lemmas->Mctt.Core.Completeness.LogicalRelation - - + + Mctt.Core.Completeness.LogicalRelation.Tactics - - - -Tactics + + + +Tactics - + Mctt.Core.Completeness.LogicalRelation.Tactics->Mctt.Core.Completeness.LogicalRelation.Lemmas - - + + Mctt.Core.Completeness - - - -Completeness + + + +Completeness Mctt.Core.Completeness->Mctt.Core.Completeness.Consequences.Rules - - + + Mctt.Core.Completeness->Mctt.Core.Completeness.Consequences.Types - - + + Mctt.Core.Completeness.FundamentalTheorem - - - -FundamentalTheorem + + + +FundamentalTheorem Mctt.Core.Completeness.FundamentalTheorem->Mctt.Core.Completeness - - + + + + + +Mctt.Core.Soundness.LogicalRelation.Lemmas + + + + +Lemmas + + + + + +Mctt.Core.Completeness.FundamentalTheorem->Mctt.Core.Soundness.LogicalRelation.Lemmas + + Mctt.Core.Completeness.ContextCases - - - -ContextCases + + + +ContextCases @@ -275,182 +292,182 @@ Mctt.Core.Completeness.SubstitutionCases - - - -SubstitutionCases + + + +SubstitutionCases - + Mctt.Core.Completeness.ContextCases->Mctt.Core.Completeness.SubstitutionCases - - + + Mctt.Core.Completeness.UniverseCases - - - -UniverseCases + + + +UniverseCases - + Mctt.Core.Completeness.LogicalRelation->Mctt.Core.Completeness.UniverseCases - - + + Mctt.Core.Completeness.VariableCases - - - -VariableCases + + + +VariableCases - + Mctt.Core.Completeness.LogicalRelation->Mctt.Core.Completeness.VariableCases - - + + - + Mctt.Core.Completeness.UniverseCases->Mctt.Core.Completeness.ContextCases - - + + Mctt.Core.Completeness.TermStructureCases - - - -TermStructureCases + + + +TermStructureCases - + Mctt.Core.Completeness.UniverseCases->Mctt.Core.Completeness.TermStructureCases - - + + Mctt.Core.Completeness.EqualityCases - - - -EqualityCases + + + +EqualityCases - + Mctt.Core.Completeness.EqualityCases->Mctt.Core.Completeness.FundamentalTheorem - - + + - + Mctt.Core.Completeness.SubstitutionCases->Mctt.Core.Completeness.EqualityCases - - + + Mctt.Core.Completeness.NatCases - - - -NatCases + + + +NatCases - + Mctt.Core.Completeness.SubstitutionCases->Mctt.Core.Completeness.NatCases - - + + Mctt.Core.Completeness.SubtypingCases - - - -SubtypingCases + + + +SubtypingCases - + Mctt.Core.Completeness.SubtypingCases->Mctt.Core.Completeness.EqualityCases - - + + Mctt.Core.Completeness.FunctionCases - - - -FunctionCases + + + +FunctionCases - + Mctt.Core.Completeness.TermStructureCases->Mctt.Core.Completeness.FunctionCases - - + + - + Mctt.Core.Completeness.TermStructureCases->Mctt.Core.Completeness.NatCases - - + + - + Mctt.Core.Completeness.VariableCases->Mctt.Core.Completeness.EqualityCases - - + + - + Mctt.Core.Completeness.FunctionCases->Mctt.Core.Completeness.SubtypingCases - - + + - + Mctt.Core.Completeness.NatCases->Mctt.Core.Completeness.FundamentalTheorem - - + + Mctt.Core.Semantic.Evaluation.Definitions - - - -Definitions + + + +Definitions @@ -458,61 +475,61 @@ Mctt.Core.Semantic.Evaluation.Lemmas - - - -Lemmas + + + +Lemmas - + Mctt.Core.Semantic.Evaluation.Definitions->Mctt.Core.Semantic.Evaluation.Lemmas - - + + Mctt.Core.Semantic.Evaluation.Tactics - - - -Tactics + + + +Tactics - + Mctt.Core.Semantic.Evaluation.Lemmas->Mctt.Core.Semantic.Evaluation.Tactics - - + + Mctt.Core.Semantic.Evaluation - - - -Evaluation + + + +Evaluation - + Mctt.Core.Semantic.Evaluation.Tactics->Mctt.Core.Semantic.Evaluation - - + + Mctt.Core.Semantic.PER.CoreTactics - - - -CoreTactics + + + +CoreTactics @@ -520,61 +537,61 @@ Mctt.Core.Semantic.PER.Lemmas - - - -Lemmas + + + +Lemmas - + Mctt.Core.Semantic.PER.CoreTactics->Mctt.Core.Semantic.PER.Lemmas - - + + Mctt.Core.Semantic.PER.Definitions - - - -Definitions + + + +Definitions - + Mctt.Core.Semantic.PER.Definitions->Mctt.Core.Semantic.PER.CoreTactics - - + + Mctt.Core.Semantic.PER - - - -PER + + + +PER - + Mctt.Core.Semantic.PER.Lemmas->Mctt.Core.Semantic.PER - - + + Mctt.Core.Semantic.Readback.Definitions - - - -Definitions + + + +Definitions @@ -582,493 +599,539 @@ Mctt.Core.Semantic.Readback.Lemmas - - - -Lemmas + + + +Lemmas - + Mctt.Core.Semantic.Readback.Definitions->Mctt.Core.Semantic.Readback.Lemmas - - + + Mctt.Core.Semantic.Readback - - - -Readback + + + +Readback - + Mctt.Core.Semantic.Readback.Lemmas->Mctt.Core.Semantic.Readback - - + + Mctt.Core.Semantic.Realizability - - - -Realizability + + + +Realizability - + Mctt.Core.Semantic.Realizability->Mctt.Core.Completeness.EqualityCases - - + + - + Mctt.Core.Semantic.Realizability->Mctt.Core.Completeness.NatCases - - + + + + + +Mctt.Core.Soundness.Realizability + + + + +Realizability + + + + + +Mctt.Core.Semantic.Realizability->Mctt.Core.Soundness.Realizability + + Mctt.Core.Semantic.NbE - - - -NbE + + + +NbE - + Mctt.Core.Semantic.NbE->Mctt.Core.Semantic.Realizability - - + + - + Mctt.Core.Semantic.PER->Mctt.Core.Completeness.LogicalRelation.Definitions - - + + - + Mctt.Core.Semantic.PER->Mctt.Core.Completeness.LogicalRelation.Tactics - - + + - + Mctt.Core.Semantic.PER->Mctt.Core.Semantic.Realizability - - + + - + Mctt.Core.Soundness.LogicalRelation.Definitions - - - - -Definitions + + + + +Definitions - + Mctt.Core.Semantic.PER->Mctt.Core.Soundness.LogicalRelation.Definitions - - + + Mctt.Core.Semantic.Domain - - - -Domain + + + +Domain - + Mctt.Core.Semantic.Domain->Mctt.Core.Semantic.Evaluation.Definitions - - + + - + Mctt.Core.Semantic.Evaluation->Mctt.Core.Semantic.Readback.Definitions - - + + - + Mctt.Core.Semantic.Readback->Mctt.Core.Semantic.PER.Definitions - - + + - + Mctt.Core.Semantic.Readback->Mctt.Core.Semantic.NbE - - + + - + -Mctt.Core.Soundness.LogicalRelation.CoreLemmas - - - - -CoreLemmas +Mctt.Core.Soundness.LogicalRelation.Core + + + + +Core - - -Mctt.Core.Soundness.LogicalRelation.Core - - - - -Core + + +Mctt.Core.Soundness.LogicalRelation.Core->Mctt.Core.Soundness.Realizability + + + + + +Mctt.Core.Soundness.LogicalRelation + + + + +LogicalRelation + + + + + +Mctt.Core.Soundness.LogicalRelation.Lemmas->Mctt.Core.Soundness.LogicalRelation + + + + + +Mctt.Core.Soundness.LogicalRelation.CoreLemmas + + + + +CoreLemmas - + Mctt.Core.Soundness.LogicalRelation.CoreLemmas->Mctt.Core.Soundness.LogicalRelation.Core - - + + - + Mctt.Core.Soundness.LogicalRelation.CoreTactics - - - - -CoreTactics + + + + +CoreTactics - + Mctt.Core.Soundness.LogicalRelation.CoreTactics->Mctt.Core.Soundness.LogicalRelation.CoreLemmas - - + + - + Mctt.Core.Soundness.LogicalRelation.Definitions->Mctt.Core.Soundness.LogicalRelation.CoreTactics - - + + - + Mctt.Core.Soundness.Weakening.Lemmas - - - - -Lemmas + + + + +Lemmas - + Mctt.Core.Soundness.Weakening.Lemmas->Mctt.Core.Soundness.LogicalRelation.CoreLemmas - - + + - + Mctt.Core.Soundness.Weakening.Definitions - - - - -Definitions + + + + +Definitions - + Mctt.Core.Soundness.Weakening.Definitions->Mctt.Core.Soundness.LogicalRelation.Definitions - - + + - + Mctt.Core.Soundness.Weakening.Definitions->Mctt.Core.Soundness.Weakening.Lemmas - - + + + + + +Mctt.Core.Soundness.Realizability->Mctt.Core.Soundness.LogicalRelation.Lemmas + + - + Mctt.Core.Syntactic.System.Definitions - - - - -Definitions + + + + +Definitions - + Mctt.Core.Syntactic.System.Lemmas - - - - -Lemmas + + + + +Lemmas - + Mctt.Core.Syntactic.System.Definitions->Mctt.Core.Syntactic.System.Lemmas - - + + - + Mctt.Core.Syntactic.System.Tactics - - - - -Tactics + + + + +Tactics - + Mctt.Core.Syntactic.System.Lemmas->Mctt.Core.Syntactic.System.Tactics - - + + - + Mctt.Core.Syntactic.System - - - - -System + + + + +System - + Mctt.Core.Syntactic.System.Tactics->Mctt.Core.Syntactic.System - - + + - + Mctt.Core.Syntactic.SystemOpt - - - - -SystemOpt + + + + +SystemOpt - + Mctt.Core.Syntactic.SystemOpt->Mctt.Core.Completeness.VariableCases - - + + - + Mctt.Core.Syntactic.SystemOpt->Mctt.Core.Soundness.Weakening.Definitions - - + + - + Mctt.Core.Syntactic.Corollaries - - - - -Corollaries + + + + +Corollaries - + Mctt.Core.Syntactic.SystemOpt->Mctt.Core.Syntactic.Corollaries - - + + - + Mctt.Core.Syntactic.Syntax - - - - -Syntax + + + + +Syntax - + Mctt.Core.Syntactic.Syntax->Mctt.Core.Semantic.Domain - - + + - + Mctt.Core.Syntactic.Syntax->Mctt.Core.Syntactic.System.Definitions - - + + - + Mctt.Core.Syntactic.System->Mctt.Core.Semantic.NbE - - + + - + Mctt.Core.Syntactic.CtxSub - - - - -CtxSub + + + + +CtxSub - + Mctt.Core.Syntactic.System->Mctt.Core.Syntactic.CtxSub - - + + - + Mctt.Core.Syntactic.Corollaries->Mctt.Core.Soundness.Weakening.Lemmas - - + + - + Mctt.Core.Syntactic.CoreInversions - - - - -CoreInversions + + + + +CoreInversions - + Mctt.Core.Syntactic.CoreInversions->Mctt.Core.Syntactic.SystemOpt - - + + - + Mctt.Core.Syntactic.CtxEq - - - - -CtxEq + + + + +CtxEq - + Mctt.Core.Syntactic.CtxEq->Mctt.Core.Syntactic.CoreInversions - - + + - + Mctt.Core.Syntactic.Presup - - - - -Presup + + + + +Presup - + Mctt.Core.Syntactic.CtxEq->Mctt.Core.Syntactic.Presup - - + + - + Mctt.Core.Syntactic.CtxSub->Mctt.Core.Syntactic.CtxEq - - + + - + Mctt.Core.Syntactic.Presup->Mctt.Core.Syntactic.SystemOpt - - + + - + Mctt.Core.Base - - - - -Base + + + + +Base Mctt.Core.Base->Mctt.Core.Syntactic.Syntax - - + + - + Mctt.LibTactics - - - - -LibTactics + + + + +LibTactics Mctt.LibTactics->Mctt.Core.Semantic.Evaluation.Lemmas - - + + Mctt.LibTactics->Mctt.Core.Syntactic.System.Definitions - - + +
diff --git a/ext/prop-eq/indexpage.html b/ext/prop-eq/indexpage.html index 2568d04..486919d 100644 --- a/ext/prop-eq/indexpage.html +++ b/ext/prop-eq/indexpage.html @@ -56,7 +56,7 @@ Z _ other -(1160 entries) +(1227 entries) Notation Index @@ -184,7 +184,7 @@ Z _ other -(50 entries) +(53 entries) Lemma Index @@ -200,7 +200,7 @@ J K L -M +M N O P @@ -216,7 +216,7 @@ Z _ other -(485 entries) +(547 entries) Constructor Index @@ -344,7 +344,7 @@ Z _ other -(7 entries) +(8 entries) Instance Index @@ -440,7 +440,7 @@ Z _ other -(154 entries) +(155 entries) Record Index @@ -514,6 +514,8 @@

Global Index

completeness_fundamental [section, in Mctt.Core.Completeness.FundamentalTheorem]
completeness_ty [lemma, in Mctt.Core.Completeness]
cons_per_ctx_env [inductive, in Mctt.Core.Semantic.PER.Definitions]
+cons_glu_sub_pred_helper [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+cons_glu_sub_pred_resp_wf_sub_eq [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
cons_glu_sub_pred [inductive, in Mctt.Core.Soundness.LogicalRelation.Definitions]
ContextCases [library]
Core [library]
@@ -769,6 +771,7 @@

Global Index

functional_eval_exp [lemma, in Mctt.Core.Semantic.Evaluation.Lemmas]
functional_eval [lemma, in Mctt.Core.Semantic.Evaluation.Lemmas]
functional_eval [section, in Mctt.Core.Semantic.Evaluation.Lemmas]
+functional_glu_ctx_env [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
functional_read_typ [lemma, in Mctt.Core.Semantic.Readback.Lemmas]
functional_read_ne [lemma, in Mctt.Core.Semantic.Readback.Lemmas]
functional_read_nf [lemma, in Mctt.Core.Semantic.Readback.Lemmas]
@@ -817,6 +820,53 @@

Global Index

glu_nat_resp_ctx_eq [lemma, in Mctt.Core.Soundness.LogicalRelation.CoreLemmas]
glu_nat_escape [lemma, in Mctt.Core.Soundness.LogicalRelation.CoreLemmas]
glu_nat_per_nat [lemma, in Mctt.Core.Soundness.LogicalRelation.CoreLemmas]
+glu_rel_sub_wf_sub [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_sub_clean_inversion3 [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_sub_clean_inversion2 [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_sub_clean_inversion1 [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_to_wf_exp [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_clean_inversion2 [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_clean_inversion2_result [definition, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_clean_inversion1 [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_sub_monotone [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_subtyp_sub_if [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_cons_clean_inversion [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_resp_per_ctx_helper [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_per_ctx_env [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_sub_escape [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_wf_ctx [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_per_env [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_sub_resp_sub_eq [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_sub_resp_ctx_eq [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_typ_with_sub_implies_glu_rel_exp_with_sub [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_with_sub_implies_glu_rel_typ_with_sub [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_with_sub_implies_glu_rel_exp_sub_with_typ [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_subtyp_trm_conv [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_subtyp_trm_if [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_subtyp_typ_escape [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_conv [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_lower_max_right [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_lower_max_left [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_lower [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_cumu_max_right [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_cumu_max_left [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_cumu_ge [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_cumu_max_right [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_cumu_max_left [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_cumu_ge [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumulativity_ge [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumulativity [section, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumu_max_right [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumu_max_left [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumu_ge [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_univ_typ_iff [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_unique_upto_exp_eq' [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_unique_upto_exp_eq [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_univ_typ_escape [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_univ_elem_typ_escape [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_unique_upto_exp_eq' [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_unique_upto_exp_eq_ge [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_unique_upto_exp_eq [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
glu_rel_sub [definition, in Mctt.Core.Soundness.LogicalRelation.Definitions]
glu_rel_exp [definition, in Mctt.Core.Soundness.LogicalRelation.Definitions]
glu_rel_ctx [definition, in Mctt.Core.Soundness.LogicalRelation.Definitions]
@@ -865,6 +915,7 @@

Global Index

initial_env_cons [constructor, in Mctt.Core.Semantic.NbE]
initial_env_nil [constructor, in Mctt.Core.Semantic.NbE]
initial_env [inductive, in Mctt.Core.Semantic.NbE]
+initial_env_glu_rel_exp [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
invert_compose_id [lemma, in Mctt.Core.Syntactic.Corollaries]
invert_sub_id_typ [lemma, in Mctt.Core.Syntactic.Corollaries]
invert_sub_id [lemma, in Mctt.Core.Syntactic.Corollaries]
@@ -877,6 +928,7 @@

Global Index



L

Lemmas [library]
Lemmas [library]
+Lemmas [library]
Lemmas [library]
Lemmas [library]
Lemmas [library]
@@ -891,11 +943,16 @@

Global Index

lift_exp_max_right [lemma, in Mctt.Core.Syntactic.System.Lemmas]
lift_exp_max_left [lemma, in Mctt.Core.Syntactic.System.Lemmas]
lift_exp_ge [lemma, in Mctt.Core.Syntactic.System.Lemmas]
+LogicalRelation [library]
LogicalRelation [library]


M

mk_cons_per_ctx_env [constructor, in Mctt.Core.Semantic.PER.Definitions]
mk_rel_mod_app [constructor, in Mctt.Core.Semantic.PER.Definitions]
mk_rel_mod_eval [constructor, in Mctt.Core.Semantic.PER.Definitions]
+mk_glu_rel_exp_with_sub'' [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+mk_glu_rel_exp_with_sub' [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+mk_glu_rel_typ_with_sub'' [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+mk_glu_rel_typ_with_sub' [lemma, in Mctt.Core.Soundness.LogicalRelation.Lemmas]
mk_rel_sub [constructor, in Mctt.Core.Completeness.LogicalRelation.Definitions]
mk_rel_exp [constructor, in Mctt.Core.Completeness.LogicalRelation.Definitions]
mk_glu_rel_sub_with_sub [constructor, in Mctt.Core.Soundness.LogicalRelation.Definitions]
@@ -1196,8 +1253,13 @@

Global Index

read_nf_zero [constructor, in Mctt.Core.Semantic.Readback.Definitions]
read_nf_type [constructor, in Mctt.Core.Semantic.Readback.Definitions]
read_nf [inductive, in Mctt.Core.Semantic.Readback.Definitions]
+Realizability [library]
Realizability [library]
realize_per_univ_elem_gen [lemma, in Mctt.Core.Semantic.Realizability]
+realize_glu_elem_top [lemma, in Mctt.Core.Soundness.Realizability]
+realize_glu_elem_bot [lemma, in Mctt.Core.Soundness.Realizability]
+realize_glu_typ_top [lemma, in Mctt.Core.Soundness.Realizability]
+realize_glu_univ_elem_gen [lemma, in Mctt.Core.Soundness.Realizability]
rel_exp_cumu [lemma, in Mctt.Core.Completeness.UniverseCases]
rel_exp_typ_sub [lemma, in Mctt.Core.Completeness.UniverseCases]
rel_exp_of_typ [lemma, in Mctt.Core.Completeness.UniverseCases]
@@ -1408,8 +1470,12 @@

Global Index

VariableCases [library]
var_per_elem [lemma, in Mctt.Core.Semantic.Realizability]
var_per_bot [lemma, in Mctt.Core.Semantic.PER.Lemmas]
+var_glu_elem_bot [lemma, in Mctt.Core.Soundness.Realizability]
+var_weaken_gen [lemma, in Mctt.Core.Soundness.Realizability]
+var_arith [lemma, in Mctt.Core.Soundness.Realizability]
var_is_typ_constr [constructor, in Mctt.Core.Completeness.Consequences.Types]
var_compose_subs [lemma, in Mctt.Core.Syntactic.System.Lemmas]
+var0_glu_elem [lemma, in Mctt.Core.Soundness.Realizability]
vlookup_1_nat [lemma, in Mctt.Core.Syntactic.System.Lemmas]
vlookup_0_nat [lemma, in Mctt.Core.Syntactic.System.Lemmas]
vlookup_1_typ [lemma, in Mctt.Core.Syntactic.System.Lemmas]
@@ -1589,6 +1655,7 @@

Global Index

wf_zero_inversion [lemma, in Mctt.Core.Syntactic.CoreInversions]
wf_nat_inversion [lemma, in Mctt.Core.Syntactic.CoreInversions]
wf_typ_inversion [lemma, in Mctt.Core.Syntactic.CoreInversions]
+wf_ctx_sub_ctx_lookup [lemma, in Mctt.Core.Soundness.Realizability]
wf_ctx_sub_trans_ins [instance, in Mctt.Core.Syntactic.CtxSub]
wf_ctx_sub_trans [lemma, in Mctt.Core.Syntactic.CtxSub]
wf_subtyp_univ_weaken [lemma, in Mctt.Core.Syntactic.System.Lemmas]
@@ -1846,11 +1913,13 @@

Library Index



L

Lemmas
Lemmas
+Lemmas
Lemmas
Lemmas
Lemmas
Lemmas
LibTactics
+LogicalRelation
LogicalRelation


N

NatCases
@@ -1860,6 +1929,7 @@

Library Index

Presup


R

Readback
+Realizability
Realizability
Rules


S

@@ -1895,6 +1965,8 @@

Lemma Index

completeness_fundamental_ctx [in Mctt.Core.Completeness.FundamentalTheorem]
completeness_fundamental [in Mctt.Core.Completeness.FundamentalTheorem]
completeness_ty [in Mctt.Core.Completeness]
+cons_glu_sub_pred_helper [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+cons_glu_sub_pred_resp_wf_sub_eq [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
ctxeq_weakening [in Mctt.Core.Soundness.Weakening.Lemmas]
ctxeq_nbe_ty_eq' [in Mctt.Core.Completeness.Consequences.Rules]
ctxeq_nbe_ty_eq [in Mctt.Core.Completeness.Consequences.Rules]
@@ -1999,6 +2071,7 @@

Lemma Index

functional_eval_natrec [in Mctt.Core.Semantic.Evaluation.Lemmas]
functional_eval_exp [in Mctt.Core.Semantic.Evaluation.Lemmas]
functional_eval [in Mctt.Core.Semantic.Evaluation.Lemmas]
+functional_glu_ctx_env [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
functional_read_typ [in Mctt.Core.Semantic.Readback.Lemmas]
functional_read_ne [in Mctt.Core.Semantic.Readback.Lemmas]
functional_read_nf [in Mctt.Core.Semantic.Readback.Lemmas]
@@ -2034,10 +2107,56 @@

Lemma Index

glu_nat_resp_ctx_eq [in Mctt.Core.Soundness.LogicalRelation.CoreLemmas]
glu_nat_escape [in Mctt.Core.Soundness.LogicalRelation.CoreLemmas]
glu_nat_per_nat [in Mctt.Core.Soundness.LogicalRelation.CoreLemmas]
+glu_rel_sub_wf_sub [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_sub_clean_inversion3 [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_sub_clean_inversion2 [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_sub_clean_inversion1 [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_to_wf_exp [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_clean_inversion2 [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_clean_inversion1 [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_sub_monotone [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_subtyp_sub_if [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_cons_clean_inversion [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_resp_per_ctx_helper [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_per_ctx_env [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_sub_escape [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_wf_ctx [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_per_env [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_sub_resp_sub_eq [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_ctx_env_sub_resp_ctx_eq [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_typ_with_sub_implies_glu_rel_exp_with_sub [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_with_sub_implies_glu_rel_typ_with_sub [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_rel_exp_with_sub_implies_glu_rel_exp_sub_with_typ [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_subtyp_trm_conv [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_subtyp_trm_if [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_subtyp_typ_escape [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_conv [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_lower_max_right [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_lower_max_left [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_lower [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_cumu_max_right [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_cumu_max_left [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_cumu_ge [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_cumu_max_right [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_cumu_max_left [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_cumu_ge [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumulativity_ge [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumu_max_right [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumu_max_left [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_cumu_ge [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_univ_typ_iff [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_unique_upto_exp_eq' [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_exp_unique_upto_exp_eq [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_univ_typ_escape [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_per_univ_elem_typ_escape [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_unique_upto_exp_eq' [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_unique_upto_exp_eq_ge [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+glu_univ_elem_typ_unique_upto_exp_eq [in Mctt.Core.Soundness.LogicalRelation.Lemmas]


I

id_sub_lookup_var1 [in Mctt.Core.Syntactic.System.Lemmas]
id_sub_lookup_var0 [in Mctt.Core.Syntactic.System.Lemmas]
initial_env_spec [in Mctt.Core.Semantic.NbE]
+initial_env_glu_rel_exp [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
invert_compose_id [in Mctt.Core.Syntactic.Corollaries]
invert_sub_id_typ [in Mctt.Core.Syntactic.Corollaries]
invert_sub_id [in Mctt.Core.Syntactic.Corollaries]
@@ -2054,6 +2173,11 @@

Lemma Index

lift_exp_max_right [in Mctt.Core.Syntactic.System.Lemmas]
lift_exp_max_left [in Mctt.Core.Syntactic.System.Lemmas]
lift_exp_ge [in Mctt.Core.Syntactic.System.Lemmas]
+

M

+mk_glu_rel_exp_with_sub'' [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+mk_glu_rel_exp_with_sub' [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+mk_glu_rel_typ_with_sub'' [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
+mk_glu_rel_typ_with_sub' [in Mctt.Core.Soundness.LogicalRelation.Lemmas]


N

nbe_type_to_nbe_ty [in Mctt.Core.Semantic.NbE]
nbe_cumu [in Mctt.Core.Semantic.NbE]
@@ -2183,6 +2307,10 @@

Lemma Index

presup_ctx_eq [in Mctt.Core.Syntactic.System.Lemmas]


R

realize_per_univ_elem_gen [in Mctt.Core.Semantic.Realizability]
+realize_glu_elem_top [in Mctt.Core.Soundness.Realizability]
+realize_glu_elem_bot [in Mctt.Core.Soundness.Realizability]
+realize_glu_typ_top [in Mctt.Core.Soundness.Realizability]
+realize_glu_univ_elem_gen [in Mctt.Core.Soundness.Realizability]
rel_exp_cumu [in Mctt.Core.Completeness.UniverseCases]
rel_exp_typ_sub [in Mctt.Core.Completeness.UniverseCases]
rel_exp_of_typ [in Mctt.Core.Completeness.UniverseCases]
@@ -2307,7 +2435,11 @@

Lemma Index

valid_exp_eq [in Mctt.Core.Completeness.EqualityCases]
var_per_elem [in Mctt.Core.Semantic.Realizability]
var_per_bot [in Mctt.Core.Semantic.PER.Lemmas]
+var_glu_elem_bot [in Mctt.Core.Soundness.Realizability]
+var_weaken_gen [in Mctt.Core.Soundness.Realizability]
+var_arith [in Mctt.Core.Soundness.Realizability]
var_compose_subs [in Mctt.Core.Syntactic.System.Lemmas]
+var0_glu_elem [in Mctt.Core.Soundness.Realizability]
vlookup_1_nat [in Mctt.Core.Syntactic.System.Lemmas]
vlookup_0_nat [in Mctt.Core.Syntactic.System.Lemmas]
vlookup_1_typ [in Mctt.Core.Syntactic.System.Lemmas]
@@ -2367,6 +2499,7 @@

Lemma Index

wf_zero_inversion [in Mctt.Core.Syntactic.CoreInversions]
wf_nat_inversion [in Mctt.Core.Syntactic.CoreInversions]
wf_typ_inversion [in Mctt.Core.Syntactic.CoreInversions]
+wf_ctx_sub_ctx_lookup [in Mctt.Core.Soundness.Realizability]
wf_ctx_sub_trans [in Mctt.Core.Syntactic.CtxSub]
wf_subtyp_univ_weaken [in Mctt.Core.Syntactic.System.Lemmas]
wf_subtyp_sub [in Mctt.Core.Syntactic.System.Lemmas]
@@ -2715,6 +2848,7 @@

Section Index



G

Gluing [in Mctt.Core.Soundness.LogicalRelation.Definitions]
GluingInduction [in Mctt.Core.Soundness.LogicalRelation.Definitions]
+glu_univ_elem_cumulativity [in Mctt.Core.Soundness.LogicalRelation.Lemmas]


P

Per_univ_elem_ind_def [in Mctt.Core.Semantic.PER.Definitions]
Per_univ_elem_core_def [in Mctt.Core.Semantic.PER.Definitions]
@@ -2804,6 +2938,7 @@

Definition Index

exp_rect [in Mctt.Core.Syntactic.Syntax]
extend_env [in Mctt.Core.Semantic.Domain]


G

+glu_rel_exp_clean_inversion2_result [in Mctt.Core.Soundness.LogicalRelation.Lemmas]
glu_rel_sub [in Mctt.Core.Soundness.LogicalRelation.Definitions]
glu_rel_exp [in Mctt.Core.Soundness.LogicalRelation.Definitions]
glu_rel_ctx [in Mctt.Core.Soundness.LogicalRelation.Definitions]
@@ -2961,7 +3096,7 @@

Record Index

Z _ other -(1160 entries) +(1227 entries) Notation Index @@ -3089,7 +3224,7 @@

Record Index

Z _ other -(50 entries) +(53 entries) Lemma Index @@ -3105,7 +3240,7 @@

Record Index

J K L -M +M N O P @@ -3121,7 +3256,7 @@

Record Index

Z _ other -(485 entries) +(547 entries) Constructor Index @@ -3249,7 +3384,7 @@

Record Index

Z _ other -(7 entries) +(8 entries) Instance Index @@ -3345,7 +3480,7 @@

Record Index

Z _ other -(154 entries) +(155 entries) Record Index diff --git a/ext/prop-eq/toc.html b/ext/prop-eq/toc.html index 1e81cf5..24fb84c 100644 --- a/ext/prop-eq/toc.html +++ b/ext/prop-eq/toc.html @@ -80,10 +80,13 @@

Mctt.Core.Semantic.ReadbackMctt.Core.Semantic.Readback.Definitions

Mctt.Core.Semantic.Readback.Lemmas

Mctt.Core.Semantic.Realizability

+

Mctt.Core.Soundness.LogicalRelation

Mctt.Core.Soundness.LogicalRelation.Core

Mctt.Core.Soundness.LogicalRelation.CoreLemmas

Mctt.Core.Soundness.LogicalRelation.CoreTactics

Mctt.Core.Soundness.LogicalRelation.Definitions

+

Mctt.Core.Soundness.LogicalRelation.Lemmas

+

Mctt.Core.Soundness.Realizability

Mctt.Core.Soundness.Weakening.Definitions

Mctt.Core.Soundness.Weakening.Lemmas

Mctt.Core.Syntactic.CoreInversions

@@ -93,15 +96,15 @@

Mctt.Core.Syntactic.CtxSub

Mctt.Core.Syntactic.Presup

Mctt.Core.Syntactic.Syntax