Skip to content

Commit b464130

Browse files
author
Martin Baillon
committed
Through to Poly.v
1 parent 49a85a0 commit b464130

File tree

13 files changed

+706
-302
lines changed

13 files changed

+706
-302
lines changed

theories/LogicalRelation.v

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,11 +1437,20 @@ Notation "W[ Γ ||-< l > A ≅ B | RA ]< wl >" := (WLogRelEq l wl Γ A B RA).
14371437
Notation "W[ Γ ||-< l > t : A | RA ]< wl >" := (WLogRelTm l wl Γ t A RA).
14381438
Notation "W[ Γ ||-< l > t ≅ u : A | RA ]< wl >" := (WLogRelTmEq l wl Γ t u A RA).
14391439

1440-
Lemma instKripke `{GenericTypingProperties} {k Γ A l} (wfΓ : [|-Γ]< k >) (h : forall Δ (ρ : Δ ≤ Γ) (wfΔ : [|-Δ]< k >), [Δ ||-<l> A⟨ρ⟩]< k >) : [Γ ||-<l> A]< k >.
1440+
Lemma instKripke `{GenericTypingProperties} {k Γ A l} (wfΓ : [|-Γ]< k >)
1441+
(h : forall Δ (ρ : Δ ≤ Γ) (wfΔ : [|-Δ]< k >), [Δ ||-<l> A⟨ρ⟩]< k >) :
1442+
[Γ ||-<l> A]< k >.
14411443
Proof.
14421444
specialize (h Γ wk_id wfΓ); now rewrite wk_id_ren_on in h.
14431445
Qed.
14441446

1447+
Lemma instKripke' `{GenericTypingProperties} {wl Γ A l} (wfΓ : [|-Γ]< wl >)
1448+
(h : forall Δ wl' (ρ : Δ ≤ Γ) (f : wl' ≤ε wl) (wfΔ : [|-Δ]< wl' >), [Δ ||-<l> A⟨ρ⟩]< wl' >) :
1449+
[Γ ||-<l> A]< wl >.
1450+
Proof.
1451+
specialize (h Γ wl wk_id (wfLCon_le_id _) wfΓ); now rewrite wk_id_ren_on in h.
1452+
Qed.
1453+
14451454
(** ** Rebundling reducibility of Polynomial *)
14461455

14471456
(** The definition of reducibility of product types in the logical relation, which separates
@@ -1541,11 +1550,13 @@ Section PolyRed.
15411550
: toAd (from PAad) = PAad.
15421551
Proof. destruct PA, PAad; reflexivity. Qed.
15431552

1553+
15441554
End PolyRed.
15451555

15461556
Arguments PolyRed : clear implicits.
15471557
Arguments PolyRed {_ _ _ _ _ _ _ _ _} _ _ _.
15481558

1559+
15491560
End PolyRed.
15501561

15511562
Export PolyRed(PolyRed,Build_PolyRed).
@@ -1637,6 +1648,25 @@ Section EvenMoreDefs.
16371648
: [ LogRel@{i j k l} l | Γ ||- A ]< k > :=
16381649
LRbuild (LRSig (LogRelRec l) _ (ParamRedTy.toAd ΠA)).
16391650

1651+
1652+
Record WPolyRed@{i j k l} (k : wfLCon) (Γ : context) (l : TypeLevel) (shp pos : term) :=
1653+
{ WPol : DTree k ;
1654+
WRedPol {k'} (Ho : over_tree k k' WPol) :
1655+
PolyRed@{i j k l} k' Γ l shp pos ;
1656+
}.
1657+
Arguments WPol [_ _ _ _ _ ] _.
1658+
Arguments WRedPol [_ _ _ _ _] _ [_] _.
1659+
1660+
Record WPolyRedEq@{i j k l} {k : wfLCon} {Γ : context} {l : TypeLevel} {shp pos : term} (Hyp : WPolyRed@{i j k l} k Γ l shp pos)
1661+
(shp' pos' : term) :=
1662+
{ WPolEq : DTree k ;
1663+
WRedPolEq {k'} (Ho : over_tree k k' (WPol Hyp))
1664+
(Ho' : over_tree k k' WPolEq) :
1665+
PolyRedEq@{k} (PolyRed.toPack (WRedPol Hyp Ho)) shp' pos' ;
1666+
}.
1667+
Arguments WPolEq [_ _ _ _ _] _.
1668+
Arguments WRedPolEq [_ _ _ _ _ _] _.
1669+
16401670
End EvenMoreDefs.
16411671

16421672

theories/LogicalRelation/Irrelevance.v

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,16 @@ Corollary LRCumulative' @{i j k l i' j' k' l'} {lA}
917917
Proof.
918918
intros ->; apply LRCumulative.
919919
Qed.
920+
921+
Theorem WLRCumulative@{i j k l i' j' k' l'} {lA}
922+
{wl : wfLCon} {Γ : context} {A : term}
923+
: WLogRel@{i j k l} lA wl Γ A ->
924+
WLogRel@{i' j' k' l'} lA wl Γ A.
925+
Proof.
926+
intros [d Hd] ; exists d.
927+
intros wl' f ; now eapply LRCumulative, Hd.
928+
Qed.
929+
920930
End LRIrrelevant.
921931

922932

theories/LogicalRelation/Monotonicity.v

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,3 +856,89 @@ Proof.
856856
Defined.
857857

858858
End Injection.
859+
860+
Section Weakening_Ltrans.
861+
Context `{GenericTypingProperties}.
862+
863+
Lemma wk_Ltrans@{h i j k l} {wl Γ Δ wl' A l}
864+
(ρ : Δ ≤ Γ)
865+
(f : wl' ≤ε wl)
866+
(wfΔ : [|- Δ]< wl' >) :
867+
[LogRel@{i j k l} l | Γ ||- A]< wl > ->
868+
[LogRel@{i j k l} l | Δ ||- A⟨ρ⟩]< wl' >.
869+
Proof.
870+
intros ; now eapply (wk@{i j k l}), (Ltrans@{h i j k l}).
871+
Defined.
872+
873+
Lemma Wwk_Ltrans@{h i j k l} {wl Γ Δ wl' A l}
874+
(ρ : Δ ≤ Γ)
875+
(f : wl' ≤ε wl)
876+
(wfΔ : [|- Δ]< wl' >) :
877+
WLogRel@{i j k l} l wl Γ A ->
878+
WLogRel@{i j k l} l wl' Δ A⟨ρ⟩.
879+
Proof.
880+
intros ; now eapply (Wwk@{i j k l}), (WLtrans@{h i j k l}).
881+
Defined.
882+
883+
Lemma wkEq_Ltrans@{h i j k l} {wl Γ Δ wl' A B l} (ρ : Δ ≤ Γ) (f : wl' ≤ε wl)
884+
(wfΔ : [|- Δ]< wl' >)
885+
(lrA : [Γ ||-<l> A]< wl >) :
886+
[LogRel@{i j k l} l | Γ ||- A ≅ B | lrA]< wl > ->
887+
[LogRel@{i j k l} l | Δ ||- A⟨ρ⟩ ≅ B⟨ρ⟩ | wk_Ltrans@{h i j k l} ρ f wfΔ lrA]< wl' >.
888+
Proof.
889+
intros ; now eapply (wkEq@{i j k l}), (Eq_Ltrans@{h i j k l}).
890+
Defined.
891+
892+
Lemma WwkEq_Ltrans@{h i j k l} {wl Γ Δ wl' A B l}
893+
(ρ : Δ ≤ Γ)
894+
(f : wl' ≤ε wl)
895+
(wfΔ : [|- Δ]< wl' >)
896+
(lrA : W[Γ ||-<l> A]< wl >) :
897+
WLogRelEq@{i j k l} l wl Γ A B lrA ->
898+
WLogRelEq@{i j k l} l wl' Δ A⟨ρ⟩ B⟨ρ⟩ (Wwk_Ltrans@{h i j k l} ρ f wfΔ lrA).
899+
Proof.
900+
intros ; now eapply (WwkEq@{i j k l}), (WEq_Ltrans@{h i j k l}).
901+
Defined.
902+
903+
Lemma wkTm_Ltrans@{h i j k l} {wl Γ Δ wl' t A l} (ρ : Δ ≤ Γ) (f : wl' ≤ε wl)
904+
(wfΔ : [|- Δ]< wl' >)
905+
(lrA : [Γ ||-<l> A]< wl >) :
906+
[LogRel@{i j k l} l | Γ ||- t : A | lrA]< wl > ->
907+
[LogRel@{i j k l} l | Δ ||- t⟨ρ⟩ : A⟨ρ⟩ | wk_Ltrans@{h i j k l} ρ f wfΔ lrA]< wl' >.
908+
Proof.
909+
intros ; now eapply (wkTerm@{i j k l}), (Tm_Ltrans@{h i j k l}).
910+
Defined.
911+
912+
Lemma WwkTm_Ltrans@{h i j k l} {wl Γ Δ wl' t A l}
913+
(ρ : Δ ≤ Γ)
914+
(f : wl' ≤ε wl)
915+
(wfΔ : [|- Δ]< wl' >)
916+
(lrA : W[Γ ||-<l> A]< wl >) :
917+
WLogRelTm@{i j k l} l wl Γ t A lrA ->
918+
WLogRelTm@{i j k l} l wl' Δ t⟨ρ⟩ A⟨ρ⟩ (Wwk_Ltrans@{h i j k l} ρ f wfΔ lrA).
919+
Proof.
920+
intros ; now eapply (WwkTerm@{i j k l}), (WTm_Ltrans@{h i j k l}).
921+
Defined.
922+
923+
Lemma wkTmEq_Ltrans@{h i j k l} {wl Γ Δ wl' t u A l} (ρ : Δ ≤ Γ) (f : wl' ≤ε wl)
924+
(wfΔ : [|- Δ]< wl' >)
925+
(lrA : [Γ ||-<l> A]< wl >) :
926+
[LogRel@{i j k l} l | Γ ||- t ≅ u : A | lrA]< wl > ->
927+
[LogRel@{i j k l} l | Δ ||- t⟨ρ⟩ ≅ u⟨ρ⟩ : A⟨ρ⟩ | wk_Ltrans@{h i j k l} ρ f wfΔ lrA]< wl' >.
928+
Proof.
929+
intros ; now eapply (wkTermEq@{i j k l}), (TmEq_Ltrans@{h i j k l}).
930+
Defined.
931+
932+
Lemma WwkEqTm_Ltrans@{h i j k l} {wl Γ Δ wl' t u A l}
933+
(ρ : Δ ≤ Γ)
934+
(f : wl' ≤ε wl)
935+
(wfΔ : [|- Δ]< wl' >)
936+
(lrA : W[Γ ||-<l> A]< wl >) :
937+
WLogRelTmEq@{i j k l} l wl Γ t u A lrA ->
938+
WLogRelTmEq@{i j k l} l wl' Δ t⟨ρ⟩ u⟨ρ⟩ A⟨ρ⟩ (Wwk_Ltrans@{h i j k l} ρ f wfΔ lrA).
939+
Proof.
940+
intros ; now eapply (WwkTermEq@{i j k l}), (WTmEq_Ltrans@{h i j k l}).
941+
Defined.
942+
943+
944+
End Weakening_Ltrans.

theories/LogicalRelation/Reduction.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ Proof.
203203
intros ? []; now eapply redSubstTerm.
204204
Qed.
205205

206+
Lemma WredwfSubstTerm {wl Γ A t u l} (RA : W[Γ ||-<l> A]< wl >) :
207+
W[Γ ||-<l> u : A | RA]< wl > ->
208+
[Γ |- t :⤳*: u : A ]< wl > ->
209+
W[Γ ||-<l> t : A | RA]< wl > × W[Γ ||-<l> t ≅ u : A | RA]< wl >.
210+
Proof.
211+
intros ? []; now eapply WredSubstTerm.
212+
Qed.
206213

207214
Lemma redFwd {wl Γ l A B} :
208215
[Γ ||-<l> A]< wl > ->

theories/LogicalRelation/Reflexivity.v

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,24 @@ Set Universe Polymorphism.
99
Section Reflexivities.
1010
Context `{GenericTypingProperties}.
1111

12-
Definition reflLRTyEq {l wl Γ A} (lr : [ Γ ||-< l > A ]< wl > ) : [ Γ ||-< l > A ≅ A | lr ]< wl >.
12+
Definition reflLRTyEq {l wl Γ A} (lr : [ Γ ||-< l > A ]< wl > ) :
13+
[ Γ ||-< l > A ≅ A | lr ]< wl >.
1314
Proof.
1415
pattern l, wl, Γ, A, lr; eapply LR_rect_TyUr; intros ???? [] **.
1516
all: try match goal with H : PolyRed _ _ _ _ _ |- _ => destruct H; econstructor; tea end.
1617
all: try now econstructor.
1718
Unshelve.
18-
all: cbn in * ; try eassumption.
19+
all: cbn in * ; eassumption.
1920
(* econstructor; tea; now eapply escapeEqTerm. *)
2021
Qed.
2122

23+
Definition WreflLRTyEq {l wl Γ A} (lr : W[ Γ ||-< l > A ]< wl > ) :
24+
W[ Γ ||-< l > A ≅ A | lr ]< wl >.
25+
Proof.
26+
exists (WT _ lr).
27+
intros ; now eapply reflLRTyEq.
28+
Defined.
29+
2230
(* Deprecated *)
2331
Corollary LRTyEqRefl {l wl Γ A eqTy redTm eqTm}
2432
(lr : LogRel l wl Γ A eqTy redTm eqTm) : eqTy A.

theories/LogicalRelation/Universe.v

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
From LogRel.AutoSubst Require Import core unscoped Ast Extra.
2-
From LogRel Require Import Utils BasicAst Notations Context NormalForms Weakening GenericTyping LogicalRelation.
2+
From LogRel Require Import Utils BasicAst Notations Context NormalForms Weakening GenericTyping Monad LogicalRelation.
33
From LogRel.LogicalRelation Require Import Induction Escape Irrelevance.
44

55
Set Universe Polymorphism.
@@ -31,13 +31,38 @@ Section UniverseReducibility.
3131
+ apply (UnivEq' rU rA).
3232
Qed.
3333

34-
Lemma UnivEqEq@{i j k l} {wl Γ A B l l'} (rU : [ LogRel@{i j k l} l | Γ ||- U ]< wl >) (rA : [LogRel@{i j k l} l' | Γ ||- A ]< wl >) (rAB : [ LogRel@{i j k l} l | Γ ||- A ≅ B : U | rU ]< wl >)
34+
Lemma WUnivEq@{i j k l} {wl Γ A l} l' (rU : WLogRel@{i j k l} l wl Γ U) (rA : WLogRelTm@{i j k l} l wl Γ A U rU)
35+
: WLogRel@{i j k l} l' wl Γ A.
36+
Proof.
37+
unshelve eexists (DTree_fusion _ _ _).
38+
+ exact (WTTm _ rA).
39+
+ exact (WT _ rU).
40+
+ intros ; now eapply UnivEq, rA, over_tree_fusion_l.
41+
Unshelve.
42+
now eapply over_tree_fusion_r.
43+
Qed.
44+
45+
Lemma UnivEqEq@{i j k l} {wl Γ A B l l'} (rU : [ LogRel@{i j k l} l | Γ ||- U ]< wl >)
46+
(rA : [LogRel@{i j k l} l' | Γ ||- A ]< wl >)
47+
(rAB : [ LogRel@{i j k l} l | Γ ||- A ≅ B : U | rU ]< wl >)
3548
: [ LogRel@{i j k l} l' | Γ ||- A ≅ B | rA ]< wl >.
3649
Proof.
3750
assert [ LogRel@{i j k l} one | Γ ||- A ≅ B : U | LRU_@{i j k l} (redUOne rU) ]< wl > as [ _ _ _ hA _ hAB ] by irrelevance.
3851
eapply LRTyEqIrrelevantCum. exact hAB.
3952
Qed.
4053

54+
Lemma WUnivEqEq@{i j k l} {wl Γ A B l l'} (rU : WLogRel@{i j k l} l wl Γ U)
55+
(rA : WLogRel@{i j k l} l' wl Γ A)
56+
(rAB : WLogRelTmEq@{i j k l} l wl Γ A B U rU)
57+
: WLogRelEq@{i j k l} l' wl Γ A B rA.
58+
Proof.
59+
unshelve eexists (DTree_fusion _ _ _).
60+
+ exact (WTTmEq _ rAB).
61+
+ exact (WT _ rU).
62+
+ intros ; now eapply UnivEqEq, rAB, over_tree_fusion_l.
63+
Unshelve.
64+
now eapply over_tree_fusion_r.
65+
Qed.
4166

4267
(* The lemmas below does not seem to be
4368
at the right levels for fundamental lemma ! *)
Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
From LogRel.AutoSubst Require Import core unscoped Ast Extra.
2-
From LogRel Require Import Utils BasicAst Notations Context NormalForms Weakening GenericTyping LogicalRelation Validity.
2+
From LogRel Require Import Utils BasicAst Notations LContexts Context NormalForms Weakening GenericTyping LogicalRelation Validity.
33
From LogRel.LogicalRelation Require Import Induction Irrelevance Escape Reflexivity Weakening Neutral Transitivity Reduction Application.
44
From LogRel.Substitution Require Import Irrelevance Properties Conversion SingleSubst Reflexivity.
55

@@ -12,41 +12,44 @@ Set Printing Primitive Projection Parameters.
1212

1313
Set Printing Universes.
1414

15-
Lemma appValid {Γ F G t u l}
16-
{VΓ : [||-v Γ]}
17-
{VF : [Γ ||-v<l> F | VΓ]}
18-
{VΠFG : [Γ ||-v<l> tProd F G | VΓ]}
19-
(Vt : [Γ ||-v<l> t : tProd F G | VΓ | VΠFG])
20-
(Vu : [Γ ||-v<l> u : F | VΓ | VF])
15+
Lemma appValid {Γ wl F G t u l}
16+
{VΓ : [||-v Γ]< wl >}
17+
{VF : [Γ ||-v<l> F | VΓ]< wl >}
18+
{VΠFG : [Γ ||-v<l> tProd F G | VΓ]< wl >}
19+
(Vt : [Γ ||-v<l> t : tProd F G | VΓ | VΠFG]< wl >)
20+
(Vu : [Γ ||-v<l> u : F | VΓ | VF]< wl >)
2121
(VGu := substSΠ VΠFG Vu) :
22-
[Γ ||-v<l> tApp t u : G[u..] | VΓ | VGu].
22+
[Γ ||-v<l> tApp t u : G[u..] | VΓ | VGu]< wl >.
2323
Proof.
2424
opector; intros.
2525
- instValid Vσ.
26-
epose (appTerm RVΠFG RVt RVu (substSΠaux VΠFG Vu _ _ wfΔ Vσ)).
27-
irrelevance.
26+
epose (WappTerm RVΠFG RVt RVu (substSΠaux VΠFG Vu _ _ _ f wfΔ Vσ)).
27+
Wirrelevance.
28+
fold subst_term ; now bsimpl.
2829
- instAllValid Vσ Vσ' Vσσ'.
29-
unshelve epose (appcongTerm _ REVt RVu _ REVu (substSΠaux VΠFG Vu _ _ wfΔ Vσ)).
30-
2: irrelevance.
31-
eapply LRTmRedConv; tea.
32-
unshelve eapply LRTyEqSym. 2,3: tea.
30+
unshelve epose (WappcongTerm _ REVt RVu _ REVu (substSΠaux VΠFG Vu _ _ _ f wfΔ Vσ)).
31+
2: Wirrelevance.
32+
eapply WLRTmRedConv; tea.
33+
unshelve eapply WLRTyEqSym. 2,3: tea.
34+
fold subst_term ; now bsimpl.
3335
Qed.
3436

35-
Lemma appcongValid {Γ F G t u a b l}
36-
{VΓ : [||-v Γ]}
37-
{VF : [Γ ||-v<l> F | VΓ]}
38-
{VΠFG : [Γ ||-v<l> tProd F G | VΓ]}
39-
(Vtu : [Γ ||-v<l> t ≅ u : tProd F G | VΓ | VΠFG])
40-
(Va : [Γ ||-v<l> a : F | VΓ | VF])
41-
(Vb : [Γ ||-v<l> b : F | VΓ | VF])
42-
(Vab : [Γ ||-v<l> a ≅ b : F | VΓ | VF])
37+
Lemma appcongValid {Γ wl F G t u a b l}
38+
{VΓ : [||-v Γ]< wl >}
39+
{VF : [Γ ||-v<l> F | VΓ]< wl >}
40+
{VΠFG : [Γ ||-v<l> tProd F G | VΓ]< wl >}
41+
(Vtu : [Γ ||-v<l> t ≅ u : tProd F G | VΓ | VΠFG]< wl >)
42+
(Va : [Γ ||-v<l> a : F | VΓ | VF]< wl >)
43+
(Vb : [Γ ||-v<l> b : F | VΓ | VF]< wl >)
44+
(Vab : [Γ ||-v<l> a ≅ b : F | VΓ | VF]< wl >)
4345
(VGa := substSΠ VΠFG Va) :
44-
[Γ ||-v<l> tApp t a ≅ tApp u b : G[a..] | VΓ | VGa].
46+
[Γ ||-v<l> tApp t a ≅ tApp u b : G[a..] | VΓ | VGa]< wl >.
4547
Proof.
4648
constructor; intros; instValid Vσ.
47-
unshelve epose proof (appcongTerm _ RVtu _ _ _ (substSΠaux VΠFG Va _ _ wfΔ Vσ)); fold subst_term; cycle 5.
48-
all: try irrelevance.
49-
now eapply LRCumulative.
49+
unshelve epose proof (WappcongTerm _ RVtu _ _ _ (substSΠaux VΠFG Va _ _ _ f wfΔ Vσ)); fold subst_term; cycle 5.
50+
all: try Wirrelevance.
51+
1: fold subst_term ; now bsimpl.
52+
now eapply WLRCumulative.
5053
Qed.
5154

5255
End Application.

0 commit comments

Comments
 (0)